From 760e20bc0f7504e5539b0c07963d74ea6dce12d9 Mon Sep 17 00:00:00 2001 From: Isaac Connor Date: Sat, 24 Oct 2020 08:50:59 -0400 Subject: [PATCH 1/7] Populate Monitor name and use event class DiskSpace to get DiskSpace when it hasn't been populated in the db yet --- web/ajax/events.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/web/ajax/events.php b/web/ajax/events.php index e420e2460..d224b8742 100644 --- a/web/ajax/events.php +++ b/web/ajax/events.php @@ -212,14 +212,14 @@ function queryRequest($filter, $search, $advsearch, $sort, $offset, $order, $lim $row['Name'] = validHtmlStr($row['Name']); $row['Archived'] = $row['Archived'] ? translate('Yes') : translate('No'); $row['Emailed'] = $row['Emailed'] ? translate('Yes') : translate('No'); - //$row['Monitor'] = ( $row['MonitorId'] and isset($MonitorById[$row['MonitorId']]) ) ? $MonitorById[$row['MonitorId']]->Name() : ''; + $row['Monitor'] = ( $row['MonitorId'] and isset($MonitorById[$row['MonitorId']]) ) ? $MonitorById[$row['MonitorId']]->Name() : ''; $row['Cause'] = validHtmlStr($row['Cause']); $row['StartTime'] = strftime(STRF_FMT_DATETIME_SHORTER, strtotime($row['StartTime'])); $row['EndTime'] = strftime(STRF_FMT_DATETIME_SHORTER, strtotime($row['StartTime'])); $row['Length'] = gmdate('H:i:s', $row['Length'] ); $row['Storage'] = ( $row['StorageId'] and isset($StorageById[$row['StorageId']]) ) ? $StorageById[$row['StorageId']]->Name() : 'Default'; $row['Notes'] = htmlspecialchars($row['Notes']); - $row['DiskSpace'] = human_filesize($row['DiskSpace']); + $row['DiskSpace'] = human_filesize($event->DiskSpace()); $rows[] = $row; } $data['rows'] = $rows; From efaf95bedaed2e395002a05c9044cd4fb62370c1 Mon Sep 17 00:00:00 2001 From: Isaac Connor Date: Sat, 24 Oct 2020 08:51:26 -0400 Subject: [PATCH 2/7] dirty hack to rename data.filter to data.advsearch --- web/skins/classic/views/js/events.js | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/web/skins/classic/views/js/events.js b/web/skins/classic/views/js/events.js index 62f53a1d8..90bce5f5f 100644 --- a/web/skins/classic/views/js/events.js +++ b/web/skins/classic/views/js/events.js @@ -35,7 +35,10 @@ var params = // Called by bootstrap-table to retrieve zm event data function ajaxRequest(params) { - console.log(params); + if ( params.data.filter ) { + params.data.advsearch = params.data.filter; + delete params.data.filter; + } $j.getJSON(thisUrl + '?view=request&request=events&task=query'+filterQuery, params.data) .done(function(data) { var rows = processRows(data.rows); From 90c5f63d6d11f5edfb72b16cae4a5df188cccc86 Mon Sep 17 00:00:00 2001 From: Isaac Connor Date: Sat, 24 Oct 2020 09:05:39 -0400 Subject: [PATCH 3/7] Fix session.gc SQL issue. Don't need a * when deleting --- web/includes/session.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/web/includes/session.php b/web/includes/session.php index 34ce8b13c..0190f9897 100644 --- a/web/includes/session.php +++ b/web/includes/session.php @@ -147,7 +147,7 @@ class Session { $now = time(); $old = $now - $max; ZM\Debug('doing session gc ' . $now . '-' . $max. '='.$old); - $sth = $this->db->prepare('DELETE * FROM Sessions WHERE access < :old'); + $sth = $this->db->prepare('DELETE FROM Sessions WHERE access < :old'); $sth->bindParam(':old', $old, PDO::PARAM_INT); return $sth->execute() ? true : false; } From a2dc4b5f08aaa2fc8237540e532eccdc5976dbe6 Mon Sep 17 00:00:00 2001 From: Isaac Connor Date: Sat, 24 Oct 2020 09:45:38 -0400 Subject: [PATCH 4/7] handle params.daa not existing --- web/skins/classic/views/js/events.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/web/skins/classic/views/js/events.js b/web/skins/classic/views/js/events.js index 90bce5f5f..442eca616 100644 --- a/web/skins/classic/views/js/events.js +++ b/web/skins/classic/views/js/events.js @@ -35,7 +35,7 @@ var params = // Called by bootstrap-table to retrieve zm event data function ajaxRequest(params) { - if ( params.data.filter ) { + if ( params.data && params.data.filter ) { params.data.advsearch = params.data.filter; delete params.data.filter; } From f87be2d2895b7c3f0f77f9a42ff4b56c87155bbb Mon Sep 17 00:00:00 2001 From: Andrew Bauer Date: Sun, 25 Oct 2020 08:24:56 -0500 Subject: [PATCH 5/7] specify the table name when we sort in events view --- web/ajax/events.php | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/web/ajax/events.php b/web/ajax/events.php index d224b8742..eddd62463 100644 --- a/web/ajax/events.php +++ b/web/ajax/events.php @@ -173,6 +173,7 @@ function queryRequest($filter, $search, $advsearch, $sort, $offset, $order, $lim if ( $where ) $where = ' WHERE '.$where; + $sort = $sort == "Name" ? 'M.'.$sort : 'E.'.$sort; $col_str = 'E.*'; $query['sql'] = 'SELECT ' .$col_str. ' FROM `' .$table. '` AS E INNER JOIN Monitors AS M ON E.MonitorId = M.Id'.$where.' ORDER BY LENGTH(' .$sort. '), ' .$sort. ' ' .$order. ' LIMIT ?, ?'; array_push($query['values'], $offset, $limit); @@ -192,12 +193,6 @@ function queryRequest($filter, $search, $advsearch, $sort, $offset, $order, $lim $StorageById[$S->Id()] = $S; } - $monitor_names = ZM\Monitor::find(); - $MonitorById = array(); - foreach ( $monitor_names as $S ) { - $MonitorById[$S->Id()] = $S; - } - $rows = array(); foreach ( dbFetchAll($query['sql'], NULL, $query['values']) as $row ) { ZM\Debug("row".print_r($row,true)); @@ -212,7 +207,6 @@ function queryRequest($filter, $search, $advsearch, $sort, $offset, $order, $lim $row['Name'] = validHtmlStr($row['Name']); $row['Archived'] = $row['Archived'] ? translate('Yes') : translate('No'); $row['Emailed'] = $row['Emailed'] ? translate('Yes') : translate('No'); - $row['Monitor'] = ( $row['MonitorId'] and isset($MonitorById[$row['MonitorId']]) ) ? $MonitorById[$row['MonitorId']]->Name() : ''; $row['Cause'] = validHtmlStr($row['Cause']); $row['StartTime'] = strftime(STRF_FMT_DATETIME_SHORTER, strtotime($row['StartTime'])); $row['EndTime'] = strftime(STRF_FMT_DATETIME_SHORTER, strtotime($row['StartTime'])); From cb073950b93a6e39955f851e8ed9aea6afef34ab Mon Sep 17 00:00:00 2001 From: Andrew Bauer Date: Sun, 25 Oct 2020 10:28:22 -0500 Subject: [PATCH 6/7] events view server pagination WIP --- web/ajax/events.php | 11 +---------- web/skins/classic/views/js/events.js | 2 +- web/skins/classic/views/newevents.php | 2 +- 3 files changed, 3 insertions(+), 12 deletions(-) diff --git a/web/ajax/events.php b/web/ajax/events.php index eddd62463..f6be6e501 100644 --- a/web/ajax/events.php +++ b/web/ajax/events.php @@ -129,15 +129,6 @@ function queryRequest($filter, $search, $advsearch, $sort, $offset, $order, $lim ZM\Fatal('Invalid sort field: ' . $sort); } - $col_str = ''; - foreach ( $columns as $key => $col ) { - if ( $col == 'Name' ) { - $columns[$key] = 'M.'.$col; - } else { - $columns[$key] = 'E.'.$col; - } - } - $col_str = implode(', ', $columns); $data = array(); $query = array(); $query['values'] = array(); @@ -174,7 +165,7 @@ function queryRequest($filter, $search, $advsearch, $sort, $offset, $order, $lim $where = ' WHERE '.$where; $sort = $sort == "Name" ? 'M.'.$sort : 'E.'.$sort; - $col_str = 'E.*'; + $col_str = 'E.*, M.Name AS Monitor'; $query['sql'] = 'SELECT ' .$col_str. ' FROM `' .$table. '` AS E INNER JOIN Monitors AS M ON E.MonitorId = M.Id'.$where.' ORDER BY LENGTH(' .$sort. '), ' .$sort. ' ' .$order. ' LIMIT ?, ?'; array_push($query['values'], $offset, $limit); diff --git a/web/skins/classic/views/js/events.js b/web/skins/classic/views/js/events.js index 442eca616..b51c679a3 100644 --- a/web/skins/classic/views/js/events.js +++ b/web/skins/classic/views/js/events.js @@ -58,7 +58,7 @@ function processRows(rows) { row.Id = '' + eid + ''; row.Name = '' + row.Name + '' + '
' + archived + emailed + '
'; - if ( canEditMonitors ) row.Name = '' + row.Name + ''; + if ( canEditMonitors ) row.Monitor = '' + row.Monitor + ''; if ( canEditEvents ) row.Cause = '' + row.Cause + ''; if ( row.Notes.indexOf('detected:') >= 0 ) { row.Cause = row.Cause + '
' + row.Notes + '
'; diff --git a/web/skins/classic/views/newevents.php b/web/skins/classic/views/newevents.php index 73f9e4a4d..555f13f51 100644 --- a/web/skins/classic/views/newevents.php +++ b/web/skins/classic/views/newevents.php @@ -102,7 +102,7 @@ getBodyTopHTML(); - + From e9b71b4ce17f8c23ecfa6625d51f9b84b9eab823 Mon Sep 17 00:00:00 2001 From: Andrew Bauer Date: Sun, 25 Oct 2020 10:40:29 -0500 Subject: [PATCH 7/7] events view server pagination - fix sorting name & monitor --- web/ajax/events.php | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/web/ajax/events.php b/web/ajax/events.php index f6be6e501..eb74f543a 100644 --- a/web/ajax/events.php +++ b/web/ajax/events.php @@ -164,9 +164,10 @@ function queryRequest($filter, $search, $advsearch, $sort, $offset, $order, $lim if ( $where ) $where = ' WHERE '.$where; - $sort = $sort == "Name" ? 'M.'.$sort : 'E.'.$sort; + $sort = $sort == "Monitor" ? 'M.Name' : 'E.'.$sort; $col_str = 'E.*, M.Name AS Monitor'; - $query['sql'] = 'SELECT ' .$col_str. ' FROM `' .$table. '` AS E INNER JOIN Monitors AS M ON E.MonitorId = M.Id'.$where.' ORDER BY LENGTH(' .$sort. '), ' .$sort. ' ' .$order. ' LIMIT ?, ?'; + //$query['sql'] = 'SELECT ' .$col_str. ' FROM `' .$table. '` AS E INNER JOIN Monitors AS M ON E.MonitorId = M.Id'.$where.' ORDER BY LENGTH(' .$sort. '), ' .$sort. ' ' .$order. ' LIMIT ?, ?'; + $query['sql'] = 'SELECT ' .$col_str. ' FROM `' .$table. '` AS E INNER JOIN Monitors AS M ON E.MonitorId = M.Id'.$where.' ORDER BY ' .$sort. ' ' .$order. ' LIMIT ?, ?'; array_push($query['values'], $offset, $limit); ZM\Warning('Calling the following sql query: ' .$query['sql']);