From ac7867eab3153980df63f0a7cf907a91ec717d87 Mon Sep 17 00:00:00 2001 From: Andrew Bauer Date: Wed, 26 Aug 2020 11:39:48 -0500 Subject: [PATCH] make function view a modal --- web/skins/classic/views/console.php | 4 +- web/skins/classic/views/function.php | 57 ++++++++++++--------------- web/skins/classic/views/js/console.js | 32 +++++++++++++++ 3 files changed, 59 insertions(+), 34 deletions(-) diff --git a/web/skins/classic/views/console.php b/web/skins/classic/views/console.php index 1c0698ec6..818cf2e82 100644 --- a/web/skins/classic/views/console.php +++ b/web/skins/classic/views/console.php @@ -244,7 +244,7 @@ echo $table_head; for( $monitor_i = 0; $monitor_i < count($displayMonitors); $monitor_i += 1 ) { $monitor = $displayMonitors[$monitor_i]; $Monitor = new ZM\Monitor($monitor); - + include('function.php'); if ( $monitor_i and ( $monitor_i % 100 == 0 ) ) { echo ''; echo $table_head; @@ -325,7 +325,7 @@ for( $monitor_i = 0; $monitor_i < count($displayMonitors); $monitor_i += 1 ) { ?> - '.translate('Fn'.$monitor['Function']).( empty($monitor['Enabled']) ? ', disabled' : '' ) .'', canEdit('Monitors') ) ?>
+

$_REQUEST['mid'])); - -$focusWindow = true; - -xhtmlHeaders(__FILE__, translate('Function').' - '.validHtmlStr($monitor->Name())); ?> - -
- -
-
- - - + +
diff --git a/web/skins/classic/views/js/console.js b/web/skins/classic/views/js/console.js index ab8fc8daa..2b4ffe935 100644 --- a/web/skins/classic/views/js/console.js +++ b/web/skins/classic/views/js/console.js @@ -135,6 +135,18 @@ function reloadWindow() { } function initPage() { + + $j('.functionLnk').click(function(evt) { + if ( ! canEditEvents ) { + alert("You do not have permission to change monitor function."); + return; + } + var mid = evt.currentTarget.getAttribute("data-mid"); + + evt.preventDefault(); + $j('#modalFunction-'+mid).modal('show'); + }); + reloadWindow.periodical(consoleRefreshTimeout); if ( showVersionPopup ) { createPopup('?view=version', 'zmVersion', 'version'); @@ -154,6 +166,26 @@ function initPage() { // Setup the thumbnail video animation initThumbAnimation(); + + // Manage the CANCEL modal buttons + $j('.funcCancelBtn').click(function(evt) { + var mid = evt.currentTarget.getAttribute("data-mid"); + + evt.preventDefault(); + $j('#modalFunction-'+mid).modal('hide'); + }); + + // Manage the SAVE modal buttons + $j('.funcSaveBtn').click(function(evt) { + var mid = evt.currentTarget.getAttribute("data-mid"); + var newFunc = $j("#funcSelect-"+mid).val(); + var newEnabled = $j('#newEnabled-'+mid).is(':checked') ? 1 : 0; + + evt.preventDefault(); + $j.getJSON(thisUrl + '?view=function&action=function&mid='+mid+'&newFunction='+newFunc+'&newEnabled='+newEnabled); + window.location.reload(true); + }); + } function applySort(event, ui) {