diff --git a/.env b/.env index 7ac7cf6a..c75c843a 100644 --- a/.env +++ b/.env @@ -2,5 +2,9 @@ APP_DATA_LOCATION=/path/to/docker_appdata APP_CONFIG_LOCATION=/path/to/docker_config LOGS_LOCATION=/path/to/docker_logs +TZ=Europe/Paris +HOST_USER_ID=1000 +HOST_USER_GID=1000 +PORT=20211 diff --git a/README.md b/README.md index d5d95bde..a495bf29 100644 --- a/README.md +++ b/README.md @@ -23,7 +23,7 @@ JavaScript)* 📚 [Dockerfile instructions](https://github.com/jokob-sk/Pi.Alert/blob/main//dockerfiles/README.md). ![Main screen dark][main_dark] -Dark mode (and Activity over the last x scans) within this fork courtesy of [leiweibau](https://github.com/leiweibau/Pi.Alert) +Dark mode (and Device presence over time) within this fork courtesy of [leiweibau](https://github.com/leiweibau/Pi.Alert) ## How it works The system continuously scans the network for: @@ -164,7 +164,7 @@ Linux distributions. This code is a collaborative body of work, with special thanks to: - - [leiweibau](https://github.com/leiweibau/Pi.Alert): Dark mode (and Last X scans activity chart) + - [leiweibau](https://github.com/leiweibau/Pi.Alert): Dark mode (and Device presence over time) - [Macleykun](https://github.com/Macleykun): Help with Dockerfile clean-up - [Final-Hawk](https://github.com/Final-Hawk): Help with NTFY, styling and other fixes - Please see the [Git commit history](https://github.com/jokob-sk/Pi.Alert/commits/main) for a full list of people and their contributions to the project diff --git a/back/pialert.py b/back/pialert.py index 3cc7c5bb..268aa023 100644 --- a/back/pialert.py +++ b/back/pialert.py @@ -1480,17 +1480,31 @@ def send_email (pText, pHTML): #=============================================================================== # DB #=============================================================================== -def upgradeDB (): +def upgradeDB (): openDB() - # check if table exists - listOfTables = sql.execute( - """SELECT name FROM sqlite_master WHERE type='table' - AND name='Online_History'; """).fetchall() + # indicates, if Online_History table is available + onlineHistoryAvailable = sql.execute(""" + SELECT name FROM sqlite_master WHERE type='table' + AND name='Online_History'; + """).fetchall() != [] + + # Check if it is incompatible (Check if table has all required columns) + isIncompatible = False - if listOfTables == []: - print_log ('Upgrading DB (creating Online_History table)') + if onlineHistoryAvailable : + isIncompatible = sql.execute (""" + SELECT COUNT(*) AS CNTREC FROM pragma_table_info('Online_History') WHERE name='Archived_Devices' + """).fetchone()[0] == 0 + + # Drop table if available, but incompatible + if onlineHistoryAvailable and isIncompatible: + print_log ('Table is incompatible, Dropping the Online_History table)') + sql.execute("DROP TABLE Online_History;") + onlineHistoryAvailable = False + + if onlineHistoryAvailable == False : sql.execute(""" CREATE TABLE "Online_History" ( "Index" INTEGER, @@ -1503,6 +1517,7 @@ def upgradeDB (): ); """) + #------------------------------------------------------------------------------- def openDB (): diff --git a/docker-compose.yml b/docker-compose.yml index f629723b..b1ec288d 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -10,7 +10,7 @@ services: - ${APP_DATA_LOCATION}/pialert/db/pialert.db:/home/pi/pialert/db/pialert.db - ${LOGS_LOCATION}/tmp:/home/pi/pialert/log environment: - - TZ=Europe/London - - PORT=20211 - - HOST_USER_ID=1000 - - HOST_USER_GID=1000 + - TZ=${TZ} + - PORT=${PORT} + - HOST_USER_ID=${HOST_USER_ID} + - HOST_USER_GID=${HOST_USER_GID} diff --git a/front/devices.php b/front/devices.php index 3e8563d4..91b2326d 100644 --- a/front/devices.php +++ b/front/devices.php @@ -106,7 +106,7 @@
-

12

+

diff --git a/front/php/templates/language/de_de.php b/front/php/templates/language/de_de.php index 9d613253..a7dafeaa 100644 --- a/front/php/templates/language/de_de.php +++ b/front/php/templates/language/de_de.php @@ -15,8 +15,7 @@ $pia_lang['Device_Shortcut_NewDevices'] = 'Neue Geräte'; $pia_lang['Device_Shortcut_DownAlerts'] = 'Down Meldungen'; $pia_lang['Device_Shortcut_Archived'] = 'Archiviert'; $pia_lang['Device_Shortcut_Devices'] = 'Geräte'; -$pia_lang['Device_Shortcut_OnlineChart_a'] = 'Netzwerkaktivität über die letzten'; -$pia_lang['Device_Shortcut_OnlineChart_b'] = 'Stunden'; +$pia_lang['Device_Shortcut_OnlineChart'] = 'Gerätepräsenz im Laufe der Zeit'; $pia_lang['Device_TableHead_Name'] = 'Name'; $pia_lang['Device_TableHead_Owner'] = 'Eigentümer'; $pia_lang['Device_TableHead_Type'] = 'Typ'; diff --git a/front/php/templates/language/en_us.php b/front/php/templates/language/en_us.php index 3a98ebc8..046eb4c5 100644 --- a/front/php/templates/language/en_us.php +++ b/front/php/templates/language/en_us.php @@ -15,8 +15,7 @@ $pia_lang['Device_Shortcut_NewDevices'] = 'New Devices'; $pia_lang['Device_Shortcut_DownAlerts'] = 'Down Alerts'; $pia_lang['Device_Shortcut_Archived'] = 'Archived'; $pia_lang['Device_Shortcut_Devices'] = 'Devices'; -$pia_lang['Device_Shortcut_OnlineChart_a'] = 'Network activity over last'; -$pia_lang['Device_Shortcut_OnlineChart_b'] = 'hours'; +$pia_lang['Device_Shortcut_OnlineChart'] = 'Device presence over time'; $pia_lang['Device_TableHead_Name'] = 'Name'; $pia_lang['Device_TableHead_Owner'] = 'Owner'; $pia_lang['Device_TableHead_Type'] = 'Type'; diff --git a/front/php/templates/language/es_es.php b/front/php/templates/language/es_es.php index 59615751..4c7c7419 100644 --- a/front/php/templates/language/es_es.php +++ b/front/php/templates/language/es_es.php @@ -15,8 +15,7 @@ $pia_lang['Device_Shortcut_NewDevices'] = 'Nuevos dispositivos'; $pia_lang['Device_Shortcut_DownAlerts'] = 'Alertas de caídas'; $pia_lang['Device_Shortcut_Archived'] = 'Archivada'; $pia_lang['Device_Shortcut_Devices'] = 'Dispositivos'; -$pia_lang['Device_Shortcut_OnlineChart_a'] = 'Actividad de la red durante el último'; -$pia_lang['Device_Shortcut_OnlineChart_b'] = 'horas'; +$pia_lang['Device_Shortcut_OnlineChart'] = 'Presencia del dispositivo a lo largo del tiempo'; $pia_lang['Device_TableHead_Name'] = 'Nombre'; $pia_lang['Device_TableHead_Owner'] = 'Propietario'; $pia_lang['Device_TableHead_Type'] = 'Tipo'; diff --git a/front/presence.php b/front/presence.php index 5ab20310..e90ed99c 100644 --- a/front/presence.php +++ b/front/presence.php @@ -106,7 +106,7 @@
-

12

+