From 9bd5ff10b449ef8ed8ccb7ca1931d7cc8c4bedd8 Mon Sep 17 00:00:00 2001 From: jokob-sk Date: Mon, 2 Sep 2024 09:15:49 +1000 Subject: [PATCH] =?UTF-8?q?=F0=9F=93=A1=20Upgrade=20->=20Show=20message?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- front/php/templates/language/cs_cz.json | 2 ++ front/php/templates/language/de_de.json | 2 ++ front/php/templates/language/en_us.json | 2 ++ front/php/templates/language/es_es.json | 4 +++- front/php/templates/language/fr_fr.json | 4 +++- front/php/templates/language/it_it.json | 2 ++ front/php/templates/language/nb_no.json | 2 ++ front/php/templates/language/pl_pl.json | 2 ++ front/php/templates/language/pt_br.json | 2 ++ front/php/templates/language/ru_ru.json | 4 +++- front/php/templates/language/tr_tr.json | 2 ++ front/php/templates/language/zh_cn.json | 4 +++- server/initialise.py | 18 ++++++++++++++---- 13 files changed, 42 insertions(+), 8 deletions(-) diff --git a/front/php/templates/language/cs_cz.json b/front/php/templates/language/cs_cz.json index caafd50c..1dbe57ac 100755 --- a/front/php/templates/language/cs_cz.json +++ b/front/php/templates/language/cs_cz.json @@ -654,6 +654,8 @@ "UI_PRESENCE_name": "", "UI_REFRESH_description": "", "UI_REFRESH_name": "", + "VERSION_description": "", + "VERSION_name": "", "devices_old": "", "general_event_description": "", "general_event_title": "", diff --git a/front/php/templates/language/de_de.json b/front/php/templates/language/de_de.json index 3553438b..894f8727 100755 --- a/front/php/templates/language/de_de.json +++ b/front/php/templates/language/de_de.json @@ -723,6 +723,8 @@ "UI_PRESENCE_name": "Anzeige im Präsenzdiagramm", "UI_REFRESH_description": "", "UI_REFRESH_name": "Automatisch Aktualisieren", + "VERSION_description": "", + "VERSION_name": "", "WEBHOOK_PAYLOAD_description": "The Webhook payload data format for the body > attachments > text attribute in the payload json. See an example of the payload here. (e.g.: for discord use text)", "WEBHOOK_PAYLOAD_name": "Payload type", "WEBHOOK_REQUEST_METHOD_description": "The HTTP request method to be used for the webhook call.", diff --git a/front/php/templates/language/en_us.json b/front/php/templates/language/en_us.json index 265e1424..5d37cbde 100755 --- a/front/php/templates/language/en_us.json +++ b/front/php/templates/language/en_us.json @@ -654,6 +654,8 @@ "UI_PRESENCE_name": "Show in presence chart", "UI_REFRESH_description": "Enter number of seconds after which the UI reloads. Set to 0 to disable.", "UI_REFRESH_name": "Auto-refresh UI", + "VERSION_description": "Version timestamp helper value to check if app was upgarded.", + "VERSION_name": "Version timestamp", "devices_old": "Refreshing...", "general_event_description": "The event you have triggered might take a while until background processes finish. The execution ended once the below execution queue empties (Check the error log if you encounter issues).

