From 242e5a56d8eb1beaaf7ba2415d05f4c172894860 Mon Sep 17 00:00:00 2001 From: Isaac Connor Date: Sat, 14 Jan 2017 16:55:28 -0500 Subject: [PATCH 01/30] rough in the ability to filter on RunState --- db/zm_create.sql.in | 1 + src/zm_event.cpp | 8 ++++++-- web/includes/functions.php | 1 + web/lang/en_gb.php | 1 + web/skins/classic/views/filter.php | 12 ++++++++++++ 5 files changed, 21 insertions(+), 2 deletions(-) diff --git a/db/zm_create.sql.in b/db/zm_create.sql.in index 50c4e9012..e9df807f7 100644 --- a/db/zm_create.sql.in +++ b/db/zm_create.sql.in @@ -203,6 +203,7 @@ CREATE TABLE `Events` ( `Messaged` tinyint(3) unsigned NOT NULL default '0', `Executed` tinyint(3) unsigned NOT NULL default '0', `Notes` text, + `StateId` int(10) unsigned NOT NULL, PRIMARY KEY (`Id`,`MonitorId`), KEY `MonitorId` (`MonitorId`), KEY `StartTime` (`StartTime`), diff --git a/src/zm_event.cpp b/src/zm_event.cpp index 9b6202966..00e4e38a0 100644 --- a/src/zm_event.cpp +++ b/src/zm_event.cpp @@ -77,10 +77,14 @@ Event::Event( Monitor *p_monitor, struct timeval p_start_time, const std::string gettimeofday( &start_time, 0 ); } - static char sql[ZM_SQL_MED_BUFSIZ]; + unsigned int state_id = 0; + if ( MYSQL_ROW dbrow = zmDbFetchOne( "SELECT Id FROM States WHERE IsActive=1" ) ) { + state_id = atoi(dbrow[0]); + } + static char sql[ZM_SQL_MED_BUFSIZ]; struct tm *stime = localtime( &start_time.tv_sec ); - snprintf( sql, sizeof(sql), "insert into Events ( MonitorId, Name, StartTime, Width, Height, Cause, Notes ) values ( %d, 'New Event', from_unixtime( %ld ), %d, %d, '%s', '%s' )", monitor->Id(), start_time.tv_sec, monitor->Width(), monitor->Height(), cause.c_str(), notes.c_str() ); + snprintf( sql, sizeof(sql), "insert into Events ( MonitorId, Name, StartTime, Width, Height, Cause, Notes, StateId ) values ( %d, 'New Event', from_unixtime( %ld ), %d, %d, '%s', '%s', %d )", monitor->Id(), start_time.tv_sec, monitor->Width(), monitor->Height(), cause.c_str(), notes.c_str(), state_id ); if ( mysql_query( &dbconn, sql ) ) { Error( "Can't insert event: %s", mysql_error( &dbconn ) ); diff --git a/web/includes/functions.php b/web/includes/functions.php index 36a80cf2e..bd1375b73 100644 --- a/web/includes/functions.php +++ b/web/includes/functions.php @@ -1243,6 +1243,7 @@ function parseFilter( &$filter, $saveToSession=false, $querySep='&' ) { case 'MaxScore': case 'Cause': case 'Notes': + case 'StateId': case 'Archived': $filter['sql'] .= 'E.'.$filter['terms'][$i]['attr']; break; diff --git a/web/lang/en_gb.php b/web/lang/en_gb.php index 4adb1fc7f..922ca1e21 100644 --- a/web/lang/en_gb.php +++ b/web/lang/en_gb.php @@ -127,6 +127,7 @@ $SLANG = array( 'AttrMonitorName' => 'Monitor Name', 'AttrServerId' => 'Server Id', 'AttrServerName' => 'Server Name', + 'AttrStateId' => 'Run State', 'AttrName' => 'Name', 'AttrNotes' => 'Notes', 'AttrSystemLoad' => 'System Load', diff --git a/web/skins/classic/views/filter.php b/web/skins/classic/views/filter.php index 390e94ee1..465777bd3 100644 --- a/web/skins/classic/views/filter.php +++ b/web/skins/classic/views/filter.php @@ -97,6 +97,7 @@ $attrTypes = array( 'DiskPercent' => translate('AttrDiskPercent'), 'DiskBlocks' => translate('AttrDiskBlocks'), 'SystemLoad' => translate('AttrSystemLoad'), + 'StateId' => translate('AttrStateId'), 'ServerId' => translate('AttrServerId'), 'ServerName' => translate('AttrServerName'), ); @@ -217,6 +218,17 @@ for ( $i = 0; isset($_REQUEST['filter']) && $i < count($_REQUEST['filter']['term ?> + + + Date: Sat, 14 Jan 2017 16:58:22 -0500 Subject: [PATCH 02/30] add an update script to add StateId to Events table --- db/zm_update-1.30.2.sql | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) create mode 100644 db/zm_update-1.30.2.sql diff --git a/db/zm_update-1.30.2.sql b/db/zm_update-1.30.2.sql new file mode 100644 index 000000000..48e9b3c52 --- /dev/null +++ b/db/zm_update-1.30.2.sql @@ -0,0 +1,20 @@ +-- +-- This updates a 1.30.1 database to 1.30.2 +-- +-- Add StateId Column to Events. +-- + +SET @s = (SELECT IF( + (SELECT COUNT(*) + FROM INFORMATION_SCHEMA.COLUMNS + WHERE table_name = 'Events' + AND table_schema = DATABASE() + AND column_name = 'StateId' + ) > 0, +"SELECT 'Column StateId exists in Events'", +"ALTER TABLE Events ADD `StateId` int(10) unsigned default NULL AFTER `Notes`" +)); + +PREPARE stmt FROM @s; +EXECUTE stmt; + From 9c8b229c745878d88d494bea38daf9178c1097d9 Mon Sep 17 00:00:00 2001 From: Isaac Connor Date: Sat, 14 Jan 2017 17:08:13 -0500 Subject: [PATCH 03/30] Fix cutnpaste error --- web/skins/classic/views/filter.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/web/skins/classic/views/filter.php b/web/skins/classic/views/filter.php index 465777bd3..afe9bc883 100644 --- a/web/skins/classic/views/filter.php +++ b/web/skins/classic/views/filter.php @@ -220,7 +220,7 @@ for ( $i = 0; isset($_REQUEST['filter']) && $i < count($_REQUEST['filter']['term Date: Thu, 25 May 2017 14:08:04 -0400 Subject: [PATCH 04/30] merge from sa the ajax file to apply the sorting. --- web/ajax/console.php | 37 +++++++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) create mode 100644 web/ajax/console.php diff --git a/web/ajax/console.php b/web/ajax/console.php new file mode 100644 index 000000000..61c8e87fb --- /dev/null +++ b/web/ajax/console.php @@ -0,0 +1,37 @@ +beginTransaction(); + $dbConn->exec( 'LOCK TABLES Monitors WRITE' ); + for ( $i = 0; $i < count($monitor_ids); $i += 1 ) { + $monitor_id = $monitor_ids[$i]; + $monitor_id = preg_replace( '/^monitor_id-/', '', $monitor_id ); + if ( ( ! $monitor_id ) or ! ( is_integer( $monitor_id ) or ctype_digit( $monitor_id ) ) ) { + Warning( "Got $monitor_id from " . $monitor_ids[$i] ); + continue; + } + dbQuery( 'UPDATE Monitors SET Sequence=? WHERE Id=?', array( $i, $monitor_id ) ); + } // end for each monitor_id + $dbConn->commit(); + $dbConn->exec('UNLOCK TABLES'); + + return; + } // end case sort + default: + { + Warning("unknown action " . $_REQUEST['action'] ); + } // end ddcase default + } +} else { + Warning("Cannot edit monitors" ); +} + +ajaxError( 'Unrecognised action or insufficient permissions' ); + +?> From 31b5a99b4301bd25da9eba494d4650dfc77ceb21 Mon Sep 17 00:00:00 2001 From: Isaac Connor Date: Thu, 25 May 2017 14:30:07 -0400 Subject: [PATCH 05/30] remove old code to do sequence up/down arrows, replace with jquery sortable --- web/skins/classic/views/console.php | 65 +++++++---------------------- 1 file changed, 14 insertions(+), 51 deletions(-) diff --git a/web/skins/classic/views/console.php b/web/skins/classic/views/console.php index e34a24607..4e2b52e42 100644 --- a/web/skins/classic/views/console.php +++ b/web/skins/classic/views/console.php @@ -88,7 +88,6 @@ $maxHeight = 0; $cycleCount = 0; $minSequence = 0; $maxSequence = 1; -$seqIdList = array(); $monitors = dbFetchAll( "select * from Monitors order by Sequence asc" ); $displayMonitors = array(); for ( $i = 0; $i < count($monitors); $i++ ) @@ -102,14 +101,6 @@ for ( $i = 0; $i < count($monitors); $i++ ) continue; } $monitors[$i]['Show'] = true; - if ( empty($minSequence) || ($monitors[$i]['Sequence'] < $minSequence) ) - { - $minSequence = $monitors[$i]['Sequence']; - } - if ( $monitors[$i]['Sequence'] > $maxSequence ) - { - $maxSequence = $monitors[$i]['Sequence']; - } $monitors[$i]['zmc'] = zmcStatus( $monitors[$i] ); $monitors[$i]['zma'] = zmaStatus( $monitors[$i] ); $monitors[$i]['ZoneCount'] = dbFetchOne( 'select count(Id) as ZoneCount from Zones where MonitorId = ?', 'ZoneCount', array($monitors[$i]['Id']) ); @@ -132,29 +123,8 @@ for ( $i = 0; $i < count($monitors); $i++ ) if ( $maxHeight < $scaleHeight ) $maxHeight = $scaleHeight; } if ( $counts ) $monitors[$i] = array_merge( $monitors[$i], $counts ); - $seqIdList[] = $monitors[$i]['Id']; $displayMonitors[] = $monitors[$i]; } -$lastId = 0; -$seqIdUpList = array(); -foreach ( $seqIdList as $seqId ) -{ - if ( !empty($lastId) ) - $seqIdUpList[$seqId] = $lastId; - else - $seqIdUpList[$seqId] = $seqId; - $lastId = $seqId; -} -$lastId = 0; -$seqIdDownList = array(); -foreach ( array_reverse($seqIdList) as $seqId ) -{ - if ( !empty($lastId) ) - $seqIdDownList[$seqId] = $lastId; - else - $seqIdDownList[$seqId] = $seqId; - $lastId = $seqId; -} $cycleWidth = $maxWidth; $cycleHeight = $maxHeight; @@ -177,9 +147,6 @@ foreach( $displayMonitors as $monitor ) $zoneCount += $monitor['ZoneCount']; } -$seqUpFile = getSkinFile( 'graphics/seq-u.png' ); -$seqDownFile = getSkinFile( 'graphics/seq-d.png' ); - $versionClass = (ZM_DYN_DB_VERSION&&(ZM_DYN_DB_VERSION!=ZM_VERSION))?'errorText':''; $left_columns = 3; @@ -263,14 +230,6 @@ for ( $i = 0; $i < count($eventCounts); $i++ ) } ?> - - - @@ -278,7 +237,7 @@ if ( canEdit('Monitors') ) - + @@ -361,15 +320,10 @@ echo $Server->Name(); } ?> - - ', $monitor['Sequence']>$minSequence ) ?>', $monitor['Sequence']<$maxSequence ) ?> - - disabled="disabled"/> + + disabled="disabled"/> + + Name(); + From aacfea735e4fa92a53a5dee1de252adc282bf466 Mon Sep 17 00:00:00 2001 From: Isaac Connor Date: Thu, 25 May 2017 15:00:44 -0400 Subject: [PATCH 06/30] always include bootstrap, and include jquery --- web/skins/classic/includes/functions.php | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/web/skins/classic/includes/functions.php b/web/skins/classic/includes/functions.php index ed11748ab..9cbdbccee 100644 --- a/web/skins/classic/includes/functions.php +++ b/web/skins/classic/includes/functions.php @@ -51,9 +51,7 @@ function xhtmlHeaders( $file, $title ) - - + + + + + From 09c0b47568dab6a27eaa5cebbdd0f657da8cad2d Mon Sep 17 00:00:00 2001 From: Isaac Connor Date: Thu, 25 May 2017 15:02:30 -0400 Subject: [PATCH 07/30] remove no longer used styles, and increase the width of the Mark Column to accomodate the up/down arrows --- web/skins/classic/css/classic/views/console.css | 16 +--------------- web/skins/classic/css/dark/views/console.css | 16 +--------------- web/skins/classic/css/flat/views/console.css | 16 +--------------- 3 files changed, 3 insertions(+), 45 deletions(-) diff --git a/web/skins/classic/css/classic/views/console.css b/web/skins/classic/css/classic/views/console.css index 49920402a..481a14944 100644 --- a/web/skins/classic/css/classic/views/console.css +++ b/web/skins/classic/css/classic/views/console.css @@ -61,12 +61,8 @@ text-align: left; } -#consoleTable .colOrder { - text-align: center; -} - #consoleTable .colMark { - width: 32px; + width: 62px; text-align: center; } @@ -85,13 +81,3 @@ #consoleTable .colLeftButtons input { margin-right: 24px; } - -#consoleTable .colRightButtons { - text-align: right; - padding-right: 8px; -} - -#consoleTable .colRightButtons input { - margin: 0 8px; -} - diff --git a/web/skins/classic/css/dark/views/console.css b/web/skins/classic/css/dark/views/console.css index c198b460b..9de9128b5 100644 --- a/web/skins/classic/css/dark/views/console.css +++ b/web/skins/classic/css/dark/views/console.css @@ -61,12 +61,8 @@ text-align: left; } -#consoleTable .colOrder { - text-align: center; -} - #consoleTable .colMark { - width: 32px; + width: 62px; text-align: center; } @@ -85,13 +81,3 @@ #consoleTable .colLeftButtons input { margin-right: 24px; } - -#consoleTable .colRightButtons { - text-align: right; - padding-right: 8px; -} - -#consoleTable .colRightButtons input { - margin: 0 8px; -} - diff --git a/web/skins/classic/css/flat/views/console.css b/web/skins/classic/css/flat/views/console.css index 49920402a..481a14944 100644 --- a/web/skins/classic/css/flat/views/console.css +++ b/web/skins/classic/css/flat/views/console.css @@ -61,12 +61,8 @@ text-align: left; } -#consoleTable .colOrder { - text-align: center; -} - #consoleTable .colMark { - width: 32px; + width: 62px; text-align: center; } @@ -85,13 +81,3 @@ #consoleTable .colLeftButtons input { margin-right: 24px; } - -#consoleTable .colRightButtons { - text-align: right; - padding-right: 8px; -} - -#consoleTable .colRightButtons input { - margin: 0 8px; -} - From 229c8c6e23d269efd91b301fec81517d32ff54d8 Mon Sep 17 00:00:00 2001 From: Isaac Connor Date: Thu, 25 May 2017 15:03:10 -0400 Subject: [PATCH 08/30] Mmove Right buttons to the left, because there is no more room on the right anymore, move the script that sets up the sorting to js/console.js --- web/skins/classic/views/console.php | 20 ++++++++------------ 1 file changed, 8 insertions(+), 12 deletions(-) diff --git a/web/skins/classic/views/console.php b/web/skins/classic/views/console.php index 0697519bf..520d9024c 100644 --- a/web/skins/classic/views/console.php +++ b/web/skins/classic/views/console.php @@ -223,6 +223,8 @@ for ( $i = 0; $i < count($eventCounts); $i++ ) { + + - + - + - + Name(); + - From 123aaad08070351a6eb7345a05ec162ec46ee497 Mon Sep 17 00:00:00 2001 From: Isaac Connor Date: Thu, 25 May 2017 15:03:30 -0400 Subject: [PATCH 09/30] add applySort function, and the sorting init code --- web/skins/classic/views/js/console.js | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/web/skins/classic/views/js/console.js b/web/skins/classic/views/js/console.js index 032f0de0b..b95c97ecb 100644 --- a/web/skins/classic/views/js/console.js +++ b/web/skins/classic/views/js/console.js @@ -74,6 +74,27 @@ function initPage() { createPopup( '?view=version', 'zmVersion', 'version' ); if ( showDonatePopup ) createPopup( '?view=donate', 'zmDonate', 'donate' ); + + // Makes table sortable +$j( function() { + $j( "#consoleTableBody" ).sortable({ + handle: ".glyphicon-sort", + update: applySort, + axis:'Y' } ); + $j( "#consoleTableBody" ).disableSelection(); + } ); } +function applySort(event, ui) { + var monitor_ids = $j(this).sortable('toArray'); + var ajax = new Request.JSON( { + url: '/index.php?request=console', + data: { monitor_ids: monitor_ids, action: 'sort' }, + method: 'post', + timeout: AJAX_TIMEOUT + } ); + ajax.send(); +} // end function applySort(event,ui) + + window.addEvent( 'domready', initPage ); From e2df0b74d410caac4de6f13e49911b8f2b62bf7c Mon Sep 17 00:00:00 2001 From: Isaac Connor Date: Mon, 29 May 2017 09:51:31 -0400 Subject: [PATCH 10/30] remove including state.js.php as it has nothing to do with this pr --- web/skins/classic/includes/functions.php | 1 - 1 file changed, 1 deletion(-) diff --git a/web/skins/classic/includes/functions.php b/web/skins/classic/includes/functions.php index 9cbdbccee..a6531ed17 100644 --- a/web/skins/classic/includes/functions.php +++ b/web/skins/classic/includes/functions.php @@ -85,7 +85,6 @@ function xhtmlHeaders( $file, $title ) var $j = jQuery.noConflict(); // $j is now an alias to the jQuery function; creating the new alias is optional. - //--> //]]> From 175e6921f94ee1734fb717c073a32073742b623a Mon Sep 17 00:00:00 2001 From: Isaac Connor Date: Wed, 7 Jun 2017 14:13:03 -0400 Subject: [PATCH 11/30] use version-generic urls to jquery and jquery-ui --- web/skins/classic/includes/functions.php | 4 ++-- web/skins/classic/js/jquery-ui.js | 1 + 2 files changed, 3 insertions(+), 2 deletions(-) create mode 120000 web/skins/classic/js/jquery-ui.js diff --git a/web/skins/classic/includes/functions.php b/web/skins/classic/includes/functions.php index 821a15f06..74fde203f 100644 --- a/web/skins/classic/includes/functions.php +++ b/web/skins/classic/includes/functions.php @@ -72,8 +72,8 @@ function xhtmlHeaders( $file, $title ) { - - + +