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 "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"

View File

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

View File

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

View File

@@ -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

View File

@@ -151,14 +151,14 @@ if ($ENABLED_DARKMODE === True) {
<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>
</li>
<!-- Reload -->
<!-- Clear cache & Reload -->
<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>
<!-- Full Screen -->
<li>
<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 -->
<li>
<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";
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;

View File

@@ -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;