Execution queue:", "general_event_title": "Executing an ad-hoc event", diff --git a/front/php/templates/language/es_es.json b/front/php/templates/language/es_es.json index 853efa7b..5196bb7e 100755 --- a/front/php/templates/language/es_es.json +++ b/front/php/templates/language/es_es.json @@ -723,6 +723,8 @@ "UI_PRESENCE_name": "Mostrar en el gráfico de presencia", "UI_REFRESH_description": "Ingrese el número de segundos después de los cuales se recarga la interfaz de usuario. Ajustado a 0 para desactivar.", "UI_REFRESH_name": "Actualización automática de la interfaz de usuario", + "VERSION_description": "", + "VERSION_name": "", "WEBHOOK_PAYLOAD_description": "El formato de datos de carga de Webhook para el atributo body > attachments > text en el json de carga. Vea un ejemplo de la carga aquí. (por ejemplo: para discord use text)", "WEBHOOK_PAYLOAD_name": "Tipo de carga", "WEBHOOK_REQUEST_METHOD_description": "El método de solicitud HTTP que se utilizará para la llamada de webhook.", @@ -770,4 +772,4 @@ "settings_update_item_warning": "Actualice el valor a continuación. Tenga cuidado de seguir el formato anterior. O la validación no se realiza.", "test_event_icon": "fa-vial-circle-check", "test_event_tooltip": "Guarda tus cambios antes de probar nuevos ajustes." -} +} \ No newline at end of file diff --git a/front/php/templates/language/fr_fr.json b/front/php/templates/language/fr_fr.json index 094c00da..13677bc4 100755 --- a/front/php/templates/language/fr_fr.json +++ b/front/php/templates/language/fr_fr.json @@ -654,6 +654,8 @@ "UI_PRESENCE_name": "Afficher dans le graphique de présence", "UI_REFRESH_description": "Renseignez le nombre de secondes après lequel rafraîchir l'interface graphique. Renseignez 0 pour désactiver.", "UI_REFRESH_name": "Rafraîchir automatiquement l'interface graphique", + "VERSION_description": "", + "VERSION_name": "", "devices_old": "Rafraichissement...", "general_event_description": "L'événement que vous avez lancé peut prendre du temps avant que les tâches de fond ne soit terminées. La durée d'exécution finira une fois que la file d'exécution ci-dessous sera vide (consulter les journaux d'erreur si vous rencontrez des erreurs).

File d'exécution :", "general_event_title": "Lancement d'un événement sur mesure", @@ -690,4 +692,4 @@ "settings_update_item_warning": "Mettre à jour la valeur ci-dessous. Veillez à bien suivre le même format qu'auparavant. Il n'y a pas de pas de contrôle.", "test_event_icon": "fa-vial-circle-check", "test_event_tooltip": "Enregistrer d'abord vos modifications avant de tester vôtre paramétrage." -} +} \ No newline at end of file diff --git a/front/php/templates/language/it_it.json b/front/php/templates/language/it_it.json index 9fbcd0e5..554f9466 100755 --- a/front/php/templates/language/it_it.json +++ b/front/php/templates/language/it_it.json @@ -654,6 +654,8 @@ "UI_PRESENCE_name": "Mostra nel grafico delle presenze", "UI_REFRESH_description": "Inserisci il numero di secondi dopo il quale la UI si ricarica. Imposta a 0 per disabilitare.", "UI_REFRESH_name": "Aggiorna automaticamente la UI", + "VERSION_description": "", + "VERSION_name": "", "devices_old": "Aggiornamento...", "general_event_description": "L'evento che hai attivato potrebbe richiedere del tempo prima che i processi in background vengano completati. L'esecuzione è terminata una volta che la coda di esecuzione sottostante si è svuotata (controlla il log degli errori se riscontri problemi).

Coda di esecuzione:", "general_event_title": "Esecuzione di un evento ad-hoc", diff --git a/front/php/templates/language/nb_no.json b/front/php/templates/language/nb_no.json index c84b2aec..db96982e 100755 --- a/front/php/templates/language/nb_no.json +++ b/front/php/templates/language/nb_no.json @@ -654,6 +654,8 @@ "UI_PRESENCE_name": "Vis i tilstedeværelse-diagrammet", "UI_REFRESH_description": "Skriv inn antall sekunder før UI laster inn på nytt. Sett til 0 for å deaktivere.", "UI_REFRESH_name": "Oppdater UI automatisk", + "VERSION_description": "", + "VERSION_name": "", "devices_old": "Oppdaterer...", "general_event_description": "Hendelsen du har utløst kan ta en stund til før bakgrunnsprosesser er ferdig. Utførelsen ble avsluttet når utførelseskøen nedenfor tømmes (sjekk Feillogg Hvis du møter problemer).

Utførelseskø:", "general_event_title": "Utfører en ad-hoc hendelse", diff --git a/front/php/templates/language/pl_pl.json b/front/php/templates/language/pl_pl.json index 3f6a2e1e..6f7a8b8c 100755 --- a/front/php/templates/language/pl_pl.json +++ b/front/php/templates/language/pl_pl.json @@ -654,6 +654,8 @@ "UI_PRESENCE_name": "Pokaż w tabeli obecności", "UI_REFRESH_description": "Wprowadź liczbę sekund po której UI ma się przeładować. Ustaw na 0 by wyłączyć.", "UI_REFRESH_name": "Automatycznie odświeżaj UI", + "VERSION_description": "", + "VERSION_name": "", "devices_old": "Odświeżanie...", "general_event_description": "Wydarzenie które wyzwoliłeś może chwilę zająć dopóki procesy w tle nie zakończą się. Wykonanie zakończy się kiedy kolejka się opróżni (Sprawdź logi błędów jeżeli napotkasz błędy).

