Column order bogfix in network

This commit is contained in:
Jokob-sk
2023-01-23 22:39:18 +11:00
parent 69061ed537
commit 8bc1c3e0ed
4 changed files with 40 additions and 17 deletions

View File

@@ -2840,6 +2840,17 @@ def upgradeDB ():
AND name='Nmap_Scan';
""").fetchone() == None
# Re-creating Parameters table
file_print("[upgradeDB] Re-creating Parameters table")
sql.execute("DROP TABLE Parameters;")
sql.execute("""
CREATE TABLE "Parameters" (
"par_ID" TEXT PRIMARY KEY,
"par_Value" TEXT
);
""")
# Initialize Parameters if unavailable
initOrSetParam('Back_App_State','Initializing')

View File

@@ -7,9 +7,9 @@ services:
network_mode: "host"
restart: unless-stopped
volumes:
- ${APP_DATA_LOCATION}/pialert/config2:/home/pi/pialert/config
- ${APP_DATA_LOCATION}/pialert/config:/home/pi/pialert/config
# - ${APP_DATA_LOCATION}/pialert/db/pialert.db:/home/pi/pialert/db/pialert.db
- ${APP_DATA_LOCATION}/pialert/db2:/home/pi/pialert/db
- ${APP_DATA_LOCATION}/pialert/db:/home/pi/pialert/db
# (optional) useful for debugging if you have issues setting up the container
- ${LOGS_LOCATION}:/home/pi/pialert/front/log
# DELETE START anyone trying to use this file: comment out / delete BELOW lines, they are only for development purposes

View File

@@ -454,10 +454,10 @@
<script src="js/pialert_common.js"></script>
<script>
$.get('php/server/devices.php?action=getDevicesList&status=all', function(data) {
$.get('php/server/devices.php?action=getDevicesList&status=all&forceDefaultOrder', function(data) {
rawData = JSON.parse (data)
// console.log(rawData)
console.log(rawData)
devicesListnew = rawData["data"].map(item => { return {
"name":item[0],
@@ -469,7 +469,9 @@
"status":item[10]
}})
setCache('devicesList', JSON.stringify(devicesListnew))
setCache('devicesListNew', JSON.stringify(devicesListnew))
console.log(devicesListnew)
// create tree
initTree(getHierarchy());
@@ -488,7 +490,7 @@
function getDevicesList()
{
// Read cache
devicesList = getCache('devicesList');
devicesList = getCache('devicesListNew');
if (devicesList != '') {
devicesList = JSON.parse (devicesList);

View File

@@ -569,6 +569,13 @@ function getDevicesTotals() {
function getDevicesList() {
global $db;
$forceDefaultOrder = FALSE;
if (isset ($_REQUEST['forceDefaultOrder']) )
{
$forceDefaultOrder = TRUE;
}
// This object is used to map from the old order ( second parameter, first number) to the 3rd parameter (Second number (here initialized to -1))
$columnOrderMapping = array(
array("dev_Name", 0, 0),
@@ -588,19 +595,22 @@ function getDevicesList() {
array("dev_Network_Node_MAC_ADDR", 14, 14)
);
// get device columns order
$sql = 'SELECT par_Value FROM Parameters where par_ID = "Front_Devices_Columns_Order"';
$result = $db->query($sql);
$row = $result -> fetchArray (SQLITE3_NUM);
if($row != NULL && count($row) == 1)
if($forceDefaultOrder == FALSE)
{
// ordered columns setting from the maintenance page
$orderedColumns = createArray($row[0]);
// get device columns order
$sql = 'SELECT par_Value FROM Parameters where par_ID = "Front_Devices_Columns_Order"';
$result = $db->query($sql);
$row = $result -> fetchArray (SQLITE3_NUM);
// init ordered columns
for($i = 0; $i < count($orderedColumns); $i++) {
$columnOrderMapping[$i][2] = $orderedColumns[$i];
if($row != NULL && count($row) == 1)
{
// ordered columns setting from the maintenance page
$orderedColumns = createArray($row[0]);
// init ordered columns
for($i = 0; $i < count($orderedColumns); $i++) {
$columnOrderMapping[$i][2] = $orderedColumns[$i];
}
}
}