From 78f90180835cc4bf4a130e76390ae5b749895c14 Mon Sep 17 00:00:00 2001 From: Jokob-sk Date: Tue, 24 Jan 2023 21:58:01 +1100 Subject: [PATCH] Empty fields on New Devices selection --- front/deviceDetails.php | 33 ++++++++++++++++++++++++++++----- front/network.php | 5 +---- 2 files changed, 29 insertions(+), 9 deletions(-) diff --git a/front/deviceDetails.php b/front/deviceDetails.php index 7906ea2c..d50a686b 100755 --- a/front/deviceDetails.php +++ b/front/deviceDetails.php @@ -715,12 +715,15 @@ if ($ENABLED_DARKMODE === True) { // ------------------------------------------------------------ function getDevicesListValue(idColumn, idValue, returnColumn) { - if(emptyArr.includes(devicesList) || emptyArr.includes(idValue)) + // Read cache + devicesListAll = JSON.parse(getCache('devicesListAll')); + + if(emptyArr.includes(devicesListAll) || emptyArr.includes(idValue)) { return ''; } - return devicesList.find((item) => {return item[idColumn] == idValue})[returnColumn] + return devicesListAll.find((item) => {return item[idColumn] == idValue})[returnColumn] } // ------------------------------------------------------------ @@ -741,8 +744,29 @@ if ($ENABLED_DARKMODE === True) { mac = getMac() // can also be rowID!! not only mac var devicesList = []; // this will contain a list the database row IDs of the devices ordered by the position displayed in the UI + var devicesListAll = []; // this will contain a list off all devices + + + $.get('php/server/devices.php?action=getDevicesList&status=all&forceDefaultOrder', function(data) { + + rawData = JSON.parse (data) + + devicesListAll = rawData["data"].map(item => { return { + "name":item[0], + "type":item[2], + "icon":item[3], + "mac":item[11], + "parentMac":item[14], + "rowid":item[13], + "status":item[10] + }}) + + setCache('devicesListAll', JSON.stringify(devicesListAll)) + + // Read parameters & Initialize components + main(); + }); - devicesList = getDevicesList(); var pos = -1; var parPeriod = 'Front_Details_Period'; @@ -759,8 +783,7 @@ if ($ENABLED_DARKMODE === True) { var selectedTab = 'tabDetails'; var emptyArr = ['undefined', "", undefined, null]; - // Read parameters & Initialize components - main(); + // ----------------------------------------------------------------------------- diff --git a/front/network.php b/front/network.php index 54a7d7aa..3831a04d 100755 --- a/front/network.php +++ b/front/network.php @@ -457,8 +457,7 @@