From 702143e51bd8f0f52d9700491b8ca7e96665f66c Mon Sep 17 00:00:00 2001 From: Isaac Connor Date: Wed, 7 Nov 2018 12:33:54 -0500 Subject: [PATCH] Create a function called getBodyTopHTML that outputs the body tag and anything else that should go at the top. Things like the we require javascript message, and any other messages like error messages. Use this on the monitor and console view to stick an error message at the top when saving a monitor fails. This is a pretty quick, crude implementation. --- web/includes/actions.php | 4 +++- web/index.php | 1 + web/skins/classic/includes/functions.php | 22 +++++++++++++++++----- web/skins/classic/views/console.php | 2 +- web/skins/classic/views/monitor.php | 2 +- 5 files changed, 23 insertions(+), 8 deletions(-) diff --git a/web/includes/actions.php b/web/includes/actions.php index de0861fe0..48082a585 100644 --- a/web/includes/actions.php +++ b/web/includes/actions.php @@ -554,7 +554,8 @@ if ( canEdit('Monitors') ) { $maxSeq = dbFetchOne('SELECT MAX(Sequence) AS MaxSequence FROM Monitors', 'MaxSequence'); $changes[] = 'Sequence = '.($maxSeq+1); - if ( dbQuery('INSERT INTO Monitors SET '.implode(', ', $changes)) ) { + $sql = 'INSERT INTO Monitors SET '.implode(', ', $changes); + if ( dbQuery($sql) ) { $mid = dbInsertId(); $zoneArea = $_REQUEST['newMonitor']['Width'] * $_REQUEST['newMonitor']['Height']; dbQuery("INSERT INTO Zones SET MonitorId = ?, Name = 'All', Type = 'Active', Units = 'Percent', NumCoords = 4, Coords = ?, Area=?, AlarmRGB = 0xff0000, CheckMethod = 'Blobs', MinPixelThreshold = 25, MinAlarmPixels=?, MaxAlarmPixels=?, FilterX = 3, FilterY = 3, MinFilterPixels=?, MaxFilterPixels=?, MinBlobPixels=?, MinBlobs = 1", array( $mid, sprintf( "%d,%d %d,%d %d,%d %d,%d", 0, 0, $_REQUEST['newMonitor']['Width']-1, 0, $_REQUEST['newMonitor']['Width']-1, $_REQUEST['newMonitor']['Height']-1, 0, $_REQUEST['newMonitor']['Height']-1 ), $zoneArea, intval(($zoneArea*3)/100), intval(($zoneArea*75)/100), intval(($zoneArea*3)/100), intval(($zoneArea*75)/100), intval(($zoneArea*2)/100) ) ); @@ -566,6 +567,7 @@ if ( canEdit('Monitors') ) { } else { Error('Error saving new Monitor.'); + $error_message = dbError($sql); return; } } else { diff --git a/web/index.php b/web/index.php index addddce06..cbda1096a 100644 --- a/web/index.php +++ b/web/index.php @@ -170,6 +170,7 @@ if ( !is_writable(ZM_DIR_EVENTS) || !is_writable(ZM_DIR_IMAGES) ) { } # Globals +$error_message = null; $redirect = null; $view = null; if ( isset($_REQUEST['view']) ) diff --git a/web/skins/classic/includes/functions.php b/web/skins/classic/includes/functions.php index 7847e37c7..8fd9e2a8e 100644 --- a/web/skins/classic/includes/functions.php +++ b/web/skins/classic/includes/functions.php @@ -208,6 +208,23 @@ echo output_link_if_exists( array( + +'; + global $error_message; + if ( $error_message ) { + echo '
'.$error_message.'
'; + } +} // end function getBodyTopHTML + function getNavBarHTML($reload = null) { # Provide a facility to turn off the headers if you put headers=0 into the url if ( isset($_REQUEST['navbar']) and $_REQUEST['navbar']=='0' ) @@ -235,11 +252,6 @@ function getNavBarHTML($reload = null) { $running = daemonCheck(); $status = $running?translate('Running'):translate('Stopped'); ?> -