Kolejka wykonywania:", "general_event_title": "Wykonywanie wydarzeń ad-hoc", diff --git a/front/php/templates/language/pt_br.json b/front/php/templates/language/pt_br.json index cab9da8e..52ba564d 100755 --- a/front/php/templates/language/pt_br.json +++ b/front/php/templates/language/pt_br.json @@ -654,6 +654,8 @@ "UI_PRESENCE_name": "", "UI_REFRESH_description": "", "UI_REFRESH_name": "", + "VERSION_description": "", + "VERSION_name": "", "devices_old": "", "general_event_description": "", "general_event_title": "", diff --git a/front/php/templates/language/ru_ru.json b/front/php/templates/language/ru_ru.json index c6da6c00..29a4bb6e 100755 --- a/front/php/templates/language/ru_ru.json +++ b/front/php/templates/language/ru_ru.json @@ -654,6 +654,8 @@ "UI_PRESENCE_name": "Показать в диаграмме присутствия", "UI_REFRESH_description": "Введите количество секунд, по истечении которых пользовательский интерфейс перезагружается. Установите значение 0, чтобы отключить.", "UI_REFRESH_name": "Автоматическое обновление интерфейса", + "VERSION_description": "", + "VERSION_name": "", "devices_old": "Актуализируется...", "general_event_description": "Событие, которое вы инициировали, может занять некоторое время, прежде чем фоновые процессы завершатся. Выполнение завершится, как только очередь выполнения, указанная ниже, опустеет (Проверьте журнал ошибок при возникновении проблем).

· · Очередь выполнения:", "general_event_title": "Выполнение специального события", @@ -690,4 +692,4 @@ "settings_update_item_warning": "Обновить значение ниже. Будьте осторожны, следуя предыдущему формату. Проверка не выполняется.", "test_event_icon": "fa-vial-circle-check", "test_event_tooltip": "Сначала сохраните изменения, прежде чем проверять настройки." -} +} \ No newline at end of file diff --git a/front/php/templates/language/tr_tr.json b/front/php/templates/language/tr_tr.json index da453335..adae9f74 100755 --- a/front/php/templates/language/tr_tr.json +++ b/front/php/templates/language/tr_tr.json @@ -654,6 +654,8 @@ "UI_PRESENCE_name": "", "UI_REFRESH_description": "", "UI_REFRESH_name": "", + "VERSION_description": "", + "VERSION_name": "", "devices_old": "Yenileniyor...", "general_event_description": "", "general_event_title": "", diff --git a/front/php/templates/language/zh_cn.json b/front/php/templates/language/zh_cn.json index 4695c490..c9b7377c 100755 --- a/front/php/templates/language/zh_cn.json +++ b/front/php/templates/language/zh_cn.json @@ -654,6 +654,8 @@ "UI_PRESENCE_name": "在存在图表中显示", "UI_REFRESH_description": "输入界面重新加载的秒数。设置为 0 可禁用。", "UI_REFRESH_name": "自动刷新界面", + "VERSION_description": "", + "VERSION_name": "", "devices_old": "刷新中...", "general_event_description": "您触发的事件可能需要一段时间才能完成后台进程。一旦以下执行队列清空,执行就会结束(如果遇到问题,请检查错误日志)。

