diff options
author | Mārtiņš Tālbergs <martins.talbergs@zabbix.com> | 2021-03-01 18:43:34 +0300 |
---|---|---|
committer | Mārtiņš Tālbergs <martins.talbergs@zabbix.com> | 2021-03-01 18:45:10 +0300 |
commit | d9a785772bd2fdbfd3dedd79d7ec90feec9c1351 (patch) | |
tree | d2bcefdb414e24f96c2630ebd914a5178c22aa87 | |
parent | f33f771ebae478cc834463c9663bc5cb8c0e1b4b (diff) |
..F....... [ZBXNEXT-6288] removed screen related view and JavaScript
-rw-r--r-- | ui/include/classes/screens/CScreenBuilder.php | 11 | ||||
-rw-r--r-- | ui/include/views/js/monitoring.screen.constructor.edit.js.php | 33 | ||||
-rw-r--r-- | ui/include/views/js/monitoring.screen.edit.js.php | 187 | ||||
-rw-r--r-- | ui/include/views/js/monitoring.screen.js.php | 84 | ||||
-rw-r--r-- | ui/include/views/js/monitoring.slideconf.edit.js.php | 348 | ||||
-rw-r--r-- | ui/include/views/js/monitoring.slides.js.php | 48 | ||||
-rw-r--r-- | ui/include/views/monitoring.screen.constructor.edit.php | 862 | ||||
-rw-r--r-- | ui/include/views/monitoring.screen.constructor.list.php | 43 | ||||
-rw-r--r-- | ui/include/views/monitoring.screen.edit.php | 233 | ||||
-rw-r--r-- | ui/include/views/monitoring.screen.list.php | 137 | ||||
-rw-r--r-- | ui/include/views/monitoring.screen.php | 143 | ||||
-rw-r--r-- | ui/include/views/monitoring.slideconf.edit.php | 295 | ||||
-rw-r--r-- | ui/include/views/monitoring.slideconf.list.php | 117 | ||||
-rw-r--r-- | ui/include/views/monitoring.slides.php | 139 | ||||
-rw-r--r-- | ui/js/class.cscreen.js | 116 |
15 files changed, 0 insertions, 2796 deletions
diff --git a/ui/include/classes/screens/CScreenBuilder.php b/ui/include/classes/screens/CScreenBuilder.php index 08f3aa9147e..a553b39440b 100644 --- a/ui/include/classes/screens/CScreenBuilder.php +++ b/ui/include/classes/screens/CScreenBuilder.php @@ -578,17 +578,6 @@ class CScreenBuilder { } /** - * Insert javascript to init screens. - * - * @static - * - * @param string $screenid - */ - public static function insertInitScreenJs($screenid) { - zbx_add_post_js('init_screen("'.$screenid.'", "'.self::makeScreenTableId($screenid).'", "'.$screenid.'");'); - } - - /** * Insert javascript to start time control rendering. * * @static diff --git a/ui/include/views/js/monitoring.screen.constructor.edit.js.php b/ui/include/views/js/monitoring.screen.constructor.edit.js.php deleted file mode 100644 index c071f3c2aa5..00000000000 --- a/ui/include/views/js/monitoring.screen.constructor.edit.js.php +++ /dev/null @@ -1,33 +0,0 @@ -<?php declare(strict_types=1); -/* - ** Zabbix - ** Copyright (C) 2001-2021 Zabbix SIA - ** - ** This program is free software; you can redistribute it and/or modify - ** it under the terms of the GNU General Public License as published by - ** the Free Software Foundation; either version 2 of the License, or - ** (at your option) any later version. - ** - ** This program is distributed in the hope that it will be useful, - ** but WITHOUT ANY WARRANTY; without even the implied warranty of - ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - ** GNU General Public License for more details. - ** - ** You should have received a copy of the GNU General Public License - ** along with this program; if not, write to the Free Software - ** Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - **/ - - -/** - * @var CView $this - */ -?> - -<script type="text/javascript"> - $(() => { - $('#resourcetype, #style').on('change', (e) => { - document.forms['screen_item_form'].submit(); - }); - }); -</script> diff --git a/ui/include/views/js/monitoring.screen.edit.js.php b/ui/include/views/js/monitoring.screen.edit.js.php deleted file mode 100644 index 0bcae9c0a03..00000000000 --- a/ui/include/views/js/monitoring.screen.edit.js.php +++ /dev/null @@ -1,187 +0,0 @@ -<?php -/* -** Zabbix -** Copyright (C) 2001-2021 Zabbix SIA -** -** This program is free software; you can redistribute it and/or modify -** it under the terms of the GNU General Public License as published by -** the Free Software Foundation; either version 2 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU General Public License for more details. -** -** You should have received a copy of the GNU General Public License -** along with this program; if not, write to the Free Software -** Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. -**/ - - -/** - * @var CView $this - */ -?> - -<script type="text/x-jquery-tmpl" id="user_group_row_tpl"> - <?= (new CRow([ - new CCol([ - (new CTextBox('userGroups[#{usrgrpid}][usrgrpid]', '#{usrgrpid}'))->setAttribute('type', 'hidden'), - (new CSpan('#{name}')) - ]), - new CCol( - (new CTag('ul', false, [ - new CTag('li', false, [ - (new CInput('radio', 'userGroups[#{usrgrpid}][permission]', PERM_READ)) - ->setId('user_group_#{usrgrpid}_permission_'.PERM_READ), - (new CTag('label', false, _('Read-only'))) - ->setAttribute('for', 'user_group_#{usrgrpid}_permission_'.PERM_READ) - ]), - new CTag('li', false, [ - (new CInput('radio', 'userGroups[#{usrgrpid}][permission]', PERM_READ_WRITE)) - ->setId('user_group_#{usrgrpid}_permission_'.PERM_READ_WRITE), - (new CTag('label', false, _('Read-write'))) - ->setAttribute('for', 'user_group_#{usrgrpid}_permission_'.PERM_READ_WRITE) - ]) - ]))->addClass(CRadioButtonList::ZBX_STYLE_CLASS) - ), - (new CCol( - (new CButton('remove', _('Remove'))) - ->addClass(ZBX_STYLE_BTN_LINK) - ->onClick('removeUserGroupShares("#{usrgrpid}");') - ->removeId() - ))->addClass(ZBX_STYLE_NOWRAP) - ])) - ->setId('user_group_shares_#{usrgrpid}') - ->toString() - ?> -</script> - -<script type="text/x-jquery-tmpl" id="user_row_tpl"> - <?= (new CRow([ - new CCol([ - (new CTextBox('users[#{id}][userid]', '#{id}'))->setAttribute('type', 'hidden'), - (new CSpan('#{name}')) - ]), - new CCol( - (new CTag('ul', false, [ - new CTag('li', false, [ - (new CInput('radio', 'users[#{id}][permission]', PERM_READ)) - ->setId('user_#{id}_permission_'.PERM_READ), - (new CTag('label', false, _('Read-only'))) - ->setAttribute('for', 'user_#{id}_permission_'.PERM_READ) - ]), - new CTag('li', false, [ - (new CInput('radio', 'users[#{id}][permission]', PERM_READ_WRITE)) - ->setId('user_#{id}_permission_'.PERM_READ_WRITE), - (new CTag('label', false, _('Read-write'))) - ->setAttribute('for', 'user_#{id}_permission_'.PERM_READ_WRITE) - ]) - ]))->addClass(CRadioButtonList::ZBX_STYLE_CLASS) - ), - (new CCol( - (new CButton('remove', _('Remove'))) - ->addClass(ZBX_STYLE_BTN_LINK) - ->onClick('removeUserShares("#{id}");') - ->removeId() - ))->addClass(ZBX_STYLE_NOWRAP) - ])) - ->setId('user_shares_#{id}') - ->toString() - ?> -</script> - -<script type="text/javascript"> - jQuery(function($) { - $('#clone, #full_clone').click(function() { - var form = $(this).attr('id'); - - $('#form').val(form); - - if (form === 'clone') { - $('#screenid').remove(); - } - - $('#delete, #clone, #full_clone, #inaccessible_user').remove(); - - $('#update') - .text(<?= json_encode(_('Add')) ?>) - .attr({id: 'add', name: 'add'}); - - $('#tab_screen_tab').trigger('click'); - $('#multiselect_userid_wrapper').show(); - - $('#userid').multiSelect('addData', [{ - 'id': $('#current_user_userid').val(), - 'name': $('#current_user_fullname').val() - }]); - - $('#name').focus(); - }); - }); - - /** - * @see init.js add.popup event - */ - function addPopupValues(list) { - var i, - value, - tpl, - container; - - for (i = 0; i < list.values.length; i++) { - if (empty(list.values[i])) { - continue; - } - - value = list.values[i]; - if (typeof value.permission === 'undefined') { - if (jQuery('input[name=private]:checked').val() == <?= PRIVATE_SHARING ?>) { - value.permission = <?= PERM_READ ?>; - } - else { - value.permission = <?= PERM_READ_WRITE ?>; - } - } - - switch (list.object) { - case 'usrgrpid': - if (jQuery('#user_group_shares_' + value.usrgrpid).length) { - continue; - } - - tpl = new Template(jQuery('#user_group_row_tpl').html()); - - container = jQuery('#user_group_list_footer'); - container.before(tpl.evaluate(value)); - - jQuery('#user_group_' + value.usrgrpid + '_permission_' + value.permission + '') - .prop('checked', true); - break; - - case 'userid': - if (jQuery('#user_shares_' + value.id).length) { - continue; - } - - tpl = new Template(jQuery('#user_row_tpl').html()); - - container = jQuery('#user_list_footer'); - container.before(tpl.evaluate(value)); - - jQuery('#user_' + value.id + '_permission_' + value.permission + '') - .prop('checked', true); - break; - } - } - } - - function removeUserGroupShares(usrgrpid) { - jQuery('#user_group_shares_' + usrgrpid).remove(); - } - - function removeUserShares(userid) { - jQuery('#user_shares_' + userid).remove(); - } -</script> diff --git a/ui/include/views/js/monitoring.screen.js.php b/ui/include/views/js/monitoring.screen.js.php deleted file mode 100644 index 45f36030999..00000000000 --- a/ui/include/views/js/monitoring.screen.js.php +++ /dev/null @@ -1,84 +0,0 @@ -<?php -/* -** Zabbix -** Copyright (C) 2001-2021 Zabbix SIA -** -** This program is free software; you can redistribute it and/or modify -** it under the terms of the GNU General Public License as published by -** the Free Software Foundation; either version 2 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU General Public License for more details. -** -** You should have received a copy of the GNU General Public License -** along with this program; if not, write to the Free Software -** Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. -**/ - - -/** - * @var CView $this - */ -?> - -<script type="text/javascript"> - var monitoringScreen = { - refreshOnAcknowledgeCreateSubscribed: false, - - /** - * Find and refresh screen responsible for launching the "Update problem" popup after it was submitted. - * - * @param {object} response The response object from the "acknowledge.create" action. - * @param {object} overlay The overlay object of the "Update problem" popup form. - */ - refreshOnAcknowledgeCreateHandler: function(response, overlay) { - var handle_selector = '.screenitem', - handle = overlay.trigger_parents.filter(handle_selector).get(0); - - if (!handle) { - var dialogue = overlay.trigger_parents.filter('.overlay-dialogue'); - if (dialogue.length) { - var dialogue_overlay = overlays_stack.getById(dialogue.data('hintboxid')); - if (dialogue_overlay && dialogue_overlay.type === 'hintbox') { - handle = dialogue_overlay.element.closest(handle_selector); - } - } - } - - if (handle) { - for (var id in flickerfreeScreen.screens) { - if (flickerfreeScreen.screens.hasOwnProperty(id)) { - var screen = document.getElementById('flickerfreescreen_' + id); - if ($.contains(screen, handle) || $.contains(handle, screen)) { - for (var i = overlays_stack.length - 1; i >= 0; i--) { - var hintbox = overlays_stack.getById(overlays_stack.stack[i]); - if (hintbox.type === 'hintbox') { - hintbox_handle = hintbox.element.closest(handle_selector); - if ($.contains(screen, hintbox_handle) || $.contains(hintbox_handle, screen)) { - hintBox.hideHint(hintbox.element, true); - } - } - } - - clearMessages(); - addMessage(makeMessageBox('good', [], response.message, true, false)); - flickerfreeScreen.refresh(id); - } - } - } - } - }, - refreshOnAcknowledgeCreate: function() { - if (!this.refreshOnAcknowledgeCreateSubscribed) { - $.subscribe('acknowledge.create', - (event, response, overlay) => this.refreshOnAcknowledgeCreateHandler(response, overlay) - ); - - this.refreshOnAcknowledgeCreateSubscribed = true; - } - } - }; -</script> diff --git a/ui/include/views/js/monitoring.slideconf.edit.js.php b/ui/include/views/js/monitoring.slideconf.edit.js.php deleted file mode 100644 index 3360814b378..00000000000 --- a/ui/include/views/js/monitoring.slideconf.edit.js.php +++ /dev/null @@ -1,348 +0,0 @@ -<?php -/* -** Zabbix -** Copyright (C) 2001-2021 Zabbix SIA -** -** This program is free software; you can redistribute it and/or modify -** it under the terms of the GNU General Public License as published by -** the Free Software Foundation; either version 2 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU General Public License for more details. -** -** You should have received a copy of the GNU General Public License -** along with this program; if not, write to the Free Software -** Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. -**/ - - -/** - * @var CView $this - */ -?> - -<script type="text/x-jquery-tmpl" id="screenRowTPL"> -<?= (new CRow([ - (new CCol([ - (new CDiv())->addClass(ZBX_STYLE_DRAG_ICON), - new CInput('hidden', 'slides[#{rowId}][screenid]', '#{screenid}'), - new CInput('hidden', 'slides[#{rowId}][slideid]') - ]))->addClass(ZBX_STYLE_TD_DRAG_ICON), - (new CSpan('#{rowNum}:')) - ->addClass('rowNum') - ->setId('current_slide_#{rowId}'), - '#{name}', - (new CTextBox('slides[#{rowId}][delay]')) - ->setWidth(ZBX_TEXTAREA_TINY_WIDTH) - ->setAttribute('placeholder', _('default')), - (new CCol( - (new CButton('remove_#{rowId}', _('Remove'))) - ->onClick('javascript: removeSlide(this);') - ->addClass(ZBX_STYLE_BTN_LINK) - ->setAttribute('remove_slide', '#{rowId}') - ))->addClass(ZBX_STYLE_NOWRAP) -])) - ->addClass('sortable') - ->setId('slides_#{rowId}') - ->toString() -?> -</script> - -<script type="text/x-jquery-tmpl" id="user_group_row_tpl"> - <?= (new CRow([ - new CCol([ - (new CTextBox('userGroups[#{usrgrpid}][usrgrpid]', '#{usrgrpid}'))->setAttribute('type', 'hidden'), - (new CSpan('#{name}')) - ]), - new CCol( - (new CTag('ul', false, [ - new CTag('li', false, [ - (new CInput('radio', 'userGroups[#{usrgrpid}][permission]', PERM_READ)) - ->setId('user_group_#{usrgrpid}_permission_'.PERM_READ), - (new CTag('label', false, _('Read-only'))) - ->setAttribute('for', 'user_group_#{usrgrpid}_permission_'.PERM_READ) - ]), - new CTag('li', false, [ - (new CInput('radio', 'userGroups[#{usrgrpid}][permission]', PERM_READ_WRITE)) - ->setId('user_group_#{usrgrpid}_permission_'.PERM_READ_WRITE), - (new CTag('label', false, _('Read-write'))) - ->setAttribute('for', 'user_group_#{usrgrpid}_permission_'.PERM_READ_WRITE) - ]) - ]))->addClass(CRadioButtonList::ZBX_STYLE_CLASS) - ), - (new CCol( - (new CButton('remove', _('Remove'))) - ->addClass(ZBX_STYLE_BTN_LINK) - ->onClick('removeUserGroupShares("#{usrgrpid}");') - ->removeId() - ))->addClass(ZBX_STYLE_NOWRAP) - ])) - ->setId('user_group_shares_#{usrgrpid}') - ->toString() - ?> -</script> - -<script type="text/x-jquery-tmpl" id="user_row_tpl"> - <?= (new CRow([ - new CCol([ - (new CTextBox('users[#{id}][userid]', '#{id}'))->setAttribute('type', 'hidden'), - (new CSpan('#{name}')) - ]), - new CCol( - (new CTag('ul', false, [ - new CTag('li', false, [ - (new CInput('radio', 'users[#{id}][permission]', PERM_READ)) - ->setId('user_#{id}_permission_'.PERM_READ), - (new CTag('label', false, _('Read-only'))) - ->setAttribute('for', 'user_#{id}_permission_'.PERM_READ) - ]), - new CTag('li', false, [ - (new CInput('radio', 'users[#{id}][permission]', PERM_READ_WRITE)) - ->setId('user_#{id}_permission_'.PERM_READ_WRITE), - (new CTag('label', false, _('Read-write'))) - ->setAttribute('for', 'user_#{id}_permission_'.PERM_READ_WRITE) - ]) - ]))->addClass(CRadioButtonList::ZBX_STYLE_CLASS) - ), - (new CCol( - (new CButton('remove', _('Remove'))) - ->addClass(ZBX_STYLE_BTN_LINK) - ->onClick('removeUserShares("#{id}");') - ->removeId() - ))->addClass(ZBX_STYLE_NOWRAP) - ])) - ->setId('user_shares_#{id}') - ->toString() - ?> -</script> - -<script type="text/javascript"> - jQuery(function($) { - $('#clone').click(function() { - $('#slideshowid, #delete, #clone, #inaccessible_user').remove(); - $('#update') - .text(<?= json_encode(_('Add')) ?>) - .attr({id: 'add', name: 'add'}); - - $('#form').val('clone'); - - // Switch to first tab so multiselect is visible and only then add data and resize. - $('#tab_slideTab').trigger('click'); - - $('#multiselect_userid_wrapper').show(); - - // Set current user as owner. - $('#userid').multiSelect('addData', [{ - 'id': $('#current_user_userid').val(), - 'name': $('#current_user_fullname').val() - }]); - - $('#name').focus(); - }); - }); - - function removeSlide(obj) { - var step = obj.getAttribute('remove_slide'); - - jQuery('#slides_' + step).remove(); - jQuery('#slides_' + step + '_slideid').remove(); - jQuery('#slides_' + step + '_screenid').remove(); - jQuery('#slides_' + step + '_delay').remove(); - - if (jQuery('#slideTable tr.sortable').length <= 1) { - jQuery('#slideTable').sortable('disable'); - } - - recalculateSortOrder(); - } - - function recalculateSortOrder() { - var i = 0; - - jQuery('#slideTable tr.sortable .rowNum').each(function() { - var newStep = (i == 0) ? '0' : i, - currentStep = jQuery(this).closest('tr').attr('id').split('_')[1]; - - // rewrite ids to temp - jQuery('#remove_' + currentStep).attr('id', 'tmp_remove_' + newStep); - jQuery('#slides_' + currentStep).attr('id', 'tmp_slides_' + newStep); - jQuery('#slides_' + currentStep + '_slideid').attr('id', 'tmp_slides_' + newStep + '_slideid'); - jQuery('#slides_' + currentStep + '_screenid').attr('id', 'tmp_slides_' + newStep + '_screenid'); - jQuery('#slides_' + currentStep + '_delay').attr('id', 'tmp_slides_' + newStep + '_delay'); - jQuery('#current_slide_' + currentStep).attr('id', 'tmp_current_slide_' + newStep); - - // set order number - jQuery(this) - .attr('new_slide', i) - .text((i + 1) + ':'); - i++; - }); - - // rewrite ids in new order - for (var n = 0; n < i; n++) { - var newStep = jQuery('#tmp_current_slide_' + n).attr('new_slide'); - jQuery('#tmp_current_slide_' + n).removeAttr('new_slide'); - - jQuery('#tmp_remove_' + n).attr('id', 'remove_' + newStep); - jQuery('#tmp_slides_' + n).attr('id', 'slides_' + newStep); - jQuery('#tmp_slides_' + n + '_slideid').attr('id', 'slides_' + newStep + '_slideid'); - jQuery('#tmp_slides_' + n + '_screenid').attr('id', 'slides_' + newStep + '_screenid'); - jQuery('#tmp_slides_' + n + '_delay').attr('id', 'slides_' + newStep + '_delay'); - - jQuery('#slides_' + newStep + '_slideid').attr('name', 'slides[' + newStep + '][slideid]'); - jQuery('#slides_' + newStep + '_screenid').attr('name', 'slides[' + newStep + '][screenid]'); - jQuery('#slides_' + newStep + '_delay').attr('name', 'slides[' + newStep + '][delay]'); - jQuery('#remove_' + newStep) - .attr('remove_slide', newStep) - .attr('name', 'remove_' + newStep); - - // set new slide order position - jQuery('#tmp_current_slide_' + n).attr('id', 'current_slide_' + newStep); - } - } - - /** - * @see init.js add.popup event - */ - function addPopupValues(list) { - var initSize = jQuery('#slideTable tr.sortable .rowNum').length, - defaultDelay = jQuery('#delay').val(), - i, - value, - tpl, - container; - - for (i = 0; i < list.values.length; i++) { - if (empty(list.values[i])) { - continue; - } - - value = list.values[i]; - - switch (list.object) { - case 'screenid': - value['rowId'] = jQuery('#slideTable tr.sortable .rowNum').length; - value['rowNum'] = value['rowId'] + 1; - value['rowDelay'] = defaultDelay; - - tpl = new Template(jQuery('#screenRowTPL').html()); - jQuery('#screenListFooter').before(tpl.evaluate(value)); - break; - - case 'usrgrpid': - if (jQuery('#user_group_shares_' + value.usrgrpid).length) { - continue; - } - - if (typeof value.permission === 'undefined') { - if (jQuery('input[name=private]:checked').val() == <?= PRIVATE_SHARING ?>) { - value.permission = <?= PERM_READ ?>; - } - else { - value.permission = <?= PERM_READ_WRITE ?>; - } - } - - tpl = new Template(jQuery('#user_group_row_tpl').html()); - - container = jQuery('#user_group_list_footer'); - container.before(tpl.evaluate(value)); - - jQuery('#user_group_' + value.usrgrpid + '_permission_' + value.permission + '') - .prop('checked', true); - break; - - case 'userid': - if (jQuery('#user_shares_' + value.id).length) { - continue; - } - - if (typeof value.permission === 'undefined') { - if (jQuery('input[name=private]:checked').val() == <?= PRIVATE_SHARING ?>) { - value.permission = <?= PERM_READ ?>; - } - else { - value.permission = <?= PERM_READ_WRITE ?>; - } - } - - tpl = new Template(jQuery('#user_row_tpl').html()); - - container = jQuery('#user_list_footer'); - container.before(tpl.evaluate(value)); - - jQuery('#user_' + value.id + '_permission_' + value.permission + '') - .prop('checked', true); - break; - } - } - - if (initSize < 2) { - initSortable(); - } - } - - function initSortable() { - var slideTable = jQuery('#slideTable'), - slideTableWidth = slideTable.width(), - slideTableColumns = jQuery('#slideTable .header td'), - slideTableColumnWidths = []; - - slideTableColumns.each(function() { - slideTableColumnWidths[slideTableColumnWidths.length] = jQuery(this).width(); - }); - - slideTable.sortable({ - disabled: (slideTable.find('tr.sortable').length < 2), - items: 'tbody tr.sortable', - axis: 'y', - containment: 'parent', - cursor: 'grabbing', - handle: 'div.<?= ZBX_STYLE_DRAG_ICON ?>', - tolerance: 'pointer', - opacity: 0.6, - update: recalculateSortOrder, - create: function () { - // force not to change table width - slideTable.width(slideTableWidth); - }, - helper: function(e, ui) { - ui.children().each(function(i) { - var td = jQuery(this); - - td.width(slideTableColumnWidths[i]); - }); - - // when dragging element on safari, it jumps out of the table on IE it moves about 4 pixels to right - if (SF) { - // move back draggable element to proper position - ui.css('left', (ui.offset().left - 4) + 'px'); - } - - slideTableColumns.each(function(i) { - jQuery(this).width(slideTableColumnWidths[i]); - }); - - return ui; - }, - start: function(e, ui) { - jQuery(ui.placeholder).height(jQuery(ui.helper).height()); - } - }); - } - - function removeUserGroupShares(usrgrpid) { - jQuery('#user_group_shares_' + usrgrpid).remove(); - } - - function removeUserShares(userid) { - jQuery('#user_shares_' + userid).remove(); - } - - jQuery(function() { - initSortable(); - }); -</script> diff --git a/ui/include/views/js/monitoring.slides.js.php b/ui/include/views/js/monitoring.slides.js.php deleted file mode 100644 index 472e4560d72..00000000000 --- a/ui/include/views/js/monitoring.slides.js.php +++ /dev/null @@ -1,48 +0,0 @@ -<?php -/* -** Zabbix -** Copyright (C) 2001-2021 Zabbix SIA -** -** This program is free software; you can redistribute it and/or modify -** it under the terms of the GNU General Public License as published by -** the Free Software Foundation; either version 2 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU General Public License for more details. -** -** You should have received a copy of the GNU General Public License -** along with this program; if not, write to the Free Software -** Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. -**/ - - -/** - * @var CView $this - */ -?> - -<script type="text/javascript"> - jQuery(function() { - initPMaster( - 'slideshows', - <?= - json_encode([ - WIDGET_SLIDESHOW => [ - 'frequency' => timeUnitToSeconds($data['element']['delay']) * $data['refreshMultiplier'], - 'url' => 'slides.php?output=html&elementid='.$this->data['elementId']. - (isset($this->data['hostid']) ? '&hostid='.$this->data['hostid'] : ''), - 'counter' => 0, - 'darken' => 0, - 'params' => [ - 'widgetRefresh' => WIDGET_SLIDESHOW, - 'lastupdate' => time() - ] - ] - ]) - ?> - ); - }); -</script> diff --git a/ui/include/views/monitoring.screen.constructor.edit.php b/ui/include/views/monitoring.screen.constructor.edit.php deleted file mode 100644 index 2ccd9bd3641..00000000000 --- a/ui/include/views/monitoring.screen.constructor.edit.php +++ /dev/null @@ -1,862 +0,0 @@ -<?php -/* -** Zabbix -** Copyright (C) 2001-2021 Zabbix SIA -** -** This program is free software; you can redistribute it and/or modify -** it under the terms of the GNU General Public License as published by -** the Free Software Foundation; either version 2 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU General Public License for more details. -** -** You should have received a copy of the GNU General Public License -** along with this program; if not, write to the Free Software -** Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. -**/ - - -/** - * @var CView $this - */ - -$this->includeJsFile('monitoring.screen.constructor.edit.js.php'); -$action = 'screenedit.php?form=update&screenid='.getRequest('screenid'); -if (isset($_REQUEST['screenitemid'])) { - $action .= '&screenitemid='.getRequest('screenitemid'); -} - -$form = (new CForm('post', $action)) - ->setName('screen_item_form') - ->setAttribute('aria-labeledby', ZBX_STYLE_PAGE_TITLE) - ->addVar('screenid', getRequest('screenid')); - -if (hasRequest('screenitemid')) { - $form->addVar('screenitemid', getRequest('screenitemid')); - $screenItems = zbx_toHash($this->data['screen']['screenitems'], 'screenitemid'); -} -else { - $form - ->addVar('x', getRequest('x')) - ->addVar('y', getRequest('y')); -} - -if (isset($_REQUEST['screenitemid']) && !isset($_REQUEST['form_refresh'])) { - $screenItem = $screenItems[$_REQUEST['screenitemid']]; - $resourceType = $screenItem['resourcetype']; - $resourceId = $screenItem['resourceid']; - $width = $screenItem['width']; - $height = $screenItem['height']; - $colspan = $screenItem['colspan']; - $rowspan = $screenItem['rowspan']; - $elements = $screenItem['elements']; - $valign = $screenItem['valign']; - $halign = $screenItem['halign']; - $style = $screenItem['style']; - $url = $screenItem['url']; - $dynamic = $screenItem['dynamic']; - $sortTriggers = $screenItem['sort_triggers']; - $application = $screenItem['application']; - $maxColumns = $screenItem['max_columns']; -} -else { - $resourceType = getRequest('resourcetype', 0); - $resourceId = getRequest('resourceid', 0); - $width = getRequest('width', 500); - $height = getRequest('height', 100); - $colspan = getRequest('colspan', 1); - $rowspan = getRequest('rowspan', 1); - $elements = getRequest('elements', 25); - $valign = getRequest('valign', VALIGN_DEFAULT); - $halign = getRequest('halign', HALIGN_DEFAULT); - $style = getRequest('style', 0); - $url = getRequest('url', ''); - $dynamic = getRequest('dynamic', SCREEN_SIMPLE_ITEM); - $sortTriggers = getRequest('sort_triggers', SCREEN_SORT_TRIGGERS_DATE_DESC); - $application = getRequest('application', ''); - $maxColumns = getRequest('max_columns', 3); -} - -// append resource types to form list -$screenResources = screen_resources(); - -$screenFormList = (new CFormList()) - ->addRow((new CLabel(_('Resource'), 'label-resourcetype')), - (new CSelect('resourcetype')) - ->setId('resourcetype') - ->setFocusableElementId('label-resourcetype') - ->setValue($resourceType) - ->addOptions(CSelect::createOptionsFromArray($screenResources)) - ); - -/* - * Screen item: Graph - */ -if ($resourceType == SCREEN_RESOURCE_GRAPH) { - $graph = false; - - if ($resourceId > 0) { - $graphs = API::Graph()->get([ - 'output' => ['name'], - 'selectHosts' => ['name'], - 'graphids' => $resourceId - ]); - - if ($graphs) { - $graph = reset($graphs); - - order_result($graph['hosts'], 'name'); - $graph['host'] = reset($graph['hosts']); - } - } - - $screenFormList->addRow( - (new CLabel(_('Graph'), 'resourceid_ms'))->setAsteriskMark(), - (new CMultiSelect([ - 'name' => 'resourceid', - 'object_name' => 'graphs', - 'multiple' => false, - 'data' => $graph - ? [ - [ - 'id' => $resourceId, - 'prefix' => $graph['host']['name'].NAME_DELIMITER, - 'name' => $graph['name'] - ] - ] - : [], - 'popup' => [ - 'parameters' => [ - 'srctbl' => 'graphs', - 'srcfld1' => 'graphid', - 'srcfld2' => 'name', - 'dstfrm' => $form->getName(), - 'dstfld1' => 'resourceid', - 'real_hosts' => '1', - 'with_graphs' => '1' - ] - ] - ])) - ->setWidth(ZBX_TEXTAREA_STANDARD_WIDTH) - ->setAriaRequired(true) - ); -} - -/* - * Screen item: Graph prototype - */ -elseif ($resourceType == SCREEN_RESOURCE_LLD_GRAPH) { - $graph_prototype = false; - - if ($resourceId > 0) { - $graph_prototypes = API::GraphPrototype()->get([ - 'output' => ['name'], - 'selectHosts' => ['name'], - 'graphids' => $resourceId - ]); - - if ($graph_prototypes) { - $graph_prototype = reset($graph_prototypes); - - order_result($graph_prototype['hosts'], 'name'); - $graph_prototype['host'] = reset($graph_prototype['hosts']); - } - } - - $screenFormList - ->addRow( - (new CLabel(_('Graph prototype'), 'resourceid_ms'))->setAsteriskMark(), - (new CMultiSelect([ - 'name' => 'resourceid', - 'object_name' => 'graph_prototypes', - 'multiple' => false, - 'data' => $graph_prototype - ? [ - [ - 'id' => $resourceId, - 'prefix' => $graph_prototype['host']['name'].NAME_DELIMITER, - 'name' => $graph_prototype['name'] - ] - ] - : [], - 'popup' => [ - 'parameters' => [ - 'srctbl' => 'graph_prototypes', - 'srcfld1' => 'graphid', - 'srcfld2' => 'name', - 'dstfrm' => $form->getName(), - 'dstfld1' => 'resourceid', - 'real_hosts' => '1' - ] - ] - ])) - ->setWidth(ZBX_TEXTAREA_STANDARD_WIDTH) - ->setAriaRequired() - ) - ->addRow( - (new CLabel(_('Max columns'), 'max_columns'))->setAsteriskMark(), - (new CNumericBox('max_columns', $maxColumns, 3, false, false, false)) - ->setWidth(ZBX_TEXTAREA_NUMERIC_STANDARD_WIDTH) - ->setAriaRequired() - ); -} - -/* - * Screen item: Simple graph - */ -elseif ($resourceType == SCREEN_RESOURCE_SIMPLE_GRAPH) { - $item = false; - - if ($resourceId > 0) { - $items = API::Item()->get([ - 'itemids' => $resourceId, - 'selectHosts' => ['name'], - 'output' => ['itemid', 'hostid', 'key_', 'name'], - 'webitems' => true - ]); - - if ($items) { - $items = CMacrosResolverHelper::resolveItemNames($items); - $item = reset($items); - } - } - - $screenFormList->addRow( - (new CLabel(_('Item'), 'resourceid_ms'))->setAsteriskMark(), - (new CMultiSelect([ - 'name' => 'resourceid', - 'object_name' => 'items', - 'multiple' => false, - 'data' => $item - ? [ - [ - 'id' => $resourceId, - 'prefix' => $item['hosts'][0]['name'].NAME_DELIMITER, - 'name' => $item['name_expanded'] - ] - ] - : [], - 'popup' => [ - 'parameters' => [ - 'srctbl' => 'items', - 'srcfld1' => 'itemid', - 'dstfrm' => $form->getName(), - 'dstfld1' => 'resourceid', - 'webitems' => true, - 'numeric' => true, - 'hostid' => 0, - 'real_hosts' => true, - 'with_simple_graph_items' => true - ] - ] - ])) - ->setWidth(ZBX_TEXTAREA_STANDARD_WIDTH) - ->setAriaRequired(true) - ); -} - -/* - * Screen item: Simple graph prototype - */ -elseif ($resourceType == SCREEN_RESOURCE_LLD_SIMPLE_GRAPH) { - $caption = ''; - $id = 0; - - $items = API::ItemPrototype()->get([ - 'output' => ['hostid', 'key_', 'name'], - 'itemids' => $resourceId, - 'selectHosts' => ['name'] - ]); - - if ($items) { - $items = CMacrosResolverHelper::resolveItemNames($items); - - $id = $resourceId; - $item = reset($items); - $item['host'] = reset($item['hosts']); - - $caption = $item['host']['name'].NAME_DELIMITER.$item['name_expanded']; - } - - $selectButton = (new CButton('select', _('Select'))) - ->addClass(ZBX_STYLE_BTN_GREY) - ->onClick('return PopUp("popup.generic",'. - json_encode([ - 'srctbl' => 'item_prototypes', - 'srcfld1' => 'itemid', - 'srcfld2' => 'name', - 'dstfrm' => $form->getName(), - 'dstfld1' => 'resourceid', - 'dstfld2' => 'caption', - 'real_hosts' => '1', - 'with_discovery_rule' => '1', - 'items' => '1', - 'numeric' => '1' - ]).', null, this);' - ); - - $form->addVar('resourceid', $id); - $screenFormList->addRow((new CLabel(_('Item prototype'), 'caption'))->setAsteriskMark(), [ - (new CTextBox('caption', $caption, true)) - ->setWidth(ZBX_TEXTAREA_STANDARD_WIDTH) - ->setAriaRequired(), - (new CDiv())->addClass(ZBX_STYLE_FORM_INPUT_MARGIN), - $selectButton - ]); - - $screenFormList->addRow( - (new CLabel(_('Max columns'), 'max_columns'))->setAsteriskMark(), - (new CNumericBox('max_columns', $maxColumns, 3, false, false, false)) - ->setAriaRequired() - ->setWidth(ZBX_TEXTAREA_NUMERIC_STANDARD_WIDTH) - ); -} - -/* - * Screen item: Map - */ -elseif ($resourceType == SCREEN_RESOURCE_MAP) { - $caption = ''; - $id = 0; - - $maps = API::Map()->get([ - 'sysmapids' => $resourceId, - 'output' => API_OUTPUT_EXTEND - ]); - if (!empty($maps)) { - $id = $resourceId; - $map = reset($maps); - $caption = $map['name']; - } - - $form->addVar('resourceid', $id); - $screenFormList->addRow((new CLabel(_('Map'), 'caption'))->setAsteriskMark(), [ - (new CTextBox('caption', $caption, true)) - ->setWidth(ZBX_TEXTAREA_STANDARD_WIDTH) - ->setAriaRequired(), - (new CDiv())->addClass(ZBX_STYLE_FORM_INPUT_MARGIN), - (new CButton('select', _('Select'))) - ->addClass(ZBX_STYLE_BTN_GREY) - ->onClick('return PopUp("popup.generic",'. - json_encode([ - 'srctbl' => 'sysmaps', - 'srcfld1' => 'sysmapid', - 'srcfld2' => 'name', - 'dstfrm' => $form->getName(), - 'dstfld1' => 'resourceid', - 'dstfld2' => 'caption' - ]).', null, this);' - ) - ]); -} - -/* - * Screen item: Plain text - */ -elseif ($resourceType == SCREEN_RESOURCE_PLAIN_TEXT) { - $item = false; - - if ($resourceId != 0) { - $items = API::Item()->get([ - 'output' => ['itemid', 'hostid', 'key_', 'name'], - 'selectHosts' => ['name'], - 'itemids' => $resourceId, - 'webitems' => true - ]); - - if ($items) { - $items = CMacrosResolverHelper::resolveItemNames($items); - $item = reset($items); - } - } - - $screenFormList - ->addRow( - (new CLabel(_('Item'), 'resourceid_ms'))->setAsteriskMark(), - (new CMultiSelect([ - 'name' => 'resourceid', - 'object_name' => 'items', - 'multiple' => false, - 'data' => $item - ? [ - [ - 'id' => $resourceId, - 'prefix' => $item['hosts'][0]['name'].NAME_DELIMITER, - 'name' => $item['name_expanded'] - ] - ] - : [], - 'popup' => [ - 'parameters' => [ - 'srctbl' => 'items', - 'srcfld1' => 'itemid', - 'dstfrm' => $form->getName(), - 'dstfld1' => 'resourceid', - 'hostid' => 0, - 'real_hosts' => true, - 'webitems' => true - ] - ] - ])) - ->setWidth(ZBX_TEXTAREA_STANDARD_WIDTH) - ->setAriaRequired(true) - ) - ->addRow((new CLabel(_('Show lines'), 'elements'))->setAsteriskMark(), - (new CNumericBox('elements', $elements, 3)) - ->setAriaRequired() - ->setWidth(ZBX_TEXTAREA_NUMERIC_STANDARD_WIDTH) - ) - ->addRow(_('Show text as HTML'), - (new CCheckBox('style')) - ->setChecked($style == 1) - ->removeId() - ); -} - -/* - * Screen item: Triggers - */ -elseif (in_array($resourceType, [SCREEN_RESOURCE_HOSTGROUP_TRIGGERS, SCREEN_RESOURCE_HOST_TRIGGERS])) { - $data = []; - - if ($resourceType == SCREEN_RESOURCE_HOSTGROUP_TRIGGERS) { - if ($resourceId > 0) { - $data = API::HostGroup()->get([ - 'groupids' => $resourceId, - 'output' => ['groupid', 'name'] - ]); - - if ($data) { - $data = reset($data); - } - } - - $screenFormList->addRow((new CLabel(_('Group'), 'resourceid_ms')), - (new CMultiSelect([ - 'name' => 'resourceid', - 'object_name' => 'hostGroup', - 'multiple' => false, - 'default_value' => 0, - 'data' => $data - ? [ - [ - 'id' => $data['groupid'], - 'name' => $data['name'] - ] - ] - : [], - 'popup' => [ - 'parameters' => [ - 'srctbl' => 'host_groups', - 'srcfld1' => 'groupid', - 'dstfrm' => $form->getName(), - 'dstfld1' => 'resourceid', - 'real_hosts' => true - ] - ] - ]))->setWidth(ZBX_TEXTAREA_STANDARD_WIDTH) - ); - } - else { - if ($resourceId > 0) { - $data = API::Host()->get([ - 'hostids' => $resourceId, - 'output' => ['hostid', 'name'] - ]); - - if ($data) { - $data = reset($data); - } - } - - $screenFormList->addRow((new CLabel(_('Host'), 'resourceid_ms')), - (new CMultiSelect([ - 'name' => 'resourceid', - 'object_name' => 'hosts', - 'multiple' => false, - 'default_value' => 0, - 'data' => $data - ? [ - [ - 'id' => $data['hostid'], - 'name' => $data['name'] - ] - ] - : [], - 'popup' => [ - 'parameters' => [ - 'srctbl' => 'hosts', - 'srcfld1' => 'hostid', - 'dstfrm' => $form->getName(), - 'dstfld1' => 'resourceid' - ] - ] - ]))->setWidth(ZBX_TEXTAREA_STANDARD_WIDTH) - ); - } - - $screenFormList->addRow( - (new CLabel(_('Show lines'), 'elements'))->setAsteriskMark(), - (new CNumericBox('elements', $elements, 3)) - ->setAriaRequired() - ->setWidth(ZBX_TEXTAREA_NUMERIC_STANDARD_WIDTH) - ); - $screenFormList->addRow( - new CLabel(_('Sort triggers by'), 'label-sort-triggers'), - (new CSelect('sort_triggers')) - ->setFocusableElementId('label-sort-triggers') - ->setValue($sortTriggers) - ->addOptions(CSelect::createOptionsFromArray([ - SCREEN_SORT_TRIGGERS_DATE_DESC => _('Last change (descending)'), - SCREEN_SORT_TRIGGERS_SEVERITY_DESC => _('Severity (descending)'), - SCREEN_SORT_TRIGGERS_HOST_NAME_ASC => _('Host (ascending)') - ])) - ); -} - -/* - * Screen item: Action log - */ -elseif ($resourceType == SCREEN_RESOURCE_ACTIONS) { - $screenFormList->addRow( - (new CLabel(_('Show lines'), 'elements'))->setAsteriskMark(), - (new CNumericBox('elements', $elements, 3)) - ->setAriaRequired() - ->setWidth(ZBX_TEXTAREA_NUMERIC_STANDARD_WIDTH) - ); - $screenFormList->addRow( - new CLabel(_('Sort entries by'), 'label-sort-triggers'), - (new CSelect('sort_triggers')) - ->setFocusableElementId('label-sort-triggers') - ->setValue($sortTriggers) - ->addOptions(CSelect::createOptionsFromArray([ - SCREEN_SORT_TRIGGERS_TIME_DESC => _('Time (descending)'), - SCREEN_SORT_TRIGGERS_TIME_ASC => _('Time (ascending)'), - SCREEN_SORT_TRIGGERS_TYPE_DESC => _('Type (descending)'), - SCREEN_SORT_TRIGGERS_TYPE_ASC => _('Type (ascending)'), - SCREEN_SORT_TRIGGERS_STATUS_DESC => _('Status (descending)'), - SCREEN_SORT_TRIGGERS_STATUS_ASC => _('Status (ascending)'), - SCREEN_SORT_TRIGGERS_RECIPIENT_DESC => _('Recipient (descending)'), - SCREEN_SORT_TRIGGERS_RECIPIENT_ASC => _('Recipient (ascending)') - ])) - ); -} - -/* - * Screen item: History of events - */ -elseif ($resourceType == SCREEN_RESOURCE_EVENTS) { - $screenFormList->addRow( - (new CLabel(_('Show lines'), 'elements'))->setAsteriskMark(), - (new CNumericBox('elements', $elements, 3)) - ->setAriaRequired() - ->setWidth(ZBX_TEXTAREA_NUMERIC_STANDARD_WIDTH) - ); - $form->addVar('resourceid', 0); -} - -/* - * Screen item: Overviews - */ -elseif (in_array($resourceType, [SCREEN_RESOURCE_TRIGGER_OVERVIEW, SCREEN_RESOURCE_DATA_OVERVIEW])) { - $data = []; - - if ($resourceId > 0) { - $data = API::HostGroup()->get([ - 'groupids' => $resourceId, - 'output' => ['groupid', 'name'] - ]); - - if ($data) { - $data = reset($data); - } - } - - $screenFormList->addRow((new CLabel(_('Group'), 'resourceid_ms'))->setAsteriskMark(), - (new CMultiSelect([ - 'name' => 'resourceid', - 'object_name' => 'hostGroup', - 'multiple' => false, - 'data' => $data - ? [ - [ - 'id' => $data['groupid'], - 'name' => $data['name'] - ] - ] - : [], - 'popup' => [ - 'parameters' => [ - 'srctbl' => 'host_groups', - 'srcfld1' => 'groupid', - 'dstfrm' => $form->getName(), - 'dstfld1' => 'resourceid', - 'real_hosts' => true - ] - ] - ])) - ->setWidth(ZBX_TEXTAREA_STANDARD_WIDTH) - ->setAriaRequired() - ) - ->addRow(_('Application'), [ - (new CTextBox('application', $application)) - ->setWidth(ZBX_TEXTAREA_STANDARD_WIDTH), - (new CDiv())->addClass(ZBX_STYLE_FORM_INPUT_MARGIN), - (new CButton('application_select', _('Select'))) - ->addClass(ZBX_STYLE_BTN_GREY) - ->onClick('return PopUp("popup.generic", '. - json_encode([ - 'srctbl' => 'applications', - 'srcfld1' => 'name', - 'dstfrm' => $form->getName(), - 'dstfld1' => 'application', - 'real_hosts' => '1', - 'with_applications' => '1' - ]).', null, this);' - ) - ]); -} - -/* - * Screen item: Host info - */ -elseif ($resourceType == SCREEN_RESOURCE_HOST_INFO || $resourceType == SCREEN_RESOURCE_TRIGGER_INFO) { - $data = []; - - if ($resourceId > 0) { - $data = API::HostGroup()->get([ - 'groupids' => $resourceId, - 'output' => ['groupid', 'name'] - ]); - - if ($data) { - $data = reset($data); - } - } - - $screenFormList->addRow((new CLabel(_('Group'), 'resourceid_ms')), - (new CMultiSelect([ - 'name' => 'resourceid', - 'object_name' => 'hostGroup', - 'multiple' => false, - 'default_value' => 0, - 'data' => $data - ? [ - [ - 'id' => $data['groupid'], - 'name' => $data['name'] - ] - ] - : [], - 'popup' => [ - 'parameters' => [ - 'srctbl' => 'host_groups', - 'srcfld1' => 'groupid', - 'dstfrm' => $form->getName(), - 'dstfld1' => 'resourceid', - 'real_hosts' => true - ] - ] - ]))->setWidth(ZBX_TEXTAREA_STANDARD_WIDTH) - ); -} - -/* - * Screen item: Clock - */ -elseif ($resourceType == SCREEN_RESOURCE_CLOCK) { - $item = false; - - $screenFormList->addRow(new CLabel(_('Time type'), 'label-time-type'), - (new CSelect('style')) - ->setValue($style) - ->setId('style') - ->setFocusableElementId('label-time-type') - ->addOptions(CSelect::createOptionsFromArray([ - TIME_TYPE_LOCAL => _('Local time'), - TIME_TYPE_SERVER => _('Server time'), - TIME_TYPE_HOST => _('Host time') - ])) - ); - - if ($style == TIME_TYPE_HOST) { - if ($resourceId > 0) { - $items = API::Item()->get([ - 'output' => ['itemid', 'hostid', 'key_', 'name'], - 'selectHosts' => ['name'], - 'itemids' => $resourceId, - 'webitems' => true - ]); - - if ($items) { - $items = CMacrosResolverHelper::resolveItemNames($items); - $item = reset($items); - } - } - - $screenFormList->addRow( - (new CLabel(_('Item'), 'resourceid_ms'))->setAsteriskMark(), - (new CMultiSelect([ - 'name' => 'resourceid', - 'object_name' => 'items', - 'multiple' => false, - 'data' => $item - ? [ - [ - 'id' => $resourceId, - 'prefix' => $item['hosts'][0]['name'].NAME_DELIMITER, - 'name' => $item['name_expanded'] - ] - ] - : [], - 'popup' => [ - 'parameters' => [ - 'srctbl' => 'items', - 'srcfld1' => 'itemid', - 'dstfrm' => $form->getName(), - 'dstfld1' => 'resourceid', - 'hostid' => 0, - 'real_hosts' => true, - 'webitems' => true - ] - ] - ])) - ->setWidth(ZBX_TEXTAREA_STANDARD_WIDTH) - ->setAriaRequired(true) - ); - } -} - -/* - * Append common fields - */ -if (in_array($resourceType, [SCREEN_RESOURCE_HOST_INFO, SCREEN_RESOURCE_TRIGGER_INFO])) { - $screenFormList->addRow(_('Style'), - (new CRadioButtonList('style', (int) $style)) - ->addValue(_('Horizontal'), STYLE_HORIZONTAL) - ->addValue(_('Vertical'), STYLE_VERTICAL) - ->setModern(true) - ); -} -elseif (in_array($resourceType, [SCREEN_RESOURCE_TRIGGER_OVERVIEW, SCREEN_RESOURCE_DATA_OVERVIEW])) { - $screenFormList->addRow(_('Hosts location'), - (new CRadioButtonList('style', (int) $style)) - ->addValue(_('Left'), STYLE_LEFT) - ->addValue(_('Top'), STYLE_TOP) - ->setModern(true) - ); -} -elseif ($resourceType != SCREEN_RESOURCE_CLOCK) { - $form->addVar('style', 0); -} - -if (in_array($resourceType, [SCREEN_RESOURCE_URL])) { - $screenFormList->addRow((new CLabel(_('URL'), 'url'))->setAsteriskMark(), - (new CTextBox('url', $url))->setWidth(ZBX_TEXTAREA_STANDARD_WIDTH)->setAriaRequired() - ); -} -else { - $form->addVar('url', ''); -} - -$resourcesWithWidthAndHeight = [ - SCREEN_RESOURCE_GRAPH, - SCREEN_RESOURCE_SIMPLE_GRAPH, - SCREEN_RESOURCE_CLOCK, - SCREEN_RESOURCE_URL, - SCREEN_RESOURCE_LLD_GRAPH, - SCREEN_RESOURCE_LLD_SIMPLE_GRAPH -]; -if (in_array($resourceType, $resourcesWithWidthAndHeight)) { - $screenFormList->addRow(_('Width'), - (new CNumericBox('width', $width, 5))->setWidth(ZBX_TEXTAREA_NUMERIC_STANDARD_WIDTH) - ); - $screenFormList->addRow(_('Height'), - (new CNumericBox('height', $height, 5))->setWidth(ZBX_TEXTAREA_NUMERIC_STANDARD_WIDTH) - ); -} -else { - $form - ->addVar('width', 500) - ->addVar('height', 100); -} - -$resourcesWithHAlign = [ - SCREEN_RESOURCE_GRAPH, - SCREEN_RESOURCE_SIMPLE_GRAPH, - SCREEN_RESOURCE_MAP, - SCREEN_RESOURCE_CLOCK, - SCREEN_RESOURCE_URL, - SCREEN_RESOURCE_LLD_GRAPH, - SCREEN_RESOURCE_LLD_SIMPLE_GRAPH -]; -if (in_array($resourceType, $resourcesWithHAlign)) { - $screenFormList->addRow(_('Horizontal align'), - (new CRadioButtonList('halign', (int) $halign)) - ->addValue(_('Left'), HALIGN_LEFT) - ->addValue(_('Centre'), HALIGN_CENTER) - ->addValue(_('Right'), HALIGN_RIGHT) - ->setModern(true) - ); -} -else { - $form->addVar('halign', 0); -} - -$screenFormList->addRow(_('Vertical align'), - (new CRadioButtonList('valign', (int) $valign)) - ->addValue(_('Top'), VALIGN_TOP) - ->addValue(_('Middle'), VALIGN_MIDDLE) - ->addValue(_('Bottom'), VALIGN_BOTTOM) - ->setModern(true) -); -$screenFormList->addRow( - (new CLabel(_('Column span'), 'colspan'))->setAsteriskMark(), - (new CNumericBox('colspan', $colspan, 3)) - ->setAriaRequired() - ->setWidth(ZBX_TEXTAREA_NUMERIC_STANDARD_WIDTH) -); -$screenFormList->addRow( - (new CLabel(_('Row span'), 'rowspan'))->setAsteriskMark(), - (new CNumericBox('rowspan', $rowspan, 3)) - ->setAriaRequired() - ->setWidth(ZBX_TEXTAREA_NUMERIC_STANDARD_WIDTH) -); - -// dynamic addon -$resourcesWithDynamic = [ - SCREEN_RESOURCE_GRAPH, - SCREEN_RESOURCE_SIMPLE_GRAPH, - SCREEN_RESOURCE_PLAIN_TEXT, - SCREEN_RESOURCE_URL, - SCREEN_RESOURCE_LLD_GRAPH, - SCREEN_RESOURCE_LLD_SIMPLE_GRAPH -]; -if (in_array($resourceType, $resourcesWithDynamic)) { - $screenFormList->addRow(_('Dynamic item'), (new CCheckBox('dynamic'))->setChecked($dynamic == 1)); -} - -// append list to form -$form->addItem($screenFormList); - -// append buttons to form -if (isset($_REQUEST['screenitemid'])) { - $form->addItem(makeFormFooter( - new CSubmit('update', _('Update')), - [ - new CButtonDelete(null, url_params(['form', 'screenid', 'screenitemid'])), - new CButtonCancel(url_param('screenid')) - ] - )); -} -else { - $form->addItem(makeFormFooter( - new CSubmit('add', _('Add')), - [new CButtonCancel(url_param('screenid'))] - )); -} - -$form->show(); diff --git a/ui/include/views/monitoring.screen.constructor.list.php b/ui/include/views/monitoring.screen.constructor.list.php deleted file mode 100644 index 2b2a7f9ac93..00000000000 --- a/ui/include/views/monitoring.screen.constructor.list.php +++ /dev/null @@ -1,43 +0,0 @@ -<?php -/* -** Zabbix -** Copyright (C) 2001-2021 Zabbix SIA -** -** This program is free software; you can redistribute it and/or modify -** it under the terms of the GNU General Public License as published by -** the Free Software Foundation; either version 2 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU General Public License for more details. -** -** You should have received a copy of the GNU General Public License -** along with this program; if not, write to the Free Software -** Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. -**/ - - -/** - * @var CView $this - */ - -$this->includeJsFile('monitoring.screen.js.php'); - -$widget = (new CWidget())->setTitle(_('Screens').': '.$data['screen']['name']); - -$screenBuilder = new CScreenBuilder([ - 'isFlickerfree' => false, - 'screen' => $data['screen'], - 'mode' => SCREEN_MODE_EDIT -]); - -$widget->addItem( - (new CDiv($screenBuilder->show()))->addClass(ZBX_STYLE_TABLE_FORMS_CONTAINER) -); - -$screenBuilder->insertInitScreenJs($data['screenid']); -$screenBuilder->insertProcessObjectsJs(); - -$widget->show(); diff --git a/ui/include/views/monitoring.screen.edit.php b/ui/include/views/monitoring.screen.edit.php deleted file mode 100644 index 07c7378fc36..00000000000 --- a/ui/include/views/monitoring.screen.edit.php +++ /dev/null @@ -1,233 +0,0 @@ -<?php -/* -** Zabbix -** Copyright (C) 2001-2021 Zabbix SIA -** -** This program is free software; you can redistribute it and/or modify -** it under the terms of the GNU General Public License as published by -** the Free Software Foundation; either version 2 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU General Public License for more details. -** -** You should have received a copy of the GNU General Public License -** along with this program; if not, write to the Free Software -** Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. -**/ - - -/** - * @var CView $this - */ - -require_once dirname(__FILE__).'/js/monitoring.screen.edit.js.php'; - -$widget = (new CWidget())->setTitle(_('Screens')); - -$tabs = new CTabView(); - -if (!$data['form_refresh']) { - $tabs->setSelected(0); -} - -// create form -$form = (new CForm()) - ->setName('screenForm') - ->setAttribute('aria-labeledby', ZBX_STYLE_PAGE_TITLE) - ->addVar('form', $data['form']); - -$form - ->addVar('current_user_userid', $data['current_user_userid']) - ->addVar('current_user_fullname', getUserFullname($data['users'][$data['current_user_userid']])); - -if ($data['screen']['screenid']) { - $form->addVar('screenid', $data['screen']['screenid']); -} - -$user_type = CWebUser::getType(); - -// Create screen form list. -$screen_tab = (new CFormList()); - -// Screen owner multiselect. -$multiselect_data = [ - 'name' => 'userid', - 'object_name' => 'users', - 'multiple' => false, - 'disabled' => ($user_type != USER_TYPE_SUPER_ADMIN && $user_type != USER_TYPE_ZABBIX_ADMIN), - 'data' => [], - 'popup' => [ - 'parameters' => [ - 'srctbl' => 'users', - 'srcfld1' => 'userid', - 'srcfld2' => 'fullname', - 'dstfrm' => $form->getName(), - 'dstfld1' => 'userid' - ] - ] -]; - -$screen_ownerid = $data['screen']['userid']; - -if ($screen_ownerid !== '') { - $multiselect_data['data'][] = array_key_exists($screen_ownerid, $data['users']) - ? [ - 'id' => $screen_ownerid, - 'name' => getUserFullname($data['users'][$screen_ownerid]) - ] - : [ - 'id' => $screen_ownerid, - 'name' => _('Inaccessible user'), - 'inaccessible' => true - ]; -} - -// Append multiselect to screen tab. -$screen_tab->addRow((new CLabel(_('Owner'), 'userid_ms'))->setAsteriskMark(), - (new CMultiSelect($multiselect_data)) - ->setWidth(ZBX_TEXTAREA_STANDARD_WIDTH) - ->setAriaRequired() -); - -$screen_tab->addRow( - (new CLabel(_('Name'), 'name'))->setAsteriskMark(), - (new CTextBox('name', $data['screen']['name'])) - ->setWidth(ZBX_TEXTAREA_STANDARD_WIDTH) - ->setAriaRequired() - ->setAttribute('autofocus', 'autofocus') - ) - ->addRow((new CLabel(_('Columns'), 'hsize'))->setAsteriskMark(), - (new CNumericBox('hsize', $data['screen']['hsize'], 3)) - ->setWidth(ZBX_TEXTAREA_NUMERIC_STANDARD_WIDTH) - ->setAriaRequired() - ) - ->addRow((new CLabel(_('Rows'), 'vsize'))->setAsteriskMark(), - (new CNumericBox('vsize', $data['screen']['vsize'], 3)) - ->setWidth(ZBX_TEXTAREA_NUMERIC_STANDARD_WIDTH) - ->setAriaRequired() - ); - -// append tab to form -$tabs->addTab('screen_tab', _('Screen'), $screen_tab); - -// User group sharing table. -$user_group_shares_table = (new CTable()) - ->setHeader([_('User groups'), _('Permissions'), _('Action')]) - ->setAttribute('style', 'width: 100%;'); - -$add_user_group_btn = ([(new CButton(null, _('Add'))) - ->onClick('return PopUp("popup.generic",'. - json_encode([ - 'srctbl' => 'usrgrp', - 'srcfld1' => 'usrgrpid', - 'srcfld2' => 'name', - 'dstfrm' => $form->getName(), - 'multiselect' => '1' - ]).', null, this);' - ) - ->addClass(ZBX_STYLE_BTN_LINK)]); - -$user_group_shares_table->addRow( - (new CRow( - (new CCol($add_user_group_btn))->setColSpan(3) - ))->setId('user_group_list_footer') -); - -$user_groups = []; - -foreach ($data['screen']['userGroups'] as $user_group) { - $user_groupid = $user_group['usrgrpid']; - $user_groups[$user_groupid] = [ - 'usrgrpid' => $user_groupid, - 'name' => $data['user_groups'][$user_groupid]['name'], - 'permission' => $user_group['permission'] - ]; -} - -$js_insert = 'addPopupValues('.zbx_jsvalue(['object' => 'usrgrpid', 'values' => $user_groups]).');'; - -// User sharing table. -$user_shares_table = (new CTable()) - ->setHeader([_('Users'), _('Permissions'), _('Action')]) - ->setAttribute('style', 'width: 100%;'); - -$add_user_btn = ([(new CButton(null, _('Add'))) - ->onClick('return PopUp("popup.generic",'. - json_encode([ - 'srctbl' => 'users', - 'srcfld1' => 'userid', - 'srcfld2' => 'fullname', - 'dstfrm' => $form->getName(), - 'multiselect' => '1' - ]).', null, this);' - ) - ->addClass(ZBX_STYLE_BTN_LINK)]); - -$user_shares_table->addRow( - (new CRow( - (new CCol($add_user_btn))->setColSpan(3) - ))->setId('user_list_footer') -); - -$users = []; - -foreach ($data['screen']['users'] as $user) { - $userid = $user['userid']; - $users[$userid] = [ - 'id' => $userid, - 'name' => getUserFullname($data['users'][$userid]), - 'permission' => $user['permission'] - ]; -} - -$js_insert .= 'addPopupValues('.zbx_jsvalue(['object' => 'userid', 'values' => $users]).');'; - -zbx_add_post_js($js_insert); - -$sharing_tab = (new CFormList('sharing_form')) - ->addRow(_('Type'), - (new CRadioButtonList('private', (int) $data['screen']['private'])) - ->addValue(_('Private'), PRIVATE_SHARING) - ->addValue(_('Public'), PUBLIC_SHARING) - ->setModern(true) - ) - ->addRow(_('List of user group shares'), - (new CDiv($user_group_shares_table)) - ->addClass(ZBX_STYLE_TABLE_FORMS_SEPARATOR) - ->setAttribute('style', 'min-width: '.ZBX_TEXTAREA_STANDARD_WIDTH.'px;') - ) - ->addRow(_('List of user shares'), - (new CDiv($user_shares_table)) - ->addClass(ZBX_STYLE_TABLE_FORMS_SEPARATOR) - ->setAttribute('style', 'min-width: '.ZBX_TEXTAREA_STANDARD_WIDTH.'px;') - ); - -// Append data to form. -$tabs->addTab('sharing_tab', _('Sharing'), $sharing_tab); - -if ($data['form'] === 'update') { - $tabs->setFooter(makeFormFooter( - new CSubmit('update', _('Update')), - [ - (new CSimpleButton(_('Clone')))->setId('clone'), - new CButton('full_clone', _('Full clone')), - new CButtonDelete(_('Delete screen?'), url_params(['form', 'screenid'])), - new CButtonCancel() - ] - )); -} -else { - $tabs->setFooter(makeFormFooter( - new CSubmit('add', _('Add')), - [new CButtonCancel()] - )); -} - -$form->addItem($tabs); - -$widget->addItem($form); - -$widget->show(); diff --git a/ui/include/views/monitoring.screen.list.php b/ui/include/views/monitoring.screen.list.php deleted file mode 100644 index 56a6dfdbd5e..00000000000 --- a/ui/include/views/monitoring.screen.list.php +++ /dev/null @@ -1,137 +0,0 @@ -<?php -/* -** Zabbix -** Copyright (C) 2001-2021 Zabbix SIA -** -** This program is free software; you can redistribute it and/or modify -** it under the terms of the GNU General Public License as published by -** the Free Software Foundation; either version 2 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU General Public License for more details. -** -** You should have received a copy of the GNU General Public License -** along with this program; if not, write to the Free Software -** Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. -**/ - - -/** - * @var CView $this - */ - -$widget = (new CWidget())->setTitle(_('Screens')); - -$form = (new CForm('get'))->cleanItems(); - -$content_control = (new CList())->addItem((new CSubmit('form', _('Create screen')))->setEnabled($data['allowed_edit'])); - -$widget->setTitleSubmenu([ - 'main_section' => [ - 'items' => [ - 'screens.php' => _('Screens'), - 'slides.php' => _('Slide shows') - ] - ] -]); - -$content_control->addItem( - (new CButton('form', _('Import'))) - ->setEnabled($data['allowed_edit']) - ->onClick('return PopUp("popup.import", jQuery.extend('. - json_encode(['rules_preset' => 'screen']).', null), null, this);' - ) - ->removeId() -); - -$form->addItem($content_control); -$widget->setControls((new CTag('nav', true, $form)) - ->setAttribute('aria-label', _('Content controls')) -); - -// filter -$widget->addItem( - (new CFilter(new CUrl('screenconf.php'))) - ->setProfile($data['profileIdx']) - ->setActiveTab($data['active_tab']) - ->addFilterTab(_('Filter'), [ - (new CFormList())->addRow(_('Name'), - (new CTextBox('filter_name', $data['filter']['name'])) - ->setWidth(ZBX_TEXTAREA_FILTER_STANDARD_WIDTH) - ->setAttribute('autofocus', 'autofocus') - ) - ]) -); - -// create form -$screenForm = (new CForm())->setName('screenForm'); - -// create table -$screenTable = (new CTableInfo()) - ->setHeader([ - (new CColHeader( - (new CCheckBox('all_screens'))->onClick("checkAll('".$screenForm->getName()."', 'all_screens', 'screens');") - ))->addClass(ZBX_STYLE_CELL_WIDTH), - make_sorting_header(_('Name'), 'name', $data['sort'], $data['sortorder'], - (new CUrl('screenconf.php'))->getUrl() - ), - _('Dimension (cols x rows)'), - _('Actions') - ]); - -foreach ($data['screens'] as $screen) { - $user_type = CWebUser::getType(); - - if ($user_type == USER_TYPE_SUPER_ADMIN || $user_type == USER_TYPE_ZABBIX_ADMIN || $screen['editable']) { - $checkbox = new CCheckBox('screens['.$screen['screenid'].']', $screen['screenid']); - $action = $data['allowed_edit'] - ? new CLink(_('Properties'), '?form=update&screenid='.$screen['screenid']) - : _('Properties'); - $constructor = $data['allowed_edit'] - ? new CLink(_('Constructor'), 'screenedit.php?screenid='.$screen['screenid']) - : _('Constructor'); - } - else { - $checkbox = (new CCheckBox('screens['.$screen['screenid'].']', $screen['screenid'])) - ->setAttribute('disabled', 'disabled'); - $action = ''; - $constructor = ''; - } - - $screenTable->addRow([ - $checkbox, - new CLink($screen['name'], 'screens.php?elementid='.$screen['screenid']), - $screen['hsize'].' x '.$screen['vsize'], - new CHorList([$action, $constructor]) - ]); -} - -// buttons -$buttons = []; - -$buttons['screen.export'] = [ - 'content' => new CButtonExport('export.screens', - (new CUrl('screenconf.php')) - ->setArgument('page', ($data['page'] == 1) ? null : $data['page']) - ->getUrl() - ) -]; - -$buttons['screen.massdelete'] = ['name' => _('Delete'), 'confirm' => _('Delete selected screens?'), - 'disabled' => $data['allowed_edit'] ? null : 'disabled' -]; - -// append table to form -$screenForm->addItem([ - $screenTable, - $data['paging'], - new CActionButtonList('action', 'screens', $buttons) -]); - -// append form to widget -$widget->addItem($screenForm); - -$widget->show(); diff --git a/ui/include/views/monitoring.screen.php b/ui/include/views/monitoring.screen.php deleted file mode 100644 index 1d788717a99..00000000000 --- a/ui/include/views/monitoring.screen.php +++ /dev/null @@ -1,143 +0,0 @@ -<?php -/* -** Zabbix -** Copyright (C) 2001-2021 Zabbix SIA -** -** This program is free software; you can redistribute it and/or modify -** it under the terms of the GNU General Public License as published by -** the Free Software Foundation; either version 2 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU General Public License for more details. -** -** You should have received a copy of the GNU General Public License -** along with this program; if not, write to the Free Software -** Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. -**/ - - -/** - * @var CView $this - */ - -$this->includeJsFile('monitoring.screen.js.php'); - -$web_layout_mode = CViewHelper::loadLayoutMode(); - -$widget = (new CWidget())->setWebLayoutMode($web_layout_mode); - -if ($web_layout_mode == ZBX_LAYOUT_NORMAL) { - $widget - ->setTitle(_('Screens')) - ->setTitleSubmenu([ - 'main_section' => [ - 'items' => [ - 'screens.php' => _('Screens'), - 'slides.php' => _('Slide shows') - ] - ] - ]) - ->setNavigation((new CList())->addItem(new CBreadcrumbs([ - (new CSpan())->addItem(new CLink(_('All screens'), 'screenconf.php')), - (new CSpan()) - ->addItem(new CLink($data['screen']['name'], - (new CUrl('screens.php'))->setArgument('elementid', $data['screen']['screenid']) - )) - ->addClass(ZBX_STYLE_SELECTED) - ]))); -} - -$controls = new CList(); - -if ($data['has_dynamic_widgets']) { - $controls - ->addItem(new CLabel(_('Host'), 'hostid')) - ->addItem( - (new CMultiSelect([ - 'name' => 'dynamic_hostid', - 'object_name' => 'hosts', - 'data' => $data['host'], - 'multiple' => false, - 'popup' => [ - 'parameters' => [ - 'srctbl' => 'hosts', - 'srcfld1' => 'hostid', - 'dstfld1' => 'dynamic_hostid', - 'dstfrm' => 'headerForm', - 'monitored_hosts' => 1, - 'with_items' => 1 - ] - ] - ]))->setWidth(ZBX_TEXTAREA_FILTER_STANDARD_WIDTH) - ); - - zbx_add_post_js( - 'jQuery("#dynamic_hostid").on("change", function() {'. - 'var hosts = jQuery(this).multiSelect("getData"),'. - 'url = new Curl("screens.php", false);'. - - // Make URL. - 'url.setArgument("elementid", '.$data['screen']['screenid'].');'. - 'if (hosts.length) {'. - 'url.setArgument("hostid", hosts[0].id);'. - '}'. - 'else {'. - 'url.setArgument("reset", "reset");'. - '}'. - - // Push URL change. - 'return redirect(url.getUrl(), "get", "", false, false);'. - '});' - ); -} - -$controls - ->addItem($data['screen']['editable'] - ? (new CButton('edit', _('Edit screen'))) - ->onClick('redirect("screenedit.php?screenid='.$data['screen']['screenid'].'", "get", "", false, false)') - ->setEnabled($data['allowed_edit']) - : null - ) - ->addItem(get_icon('favourite', [ - 'fav' => 'web.favorite.screenids', - 'elname' => 'screenid', - 'elid' => $data['screen']['screenid'] - ] - )) - ->addItem(get_icon('kioskmode', ['mode' => $web_layout_mode])); - -$widget->setControls((new CTag('nav', true, (new CList()) - ->addItem((new CForm('get')) - ->setName('headerForm') - ->addItem($controls) - ))) - ->setAttribute('aria-label', _('Content controls')) -); - -// Append screens to widget. -$screenBuilder = new CScreenBuilder([ - 'screenid' => $data['screen']['screenid'], - 'mode' => SCREEN_MODE_PREVIEW, - 'hostid' => array_key_exists('hostid', $data) ? $data['hostid'] : null, - 'profileIdx' => $data['profileIdx'], - 'profileIdx2' => $data['profileIdx2'], - 'from' => $data['from'], - 'to' => $data['to'] -]); - -$widget->addItem( - (new CFilter(new CUrl())) - ->setProfile($data['profileIdx'], $data['profileIdx2']) - ->setActiveTab($data['active_tab']) - ->addTimeSelector($screenBuilder->timeline['from'], $screenBuilder->timeline['to'], - $web_layout_mode != ZBX_LAYOUT_KIOSKMODE) -); - -$widget->addItem((new CDiv($screenBuilder->show()))->addClass(ZBX_STYLE_TABLE_FORMS_CONTAINER)); - -CScreenBuilder::insertScreenStandardJs($screenBuilder->timeline); - -$widget->show(); diff --git a/ui/include/views/monitoring.slideconf.edit.php b/ui/include/views/monitoring.slideconf.edit.php deleted file mode 100644 index be4e25b910a..00000000000 --- a/ui/include/views/monitoring.slideconf.edit.php +++ /dev/null @@ -1,295 +0,0 @@ -<?php -/* -** Zabbix -** Copyright (C) 2001-2021 Zabbix SIA -** -** This program is free software; you can redistribute it and/or modify -** it under the terms of the GNU General Public License as published by -** the Free Software Foundation; either version 2 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU General Public License for more details. -** -** You should have received a copy of the GNU General Public License -** along with this program; if not, write to the Free Software -** Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. -**/ - - -/** - * @var CView $this - */ - -require_once dirname(__FILE__).'/js/monitoring.slideconf.edit.js.php'; - -$widget = (new CWidget())->setTitle(_('Slide shows')); - -$tabs = new CTabView(); - -if (!$data['form_refresh']) { - $tabs->setSelected(0); -} - -// create form -$form = (new CForm()) - ->setName('slideForm') - ->setAttribute('aria-labeledby', ZBX_STYLE_PAGE_TITLE) - ->addVar('form', $data['form']) - ->addVar('slides', $data['slides_without_delay']) - ->addVar('current_user_userid', $data['current_user_userid']) - ->addVar('current_user_fullname', getUserFullname($data['users'][$data['current_user_userid']])); - -if (!empty($data['slideshow']['slideshowid'])) { - $form->addVar('slideshowid', $data['slideshow']['slideshowid']); -} - -$user_type = CWebUser::getType(); - -// Create slide form list. -$slideshow_tab = (new CFormList()); - -// Slide show owner multiselect. -$multiselect_data = [ - 'name' => 'userid', - 'object_name' => 'users', - 'multiple' => false, - 'disabled' => ($user_type != USER_TYPE_SUPER_ADMIN && $user_type != USER_TYPE_ZABBIX_ADMIN), - 'data' => [], - 'popup' => [ - 'parameters' => [ - 'srctbl' => 'users', - 'srcfld1' => 'userid', - 'srcfld2' => 'fullname', - 'dstfrm' => $form->getName(), - 'dstfld1' => 'userid' - ] - ] -]; - -$slideshow_ownerid = $data['slideshow']['userid']; - -if ($slideshow_ownerid !== '') { - $multiselect_data['data'][] = array_key_exists($slideshow_ownerid, $data['users']) - ? [ - 'id' => $slideshow_ownerid, - 'name' => getUserFullname($data['users'][$slideshow_ownerid]) - ] - : [ - 'id' => $slideshow_ownerid, - 'name' => _('Inaccessible user'), - 'inaccessible' => true - ]; -} - -// Append multiselect to slide show tab. -$slideshow_tab->addRow( - (new CLabel(_('Owner'), 'userid_ms'))->setAsteriskMark(), - (new CMultiSelect($multiselect_data)) - ->setAriaRequired() - ->setWidth(ZBX_TEXTAREA_STANDARD_WIDTH) -); - -$slideshow_tab - ->addRow( - (new CLabel(_('Name'), 'name'))->setAsteriskMark(), - (new CTextBox('name', $data['slideshow']['name'])) - ->setAriaRequired() - ->setWidth(ZBX_TEXTAREA_STANDARD_WIDTH) - ->setAttribute('autofocus', 'autofocus') - ) - ->addRow( - (new CLabel(_('Default delay'), 'delay'))->setAsteriskMark(), - (new CTextBox('delay', $data['slideshow']['delay'])) - ->setAriaRequired() - ->setWidth(ZBX_TEXTAREA_TINY_WIDTH) - ); - -// append slide table -$slideTable = (new CTable()) - ->setAttribute('style', 'width: 100%;') - ->setId('slideTable') - ->setHeader([ - (new CColHeader())->setWidth(15), - (new CColHeader())->setWidth(15), - _('Screen'), - (new CColHeader(_('Delay')))->setWidth(70), - (new CColHeader(_('Action')))->setWidth(50) - ]); - -$i = 1; - -foreach ($data['slideshow']['slides'] as $key => $slides) { - $slideTable->addRow( - (new CRow([ - (new CCol( - (new CDiv())->addClass(ZBX_STYLE_DRAG_ICON) - ))->addClass(ZBX_STYLE_TD_DRAG_ICON), - (new CSpan($i++.':')) - ->addClass('rowNum') - ->setId('current_slide_'.$key), - $data['slideshow']['screens'][$slides['screenid']]['name'], - (new CTextBox('slides['.$key.'][delay]', $slides['delay'])) - ->setWidth(ZBX_TEXTAREA_TINY_WIDTH) - ->setAttribute('placeholder', _('default')), - (new CCol( - (new CButton('remove_'.$key, _('Remove'))) - ->onClick('javascript: removeSlide(this);') - ->addClass(ZBX_STYLE_BTN_LINK) - ->setAttribute('remove_slide', $key) - ))->addClass(ZBX_STYLE_NOWRAP) - ])) - ->addClass('sortable') - ->setId('slides_'.$key) - ); -} - -$addButtonColumn = (new CCol( - (new CButton('add', _('Add'))) - ->onClick('return PopUp("popup.generic",'. - json_encode([ - 'srctbl' => 'screens', - 'srcfld1' => 'screenid', - 'dstfrm' => $form->getName(), - 'multiselect' => '1' - ]).', null, this);' - ) - ->addClass(ZBX_STYLE_BTN_LINK) - ))->setColSpan(5); - -$addButtonColumn->setAttribute('style', 'vertical-align: middle;'); -$slideTable->addRow((new CRow($addButtonColumn))->setId('screenListFooter')); - -$slideshow_tab->addRow( - (new CLabel(_('Slides'), $slideTable->getId()))->setAsteriskMark(), - (new CDiv($slideTable)) - ->addClass(ZBX_STYLE_TABLE_FORMS_SEPARATOR) - ->setAttribute('style', 'min-width: '.ZBX_TEXTAREA_BIG_WIDTH.'px;') -); - -// Append tabs to form. -$tabs->addTab('slideTab', _('Slide'), $slideshow_tab); - -// User group sharing table. -$user_group_shares_table = (new CTable()) - ->setHeader([_('User groups'), _('Permissions'), _('Action')]) - ->setAttribute('style', 'width: 100%;'); - -$add_user_group_btn = ([(new CButton(null, _('Add'))) - ->onClick('return PopUp("popup.generic",'. - json_encode([ - 'srctbl' => 'usrgrp', - 'srcfld1' => 'usrgrpid', - 'srcfld2' => 'name', - 'dstfrm' => $form->getName(), - 'multiselect' => '1' - ]).', null, this);' - ) - ->addClass(ZBX_STYLE_BTN_LINK)]); - -$user_group_shares_table->addRow( - (new CRow( - (new CCol($add_user_group_btn))->setColSpan(3) - ))->setId('user_group_list_footer') -); - -$user_groups = []; - -foreach ($data['slideshow']['userGroups'] as $user_group) { - $user_groupid = $user_group['usrgrpid']; - if (array_key_exists($user_groupid, $data['user_groups'])) { - $user_groups[$user_groupid] = [ - 'usrgrpid' => $user_groupid, - 'name' => $data['user_groups'][$user_groupid]['name'], - 'permission' => $user_group['permission'] - ]; - } -} - -$js_insert = 'addPopupValues('.zbx_jsvalue(['object' => 'usrgrpid', 'values' => $user_groups]).');'; - -// User sharing table. -$user_shares_table = (new CTable()) - ->setHeader([_('Users'), _('Permissions'), _('Action')]) - ->setAttribute('style', 'width: 100%;'); - -$add_user_btn = ([(new CButton(null, _('Add'))) - ->onClick('return PopUp("popup.generic",'. - json_encode([ - 'srctbl' => 'users', - 'srcfld1' => 'userid', - 'srcfld2' => 'fullname', - 'dstfrm' => $form->getName(), - 'multiselect' => '1' - ]).', null, this);' - ) - ->addClass(ZBX_STYLE_BTN_LINK)]); - -$user_shares_table->addRow( - (new CRow( - (new CCol($add_user_btn))->setColSpan(3) - ))->setId('user_list_footer') -); - -$users = []; - -foreach ($data['slideshow']['users'] as $user) { - $userid = $user['userid']; - if (array_key_exists($userid, $data['users'])) { - $users[$userid] = [ - 'id' => $userid, - 'name' => getUserFullname($data['users'][$userid]), - 'permission' => $user['permission'] - ]; - } -} - -$js_insert .= 'addPopupValues('.zbx_jsvalue(['object' => 'userid', 'values' => $users]).');'; - -zbx_add_post_js($js_insert); - -$sharing_tab = (new CFormList('sharing_form')) - ->addRow(_('Type'), - (new CRadioButtonList('private', (int) $data['slideshow']['private'])) - ->addValue(_('Private'), PRIVATE_SHARING) - ->addValue(_('Public'), PUBLIC_SHARING) - ->setModern(true) - ) - ->addRow(_('List of user group shares'), - (new CDiv($user_group_shares_table)) - ->addClass(ZBX_STYLE_TABLE_FORMS_SEPARATOR) - ->setAttribute('style', 'min-width: '.ZBX_TEXTAREA_STANDARD_WIDTH.'px;') - ) - ->addRow(_('List of user shares'), - (new CDiv($user_shares_table)) - ->addClass(ZBX_STYLE_TABLE_FORMS_SEPARATOR) - ->setAttribute('style', 'min-width: '.ZBX_TEXTAREA_STANDARD_WIDTH.'px;') - ); - -// Append data to form. -$tabs->addTab('sharing_tab', _('Sharing'), $sharing_tab); - -// append buttons to form -if (isset($data['slideshow']['slideshowid'])) { - $tabs->setFooter(makeFormFooter( - new CSubmit('update', _('Update')), - [ - (new CSimpleButton(_('Clone')))->setId('clone'), - new CButtonDelete(_('Delete slide show?'), url_params(['form', 'slideshowid'])), - new CRedirectButton(_('Cancel'), 'slides.php') - ] - )); -} -else { - $tabs->setFooter(makeFormFooter( - (new CSubmit('add', _('Add')))->removeId(), - [new CButtonCancel()] - )); -} - -$form->addItem($tabs); -$widget->addItem($form); - -$widget->show(); diff --git a/ui/include/views/monitoring.slideconf.list.php b/ui/include/views/monitoring.slideconf.list.php deleted file mode 100644 index 3efd460cb4c..00000000000 --- a/ui/include/views/monitoring.slideconf.list.php +++ /dev/null @@ -1,117 +0,0 @@ -<?php -/* -** Zabbix -** Copyright (C) 2001-2021 Zabbix SIA -** -** This program is free software; you can redistribute it and/or modify -** it under the terms of the GNU General Public License as published by -** the Free Software Foundation; either version 2 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU General Public License for more details. -** -** You should have received a copy of the GNU General Public License -** along with this program; if not, write to the Free Software -** Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. -**/ - - -/** - * @var CView $this - */ - -$widget = (new CWidget()) - ->setTitle(_('Slide shows')) - ->setTitleSubmenu([ - 'main_section' => [ - 'items' => [ - 'screens.php' => _('Screens'), - 'slides.php' => _('Slide shows') - ] - ] - ]) - ->setControls((new CTag('nav', true, - (new CForm('get')) - ->cleanItems() - ->addItem( - (new CList()) - ->addItem((new CSubmit('form', _('Create slide show')))->setEnabled($data['allowed_edit'])) - ) - )) - ->setAttribute('aria-label', _('Content controls')) - ); - -// filter -$widget->addItem( - (new CFilter(new CUrl('slideconf.php'))) - ->setProfile($data['profileIdx']) - ->setActiveTab($data['active_tab']) - ->addFilterTab(_('Filter'), [ - (new CFormList())->addRow(_('Name'), - (new CTextBox('filter_name', $data['filter']['name'])) - ->setWidth(ZBX_TEXTAREA_FILTER_STANDARD_WIDTH) - ->setAttribute('autofocus', 'autofocus') - ) - ]) -); - -// Create form. -$form = (new CForm())->setName('slideForm'); - -// create table -$url = (new CUrl('slideconf.php'))->getUrl(); - -$slidesTable = (new CTableInfo()) - ->setHeader([ - (new CColHeader( - (new CCheckBox('all_shows'))->onClick("checkAll('".$form->getName()."', 'all_shows', 'shows');") - ))->addClass(ZBX_STYLE_CELL_WIDTH), - make_sorting_header(_('Name'), 'name', $this->data['sort'], $this->data['sortorder'], $url), - make_sorting_header(_('Delay'), 'delay', $this->data['sort'], $this->data['sortorder'], $url), - make_sorting_header(_('Number of slides'), 'cnt', $this->data['sort'], $this->data['sortorder'], $url), - _('Actions') - ]); - -foreach ($this->data['slides'] as $slide) { - $user_type = CWebUser::getType(); - - if ($user_type == USER_TYPE_SUPER_ADMIN || $user_type == USER_TYPE_ZABBIX_ADMIN || $slide['editable']) { - $checkbox = new CCheckBox('shows['.$slide['slideshowid'].']', $slide['slideshowid']); - $properties = $data['allowed_edit'] - ?(new CLink(_('Properties'), '?form=update&slideshowid='.$slide['slideshowid'])) - ->addClass('action') - : _('Properties'); - } - else { - $checkbox = (new CCheckBox('shows['.$slide['slideshowid'].']', $slide['slideshowid'])) - ->setAttribute('disabled', 'disabled'); - $properties = ''; - } - - $slidesTable->addRow([ - $checkbox, - (new CLink($slide['name'], 'slides.php?elementid='.$slide['slideshowid']))->addClass('action'), - $slide['delay'], - $slide['cnt'], - $properties - ]); -} - -// append table to form -$form->addItem([ - $slidesTable, - $this->data['paging'], - new CActionButtonList('action', 'shows', [ - 'slideshow.massdelete' => ['name' => _('Delete'), 'confirm' => _('Delete selected slide shows?'), - 'disabled' => $data['allowed_edit'] ? null : 'disabled' - ] - ]) -]); - -// append form to widget -$widget->addItem($form); - -$widget->show(); diff --git a/ui/include/views/monitoring.slides.php b/ui/include/views/monitoring.slides.php deleted file mode 100644 index 5cb5b414c12..00000000000 --- a/ui/include/views/monitoring.slides.php +++ /dev/null @@ -1,139 +0,0 @@ -<?php -/* -** Zabbix -** Copyright (C) 2001-2021 Zabbix SIA -** -** This program is free software; you can redistribute it and/or modify -** it under the terms of the GNU General Public License as published by -** the Free Software Foundation; either version 2 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU General Public License for more details. -** -** You should have received a copy of the GNU General Public License -** along with this program; if not, write to the Free Software -** Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. -**/ - - -/** - * @var CView $this - */ - -$web_layout_mode = CViewHelper::loadLayoutMode(); - -$widget = (new CWidget())->setWebLayoutMode($web_layout_mode); - -if ($web_layout_mode == ZBX_LAYOUT_NORMAL) { - $widget - ->setTitle(_('Slide shows')) - ->setTitleSubmenu([ - 'main_section' => [ - 'items' => [ - 'screens.php' => _('Screens'), - 'slides.php' => _('Slide shows') - ] - ] - ]) - ->setNavigation((new CList())->addItem(new CBreadcrumbs([ - (new CSpan())->addItem(new CLink(_('All slide shows'), 'slideconf.php')), - (new CSpan()) - ->addItem(new CLink($data['screen']['name'], - (new CUrl('slides.php'))->setArgument('elementid', $data['screen']['slideshowid']) - )) - ->addClass(ZBX_STYLE_SELECTED) - ]))); -} - -$favourite_icon = get_icon('favourite', [ - 'fav' => 'web.favorite.screenids', - 'elname' => 'slideshowid', - 'elid' => $this->data['elementId'] -]); - -$refresh_icon = get_icon('screenconf'); - -$refresh_icon->setMenuPopup(CMenuPopupHelper::getRefresh(WIDGET_SLIDESHOW, 'x'.$this->data['refreshMultiplier'], - true, ['elementid' => $this->data['elementId']] -)); - -$controls = null; - -if ($data['has_dynamic_widgets']) { - $controls = (new CList()) - ->addItem(new CLabel(_('Host'), 'hostid')) - ->addItem( - (new CMultiSelect([ - 'name' => 'dynamic_hostid', - 'object_name' => 'hosts', - 'data' => $data['host'], - 'multiple' => false, - 'popup' => [ - 'parameters' => [ - 'srctbl' => 'hosts', - 'srcfld1' => 'hostid', - 'dstfld1' => 'dynamic_hostid', - 'monitored_hosts' => 1 - ] - ] - ]))->setWidth(ZBX_TEXTAREA_FILTER_STANDARD_WIDTH) - ); - - zbx_add_post_js( - 'jQuery("#dynamic_hostid").on("change", function() {'. - 'var hosts = jQuery(this).multiSelect("getData"),'. - 'url = new Curl("slides.php", false);'. - - // Make URL. - 'url.setArgument("elementid", '.$data['screen']['slideshowid'].');'. - 'if (hosts.length) {'. - 'url.setArgument("hostid", hosts[0].id);'. - '}'. - 'else {'. - 'url.setArgument("reset", "reset");'. - '}'. - - // Push URL change. - 'return redirect(url.getUrl(), "get", "", false, false);'. - '});' - ); -} - -$widget->setControls((new CList([ - (new CForm('get')) - ->setAttribute('aria-label', _('Main filter')) - ->setName('slideHeaderForm') - ->addItem($controls), - (new CTag('nav', true, (new CList()) - ->addItem($data['screen']['editable'] - ? (new CButton('edit', _('Edit slide show'))) - ->onClick('redirect("slideconf.php?form=update&slideshowid='.$data['screen']['slideshowid'].'")') - ->setEnabled($data['allowed_edit']) - : null - ) - ->addItem($favourite_icon) - ->addItem($refresh_icon) - ->addItem(get_icon('kioskmode', ['mode' => $web_layout_mode])) - )) - ->setAttribute('aria-label', _('Content controls')) -]))); - -$widget - ->addItem( - (new CFilter(new CUrl())) - ->setProfile($data['timeline']['profileIdx'], $data['timeline']['profileIdx2']) - ->setActiveTab($data['active_tab']) - ->addTimeSelector($data['timeline']['from'], $data['timeline']['to'], - $web_layout_mode != ZBX_LAYOUT_KIOSKMODE) - ) - ->addItem( - (new CDiv((new CDiv())->addStyle('position: relative;margin-top: 20px;')->addClass('is-loading'))) - ->setId(WIDGET_SLIDESHOW) - ); - -require_once dirname(__FILE__).'/js/monitoring.slides.js.php'; - -$widget->show(); diff --git a/ui/js/class.cscreen.js b/ui/js/class.cscreen.js deleted file mode 100644 index e0f00857337..00000000000 --- a/ui/js/class.cscreen.js +++ /dev/null @@ -1,116 +0,0 @@ -/* -** Zabbix -** Copyright (C) 2001-2021 Zabbix SIA -** -** This program is free software; you can redistribute it and/or modify -** it under the terms of the GNU General Public License as published by -** the Free Software Foundation; either version 2 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU General Public License for more details. -** -** You should have received a copy of the GNU General Public License -** along with this program; if not, write to the Free Software -** Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. -**/ - -var ZBX_SCREENS = []; // screens obj reference - -// screenid always must be a string (js doesn't support uint64) ! -function init_screen(screenid, obj_id, id) { - if (typeof(id) == 'undefined') { - id = ZBX_SCREENS.length; - } - - if (is_number(screenid) && screenid > 100000000000000) { - throw('Error: Wrong type of arguments passed to function [init_screen]'); - } - - ZBX_SCREENS[id] = new Object; - ZBX_SCREENS[id].screen = new Cscreen(screenid, obj_id, id); -} - -var Cscreen = function(screenid, obj_id, id) { - this.screenid = screenid; - this.id = id; - this.screen_obj = document.getElementById(obj_id); - - jQuery('.draggable').draggable({ - revert: 'invalid', - zIndex: 999 - }); - - jQuery('.screenitem').droppable({ - accept: '.draggable', - drop: this.on_drop, - tolerance: 'pointer' - }); -}; - -Cscreen.prototype = { - id: 0, - screenid: 0, - screen_obj: null, // DOM ref to screen obj - - on_drop: function(event, ui) { - var element = ui.draggable; - var dropDiv = jQuery(this).children('.draggable'); - - var x1 = element.data('xcoord'); - var y1 = element.data('ycoord'); - var x2 = dropDiv.data('xcoord'); - var y2 = dropDiv.data('ycoord'); - - var url = new Curl(); - var params = { - ajaxAction: 'sw_pos', - output: 'ajax', - 'sw_pos[0]': y1, - 'sw_pos[1]': x1, - 'sw_pos[2]': y2, - 'sw_pos[3]': x2, - screenid: url.getArgument('screenid'), - sid: url.getArgument('sid') - }; - - jQuery.post('screenedit.php', params, function(data) { - if (!isset('result', data) || !data.result) { - overlayDialogue({ - 'title': 'Error', - 'content': jQuery('<span>').text('Ajax request error'), - 'buttons': [] - }, dropDiv); - } - else { - var parent = dropDiv.parent().get(0); - element.parent().get(0).appendChild(dropDiv.get(0)); - parent.appendChild(element.get(0)); - - // replace "change" link href for empty cells - var link = jQuery(element).find('.empty_change_link')[0]; - if (link) { - var href = jQuery(link).attr('href'); - href = href.replace(/\&x\=[0-9]+/, '&x=' + x2); - href = href.replace(/\&y\=[0-9]+/, '&y=' + y2); - jQuery(link).attr('href', href); - } - - var link = jQuery(dropDiv).find('.empty_change_link')[0]; - if (link) { - var href = jQuery(link).attr('href'); - href = href.replace(/\&x\=[0-9]+/, '&x=' + x1); - href = href.replace(/\&y\=[0-9]+/, '&y=' + y1); - jQuery(link).attr('href', href); - } - - element.data({ycoord: y2, xcoord: x2}); - dropDiv.data({ycoord: y1, xcoord: x1}); - } - }, 'json'); - - element.css({top: '0px', left: '0px'}); - } -}; |