From 5584512bcc9f1a13db8f5f55041c0f58a55cc9fd Mon Sep 17 00:00:00 2001 From: Jokob-sk Date: Wed, 20 Mar 2024 08:16:12 +1100 Subject: [PATCH] pytz debug #596 --- dockerfiles/setup.sh | 28 ++++++++++++++-------------- front/js/pialert_common.js | 19 +++++++++++++++---- 2 files changed, 29 insertions(+), 18 deletions(-) diff --git a/dockerfiles/setup.sh b/dockerfiles/setup.sh index fdf68eb9..8cfd0b65 100755 --- a/dockerfiles/setup.sh +++ b/dockerfiles/setup.sh @@ -34,23 +34,23 @@ fi cp -na "${INSTALL_DIR}/pialert/back/pialert.conf" "${INSTALL_DIR}/pialert/config/pialert.conf" cp -na "${INSTALL_DIR}/pialert/back/pialert.db" "${FILEDB}" -# if custom variables not set we do not need to do anything -if [ -n "${TZ}" ]; then - FILECONF="${INSTALL_DIR}/pialert/config/pialert.conf" - echo "[INSTALL] Setup timezone" - sed -i "\#^TIMEZONE=#c\TIMEZONE='${TZ}'" "${FILECONF}" -fi - # # if custom variables not set we do not need to do anything -# if [ -n "${TZ}" ]; then -# FILECONF=$INSTALL_DIR/pialert/config/pialert.conf -# if [ -f "$FILECONF" ]; then -# sed -ie "s|Europe/Berlin|${TZ}|g" $INSTALL_DIR/pialert/config/pialert.conf -# else -# sed -ie "s|Europe/Berlin|${TZ}|g" $INSTALL_DIR/pialert/back/pialert.conf_bak -# fi +# if [ -n "${TZ}" ]; then +# FILECONF="${INSTALL_DIR}/pialert/config/pialert.conf" +# echo "[INSTALL] Setup timezone" +# sed -i "\#^TIMEZONE=#c\TIMEZONE='${TZ}'" "${FILECONF}" # fi +# if custom variables not set we do not need to do anything +if [ -n "${TZ}" ]; then + FILECONF=$INSTALL_DIR/pialert/config/pialert.conf + if [ -f "$FILECONF" ]; then + sed -ie "s|Europe/Berlin|${TZ}|g" $INSTALL_DIR/pialert/config/pialert.conf + else + sed -ie "s|Europe/Berlin|${TZ}|g" $INSTALL_DIR/pialert/back/pialert.conf_bak + fi +fi + echo "[INSTALL] Setup NGINX" echo "Setting webserver to address ($LISTEN_ADDR) and port ($PORT)" envsubst '$INSTALL_DIR $LISTEN_ADDR $PORT' < "${INSTALL_DIR}/pialert/install/pialert.template.conf" > "${NGINX_CONFIG_FILE}" diff --git a/front/js/pialert_common.js b/front/js/pialert_common.js index 7804f62f..87e31ed7 100755 --- a/front/js/pialert_common.js +++ b/front/js/pialert_common.js @@ -229,7 +229,7 @@ function cacheStrings() function getString (key) { // handle initial laod to make sure everything is set-up and cached - handleFirstLoad() + handleFirstLoad(getString) UI_LANG = getSetting("UI_LANG"); @@ -1084,6 +1084,8 @@ function arraysContainSameValues(arr1, arr2) { // ----------------------------------------------------------------------------- // initialize // ----------------------------------------------------------------------------- +// ----------------------------------------------------------------------------- + // Define a unique key for storing the flag in sessionStorage var sessionStorageKey = "myScriptExecuted_pialert_common"; @@ -1130,17 +1132,18 @@ $.get('api/app_state.json?nocache=' + Date.now(), function(appState) { // ----------------------------------------------------------------------------- // Display spinner and reload page if not yet initialized -function handleFirstLoad() +function handleFirstLoad(callback) { if(!pialert_common_init) { setTimeout(function() { - location.reload(); + callback(); }, 1000); } } + // ----------------------------------------------------------------------------- // Check if the code has been executed before by checking sessionStorage var pialert_common_init = sessionStorage.getItem(sessionStorageKey) === "true"; @@ -1152,7 +1155,7 @@ function executeOnce() { resetInitializedFlag() - showSpinner() + // to keep track of completed AJAX calls completedCalls = [] @@ -1162,6 +1165,14 @@ function executeOnce() { cacheSettings(); cacheStrings(); initDeviceListAll_JSON(); + + showSpinner() + + // reload ONCE after all caches initialized + setTimeout(() => { + location.reload() + }, 500); + } }