Archived devices were shown #920

This commit is contained in:
jokob-sk
2024-12-28 09:19:25 +11:00
parent fa570b9bc9
commit 4fef6e156b
12 changed files with 117 additions and 54 deletions
+27
View File
@@ -1416,6 +1416,7 @@ input[readonly] {
display: inline-block; display: inline-block;
padding: 0.1em; padding: 0.1em;
margin: 0.1em; margin: 0.1em;
/* transition: font-size 0.3s;*/
} }
.devicePropAction:hover .devicePropAction:hover
@@ -1426,6 +1427,32 @@ input[readonly] {
} }
#panDetails .dataTables_wrapper .bottom div
{
max-width: 34%;
display: block;
float:inline-end;
height: 2em;
}
#panDetails .dataTables_wrapper .bottom .dataTables_info
{
float:inline-start;
}
#panDetails .dataTables_wrapper .bottom .dataTables_length
{
padding: 0.3em;
}
/* #panDetails .dataTables_wrapper .bottom .paging_simple_numbers */
#panDetails #NEWDEV_devCustomProps_label
{
display: none;
}
/* ----------------------------------------------------------------- */ /* ----------------------------------------------------------------- */
/* MODAL popups */ /* MODAL popups */
/* ----------------------------------------------------------------- */ /* ----------------------------------------------------------------- */
+1 -1
View File
@@ -211,7 +211,7 @@
// Generate the input field HTML // Generate the input field HTML
const inputFormHtml = `<div class="form-group col-xs-12"> const inputFormHtml = `<div class="form-group col-xs-12">
<label class="${obj.labelClasses}"> ${setting.setName} <label id="${setting.setKey}_label" class="${obj.labelClasses}" > ${setting.setName}
<i my-set-key="${setting.setKey}" <i my-set-key="${setting.setKey}"
title="${getString("Settings_Show_Description")}" title="${getString("Settings_Show_Description")}"
class="fa fa-circle-info pointer helpIconSmallTopRight" class="fa fa-circle-info pointer helpIconSmallTopRight"
+43 -38
View File
@@ -295,46 +295,46 @@ function renderInfoboxes(customData) {
}); });
} }
// ----------------------------------------------------------------------------- // // -----------------------------------------------------------------------------
// Define a function to filter data based on deviceStatus // // Define a function to filter data based on deviceStatus
function filterDataByStatus(data, status) { // function filterDataByStatus(data, status) {
return data.filter(function(item) { // return data.filter(function(item) {
switch (status) { // switch (status) {
case 'my_devices': // case 'my_devices':
to_display = getSetting('UI_MY_DEVICES'); // to_display = getSetting('UI_MY_DEVICES');
let result = true; // let result = true;
if (!to_display.includes('down') && item.devPresentLastScan === 0 && item.devAlertDown !== 0) { // if (!to_display.includes('down') && item.devPresentLastScan === 0 && item.devAlertDown !== 0) {
result = false; // result = false;
} else if (!to_display.includes('new') && item.devIsNew === 1) { // } else if (!to_display.includes('new') && item.devIsNew === 1) {
result = false; // result = false;
} else if (!to_display.includes('archived') && item.devIsArchived === 1) { // } else if (!to_display.includes('archived') && item.devIsArchived === 1) {
result = false; // result = false;
} else if (!to_display.includes('offline') && item.devPresentLastScan === 0) { // } else if (!to_display.includes('offline') && item.devPresentLastScan === 0) {
result = false; // result = false;
} else if (!to_display.includes('online') && item.devPresentLastScan === 1) { // } else if (!to_display.includes('online') && item.devPresentLastScan === 1) {
result = false; // result = false;
} // }
return result; // Include all items for 'my_devices' status // return result; // Include all items for 'my_devices' status
case 'connected': // case 'connected':
return item.devPresentLastScan === 1; // return item.devPresentLastScan === 1;
case 'favorites': // case 'favorites':
return item.devFavorite === 1; // return item.devFavorite === 1;
case 'new': // case 'new':
return item.devIsNew === 1; // return item.devIsNew === 1;
case 'offline': // case 'offline':
return item.devPresentLastScan === 0; // return item.devPresentLastScan === 0;
case 'down': // case 'down':
return (item.devPresentLastScan === 0 && item.devAlertDown !== 0); // return (item.devPresentLastScan === 0 && item.devAlertDown !== 0);
case 'archived': // case 'archived':
return item.devIsArchived === 1; // return item.devIsArchived === 1;
default: // default:
return true; // Include all items for unknown statuses // return true; // Include all items for unknown statuses
} // }
}); // });
} // }
// Map column index to column name for GraphQL query // Map column index to column name for GraphQL query
@@ -792,6 +792,11 @@ function initializeDatatable (status) {
hideSpinner(); hideSpinner();
},
createdRow: function(row, data, dataIndex) {
// add devMac to the table row
$(row).attr('my-devMac', data[mapIndx(11)]);
} }
}); });
@@ -919,7 +924,7 @@ function renderCustomProps(custProps, mac) {
onClickEvent = `alert('Not implemented')`; onClickEvent = `alert('Not implemented')`;
break; break;
case "delete_dev": case "delete_dev":
onClickEvent = `deleteDeviceByMac('${mac}')`; onClickEvent = `askDelDevDTInline('${mac}')`;
break; break;
default: default:
break; break;
+25 -2
View File
@@ -8,8 +8,27 @@ function askDeleteDevice () {
} }
// Ask delete device // Ask delete device
showModalWarning ('Delete Device', 'Are you sure you want to delete this device?<br>(maybe you prefer to archive it)', showModalWarning(
getString('Gen_Cancel'), getString('Gen_Delete'), 'deleteDevice'); getString("DevDetail_button_Delete"),
getString("DevDetail_button_Delete_ask"),
getString('Gen_Cancel'),
getString('Gen_Delete'),
'deleteDevice');
}
// -----------------------------------------------------------------------------
function askDelDevDTInline(mac) {
// Check MAC
if (mac == '') {
return;
}
showModalWarning(
getString("DevDetail_button_Delete"),
getString("DevDetail_button_Delete_ask"),
getString('Gen_Cancel'),
getString('Gen_Delete'),
() => deleteDeviceByMac(mac))
} }
@@ -36,6 +55,9 @@ function deleteDeviceByMac (mac) {
return; return;
} }
// alert(mac)
// return;
// Delete device // Delete device
$.get('php/server/devices.php?action=deleteDevice&mac=' + mac, function (msg) { $.get('php/server/devices.php?action=deleteDevice&mac=' + mac, function (msg) {
showMessage(msg); showMessage(msg);
@@ -45,3 +67,4 @@ function deleteDeviceByMac (mac) {
updateApi("devices,appevents") updateApi("devices,appevents")
} }
+6 -1
View File
@@ -65,7 +65,8 @@ function showModalWarning(
message, message,
btnCancel = getString("Gen_Cancel"), btnCancel = getString("Gen_Cancel"),
btnOK = getString("Gen_Okay"), btnOK = getString("Gen_Okay"),
callbackFunction = null callbackFunction = null,
triggeredBy = null
) { ) {
// set captions // set captions
$("#modal-warning-title").html(title); $("#modal-warning-title").html(title);
@@ -77,6 +78,10 @@ function showModalWarning(
modalCallbackFunction = callbackFunction; modalCallbackFunction = callbackFunction;
} }
if (triggeredBy != null) {
$('#'+prefix).attr("data-myparam-triggered-by", triggeredBy)
}
// Show modal // Show modal
$("#modal-warning").modal("show"); $("#modal-warning").modal("show");
} }
+2 -1
View File
@@ -1159,7 +1159,8 @@ function generateFormHtml(settingsData, set, overrideValue, overrideOptions, ori
$(document).ready(() => { $(document).ready(() => {
$(`#${tableId}`).DataTable({ $(`#${tableId}`).DataTable({
ordering: false, // Disables sorting on all columns ordering: false, // Disables sorting on all columns
searching: false // Disables the search box searching: false, // Disables the search box
dom: "<'top'rt><'bottom'ipl>", // Move length dropdown to the bottom
}); });
}); });
+1
View File
@@ -183,6 +183,7 @@
"DevDetail_button_AddIcon_Help": "Paste in an SVG html tag or Font Awesome html tag icon. Read the <a href=\"https://github.com/jokob-sk/NetAlertX/blob/main/docs/ICONS.md\" target=\"_blank\">Icons docs</a> for details.", "DevDetail_button_AddIcon_Help": "Paste in an SVG html tag or Font Awesome html tag icon. Read the <a href=\"https://github.com/jokob-sk/NetAlertX/blob/main/docs/ICONS.md\" target=\"_blank\">Icons docs</a> for details.",
"DevDetail_button_AddIcon_Tooltip": "Add a new Icon to this device that is not yet available in the dropdown.", "DevDetail_button_AddIcon_Tooltip": "Add a new Icon to this device that is not yet available in the dropdown.",
"DevDetail_button_Delete": "Delete Device", "DevDetail_button_Delete": "Delete Device",
"DevDetail_button_Delete_ask": "Are you sure you want to delete this device? You may also archive it instead.",
"DevDetail_button_DeleteEvents": "Delete Events", "DevDetail_button_DeleteEvents": "Delete Events",
"DevDetail_button_DeleteEvents_Warning": "Are you sure you want to delete all Events of this device?<br><br>(this will clear the <b>Events history</b> and the <b>Sessions</b> and might help with constant (persistent) notifications)", "DevDetail_button_DeleteEvents_Warning": "Are you sure you want to delete all Events of this device?<br><br>(this will clear the <b>Events history</b> and the <b>Sessions</b> and might help with constant (persistent) notifications)",
"DevDetail_button_OverwriteIcons": "Overwrite Icons", "DevDetail_button_OverwriteIcons": "Overwrite Icons",
View File
Regular → Executable
View File
Regular → Executable
View File
+1 -1
View File
@@ -88,7 +88,7 @@ sql_devices_tiles = """
FROM Devices FROM Devices
WHERE WHERE
(instr((SELECT setValue FROM Statuses), 'online') > 0 AND devPresentLastScan = 1) OR (instr((SELECT setValue FROM Statuses), 'online') > 0 AND devPresentLastScan = 1) OR
(instr((SELECT setValue FROM Statuses), 'offline') > 0 AND devPresentLastScan = 0) OR (instr((SELECT setValue FROM Statuses), 'offline') > 0 AND devPresentLastScan = 0 AND devIsArchived = 0) OR
(instr((SELECT setValue FROM Statuses), 'down') > 0 AND devPresentLastScan = 0 AND devAlertDown = 1) OR (instr((SELECT setValue FROM Statuses), 'down') > 0 AND devPresentLastScan = 0 AND devAlertDown = 1) OR
(instr((SELECT setValue FROM Statuses), 'new') > 0 AND devIsNew = 1) OR (instr((SELECT setValue FROM Statuses), 'new') > 0 AND devIsNew = 1) OR
(instr((SELECT setValue FROM Statuses), 'archived') > 0 AND devIsArchived = 1) (instr((SELECT setValue FROM Statuses), 'archived') > 0 AND devIsArchived = 1)
+2 -1
View File
@@ -142,7 +142,8 @@ class Query(ObjectType):
(device["devPresentLastScan"] == 1 and 'online' in allowed_statuses) or (device["devPresentLastScan"] == 1 and 'online' in allowed_statuses) or
(device["devIsNew"] == 1 and 'new' in allowed_statuses) or (device["devIsNew"] == 1 and 'new' in allowed_statuses) or
(device["devPresentLastScan"] == 0 and device["devAlertDown"] and 'down' in allowed_statuses) or (device["devPresentLastScan"] == 0 and device["devAlertDown"] and 'down' in allowed_statuses) or
(device["devPresentLastScan"] == 0 and 'offline' in allowed_statuses) (device["devPresentLastScan"] == 0 and 'offline' in allowed_statuses) and device["devIsArchived"] == 0 or
(device["devIsArchived"] == 1 and 'archived' in allowed_statuses)
) )
] ]
elif status == "connected": elif status == "connected":