From 9f821c74f6ea00b7c3b4676afb800cdfb2a78978 Mon Sep 17 00:00:00 2001 From: Isaac Connor Date: Fri, 3 Jul 2020 19:16:41 -0400 Subject: [PATCH 1/6] Add tooltip on Add Monitor button explaining that the user doesn't have permission to add a monitor --- web/lang/en_gb.php | 1 + web/skins/classic/views/console.php | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/web/lang/en_gb.php b/web/lang/en_gb.php index 6b60c0099..77fadd29d 100644 --- a/web/lang/en_gb.php +++ b/web/lang/en_gb.php @@ -87,6 +87,7 @@ $SLANG = array( 'Actual' => 'Actual', 'AddNewControl' => 'Add New Control', 'AddNewMonitor' => 'Add', + 'AddMonitorDisabled' => 'Your user is not allowed to add a new monitor', 'AddNewServer' => 'Add New Server', 'AddNewStorage' => 'Add New Storage', 'AddNewUser' => 'Add New User', diff --git a/web/skins/classic/views/console.php b/web/skins/classic/views/console.php index 71c60b6f0..73f79185d 100644 --- a/web/skins/classic/views/console.php +++ b/web/skins/classic/views/console.php @@ -178,7 +178,7 @@ getBodyTopHTML();

