multi-edit floating, no-cache headers 🔘

This commit is contained in:
Jokob-sk
2024-03-16 10:40:18 +11:00
parent a99dbaef78
commit 23aa1e4e85
7 changed files with 59 additions and 21 deletions

View File

@@ -43,7 +43,7 @@ fi
echo "[INSTALL] Setup NGINX" echo "[INSTALL] Setup NGINX"
echo "Setting webserver to address ($LISTEN_ADDR) and port ($PORT)" 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 # Run the hardware vendors update at least once
echo "[INSTALL] Run the hardware vendors update" echo "[INSTALL] Run the hardware vendors update"

View File

@@ -1060,6 +1060,17 @@ input[readonly] {
height:50px; height:50px;
} }
/* -----------------------------------------------------------------------------
Floating edit button
----------------------------------------------------------------------------- */
#multiEditPlc
{
position: fixed;
bottom: 50px;
right: 0px;
z-index: 10;
}
/* ----------------------------------------------------------------------------- /* -----------------------------------------------------------------------------
Donations Donations
----------------------------------------------------------------------------- */ ----------------------------------------------------------------------------- */

View File

@@ -148,10 +148,9 @@
<!-- box-header --> <!-- box-header -->
<div class="box-header"> <div class="box-header">
<div class=" col-md-10 "> <div class=" col-md-10 ">
<h3 id="tableDevicesTitle" class="box-title text-gray "></h3> <h3 id="tableDevicesTitle" class="box-title text-gray "></h3>
</div> </div>
<div id="multiEditPlc" class="col-md-2"></div>
</div> </div>
<!-- table --> <!-- table -->
@@ -176,6 +175,7 @@
<!-- ----------------------------------------------------------------------- --> <!-- ----------------------------------------------------------------------- -->
</section> </section>
<!-- /.content --> <!-- /.content -->
<div id="multiEditPlc" class="col-md-2"></div>
</div> </div>
<!-- /.content-wrapper --> <!-- /.content-wrapper -->

View File

@@ -28,15 +28,15 @@ function getCache(key, noCookie = false)
// check cache // check cache
cachedValue = localStorage.getItem(key) cachedValue = localStorage.getItem(key)
console.log(cachedValue); // console.log(cachedValue);
if(cachedValue) if(cachedValue)
{ {
// check if not expired // // check if not expired
if(noCookie || getCookie(key + '_session_expiry') != "") // if(noCookie || getCookie(key + '_session_expiry') != "")
{ // {
return cachedValue; return cachedValue;
} // }
} }
return ""; return "";
@@ -47,11 +47,11 @@ function setCache(key, data, expirationMinutes='')
{ {
localStorage.setItem(key, data); localStorage.setItem(key, data);
// create cookie if expiration set to handle refresh of data // // create cookie if expiration set to handle refresh of data
if (expirationMinutes != '') // if (expirationMinutes != '')
{ // {
setCookie (key + '_session_expiry', 'OK', expirationMinutes='') // setCookie ('cache_session_expiry', 'OK', 1)
} // }
} }
@@ -229,10 +229,16 @@ function cacheStrings()
function getString (key) { function getString (key) {
// handle initial laod to make sure everything is set-up and cached // handle initial laod to make sure everything is set-up and cached
// handleFirstLoad() handleFirstLoad()
UI_LANG = getSetting("UI_LANG"); UI_LANG = getSetting("UI_LANG");
// //
// if(UI_LANG == "")
// {
// }
lang_code = 'en_us'; lang_code = 'en_us';
switch(UI_LANG) switch(UI_LANG)
@@ -865,7 +871,7 @@ function initDeviceListAll_JSON()
$.get('api/table_devices.json', function(data) { $.get('api/table_devices.json', function(data) {
console.log(data) // console.log(data)
devicesListAll_JSON = data["data"] devicesListAll_JSON = data["data"]
@@ -878,9 +884,13 @@ function initDeviceListAll_JSON()
}, 1000); }, 1000);
} }
// console.log("devicesListAll_JSON_str");
// console.log(devicesListAll_JSON_str);
setCache('devicesListAll_JSON', 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 }).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 // Define a unique key for storing the flag in sessionStorage
var sessionStorageKey = "myScriptExecuted_pialert_common"; var sessionStorageKey = "myScriptExecuted_pialert_common";
// -----------------------------------------------------------------------------
// Clearing all the caches
function clearCache()
{
resetInitializedFlag()
window.location.reload()
}
// ----------------------------------------------------------------------------- // -----------------------------------------------------------------------------
function resetInitializedFlag() function resetInitializedFlag()
{ {
// Clear local storage
localStorage.clear();
// Set the flag in sessionStorage to indicate that the code and cahce needs to be reloaded // Set the flag in sessionStorage to indicate that the code and cahce needs to be reloaded
sessionStorage.setItem(sessionStorageKey, "false"); sessionStorage.setItem(sessionStorageKey, "false");
} }
@@ -1122,6 +1143,8 @@ function executeOnce() {
if (!pialert_common_init) { if (!pialert_common_init) {
resetInitializedFlag()
showSpinner() showSpinner()
// Counter to keep track of completed AJAX calls // Counter to keep track of completed AJAX calls

View File

@@ -151,14 +151,14 @@ if ($ENABLED_DARKMODE === True) {
<li> <li>
<a id="next-button" href="javascript:history.go(1);" role="button" span class='of-bt-icon'><i class='fa fa-arrow-right'></i></a> <a id="next-button" href="javascript:history.go(1);" role="button" span class='of-bt-icon'><i class='fa fa-arrow-right'></i></a>
</li> </li>
<!-- Reload --> <!-- Clear cache & Reload -->
<li> <li>
<a id="reload-button" href='#' role="button" span class='of-bt-icon' onclick='location.reload()'><i class='fa fa-repeat'></i></a> <a id="reload-button" href='#' role="button" span class='of-bt-icon' onclick='clearCache()'><i class='fa fa-repeat'></i></a>
</li> </li>
<!-- Full Screen --> <!-- Full Screen -->
<li> <li>
<a id="fullscreen-button" href='#' role="button" span class='of-bt-icon' onclick='toggleFullscreen()'><i class='fa fa-arrows-alt'></i></a> <a id="fullscreen-button" href='#' role="button" span class='of-bt-icon' onclick='toggleFullscreen()'><i class='fa fa-arrows-alt'></i></a>
</li> </li>
<!-- Server Status --> <!-- Server Status -->
<li> <li>
<a onclick="setCache('activeMaintenanceTab', 'tab_Logging_id')" href="maintenance.php#tab_Logging"> <a onclick="setCache('activeMaintenanceTab', 'tab_Logging_id')" href="maintenance.php#tab_Logging">

View File

@@ -7,6 +7,8 @@ server {
proxy_set_header X-Forwarded-Prefix "/pialert"; proxy_set_header X-Forwarded-Prefix "/pialert";
location ~* \.php$ { 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; fastcgi_pass unix:/run/php/php8.2-fpm.sock;
include fastcgi_params; include fastcgi_params;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;

View File

@@ -6,6 +6,8 @@ server {
proxy_set_header X-Forwarded-Prefix "/pialert"; proxy_set_header X-Forwarded-Prefix "/pialert";
location ~* \.php$ { 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; fastcgi_pass unix:/run/php/php8.2-fpm.sock;
include fastcgi_params; include fastcgi_params;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;