Skip to content

Commit

Permalink
var
Browse files Browse the repository at this point in the history
  • Loading branch information
jack-blackson committed Feb 6, 2024
1 parent 7367135 commit 67b8d1b
Show file tree
Hide file tree
Showing 3 changed files with 62 additions and 30 deletions.
14 changes: 9 additions & 5 deletions admin/index_m.html
Original file line number Diff line number Diff line change
Expand Up @@ -124,10 +124,6 @@
function findGeoCode(){
console.log('Start import geocode')
document.getElementById("loader").style.display = "block";
//$('#loader1').removeClass('seenot');

//const geoCodeJSON = require('./meteoalarm/geocodes.json')
//turf = require('@turf/turf')

$.getJSON('geocodes.json', function(data) {

Expand All @@ -137,13 +133,16 @@


locationArray = []
var geocodeNameArray = []

for(let i = 0; i < crs.length; i++) {
var loccode = crs[i].properties.code
let polygon = JSON.stringify(crs[i].geometry.coordinates)
let type = JSON.stringify(crs[i].properties.type)
let geocodeLocation = crs[i].properties.name
if (checkIfInPoly(polygon)){
locationArray.push(loccode)
geocodeNameArray.push(geocodeLocation)
}

//console.log('Code: ' + loccode)
Expand All @@ -156,6 +155,8 @@

// geocode gefunden
$("#geocode").val(locationArray);
$("#geocodeLocation").val(geocodeNameArray);

}
else{
console.log('Geocode not found')
Expand Down Expand Up @@ -536,7 +537,7 @@ <h6 class="title translate" data-lang="regionsetup">chooseAlarmLocation</h6>
</div>
<div>

<div class="column">
<div class="column ">
<input type="text" id="lat" class="value" />
<label for="lat" class="translate">lattitude</label>
</div>
Expand Down Expand Up @@ -567,6 +568,9 @@ <h6 class="title translate" data-lang="regionsetup">chooseAlarmLocation</h6>
</div>

<div class="col" style="width:20%">
<input type="text" id="geocodeLocation" class="value" readonly/>
</div>
<div class="col" style="width:20%" hidden>
<input type="text" id="geocode" class="value" readonly/>
</div>

Expand Down
45 changes: 44 additions & 1 deletion io-package.json
Original file line number Diff line number Diff line change
Expand Up @@ -256,7 +256,50 @@
"sentry": {
"dsn": "https://[email protected]/124"
}
}
},
"messages": [
{
"condition": {
"operand": "and",
"rules": [
"oldVersion<3.0.0",
"newVersion>=3.0.0"
]
},
"title": {
"en": "Important notice!",
"de": "Wichtiger Hinweis!",
"ru": "Важное замечание!",
"pt": "Notícia importante!",
"nl": "Belangrijke mededeling!",
"fr": "Avis important!",
"it": "Avviso IMPORTANTE!",
"es": "Noticia importante!",
"pl": "Ważna uwaga!",
"zh-cn": "重要通知!",
"uk": "Важливе повідомлення!"
},
"text": {
"en": "This update contains a breaking change. Please go to the setup and maintain the location. Otherwise, the alarms will not work any more.",
"de": "Dieses Update enthält eine kritische Änderung. Bitte gehen Sie zum Setup und halten Sie den Standort. Sonst funktionieren die Alarme nicht mehr.",
"ru": "Это обновление содержит нарушающие изменения. Пожалуйста, отправляйтесь на установку и сохраняйте местоположение. В противном случае тревога больше не будет работать.",
"pt": "Esta atualização contém uma mudança de ruptura. Por favor, vá para a configuração e mantenha a localização. Caso contrário, os alarmes não funcionarão mais.",
"nl": "Deze update bevat een breuk verandering. Ga naar de setup en onderhoud de locatie. Anders werkt het alarm niet meer.",
"fr": "Cette mise à jour contient un changement de rupture. Veuillez aller à l'installation et maintenir l'emplacement. Sinon, les alarmes ne fonctionneront plus.",
"it": "Questo aggiornamento contiene un cambiamento di rottura. Si prega di andare alla configurazione e mantenere la posizione. Altrimenti, gli allarmi non funzioneranno più.",
"es": "Esta actualización contiene un cambio de ruptura. Por favor, vaya a la configuración y mantenga la ubicación. De lo contrario, las alarmas ya no funcionarán.",
"pl": "Ta aktualizacja zawiera przełomową zmianę. Proszę przejść do ustawienia i utrzymać lokalizację. Inaczej alarmy już nie będą działać.",
"uk": "Цей оновлення містить зміни розриву. Будь ласка, перейдемо на налаштування та підтримує розташування. В іншому випадку сигналізація не працює.",
"zh-cn": "此更新包含一个突破性的更改 。 请到设置处维持位置. 否则,警报就会失效."
},
"level": "warn",
"buttons": [
"agree",
"cancel"
]
}
]

},
"adminUI": {
"config": "materialize"
Expand Down
33 changes: 9 additions & 24 deletions main.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ var DescFilter1 = '';
var DescFilter2 = '';
var country = '';
var countryConfig = '';
var geocodeLocationConfig = []
//var regionConfig = '';
var latConfig = '';
var longConfig = '';
Expand All @@ -42,7 +43,7 @@ var typeArray = [];
var urlArray = [];

var regionCSV = ""
var regionName = ""
//var regionName = ""
var xmlLanguage = ""
const warnMessages = {};

Expand Down Expand Up @@ -238,6 +239,7 @@ function initialSetup(){
locationArray = adapter.config.geocode

countryConfig = adapter.config.country
geocodeLocationConfig = adapter.config.geocodeLocation
imageSizeSetup = Number(adapter.config.imageSize)

adapter.log.debug('0.0 Initial setup loaded')
Expand Down Expand Up @@ -267,7 +269,7 @@ async function getData(){
adapter.terminate ? adapter.terminate(0) : process.exit(0);
}
else{
adapter.log.debug('0.1 Setup found: country ' + countryConfig + ' with geocode(s) ' + locationArray + ' and location Lat ' + latConfig + ' Long ' + longConfig )
adapter.log.debug('0.1 Setup found: country ' + countryConfig + ' with geocode(s) ' + locationArray + ' for location ' + geocodeLocationConfig+ ' and Lat ' + latConfig + ' Long ' + longConfig )
if (Sentry){
adapter.log.debug('Sentry aktiv - Breadcrumb gesetzt')
Sentry.addBreadcrumb({
Expand Down Expand Up @@ -636,7 +638,7 @@ async function getData(){
await Promise.all([
adapter.setStateAsync({device: '' , channel: '',state: 'level'}, {val: maxAlarmLevel, ack: true}),
adapter.setStateAsync({device: '' , channel: '',state: 'htmlToday'}, {val: htmlCode, ack: true}),
adapter.setStateAsync({device: '' , channel: '',state: 'location'}, {val: regionName, ack: true}),
adapter.setStateAsync({device: '' , channel: '',state: 'location'}, {val: geocodeLocationConfig, ack: true}),
adapter.setStateAsync({device: '' , channel: '',state: 'link'}, {val: urlAtom, ack: true}),
adapter.setStateAsync({device: '' , channel: '',state: 'color'}, {val: getColor(maxAlarmLevel.toString()), ack: true}),
adapter.setStateAsync({device: '' , channel: '',state: 'noOfAlarms'}, {val: warningCount, ack: true}),
Expand All @@ -650,8 +652,8 @@ async function getData(){


adapter.log.debug('15: All Done')
if (regionName){
adapter.log.info('15.1: Updated Weather Alarms for ' + regionName + ' -> ' + warningCount + ' alarm(s) found')
if (geocodeLocationConfig){
adapter.log.info('15.1: Updated Weather Alarms for ' + geocodeLocationConfig + ' -> ' + warningCount + ' alarm(s) found')
}

adapter.terminate ? adapter.terminate('All data processed. Adapter stopped until next scheduled process.') : process.exit(0);
Expand Down Expand Up @@ -1074,7 +1076,7 @@ async function processNotifications(alarms){
}
var region = ""
if (adapter.config.showLocation){
region = ' - ' + regionName
region = ' - ' + geocodeLocationConfig
}

var notificationLevel = getNotificationLevel(alarms.Level)
Expand All @@ -1094,7 +1096,7 @@ async function processNotifications(alarms){
adapter.log.debug('14.1.1: Warning for "All warnings ended" sent')
var region = ""
if (adapter.config.showLocation){
region = ' - ' + regionName
region = ' - ' + geocodeLocationConfig
}
var notificationLevel = getNotificationLevel(1)
var notificationText = notificationLevel + region + ': ' + i18nHelper.warningsLifted[lang]
Expand Down Expand Up @@ -1397,23 +1399,6 @@ async function processDetails(content, countInt,detailsType,detailsIdentifier,de
}
//adapter.log.debug('geocodes.array length ' + geoCodesArray.length)

for(let h = 0; h < geoCodesArray.length; h++) {
//adapter.log.debug('EMMA ID: ' + geoCodesArray[h].valueName + ' - ' + geoCodesArray[h].value)
//adapter.log.debug('Location Array: ' + locationArray)
//adapter.log.debug('Incouded: ' + locationArray.includes(geoCodesArray[h].value))
if (geoCodesArray[h].valueName == "EMMA_ID" && (locationArray.includes(geoCodesArray[h].value))){
adapter.log.debug(' Region found - ' + areaData[i].areaDesc)
if (regionName ==""){
regionName = areaData[i].areaDesc
}
else{
if (!regionName.includes(areaData[i].areaDesc)){
regionName += ', ' + areaData[i].areaDesc
}
}
}
}

//adapter.log.debug('Location : ' + areaData[i].areaDesc)

}
Expand Down

0 comments on commit 67b8d1b

Please sign in to comment.