diff --git a/web/ajax/modal.php b/web/ajax/modal.php index 413cb34f8..49efcb202 100644 --- a/web/ajax/modal.php +++ b/web/ajax/modal.php @@ -35,6 +35,10 @@ switch ( $modal ) { if ( !isset($_REQUEST['id']) ) ajaxError('Storage Id Not Provided'); $data['html'] = getStorageModalHTML($_REQUEST['id']); break; + case 'server' : + if ( !isset($_REQUEST['id']) ) ajaxError('Storage Id Not Provided'); + $data['html'] = getServerModalHTML($_REQUEST['id']); + break; case 'eventdetail' : $eid = isset($_REQUEST['eid']) ? $_REQUEST['eid'] : ''; $eids = isset($_REQUEST['eids']) ? $_REQUEST['eids'] : ''; diff --git a/web/skins/classic/includes/functions.php b/web/skins/classic/includes/functions.php index f9053fab9..90fbb4e2d 100644 --- a/web/skins/classic/includes/functions.php +++ b/web/skins/classic/includes/functions.php @@ -1104,6 +1104,104 @@ function getCSRFinputHTML() { return $result; } +function getServerModalHTML($sid) { + $result = ''; + $checked = ' checked="checked"'; + $null = ''; + + if ( !canEdit('System') ) return; + + $Server = new ZM\Server($sid); + if ( $sid and ! $Server->Id() ) return; + + $result .= ''.PHP_EOL; + + return $result; +} + function xhtmlFooter() { global $css; global $cspNonce; diff --git a/web/skins/classic/views/js/options.js b/web/skins/classic/views/js/options.js index 330a0e73b..2629f33fe 100644 --- a/web/skins/classic/views/js/options.js +++ b/web/skins/classic/views/js/options.js @@ -1,3 +1,37 @@ +// Load the Server Modal HTML via Ajax call +function getServerModal(sid) { + $j.getJSON(thisUrl + '?request=modal&modal=server&id=' + sid) + .done(function(data) { + if ( $j('#ServerModal').length ) { + $j('#ServerModal').replaceWith(data.html); + } else { + $j("body").append(data.html); + } + $j('#ServerModal').modal('show'); + // Manage the Save button + $j('#serverSubmitBtn').click(function(evt) { + evt.preventDefault(); + $j('#serverModalForm').submit(); + }); + }) + .fail(function(jqxhr, textStatus, error) { + console.log("Request Failed: " + textStatus + ", " + error); + console.log("Response Text: " + jqxhr.responseText); + }); +} + +function enableServerModal() { + $j(".serverCol").click(function(evt) { + evt.preventDefault(); + var sid = $j(this).data('sid'); + getServerModal(sid); + }); + $j('#NewServerBtn').click(function(evt) { + evt.preventDefault(); + getServerModal(0); + }); +} + // Load the Storage Modal HTML via Ajax call function getStorageModal(sid) { $j.getJSON(thisUrl + '?request=modal&modal=storage&id=' + sid) @@ -34,10 +68,13 @@ function enableStorageModal() { function initPage() { var NewStorageBtn = $j('#NewStorageBtn'); + var NewServerBtn = $j('#NewServerBtn'); if ( canEditSystem ) enableStorageModal(); + if ( canEditSystem ) enableServerModal(); NewStorageBtn.prop('disabled', !canEditSystem); + NewServerBtn.prop('disabled', !canEditSystem); } $j(document).ready(function() { diff --git a/web/skins/classic/views/options.php b/web/skins/classic/views/options.php index e1e6f4f78..6dba8a3c9 100644 --- a/web/skins/classic/views/options.php +++ b/web/skins/classic/views/options.php @@ -181,8 +181,9 @@ foreach ( array_map('basename', glob('skins/'.$skin.'/css/*', GLOB_ONLYDIR)) as - +
@@ -209,47 +210,42 @@ foreach ( array_map('basename', glob('skins/'.$skin.'/css/*', GLOB_ONLYDIR)) as - + Id().'"'; + ?> - Id(), 'zmServer', 'server', validHtmlStr($Server->Name()), $canEdit) ?> - Id(), 'zmServer', 'server', validHtmlStr($Server->Url()), $canEdit) ?> - Id(), 'zmServer', 'server', validHtmlStr($Server->PathToIndex()), $canEdit) ?> - Id(), 'zmServer', 'server', validHtmlStr($Server->PathToZMS()), $canEdit) ?> - Id(), 'zmServer', 'server', validHtmlStr($Server->PathToApi()), $canEdit) ?> + Name()), $canEdit, $svr_opt ) ?> + Url()), $canEdit, $svr_opt ) ?> + PathToIndex()), $canEdit, $svr_opt ) ?> + PathToZMS()), $canEdit, $svr_opt ) ?> - Id(), 'zmServer', 'server', validHtmlStr($Server->Status()), $canEdit) ?> - - Id(), 'zmServer', 'server', validHtmlStr($monitor_counts[$Server->Id()]), $canEdit) ?> - - - Id(), 'zmServer', 'server',$Server->CpuLoad(), $canEdit) ?> - + Status()), $canEdit, $svr_opt) ?> + Id()]), $canEdit, $svr_opt) ?> + CpuLoad(), $canEdit, $svr_opt) ?> - Id(), 'zmServer', 'server', human_filesize($Server->FreeMem()) . ' / ' . human_filesize($Server->TotalMem()), $canEdit) ?> - + FreeMem()) . ' / ' . human_filesize($Server->TotalMem()), $canEdit, $svr_opt) ?> - Id(), 'zmServer', 'server', human_filesize($Server->FreeSwap()) . ' / ' . human_filesize($Server->TotalSwap()) , $canEdit) ?> - - Id(), 'zmServer', 'server', $Server->zmstats() ? 'yes' : 'no', $canEdit) ?> - Id(), 'zmServer', 'server', $Server->zmaudit() ? 'yes' : 'no', $canEdit) ?> - Id(), 'zmServer', 'server', $Server->zmtrigger() ? 'yes' : 'no', $canEdit) ?> - Id(), 'zmServer', 'server', $Server->zmeventnotification() ? 'yes' : 'no', $canEdit) ?> + FreeSwap()) . ' / ' . human_filesize($Server->TotalSwap()) , $canEdit, $svr_opt) ?> + zmstats() ? 'yes' : 'no', $canEdit, $svr_opt) ?> + zmaudit() ? 'yes' : 'no', $canEdit, $svr_opt) ?> + zmtrigger() ? 'yes' : 'no', $canEdit, $svr_opt) ?> + zmeventnotification() ? 'yes' : 'no', $canEdit, $svr_opt) ?> disabled="disabled"/> - +
- +
- +
@@ -270,14 +266,17 @@ foreach ( array_map('basename', glob('skins/'.$skin.'/css/*', GLOB_ONLYDIR)) as -'lower(Name)') ) as $Storage ) { ?> + 'lower(Name)') ) as $Storage ) { + $str_opt = 'class="storageCol" data-sid="'.$Storage->Id().'"'; + ?> - Id()), $canEdit, 'class="storageCol" data-sid="'.$Storage->Id().'"' ) ?> - Name()), $canEdit, 'class="storageCol" data-sid="'.$Storage->Id().'"' ) ?> - Path()), $canEdit, 'class="storageCol" data-sid="'.$Storage->Id().'"' ) ?> - Type()), $canEdit, 'class="storageCol" data-sid="'.$Storage->Id().'"' ) ?> - Scheme()), $canEdit, 'class="storageCol" data-sid="'.$Storage->Id().'"' ) ?> - Server()->Name()), $canEdit, 'class="storageCol" data-sid="'.$Storage->Id().'"' ) ?> + Id()), $canEdit, $str_opt ) ?> + Name()), $canEdit, $str_opt ) ?> + Path()), $canEdit, $str_opt ) ?> + Type()), $canEdit, $str_opt ) ?> + Scheme()), $canEdit, $str_opt ) ?> + Server()->Name()), $canEdit, $str_opt ) ?> disk_used_space()) . ' of ' . human_filesize($Storage->disk_total_space()) ?> EventCount().' using '.human_filesize($Storage->event_disk_space()) ?> EventCount() or !$canEdit ) { ?> disabled="disabled"EventCount() ? ' title="Can\'t delete as long as there are events stored here."' : ''?>/> diff --git a/web/skins/classic/views/server.php b/web/skins/classic/views/server.php deleted file mode 100644 index f3f177a62..000000000 --- a/web/skins/classic/views/server.php +++ /dev/null @@ -1,113 +0,0 @@ -Id() ) { - $view = 'error'; - return; -} - -$focusWindow = true; - -xhtmlHeaders(__FILE__, translate('Server').' - '.$Server->Name()); -getBodyTopHTML(); -?> -
- -
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
- zmstats() ? ' checked="checked"' : '' ?>/> Yes - zmstats() ? '' : ' checked="checked"' ?>/> No -
- zmaudit() ? ' checked="checked"' : '' ?>/> Yes - zmaudit() ? '' : ' checked="checked"' ?>/> No -
- zmtrigger() ? ' checked="checked"' : '' ?>/> Yes - zmtrigger() ? '' : ' checked="checked"' ?>/> No -
- zmeventnotification() ? ' checked="checked"' : '' ?>/> Yes - zmeventnotification() ? '' : ' checked="checked"' ?>/> No -
-
- - -
- -
-
-