From 343d8d832ed25e611e6ec54fc403eb81a2e49684 Mon Sep 17 00:00:00 2001 From: Isaac Connor Date: Fri, 3 Jul 2020 19:18:05 -0400 Subject: [PATCH 4/6] handle scale values of '' and 'auto' --- web/skins/classic/views/js/cycle.js | 62 ++++++++++++++++------------- 1 file changed, 34 insertions(+), 28 deletions(-) diff --git a/web/skins/classic/views/js/cycle.js b/web/skins/classic/views/js/cycle.js index f9b1d19fc..6d2c3bdd4 100644 --- a/web/skins/classic/views/js/cycle.js +++ b/web/skins/classic/views/js/cycle.js @@ -9,24 +9,27 @@ function cyclePause() { $('pauseBtn').disabled = true; $('playBtn').disabled = false; } + function cycleStart() { periodical_id = nextCycleView.periodical(cycleRefreshTimeout); $('pauseBtn').disabled = false; $('playBtn').disabled = true; } + function cycleNext() { monIdx ++; if ( monIdx >= monitorData.length ) { monIdx = 0; } if ( !monitorData[monIdx] ) { - console.log("No monitorData for " + monIdx); + console.log('No monitorData for ' + monIdx); } window.location.replace('?view=cycle&mid='+monitorData[monIdx].id+'&mode='+mode, cycleRefreshTimeout); } + function cyclePrev() { - if (monIdx) { + if ( monIdx ) { monIdx -= 1; } else { monIdx = monitorData.length - 1; @@ -71,7 +74,7 @@ function changeSize() { streamImg.style.width = width ? width : null; streamImg.style.height = height ? height : null; } else { - console.log("Did not find liveStream"+monitorData[monIdx].id); + console.log('Did not find liveStream'+monitorData[monIdx].id); } $('scale').set('value', ''); Cookie.write('zmCycleScale', '', {duration: 10*365}); @@ -96,7 +99,7 @@ function changeScale() { return; } - if ( scale != '0' ) { + if ( scale != '0' && scale != '' && scale != 'auto' ) { if ( newWidth ) { monitor_frame.css('width', newWidth+'px'); } @@ -107,33 +110,36 @@ function changeScale() { monitor_frame.css('width', '100%'); monitor_frame.css('height', 'auto'); } + /*Stream could be an applet so can't use moo tools*/ var streamImg = $j('#liveStream'+monitorData[monIdx].id)[0]; - if ( streamImg ) { - if ( streamImg.nodeName == 'IMG' ) { - var src = streamImg.src; - streamImg.src = ''; - - //src = src.replace(/rand=\d+/i,'rand='+Math.floor((Math.random() * 1000000) )); - src = src.replace(/scale=[\.\d]+/i, 'scale='+scale); - if ( scale != '0' ) { - src = src.replace(/width=[\.\d]+/i, 'width='+newWidth); - src = src.replace(/height=[\.\d]+/i, 'height='+newHeight); - } else { - src = src.replace(/width=[\.\d]+/i, 'width='+monitorData[monIdx].width); - src = src.replace(/height=[\.\d]+/i, 'height='+monitorData[monIdx].height); - } - streamImg.src = src; - } - if ( scale != '0' ) { - streamImg.style.width = newWidth+'px'; - streamImg.style.height = newHeight+'px'; - } else { - streamImg.style.width = '100%'; - streamImg.style.height = 'auto'; - } - } else { + if ( !streamImg ) { console.log("Did not find liveStream"+monitorData[monIdx].id); + return; + } + + if ( streamImg.nodeName == 'IMG' ) { + var src = streamImg.src; + streamImg.src = ''; + + //src = src.replace(/rand=\d+/i,'rand='+Math.floor((Math.random() * 1000000) )); + src = src.replace(/scale=[\.\d]+/i, 'scale='+scale); + if ( scale != '0' && scale != '' && scale != 'auto' ) { + src = src.replace(/width=[\.\d]+/i, 'width='+newWidth); + src = src.replace(/height=[\.\d]+/i, 'height='+newHeight); + } else { + src = src.replace(/width=[\.\d]+/i, 'width='+monitorData[monIdx].width); + src = src.replace(/height=[\.\d]+/i, 'height='+monitorData[monIdx].height); + } + streamImg.src = src; + } + + if ( scale != '0' && scale != '' && scale != 'auto' ) { + streamImg.style.width = newWidth+'px'; + streamImg.style.height = newHeight+'px'; + } else { + streamImg.style.width = '100%'; + streamImg.style.height = 'auto'; } } // end function changeScale() From 1860ad188b4e36bc2176c5b183ec7f63459ecc1d Mon Sep 17 00:00:00 2001 From: Isaac Connor Date: Fri, 3 Jul 2020 19:18:36 -0400 Subject: [PATCH 5/6] Don't allow viewing of zones or zone if Monitor permissions are view --- web/skins/classic/views/zone.php | 4 ++-- web/skins/classic/views/zones.php | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/web/skins/classic/views/zone.php b/web/skins/classic/views/zone.php index 6b5801744..cfd9ac1ed 100644 --- a/web/skins/classic/views/zone.php +++ b/web/skins/classic/views/zone.php @@ -18,12 +18,12 @@ // Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. // -if ( !canView('Monitors') ) { +$mid = empty($_REQUEST['mid']) ? 0 : validInt($_REQUEST['mid']); +if ( !($mid and canEdit('Monitors', $mid)) ) { $view = 'error'; return; } -$mid = validInt($_REQUEST['mid']); $zid = (!empty($_REQUEST['zid'])) ? validInt($_REQUEST['zid']) : 0; $scale = SCALE_BASE; diff --git a/web/skins/classic/views/zones.php b/web/skins/classic/views/zones.php index f8f758f46..de862d5c0 100644 --- a/web/skins/classic/views/zones.php +++ b/web/skins/classic/views/zones.php @@ -18,12 +18,12 @@ // Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. // -if ( !canView('Monitors') ) { +$mid = empty($_REQUEST['mid']) ? 0 : validInt($_REQUEST['mid']); +if ( !($mid and canEdit('Monitors', $mid)) ) { $view = 'error'; return; } -$mid = validInt($_REQUEST['mid']); $monitor = new ZM\Monitor($mid); # ViewWidth() and ViewHeight() are already rotated $minX = 0; From cc0624eb3f3644a145062f6a60417b5d39427dc1 Mon Sep 17 00:00:00 2001 From: Isaac Connor Date: Fri, 3 Jul 2020 19:19:13 -0400 Subject: [PATCH 6/6] Don't allow viewing of monitor setting if monitor permissions are set to View --- web/skins/classic/views/monitor.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/web/skins/classic/views/monitor.php b/web/skins/classic/views/monitor.php index 795c60332..ce7d436ea 100644 --- a/web/skins/classic/views/monitor.php +++ b/web/skins/classic/views/monitor.php @@ -21,7 +21,7 @@ require_once('includes/Server.php'); require_once('includes/Storage.php'); -if ( !canView('Monitors') ) { +if ( !canEdit('Monitors', empty($_REQUEST['mid'])?0:$_REQUEST['mid']) ) { $view = 'error'; return; }