From 23aa1e4e85313ce8f9ab0967924a000c3d7d2240 Mon Sep 17 00:00:00 2001 From: Jokob-sk Date: Sat, 16 Mar 2024 10:40:18 +1100 Subject: [PATCH] =?UTF-8?q?multi-edit=20floating,=20no-cache=20headers=20?= =?UTF-8?q?=F0=9F=94=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- dockerfiles/setup.sh | 2 +- front/css/pialert.css | 11 +++++ front/devices.php | 8 +-- front/js/pialert_common.js | 49 ++++++++++++++----- front/php/templates/header.php | 6 +-- install/pialert.debian.conf | 2 + ...rt.conf.template => pialert.template.conf} | 2 + 7 files changed, 59 insertions(+), 21 deletions(-) rename install/{pialert.conf.template => pialert.template.conf} (84%) diff --git a/dockerfiles/setup.sh b/dockerfiles/setup.sh index e8aec200..495ef2e7 100755 --- a/dockerfiles/setup.sh +++ b/dockerfiles/setup.sh @@ -43,7 +43,7 @@ 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.conf.template" > "${NGINX_CONFIG_FILE}" +envsubst '$INSTALL_DIR $LISTEN_ADDR $PORT' < "${INSTALL_DIR}/pialert/install/pialert.template.conf" > "${NGINX_CONFIG_FILE}" # Run the hardware vendors update at least once echo "[INSTALL] Run the hardware vendors update" diff --git a/front/css/pialert.css b/front/css/pialert.css index 746f0537..2b1224d9 100755 --- a/front/css/pialert.css +++ b/front/css/pialert.css @@ -1060,6 +1060,17 @@ input[readonly] { height:50px; } +/* ----------------------------------------------------------------------------- + Floating edit button +----------------------------------------------------------------------------- */ +#multiEditPlc +{ + position: fixed; + bottom: 50px; + right: 0px; + z-index: 10; +} + /* ----------------------------------------------------------------------------- Donations ----------------------------------------------------------------------------- */ diff --git a/front/devices.php b/front/devices.php index 86d3a063..4f56430a 100755 --- a/front/devices.php +++ b/front/devices.php @@ -148,10 +148,9 @@
-
-

-
-
+
+

+
@@ -176,6 +175,7 @@ +
diff --git a/front/js/pialert_common.js b/front/js/pialert_common.js index 3b8739be..7c3bf55d 100755 --- a/front/js/pialert_common.js +++ b/front/js/pialert_common.js @@ -28,15 +28,15 @@ function getCache(key, noCookie = false) // check cache cachedValue = localStorage.getItem(key) - console.log(cachedValue); + // console.log(cachedValue); if(cachedValue) { - // check if not expired - if(noCookie || getCookie(key + '_session_expiry') != "") - { + // // check if not expired + // if(noCookie || getCookie(key + '_session_expiry') != "") + // { return cachedValue; - } + // } } return ""; @@ -47,11 +47,11 @@ function setCache(key, data, expirationMinutes='') { localStorage.setItem(key, data); - // create cookie if expiration set to handle refresh of data - if (expirationMinutes != '') - { - setCookie (key + '_session_expiry', 'OK', expirationMinutes='') - } + // // create cookie if expiration set to handle refresh of data + // if (expirationMinutes != '') + // { + // setCookie ('cache_session_expiry', 'OK', 1) + // } } @@ -229,10 +229,16 @@ function cacheStrings() function getString (key) { // handle initial laod to make sure everything is set-up and cached - // handleFirstLoad() + handleFirstLoad() UI_LANG = getSetting("UI_LANG"); + // // + // if(UI_LANG == "") + // { + + // } + lang_code = 'en_us'; switch(UI_LANG) @@ -865,7 +871,7 @@ function initDeviceListAll_JSON() $.get('api/table_devices.json', function(data) { - console.log(data) + // console.log(data) devicesListAll_JSON = data["data"] @@ -878,9 +884,13 @@ function initDeviceListAll_JSON() }, 1000); } + + // console.log("devicesListAll_JSON_str"); + // console.log(devicesListAll_JSON_str); + setCache('devicesListAll_JSON', devicesListAll_JSON_str) - console.log(getCache('devicesListAll_JSON')) + // console.log(getCache('devicesListAll_JSON')) }).then(() => handleSuccess('initDeviceListAll_JSON')).catch(() => handleFailure('initDeviceListAll_JSON')); // handle AJAX synchronization } @@ -1070,9 +1080,20 @@ function resolveParams(params, template) { // Define a unique key for storing the flag in sessionStorage var sessionStorageKey = "myScriptExecuted_pialert_common"; +// ----------------------------------------------------------------------------- +// Clearing all the caches +function clearCache() +{ + resetInitializedFlag() + window.location.reload() +} + + // ----------------------------------------------------------------------------- function resetInitializedFlag() { + // Clear local storage + localStorage.clear(); // Set the flag in sessionStorage to indicate that the code and cahce needs to be reloaded sessionStorage.setItem(sessionStorageKey, "false"); } @@ -1122,6 +1143,8 @@ function executeOnce() { if (!pialert_common_init) { + resetInitializedFlag() + showSpinner() // Counter to keep track of completed AJAX calls diff --git a/front/php/templates/header.php b/front/php/templates/header.php index 9eb9c03b..ed9081ca 100755 --- a/front/php/templates/header.php +++ b/front/php/templates/header.php @@ -151,14 +151,14 @@ if ($ENABLED_DARKMODE === True) {
  • - +
  • - +
  • -
  • +
  • diff --git a/install/pialert.debian.conf b/install/pialert.debian.conf index 88db31dc..81134d52 100755 --- a/install/pialert.debian.conf +++ b/install/pialert.debian.conf @@ -7,6 +7,8 @@ server { proxy_set_header X-Forwarded-Prefix "/pialert"; location ~* \.php$ { + # Set Cache-Control header to prevent caching on the first load + add_header Cache-Control "no-store"; fastcgi_pass unix:/run/php/php8.2-fpm.sock; include fastcgi_params; fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; diff --git a/install/pialert.conf.template b/install/pialert.template.conf similarity index 84% rename from install/pialert.conf.template rename to install/pialert.template.conf index 6e71e12b..e2d526a1 100755 --- a/install/pialert.conf.template +++ b/install/pialert.template.conf @@ -6,6 +6,8 @@ server { proxy_set_header X-Forwarded-Prefix "/pialert"; location ~* \.php$ { + # Set Cache-Control header to prevent caching on the first load + add_header Cache-Control "no-store"; fastcgi_pass unix:/run/php/php8.2-fpm.sock; include fastcgi_params; fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;