mirror of
https://github.com/jokob-sk/NetAlertX.git
synced 2026-04-15 22:51:37 -07:00
Devices view spinner #509🔃
This commit is contained in:
+25
-29
@@ -1459,6 +1459,9 @@ function setDeviceData (direction='', refreshCallback='') {
|
|||||||
window.onbeforeunload = null;
|
window.onbeforeunload = null;
|
||||||
somethingChanged = false;
|
somethingChanged = false;
|
||||||
|
|
||||||
|
// refresh API
|
||||||
|
updateApi()
|
||||||
|
|
||||||
// Callback fuction
|
// Callback fuction
|
||||||
if (typeof refreshCallback == 'function') {
|
if (typeof refreshCallback == 'function') {
|
||||||
refreshCallback(direction);
|
refreshCallback(direction);
|
||||||
@@ -1466,6 +1469,25 @@ function setDeviceData (direction='', refreshCallback='') {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// --------------------------------------------------------
|
||||||
|
// Calls a backend function to add a front-end event to an execution queue
|
||||||
|
function updateApi()
|
||||||
|
{
|
||||||
|
|
||||||
|
// value has to be in format event|param. e.g. run|ARPSCAN
|
||||||
|
action = `update_api|devices`
|
||||||
|
|
||||||
|
$.ajax({
|
||||||
|
method: "POST",
|
||||||
|
url: "php/server/util.php",
|
||||||
|
data: { function: "addToExecutionQueue", action: action },
|
||||||
|
success: function(data, textStatus) {
|
||||||
|
console.log(data)
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
// -----------------------------------------------------------------------------
|
// -----------------------------------------------------------------------------
|
||||||
function askSkipNotifications () {
|
function askSkipNotifications () {
|
||||||
// Check MAC
|
// Check MAC
|
||||||
@@ -1632,36 +1654,10 @@ function deleteDevice () {
|
|||||||
|
|
||||||
// Deactivate controls
|
// Deactivate controls
|
||||||
$('#panDetails :input').attr('disabled', true);
|
$('#panDetails :input').attr('disabled', true);
|
||||||
|
|
||||||
|
// refresh API
|
||||||
|
updateApi()
|
||||||
}
|
}
|
||||||
// -----------------------------------------------------------------------------
|
|
||||||
function askDeleteDevice () {
|
|
||||||
// Check MAC
|
|
||||||
if (mac == '') {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Ask delete device
|
|
||||||
showModalWarning ('Delete Device', 'Are you sure you want to delete this device?<br>(maybe you prefer to archive it)',
|
|
||||||
'<?= lang('Gen_Cancel');?>', '<?= lang('Gen_Delete');?>', 'deleteDevice');
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
// -----------------------------------------------------------------------------
|
|
||||||
function deleteDevice () {
|
|
||||||
// Check MAC
|
|
||||||
if (mac == '') {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Delete device
|
|
||||||
$.get('php/server/devices.php?action=deleteDevice&mac='+ mac, function(msg) {
|
|
||||||
showMessage (msg);
|
|
||||||
});
|
|
||||||
|
|
||||||
// Deactivate controls
|
|
||||||
$('#panDetails :input').attr('disabled', true);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
// -----------------------------------------------------------------------------
|
// -----------------------------------------------------------------------------
|
||||||
function getSessionsPresenceEvents () {
|
function getSessionsPresenceEvents () {
|
||||||
|
|||||||
+19
-9
@@ -288,7 +288,12 @@ function main () {
|
|||||||
initializeDatatable();
|
initializeDatatable();
|
||||||
|
|
||||||
// query data
|
// query data
|
||||||
getDevicesTotals();
|
getDevicesTotals();
|
||||||
|
|
||||||
|
// check if dat outdated and show spinner if so
|
||||||
|
handleLoadingDialog()
|
||||||
|
|
||||||
|
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
@@ -390,7 +395,7 @@ function initializeDatatable (status) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$.get('api/table_devices.json', function(result) {
|
$.get('api/table_devices.json?nocache=' + Date.now(), function(result) {
|
||||||
|
|
||||||
// Filter the data based on deviceStatus
|
// Filter the data based on deviceStatus
|
||||||
var filteredData = filterDataByStatus(result.data, deviceStatus);
|
var filteredData = filterDataByStatus(result.data, deviceStatus);
|
||||||
@@ -641,21 +646,26 @@ function getDevicesTotals () {
|
|||||||
// -----------------------------------------------------------------------------
|
// -----------------------------------------------------------------------------
|
||||||
function handleLoadingDialog()
|
function handleLoadingDialog()
|
||||||
{
|
{
|
||||||
$.get('api/app_state.json?nocache=' + Date.now(), function(appState) {
|
$.get('log/execution_queue.log?nocache=' + Date.now(), function(data) {
|
||||||
|
|
||||||
console.log(appState["showSpinner"])
|
|
||||||
if(appState["showSpinner"])
|
console.log(data)
|
||||||
|
console.log("hree")
|
||||||
|
|
||||||
|
if(data.includes("update_api|devices"))
|
||||||
{
|
{
|
||||||
showSpinner("settings_old")
|
spinnerShown = true;
|
||||||
|
showSpinner("devices_old")
|
||||||
|
|
||||||
setTimeout("handleLoadingDialog()", 1000);
|
setTimeout("handleLoadingDialog()", 1000);
|
||||||
|
|
||||||
} else
|
} else if ($("#loadingSpinner").is(":visible"))
|
||||||
{
|
{
|
||||||
hideSpinner()
|
hideSpinner();
|
||||||
|
location.reload();
|
||||||
}
|
}
|
||||||
|
|
||||||
})
|
})
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -471,6 +471,7 @@
|
|||||||
"settings_missing" : "Not all settings loaded, refresh the page! This is probably caused by a high load on the database or app startup sequence.",
|
"settings_missing" : "Not all settings loaded, refresh the page! This is probably caused by a high load on the database or app startup sequence.",
|
||||||
"settings_missing_block" : "You can not save your settings without specifying all setting keys. Refresh the page. This is probably caused by a high load on the database.",
|
"settings_missing_block" : "You can not save your settings without specifying all setting keys. Refresh the page. This is probably caused by a high load on the database.",
|
||||||
"settings_old" : "Importing settings and re-initializing...",
|
"settings_old" : "Importing settings and re-initializing...",
|
||||||
|
"devices_old" : "Refreshing...",
|
||||||
"settings_saved" : "<br/>Settings saved to the <code>pialert.conf</code> file.<br/><br/>A time-stamped backup of the previous file created. <br/><br/> Reloading...<br/>",
|
"settings_saved" : "<br/>Settings saved to the <code>pialert.conf</code> file.<br/><br/>A time-stamped backup of the previous file created. <br/><br/> Reloading...<br/>",
|
||||||
"settings_system_label" : "System",
|
"settings_system_label" : "System",
|
||||||
"settings_core_label" : "Core",
|
"settings_core_label" : "Core",
|
||||||
|
|||||||
@@ -750,6 +750,9 @@ def check_and_run_user_event(db, pluginsState):
|
|||||||
pluginsState = handle_test(param, db, pluginsState)
|
pluginsState = handle_test(param, db, pluginsState)
|
||||||
if event == 'run':
|
if event == 'run':
|
||||||
pluginsState = handle_run(param, db, pluginsState)
|
pluginsState = handle_run(param, db, pluginsState)
|
||||||
|
if event == 'update_api':
|
||||||
|
# update API endpoints
|
||||||
|
update_api(db, False, param.split(','))
|
||||||
|
|
||||||
# Clear the log file
|
# Clear the log file
|
||||||
open(logFile, "w").close()
|
open(logFile, "w").close()
|
||||||
|
|||||||
Reference in New Issue
Block a user