Add next scan ETA display and update app state with scan timing information

This commit is contained in:
Jokob @NetAlertX
2026-03-03 04:07:22 +00:00
parent 95f411d92a
commit ab74307ed1
24 changed files with 254 additions and 8 deletions

View File

@@ -43,7 +43,9 @@ class app_state_class:
processScan=False,
pluginsStates=None,
appVersion=None,
buildTimestamp=None
buildTimestamp=None,
last_scan_run=None,
next_scan_time=None
):
"""
Initialize the application state, optionally overwriting previous values.
@@ -89,6 +91,8 @@ class app_state_class:
self.pluginsStates = previousState.get("pluginsStates", {})
self.appVersion = previousState.get("appVersion", "")
self.buildTimestamp = previousState.get("buildTimestamp", "")
self.last_scan_run = previousState.get("last_scan_run", "")
self.next_scan_time = previousState.get("next_scan_time", "")
else: # init first time values
self.settingsSaved = 0
self.settingsImported = 0
@@ -101,6 +105,8 @@ class app_state_class:
self.pluginsStates = {}
self.appVersion = ""
self.buildTimestamp = ""
self.last_scan_run = ""
self.next_scan_time = ""
# Overwrite with provided parameters if supplied
if settingsSaved is not None:
@@ -133,6 +139,10 @@ class app_state_class:
self.appVersion = appVersion
if buildTimestamp is not None:
self.buildTimestamp = buildTimestamp
if last_scan_run is not None:
self.last_scan_run = last_scan_run
if next_scan_time is not None:
self.next_scan_time = next_scan_time
# check for new version every hour and if currently not running new version
if self.isNewVersion is False and self.isNewVersionChecked + 3600 < int(
timeNowUTC(as_string=False).timestamp()
@@ -165,7 +175,9 @@ class app_state_class:
self.settingsImported,
timestamp=self.lastUpdated,
appVersion=self.appVersion,
buildTimestamp=self.buildTimestamp
buildTimestamp=self.buildTimestamp,
last_scan_run=self.last_scan_run,
next_scan_time=self.next_scan_time
)
except Exception as e:
mylog("none", [f"[app_state] SSE broadcast: {e}"])
@@ -183,7 +195,9 @@ def updateState(newState = None,
processScan = None,
pluginsStates=None,
appVersion=None,
buildTimestamp=None):
buildTimestamp=None,
last_scan_run=None,
next_scan_time=None):
"""
Convenience method to create or update the app state.
@@ -197,6 +211,8 @@ def updateState(newState = None,
pluginsStates (dict, optional): Plugin state updates.
appVersion (str, optional): Application version.
buildTimestamp (str, optional): Build timestamp.
last_scan_run (str, optional): ISO timestamp of last backend scan run.
next_scan_time (str, optional): ISO timestamp of next scheduled device_scanner run.
Returns:
app_state_class: Updated state object.
@@ -210,7 +226,9 @@ def updateState(newState = None,
processScan,
pluginsStates,
appVersion,
buildTimestamp
buildTimestamp,
last_scan_run,
next_scan_time
)