执行队列:", "general_event_title": "执行自组织网络事件", @@ -690,4 +692,4 @@ "settings_update_item_warning": "更新下面的值。请注意遵循先前的格式。未执行验证。", "test_event_icon": "", "test_event_tooltip": "在测试设置之前,请先保存更改。" -} +} \ No newline at end of file diff --git a/server/initialise.py b/server/initialise.py index 50c3df77..0ddfd5e0 100755 --- a/server/initialise.py +++ b/server/initialise.py @@ -11,13 +11,14 @@ import re import conf -from const import fullConfPath -from helper import collect_lang_strings, updateSubnets, initOrSetParam, isJsonObject, updateState, setting_value_to_python_type +from const import fullConfPath, applicationPath +from helper import collect_lang_strings, updateSubnets, initOrSetParam, isJsonObject, updateState, setting_value_to_python_type, timeNowTZ from logger import mylog from api import update_api from scheduler import schedule_class from plugin import print_plugin_info, run_plugin_scripts from plugin_utils import get_plugins_configs, get_plugin_setting_obj +from notification import write_notification #=============================================================================== # Initialise user defined values @@ -140,6 +141,7 @@ def importConfigs (db, all_plugins): conf.DAYS_TO_KEEP_EVENTS = ccd('DAYS_TO_KEEP_EVENTS', 90 , c_d, 'Delete events days', '{"dataType":"integer", "elements": [{"elementType" : "input", "elementOptions" : [{"type": "number"}] ,"transformers": []}]}', '[]', 'General') conf.HRS_TO_KEEP_NEWDEV = ccd('HRS_TO_KEEP_NEWDEV', 0 , c_d, 'Keep new devices for', '{"dataType":"integer", "elements": [{"elementType" : "input", "elementOptions" : [{"type": "number"}] ,"transformers": []}]}', "[]", 'General') conf.API_CUSTOM_SQL = ccd('API_CUSTOM_SQL', 'SELECT * FROM Devices WHERE dev_PresentLastScan = 0' , c_d, 'Custom endpoint', '{"dataType":"string", "elements": [{"elementType" : "input", "elementOptions" : [] ,"transformers": []}]}', '[]', 'General') + conf.VERSION = ccd('VERSION', '' , c_d, 'Version', '{"dataType":"string", "elements": [{"elementType" : "input", "elementOptions" : [{ "readonly": "true" }] ,"transformers": []}]}', '', 'General') conf.NETWORK_DEVICE_TYPES = ccd('NETWORK_DEVICE_TYPES', ['AP', 'Gateway', 'Firewall', 'Hypervisor', 'Powerline', 'Switch', 'WLAN', 'PLC', 'Router','USB LAN Adapter', 'USB WIFI Adapter', 'Internet'] , c_d, 'Network device types', '{"dataType":"array","elements":[{"elementType":"input","elementOptions":[{"placeholder":"Enter value"},{"suffix":"_in"},{"cssClasses":"col-sm-10"},{"prefillValue":"null"}],"transformers":[]},{"elementType":"button","elementOptions":[{"sourceSuffixes":["_in"]},{"separator":""},{"cssClasses":"col-xs-12"},{"onClick":"addList(this,false)"},{"getStringKey":"Gen_Add"}],"transformers":[]},{"elementType":"select", "elementHasInputValue":1,"elementOptions":[{"multiple":"true"},{"readonly":"true"},{"editable":"true"}],"transformers":[]},{"elementType":"button","elementOptions":[{"sourceSuffixes":[]},{"separator":""},{"cssClasses":"col-xs-6"},{"onClick":"removeAllOptions(this)"},{"getStringKey":"Gen_Remove_All"}],"transformers":[]},{"elementType":"button","elementOptions":[{"sourceSuffixes":[]},{"separator":""},{"cssClasses":"col-xs-6"},{"onClick":"removeFromList(this)"},{"getStringKey":"Gen_Remove_Last"}],"transformers":[]}]}', '[]', 'General') # UI @@ -285,8 +287,7 @@ def importConfigs (db, all_plugins): for plugin in all_plugins: pref = plugin["unique_prefix"] loaded_plugins_prefixes.append(pref) - - + # save the newly discovered plugins as options and default values conf.LOADED_PLUGINS = ccd('LOADED_PLUGINS', loaded_plugins_prefixes , c_d, 'Loaded plugins', '{"dataType":"array", "elements": [{"elementType" : "select", "elementOptions" : [{"multiple":"true"}] ,"transformers": []}]}', str(sorted(all_plugins_prefixes)), 'General') @@ -297,6 +298,15 @@ def importConfigs (db, all_plugins): # ----------------- # Plugins END + # manage upgrade + with open(applicationPath + '/front/buildtimestamp.txt', 'r') as f: + buildTimestamp = int(f.read().strip()) + + if conf.VERSION != buildTimestamp: + conf.VERSION = ccd('VERSION', buildTimestamp , c_d, 'Version', '{"dataType":"string", "elements": [{"elementType" : "input", "elementOptions" : [{ "readonly": "true" }] ,"transformers": []}]}', '', 'General') + + write_notification(f'[Upgrade] : App upgarded, please clear cache.', 'interrupt', timeNowTZ()) + # Insert settings into the DB sql.execute ("DELETE FROM Settings")