diff --git a/front/deviceDetails.php b/front/deviceDetails.php index d0a0b3e0..3bf89c35 100755 --- a/front/deviceDetails.php +++ b/front/deviceDetails.php @@ -1755,7 +1755,7 @@ function loadNmap() \
\ \ - \ + \
\ \ '; diff --git a/front/devices.php b/front/devices.php index 02a1e465..72c5ab55 100755 --- a/front/devices.php +++ b/front/devices.php @@ -237,6 +237,9 @@ function main () { $.get('php/server/parameters.php?action=get&defaultValue=[[3,"desc"],[0,"asc"]]¶meter='+ parTableOrder, function(data) { var result = JSON.parse(data); result = JSON.parse(result); + + + if (Array.isArray (result) ) { tableOrder = result; } @@ -253,9 +256,16 @@ function main () { } // ----------------------------------------------------------------------------- +var tableColumnHide = []; + +function mapIndx(oldIndex) +{ + newIndex = oldIndex; + return newIndex; +} + + function initializeDatatable () { - // - var tableColumnHide = []; for(i = 0; i < tableColumnAll.length; i++) { // hide this coolumn if not in the tableColumnShow variable @@ -292,19 +302,19 @@ function initializeDatatable () { 'columnDefs' : [ {visible: false, targets: tableColumnHide }, - {className: 'text-center', targets: [3, 4, 9, 10] }, - {width: '80px', targets: [6, 7] }, - {width: '30px', targets: [10, 13] }, - {orderData: [11], targets: 8 }, + {className: 'text-center', targets: [mapIndx(3), mapIndx(4), mapIndx(9), mapIndx(10)] }, + {width: '80px', targets: [mapIndx(6), mapIndx(7)] }, + {width: '30px', targets: [mapIndx(10), mapIndx(13)] }, + {orderData: [mapIndx(11)], targets: mapIndx(8) }, // Device Name - {targets: [0], + {targets: [mapIndx(0)], 'createdCell': function (td, cellData, rowData, row, col) { $(td).html (''+ cellData +''); } }, // Icon - {targets: [3], + {targets: [mapIndx(3)], 'createdCell': function (td, cellData, rowData, row, col) { if (!emptyArr.includes(cellData)){ $(td).html (''); @@ -314,7 +324,7 @@ function initializeDatatable () { } }, // Favorite // {targets: [3], - {targets: [4], + {targets: [mapIndx(4)], 'createdCell': function (td, cellData, rowData, row, col) { if (cellData == 1){ $(td).html (''); @@ -325,14 +335,14 @@ function initializeDatatable () { // Dates // {targets: [5, 6], - {targets: [6, 7], + {targets: [mapIndx(6), mapIndx(7)], 'createdCell': function (td, cellData, rowData, row, col) { $(td).html (translateHTMLcodes (cellData)); } }, // Random MAC // {targets: [8], - {targets: [9], + {targets: [mapIndx(9)], 'createdCell': function (td, cellData, rowData, row, col) { if (cellData == 1){ $(td).html (''); @@ -343,7 +353,7 @@ function initializeDatatable () { // Status color // {targets: [9], - {targets: [10], + {targets: [mapIndx(10)], 'createdCell': function (td, cellData, rowData, row, col) { switch (cellData) { case 'Down': color='red'; break; @@ -395,11 +405,11 @@ function initializeDatatable () { function getDevicesFromTable(table) { // rowIDs = table.column(12, { 'search': 'applied' }).data().toArray() // rowID is in hidden column 12 - rowIDs = table.column(13, { 'search': 'applied' }).data().toArray() // rowID is in hidden column 12 + rowIDs = table.column(mapIndx(13), { 'search': 'applied' }).data().toArray() // rowID is in hidden column 12 // rowMACs = table.column(10, { 'search': 'applied' }).data().toArray() // MAC is in hidden column 10 - rowMACs = table.column(11, { 'search': 'applied' }).data().toArray() // MAC is in hidden column 10 - rowNames = table.column(0, { 'search': 'applied' }).data().toArray() // - rowTypes = table.column(2, { 'search': 'applied' }).data().toArray() // + rowMACs = table.column(mapIndx(11), { 'search': 'applied' }).data().toArray() // MAC is in hidden column 10 + rowNames = table.column(mapIndx(0), { 'search': 'applied' }).data().toArray() // + rowTypes = table.column(mapIndx(2), { 'search': 'applied' }).data().toArray() // result = [] diff --git a/front/js/helper_objects.js b/front/js/helper_objects.js new file mode 100644 index 00000000..ffa85a93 --- /dev/null +++ b/front/js/helper_objects.js @@ -0,0 +1 @@ +var deviceColumns = {'Icon':4, 'Owner':5} \ No newline at end of file diff --git a/front/maintenance.php b/front/maintenance.php index e8012f79..1b548656 100755 --- a/front/maintenance.php +++ b/front/maintenance.php @@ -252,25 +252,28 @@ if (isset($_POST['submit']) && submit && isset($_POST['skinselector_set'])) {
-
- - -
+
+
+ + +
+
+
@@ -509,6 +512,8 @@ if (isset($_POST['submit']) && submit && isset($_POST['skinselector_set'])) { + + + - \ No newline at end of file diff --git a/front/php/server/devices.php b/front/php/server/devices.php index 1ddd8db4..d6798fea 100755 --- a/front/php/server/devices.php +++ b/front/php/server/devices.php @@ -12,7 +12,7 @@ require '/home/pi/pialert/front/php/templates/timezone.php'; require '/home/pi/pialert/front/php/templates/language/lang.php'; require '/home/pi/pialert/front/php/server/db.php'; - require '/home/pi/pialert/front/php/server/util.php'; + require '/home/pi/pialert/front/php/server/util.php'; //------------------------------------------------------------------------------ // Action selector @@ -569,6 +569,51 @@ function getDevicesTotals() { function getDevicesList() { global $db; + + $columnOrderMapping = array( + array("dev_Name", 0, -1), // 2 + array("dev_Owner", 1, -1), // 5 + array("dev_DeviceType", 2, -1), // 6 + array("dev_Icon", 3, -1), // 0 + array("dev_Favorite", 4, -1), // 7 + array("dev_Group", 5, -1), // 8 + array("dev_FirstConnection", 6, -1), // 9 + array("dev_LastConnection", 7, -1), // 10 + array("dev_LastIP", 8, -1), // 4 + array("dev_MAC", 9, -1), // 11 + array("dev_Status", 10, -1), // 1 + array("dev_MAC_full", 11, -1), // 3 + array("dev_LastIP_orderable", 12, -1), // 12 + array("rowid", 13, -1) // 13 + ); + + // get device columns order + $sql = 'SELECT par_Value FROM Parameters where par_ID = "Front_Devices_Columns"'; + $result = $db->query($sql); + $row = $result -> fetchArray (SQLITE3_NUM); + + if($row != NULL && count($row) == 1) + { + $displayedColumns = createArray($row[0]); + + // init ordered columns + $index = 0; + foreach ($displayedColumns as $columnIndex) { + + $columnOrderMapping[$columnIndex][2] = $index; + + $index = $index + 1; + } + + foreach ($columnOrderMapping as $mapping) { + if($mapping[2] == -1) + { + $mapping[2] = $index; + $index = $index + 1; + } + } + } + // SQL $condition = getDeviceCondition ($_REQUEST['status']); @@ -581,9 +626,12 @@ function getDevicesList() { FROM Devices '. $condition; $result = $db->query($sql); + + // arrays of rows $tableData = array(); while ($row = $result -> fetchArray (SQLITE3_ASSOC)) { + $tableData['data'][] = array ($row['dev_Name'], $row['dev_Owner'], $row['dev_DeviceType'],