From 7c0ff4c907c7a0238fb988e9dedf966d92332cc2 Mon Sep 17 00:00:00 2001 From: Larisa Grigorjeva Date: Mon, 27 Jun 2022 15:49:56 +0100 Subject: .......... [DEV-2073] reorganized tests vol. 1 --- ui/tests/selenium/SeleniumTests.php | 92 +++--- ui/tests/selenium/dashboard/testPageDashboard.php | 312 +++++++++++++++++++++ .../selenium/dashboard/testPageDashboardList.php | 246 ++++++++++++++++ .../dashboard/testPageDashboardWidgets.php | 306 ++++++++++++++++++++ ui/tests/selenium/testPageDashboard.php | 312 --------------------- ui/tests/selenium/testPageDashboardList.php | 246 ---------------- ui/tests/selenium/testPageDashboardWidgets.php | 306 -------------------- 7 files changed, 916 insertions(+), 904 deletions(-) create mode 100644 ui/tests/selenium/dashboard/testPageDashboard.php create mode 100644 ui/tests/selenium/dashboard/testPageDashboardList.php create mode 100644 ui/tests/selenium/dashboard/testPageDashboardWidgets.php delete mode 100644 ui/tests/selenium/testPageDashboard.php delete mode 100644 ui/tests/selenium/testPageDashboardList.php delete mode 100644 ui/tests/selenium/testPageDashboardWidgets.php diff --git a/ui/tests/selenium/SeleniumTests.php b/ui/tests/selenium/SeleniumTests.php index 3472cdd3199..56d48cdbc65 100644 --- a/ui/tests/selenium/SeleniumTests.php +++ b/ui/tests/selenium/SeleniumTests.php @@ -20,10 +20,34 @@ require_once dirname(__FILE__).'/testDocumentationLinks.php'; require_once dirname(__FILE__).'/testGeneric.php'; + +// Api Tokens. +require_once dirname(__FILE__).'/apiTokens/testPageApiTokensAdministrationGeneral.php'; +require_once dirname(__FILE__).'/apiTokens/testPageApiTokensUserSettings.php'; +require_once dirname(__FILE__).'/apiTokens/testFormApiTokensAdministrationGeneral.php'; +require_once dirname(__FILE__).'/apiTokens/testFormApiTokensUserSettings.php'; + +// Dashboards. +require_once dirname(__FILE__).'/dashboard/testDashboardCopyWidgets.php'; +require_once dirname(__FILE__).'/dashboard/testDashboardGraphPrototypeWidget.php'; +require_once dirname(__FILE__).'/dashboard/testDashboardGeomapWidget.php'; +require_once dirname(__FILE__).'/dashboard/testDashboardDynamicItemWidgets.php'; +require_once dirname(__FILE__).'/dashboard/testDashboardGraphWidget.php'; +require_once dirname(__FILE__).'/dashboard/testDashboardHostAvailabilityWidget.php'; +require_once dirname(__FILE__).'/dashboard/testDashboardProblemsBySeverityWidget.php'; +require_once dirname(__FILE__).'/dashboard/testDashboardItemValueWidget.php'; +require_once dirname(__FILE__).'/dashboard/testDashboardSystemInformationWidget.php'; +require_once dirname(__FILE__).'/dashboard/testDashboardTopHostsWidget.php'; +require_once dirname(__FILE__).'/dashboard/testDashboardPages.php'; +require_once dirname(__FILE__).'/dashboard/testFormTemplateDashboards.php'; +require_once dirname(__FILE__).'/dashboard/testPageDashboard.php'; +require_once dirname(__FILE__).'/dashboard/testPageDashboardList.php'; +require_once dirname(__FILE__).'/dashboard/testPageDashboardWidgets.php'; +require_once dirname(__FILE__).'/dashboard/testPageTemplateDashboards.php'; + require_once dirname(__FILE__).'/testExecuteNow.php'; require_once dirname(__FILE__).'/testGraphAxis.php'; -require_once dirname(__FILE__).'/testPageDashboard.php'; -require_once dirname(__FILE__).'/testPageDashboardWidgets.php'; + require_once dirname(__FILE__).'/testPageLatestData.php'; require_once dirname(__FILE__).'/testPageWeb.php'; require_once dirname(__FILE__).'/testPageProblems.php'; @@ -35,10 +59,7 @@ require_once dirname(__FILE__).'/testPageAdministrationGeneralModules.php'; require_once dirname(__FILE__).'/testPageAdministrationGeneralRegexp.php'; require_once dirname(__FILE__).'/testPageAdministrationMediaTypes.php'; require_once dirname(__FILE__).'/testPageAdministrationScripts.php'; -require_once dirname(__FILE__).'/apiTokens/testPageApiTokensAdministrationGeneral.php'; -require_once dirname(__FILE__).'/apiTokens/testPageApiTokensUserSettings.php'; require_once dirname(__FILE__).'/testPageAvailabilityReport.php'; -require_once dirname(__FILE__).'/testPageDashboardList.php'; require_once dirname(__FILE__).'/testPageEventCorrelation.php'; require_once dirname(__FILE__).'/testPageGraphPrototypes.php'; require_once dirname(__FILE__).'/testPageHistory.php'; @@ -90,8 +111,6 @@ require_once dirname(__FILE__).'/testFormAdministrationMediaTypeMessageTemplates require_once dirname(__FILE__).'/testFormAdministrationMediaTypeWebhook.php'; require_once dirname(__FILE__).'/testFormAdministrationScripts.php'; require_once dirname(__FILE__).'/testFormAdministrationUserGroups.php'; -require_once dirname(__FILE__).'/apiTokens/testFormApiTokensAdministrationGeneral.php'; -require_once dirname(__FILE__).'/apiTokens/testFormApiTokensUserSettings.php'; require_once dirname(__FILE__).'/testFormEventCorrelation.php'; require_once dirname(__FILE__).'/filterTabs/testFormFilterHosts.php'; require_once dirname(__FILE__).'/filterTabs/testFormFilterLatestData.php'; @@ -181,19 +200,6 @@ require_once dirname(__FILE__).'/testZBX6648.php'; require_once dirname(__FILE__).'/testZBX6663.php'; require_once dirname(__FILE__).'/roles/testPageUserRoles.php'; require_once dirname(__FILE__).'/roles/testUserRolesPermissions.php'; -require_once dirname(__FILE__).'/dashboard/testDashboardCopyWidgets.php'; -require_once dirname(__FILE__).'/dashboard/testDashboardGraphPrototypeWidget.php'; -require_once dirname(__FILE__).'/dashboard/testDashboardGeomapWidget.php'; -require_once dirname(__FILE__).'/dashboard/testDashboardDynamicItemWidgets.php'; -require_once dirname(__FILE__).'/dashboard/testDashboardGraphWidget.php'; -require_once dirname(__FILE__).'/dashboard/testDashboardHostAvailabilityWidget.php'; -require_once dirname(__FILE__).'/dashboard/testDashboardProblemsBySeverityWidget.php'; -require_once dirname(__FILE__).'/dashboard/testDashboardItemValueWidget.php'; -require_once dirname(__FILE__).'/dashboard/testDashboardSystemInformationWidget.php'; -require_once dirname(__FILE__).'/dashboard/testDashboardTopHostsWidget.php'; -require_once dirname(__FILE__).'/dashboard/testDashboardPages.php'; -require_once dirname(__FILE__).'/dashboard/testFormTemplateDashboards.php'; -require_once dirname(__FILE__).'/dashboard/testPageTemplateDashboards.php'; require_once dirname(__FILE__).'/geomaps/testFormAdministrationGeneralGeomaps.php'; require_once dirname(__FILE__).'/geomaps/testGeomapWidgetScreenshots.php'; require_once dirname(__FILE__).'/reports/testPageReportsActionLog.php'; @@ -214,8 +220,34 @@ class SeleniumTests { $suite->addTestSuite('testDocumentationLinks'); $suite->addTestSuite('testGeneric'); + + // Api Tokens. + $suite->addTestSuite('testFormApiTokensAdministrationGeneral'); + $suite->addTestSuite('testFormApiTokensUserSettings'); + $suite->addTestSuite('testPageApiTokensAdministrationGeneral'); + $suite->addTestSuite('testPageApiTokensUserSettings'); + + // Dashboards. + $suite->addTestSuite('testDashboardCopyWidgets'); + $suite->addTestSuite('testDashboardGraphPrototypeWidget'); + $suite->addTestSuite('testDashboardGeomapWidget'); + $suite->addTestSuite('testDashboardDynamicItemWidgets'); + $suite->addTestSuite('testDashboardGraphWidget'); + $suite->addTestSuite('testDashboardHostAvailabilityWidget'); + $suite->addTestSuite('testDashboardItemValueWidget'); + $suite->addTestSuite('testDashboardPages'); + $suite->addTestSuite('testDashboardProblemsBySeverityWidget'); + $suite->addTestSuite('testDashboardSystemInformationWidget'); + $suite->addTestSuite('testDashboardTopHostsWidget'); + $suite->addTestSuite('testFormTemplateDashboards'); + $suite->addTestSuite('testPageDashboard'); + $suite->addTestSuite('testPageDashboardList'); + $suite->addTestSuite('testPageDashboardWidgets'); + $suite->addTestSuite('testPageTemplateDashboards'); + $suite->addTestSuite('testExecuteNow'); $suite->addTestSuite('testGraphAxis'); + $suite->addTestSuite('testPageActions'); $suite->addTestSuite('testFormAdministrationGeneralAutoregistration'); $suite->addTestSuite('testPageAdministrationGeneralIconMapping'); @@ -224,12 +256,7 @@ class SeleniumTests { $suite->addTestSuite('testPageAdministrationGeneralRegexp'); $suite->addTestSuite('testPageAdministrationMediaTypes'); $suite->addTestSuite('testPageAdministrationScripts'); - $suite->addTestSuite('testPageApiTokensAdministrationGeneral'); - $suite->addTestSuite('testPageApiTokensUserSettings'); $suite->addTestSuite('testPageAvailabilityReport'); - $suite->addTestSuite('testPageDashboard'); - $suite->addTestSuite('testPageDashboardList'); - $suite->addTestSuite('testPageDashboardWidgets'); $suite->addTestSuite('testPageEventCorrelation'); $suite->addTestSuite('testPageGraphPrototypes'); $suite->addTestSuite('testPageProblems'); @@ -291,8 +318,6 @@ class SeleniumTests { $suite->addTestSuite('testFormAdministrationMediaTypeWebhook'); $suite->addTestSuite('testFormAdministrationScripts'); $suite->addTestSuite('testFormAdministrationUserGroups'); - $suite->addTestSuite('testFormApiTokensAdministrationGeneral'); - $suite->addTestSuite('testFormApiTokensUserSettings'); $suite->addTestSuite('testFormEventCorrelation'); $suite->addTestSuite('testFormFilterHosts'); $suite->addTestSuite('testFormFilterLatestData'); @@ -382,19 +407,6 @@ class SeleniumTests { $suite->addTestSuite('testZBX6663'); $suite->addTestSuite('testPageUserRoles'); $suite->addTestSuite('testUserRolesPermissions'); - $suite->addTestSuite('testDashboardCopyWidgets'); - $suite->addTestSuite('testDashboardGraphPrototypeWidget'); - $suite->addTestSuite('testDashboardGeomapWidget'); - $suite->addTestSuite('testDashboardDynamicItemWidgets'); - $suite->addTestSuite('testDashboardGraphWidget'); - $suite->addTestSuite('testDashboardHostAvailabilityWidget'); - $suite->addTestSuite('testDashboardProblemsBySeverityWidget'); - $suite->addTestSuite('testDashboardItemValueWidget'); - $suite->addTestSuite('testDashboardSystemInformationWidget'); - $suite->addTestSuite('testDashboardTopHostsWidget'); - $suite->addTestSuite('testDashboardPages'); - $suite->addTestSuite('testFormTemplateDashboards'); - $suite->addTestSuite('testPageTemplateDashboards'); $suite->addTestSuite('testFormScheduledReport'); $suite->addTestSuite('testPageScheduledReport'); $suite->addTestSuite('testScheduledReportPermissions'); diff --git a/ui/tests/selenium/dashboard/testPageDashboard.php b/ui/tests/selenium/dashboard/testPageDashboard.php new file mode 100644 index 00000000000..336799fb938 --- /dev/null +++ b/ui/tests/selenium/dashboard/testPageDashboard.php @@ -0,0 +1,312 @@ + 'Dashboard with favorite graphs and maps widgets', + 'private' => 1, + 'pages' => [ + [ + 'name' => 'Page 1', + 'widgets' => [ + [ + 'type' => 'favgraphs', + 'x' => 0, + 'y' => 0, + 'width' => 12, + 'height' => 4 + ], + [ + 'type' => 'favmaps', + 'x' => 13, + 'y' => 0, + 'width' => 4, + 'height' => 4 + ] + ] + ] + ] + ] + ]); + self::$dashboardid = $response['dashboardids'][0]; + } + + /** + * @onBefore removeGuestFromDisabledGroup + * @onAfter addGuestToDisabledGroup + */ + public function testPageDashboard_CheckLayoutForDifferentUsers() { + $users = ['super-admin', 'admin', 'user', 'guest']; + foreach ($users as $user) { + switch ($user) { + case 'super-admin' : + $this->authenticateUser('09e7d4286dfdca4ba7be15e0f3b2b55b', 1); + $this->zbxTestOpen('zabbix.php?action=dashboard.view'); + $this->zbxTestCheckNoRealHostnames(); + break; + case 'admin' : + $this->authenticateUser('09e7d4286dfdca4ba7be15e0f3b2b55c', 4); + $this->zbxTestOpen('zabbix.php?action=dashboard.view'); + break; + case 'user'; + $this->authenticateUser('09e7d4286dfdca4ba7be15e0f3b2b55d', 5); + $this->zbxTestOpen('zabbix.php?action=dashboard.view'); + break; + case 'guest'; + $this->authenticateUser('09e7d4286dfdca4ba7be15e0f3b2b55e', 2); + $this->zbxTestOpen('zabbix.php?action=dashboard.view'); + break; + } + $this->zbxTestCheckTitle('Dashboard'); + $this->zbxTestCheckHeader('Global view'); + if ($user !== 'super-admin') { + $this->zbxTestAssertElementText("//div[@class='dashboard-grid']/div[2]//tr[@class='nothing-to-show']/td", + 'No data found.'); + $this->zbxTestAssertElementText("//div[@class='dashboard-grid']/div[3]//tr[@class='nothing-to-show']/td", + 'No permissions to referred object or it does not exist!'); + } + else { + $this->zbxTestAssertElementPresentXpath("//div[@class='dashboard-grid']/div[3]//h4[text()='Performance']"); + } + $this->zbxTestAssertElementText("//div[@class='dashboard-grid']/div[2]//h4", 'Top hosts by CPU utilization'); + $this->zbxTestAssertElementText("//div[@class='dashboard-grid']/div[4]//h4", 'System information'); + $this->zbxTestAssertElementText("//div[@class='dashboard-grid']/div[7]//h4", 'Host availability'); + $this->zbxTestAssertElementText("//div[@class='dashboard-grid']/div[8]//h4", 'Problems by severity'); + $this->zbxTestAssertElementText("//div[@class='dashboard-grid']/div[9]//h4", 'Geomap'); + $this->zbxTestAssertElementText("//div[@class='dashboard-grid']/div[10]//h4", 'Current problems'); + $this->zbxTestAssertElementPresentXpath("//div[@class='dashboard-grid']/div[5]//h4[text()='Local time']"); + $this->zbxTestAssertElementPresentXpath("//div[@class='dashboard-grid']/div[6]//h4[text()='Graph']"); + + // Logout. + $this->zbxTestLogout(); + $this->zbxTestWaitForPageToLoad(); + $this->webDriver->manage()->deleteAllCookies(); + } + } + + public function testPageDashboard_CheckDasboardPopupLayout() { + $this->page->login()->open('zabbix.php?action=dashboard.view&new=1')->waitUntilReady(); + $dialog = COverlayDialogElement::find()->waitUntilVisible()->one(); + $this->assertEquals('Dashboard properties', $dialog->getTitle()); + $properties_form = $dialog->query('name:dashboard_properties_form')->asForm()->one(); + $this->assertEquals(['Owner', 'Name', 'Default page display period', 'Start slideshow automatically'], + $properties_form->getLabels()->asText() + ); + + // Check available display periods. + $properties_form->checkValue(['Default page display period' => '30 seconds', 'Name' => 'New dashboard']); + $this->assertEquals('255', $properties_form->query('id:name')->one()->getAttribute('maxlength')); + $this->assertEquals(['10 seconds', '30 seconds', '1 minute', '2 minutes', '10 minutes', '30 minutes', '1 hour'], + $properties_form->query('name:display_period')->asDropdown()->one()->getOptions()->asText() + ); + + $properties_form->fill(['Name' => 'Dashboard creation']); + $properties_form->submit(); + COverlayDialogElement::ensureNotPresent(); + $this->page->waitUntilReady(); + $dashboard = CDashboardElement::find()->one(); + + // Check popup-menu options. + $this->query('id:dashboard-add')->one()->click(); + $add_menu = CPopupMenuElement::find()->one()->waitUntilVisible(); + foreach (['Add widget' => true, 'Add page' => true, 'Paste widget' => false, 'Paste page'=> false] as $item => $enabled) { + $this->assertTrue($add_menu->getItem($item)->isEnabled($enabled)); + } + $dashboard->cancelEditing(); + } + + public function testPageDashboard_AddFavouriteGraphs() { + $cpu_itemid = CDBHelper::getValue('SELECT itemid FROM items WHERE hostid=10084 AND name='.zbx_dbstr($this->graphCpu)); + $memory_itemid = CDBHelper::getValue('SELECT itemid FROM items WHERE hostid=10084 AND name='.zbx_dbstr($this->graphMemory)); + + $this->zbxTestLogin('zabbix.php?action=latest.view&filter_selected=0&filter_reset=1'); + $this->zbxTestCheckHeader('Latest data'); + + $filter = $this->query('name:zbx_filter')->asForm()->one(); + $filter->getField('Hosts')->fill($this->hostName); + $filter->getField('Name')->fill($this->graphCpu); + $filter->submit(); + $cpu_link = $this->query('link:Graph')->one(); + $cpu_link->click(); + + $this->zbxTestWaitUntilElementVisible(WebDriverBy::xpath("//button[@id='addrm_fav']")); + $this->zbxTestAssertAttribute("//button[@id='addrm_fav']", 'title', 'Add to favorites'); + $this->zbxTestClickWait('addrm_fav'); + $this->zbxTestWaitUntilElementVisible(WebDriverBy::xpath('//button[@id="addrm_fav" and @title="Remove from favorites"]')); + $this->zbxTestAssertAttribute("//button[@id='addrm_fav']", 'title', 'Remove from favorites'); + + $this->page->open('zabbix.php?action=latest.view'); + $filter->invalidate(); + $filter->getField('Hosts')->fill($this->hostName); + $filter->getField('Name')->fill($this->graphMemory); + $filter->submit(); + $memory_link = $this->query('link:Graph')->one(); + $memory_link->click(); + + $this->zbxTestWaitUntilElementVisible(WebDriverBy::xpath("//button[@id='addrm_fav']")); + $this->zbxTestAssertAttribute("//button[@id='addrm_fav']", 'title', 'Add to favorites'); + $this->zbxTestClickWait('addrm_fav'); + $this->query('id:addrm_fav')->one()->waitUntilAttributesPresent(['title' => 'Remove from favorites']); + $this->zbxTestAssertAttribute("//button[@id='addrm_fav']", 'title', 'Remove from favorites'); + + $this->page->login()->open('zabbix.php?action=dashboard.view&dashboardid='.self::$dashboardid)->waitUntilReady(); + $url_xpath = '//div[@class="dashboard-grid"]/div[2]//a[@href='; + + foreach ([$this->graphCpu => $cpu_itemid, $this->graphMemory => $memory_itemid] as $graph => $itemid) { + $graph_url = 'history.php?action=showgraph&itemids%5B0%5D='.$itemid; + $this->zbxTestAssertElementText($url_xpath.CXPathHelper::escapeQuotes($graph_url).']', 'ЗАББИКС Сервер: '.$graph); + $this->assertEquals(1, CDBHelper::getCount('SELECT profileid FROM profiles WHERE idx=' + .zbx_dbstr('web.favorite.graphids').' AND value_id='.$itemid) + ); + } + } + + public function testPageDashboard_RemoveFavouriteGraphs() { + $exception = null; + + try { + $this->page->login()->open('zabbix.php?action=dashboard.view&dashboardid='.self::$dashboardid)->waitUntilReady(); + $FavouriteGraphs = DBfetchArray(DBselect('SELECT value_id FROM profiles WHERE idx='.zbx_dbstr('web.favorite.graphids'))); + foreach ($FavouriteGraphs as $FavouriteGraph) { + $remove_item = $this->query('xpath://button[@data-itemid='.zbx_dbstr($FavouriteGraph['value_id']). + ' and contains(@onclick, "rm4favorites")]')->waituntilClickable()->one(); + $remove_item->click(); + $remove_item->waitUntilNotVisible(); + } + $this->zbxTestAssertElementText('//div[@class="dashboard-grid-widget-container"]//tr[@class="nothing-to-show"]/td', 'No graphs added.'); + $this->assertEquals(0, CDBHelper::getCount('SELECT profileid FROM profiles WHERE idx='.zbx_dbstr('web.favorite.graphids'))); + } + catch (Exception $e) { + $exception = $e; + } + + if ($exception !== null) { + throw $exception; + } + } + + public function testPageDashboard_AddFavouriteMap() { + $this->zbxTestLogin('sysmaps.php'); + $this->zbxTestCheckHeader('Maps'); + $this->zbxTestClickLinkTextWait($this->mapTest); + $this->zbxTestWaitUntilElementVisible(WebDriverBy::xpath("//button[@id='addrm_fav']")); + $this->zbxTestAssertAttribute("//button[@id='addrm_fav']", 'title', 'Add to favorites'); + $this->zbxTestClickWait('addrm_fav'); + $this->query('id:addrm_fav')->one()->waitUntilAttributesPresent(['title' => 'Remove from favorites']); + $this->zbxTestAssertAttribute("//button[@id='addrm_fav']", 'title', 'Remove from favorites'); + + $this->page->login()->open('zabbix.php?action=dashboard.view&dashboardid='.self::$dashboardid)->waitUntilReady(); + $this->zbxTestAssertElementText('//div[@class="dashboard-grid-widget-container"]/div[2]//a[@href="zabbix.php?action=map.view&sysmapid='.$this->mapTestId.'"]', $this->mapTest); + $this->assertEquals(1, CDBHelper::getCount('SELECT profileid FROM profiles WHERE idx='.zbx_dbstr('web.favorite.sysmapids').' AND value_id='.$this->mapTestId)); + } + + public function testPageDashboard_RemoveFavouriteMaps() { + $this->page->login()->open('zabbix.php?action=dashboard.view&dashboardid='.self::$dashboardid)->waitUntilReady(); + $widget_content = CDashboardElement::find()->one()->getWidget('Favorite maps')->getContent(); + $favourite_maps = DBfetchArray(DBselect('SELECT value_id FROM profiles WHERE idx='. + zbx_dbstr('web.favorite.sysmapids'))); + + foreach ($favourite_maps as $favourite_map) { + $remove_item = $this->query('xpath://button[@data-sysmapid='.zbx_dbstr($favourite_map['value_id']). + ' and contains(@onclick, "rm4favorites")]')->waituntilClickable()->one(); + $remove_item->click(); + $remove_item->waitUntilNotVisible(); + } + + $this->assertTrue($widget_content->query('xpath://table//td[text()="No maps added."]')->waitUntilVisible() + ->one()->isPresent()); + $this->assertEquals(0, CDBHelper::getCount('SELECT profileid FROM profiles WHERE idx='. + zbx_dbstr('web.favorite.sysmapids'))); + } + + public function testPageDashboard_KioskMode() { + $this->zbxTestLogin('zabbix.php?action=dashboard.view&dashboardid=1', false); + $this->zbxTestCheckHeader('Global view'); + $this->zbxTestAssertElementPresentXpath("//header"); + + $this->zbxTestClickXpathWait("//button[contains(@class, 'btn-kiosk')]"); + $this->zbxTestWaitForPageToLoad(); + $this->zbxTestWaitUntilElementPresent(WebDriverBy::xpath('//button[@title="Normal view"]')); + $this->zbxTestAssertElementNotPresentXpath("//header"); + $this->zbxTestAssertElementNotPresentXpath("//header[@class='header-title']"); + $this->zbxTestAssertElementNotPresentXpath("//ul[contains(@class, 'filter-breadcrumb')]"); + $this->zbxTestAssertAttribute("//button[contains(@class, 'btn-min')]", 'title', 'Normal view'); + + $this->query('class:btn-min')->one()->forceClick(); + $this->zbxTestWaitForPageToLoad(); + $this->zbxTestWaitUntilElementPresent(WebDriverBy::xpath("//button[contains(@class, 'btn-kiosk')]")); + $this->zbxTestAssertAttribute("//button[contains(@class, 'btn-kiosk')]", 'title', 'Kiosk mode'); + $this->zbxTestAssertElementPresentXpath("//header"); + $this->zbxTestAssertElementPresentXpath("//header[@class='header-title']"); + $this->zbxTestAssertElementPresentXpath('//ul[@class="breadcrumbs"]'); + } + + public function testPageDashboard_KioskModeUrlParameter() { + // Set layout mode to kiosk view. + $this->zbxTestLogin('zabbix.php?action=dashboard.view&kiosk=1', false); + $this->zbxTestWaitForPageToLoad(); + $this->zbxTestWaitUntilElementPresent(WebDriverBy::xpath('//button[@title="Normal view"]')); + $this->zbxTestAssertElementNotPresentXpath("//header"); + $this->zbxTestAssertElementNotPresentXpath("//header[@class='header-title']"); + $this->zbxTestAssertElementNotPresentXpath("//ul[contains(@class, 'filter-breadcrumb')]"); + $this->zbxTestAssertAttribute("//button[contains(@class, 'btn-min')]", 'title', 'Normal view'); + + // Set layout mode to default layout. + $this->zbxTestOpen('zabbix.php?action=dashboard.view&kiosk=0'); + $this->zbxTestCheckHeader('Global view'); + $this->zbxTestAssertElementPresentXpath("//header"); + $this->zbxTestAssertAttribute("//button[contains(@class, 'btn-kiosk')]", 'title', 'Kiosk mode'); + } + + /** + * Guest user needs to be out of "Disabled" group to have access to frontend. + */ + public static function removeGuestFromDisabledGroup() { + DBexecute('DELETE FROM users_groups WHERE userid=2 AND usrgrpid=9'); + } + + public function addGuestToDisabledGroup() { + DBexecute('INSERT INTO users_groups (id, usrgrpid, userid) VALUES (150, 9, 2)'); + } +} diff --git a/ui/tests/selenium/dashboard/testPageDashboardList.php b/ui/tests/selenium/dashboard/testPageDashboardList.php new file mode 100644 index 00000000000..52b5f5bda5f --- /dev/null +++ b/ui/tests/selenium/dashboard/testPageDashboardList.php @@ -0,0 +1,246 @@ +page->login()->open('zabbix.php?action=dashboard.list'); + $this->page->assertTitle('Dashboards'); + $table = $this->query('class:list-table')->asTable()->one(); + $this->assertEquals(['', 'Name'], $table->getHeadersText()); + + // Check filter collapse/expand. + foreach (['true', 'false'] as $status) { + $filter_tab = $this->query('xpath://a[contains(@class, "filter-trigger")]')->one(); + $filter_tab->parents('xpath:/li[@aria-expanded="'.$status.'"]')->one()->click(); + } + + // Check filter fields. + $filter_form = $this->query('name:zbx_filter')->asForm()->one(); + $this->assertEquals(['Name', 'Show'], $filter_form->getLabels()->asText()); + foreach (['All', 'Created by me'] as $show_tag) { + $this->assertTrue($filter_form->query('xpath://ul[@id="filter_show"]/li/label[text()="'.$show_tag.'"]')->exists()); + }; + + // Check filter buttons. + foreach (['Apply', 'Reset'] as $button) { + $this->assertTrue($filter_form->query('button', $button)->exists()); + } + + // Check dashboard list button. + $this->assertTrue(($this->query('name:dashboardForm')->asForm()->one())->query('button:Delete')->exists()); + + // Check header buttons. + $this->assertTrue($this->query('button:Create dashboard')->exists()); + $this->assertTrue($this->query('xpath://button[@title="Kiosk mode"]')->exists()); + } + + public static function getCheckFilterData() { + return [ + [ + [ + 'fields' => [ + 'Show' => 'All' + ], + 'result_count' => 16 + ] + ], + [ + [ + 'fields' => [ + 'Show' => 'Created by me' + ], + 'result_count' => 15 + ] + ], + [ + [ + 'fields' => [ + 'Name' => 'graph', + 'Show' => 'All' + ], + 'result_count' => 3 + ] + ], + [ + [ + 'fields' => [ + 'Name' => 'widget', + 'Show' => 'Created by me' + ], + 'result_count' => 9 + ] + ], + [ + [ + 'fields' => [ + 'Name' => '5' + ], + 'result_count' => 0 + ] + ], + [ + [ + 'fields' => [ + 'Name' => 'Dashboard for Dynamic item' + ], + 'result_count' => 1 + ] + ], + [ + [ + 'fields' => [ + 'Name' => 'Testing share dashboard', + 'Show' => 'Created by me' + ], + 'result_count' => 0 + ] + ] + ]; + } + + /** + * @dataProvider getCheckFilterData + */ + public function testPageDashboardList_CheckFilter($data) { + $this->page->login()->open('zabbix.php?action=dashboard.list'); + $table = $this->query('class:list-table')->asTable()->one(); + $start_rows_count = $table->getRows()->count(); + $this->assertTableStats($start_rows_count); + $form = $this->query('name:zbx_filter')->asForm()->one(); + $form->fill($data['fields']); + $form->submit(); + + // Check that filtered count matches expected. + if ($data['result_count'] !== 0) { + $this->assertEquals($data['result_count'], $table->getRows()->count()); + } + $this->assertTableStats($data['result_count']); + $form->query('button:Reset')->one()->click(); + $this->assertEquals($start_rows_count, $table->getRows()->count()); + } + + /** + * Check that My and Sharing tags displays correctly in Dashboard Lists for Admin. + */ + public function testPageDashboardList_CheckOwners() { + $this->page->login()->open('zabbix.php?action=dashboard.list'); + $table = $this->query('class:list-table')->asTable()->one(); + + $dashboards = CDBHelper::getAll('SELECT name, userid, private, dashboardid FROM dashboard'); + $dashboards_usrgrps = CDBHelper::getAll('SELECT dashboardid FROM dashboard_usrgrp'); + $dashboards_users = CDBHelper::getAll('SELECT dashboardid FROM dashboard_user'); + + // Checking that dashboard, owned by Admin, has My tag near its name. + foreach ($dashboards as $dashboard) { + if ($dashboard['userid'] == 1) { + $this->assertEquals('My', $this->getTagText($table, $dashboard['name'], 'green')); + + if ($dashboard['private'] == 0) { + $this->assertEquals('Shared', $this->getTagText($table, $dashboard['name'], 'yellow')); + } + } + + // Checking that Admin dashboards, shared with groups, has Shared tag. + $this->assertDashboardOwner($dashboards_usrgrps, $dashboard, $table); + + // Checking that Admin dashboards, shared with users, has Shared tag. + $this->assertDashboardOwner($dashboards_users, $dashboard, $table); + } + } + + public function testPageDashboardList_DeleteSingleDashboard() { + $this->page->login()->open('zabbix.php?action=dashboard.list'); + $dashboard_name = 'Testing share dashboard'; + $table = $this->query('class:list-table')->asTable()->one(); + + // Delete single Dashboard. + $before_rows_count = $table->getRows()->count(); + $this->assertTableStats($before_rows_count); + $table->findRow('Name', $dashboard_name, true)->select(); + $this->query('button:Delete')->one()->click(); + $this->page->acceptAlert(); + $this->page->waitUntilReady(); + $this->assertMessage(TEST_GOOD, 'Dashboard deleted'); + $this->assertTableStats($before_rows_count - 1); + + // Check database. + $this->assertEquals(0, CDBHelper::getCount('SELECT * FROM dashboard WHERE name='.zbx_dbstr($dashboard_name))); + } + + public function testPageDashboardList_DeleteAllDashboards() { + $this->page->login()->open('zabbix.php?action=dashboard.list'); + $this->selectTableRows(); + $this->query('button:Delete')->one()->click(); + $this->page->acceptAlert(); + $this->page->waitUntilReady(); + $this->assertMessage(TEST_GOOD, 'Dashboards deleted'); + $this->assertTableStats(0); + + // Check database. + $this->assertEquals(0, CDBHelper::getCount('SELECT * FROM dashboard WHERE templateid IS NULL')); + } + + /** + * Allows to check tag near Dashboard name. + * + * @param element $table Table where to find row + * @param string $column Column name + * @param string $color Color of tag in the row + */ + private function getTagText($table, $column, $color) { + $row = $table->findRow('Name', $column, true); + + return $row->query('xpath://span[@class="status-'.$color.'"]')->one()->getText(); + } + + /** + * Allows to check values in different tables from database. + * + * @param array $ids Dashboard ids where to find particular dashboard id + * @param array $dashboard Dashboard table from database + * @param element $table Frontend table + */ + private function assertDashboardOwner($ids, $dashboard, $table) { + foreach ($ids as $id) { + if ($id['dashboardid'] == $dashboard['dashboardid'] && $dashboard['userid'] == 1) { + $this->assertEquals('Shared', $this->getTagText($table, $dashboard['name'], 'yellow')); + } + } + } +} diff --git a/ui/tests/selenium/dashboard/testPageDashboardWidgets.php b/ui/tests/selenium/dashboard/testPageDashboardWidgets.php new file mode 100644 index 00000000000..4724ea686e8 --- /dev/null +++ b/ui/tests/selenium/dashboard/testPageDashboardWidgets.php @@ -0,0 +1,306 @@ +page->login()->open('zabbix.php?action=dashboard.view&dashboardid=1'); + $dashboard = CDashboardElement::find()->one()->edit(); + // Check that widget type isn't changed in frontend and in DB. + $this->checkLastSelectedWidgetType(); + + // Opening edit widget form. + $form_system_info = $dashboard->getWidget('System information')->edit(); + $this->assertEquals('System information', $form_system_info->getField('Type')->getValue()); + $form_system_info->submit(); + // Check that widget type isn't changed in frontend and in DB. + $this->checkLastSelectedWidgetType(); + + // Making changes in widget form that are not "Widget type". + $form_problems = $dashboard->getWidget('Current problems')->edit(); + $this->assertEquals('Problems', $form_problems->getField('Type')->getValue()); + $data =[ + 'Name' => 'check widget type', + 'Refresh interval' => 'No refresh', + 'Show' => 'Recent problems', + 'Show tags' => 'None' + ]; + $form_problems->fill($data); + $form_problems->submit(); + $this->checkLastSelectedWidgetType(); + + // Add widget with current default type "Action log". + $dashboard->addWidget(); + $this->query('xpath://div[@role="dialog"]//button[text()="Add"]')->waitUntilPresent()->one()->click(); + // Check if widget was added. + $dashboard->getWidget('Action log'); + $this->checkLastSelectedWidgetType(); + + $dashboard->cancelEditing(); + } + + /** + * Check last selected widget type in frontend and in DB. + * By default is 'Action log' type and without record in DB. + * + * @param string $type widget type name + * @param string $db_type widget type name stored in DB + */ + private function checkLastSelectedWidgetType($type = 'Action log', $db_type = null) { + $dashboard = CDashboardElement::find()->one(); + COverlayDialogElement::ensureNotPresent(); + $overlay = $dashboard->addWidget(); + $form = $overlay->asForm(); + $this->assertEquals($type, $form->getField('Type')->getValue()); + + if ($db_type) { + $this->assertEquals($db_type, CDBHelper::getValue("SELECT value_str FROM profiles". + " WHERE userid=1 AND idx='web.dashboard.last_widget_type'")); + } + else { + $this->assertEquals(0, CDBHelper::getCount("SELECT * FROM profiles". + " WHERE userid=1 AND idx='web.dashboard.last_widget_type'")); + } + + $overlay->close(); + } + + /** + * Widget type should be inherited from the one that was selected last time. + */ + public function testPageDashboardWidgets_checkWidgetTypeRemembering() { + $this->page->login()->open('zabbix.php?action=dashboard.view&dashboardid=1'); + $dashboard = CDashboardElement::find()->one()->edit(); + // Opening widget configuration form for new Clock widget. + $overlay = $dashboard->addWidget(); + $default_form = $overlay->asForm(); + $default_form->fill(['Type' => 'Clock']); + $default_form->waitUntilReloaded(); + $overlay->close(); + // Check that widget type is remembered as Clock. + $this->checkLastSelectedWidgetType('Clock', 'clock'); + + // Save edit widget form without changing widget type. + $sys_info_form = $dashboard->getWidget('System information')->edit(); + $this->assertEquals('System information', $sys_info_form->getField('Type')->getValue()); + $sys_info_form->submit(); + $this->page->waitUntilReady(); + // Check that widget type is still remembered as Clock. + $this->checkLastSelectedWidgetType('Clock', 'clock'); + + // Opening edit widget form and change widget type. + $change_form = $dashboard->getWidget('System information')->edit(); + $change_form->fill(['Type' => 'Data overview']); + $overlay->close(); + // Check that widget type inherited from previous widget. + $this->checkLastSelectedWidgetType('Data overview', 'dataover'); + + $dashboard->cancelEditing(); + } + + /** + * Check "Problem Hosts" widget. + */ + public function testPageDashboardWidgets_checkProblemHostsWidget() { + // Authorize user and open the page with the desired widget. + $this->page->login()->open('zabbix.php?action=dashboard.view&dashboardid=1000'); + + // Find dashboard element. + $dashboard = CDashboardElement::find()->one(); + + // Get dashboard widget element by widget title ('Problem hosts'). + $widget = $dashboard->getWidget('Problem hosts'); + // Check refresh interval of widget. + $this->assertEquals('1 minute', $widget->getRefreshInterval()); + + // Get widget content as table. + $table = $widget->getContent()->asTable(); + // Check text of the table headers. + $this->assertSame(['Host group', 'Without problems', 'With problems', 'Total'], $table->getHeadersText()); + + // Expected table values. + $expected = [ + 'Host group for tag permissions' => 1, + 'Zabbix servers' => 17, + 'ZBX6648 All Triggers' => 1, + 'ZBX6648 Disabled Triggers' => 1, + 'ZBX6648 Enabled Triggers' => 1 + ]; + + /* + * Index rows by column "Host group": + * Get table data as array where values from column 'Host group' are used as array keys. + */ + $data = $table->index('Host group'); + + foreach ($expected as $group => $problems) { + // Get table row by host name. + $row = $data[$group]; + + // Check the value in table. + $this->assertEquals($problems, $row['Without problems']); + $this->assertEquals($problems, $row['Total']); + } + } + + /** + * Check empty dashboard. + */ + public function testPageDashboardWidgets_checkEmptyDashboard() { + $this->page->login()->open('zabbix.php?action=dashboard.list'); + + // Create a new dashboard. + $this->query('button:Create dashboard')->one()->click(); + $this->page->waitUntilReady(); + + // Wait until overlay dialog is visible and ready. + $dialog = COverlayDialogElement::find()->one()->waitUntilReady(); + + // Check title of a dialog. + $this->assertEquals('Dashboard properties', $dialog->getTitle()); + // Close the dialog. + $dialog->close(); + + $dashboard = CDashboardElement::find()->one(); + // Check if dashboard is empty. + $this->assertTrue($dashboard->isEmpty()); + + // Open a new widget form. + $overlay = $dashboard->edit()->addWidget(); + // Wait until add widget dialog is shown and close it. + $overlay->close(); + + // Check if dashboard is still empty. + $this->assertTrue($dashboard->isEmpty()); + // Cancel dashboard editing. + $dashboard->cancelEditing(); + } + + /** + * Create dashboard with clock widget. + */ + public function testPageDashboardWidgets_checkDashboardCreate() { + $this->page->login()->open('zabbix.php?action=dashboard.list'); + + $this->query('button:Create dashboard')->one()->click(); + $this->page->waitUntilReady(); + $dialog = COverlayDialogElement::find()->one()->waitUntilReady(); + + $this->assertEquals('Dashboard properties', $dialog->getTitle()); + $configuration = $dialog->asForm(); + // Change dashboard owner. + $owner = $configuration->getField('Owner'); + $owner->clear(); + $owner->select('test-user'); + // Change dashboard name. + $configuration->getField('Name')->clear()->type('Dashboard create test'); + $configuration->submit(); + + if ($this->page->isAlertPresent()) { + $this->page->acceptAlert(); + } + + $dashboard = CDashboardElement::find()->one(); + // Check the name of dashboard. + $this->query('id:page-title-general')->waitUntilTextPresent('Dashboard create test'); + $this->assertEquals('Dashboard create test', $dashboard->getTitle()); + + // Add widget. + $overlay = $dashboard->addWidget(); + $form = $overlay->asForm(); + // Set type to "Clock". + $form->getField('Type')->asDropdown()->select('Clock'); + // Wait until overlay is reloaded. + $overlay->waitUntilReady(); + // Set name of widget. + $form->getField('Name')->type('Clock test'); + $form->submit(); + + if ($this->page->isAlertPresent()) { + $this->page->acceptAlert(); + } + + // Check if widget was added. + $widget = $dashboard->getWidget('Clock test'); + $widget->getContent()->query('class:clock')->waitUntilVisible(); + + // Save dashboard. + $dashboard->save(); + $this->page->waitUntilReady(); + + // Get global message. + $message = CMessageElement::find()->one(); + // Check if message is positive. + $this->assertTrue($message->isGood()); + // Check message title. + $this->assertEquals('Dashboard created', $message->getTitle()); + } + + /** + * Edit widget. + */ + public function testPageDashboardWidgets_checkProblemWidgetEdit() { + $this->page->login()->open('zabbix.php?action=dashboard.view&dashboardid=1'); + + $dashboard = CDashboardElement::find()->one()->edit(); + $widget = $dashboard->getWidget('Problems by severity'); + + // Check if widget is editable. + $this->assertEquals(true, $widget->isEditable()); + + // Open widget edit form and get the form element. + $form = $widget->edit(); + + // Get "Host groups" multiselect. + $groups = $form->getField('Host groups'); + + // Select a single group. + $groups->select('Zabbix servers'); + + // Change the name of widget. + $form->getField('Name')->clear()->type('New widget name'); + // Change show option. + $form->getField('Show')->select('Host groups'); + // Submit the form. + $form->submit(); + + if ($this->page->isAlertPresent()) { + $this->page->acceptAlert(); + } + + // Check if widget can be found by a new name. + $dashboard->getWidget('New widget name'); + $table = $widget->getContent()->asTable(); + // Check if only selected host group is shown. + $this->assertEquals(['Zabbix servers'], array_keys($table->index('Host group'))); + + $dashboard->cancelEditing(); + } +} diff --git a/ui/tests/selenium/testPageDashboard.php b/ui/tests/selenium/testPageDashboard.php deleted file mode 100644 index 8688c7badeb..00000000000 --- a/ui/tests/selenium/testPageDashboard.php +++ /dev/null @@ -1,312 +0,0 @@ - 'Dashboard with favorite graphs and maps widgets', - 'private' => 1, - 'pages' => [ - [ - 'name' => 'Page 1', - 'widgets' => [ - [ - 'type' => 'favgraphs', - 'x' => 0, - 'y' => 0, - 'width' => 12, - 'height' => 4 - ], - [ - 'type' => 'favmaps', - 'x' => 13, - 'y' => 0, - 'width' => 4, - 'height' => 4 - ] - ] - ] - ] - ] - ]); - self::$dashboardid = $response['dashboardids'][0]; - } - - /** - * @onBefore removeGuestFromDisabledGroup - * @onAfter addGuestToDisabledGroup - */ - public function testPageDashboard_CheckLayoutForDifferentUsers() { - $users = ['super-admin', 'admin', 'user', 'guest']; - foreach ($users as $user) { - switch ($user) { - case 'super-admin' : - $this->authenticateUser('09e7d4286dfdca4ba7be15e0f3b2b55b', 1); - $this->zbxTestOpen('zabbix.php?action=dashboard.view'); - $this->zbxTestCheckNoRealHostnames(); - break; - case 'admin' : - $this->authenticateUser('09e7d4286dfdca4ba7be15e0f3b2b55c', 4); - $this->zbxTestOpen('zabbix.php?action=dashboard.view'); - break; - case 'user'; - $this->authenticateUser('09e7d4286dfdca4ba7be15e0f3b2b55d', 5); - $this->zbxTestOpen('zabbix.php?action=dashboard.view'); - break; - case 'guest'; - $this->authenticateUser('09e7d4286dfdca4ba7be15e0f3b2b55e', 2); - $this->zbxTestOpen('zabbix.php?action=dashboard.view'); - break; - } - $this->zbxTestCheckTitle('Dashboard'); - $this->zbxTestCheckHeader('Global view'); - if ($user !== 'super-admin') { - $this->zbxTestAssertElementText("//div[@class='dashboard-grid']/div[2]//tr[@class='nothing-to-show']/td", - 'No data found.'); - $this->zbxTestAssertElementText("//div[@class='dashboard-grid']/div[3]//tr[@class='nothing-to-show']/td", - 'No permissions to referred object or it does not exist!'); - } - else { - $this->zbxTestAssertElementPresentXpath("//div[@class='dashboard-grid']/div[3]//h4[text()='Performance']"); - } - $this->zbxTestAssertElementText("//div[@class='dashboard-grid']/div[2]//h4", 'Top hosts by CPU utilization'); - $this->zbxTestAssertElementText("//div[@class='dashboard-grid']/div[4]//h4", 'System information'); - $this->zbxTestAssertElementText("//div[@class='dashboard-grid']/div[7]//h4", 'Host availability'); - $this->zbxTestAssertElementText("//div[@class='dashboard-grid']/div[8]//h4", 'Problems by severity'); - $this->zbxTestAssertElementText("//div[@class='dashboard-grid']/div[9]//h4", 'Geomap'); - $this->zbxTestAssertElementText("//div[@class='dashboard-grid']/div[10]//h4", 'Current problems'); - $this->zbxTestAssertElementPresentXpath("//div[@class='dashboard-grid']/div[5]//h4[text()='Local time']"); - $this->zbxTestAssertElementPresentXpath("//div[@class='dashboard-grid']/div[6]//h4[text()='Graph']"); - - // Logout. - $this->zbxTestLogout(); - $this->zbxTestWaitForPageToLoad(); - $this->webDriver->manage()->deleteAllCookies(); - } - } - - public function testPageDashboard_CheckDasboardPopupLayout() { - $this->page->login()->open('zabbix.php?action=dashboard.view&new=1')->waitUntilReady(); - $dialog = COverlayDialogElement::find()->waitUntilVisible()->one(); - $this->assertEquals('Dashboard properties', $dialog->getTitle()); - $properties_form = $dialog->query('name:dashboard_properties_form')->asForm()->one(); - $this->assertEquals(['Owner', 'Name', 'Default page display period', 'Start slideshow automatically'], - $properties_form->getLabels()->asText() - ); - - // Check available display periods. - $properties_form->checkValue(['Default page display period' => '30 seconds', 'Name' => 'New dashboard']); - $this->assertEquals('255', $properties_form->query('id:name')->one()->getAttribute('maxlength')); - $this->assertEquals(['10 seconds', '30 seconds', '1 minute', '2 minutes', '10 minutes', '30 minutes', '1 hour'], - $properties_form->query('name:display_period')->asDropdown()->one()->getOptions()->asText() - ); - - $properties_form->fill(['Name' => 'Dashboard creation']); - $properties_form->submit(); - COverlayDialogElement::ensureNotPresent(); - $this->page->waitUntilReady(); - $dashboard = CDashboardElement::find()->one(); - - // Check popup-menu options. - $this->query('id:dashboard-add')->one()->click(); - $add_menu = CPopupMenuElement::find()->one()->waitUntilVisible(); - foreach (['Add widget' => true, 'Add page' => true, 'Paste widget' => false, 'Paste page'=> false] as $item => $enabled) { - $this->assertTrue($add_menu->getItem($item)->isEnabled($enabled)); - } - $dashboard->cancelEditing(); - } - - public function testPageDashboard_AddFavouriteGraphs() { - $cpu_itemid = CDBHelper::getValue('SELECT itemid FROM items WHERE hostid=10084 AND name='.zbx_dbstr($this->graphCpu)); - $memory_itemid = CDBHelper::getValue('SELECT itemid FROM items WHERE hostid=10084 AND name='.zbx_dbstr($this->graphMemory)); - - $this->zbxTestLogin('zabbix.php?action=latest.view&filter_selected=0&filter_reset=1'); - $this->zbxTestCheckHeader('Latest data'); - - $filter = $this->query('name:zbx_filter')->asForm()->one(); - $filter->getField('Hosts')->fill($this->hostName); - $filter->getField('Name')->fill($this->graphCpu); - $filter->submit(); - $cpu_link = $this->query('link:Graph')->one(); - $cpu_link->click(); - - $this->zbxTestWaitUntilElementVisible(WebDriverBy::xpath("//button[@id='addrm_fav']")); - $this->zbxTestAssertAttribute("//button[@id='addrm_fav']", 'title', 'Add to favorites'); - $this->zbxTestClickWait('addrm_fav'); - $this->zbxTestWaitUntilElementVisible(WebDriverBy::xpath('//button[@id="addrm_fav" and @title="Remove from favorites"]')); - $this->zbxTestAssertAttribute("//button[@id='addrm_fav']", 'title', 'Remove from favorites'); - - $this->page->open('zabbix.php?action=latest.view'); - $filter->invalidate(); - $filter->getField('Hosts')->fill($this->hostName); - $filter->getField('Name')->fill($this->graphMemory); - $filter->submit(); - $memory_link = $this->query('link:Graph')->one(); - $memory_link->click(); - - $this->zbxTestWaitUntilElementVisible(WebDriverBy::xpath("//button[@id='addrm_fav']")); - $this->zbxTestAssertAttribute("//button[@id='addrm_fav']", 'title', 'Add to favorites'); - $this->zbxTestClickWait('addrm_fav'); - $this->query('id:addrm_fav')->one()->waitUntilAttributesPresent(['title' => 'Remove from favorites']); - $this->zbxTestAssertAttribute("//button[@id='addrm_fav']", 'title', 'Remove from favorites'); - - $this->page->login()->open('zabbix.php?action=dashboard.view&dashboardid='.self::$dashboardid)->waitUntilReady(); - $url_xpath = '//div[@class="dashboard-grid"]/div[2]//a[@href='; - - foreach ([$this->graphCpu => $cpu_itemid, $this->graphMemory => $memory_itemid] as $graph => $itemid) { - $graph_url = 'history.php?action=showgraph&itemids%5B0%5D='.$itemid; - $this->zbxTestAssertElementText($url_xpath.CXPathHelper::escapeQuotes($graph_url).']', 'ЗАББИКС Сервер: '.$graph); - $this->assertEquals(1, CDBHelper::getCount('SELECT profileid FROM profiles WHERE idx=' - .zbx_dbstr('web.favorite.graphids').' AND value_id='.$itemid) - ); - } - } - - public function testPageDashboard_RemoveFavouriteGraphs() { - $exception = null; - - try { - $this->page->login()->open('zabbix.php?action=dashboard.view&dashboardid='.self::$dashboardid)->waitUntilReady(); - $FavouriteGraphs = DBfetchArray(DBselect('SELECT value_id FROM profiles WHERE idx='.zbx_dbstr('web.favorite.graphids'))); - foreach ($FavouriteGraphs as $FavouriteGraph) { - $remove_item = $this->query('xpath://button[@data-itemid='.zbx_dbstr($FavouriteGraph['value_id']). - ' and contains(@onclick, "rm4favorites")]')->waituntilClickable()->one(); - $remove_item->click(); - $remove_item->waitUntilNotVisible(); - } - $this->zbxTestAssertElementText('//div[@class="dashboard-grid-widget-container"]//tr[@class="nothing-to-show"]/td', 'No graphs added.'); - $this->assertEquals(0, CDBHelper::getCount('SELECT profileid FROM profiles WHERE idx='.zbx_dbstr('web.favorite.graphids'))); - } - catch (Exception $e) { - $exception = $e; - } - - if ($exception !== null) { - throw $exception; - } - } - - public function testPageDashboard_AddFavouriteMap() { - $this->zbxTestLogin('sysmaps.php'); - $this->zbxTestCheckHeader('Maps'); - $this->zbxTestClickLinkTextWait($this->mapTest); - $this->zbxTestWaitUntilElementVisible(WebDriverBy::xpath("//button[@id='addrm_fav']")); - $this->zbxTestAssertAttribute("//button[@id='addrm_fav']", 'title', 'Add to favorites'); - $this->zbxTestClickWait('addrm_fav'); - $this->query('id:addrm_fav')->one()->waitUntilAttributesPresent(['title' => 'Remove from favorites']); - $this->zbxTestAssertAttribute("//button[@id='addrm_fav']", 'title', 'Remove from favorites'); - - $this->page->login()->open('zabbix.php?action=dashboard.view&dashboardid='.self::$dashboardid)->waitUntilReady(); - $this->zbxTestAssertElementText('//div[@class="dashboard-grid-widget-container"]/div[2]//a[@href="zabbix.php?action=map.view&sysmapid='.$this->mapTestId.'"]', $this->mapTest); - $this->assertEquals(1, CDBHelper::getCount('SELECT profileid FROM profiles WHERE idx='.zbx_dbstr('web.favorite.sysmapids').' AND value_id='.$this->mapTestId)); - } - - public function testPageDashboard_RemoveFavouriteMaps() { - $this->page->login()->open('zabbix.php?action=dashboard.view&dashboardid='.self::$dashboardid)->waitUntilReady(); - $widget_content = CDashboardElement::find()->one()->getWidget('Favorite maps')->getContent(); - $favourite_maps = DBfetchArray(DBselect('SELECT value_id FROM profiles WHERE idx='. - zbx_dbstr('web.favorite.sysmapids'))); - - foreach ($favourite_maps as $favourite_map) { - $remove_item = $this->query('xpath://button[@data-sysmapid='.zbx_dbstr($favourite_map['value_id']). - ' and contains(@onclick, "rm4favorites")]')->waituntilClickable()->one(); - $remove_item->click(); - $remove_item->waitUntilNotVisible(); - } - - $this->assertTrue($widget_content->query('xpath://table//td[text()="No maps added."]')->waitUntilVisible() - ->one()->isPresent()); - $this->assertEquals(0, CDBHelper::getCount('SELECT profileid FROM profiles WHERE idx='. - zbx_dbstr('web.favorite.sysmapids'))); - } - - public function testPageDashboard_KioskMode() { - $this->zbxTestLogin('zabbix.php?action=dashboard.view&dashboardid=1', false); - $this->zbxTestCheckHeader('Global view'); - $this->zbxTestAssertElementPresentXpath("//header"); - - $this->zbxTestClickXpathWait("//button[contains(@class, 'btn-kiosk')]"); - $this->zbxTestWaitForPageToLoad(); - $this->zbxTestWaitUntilElementPresent(WebDriverBy::xpath('//button[@title="Normal view"]')); - $this->zbxTestAssertElementNotPresentXpath("//header"); - $this->zbxTestAssertElementNotPresentXpath("//header[@class='header-title']"); - $this->zbxTestAssertElementNotPresentXpath("//ul[contains(@class, 'filter-breadcrumb')]"); - $this->zbxTestAssertAttribute("//button[contains(@class, 'btn-min')]", 'title', 'Normal view'); - - $this->query('class:btn-min')->one()->forceClick(); - $this->zbxTestWaitForPageToLoad(); - $this->zbxTestWaitUntilElementPresent(WebDriverBy::xpath("//button[contains(@class, 'btn-kiosk')]")); - $this->zbxTestAssertAttribute("//button[contains(@class, 'btn-kiosk')]", 'title', 'Kiosk mode'); - $this->zbxTestAssertElementPresentXpath("//header"); - $this->zbxTestAssertElementPresentXpath("//header[@class='header-title']"); - $this->zbxTestAssertElementPresentXpath('//ul[@class="breadcrumbs"]'); - } - - public function testPageDashboard_KioskModeUrlParameter() { - // Set layout mode to kiosk view. - $this->zbxTestLogin('zabbix.php?action=dashboard.view&kiosk=1', false); - $this->zbxTestWaitForPageToLoad(); - $this->zbxTestWaitUntilElementPresent(WebDriverBy::xpath('//button[@title="Normal view"]')); - $this->zbxTestAssertElementNotPresentXpath("//header"); - $this->zbxTestAssertElementNotPresentXpath("//header[@class='header-title']"); - $this->zbxTestAssertElementNotPresentXpath("//ul[contains(@class, 'filter-breadcrumb')]"); - $this->zbxTestAssertAttribute("//button[contains(@class, 'btn-min')]", 'title', 'Normal view'); - - // Set layout mode to default layout. - $this->zbxTestOpen('zabbix.php?action=dashboard.view&kiosk=0'); - $this->zbxTestCheckHeader('Global view'); - $this->zbxTestAssertElementPresentXpath("//header"); - $this->zbxTestAssertAttribute("//button[contains(@class, 'btn-kiosk')]", 'title', 'Kiosk mode'); - } - - /** - * Guest user needs to be out of "Disabled" group to have access to frontend. - */ - public static function removeGuestFromDisabledGroup() { - DBexecute('DELETE FROM users_groups WHERE userid=2 AND usrgrpid=9'); - } - - public function addGuestToDisabledGroup() { - DBexecute('INSERT INTO users_groups (id, usrgrpid, userid) VALUES (150, 9, 2)'); - } -} diff --git a/ui/tests/selenium/testPageDashboardList.php b/ui/tests/selenium/testPageDashboardList.php deleted file mode 100644 index fae8bd0fd72..00000000000 --- a/ui/tests/selenium/testPageDashboardList.php +++ /dev/null @@ -1,246 +0,0 @@ -page->login()->open('zabbix.php?action=dashboard.list'); - $this->page->assertTitle('Dashboards'); - $table = $this->query('class:list-table')->asTable()->one(); - $this->assertEquals(['', 'Name'], $table->getHeadersText()); - - // Check filter collapse/expand. - foreach (['true', 'false'] as $status) { - $filter_tab = $this->query('xpath://a[contains(@class, "filter-trigger")]')->one(); - $filter_tab->parents('xpath:/li[@aria-expanded="'.$status.'"]')->one()->click(); - } - - // Check filter fields. - $filter_form = $this->query('name:zbx_filter')->asForm()->one(); - $this->assertEquals(['Name', 'Show'], $filter_form->getLabels()->asText()); - foreach (['All', 'Created by me'] as $show_tag) { - $this->assertTrue($filter_form->query('xpath://ul[@id="filter_show"]/li/label[text()="'.$show_tag.'"]')->exists()); - }; - - // Check filter buttons. - foreach (['Apply', 'Reset'] as $button) { - $this->assertTrue($filter_form->query('button', $button)->exists()); - } - - // Check dashboard list button. - $this->assertTrue(($this->query('name:dashboardForm')->asForm()->one())->query('button:Delete')->exists()); - - // Check header buttons. - $this->assertTrue($this->query('button:Create dashboard')->exists()); - $this->assertTrue($this->query('xpath://button[@title="Kiosk mode"]')->exists()); - } - - public static function getCheckFilterData() { - return [ - [ - [ - 'fields' => [ - 'Show' => 'All' - ], - 'result_count' => 16 - ] - ], - [ - [ - 'fields' => [ - 'Show' => 'Created by me' - ], - 'result_count' => 15 - ] - ], - [ - [ - 'fields' => [ - 'Name' => 'graph', - 'Show' => 'All' - ], - 'result_count' => 3 - ] - ], - [ - [ - 'fields' => [ - 'Name' => 'widget', - 'Show' => 'Created by me' - ], - 'result_count' => 9 - ] - ], - [ - [ - 'fields' => [ - 'Name' => '5' - ], - 'result_count' => 0 - ] - ], - [ - [ - 'fields' => [ - 'Name' => 'Dashboard for Dynamic item' - ], - 'result_count' => 1 - ] - ], - [ - [ - 'fields' => [ - 'Name' => 'Testing share dashboard', - 'Show' => 'Created by me' - ], - 'result_count' => 0 - ] - ] - ]; - } - - /** - * @dataProvider getCheckFilterData - */ - public function testPageDashboardList_CheckFilter($data) { - $this->page->login()->open('zabbix.php?action=dashboard.list'); - $table = $this->query('class:list-table')->asTable()->one(); - $start_rows_count = $table->getRows()->count(); - $this->assertTableStats($start_rows_count); - $form = $this->query('name:zbx_filter')->asForm()->one(); - $form->fill($data['fields']); - $form->submit(); - - // Check that filtered count matches expected. - if ($data['result_count'] !== 0) { - $this->assertEquals($data['result_count'], $table->getRows()->count()); - } - $this->assertTableStats($data['result_count']); - $form->query('button:Reset')->one()->click(); - $this->assertEquals($start_rows_count, $table->getRows()->count()); - } - - /** - * Check that My and Sharing tags displays correctly in Dashboard Lists for Admin. - */ - public function testPageDashboardList_CheckOwners() { - $this->page->login()->open('zabbix.php?action=dashboard.list'); - $table = $this->query('class:list-table')->asTable()->one(); - - $dashboards = CDBHelper::getAll('SELECT name, userid, private, dashboardid FROM dashboard'); - $dashboards_usrgrps = CDBHelper::getAll('SELECT dashboardid FROM dashboard_usrgrp'); - $dashboards_users = CDBHelper::getAll('SELECT dashboardid FROM dashboard_user'); - - // Checking that dashboard, owned by Admin, has My tag near its name. - foreach ($dashboards as $dashboard) { - if ($dashboard['userid'] == 1) { - $this->assertEquals('My', $this->getTagText($table, $dashboard['name'], 'green')); - - if ($dashboard['private'] == 0) { - $this->assertEquals('Shared', $this->getTagText($table, $dashboard['name'], 'yellow')); - } - } - - // Checking that Admin dashboards, shared with groups, has Shared tag. - $this->assertDashboardOwner($dashboards_usrgrps, $dashboard, $table); - - // Checking that Admin dashboards, shared with users, has Shared tag. - $this->assertDashboardOwner($dashboards_users, $dashboard, $table); - } - } - - public function testPageDashboardList_DeleteSingleDashboard() { - $this->page->login()->open('zabbix.php?action=dashboard.list'); - $dashboard_name = 'Testing share dashboard'; - $table = $this->query('class:list-table')->asTable()->one(); - - // Delete single Dashboard. - $before_rows_count = $table->getRows()->count(); - $this->assertTableStats($before_rows_count); - $table->findRow('Name', $dashboard_name, true)->select(); - $this->query('button:Delete')->one()->click(); - $this->page->acceptAlert(); - $this->page->waitUntilReady(); - $this->assertMessage(TEST_GOOD, 'Dashboard deleted'); - $this->assertTableStats($before_rows_count - 1); - - // Check database. - $this->assertEquals(0, CDBHelper::getCount('SELECT * FROM dashboard WHERE name='.zbx_dbstr($dashboard_name))); - } - - public function testPageDashboardList_DeleteAllDashboards() { - $this->page->login()->open('zabbix.php?action=dashboard.list'); - $this->selectTableRows(); - $this->query('button:Delete')->one()->click(); - $this->page->acceptAlert(); - $this->page->waitUntilReady(); - $this->assertMessage(TEST_GOOD, 'Dashboards deleted'); - $this->assertTableStats(0); - - // Check database. - $this->assertEquals(0, CDBHelper::getCount('SELECT * FROM dashboard WHERE templateid IS NULL')); - } - - /** - * Allows to check tag near Dashboard name. - * - * @param element $table Table where to find row - * @param string $column Column name - * @param string $color Color of tag in the row - */ - private function getTagText($table, $column, $color) { - $row = $table->findRow('Name', $column, true); - - return $row->query('xpath://span[@class="status-'.$color.'"]')->one()->getText(); - } - - /** - * Allows to check values in different tables from database. - * - * @param array $ids Dashboard ids where to find particular dashboard id - * @param array $dashboard Dashboard table from database - * @param element $table Frontend table - */ - private function assertDashboardOwner($ids, $dashboard, $table) { - foreach ($ids as $id) { - if ($id['dashboardid'] == $dashboard['dashboardid'] && $dashboard['userid'] == 1) { - $this->assertEquals('Shared', $this->getTagText($table, $dashboard['name'], 'yellow')); - } - } - } -} diff --git a/ui/tests/selenium/testPageDashboardWidgets.php b/ui/tests/selenium/testPageDashboardWidgets.php deleted file mode 100644 index 2e70b871dac..00000000000 --- a/ui/tests/selenium/testPageDashboardWidgets.php +++ /dev/null @@ -1,306 +0,0 @@ -page->login()->open('zabbix.php?action=dashboard.view&dashboardid=1'); - $dashboard = CDashboardElement::find()->one()->edit(); - // Check that widget type isn't changed in frontend and in DB. - $this->checkLastSelectedWidgetType(); - - // Opening edit widget form. - $form_system_info = $dashboard->getWidget('System information')->edit(); - $this->assertEquals('System information', $form_system_info->getField('Type')->getValue()); - $form_system_info->submit(); - // Check that widget type isn't changed in frontend and in DB. - $this->checkLastSelectedWidgetType(); - - // Making changes in widget form that are not "Widget type". - $form_problems = $dashboard->getWidget('Current problems')->edit(); - $this->assertEquals('Problems', $form_problems->getField('Type')->getValue()); - $data =[ - 'Name' => 'check widget type', - 'Refresh interval' => 'No refresh', - 'Show' => 'Recent problems', - 'Show tags' => 'None' - ]; - $form_problems->fill($data); - $form_problems->submit(); - $this->checkLastSelectedWidgetType(); - - // Add widget with current default type "Action log". - $dashboard->addWidget(); - $this->query('xpath://div[@role="dialog"]//button[text()="Add"]')->waitUntilPresent()->one()->click(); - // Check if widget was added. - $dashboard->getWidget('Action log'); - $this->checkLastSelectedWidgetType(); - - $dashboard->cancelEditing(); - } - - /** - * Check last selected widget type in frontend and in DB. - * By default is 'Action log' type and without record in DB. - * - * @param string $type widget type name - * @param string $db_type widget type name stored in DB - */ - private function checkLastSelectedWidgetType($type = 'Action log', $db_type = null) { - $dashboard = CDashboardElement::find()->one(); - COverlayDialogElement::ensureNotPresent(); - $overlay = $dashboard->addWidget(); - $form = $overlay->asForm(); - $this->assertEquals($type, $form->getField('Type')->getValue()); - - if ($db_type) { - $this->assertEquals($db_type, CDBHelper::getValue("SELECT value_str FROM profiles". - " WHERE userid=1 AND idx='web.dashboard.last_widget_type'")); - } - else { - $this->assertEquals(0, CDBHelper::getCount("SELECT * FROM profiles". - " WHERE userid=1 AND idx='web.dashboard.last_widget_type'")); - } - - $overlay->close(); - } - - /** - * Widget type should be inherited from the one that was selected last time. - */ - public function testPageDashboardWidgets_checkWidgetTypeRemembering() { - $this->page->login()->open('zabbix.php?action=dashboard.view&dashboardid=1'); - $dashboard = CDashboardElement::find()->one()->edit(); - // Opening widget configuration form for new Clock widget. - $overlay = $dashboard->addWidget(); - $default_form = $overlay->asForm(); - $default_form->fill(['Type' => 'Clock']); - $default_form->waitUntilReloaded(); - $overlay->close(); - // Check that widget type is remembered as Clock. - $this->checkLastSelectedWidgetType('Clock', 'clock'); - - // Save edit widget form without changing widget type. - $sys_info_form = $dashboard->getWidget('System information')->edit(); - $this->assertEquals('System information', $sys_info_form->getField('Type')->getValue()); - $sys_info_form->submit(); - $this->page->waitUntilReady(); - // Check that widget type is still remembered as Clock. - $this->checkLastSelectedWidgetType('Clock', 'clock'); - - // Opening edit widget form and change widget type. - $change_form = $dashboard->getWidget('System information')->edit(); - $change_form->fill(['Type' => 'Data overview']); - $overlay->close(); - // Check that widget type inherited from previous widget. - $this->checkLastSelectedWidgetType('Data overview', 'dataover'); - - $dashboard->cancelEditing(); - } - - /** - * Check "Problem Hosts" widget. - */ - public function testPageDashboardWidgets_checkProblemHostsWidget() { - // Authorize user and open the page with the desired widget. - $this->page->login()->open('zabbix.php?action=dashboard.view&dashboardid=1000'); - - // Find dashboard element. - $dashboard = CDashboardElement::find()->one(); - - // Get dashboard widget element by widget title ('Problem hosts'). - $widget = $dashboard->getWidget('Problem hosts'); - // Check refresh interval of widget. - $this->assertEquals('1 minute', $widget->getRefreshInterval()); - - // Get widget content as table. - $table = $widget->getContent()->asTable(); - // Check text of the table headers. - $this->assertSame(['Host group', 'Without problems', 'With problems', 'Total'], $table->getHeadersText()); - - // Expected table values. - $expected = [ - 'Host group for tag permissions' => 1, - 'Zabbix servers' => 17, - 'ZBX6648 All Triggers' => 1, - 'ZBX6648 Disabled Triggers' => 1, - 'ZBX6648 Enabled Triggers' => 1 - ]; - - /* - * Index rows by column "Host group": - * Get table data as array where values from column 'Host group' are used as array keys. - */ - $data = $table->index('Host group'); - - foreach ($expected as $group => $problems) { - // Get table row by host name. - $row = $data[$group]; - - // Check the value in table. - $this->assertEquals($problems, $row['Without problems']); - $this->assertEquals($problems, $row['Total']); - } - } - - /** - * Check empty dashboard. - */ - public function testPageDashboardWidgets_checkEmptyDashboard() { - $this->page->login()->open('zabbix.php?action=dashboard.list'); - - // Create a new dashboard. - $this->query('button:Create dashboard')->one()->click(); - $this->page->waitUntilReady(); - - // Wait until overlay dialog is visible and ready. - $dialog = COverlayDialogElement::find()->one()->waitUntilReady(); - - // Check title of a dialog. - $this->assertEquals('Dashboard properties', $dialog->getTitle()); - // Close the dialog. - $dialog->close(); - - $dashboard = CDashboardElement::find()->one(); - // Check if dashboard is empty. - $this->assertTrue($dashboard->isEmpty()); - - // Open a new widget form. - $overlay = $dashboard->edit()->addWidget(); - // Wait until add widget dialog is shown and close it. - $overlay->close(); - - // Check if dashboard is still empty. - $this->assertTrue($dashboard->isEmpty()); - // Cancel dashboard editing. - $dashboard->cancelEditing(); - } - - /** - * Create dashboard with clock widget. - */ - public function testPageDashboardWidgets_checkDashboardCreate() { - $this->page->login()->open('zabbix.php?action=dashboard.list'); - - $this->query('button:Create dashboard')->one()->click(); - $this->page->waitUntilReady(); - $dialog = COverlayDialogElement::find()->one()->waitUntilReady(); - - $this->assertEquals('Dashboard properties', $dialog->getTitle()); - $configuration = $dialog->asForm(); - // Change dashboard owner. - $owner = $configuration->getField('Owner'); - $owner->clear(); - $owner->select('test-user'); - // Change dashboard name. - $configuration->getField('Name')->clear()->type('Dashboard create test'); - $configuration->submit(); - - if ($this->page->isAlertPresent()) { - $this->page->acceptAlert(); - } - - $dashboard = CDashboardElement::find()->one(); - // Check the name of dashboard. - $this->query('id:page-title-general')->waitUntilTextPresent('Dashboard create test'); - $this->assertEquals('Dashboard create test', $dashboard->getTitle()); - - // Add widget. - $overlay = $dashboard->addWidget(); - $form = $overlay->asForm(); - // Set type to "Clock". - $form->getField('Type')->asDropdown()->select('Clock'); - // Wait until overlay is reloaded. - $overlay->waitUntilReady(); - // Set name of widget. - $form->getField('Name')->type('Clock test'); - $form->submit(); - - if ($this->page->isAlertPresent()) { - $this->page->acceptAlert(); - } - - // Check if widget was added. - $widget = $dashboard->getWidget('Clock test'); - $widget->getContent()->query('class:clock')->waitUntilVisible(); - - // Save dashboard. - $dashboard->save(); - $this->page->waitUntilReady(); - - // Get global message. - $message = CMessageElement::find()->one(); - // Check if message is positive. - $this->assertTrue($message->isGood()); - // Check message title. - $this->assertEquals('Dashboard created', $message->getTitle()); - } - - /** - * Edit widget. - */ - public function testPageDashboardWidgets_checkProblemWidgetEdit() { - $this->page->login()->open('zabbix.php?action=dashboard.view&dashboardid=1'); - - $dashboard = CDashboardElement::find()->one()->edit(); - $widget = $dashboard->getWidget('Problems by severity'); - - // Check if widget is editable. - $this->assertEquals(true, $widget->isEditable()); - - // Open widget edit form and get the form element. - $form = $widget->edit(); - - // Get "Host groups" multiselect. - $groups = $form->getField('Host groups'); - - // Select a single group. - $groups->select('Zabbix servers'); - - // Change the name of widget. - $form->getField('Name')->clear()->type('New widget name'); - // Change show option. - $form->getField('Show')->select('Host groups'); - // Submit the form. - $form->submit(); - - if ($this->page->isAlertPresent()) { - $this->page->acceptAlert(); - } - - // Check if widget can be found by a new name. - $dashboard->getWidget('New widget name'); - $table = $widget->getContent()->asTable(); - // Check if only selected host group is shown. - $this->assertEquals(['Zabbix servers'], array_keys($table->index('Host group'))); - - $dashboard->cancelEditing(); - } -} -- cgit v1.2.3 From 67f5cefcb3124db497806067221c4b2703810632 Mon Sep 17 00:00:00 2001 From: Larisa Grigorjeva Date: Wed, 29 Jun 2022 14:02:05 +0100 Subject: .......... [DEV-2073] fixed after 1 reorganization --- ui/tests/selenium/dashboard/testPageDashboardList.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ui/tests/selenium/dashboard/testPageDashboardList.php b/ui/tests/selenium/dashboard/testPageDashboardList.php index 52b5f5bda5f..7c5b95bbe04 100644 --- a/ui/tests/selenium/dashboard/testPageDashboardList.php +++ b/ui/tests/selenium/dashboard/testPageDashboardList.php @@ -77,7 +77,7 @@ class testPageDashboardList extends CWebTest { 'fields' => [ 'Show' => 'All' ], - 'result_count' => 16 + 'result_count' => 22 ] ], [ -- cgit v1.2.3 From 539dbbf19a060309decc8909e08410a984e529a1 Mon Sep 17 00:00:00 2001 From: Larisa Grigorjeva Date: Wed, 29 Jun 2022 14:08:10 +0100 Subject: .......... [DEV-2073] reorganized tests vol. 2 --- ui/tests/selenium/SeleniumTests.php | 29 ++++++++++++++++++++--------- 1 file changed, 20 insertions(+), 9 deletions(-) diff --git a/ui/tests/selenium/SeleniumTests.php b/ui/tests/selenium/SeleniumTests.php index 56d48cdbc65..6d26e5b7748 100644 --- a/ui/tests/selenium/SeleniumTests.php +++ b/ui/tests/selenium/SeleniumTests.php @@ -21,7 +21,7 @@ require_once dirname(__FILE__).'/testDocumentationLinks.php'; require_once dirname(__FILE__).'/testGeneric.php'; -// Api Tokens. +// Api tokens. require_once dirname(__FILE__).'/apiTokens/testPageApiTokensAdministrationGeneral.php'; require_once dirname(__FILE__).'/apiTokens/testPageApiTokensUserSettings.php'; require_once dirname(__FILE__).'/apiTokens/testFormApiTokensAdministrationGeneral.php'; @@ -45,6 +45,15 @@ require_once dirname(__FILE__).'/dashboard/testPageDashboardList.php'; require_once dirname(__FILE__).'/dashboard/testPageDashboardWidgets.php'; require_once dirname(__FILE__).'/dashboard/testPageTemplateDashboards.php'; +// Filter tabs. +require_once dirname(__FILE__).'/filterTabs/testFormFilterHosts.php'; +require_once dirname(__FILE__).'/filterTabs/testFormFilterLatestData.php'; +require_once dirname(__FILE__).'/filterTabs/testFormFilterProblems.php'; + +// Geomaps. +require_once dirname(__FILE__).'/geomaps/testFormAdministrationGeneralGeomaps.php'; +require_once dirname(__FILE__).'/geomaps/testGeomapWidgetScreenshots.php'; + require_once dirname(__FILE__).'/testExecuteNow.php'; require_once dirname(__FILE__).'/testGraphAxis.php'; @@ -200,8 +209,6 @@ require_once dirname(__FILE__).'/testZBX6648.php'; require_once dirname(__FILE__).'/testZBX6663.php'; require_once dirname(__FILE__).'/roles/testPageUserRoles.php'; require_once dirname(__FILE__).'/roles/testUserRolesPermissions.php'; -require_once dirname(__FILE__).'/geomaps/testFormAdministrationGeneralGeomaps.php'; -require_once dirname(__FILE__).'/geomaps/testGeomapWidgetScreenshots.php'; require_once dirname(__FILE__).'/reports/testPageReportsActionLog.php'; require_once dirname(__FILE__).'/reports/testPageReportsAudit.php'; require_once dirname(__FILE__).'/reports/testPageReportsNotifications.php'; @@ -221,7 +228,7 @@ class SeleniumTests { $suite->addTestSuite('testDocumentationLinks'); $suite->addTestSuite('testGeneric'); - // Api Tokens. + // Api tokens. $suite->addTestSuite('testFormApiTokensAdministrationGeneral'); $suite->addTestSuite('testFormApiTokensUserSettings'); $suite->addTestSuite('testPageApiTokensAdministrationGeneral'); @@ -245,6 +252,15 @@ class SeleniumTests { $suite->addTestSuite('testPageDashboardWidgets'); $suite->addTestSuite('testPageTemplateDashboards'); + // Filter tabs. + $suite->addTestSuite('testFormFilterHosts'); + $suite->addTestSuite('testFormFilterLatestData'); + $suite->addTestSuite('testFormFilterProblems'); + + // Geomaps. + $suite->addTestSuite('testFormAdministrationGeneralGeomaps'); + $suite->addTestSuite('testGeomapWidgetScreenshots'); + $suite->addTestSuite('testExecuteNow'); $suite->addTestSuite('testGraphAxis'); @@ -319,11 +335,6 @@ class SeleniumTests { $suite->addTestSuite('testFormAdministrationScripts'); $suite->addTestSuite('testFormAdministrationUserGroups'); $suite->addTestSuite('testFormEventCorrelation'); - $suite->addTestSuite('testFormFilterHosts'); - $suite->addTestSuite('testFormFilterLatestData'); - $suite->addTestSuite('testFormFilterProblems'); - $suite->addTestSuite('testFormAdministrationGeneralGeomaps'); - $suite->addTestSuite('testGeomapWidgetScreenshots'); $suite->addTestSuite('testFormGraph'); $suite->addTestSuite('testFormGraphPrototype'); $suite->addTestSuite('testFormHostConfiguration'); -- cgit v1.2.3 From 758f08cd3b2f0c65f559bdac8828c831fb0fa8d6 Mon Sep 17 00:00:00 2001 From: Larisa Grigorjeva Date: Thu, 30 Jun 2022 09:43:30 +0100 Subject: .......... [DEV-2073] fixed copy widget test --- ui/tests/selenium/dashboard/testDashboardCopyWidgets.php | 1 + 1 file changed, 1 insertion(+) diff --git a/ui/tests/selenium/dashboard/testDashboardCopyWidgets.php b/ui/tests/selenium/dashboard/testDashboardCopyWidgets.php index 79bebdcd431..18b54a7657a 100644 --- a/ui/tests/selenium/dashboard/testDashboardCopyWidgets.php +++ b/ui/tests/selenium/dashboard/testDashboardCopyWidgets.php @@ -359,6 +359,7 @@ class testDashboardCopyWidgets extends CWebTest { $copied_widget_form->submit(); } + $copied_widget->waitUntilReady(); $this->assertEquals($name, $copied_widget->getHeaderText()); $copied_fields = $copied_widget->edit()->getFields(); -- cgit v1.2.3 From eed7ca70ab6e94cd24d3990b7d454786bc41a40f Mon Sep 17 00:00:00 2001 From: Larisa Grigorjeva Date: Thu, 30 Jun 2022 10:02:18 +0100 Subject: .......... [DEV-2073] increased retries --- ui/tests/include/web/elements/CWidgetElement.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ui/tests/include/web/elements/CWidgetElement.php b/ui/tests/include/web/elements/CWidgetElement.php index 8933d2dbdd9..5d4b1348377 100644 --- a/ui/tests/include/web/elements/CWidgetElement.php +++ b/ui/tests/include/web/elements/CWidgetElement.php @@ -76,7 +76,7 @@ class CWidgetElement extends CElement { */ public function edit() { // Edit can sometimes fail so we have to retry this operation. - for ($i = 0; $i < 2; $i++) { + for ($i = 0; $i < 4; $i++) { $this->query('xpath:.//button[@class="btn-widget-edit"]')->waitUntilPresent()->one()->click(true); try { -- cgit v1.2.3 From bb15930823f34e610000260b8e8a7a6f98cc20a1 Mon Sep 17 00:00:00 2001 From: Larisa Grigorjeva Date: Thu, 30 Jun 2022 15:27:11 +0100 Subject: .......... [DEV-2073] fixed after 2 reorganization --- .../dashboard/testDashboardTopHostsWidget.php | 51 ++++++++++++++-------- .../selenium/dashboard/testPageDashboardList.php | 2 +- ui/tests/selenium/data/sources/TopHostsWidget.php | 18 ++++---- ui/tests/selenium/testTriggerDependencies.php | 2 + 4 files changed, 44 insertions(+), 29 deletions(-) diff --git a/ui/tests/selenium/dashboard/testDashboardTopHostsWidget.php b/ui/tests/selenium/dashboard/testDashboardTopHostsWidget.php index fecac56b159..0e77d7b9ee1 100644 --- a/ui/tests/selenium/dashboard/testDashboardTopHostsWidget.php +++ b/ui/tests/selenium/dashboard/testDashboardTopHostsWidget.php @@ -25,7 +25,9 @@ require_once dirname(__FILE__).'/../../include/helpers/CDataHelper.php'; /** * @dataSource TopHostsWidget * - * @backup widget, profiles, dashboard, items + * @backup widget, profiles, items + * + * @onAfter clearData */ class testDashboardTopHostsWidget extends CWebTest { @@ -1821,7 +1823,7 @@ class testDashboardTopHostsWidget extends CWebTest { 'column_fields' => [ [ 'Data' => 'Item value', - 'Item' => 'trap_text' + 'Item' => 'top_hosts_trap_text' ] ], 'text' => 'Text for text item' @@ -1836,7 +1838,7 @@ class testDashboardTopHostsWidget extends CWebTest { 'column_fields' => [ [ 'Data' => 'Item value', - 'Item' => 'trap_text', + 'Item' => 'top_hosts_trap_text', 'History data' => 'Trends' ] ], @@ -1852,7 +1854,7 @@ class testDashboardTopHostsWidget extends CWebTest { 'column_fields' => [ [ 'Data' => 'Item value', - 'Item' => 'trap_text', + 'Item' => 'top_hosts_trap_text', 'Display' => 'Bar' ] ] @@ -1867,7 +1869,7 @@ class testDashboardTopHostsWidget extends CWebTest { 'column_fields' => [ [ 'Data' => 'Item value', - 'Item' => 'trap_text', + 'Item' => 'top_hosts_trap_text', 'Display' => 'Indicators' ] ] @@ -1882,7 +1884,7 @@ class testDashboardTopHostsWidget extends CWebTest { 'column_fields' => [ [ 'Data' => 'Item value', - 'Item' => 'trap_text', + 'Item' => 'top_hosts_trap_text', 'Aggregation function' => 'max' ] ] @@ -1897,7 +1899,7 @@ class testDashboardTopHostsWidget extends CWebTest { 'column_fields' => [ [ 'Data' => 'Item value', - 'Item' => 'trap_text', + 'Item' => 'top_hosts_trap_text', 'Thresholds' => [ [ 'value' => '10' @@ -1916,7 +1918,7 @@ class testDashboardTopHostsWidget extends CWebTest { 'column_fields' => [ [ 'Data' => 'Item value', - 'Item' => 'trap_log' + 'Item' => 'top_hosts_trap_log' ] ], 'text' => 'Logs for text item' @@ -1931,7 +1933,7 @@ class testDashboardTopHostsWidget extends CWebTest { 'column_fields' => [ [ 'Data' => 'Item value', - 'Item' => 'trap_log', + 'Item' => 'top_hosts_trap_log', 'History data' => 'Trends' ] ], @@ -1947,7 +1949,7 @@ class testDashboardTopHostsWidget extends CWebTest { 'column_fields' => [ [ 'Data' => 'Item value', - 'Item' => 'trap_log', + 'Item' => 'top_hosts_trap_log', 'Display' => 'Bar' ] ] @@ -1962,7 +1964,7 @@ class testDashboardTopHostsWidget extends CWebTest { 'column_fields' => [ [ 'Data' => 'Item value', - 'Item' => 'trap_log', + 'Item' => 'top_hosts_trap_log', 'Display' => 'Indicators' ] ] @@ -1977,7 +1979,7 @@ class testDashboardTopHostsWidget extends CWebTest { 'column_fields' => [ [ 'Data' => 'Item value', - 'Item' => 'trap_log', + 'Item' => 'top_hosts_trap_log', 'Aggregation function' => 'max' ] ] @@ -1992,7 +1994,7 @@ class testDashboardTopHostsWidget extends CWebTest { 'column_fields' => [ [ 'Data' => 'Item value', - 'Item' => 'trap_log', + 'Item' => 'top_hosts_trap_log', 'Thresholds' => [ [ 'value' => '10' @@ -2011,7 +2013,7 @@ class testDashboardTopHostsWidget extends CWebTest { 'column_fields' => [ [ 'Data' => 'Item value', - 'Item' => 'trap_char' + 'Item' => 'top_hosts_trap_char' ] ], 'text' => 'characters_here' @@ -2026,7 +2028,7 @@ class testDashboardTopHostsWidget extends CWebTest { 'column_fields' => [ [ 'Data' => 'Item value', - 'Item' => 'trap_char', + 'Item' => 'top_hosts_trap_char', 'History data' => 'Trends' ] ], @@ -2042,7 +2044,7 @@ class testDashboardTopHostsWidget extends CWebTest { 'column_fields' => [ [ 'Data' => 'Item value', - 'Item' => 'trap_char', + 'Item' => 'top_hosts_trap_char', 'Display' => 'Bar' ] ] @@ -2057,7 +2059,7 @@ class testDashboardTopHostsWidget extends CWebTest { 'column_fields' => [ [ 'Data' => 'Item value', - 'Item' => 'trap_char', + 'Item' => 'top_hosts_trap_char', 'Display' => 'Indicators' ] ] @@ -2072,7 +2074,7 @@ class testDashboardTopHostsWidget extends CWebTest { 'column_fields' => [ [ 'Data' => 'Item value', - 'Item' => 'trap_char', + 'Item' => 'top_hosts_trap_char', 'Aggregation function' => 'max' ] ] @@ -2087,7 +2089,7 @@ class testDashboardTopHostsWidget extends CWebTest { 'column_fields' => [ [ 'Data' => 'Item value', - 'Item' => 'trap_char', + 'Item' => 'top_hosts_trap_char', 'Thresholds' => [ [ 'value' => '10' @@ -2136,4 +2138,15 @@ class testDashboardTopHostsWidget extends CWebTest { $dashboard->save(); $this->assertMessage(TEST_GOOD, 'Dashboard updated'); } + + /** + * Delete all created data after test. + */ + public static function clearData() { + $dashboardids = CDBHelper::getColumn("SELECT * from dashboard where name LIKE 'top_host_%'", 'dashboardid'); + CDataHelper::call('dashboard.delete', $dashboardids); + + $itemids = CDBHelper::getColumn("SELECT * from items where name LIKE 'top_host_trap%'", 'itemid'); + CDataHelper::call('dashboard.delete', $dashboardids); + } } diff --git a/ui/tests/selenium/dashboard/testPageDashboardList.php b/ui/tests/selenium/dashboard/testPageDashboardList.php index 7c5b95bbe04..52b5f5bda5f 100644 --- a/ui/tests/selenium/dashboard/testPageDashboardList.php +++ b/ui/tests/selenium/dashboard/testPageDashboardList.php @@ -77,7 +77,7 @@ class testPageDashboardList extends CWebTest { 'fields' => [ 'Show' => 'All' ], - 'result_count' => 22 + 'result_count' => 16 ] ], [ diff --git a/ui/tests/selenium/data/sources/TopHostsWidget.php b/ui/tests/selenium/data/sources/TopHostsWidget.php index 7c855522401..701ae100438 100644 --- a/ui/tests/selenium/data/sources/TopHostsWidget.php +++ b/ui/tests/selenium/data/sources/TopHostsWidget.php @@ -37,22 +37,22 @@ class TopHostsWidget { // Create items with value type - text, log, character. CDataHelper::call('item.create', [ [ - 'name' => 'trap_text', - 'key_' => 'trap_text', + 'name' => 'top_hosts_trap_text', + 'key_' => 'top_hosts_trap_text', 'hostid' => 10084, 'type' => 2, 'value_type' => 4 ], [ - 'name' => 'trap_log', - 'key_' => 'trap_log', + 'name' => 'top_hosts_trap_log', + 'key_' => 'top_hosts_trap_log', 'hostid' => 10084, 'type' => 2, 'value_type' => 2 ], [ - 'name' => 'trap_char', - 'key_' => 'trap_char', + 'name' => 'top_hosts_trap_char', + 'key_' => 'top_hosts_trap_char', 'hostid' => 10084, 'type' => 2, 'value_type' => 1 @@ -63,9 +63,9 @@ class TopHostsWidget { // Add value to item displayed in Top Hosts widget. CDataHelper::addItemData(99086, 1000); - CDataHelper::addItemData(self::$itemids['trap_text'], 'Text for text item'); - CDataHelper::addItemData(self::$itemids['trap_log'], 'Logs for text item'); - CDataHelper::addItemData(self::$itemids['trap_char'], 'characters_here'); + CDataHelper::addItemData(self::$itemids['top_hosts_trap_text'], 'Text for text item'); + CDataHelper::addItemData(self::$itemids['top_hosts_trap_log'], 'Logs for text item'); + CDataHelper::addItemData(self::$itemids['top_hosts_trap_char'], 'characters_here'); // Create dashboards for Top host widget testing. CDataHelper::call('dashboard.create', [ diff --git a/ui/tests/selenium/testTriggerDependencies.php b/ui/tests/selenium/testTriggerDependencies.php index 7c8e826ff7d..8ca6b5ac012 100644 --- a/ui/tests/selenium/testTriggerDependencies.php +++ b/ui/tests/selenium/testTriggerDependencies.php @@ -50,6 +50,8 @@ class testTriggerDependencies extends CLegacyWebTest { * Function links Zabbix agent template to FreeBSD by Zabbix agent template. */ public static function prepareTemplateData() { + CDataHelper::setSessionId(null); + $template_ids = CDBHelper::getAll('SELECT hostid FROM hosts WHERE host IN ('.zbx_dbstr(self::TEMPLATE_AGENT).','. zbx_dbstr(self::TEMPLATE_FREEBSD).','.zbx_dbstr(self::TEMPLATE_APACHE).') ORDER BY host ASC' ); -- cgit v1.2.3 From 97b9e974fd1187ec8de902ca5b7b1fd824a605c8 Mon Sep 17 00:00:00 2001 From: Larisa Grigorjeva Date: Thu, 30 Jun 2022 15:42:51 +0100 Subject: .......... [DEV-2073] reorganized tests vol. 3 --- ui/tests/selenium/SeleniumTests.php | 12 +- ui/tests/selenium/actions/testFormAction.php | 1729 +++++++++++++++++++++++++ ui/tests/selenium/actions/testPageActions.php | 321 +++++ ui/tests/selenium/testFormAction.php | 1729 ------------------------- ui/tests/selenium/testPageActions.php | 321 ----- 5 files changed, 2058 insertions(+), 2054 deletions(-) create mode 100644 ui/tests/selenium/actions/testFormAction.php create mode 100644 ui/tests/selenium/actions/testPageActions.php delete mode 100644 ui/tests/selenium/testFormAction.php delete mode 100644 ui/tests/selenium/testPageActions.php diff --git a/ui/tests/selenium/SeleniumTests.php b/ui/tests/selenium/SeleniumTests.php index 6d26e5b7748..0728a5fd9ab 100644 --- a/ui/tests/selenium/SeleniumTests.php +++ b/ui/tests/selenium/SeleniumTests.php @@ -21,6 +21,10 @@ require_once dirname(__FILE__).'/testDocumentationLinks.php'; require_once dirname(__FILE__).'/testGeneric.php'; +// Actions. +require_once dirname(__FILE__).'/actions/testFormAction.php'; +require_once dirname(__FILE__).'/actions/testPageActions.php'; + // Api tokens. require_once dirname(__FILE__).'/apiTokens/testPageApiTokensAdministrationGeneral.php'; require_once dirname(__FILE__).'/apiTokens/testPageApiTokensUserSettings.php'; @@ -60,7 +64,6 @@ require_once dirname(__FILE__).'/testGraphAxis.php'; require_once dirname(__FILE__).'/testPageLatestData.php'; require_once dirname(__FILE__).'/testPageWeb.php'; require_once dirname(__FILE__).'/testPageProblems.php'; -require_once dirname(__FILE__).'/testPageActions.php'; require_once dirname(__FILE__).'/testFormAdministrationGeneralAutoregistration.php'; require_once dirname(__FILE__).'/testPageAdministrationGeneralIconMapping.php'; require_once dirname(__FILE__).'/testPageAdministrationGeneralImages.php'; @@ -102,7 +105,6 @@ require_once dirname(__FILE__).'/testPageTriggerDescription.php'; require_once dirname(__FILE__).'/testPageUserGroups.php'; require_once dirname(__FILE__).'/users/testPageUsers.php'; require_once dirname(__FILE__).'/testExpandExpressionMacros.php'; -require_once dirname(__FILE__).'/testFormAction.php'; require_once dirname(__FILE__).'/testFormAdministrationAuthenticationHttp.php'; require_once dirname(__FILE__).'/testFormAdministrationAuthenticationLdap.php'; require_once dirname(__FILE__).'/testFormAdministrationAuthenticationSaml.php'; @@ -228,6 +230,10 @@ class SeleniumTests { $suite->addTestSuite('testDocumentationLinks'); $suite->addTestSuite('testGeneric'); + // Actions. + $suite->addTestSuite('testFormAction'); + $suite->addTestSuite('testPageActions'); + // Api tokens. $suite->addTestSuite('testFormApiTokensAdministrationGeneral'); $suite->addTestSuite('testFormApiTokensUserSettings'); @@ -264,7 +270,6 @@ class SeleniumTests { $suite->addTestSuite('testExecuteNow'); $suite->addTestSuite('testGraphAxis'); - $suite->addTestSuite('testPageActions'); $suite->addTestSuite('testFormAdministrationGeneralAutoregistration'); $suite->addTestSuite('testPageAdministrationGeneralIconMapping'); $suite->addTestSuite('testPageAdministrationGeneralImages'); @@ -316,7 +321,6 @@ class SeleniumTests { $suite->addTestSuite('testPageWeb'); $suite->addTestSuite('testPasswordComplexity'); $suite->addTestSuite('testExpandExpressionMacros'); - $suite->addTestSuite('testFormAction'); $suite->addTestSuite('testFormAdministrationAuthenticationSaml'); $suite->addTestSuite('testFormAdministrationAuthenticationHttp'); $suite->addTestSuite('testFormAdministrationAuthenticationLdap'); diff --git a/ui/tests/selenium/actions/testFormAction.php b/ui/tests/selenium/actions/testFormAction.php new file mode 100644 index 00000000000..cd962117b58 --- /dev/null +++ b/ui/tests/selenium/actions/testFormAction.php @@ -0,0 +1,1729 @@ + 'Trigger actions', + EVENT_SOURCE_SERVICE => 'Service actions', + EVENT_SOURCE_DISCOVERY => 'Discovery actions', + EVENT_SOURCE_AUTOREGISTRATION => 'Autoregistration actions', + EVENT_SOURCE_INTERNAL => 'Internal actions' + ]; + + /** + * Id of the action to be used for Simple update and Clone scenarios. + * + * @var integer + */ + protected static $actionid; + + /** + * Name of the action to be used for Simple update and Clone scenarios. + * + * @var integer + */ + protected static $action_name = 'Service action'; + + /** + * Attach MessageBehavior to the test. + * + * @return array + */ + public function getBehaviors() { + return [ + 'class' => CMessageBehavior::class + ]; + } + + /** + * Function creates Service actions. + */ + public function prepareServiceActionData() { + $response = CDataHelper::call('action.create', [ + [ + 'name' => self::$action_name, + 'eventsource' => 4, + 'status' => '0', + 'esc_period' => '1h', + 'filter' => [ + 'evaltype' => 0, + 'conditions' => [ + [ + 'conditiontype' => 28, + 'operator' => 2, + 'value' => 'Service name' + ], + [ + 'conditiontype' => 25, + 'operator' => 2, + 'value' => 'Service tag name' + ] + ] + ], + 'operations' => [ + [ + 'operationtype' => 0, + 'esc_period' => 0, + 'esc_step_from' => 1, + 'esc_step_to' => 1, + 'opmessage' => [ + 'default_msg' => 1, + 'mediatypeid' => 0 + ], + 'opmessage_usr' => [ + [ + 'userid' => 1 + ] + ] + ] + ], + 'recovery_operations' => [ + [ + 'operationtype' => 11, + 'opmessage' => [ + 'default_msg' => 0, + 'subject' => 'Subject', + 'message' => 'Message' + ] + ] + ], + 'update_operations' => [ + [ + 'operationtype' => 0, + 'opmessage' => [ + 'default_msg' => 1, + 'mediatypeid' => 1 + ], + 'opmessage_grp' => [ + [ + 'usrgrpid' => 7 + ] + ] + ] + ] + ] + ]); + + + $this->assertArrayHasKey('actionids', $response); + self::$actionid = $response['actionids'][0]; + + CDataHelper::call('service.create', [ + [ + 'name' => 'Reference service', + 'algorithm' => 1, + 'sortorder' => 1 + ] + ]); + } + + public static function layout() { + return [ + [ + [ + 'eventsource' => EVENT_SOURCE_TRIGGERS, + 'recovery_msg' => true, + 'acknowledge_msg' => true + ] + ], + [ + [ + 'eventsource' => EVENT_SOURCE_TRIGGERS, + 'new_operation_operationtype' => 'Send message' + ] + ], + [ + [ + 'eventsource' => EVENT_SOURCE_TRIGGERS, + 'new_operation_operationtype' => 'Send message', + 'new_operation_opmessage_custom_msg' => 'unchecked' + ] + ], + [ + [ + 'eventsource' => EVENT_SOURCE_TRIGGERS, + 'new_operation_operationtype' => 'Send message', + 'add_opcondition' => true + ] + ], + [ + [ + 'eventsource' => EVENT_SOURCE_TRIGGERS, + 'check_operationtype' => true, + 'new_operation_operationtype' => 'Reboot', + 'add_opcondition' => true + ] + ], + [ + ['eventsource' => EVENT_SOURCE_TRIGGERS, 'evaltype' => 'And'] + ], + [ + ['eventsource' => EVENT_SOURCE_TRIGGERS, 'evaltype' => 'Or'] + ], + [ + ['eventsource' => EVENT_SOURCE_TRIGGERS, 'new_condition_conditiontype' => 'Tag name'] + ], + [ + ['eventsource' => EVENT_SOURCE_TRIGGERS, 'new_condition_conditiontype' => 'Tag value'] + ], + [ + ['eventsource' => EVENT_SOURCE_TRIGGERS, 'new_condition_conditiontype' => 'Host group'] + ], + [ + ['eventsource' => EVENT_SOURCE_TRIGGERS, 'new_condition_conditiontype' => 'Template'] + ], + [ + ['eventsource' => EVENT_SOURCE_TRIGGERS, 'new_condition_conditiontype' => 'Host'] + ], + [ + ['eventsource' => EVENT_SOURCE_TRIGGERS, 'new_condition_conditiontype' => 'Trigger'] + ], + [ + ['eventsource' => EVENT_SOURCE_TRIGGERS, 'new_condition_conditiontype' => 'Trigger name'] + ], + [ + ['eventsource' => EVENT_SOURCE_TRIGGERS, 'new_condition_conditiontype' => 'Trigger severity'] + ], + [ + ['eventsource' => EVENT_SOURCE_TRIGGERS, 'new_condition_conditiontype' => 'Time period'] + ], + [ + ['eventsource' => EVENT_SOURCE_TRIGGERS, 'new_condition_conditiontype' => 'Problem is suppressed'] + ], + [ + [ + 'eventsource' => EVENT_SOURCE_SERVICE, + 'recovery_msg' => true, + 'acknowledge_msg' => true + ] + ], + [ + [ + 'eventsource' => EVENT_SOURCE_SERVICE, + 'new_operation_operationtype' => 'Send message' + ] + ], + [ + [ + 'eventsource' => EVENT_SOURCE_SERVICE, + 'new_operation_operationtype' => 'Send message', + 'new_operation_opmessage_custom_msg' => 'unchecked' + ] + ], + [ + [ + 'eventsource' => EVENT_SOURCE_SERVICE, + 'check_operationtype' => true, + 'new_operation_operationtype' => 'Reboot' + ] + ], + [ + ['eventsource' => EVENT_SOURCE_SERVICE, 'new_condition_conditiontype' => 'Service'] + ], + [ + ['eventsource' => EVENT_SOURCE_SERVICE, 'new_condition_conditiontype' => 'Service name'] + ], + [ + ['eventsource' => EVENT_SOURCE_SERVICE, 'new_condition_conditiontype' => 'Service tag name'] + ], + [ + ['eventsource' => EVENT_SOURCE_SERVICE, 'new_condition_conditiontype' => 'Service tag value'] + ], + [ + ['eventsource' => EVENT_SOURCE_DISCOVERY] + ], + [ + ['eventsource' => EVENT_SOURCE_DISCOVERY, 'new_condition_conditiontype' => 'Host IP'] + ], + [ + ['eventsource' => EVENT_SOURCE_DISCOVERY, 'new_condition_conditiontype' => 'Service type'] + ], + [ + ['eventsource' => EVENT_SOURCE_DISCOVERY, 'new_condition_conditiontype' => 'Service port'] + ], + [ + ['eventsource' => EVENT_SOURCE_DISCOVERY, 'new_condition_conditiontype' => 'Discovery rule'] + ], + [ + ['eventsource' => EVENT_SOURCE_DISCOVERY, 'new_condition_conditiontype' => 'Discovery check'] + ], + [ + ['eventsource' => EVENT_SOURCE_DISCOVERY, 'new_condition_conditiontype' => 'Discovery object'] + ], + [ + ['eventsource' => EVENT_SOURCE_DISCOVERY, 'new_condition_conditiontype' => 'Discovery status'] + ], + [ + ['eventsource' => EVENT_SOURCE_DISCOVERY, 'new_condition_conditiontype' => 'Uptime/Downtime'] + ], + [ + ['eventsource' => EVENT_SOURCE_DISCOVERY, 'new_condition_conditiontype' => 'Received value'] + ], + [ + ['eventsource' => EVENT_SOURCE_DISCOVERY, 'new_condition_conditiontype' => 'Proxy'] + ], + [ + [ + 'eventsource' => EVENT_SOURCE_DISCOVERY, + 'new_operation_operationtype' => 'Send message' + ] + ], + [ + [ + 'eventsource' => EVENT_SOURCE_DISCOVERY, + 'new_operation_operationtype' => 'Send message', + 'new_operation_opmessage_custom_msg' => 'unchecked' + ] + ], + [ + [ + 'eventsource' => EVENT_SOURCE_DISCOVERY, + 'new_operation_operationtype' => 'Reboot' + ] + ], + [ + ['eventsource' => EVENT_SOURCE_DISCOVERY, 'check_operationtype' => true, 'new_operation_operationtype' => 'Add host'] + ], + [ + ['eventsource' => EVENT_SOURCE_DISCOVERY, 'new_operation_operationtype' => 'Remove host'] + ], + [ + ['eventsource' => EVENT_SOURCE_DISCOVERY, 'new_operation_operationtype' => 'Add to host group'] + ], + [ + ['eventsource' => EVENT_SOURCE_DISCOVERY, 'new_operation_operationtype' => 'Remove from host group'] + ], + [ + ['eventsource' => EVENT_SOURCE_DISCOVERY, 'new_operation_operationtype' => 'Link to template'] + ], + [ + ['eventsource' => EVENT_SOURCE_DISCOVERY, 'new_operation_operationtype' => 'Unlink from template'] + ], + [ + ['eventsource' => EVENT_SOURCE_DISCOVERY, 'new_operation_operationtype' => 'Enable host'] + ], + [ + ['eventsource' => EVENT_SOURCE_DISCOVERY, 'new_operation_operationtype' => 'Disable host'] + ], + [ + ['eventsource' => EVENT_SOURCE_AUTOREGISTRATION] + ], + [ + ['eventsource' => EVENT_SOURCE_AUTOREGISTRATION, 'new_condition_conditiontype' => 'Host name'] + ], + [ + ['eventsource' => EVENT_SOURCE_AUTOREGISTRATION, 'new_condition_conditiontype' => 'Proxy'] + ], + [ + ['eventsource' => EVENT_SOURCE_AUTOREGISTRATION, 'new_condition_conditiontype' => 'Host metadata'] + ], + [ + [ + 'eventsource' => EVENT_SOURCE_AUTOREGISTRATION, + 'new_operation_operationtype' => 'Send message' + ] + ], + [ + [ + 'eventsource' => EVENT_SOURCE_AUTOREGISTRATION, + 'new_operation_operationtype' => 'Send message', + 'new_operation_opmessage_custom_msg' => 'unchecked' + ] + ], + [ + ['eventsource' => EVENT_SOURCE_AUTOREGISTRATION, 'check_operationtype' => true, 'new_operation_operationtype' => 'Add host'] + ], + [ + ['eventsource' => EVENT_SOURCE_AUTOREGISTRATION, 'new_operation_operationtype' => 'Add to host group'] + ], + [ + ['eventsource' => EVENT_SOURCE_AUTOREGISTRATION, 'new_operation_operationtype' => 'Link to template'] + ], + [ + ['eventsource' => EVENT_SOURCE_AUTOREGISTRATION, 'new_operation_operationtype' => 'Disable host'] + ], + [ + ['eventsource' => EVENT_SOURCE_INTERNAL] + ], + [ + ['eventsource' => EVENT_SOURCE_INTERNAL, 'recovery_msg' => true] + ], + [ + ['eventsource' => EVENT_SOURCE_INTERNAL, 'new_condition_conditiontype' => 'Tag name'] + ], + [ + ['eventsource' => EVENT_SOURCE_INTERNAL, 'new_condition_conditiontype' => 'Tag value'] + ], + [ + ['eventsource' => EVENT_SOURCE_INTERNAL, 'new_condition_conditiontype' => 'Event type'] + ], + [ + ['eventsource' => EVENT_SOURCE_INTERNAL, 'new_condition_conditiontype' => 'Host group'] + ], + [ + ['eventsource' => EVENT_SOURCE_INTERNAL, 'new_condition_conditiontype' => 'Template'] + ], + [ + ['eventsource' => EVENT_SOURCE_INTERNAL, 'new_condition_conditiontype' => 'Host'] + ], + [ + ['eventsource' => EVENT_SOURCE_INTERNAL, 'new_operation_operationtype' => 'Send message'] + ], + [ + [ + 'eventsource' => EVENT_SOURCE_INTERNAL, + 'check_operationtype' => true, + 'new_operation_operationtype' => 'Send message', + 'new_operation_opmessage_custom_msg' => 'unchecked' + ] + ] + ]; + } + + /** + * @dataProvider layout + */ + public function testFormAction_CheckLayout($data) { + $eventsource = $data['eventsource']; + + $this->zbxTestLogin('actionconf.php?eventsource='.$eventsource.'&form=Create+action'); + $this->zbxTestCheckTitle('Configuration of actions'); + $this->zbxTestTextPresent(['Action', 'Operations']); + + $this->zbxTestTextPresent('Name'); + $this->zbxTestAssertVisibleId('name'); + $this->zbxTestAssertAttribute('//input[@id="name"]', 'maxlength', 255); + $this->zbxTestAssertAttribute('//input[@id="name"]', 'autofocus'); + + $this->zbxTestTextPresent('Enabled'); + $this->zbxTestAssertElementPresentId('status'); + $this->zbxTestAssertElementPresentXpath('//input[@type="checkbox" and @id="status"]'); + $this->assertTrue($this->zbxTestCheckboxSelected('status')); + + if (array_key_exists('evaltype', $data)) { + // Open Condition overlay dialog and fill first condition. + $this->zbxTestClickXpath('//button[text()="Add" and contains(@onclick, "popup.condition.actions")]'); + $this->zbxTestLaunchOverlayDialog('New condition'); + $this->zbxTestInputTypeByXpath('//textarea[@id="value"]', 'TEST1'); + $this->zbxTestClickXpathWait('//div[@class="overlay-dialogue-footer"]//button[text()="Add"]'); + $this->zbxTestWaitUntilElementVisible(WebDriverBy::id('conditions_0')); + // Open Condition overlay dialog again and fill second condition. + $this->zbxTestClickXpath('//button[text()="Add" and contains(@onclick, "popup.condition.actions")]'); + $this->zbxTestLaunchOverlayDialog('New condition'); + $this->zbxTestInputTypeByXpath('//textarea[@id="value"]', 'TEST2'); + $this->zbxTestClickXpathWait('//div[@class="overlay-dialogue-footer"]//button[text()="Add"]'); + // Wait until overlay is closed and value is added, so that Type of calculation dropdown is clickable. + $this->zbxTestWaitUntilElementVisible(WebDriverBy::id('evaltype')); + $this->zbxTestDropdownSelectWait('evaltype', $data['evaltype']); + $evaltype = $data['evaltype']; + } + + if ($eventsource == EVENT_SOURCE_TRIGGERS && array_key_exists('evaltype', $data)) { + $this->zbxTestTextPresent('Type of calculation'); + $this->zbxTestAssertElementPresentId('evaltype'); + $this->zbxTestDropdownHasOptions('evaltype', [ + 'And/Or', + 'And', + 'Or', + 'Custom expression' + ]); + $this->zbxTestDropdownAssertSelected('evaltype', $evaltype); + switch ($evaltype) { + case 'And/Or': + case 'And': + $this->zbxTestTextPresent('A and B'); + break; + default: + $this->zbxTestTextPresent('A or B'); + break; + } + } + else { + $this->zbxTestTextNotVisible('Type of calculation'); + $this->zbxTestAssertNotVisibleId('evaltype'); + } + + $this->zbxTestTextPresent([ + 'Conditions', + 'Label', 'Name', 'Action' + ]); + + if ($eventsource == EVENT_SOURCE_TRIGGERS && array_key_exists('evaltype', $data)) { + $this->zbxTestAssertElementText('//tr[@id="conditions_0"]/td[2]', 'Trigger name contains TEST1'); + $this->zbxTestAssertElementText('//tr[@id="conditions_1"]/td[2]', 'Trigger name contains TEST2'); + $this->zbxTestAssertElementPresentXpath('//button[@name="remove" and @onclick="removeCondition(0);"]'); + $this->zbxTestAssertElementPresentXpath('//button[@name="remove" and @onclick="removeCondition(1);"]'); + } + else { + $this->zbxTestAssertElementNotPresentXpath('//tr[@id="conditions_0"]'); + $this->zbxTestAssertElementNotPresentXpath('//button[@name="remove" and @onclick="removeCondition(0);"]'); + $this->zbxTestAssertElementNotPresentXpath('//button[@name="remove" and @onclick="removeCondition(1);"]'); + } + + // Open Condition overlay dialog. + $this->zbxTestClickXpath('//button[text()="Add" and contains(@onclick, "popup.condition.actions")]'); + $this->zbxTestLaunchOverlayDialog('New condition'); + COverlayDialogElement::find()->one()->waitUntilReady(); + + if (isset($data['new_condition_conditiontype'])) { + $this->zbxTestDropdownSelectWait('condition_type', $data['new_condition_conditiontype']); + COverlayDialogElement::find()->one()->waitUntilReady(); + } + $this->zbxTestWaitUntilElementVisible(WebDriverBy::id('condition-type')); + $new_condition_conditiontype = $this->zbxTestGetSelectedLabel('condition_type'); + + switch ($eventsource) { + case EVENT_SOURCE_TRIGGERS: + $this->zbxTestDropdownHasOptions('condition_type', [ + 'Tag name', + 'Tag value', + 'Host group', + 'Template', + 'Host', + 'Trigger', + 'Trigger name', + 'Trigger severity', + 'Time period', + 'Problem is suppressed' + ]); + break; + case EVENT_SOURCE_SERVICE: + $this->zbxTestDropdownHasOptions('condition_type', [ + 'Service', + 'Service name', + 'Service tag name', + 'Service tag value' + ]); + break; + case EVENT_SOURCE_DISCOVERY: + $this->zbxTestDropdownHasOptions('condition_type', [ + 'Host IP', + 'Service type', + 'Service port', + 'Discovery rule', + 'Discovery check', + 'Discovery object', + 'Discovery status', + 'Uptime/Downtime', + 'Received value', + 'Proxy' + ]); + break; + case EVENT_SOURCE_AUTOREGISTRATION: + $this->zbxTestDropdownHasOptions('condition_type', [ + 'Host name', + 'Proxy', + 'Host metadata' + ]); + break; + case EVENT_SOURCE_INTERNAL: + $this->zbxTestDropdownHasOptions('condition_type', [ + 'Tag name', + 'Tag value', + 'Event type', + 'Host group', + 'Template', + 'Host' + ]); + break; + } + + if (isset($data['new_condition_conditiontype'])) { + $this->zbxTestDropdownAssertSelected('condition_type', $new_condition_conditiontype); + } + + switch ($new_condition_conditiontype) { + case 'Tag name': + case 'Tag value': + case 'Service tag name': + case 'Service tag value': + $this->zbxTestTextPresent([ + 'equals', + 'does not equal', + 'contains', + 'does not contain' + ]); + break; + case 'Host group': + case 'Template': + case 'Host': + case 'Trigger': + case 'Host IP': + case 'Service type': + case 'Service': + case 'Discovery rule': + case 'Discovery check': + case 'Proxy': + $this->zbxTestTextPresent([ + 'equals', + 'does not equal' + ]); + break; + case 'Trigger name': + case 'Service name': + case 'Host name': + case 'Host metadata': + $this->zbxTestTextPresent([ + 'contains', + 'does not contain' + ]); + break; + case 'Trigger severity': + $this->zbxTestTextPresent([ + 'equals', + 'does not equal', + 'is greater than or equals', + 'is less than or equals' + ]); + break; + case 'Trigger value': + case 'Discovery object': + case 'Discovery status': + case 'Event type': + $this->zbxTestIsElementPresent('//td[@colspan="1" and text()="equals"]'); + break; + case 'Time period': + $this->zbxTestTextPresent([ + 'in', + 'not in' + ]); + break; + case 'Problem is suppressed': + $this->zbxTestTextPresent([ + 'No', + 'Yes' + ]); + break; + case 'Uptime/Downtime': + $this->zbxTestTextPresent([ + 'is greater than or equals', + 'is less than or equals' + ]); + break; + case 'Received value': + $this->zbxTestDropdownHasOptions('operator', [ + 'equals', + 'does not equal', + 'is greater than or equals', + 'is less than or equals', + 'contains', + 'does not contain' + ]); + break; + } + + switch ($new_condition_conditiontype) { + case 'Tag name': + case 'Tag value': + case 'Service tag name': + case 'Service tag value': + case 'Service name': + case 'Trigger name': + case 'Time period': + case 'Host IP': + case 'Uptime/Downtime': + case 'Received value': + case 'Host name': + case 'Host metadata': + case 'Service port': + $this->zbxTestAssertElementPresentXpath('//input[@id="value"] | //textarea[@id="value"]'); + break; + default: + $this->zbxTestAssertElementNotPresentXpath('//input[@id="value"] | //textarea[@id="value"]'); + break; + } + + switch ($new_condition_conditiontype) { + case 'Tag name': + case 'Tag value': + case 'Trigger name': + case 'Service tag name': + case 'Service tag value': + case 'Service name': + case 'Time period': + case 'Host IP': + case 'Received value': + case 'Host name': + case 'Host metadata': + case 'Service port': + $this->zbxTestAssertAttribute('//textarea[@id="value"] | //input[@id="value"]', 'maxlength', 255); + break; + case 'Uptime/Downtime': + $this->zbxTestAssertAttribute('//input[@id="value"]', 'maxlength', 15); + break; + } + + switch ($new_condition_conditiontype) { + case 'Tag name': + case 'Tag value': + case 'Trigger name': + case 'Service tag name': + case 'Service tag value': + case 'Service name': + case 'Received value': + case 'Host name': + case 'Host metadata': + $this->zbxTestAssertElementValue('value', ""); + break; + case 'Time period': + $this->zbxTestAssertElementValue('value', '1-7,00:00-24:00'); + break; + case 'Service port': + $this->zbxTestAssertElementValue('value', '0-1023,1024-49151'); + break; + case 'Host IP': + $this->zbxTestAssertElementValue('value', '192.168.0.1-127,192.168.2.1'); + break; + case 'Uptime/Downtime': + $this->zbxTestAssertElementValue('value', 600); + break; + } + + switch ($new_condition_conditiontype) { + case 'Host group': + case 'Service': + case 'Template': + case 'Host': + case 'Trigger': + case 'Discovery rule': + case 'Proxy': + $this->zbxTestAssertElementPresentXpath('//div[@class="multiselect"]/input[@placeholder]'); + break; + default: + $this->zbxTestAssertElementNotPresentXpath('//div[@id=\'new_condition_value_\']/input[@placeholder]'); + $this->zbxTestAssertElementNotPresentXpath('//div[@id=\'new_condition_value\']/input[@placeholder]'); + break; + } + + switch ($new_condition_conditiontype) { + case 'Trigger severity': + case 'Trigger value': + case 'Discovery object': + case 'Discovery status': + $this->zbxTestAssertElementPresentXpath('//ul[@id="value" and contains(@class, "radio")]'); + break; + case 'Event type': + case 'Service type': + $this->zbxTestAssertElementPresentXpath('//input[@type="radio" and contains(@id, "0") and @checked]'); + $this->zbxTestAssertElementPresentXpath('//z-select[@name="value"]'); + break; + default: + $this->zbxTestAssertElementNotPresentXpath('//ul[@id="value" and contains(@class, "radio")]'); + break; + } + + switch ($new_condition_conditiontype) { + case 'Trigger severity': + $this->zbxTestTextPresent([ + 'Not classified', + 'Information', + 'Warning', + 'Average', + 'High', + 'Disaster' + ]); + break; + case 'Trigger value': + $this->zbxTestDropdownHasOptions('new_condition_value', [ + 'OK', + 'PROBLEM' + ]); + break; + case 'Service type': + $this->zbxTestDropdownHasOptions('value', [ + 'SSH', + 'LDAP', + 'SMTP', + 'FTP', + 'HTTP', + 'HTTPS', + 'POP', + 'NNTP', + 'IMAP', + 'TCP', + 'Zabbix agent', + 'SNMPv1 agent', + 'SNMPv2 agent', + 'SNMPv3 agent', + 'ICMP ping', + 'Telnet' + ]); + break; + case 'Discovery object': + $this->zbxTestTextPresent([ + 'Device', + 'Service' + ]); + break; + case 'Discovery status': + $this->zbxTestTextPresent([ + 'Up', + 'Down', + 'Discovered', + 'Lost' + ]); + break; + case 'Event type': + $this->zbxTestDropdownHasOptions('value', [ + 'Item in "not supported" state', + 'Low-level discovery rule in "not supported" state', + 'Trigger in "unknown" state' + ]); + break; + } + + switch ($new_condition_conditiontype) { + case 'Trigger severity': + $this->zbxTestAssertElementPresentXpath('//label[text()="Not classified"]/../input[@checked]'); + break; + case 'Event type': + $this->zbxTestDropdownAssertSelected('value', 'Item in "not supported" state'); + break; + } + + $this->zbxTestAssertElementNotPresentXpath('//input[@id=\'drule\']'); + + switch ($new_condition_conditiontype) { + case 'Discovery check': + $this->zbxTestAssertElementPresentXpath('//input[@id=\'dcheck\']'); + $this->zbxTestAssertAttribute('//input[@id=\'dcheck\']', 'maxlength', 255); + $this->zbxTestAssertAttribute('//input[@id=\'dcheck\']', 'readonly'); + $this->zbxTestAssertElementPresentXpath('//button[@id=\'btn1\']'); + $this->zbxTestAssertElementText('//button[@id=\'btn1\']', 'Select'); + break; + + default: + $this->zbxTestAssertElementNotPresentXpath('//input[@id=\'dcheck\']'); + $this->zbxTestAssertElementNotPresentXpath('//button[@id=\'btn1\']'); + break; + } + + $this->zbxTestAssertElementPresentXpath("//div[@class='overlay-dialogue-footer']//button[text()='Add']"); + $this->zbxTestClickXpath("//div[@class='overlay-dialogue-footer']//button[text()='Cancel']"); + + $this->zbxTestTabSwitch('Operations'); + + $form = $this->query('id:action-form')->asForm()->waitUntilVisible()->one(); + $operations_field = $form->getField('Operations')->asTable(); + + switch ($eventsource) { + case EVENT_SOURCE_TRIGGERS: + case EVENT_SOURCE_SERVICE: + $this->assertEquals('1h', $form->getField('Default operation step duration')->getValue()); + $this->zbxTestAssertVisibleId('esc_period'); + $this->zbxTestAssertAttribute('//input[@id=\'esc_period\']', 'maxlength', 255); + + $this->assertEquals($operations_field->getHeadersText(), ['Steps', 'Details', 'Start in', 'Duration', 'Action']); + + $checkboxes = [ + 'Pause operations for suppressed problems' => 'id:pause_suppressed', + 'Notify about canceled escalations' => 'id:notify_if_canceled' + ]; + foreach ($checkboxes as $label => $locator) { + if ($eventsource === EVENT_SOURCE_TRIGGERS) { + $this->assertTrue($form->getField($label)->getValue()); + } + else { + $this->assertFalse($form->query($locator)->one(false)->isValid()); + } + } + + $recovery_field = $form->getField('Recovery operations')->asTable(); + $this->assertEquals($recovery_field->getHeadersText(), ['Details', 'Action']); + $update_field = $form->getField('Update operations')->asTable(); + $this->assertEquals($update_field->getHeadersText(), ['Details', 'Action']); + break; + + case EVENT_SOURCE_DISCOVERY: + case EVENT_SOURCE_AUTOREGISTRATION: + $this->zbxTestTextNotPresent(['Default operation step duration', 'Pause operations for suppressed problems', + 'Notify about canceled escalations', 'Recovery operations', 'Update operations']); + $this->zbxTestAssertElementNotPresentId('esc_period'); + $this->zbxTestAssertElementNotPresentId('pause_suppressed'); + break; + + case EVENT_SOURCE_INTERNAL: + $this->assertEquals('1h', $form->getField('Default operation step duration')->getValue()); + $this->zbxTestAssertVisibleId('esc_period'); + $this->zbxTestAssertAttribute('//input[@id=\'esc_period\']', 'maxlength', 255); + + $this->assertEquals($operations_field->getHeadersText(), ['Steps', 'Details', 'Start in', 'Duration', 'Action']); + $recovery_field = $form->getField('Recovery operations')->asTable(); + $this->assertEquals($recovery_field->getHeadersText(), ['Details', 'Action']); + $this->zbxTestTextNotPresent(['Pause operations for suppressed problems', 'Notify about canceled escalations', + 'Update operations'] + ); + $this->zbxTestAssertElementNotPresentId('pause_suppressed'); + break; + } + + if (isset($data['new_operation_operationtype'])) { + $new_operation_operationtype = $data['new_operation_operationtype']; + $operations_field->query('button:Add')->one()->click(); + COverlayDialogElement::find()->one()->waitUntilReady(); + + if ($eventsource === EVENT_SOURCE_INTERNAL) { + $this->zbxTestTextPresent('Send message'); + } + else { + $this->zbxTestWaitUntilElementPresent(webDriverBy::id('operationtype')); + $this->zbxTestDropdownSelectWait('operation-type-select', $new_operation_operationtype); + COverlayDialogElement::find()->one()->waitUntilReady(); + } + } + else { + $new_operation_operationtype = null; + } + + if (isset($data['new_operation_opmessage_custom_msg'])) { + $new_operation_opmessage_custom_msg = $data['new_operation_opmessage_custom_msg']; + $this->assertFalse($this->zbxTestCheckboxSelected('operation_opmessage_default_msg')); + } + elseif ($new_operation_operationtype == 'Send message') { + $new_operation_opmessage_custom_msg = 'checked'; + $this->zbxTestCheckboxSelect('operation_opmessage_default_msg'); + } + else { + $new_operation_opmessage_custom_msg = null; + } + + if (isset($data['add_opcondition'])) { + $this->query('xpath://tr[@id="operation-condition-list-footer"]//button[text()="Add"]')->one()->click(true); + $this->page->query('xpath://div[contains(@class, "overlay-dialogue modal")][2]') + ->asOverlayDialog()->waitUntilReady(); + $add_opcondition = $data['add_opcondition']; + } + else { + $add_opcondition = null; + } + + if ($eventsource === EVENT_SOURCE_SERVICE) { + $this->assertFalse($this->query('id:operation-condition-list')->one(false)->isValid()); + } + + if ($new_operation_operationtype != null + && in_array($eventsource, [EVENT_SOURCE_TRIGGERS, EVENT_SOURCE_SERVICE, EVENT_SOURCE_INTERNAL])) { + switch ($new_operation_operationtype) { + case 'Send message': + case 'Reboot': + $this->zbxTestTextPresent('Steps'); + $this->zbxTestAssertVisibleId('operation_esc_step_from'); + $this->zbxTestAssertAttribute('//input[@id=\'operation_esc_step_from\']', 'maxlength', 5); + $this->zbxTestAssertAttribute('//input[@id=\'operation_esc_step_from\']', 'value', 1); + + $this->zbxTestTextPresent('(0 - infinitely)'); + $this->zbxTestAssertVisibleId('operation_esc_step_to'); + $this->zbxTestAssertAttribute('//input[@id=\'operation_esc_step_to\']', 'maxlength', 5); + $this->zbxTestAssertAttribute('//input[@id=\'operation_esc_step_to\']', 'value', 1); + + $this->zbxTestTextPresent(['Step duration', '(0 - use action default)']); + $this->zbxTestAssertVisibleId('operation_esc_period'); + $this->zbxTestAssertAttribute('//input[@id=\'operation_esc_period\']', 'maxlength', 255); + $this->zbxTestAssertAttribute('//input[@id=\'operation_esc_period\']', 'value', 0); + break; + } + } + else { + $this->zbxTestAssertElementNotPresentId('operation_esc_step_from'); + $this->zbxTestAssertElementNotPresentId('operation_esc_step_to'); + $this->zbxTestAssertElementNotPresentId('operation_esc_period'); + } + + if (isset($data['new_operation_operationtype']) && $eventsource != EVENT_SOURCE_INTERNAL) { + $this->zbxTestTextPresent('Operations'); + $this->zbxTestAssertVisibleXpath('//z-select[@id=\'operation-type-select\']'); + } + else { + $this->zbxTestAssertElementNotPresentXpath('//z-select[@id=\'operation-type-select\']'); + } + + if (isset($data['check_operationtype']) && $eventsource === EVENT_SOURCE_INTERNAL) { + $this->assertFalse($this->query('id:operation-type-select')->one(false)->isValid()); + $this->assertTrue($this->query('xpath://label[text()="Operation"]/../../div[text()="Send message"]')->one()->isValid()); + } + elseif (isset($data['check_operationtype'])) { + $options = $this->query('id:operation-type-select')->asDropdown()->one(); + switch ($eventsource) { + case EVENT_SOURCE_TRIGGERS: + case EVENT_SOURCE_SERVICE: + $this->assertEquals($options->getOptions()->asText(), ['Send message', 'Reboot', 'Selenium script']); + break; + + case EVENT_SOURCE_DISCOVERY: + case EVENT_SOURCE_AUTOREGISTRATION: + $this->assertEquals($options->getOptions()->asText(), [ + 'Send message', + 'Add host', + 'Remove host', + 'Add to host group', + 'Remove from host group', + 'Link to template', + 'Unlink from template', + 'Enable host', + 'Disable host', + 'Set host inventory mode', + 'Reboot', + 'Selenium script' + ]); + break; + } + $this->assertEquals($new_operation_operationtype, $options->getValue()); + } + + if ($new_operation_operationtype === 'Reboot' && $eventsource !== EVENT_SOURCE_SERVICE) { + $this->zbxTestTextPresent(['Target list', 'Current host', 'Host', 'Host group']); + $this->query('id:operation-command-chst')->one()->isSelected(false); + $this->zbxTestAssertVisibleId('operation_opcommand_hst__hostid'); + $this->zbxTestAssertVisibleId('operation_opcommand_grp__groupid'); + } + else { + $this->zbxTestAssertElementNotPresentId('opCmdList'); + $this->zbxTestAssertElementNotPresentXpath('//li[@id="operation-command-targets"]//label[text()="Target list"]'); + $this->zbxTestAssertElementNotPresentXpath('//li[@id="operation-command-script-target"]//label[text()="Execute on"]'); + } + + if ($new_operation_operationtype == 'Send message') { + $this->zbxTestTextPresent([ + 'Send to user groups', 'User group', 'Action', + 'Send to users' + ]); + $this->zbxTestAssertVisibleXpath('//tr[@id=\'operation-message-user-groups-footer\']//button[@class=\'btn-link\']'); + $this->zbxTestAssertElementText('//tr[@id=\'operation-message-user-groups-footer\']//button[@class=\'btn-link\']', 'Add'); + $this->zbxTestAssertVisibleXpath('//tr[@id=\'operation-message-users-footer\']//button[@class=\'btn-link\']'); + $this->zbxTestAssertElementText('//tr[@id=\'operation-message-users-footer\']//button[@class=\'btn-link\']', 'Add'); + + $this->zbxTestTextPresent('Send only to'); + $this->zbxTestAssertVisibleId('operation-opmessage-mediatypeid'); + $this->zbxTestDropdownAssertSelected('operation[opmessage][mediatypeid]', '- All -'); + $this->zbxTestDropdownHasOptions('operation[opmessage][mediatypeid]', [ + '- All -', + 'Email', + 'SMS' + ]); + + $this->zbxTestTextPresent('Custom message'); + $this->zbxTestAssertElementPresentId('operation_opmessage_default_msg'); + $this->zbxTestAssertElementPresentXpath('//input[@type=\'checkbox\' and @id=\'operation_opmessage_default_msg\']'); + if ($new_operation_opmessage_custom_msg == 'checked') { + $this->assertTrue($this->zbxTestCheckboxSelected('operation_opmessage_default_msg')); + } + else { + $this->assertFalse($this->zbxTestCheckboxSelected('operation_opmessage_default_msg')); + } + } + else { + $this->zbxTestAssertElementNotPresentId('addusrgrpbtn'); + $this->zbxTestAssertElementNotPresentId('adduserbtn'); + $this->zbxTestAssertElementNotPresentXpath('//z-select[@name=\'operation[opmessage][mediatypeid]\']'); + $this->zbxTestAssertElementNotPresentId('operation_opmessage_default_msg'); + } + + switch ($new_operation_opmessage_custom_msg) { + case 'unchecked': + $this->zbxTestAssertNotVisibleId('operation_opmessage_subject'); + $this->zbxTestAssertNotVisibleId('operation_opmessage_message'); + break; + case 'checked': + $this->zbxTestTextPresent('Subject'); + $this->zbxTestAssertVisibleId('operation_opmessage_subject'); + $this->zbxTestAssertAttribute('//input[@id=\'operation_opmessage_subject\']', 'maxlength', 255); + + $this->zbxTestTextPresent('Message'); + $this->zbxTestAssertVisibleId('operation_opmessage_message'); + $this->zbxTestAssertAttribute('//textarea[@id=\'operation_opmessage_message\']', 'rows', 7); + break; + default: + $this->zbxTestAssertElementNotPresentId('operation_opmessage_subject'); + $this->zbxTestAssertElementNotPresentId('operation_opmessage_message'); + break; + } + + if ($eventsource == EVENT_SOURCE_TRIGGERS && $new_operation_operationtype != null) { + $this->zbxTestTextPresent(['Conditions', 'Label', 'Name', 'Action']); + + if ($add_opcondition == null) { + $this->zbxTestAssertVisibleXpath('//div[@id="operationTab"]//button[text()="Add"]'); + } + else { + $this->zbxTestTextPresent('New condition'); + $this->query('xpath://div[contains(@class, "overlay-dialogue modal")][2]'. + '//button[text()="Cancel"]')->one()->waitUntilVisible(); + + $this->zbxTestAssertVisibleXpath('//z-select[@id="condition-type"]'); + $this->zbxTestDropdownAssertSelected('condition_type', 'Event acknowledged'); + $this->zbxTestDropdownHasOptions('condition_type', ['Event acknowledged']); + + $this->zbxTestAssertVisibleXpath('//div[contains(@class, "overlay-dialogue modal")]'. + '//label[text()="equals"]'); + $this->zbxTestAssertVisibleXpath('//div[contains(@class, "overlay-dialogue modal")]'. + '//ul[@id="value" and @class="radio-list-control"]'); + $this->zbxTestAssertElementPresentXpath('//label[text()="No"]/../input[@checked]'); + $this->zbxTestClickXpathWait('//div[contains(@class, "overlay-dialogue modal")][2]'. + '//button[text()="Add"]'); + $this->zbxTestWaitUntilElementNotVisible(WebDriverBy::xpath('//div[contains(@class, "overlay-dialogue '. + 'modal")][2]')); + } + } + else { + $this->zbxTestAssertElementNotPresentXpath('//li[@id="operation-condition-list"]'); + $this->zbxTestAssertElementNotPresentXpath('//tr[@id="operation-condition-list-footer"]'); + } + + switch ($new_operation_operationtype) { + case 'Add to host group': + case 'Remove from host group': + $this->zbxTestAssertElementPresentXpath('//div[@id=\'operation_opgroup__groupid\']/input'); + $this->zbxTestAssertElementNotPresentXpath('//div[@id=\'operation_optemplate__templateid\']/input'); + break; + case 'Link to template': + case 'Unlink from template': + $this->zbxTestAssertElementPresentXpath('//div[@id=\'operation_optemplate__templateid\']/input'); + $this->zbxTestAssertElementNotPresentXpath('//div[@id=\'operation_opgroup__groupid\']/input'); + break; + default: + $this->zbxTestAssertElementNotPresentXpath('//div[@id=\'operation_groupids_\']/input'); + $this->zbxTestAssertElementNotPresentXpath('//div[@id=\'operation_templateids_\']/input'); + break; + } + + if ($new_operation_operationtype != null) { + $this->zbxTestAssertVisibleXpath('//div[@class="overlay-dialogue-footer"]//button[text()="Add"]'); + $this->zbxTestAssertVisibleXpath('//div[@class="overlay-dialogue-footer"]//button[text()="Cancel"]'); + } + else { + $this->zbxTestAssertElementNotPresentXpath('//div[@id="operationTab"]//button[contains(@onclick,"add_operation")]'); + $this->zbxTestAssertElementNotPresentXpath('//div[@id="operationTab"]//button[contains(@onclick,"cancel_new_operation")]'); + } + + if (CTestArrayHelper::get($data, 'recovery_msg', false)) { + $this->checkRecoveryUpdateOperations($recovery_field, $eventsource); + } + + if (CTestArrayHelper::get($data, 'acknowledge_msg', false)) { + $this->checkRecoveryUpdateOperations($update_field, $eventsource); + } + + $this->zbxTestAssertVisibleId('add'); + $this->zbxTestAssertAttribute('//button[@id="add" and @type="submit"]', 'value', 'Add'); + + $this->zbxTestAssertVisibleId('cancel'); + $this->zbxTestAssertAttribute('//button[@id=\'cancel\']', 'name', 'cancel'); + } + + /* + * Function that checks possible operation types and custom message related fields for recovery and update operations. + */ + private function checkRecoveryUpdateOperations($operation_field, $eventsource) { + $operation_field->query('button:Add')->one()->click(); + COverlayDialogElement::find()->one()->waitUntilReady(); + $operation_details = $this->query('name:popup.operation')->asForm()->one(); + // Check available operation types depending on event source and the selected operation type. + $message_types = ($eventsource === EVENT_SOURCE_INTERNAL) + ? ['Send message', 'Notify all involved'] + : ['Send message', 'Notify all involved', 'Reboot', 'Selenium script']; + $this->assertEquals($message_types, $operation_details->query('id:operation-type-select') + ->asDropdown()->one()->getOptions()->asText()); + $this->assertEquals('Send message', $operation_details->getField('Operation')->getValue()); + // Make sure that Custom message is unchecked and that message related fields are not visible. + $this->assertFalse($operation_details->getField('Custom message')->getValue()); + $this->zbxTestTextNotVisible(['Subject','Message']); + // Set the Custom message option and check Subject and Message fields. + $operation_details->getField('Custom message')->set(true); + $this->assertEquals(255, $operation_details->getField('Subject')->waitUntilVisible()->getAttribute('maxlength')); + $this->assertFalse($operation_details->getField('Message')->isAttributePresent('maxlength')); + COverlayDialogElement::find()->one()->close(); + } + + public static function update() { + return CDBHelper::getDataProvider('SELECT name, eventsource FROM actions'); + } + + public static function updateServiceAction() { + return [ + [ + [ + 'name' => self::$action_name, + 'eventsource' => '4' + ] + ] + ]; + } + + /** + * @dataProvider update + * @dataProvider updateServiceAction + */ + public function testFormAction_SimpleUpdate($data) { + $name = $data['name']; + $eventsource = $data['eventsource']; + + if ($name == 'Auto discovery. Linux servers.') { + $sqlActions = 'SELECT actionid, name, eventsource, evaltype, status FROM actions ORDER BY actionid'; + } + else { + $sqlActions = 'SELECT * FROM actions ORDER BY actionid'; + } + $oldHashActions = CDBHelper::getHash($sqlActions); + + $this->page->login()->open('actionconf.php?eventsource='.$eventsource); + $this->zbxTestClickLinkTextWait($name); + $this->zbxTestClickWait('update'); + $this->zbxTestCheckTitle('Configuration of actions'); + + $this->zbxTestCheckHeader($this->event_sources[$data['eventsource']]); + $this->zbxTestWaitUntilMessageTextPresent('msg-good', 'Action updated'); + $this->zbxTestTextPresent([ + 'Action updated', + 'Actions', + $name + ]); + + $this->assertEquals($oldHashActions, CDBHelper::getHash($sqlActions)); + } + + public static function create() { + return [ + [ + [ + 'expected' => ACTION_GOOD, + 'eventsource' => EVENT_SOURCE_TRIGGERS, + 'name' => 'TestFormAction Triggers 001', + 'esc_period' => '123', + 'conditions' => [ + [ + 'Type' => CFormElement::RELOADABLE_FILL('Trigger name'), + 'Value' => 'trigger' + ], + [ + 'Type' => CFormElement::RELOADABLE_FILL('Trigger severity'), + 'Severity' => 'Warning' + ], + [ + 'Type' => CFormElement::RELOADABLE_FILL('Tag name'), + 'Operator' => 'does not contain', + 'Tag' => 'Does not contain Tag' + ] + ], + 'expected conditions' => [ + 'A' => 'Tag name does not contain Does not contain Tag', + 'B' => 'Trigger severity equals Warning', + 'C' => 'Trigger name contains trigger' + ], + 'operations' => [ + [ + 'type' => 'Send message', + 'media' => 'Email' + ], + [ + 'type' => 'Reboot' + ] + ] + ] + ], + [ + [ + 'expected' => ACTION_BAD, + 'eventsource' => EVENT_SOURCE_TRIGGERS, + 'name' => '', + 'esc_period' => '123', + 'errors' => [ + 'Incorrect value for field "Name": cannot be empty.' + ] + ] + ], + [ + [ + 'expected' => ACTION_GOOD, + 'eventsource' => EVENT_SOURCE_DISCOVERY, + 'name' => 'TestFormAction Discovery 001', + 'conditions' => [ + [ + 'Type' => CFormElement::RELOADABLE_FILL('Service type'), + 'Service type' => 'FTP' + ], + [ + 'Type' => CFormElement::RELOADABLE_FILL('Received value'), + 'Operator' => 'does not contain', + 'Value' => 'Received value' + ] + ], + 'expected conditions' => [ + 'A' => 'Received value does not contain Received value', + 'B' => 'Service type equals FTP' + ], + 'operations' => [ + [ + 'type' => 'Send message', + 'media' => 'Email' + ], + [ + 'type' => 'Reboot' + ] + ] + ] + ], + [ + [ + 'expected' => ACTION_BAD, + 'eventsource' => EVENT_SOURCE_DISCOVERY, + 'name' => '', + 'errors' => [ + 'Incorrect value for field "Name": cannot be empty.' + ] + ] + ], + [ + [ + 'expected' => ACTION_GOOD, + 'eventsource' => EVENT_SOURCE_AUTOREGISTRATION, + 'name' => 'TestFormAction Autoregistration 001', + 'conditions' => [ + [ + 'Type' => CFormElement::RELOADABLE_FILL('Host name'), + 'Value' => 'Zabbix' + ], + [ + 'Type' => CFormElement::RELOADABLE_FILL('Host metadata'), + 'Operator'=> 'does not contain', + 'Value' => 'Zabbix' + ] + ], + 'expected conditions' => [ + 'A' => 'Host metadata does not contain Zabbix', + 'B' => 'Host name contains Zabbix' + ], + 'operations' => [ + [ + 'type' => 'Send message', + 'media' => 'Email' + ], + [ + 'type' => 'Reboot' + ] + ] + ] + ], + [ + [ + 'expected' => ACTION_BAD, + 'eventsource' => EVENT_SOURCE_AUTOREGISTRATION, + 'name' => '', + 'errors' => [ + 'Incorrect value for field "Name": cannot be empty.' + ] + ] + ], + [ + [ + 'expected' => ACTION_GOOD, + 'eventsource' => EVENT_SOURCE_INTERNAL, + 'name' => 'TestFormAction Internal 001', + 'esc_period' => '123', + 'conditions' => [ + [ + 'Type' => CFormElement::RELOADABLE_FILL('Event type'), + 'Event type' => 'Trigger in "unknown" state' + ], + [ + 'Type' => CFormElement::RELOADABLE_FILL('Tag name'), + 'Operator' => 'does not contain', + 'Tag' => 'Does not contain Tag' + ] + ], + 'expected conditions' => [ + 'A' => 'Tag name does not contain Does not contain Tag', + 'B' => 'Event type equals Trigger in "unknown" state' + ], + 'operations' => [ + [ + 'type' => 'Send message', + 'media' => 'Email' + ] + ], + 'expected operations' => [ + 'Send message to users: Admin (Zabbix Administrator) via Email' + ] + ] + ], + [ + [ + 'expected' => ACTION_BAD, + 'eventsource' => EVENT_SOURCE_INTERNAL, + 'name' => '', + 'esc_period' => '123', + 'errors' => [ + 'Incorrect value for field "Name": cannot be empty.' + ] + ] + ], + [ + [ + 'expected' => ACTION_GOOD, + 'eventsource' => EVENT_SOURCE_SERVICE, + 'name' => 'Test Service for Create operation', + 'esc_period' => '666', + 'conditions' => [ + [ + 'Type' => CFormElement::RELOADABLE_FILL('Service'), + 'Operator' => 'does not equal', + 'Services' => 'Reference service' + ], + [ + 'Type' => CFormElement::RELOADABLE_FILL('Service name'), + 'Value' => 'Part of service name' + ], + [ + 'Type' => CFormElement::RELOADABLE_FILL('Service tag name'), + 'Operator' => 'contains', + 'Tag' => 'Service tag name' + ], + [ + 'Type' => CFormElement::RELOADABLE_FILL('Service tag value'), + 'Tag' => 'Service tag', + 'Operator' => 'does not contain', + 'Value' => 'Service tag value' + ] + ], + 'expected conditions' => [ + 'A' => 'Service name contains Part of service name', + 'B' => 'Service does not equal Reference service', + 'C' => 'Value of tag Service tag does not contain Service tag value', + 'D' => 'Tag name contains Service tag name' + ], + 'operations' => [ + [ + 'type' => 'Send message', + 'user_group' => 'Selenium user group' + ], + [ + 'type' => 'Reboot' + ] + ], + 'expected operations' => [ + 'Send message to user groups: Selenium user group via all media', + 'Run script "Reboot" on Zabbix server' + ] + ] + ], + [ + [ + 'expected' => ACTION_BAD, + 'eventsource' => EVENT_SOURCE_SERVICE, + 'name' => '', + 'esc_period' => '666', + 'errors' => [ + 'Incorrect value for field "Name": cannot be empty.' + ] + ] + ], + [ + [ + 'expected' => ACTION_BAD, + 'eventsource' => EVENT_SOURCE_SERVICE, + 'name' => 'No operations action', + 'esc_period' => '666', + 'error_title' => 'Cannot add action', + 'errors' => [ + 'No operations defined for action "No operations action".' + ] + ] + ] + ]; + } + + /** + * @dataProvider create + */ + public function testFormAction_SimpleCreate($data) { + $this->zbxTestLogin('actionconf.php?form=1&eventsource='.$data['eventsource']); + $this->zbxTestCheckTitle('Configuration of actions'); + $this->zbxTestCheckHeader('Actions'); + + $action_form = $this->query('id:action-form')->asForm()->one(); + $action_form->getField('Name')->fill($data['name']); + + if (array_key_exists('conditions', $data)) { + foreach ($data['conditions'] as $condition) { + $action_form->query('xpath:.//table[@id="conditionTable"]//button[text()="Add"]')->one()->click(); + + COverlayDialogElement::find()->waitUntilReady()->one(); + $condition_form = $this->query('id:popup.condition')->asForm()->one(); + $condition_form->fill($condition); + $condition_form->submit(); + COverlayDialogElement::ensureNotPresent(); + } + } + + if (isset($data['operations'])) { + $action_form->selectTab('Operations'); + + foreach ($data['operations'] as $operation) { + $action_form->query('xpath:.//table[@id="op-table"]//button[text()="Add"]')->one()->click(); + + COverlayDialogElement::find()->waitUntilReady()->one(); + $operation_form = $this->query('id:popup.operation')->asForm()->one(); + + if ($data['eventsource'] !== EVENT_SOURCE_INTERNAL) { + $operation_form->getField('Operation')->fill($operation['type']); + } + + if ($operation['type'] === 'Send message') { + if (array_key_exists('user_group', $operation)) { + $field = 'Send to user groups'; + $value = $operation['user_group']; + } + else { + $field = 'Send to users'; + $value = 'Admin'; + } + $operation_form->getField($field)->query('button:Add')->one()->click(); + $list = COverlayDialogElement::find()->all()->last(); + $list->query('link', $value)->waitUntilClickable()->one()->click(); + } + elseif ($data['eventsource'] !== EVENT_SOURCE_SERVICE) { + $operation_form->query('id:operation-command-chst')->asCheckbox()->waitUntilVisible()->one()->check(); + } + + if (array_key_exists('media', $operation)) { + $operation_form->getField('Send only to')->fill($operation['media']); + } + + $operation_form->submit(); + COverlayDialogElement::ensureNotPresent(); + } + + if (array_key_exists('esc_period', $data)) { + $action_form->getField('Default operation step duration')->fill($data['esc_period']); + } + } + + $action_form->submit(); + $sql = 'SELECT actionid FROM actions WHERE name='.zbx_dbstr($data['name']); + + if ($data['expected'] === ACTION_GOOD) { + $this->page->waitUntilReady(); + $this->assertMessage(TEST_GOOD, 'Action added'); + $this->assertEquals(1, CDBHelper::getCount($sql), 'Action has not been created in the DB.'); + + $this->query('link', $data['name'])->waitUntilClickable()->one()->click(); + $this->page->waitUntilReady(); + + if (array_key_exists('conditions', $data)) { + $condition_table = $this->query('id:conditionTable')->waitUntilVisible()->asTable()->one(); + + foreach($data['expected conditions'] as $label => $result) { + $this->assertEquals($result, $condition_table->findRow('Label', $label)->getColumn('Name')->getText()); + } + } + + if (array_key_exists('operations', $data)) { + $expected_operations = [ + 'Send message to users: Admin (Zabbix Administrator) via Email', + 'Run script "Reboot" on current host' + ]; + if (array_key_exists('expected operations', $data)) { + $expected_operations = $data['expected operations']; + } + $action_form->invalidate(); + $action_form->selectTab('Operations'); + $operations_table = $this->query('id:op-table')->waitUntilVisible()->asTable()->one(); + + $saved_operations = []; + $row_count = count($expected_operations); + for ($i = 0; $i < $row_count; $i++) { + $saved_operations[] = $operations_table->getRow($i)->getColumn('Details')->getText(); + } + $this->assertEquals($expected_operations, $saved_operations); + } + } + else { + $title = CTestArrayHelper::get($data, 'error_title', 'Page received incorrect data'); + $this->assertMessage(TEST_BAD, $title, $data['errors']); + $this->assertEquals(0, CDBHelper::getCount($sql), 'Action has not been created in the DB.'); + } + } + + public function testFormAction_Create() { + $this->zbxTestLogin('actionconf.php?form=1&eventsource=0'); + $this->zbxTestCheckTitle('Configuration of actions'); + + $this->zbxTestInputTypeWait('name', 'action test'); + + // adding conditions + $this->zbxTestClickXpathWait('//button[text()="Add" and contains(@onclick, "popup.condition.actions")]'); + $this->zbxTestLaunchOverlayDialog('New condition'); + $this->zbxTestDropdownSelectWait('condition_type', 'Trigger name'); + $this->zbxTestInputTypeWait('value', 'trigger'); + $this->zbxTestClickXpath("//div[@class='overlay-dialogue-footer']//button[text()='Add']"); + $this->zbxTestAssertElementText("//tr[@id='conditions_0']/td[2]", 'Trigger name contains trigger'); + + $this->zbxTestClickXpathWait('//button[text()="Add" and contains(@onclick, "popup.condition.actions")]'); + $this->zbxTestLaunchOverlayDialog('New condition'); + $this->zbxTestDropdownSelectWait('condition_type', 'Trigger severity'); + $this->zbxTestClickXpathWait('//label[text()="Average"]'); + $this->zbxTestClickXpath("//div[@class='overlay-dialogue-footer']//button[text()='Add']"); + $this->zbxTestAssertElementText("//tr[@id='conditions_1']/td[2]", 'Trigger severity equals Average'); + + $this->zbxTestClickXpathWait('//button[text()="Add" and contains(@onclick, "popup.condition.actions")]'); + $this->zbxTestLaunchOverlayDialog('New condition'); + $this->zbxTestWaitUntilElementVisible(WebDriverBy::id('condition-type')); + $this->zbxTestDropdownSelectWait('condition_type', 'Tag name'); + $this->zbxTestInputTypeWait('value', 'zabbix'); + $this->zbxTestClickXpath("//div[@class='overlay-dialogue-footer']//button[text()='Add']"); + $this->zbxTestAssertElementText("//tr[@id='conditions_2']/td[2]", 'Tag name equals zabbix'); + + // adding operations + $this->zbxTestTabSwitch('Operations'); + $this->zbxTestClickXpathWait('//div[@id="operationTab"]//button[text()="Add"]'); + + $this->zbxTestClickXpathWait('//tr[@id="operation-message-user-groups-footer"]//button'); + $this->zbxTestLaunchOverlayDialog('User groups'); + $this->zbxTestCheckboxSelect('item_7'); + $this->zbxTestCheckboxSelect('item_11'); + $this->zbxTestClickXpath('//div[@class="overlay-dialogue-footer"]//button[text()="Select"]'); + + $this->zbxTestClickXpath('//tr[@id="operation-message-users-footer"]//button'); + $this->zbxTestLaunchOverlayDialog('Users'); + $this->zbxTestCheckboxSelect('item_1'); + $this->zbxTestClickXpath('//div[@class="overlay-dialogue-footer"]//button[text()="Select"]'); + + $this->zbxTestDropdownSelect('operation[opmessage][mediatypeid]', 'SMS'); + $this->zbxTestClickXpathWait('//div[@class="overlay-dialogue-footer"]//button[text()="Add"]'); + $this->zbxTestAssertElementText("//tr[@id='operations_0']//span", + "Send message to users: Admin (Zabbix Administrator) via SMS ". + "Send message to user groups: Enabled debug mode, Zabbix administrators via SMS"); + + $this->zbxTestClickXpathWait('//div[@id="operationTab"]//button[text()="Add"]'); + $this->zbxTestWaitUntilElementVisible(WebDriverBy::xpath('//div[@class="overlay-dialogue-footer"]//button[text()="Add"]')); + $this->zbxTestDropdownSelectWait('operation-type-select', 'Reboot'); + + // add target current host + $this->zbxTestCheckboxSelect('operation-command-chst'); + + // add target host Zabbix server + $this->zbxTestClickButtonMultiselect('operation_opcommand_hst__hostid'); + $this->zbxTestLaunchOverlayDialog('Hosts'); + $this->zbxTestClickButtonMultiselect('popup_host_group'); + $this->zbxTestLaunchOverlayDialog('Host groups'); + $this->query('link:Zabbix servers')->one()->waitUntilClickable()->click(); + + $this->zbxTestClickLinkTextWait('Simple form test host'); + // add target group Zabbix servers + $this->zbxTestClickButtonMultiselect('operation_opcommand_grp__groupid'); + $this->zbxTestLaunchOverlayDialog('Host groups'); + $this->zbxTestClickLinkTextWait('Zabbix servers'); + + $this->zbxTestClickXpathWait('//div[@class="overlay-dialogue-footer"]//button[text()="Add"]'); + COverlayDialogElement::ensureNotPresent(); + $this->page->waitUntilReady(); + $this->zbxTestWaitUntilElementClickable(WebDriverBy::id('add')); + $this->zbxTestAssertElementText("//tr[@id='operations_0']//span", + "Send message to users: Admin (Zabbix Administrator) via SMS ". + "Send message to user groups: Enabled debug mode, Zabbix administrators via SMS"); + $this->zbxTestAssertElementText("//tr[@id='operations_1']//span", + "Run script \"Reboot\" on current host ". + "Run script \"Reboot\" on hosts: Simple form test host ". + "Run script \"Reboot\" on host groups: Zabbix servers"); + + $this->zbxTestClickXpathWait('//div[@id="operationTab"]//button[text()="Add"]'); + $this->zbxTestWaitUntilElementVisible(WebDriverBy::xpath('//div[@class="overlay-dialogue-footer"]//button[text()="Add"]')); + $this->zbxTestInputTypeOverwrite('operation_esc_step_to', '2'); + $this->zbxTestDropdownSelectWait('operation-type-select', 'Reboot'); + $this->zbxTestCheckboxSelect('operation-command-chst'); + + $this->zbxTestClickXpathWait('//div[@class="overlay-dialogue-footer"]//button[text()="Add"]'); + $this->page->waitUntilReady(); + $this->zbxTestAssertElementText("//tr[@id='operations_0']//span", + "Send message to users: Admin (Zabbix Administrator) via SMS ". + "Send message to user groups: Enabled debug mode, Zabbix administrators via SMS"); + $this->zbxTestAssertElementText("//tr[@id='operations_1']//span", + "Run script \"Reboot\" on current host ". + "Run script \"Reboot\" on hosts: Simple form test host ". + "Run script \"Reboot\" on host groups: Zabbix servers"); + $this->zbxTestAssertElementText("//tr[@id='operations_2']//span", + "Run script \"Reboot\" on current host"); + $this->zbxTestAssertElementText('//tr[@id="operations_2"]//td', '1 - 2'); + + $this->zbxTestInputTypeOverwrite('esc_period', '123'); + // Fire onchange event. + $this->webDriver->executeScript('var event = document.createEvent("HTMLEvents");'. + 'event.initEvent("change", false, true);'. + 'document.getElementById("esc_period").dispatchEvent(event);' + ); + $this->zbxTestWaitForPageToLoad(); + + $this->zbxTestAssertElementValue('esc_period', '123'); + $this->zbxTestClickXpath('//div[@id="operationTab"]//button[text()="Add"]'); + + $this->zbxTestWaitUntilElementClickable(WebDriverBy::xpath('//tr[@id="operation-message-users-footer"]//button')); + + $this->zbxTestClickXpath('//tr[@id="operation-message-users-footer"]//button'); + $this->page->query('xpath://div[contains(@class, "overlay-dialogue modal")][2]'. + '//button[text()="Cancel"]')->waitUntilClickable()->one()->click(); + $this->zbxTestClickXpath('//div[@class="overlay-dialogue-footer"]//button[text()="Cancel"]'); + $this->zbxTestWaitUntilElementClickable(WebDriverBy::id('add')); + + $this->zbxTestDoubleClickBeforeMessage('add', 'filter_name'); + $this->zbxTestWaitUntilMessageTextPresent('msg-good', 'Action added'); + + $sql = "SELECT actionid FROM actions WHERE name='action test'"; + $this->assertEquals(1, CDBHelper::getCount($sql), 'Action has not been created in the DB.'); + } + + public function testFormAction_Clone() { + $id = self::$actionid; + $sql = 'SELECT a.eventsource, a.evaltype, a.status, a.esc_period, a.formula, a.pause_suppressed, '. + 'c.conditiontype, c.operator, c.value, c.value2, '. + 'o.operationtype, o.esc_period, o.esc_step_from, o.esc_step_to, o.evaltype, o.recovery '. + 'FROM actions a '. + 'INNER JOIN conditions c ON c.actionid = a.actionid '. + 'INNER JOIN operations o on o.actionid = c.actionid '. + 'WHERE a.actionid='.zbx_dbstr($id).' ORDER BY o.operationid'; + + $original_hash = CDBHelper::getHash($sql); + + $this->page->login()->open('actionconf.php?eventsource=4&form=update&actionid='.$id)->waitUntilReady(); + $this->query('button:Clone')->waitUntilClickable()->one()->click(); + + $form = $this->query('id:action-form')->asForm()->one(); + $form->getField('Name')->fill(self::$action_name.' Clone'); + $form->submit(); + $this->assertMessage(TEST_GOOD, 'Action added'); + + $id = CDBHelper::getValue('SELECT actionid FROM actions WHERE name='.zbx_dbstr(self::$action_name.' Clone')); + $this->assertEquals($original_hash, CDBHelper::getHash($sql)); + } +} diff --git a/ui/tests/selenium/actions/testPageActions.php b/ui/tests/selenium/actions/testPageActions.php new file mode 100644 index 00000000000..8890040cd98 --- /dev/null +++ b/ui/tests/selenium/actions/testPageActions.php @@ -0,0 +1,321 @@ + 'Trigger actions', + EVENT_SOURCE_DISCOVERY => 'Discovery actions', + EVENT_SOURCE_AUTOREGISTRATION => 'Autoregistration actions', + EVENT_SOURCE_INTERNAL => 'Internal actions' + ]; + + private function calculateHash($actionid) { + $this->sqlHashAction = 'SELECT actionid,name,eventsource,evaltype,status,formula,pause_suppressed FROM actions ' + . 'WHERE actionid='.$actionid; + $this->oldHashAction = CDBHelper::getHash($this->sqlHashAction); + $this->sqlHashConditions = 'SELECT * FROM conditions WHERE actionid='.$actionid.' AND actionid>2 ORDER BY conditionid'; + $this->oldHashConditions = CDBHelper::getHash($this->sqlHashConditions); + $this->sqlHashOperations = 'SELECT * FROM operations WHERE actionid='.$actionid.' ORDER BY operationid'; + $this->oldHashOperations = CDBHelper::getHash($this->sqlHashOperations); + $this->sqlHashOpMessage = + 'SELECT om.* FROM opmessage om,operations o'. + ' WHERE om.operationid=o.operationid'. + ' AND o.actionid='.$actionid. + ' ORDER BY om.operationid'; + $this->oldHashOpMessage = CDBHelper::getHash($this->sqlHashOpMessage); + $this->sqlHashOpMessageGrp = + 'SELECT omg.* FROM opmessage_grp omg,operations o'. + ' WHERE omg.operationid=o.operationid'. + ' AND o.actionid='.$actionid. + ' ORDER BY omg.opmessage_grpid'; + $this->oldHashOpMessageGrp = CDBHelper::getHash($this->sqlHashOpMessageGrp); + $this->sqlHashOpMessageUsr = + 'SELECT omu.* FROM opmessage_usr omu,operations o'. + ' WHERE omu.operationid=o.operationid'. + ' AND o.actionid='.$actionid. + ' ORDER BY omu.opmessage_usrid'; + $this->oldHashOpMessageUsr = CDBHelper::getHash($this->sqlHashOpMessageUsr); + $this->sqlHashOpCommand = + 'SELECT oc.* FROM opcommand oc,operations o'. + ' WHERE oc.operationid=o.operationid'. + ' AND o.actionid='.$actionid. + ' ORDER BY oc.operationid'; + $this->oldHashOpCommand = CDBHelper::getHash($this->sqlHashOpCommand); + $this->sqlHashOpCommandHst = + 'SELECT och.* FROM opcommand_hst och,operations o'. + ' WHERE och.operationid=o.operationid'. + ' AND o.actionid='.$actionid. + ' ORDER BY och.opcommand_hstid'; + $this->oldHashOpCommandHst = CDBHelper::getHash($this->sqlHashOpCommandHst); + $this->sqlHashOpCommandGrp = + 'SELECT ocg.* FROM opcommand_grp ocg,operations o'. + ' WHERE ocg.operationid=o.operationid'. + ' AND o.actionid='.$actionid. + ' ORDER BY ocg.opcommand_grpid'; + $this->oldHashOpCommandGrp = CDBHelper::getHash($this->sqlHashOpCommandGrp); + $this->sqlHashOpGroup = + 'SELECT og.* FROM opgroup og,operations o'. + ' WHERE og.operationid=o.operationid'. + ' AND o.actionid='.$actionid. + ' ORDER BY og.opgroupid'; + $this->oldHashOpGroup = CDBHelper::getHash($this->sqlHashOpGroup); + $this->sqlHashOpTemplate = + 'SELECT ot.* FROM optemplate ot,operations o'. + ' WHERE ot.operationid=o.operationid'. + ' AND o.actionid='.$actionid. + ' ORDER BY ot.optemplateid'; + $this->oldHashOpTemplate = CDBHelper::getHash($this->sqlHashOpTemplate); + $this->sqlHashOpConditions = + 'SELECT oc.* FROM opconditions oc,operations o'. + ' WHERE oc.operationid=o.operationid'. + ' AND o.actionid='.$actionid. + ' ORDER BY oc.opconditionid'; + $this->oldHashOpConditions = CDBHelper::getHash($this->sqlHashOpConditions); + } + + private function verifyHash() { + $this->assertEquals($this->oldHashAction, CDBHelper::getHash($this->sqlHashAction)); + $this->assertEquals($this->oldHashConditions, CDBHelper::getHash($this->sqlHashConditions)); + $this->assertEquals($this->oldHashOperations, CDBHelper::getHash($this->sqlHashOperations)); + $this->assertEquals($this->oldHashOpMessage, CDBHelper::getHash($this->sqlHashOpMessage)); + $this->assertEquals($this->oldHashOpMessageGrp, CDBHelper::getHash($this->sqlHashOpMessageGrp)); + $this->assertEquals($this->oldHashOpMessageUsr, CDBHelper::getHash($this->sqlHashOpMessageUsr)); + $this->assertEquals($this->oldHashOpCommand, CDBHelper::getHash($this->sqlHashOpCommand)); + $this->assertEquals($this->oldHashOpCommandHst, CDBHelper::getHash($this->sqlHashOpCommandHst)); + $this->assertEquals($this->oldHashOpCommandGrp, CDBHelper::getHash($this->sqlHashOpCommandGrp)); + $this->assertEquals($this->oldHashOpGroup, CDBHelper::getHash($this->sqlHashOpGroup)); + $this->assertEquals($this->oldHashOpTemplate, CDBHelper::getHash($this->sqlHashOpTemplate)); + $this->assertEquals($this->oldHashOpConditions, CDBHelper::getHash($this->sqlHashOpConditions)); + } + + public static function allEventSources() { + return [ + [EVENT_SOURCE_TRIGGERS], + [EVENT_SOURCE_DISCOVERY], + [EVENT_SOURCE_AUTOREGISTRATION], + [EVENT_SOURCE_INTERNAL] + ]; + } + + public static function allActions() { + return CDBHelper::getDataProvider( + 'SELECT actionid,eventsource,name,status'. + ' FROM actions'. + ' ORDER BY actionid' + ); + } + + /** + * @dataProvider allEventSources + */ + public function testPageActions_CheckLayout($eventsource) { + $this->zbxTestLogin('actionconf.php?eventsource='.$eventsource); + $this->zbxTestCheckTitle('Configuration of actions'); + + $this->zbxTestCheckHeader($this->event_sources[$eventsource]); + $this->zbxTestTextPresent('Displaying'); + + $this->zbxTestTextPresent(['Name', 'Conditions', 'Operations', 'Status']); + + $dbResult = DBselect( + 'SELECT name,status'. + ' FROM actions'. + ' WHERE eventsource='.$eventsource. + ' ORDER BY actionid' + ); + + while ($dbRow = DBfetch($dbResult)) { + $statusStr = ($dbRow['status'] == ACTION_STATUS_ENABLED ? 'Enabled' : 'Disabled'); + + $this->zbxTestTextPresent([$dbRow['name'], $statusStr]); + } + + $this->zbxTestTextPresent(['Enable', 'Disable', 'Delete']); + } + + /** + * @dataProvider allActions + */ + public function testPageActions_SimpleUpdate($action) { + $this->calculateHash($action['actionid']); + + $this->zbxTestLogin('actionconf.php?eventsource='.$action['eventsource']); + $this->zbxTestClickLinkText($action['name']); + $this->zbxTestClickWait('update'); + $this->zbxTestCheckTitle('Configuration of actions'); + $this->zbxTestTextPresent('Action updated'); + $this->zbxTestTextPresent($action['name']); + + $this->verifyHash(); + } + + /** + * @dataProvider allActions + */ + public function testPageActions_SingleEnableDisable($action) { + $this->sqlHashAction = 'SELECT * FROM actions WHERE actionid<>'.$action['actionid'].' ORDER BY actionid'; + $this->oldHashAction = CDBHelper::getHash($this->sqlHashAction); + + $this->zbxTestLogin('actionconf.php?eventsource='.$action['eventsource']); + $this->zbxTestCheckTitle('Configuration of actions'); + + switch ($action['status']) { + case ACTION_STATUS_ENABLED: + $this->zbxTestClickXpathWait("//a[contains(@onclick,'actionid[]=".$action['actionid']."')]"); + $this->zbxTestTextPresent('Action disabled'); + $newStatus = ACTION_STATUS_DISABLED; + break; + case ACTION_STATUS_DISABLED: + $this->zbxTestClickXpath("//a[contains(@onclick,'actionid[]=".$action['actionid']."')]"); + $this->zbxTestTextPresent('Action enabled'); + $newStatus = ACTION_STATUS_ENABLED; + break; + default: + $this->assertTrue(false); + } + + $this->zbxTestCheckTitle('Configuration of actions'); + + $this->assertEquals(1, CDBHelper::getCount( + 'SELECT NULL'. + ' FROM actions'. + ' WHERE actionid='.$action['actionid']. + ' AND status='.$newStatus + )); + + $this->assertEquals($this->oldHashAction, CDBHelper::getHash($this->sqlHashAction)); + } + + /** + * @dataProvider allActions + */ + public function testPageActions_MassDisable($action) { + $this->sqlHashAction = 'SELECT * FROM actions WHERE actionid<>'.$action['actionid'].' ORDER BY actionid'; + $this->oldHashAction = CDBHelper::getHash($this->sqlHashAction); + + $this->zbxTestLogin('actionconf.php?eventsource='.$action['eventsource']); + $this->zbxTestCheckTitle('Configuration of actions'); + + $this->zbxTestCheckHeader($this->event_sources[$action['eventsource']]); + + $this->zbxTestCheckboxSelect('g_actionid_'.$action['actionid']); + $this->zbxTestClickButton('action.massdisable'); + + $this->zbxTestAcceptAlert(); + + $this->zbxTestCheckTitle('Configuration of actions'); + $this->zbxTestTextPresent('Action disabled'); + $this->zbxTestTextPresent('Disabled'); + + $this->assertEquals(1, CDBHelper::getCount( + 'SELECT NULL'. + ' FROM actions'. + ' WHERE actionid='.$action['actionid']. + ' AND status='.ACTION_STATUS_DISABLED + )); + + $this->assertEquals($this->oldHashAction, CDBHelper::getHash($this->sqlHashAction)); + } + + /** + * @dataProvider allActions + */ + public function testPageActions_MassEnable($action) { + $this->sqlHashAction = 'SELECT * FROM actions WHERE actionid<>'.$action['actionid'].' ORDER BY actionid'; + $this->oldHashAction = CDBHelper::getHash($this->sqlHashAction); + + $this->zbxTestLogin('actionconf.php?eventsource='.$action['eventsource']); + $this->zbxTestCheckTitle('Configuration of actions'); + + $this->zbxTestCheckHeader($this->event_sources[$action['eventsource']]); + + $this->zbxTestCheckboxSelect('g_actionid_'.$action['actionid']); + $this->zbxTestClickButton('action.massenable'); + + $this->zbxTestAcceptAlert(); + + $this->zbxTestCheckTitle('Configuration of actions'); + $this->zbxTestWaitUntilMessageTextPresent('msg-good', 'Action enabled'); + $this->zbxTestTextPresent('Enabled'); + + $this->assertEquals(1, CDBHelper::getCount( + 'SELECT NULL'. + ' FROM actions'. + ' WHERE actionid='.$action['actionid']. + ' AND status='.ACTION_STATUS_ENABLED + )); + + $this->assertEquals($this->oldHashAction, CDBHelper::getHash($this->sqlHashAction)); + } + + /** + * @dataProvider allActions + * @backupOnce actions + */ + public function testPageActions_MassDelete($action) { + $this->sqlHashAction = 'SELECT * FROM actions WHERE actionid<>'.$action['actionid'].' ORDER BY actionid'; + $this->oldHashAction = CDBHelper::getHash($this->sqlHashAction); + + $this->zbxTestLogin('actionconf.php?eventsource='.$action['eventsource']); + $this->zbxTestCheckTitle('Configuration of actions'); + + $this->zbxTestCheckHeader($this->event_sources[$action['eventsource']]); + + $this->zbxTestCheckboxSelect('g_actionid_'.$action['actionid']); + $this->zbxTestClickButton('action.massdelete'); + + $this->zbxTestAcceptAlert(); + + $this->zbxTestCheckTitle('Configuration of actions'); + $this->zbxTestWaitUntilMessageTextPresent('msg-good', 'Selected actions deleted'); + + $this->assertEquals(0, CDBHelper::getCount('SELECT * FROM actions WHERE actionid='.$action['actionid'])); + + $this->assertEquals($this->oldHashAction, CDBHelper::getHash($this->sqlHashAction)); + } +} diff --git a/ui/tests/selenium/testFormAction.php b/ui/tests/selenium/testFormAction.php deleted file mode 100644 index cd64730c8e1..00000000000 --- a/ui/tests/selenium/testFormAction.php +++ /dev/null @@ -1,1729 +0,0 @@ - 'Trigger actions', - EVENT_SOURCE_SERVICE => 'Service actions', - EVENT_SOURCE_DISCOVERY => 'Discovery actions', - EVENT_SOURCE_AUTOREGISTRATION => 'Autoregistration actions', - EVENT_SOURCE_INTERNAL => 'Internal actions' - ]; - - /** - * Id of the action to be used for Simple update and Clone scenarios. - * - * @var integer - */ - protected static $actionid; - - /** - * Name of the action to be used for Simple update and Clone scenarios. - * - * @var integer - */ - protected static $action_name = 'Service action'; - - /** - * Attach MessageBehavior to the test. - * - * @return array - */ - public function getBehaviors() { - return [ - 'class' => CMessageBehavior::class - ]; - } - - /** - * Function creates Service actions. - */ - public function prepareServiceActionData() { - $response = CDataHelper::call('action.create', [ - [ - 'name' => self::$action_name, - 'eventsource' => 4, - 'status' => '0', - 'esc_period' => '1h', - 'filter' => [ - 'evaltype' => 0, - 'conditions' => [ - [ - 'conditiontype' => 28, - 'operator' => 2, - 'value' => 'Service name' - ], - [ - 'conditiontype' => 25, - 'operator' => 2, - 'value' => 'Service tag name' - ] - ] - ], - 'operations' => [ - [ - 'operationtype' => 0, - 'esc_period' => 0, - 'esc_step_from' => 1, - 'esc_step_to' => 1, - 'opmessage' => [ - 'default_msg' => 1, - 'mediatypeid' => 0 - ], - 'opmessage_usr' => [ - [ - 'userid' => 1 - ] - ] - ] - ], - 'recovery_operations' => [ - [ - 'operationtype' => 11, - 'opmessage' => [ - 'default_msg' => 0, - 'subject' => 'Subject', - 'message' => 'Message' - ] - ] - ], - 'update_operations' => [ - [ - 'operationtype' => 0, - 'opmessage' => [ - 'default_msg' => 1, - 'mediatypeid' => 1 - ], - 'opmessage_grp' => [ - [ - 'usrgrpid' => 7 - ] - ] - ] - ] - ] - ]); - - - $this->assertArrayHasKey('actionids', $response); - self::$actionid = $response['actionids'][0]; - - CDataHelper::call('service.create', [ - [ - 'name' => 'Reference service', - 'algorithm' => 1, - 'sortorder' => 1 - ] - ]); - } - - public static function layout() { - return [ - [ - [ - 'eventsource' => EVENT_SOURCE_TRIGGERS, - 'recovery_msg' => true, - 'acknowledge_msg' => true - ] - ], - [ - [ - 'eventsource' => EVENT_SOURCE_TRIGGERS, - 'new_operation_operationtype' => 'Send message' - ] - ], - [ - [ - 'eventsource' => EVENT_SOURCE_TRIGGERS, - 'new_operation_operationtype' => 'Send message', - 'new_operation_opmessage_custom_msg' => 'unchecked' - ] - ], - [ - [ - 'eventsource' => EVENT_SOURCE_TRIGGERS, - 'new_operation_operationtype' => 'Send message', - 'add_opcondition' => true - ] - ], - [ - [ - 'eventsource' => EVENT_SOURCE_TRIGGERS, - 'check_operationtype' => true, - 'new_operation_operationtype' => 'Reboot', - 'add_opcondition' => true - ] - ], - [ - ['eventsource' => EVENT_SOURCE_TRIGGERS, 'evaltype' => 'And'] - ], - [ - ['eventsource' => EVENT_SOURCE_TRIGGERS, 'evaltype' => 'Or'] - ], - [ - ['eventsource' => EVENT_SOURCE_TRIGGERS, 'new_condition_conditiontype' => 'Tag name'] - ], - [ - ['eventsource' => EVENT_SOURCE_TRIGGERS, 'new_condition_conditiontype' => 'Tag value'] - ], - [ - ['eventsource' => EVENT_SOURCE_TRIGGERS, 'new_condition_conditiontype' => 'Host group'] - ], - [ - ['eventsource' => EVENT_SOURCE_TRIGGERS, 'new_condition_conditiontype' => 'Template'] - ], - [ - ['eventsource' => EVENT_SOURCE_TRIGGERS, 'new_condition_conditiontype' => 'Host'] - ], - [ - ['eventsource' => EVENT_SOURCE_TRIGGERS, 'new_condition_conditiontype' => 'Trigger'] - ], - [ - ['eventsource' => EVENT_SOURCE_TRIGGERS, 'new_condition_conditiontype' => 'Trigger name'] - ], - [ - ['eventsource' => EVENT_SOURCE_TRIGGERS, 'new_condition_conditiontype' => 'Trigger severity'] - ], - [ - ['eventsource' => EVENT_SOURCE_TRIGGERS, 'new_condition_conditiontype' => 'Time period'] - ], - [ - ['eventsource' => EVENT_SOURCE_TRIGGERS, 'new_condition_conditiontype' => 'Problem is suppressed'] - ], - [ - [ - 'eventsource' => EVENT_SOURCE_SERVICE, - 'recovery_msg' => true, - 'acknowledge_msg' => true - ] - ], - [ - [ - 'eventsource' => EVENT_SOURCE_SERVICE, - 'new_operation_operationtype' => 'Send message' - ] - ], - [ - [ - 'eventsource' => EVENT_SOURCE_SERVICE, - 'new_operation_operationtype' => 'Send message', - 'new_operation_opmessage_custom_msg' => 'unchecked' - ] - ], - [ - [ - 'eventsource' => EVENT_SOURCE_SERVICE, - 'check_operationtype' => true, - 'new_operation_operationtype' => 'Reboot' - ] - ], - [ - ['eventsource' => EVENT_SOURCE_SERVICE, 'new_condition_conditiontype' => 'Service'] - ], - [ - ['eventsource' => EVENT_SOURCE_SERVICE, 'new_condition_conditiontype' => 'Service name'] - ], - [ - ['eventsource' => EVENT_SOURCE_SERVICE, 'new_condition_conditiontype' => 'Service tag name'] - ], - [ - ['eventsource' => EVENT_SOURCE_SERVICE, 'new_condition_conditiontype' => 'Service tag value'] - ], - [ - ['eventsource' => EVENT_SOURCE_DISCOVERY] - ], - [ - ['eventsource' => EVENT_SOURCE_DISCOVERY, 'new_condition_conditiontype' => 'Host IP'] - ], - [ - ['eventsource' => EVENT_SOURCE_DISCOVERY, 'new_condition_conditiontype' => 'Service type'] - ], - [ - ['eventsource' => EVENT_SOURCE_DISCOVERY, 'new_condition_conditiontype' => 'Service port'] - ], - [ - ['eventsource' => EVENT_SOURCE_DISCOVERY, 'new_condition_conditiontype' => 'Discovery rule'] - ], - [ - ['eventsource' => EVENT_SOURCE_DISCOVERY, 'new_condition_conditiontype' => 'Discovery check'] - ], - [ - ['eventsource' => EVENT_SOURCE_DISCOVERY, 'new_condition_conditiontype' => 'Discovery object'] - ], - [ - ['eventsource' => EVENT_SOURCE_DISCOVERY, 'new_condition_conditiontype' => 'Discovery status'] - ], - [ - ['eventsource' => EVENT_SOURCE_DISCOVERY, 'new_condition_conditiontype' => 'Uptime/Downtime'] - ], - [ - ['eventsource' => EVENT_SOURCE_DISCOVERY, 'new_condition_conditiontype' => 'Received value'] - ], - [ - ['eventsource' => EVENT_SOURCE_DISCOVERY, 'new_condition_conditiontype' => 'Proxy'] - ], - [ - [ - 'eventsource' => EVENT_SOURCE_DISCOVERY, - 'new_operation_operationtype' => 'Send message' - ] - ], - [ - [ - 'eventsource' => EVENT_SOURCE_DISCOVERY, - 'new_operation_operationtype' => 'Send message', - 'new_operation_opmessage_custom_msg' => 'unchecked' - ] - ], - [ - [ - 'eventsource' => EVENT_SOURCE_DISCOVERY, - 'new_operation_operationtype' => 'Reboot' - ] - ], - [ - ['eventsource' => EVENT_SOURCE_DISCOVERY, 'check_operationtype' => true, 'new_operation_operationtype' => 'Add host'] - ], - [ - ['eventsource' => EVENT_SOURCE_DISCOVERY, 'new_operation_operationtype' => 'Remove host'] - ], - [ - ['eventsource' => EVENT_SOURCE_DISCOVERY, 'new_operation_operationtype' => 'Add to host group'] - ], - [ - ['eventsource' => EVENT_SOURCE_DISCOVERY, 'new_operation_operationtype' => 'Remove from host group'] - ], - [ - ['eventsource' => EVENT_SOURCE_DISCOVERY, 'new_operation_operationtype' => 'Link to template'] - ], - [ - ['eventsource' => EVENT_SOURCE_DISCOVERY, 'new_operation_operationtype' => 'Unlink from template'] - ], - [ - ['eventsource' => EVENT_SOURCE_DISCOVERY, 'new_operation_operationtype' => 'Enable host'] - ], - [ - ['eventsource' => EVENT_SOURCE_DISCOVERY, 'new_operation_operationtype' => 'Disable host'] - ], - [ - ['eventsource' => EVENT_SOURCE_AUTOREGISTRATION] - ], - [ - ['eventsource' => EVENT_SOURCE_AUTOREGISTRATION, 'new_condition_conditiontype' => 'Host name'] - ], - [ - ['eventsource' => EVENT_SOURCE_AUTOREGISTRATION, 'new_condition_conditiontype' => 'Proxy'] - ], - [ - ['eventsource' => EVENT_SOURCE_AUTOREGISTRATION, 'new_condition_conditiontype' => 'Host metadata'] - ], - [ - [ - 'eventsource' => EVENT_SOURCE_AUTOREGISTRATION, - 'new_operation_operationtype' => 'Send message' - ] - ], - [ - [ - 'eventsource' => EVENT_SOURCE_AUTOREGISTRATION, - 'new_operation_operationtype' => 'Send message', - 'new_operation_opmessage_custom_msg' => 'unchecked' - ] - ], - [ - ['eventsource' => EVENT_SOURCE_AUTOREGISTRATION, 'check_operationtype' => true, 'new_operation_operationtype' => 'Add host'] - ], - [ - ['eventsource' => EVENT_SOURCE_AUTOREGISTRATION, 'new_operation_operationtype' => 'Add to host group'] - ], - [ - ['eventsource' => EVENT_SOURCE_AUTOREGISTRATION, 'new_operation_operationtype' => 'Link to template'] - ], - [ - ['eventsource' => EVENT_SOURCE_AUTOREGISTRATION, 'new_operation_operationtype' => 'Disable host'] - ], - [ - ['eventsource' => EVENT_SOURCE_INTERNAL] - ], - [ - ['eventsource' => EVENT_SOURCE_INTERNAL, 'recovery_msg' => true] - ], - [ - ['eventsource' => EVENT_SOURCE_INTERNAL, 'new_condition_conditiontype' => 'Tag name'] - ], - [ - ['eventsource' => EVENT_SOURCE_INTERNAL, 'new_condition_conditiontype' => 'Tag value'] - ], - [ - ['eventsource' => EVENT_SOURCE_INTERNAL, 'new_condition_conditiontype' => 'Event type'] - ], - [ - ['eventsource' => EVENT_SOURCE_INTERNAL, 'new_condition_conditiontype' => 'Host group'] - ], - [ - ['eventsource' => EVENT_SOURCE_INTERNAL, 'new_condition_conditiontype' => 'Template'] - ], - [ - ['eventsource' => EVENT_SOURCE_INTERNAL, 'new_condition_conditiontype' => 'Host'] - ], - [ - ['eventsource' => EVENT_SOURCE_INTERNAL, 'new_operation_operationtype' => 'Send message'] - ], - [ - [ - 'eventsource' => EVENT_SOURCE_INTERNAL, - 'check_operationtype' => true, - 'new_operation_operationtype' => 'Send message', - 'new_operation_opmessage_custom_msg' => 'unchecked' - ] - ] - ]; - } - - /** - * @dataProvider layout - */ - public function testFormAction_CheckLayout($data) { - $eventsource = $data['eventsource']; - - $this->zbxTestLogin('actionconf.php?eventsource='.$eventsource.'&form=Create+action'); - $this->zbxTestCheckTitle('Configuration of actions'); - $this->zbxTestTextPresent(['Action', 'Operations']); - - $this->zbxTestTextPresent('Name'); - $this->zbxTestAssertVisibleId('name'); - $this->zbxTestAssertAttribute('//input[@id="name"]', 'maxlength', 255); - $this->zbxTestAssertAttribute('//input[@id="name"]', 'autofocus'); - - $this->zbxTestTextPresent('Enabled'); - $this->zbxTestAssertElementPresentId('status'); - $this->zbxTestAssertElementPresentXpath('//input[@type="checkbox" and @id="status"]'); - $this->assertTrue($this->zbxTestCheckboxSelected('status')); - - if (array_key_exists('evaltype', $data)) { - // Open Condition overlay dialog and fill first condition. - $this->zbxTestClickXpath('//button[text()="Add" and contains(@onclick, "popup.condition.actions")]'); - $this->zbxTestLaunchOverlayDialog('New condition'); - $this->zbxTestInputTypeByXpath('//textarea[@id="value"]', 'TEST1'); - $this->zbxTestClickXpathWait('//div[@class="overlay-dialogue-footer"]//button[text()="Add"]'); - $this->zbxTestWaitUntilElementVisible(WebDriverBy::id('conditions_0')); - // Open Condition overlay dialog again and fill second condition. - $this->zbxTestClickXpath('//button[text()="Add" and contains(@onclick, "popup.condition.actions")]'); - $this->zbxTestLaunchOverlayDialog('New condition'); - $this->zbxTestInputTypeByXpath('//textarea[@id="value"]', 'TEST2'); - $this->zbxTestClickXpathWait('//div[@class="overlay-dialogue-footer"]//button[text()="Add"]'); - // Wait until overlay is closed and value is added, so that Type of calculation dropdown is clickable. - $this->zbxTestWaitUntilElementVisible(WebDriverBy::id('evaltype')); - $this->zbxTestDropdownSelectWait('evaltype', $data['evaltype']); - $evaltype = $data['evaltype']; - } - - if ($eventsource == EVENT_SOURCE_TRIGGERS && array_key_exists('evaltype', $data)) { - $this->zbxTestTextPresent('Type of calculation'); - $this->zbxTestAssertElementPresentId('evaltype'); - $this->zbxTestDropdownHasOptions('evaltype', [ - 'And/Or', - 'And', - 'Or', - 'Custom expression' - ]); - $this->zbxTestDropdownAssertSelected('evaltype', $evaltype); - switch ($evaltype) { - case 'And/Or': - case 'And': - $this->zbxTestTextPresent('A and B'); - break; - default: - $this->zbxTestTextPresent('A or B'); - break; - } - } - else { - $this->zbxTestTextNotVisible('Type of calculation'); - $this->zbxTestAssertNotVisibleId('evaltype'); - } - - $this->zbxTestTextPresent([ - 'Conditions', - 'Label', 'Name', 'Action' - ]); - - if ($eventsource == EVENT_SOURCE_TRIGGERS && array_key_exists('evaltype', $data)) { - $this->zbxTestAssertElementText('//tr[@id="conditions_0"]/td[2]', 'Trigger name contains TEST1'); - $this->zbxTestAssertElementText('//tr[@id="conditions_1"]/td[2]', 'Trigger name contains TEST2'); - $this->zbxTestAssertElementPresentXpath('//button[@name="remove" and @onclick="removeCondition(0);"]'); - $this->zbxTestAssertElementPresentXpath('//button[@name="remove" and @onclick="removeCondition(1);"]'); - } - else { - $this->zbxTestAssertElementNotPresentXpath('//tr[@id="conditions_0"]'); - $this->zbxTestAssertElementNotPresentXpath('//button[@name="remove" and @onclick="removeCondition(0);"]'); - $this->zbxTestAssertElementNotPresentXpath('//button[@name="remove" and @onclick="removeCondition(1);"]'); - } - - // Open Condition overlay dialog. - $this->zbxTestClickXpath('//button[text()="Add" and contains(@onclick, "popup.condition.actions")]'); - $this->zbxTestLaunchOverlayDialog('New condition'); - COverlayDialogElement::find()->one()->waitUntilReady(); - - if (isset($data['new_condition_conditiontype'])) { - $this->zbxTestDropdownSelectWait('condition_type', $data['new_condition_conditiontype']); - COverlayDialogElement::find()->one()->waitUntilReady(); - } - $this->zbxTestWaitUntilElementVisible(WebDriverBy::id('condition-type')); - $new_condition_conditiontype = $this->zbxTestGetSelectedLabel('condition_type'); - - switch ($eventsource) { - case EVENT_SOURCE_TRIGGERS: - $this->zbxTestDropdownHasOptions('condition_type', [ - 'Tag name', - 'Tag value', - 'Host group', - 'Template', - 'Host', - 'Trigger', - 'Trigger name', - 'Trigger severity', - 'Time period', - 'Problem is suppressed' - ]); - break; - case EVENT_SOURCE_SERVICE: - $this->zbxTestDropdownHasOptions('condition_type', [ - 'Service', - 'Service name', - 'Service tag name', - 'Service tag value' - ]); - break; - case EVENT_SOURCE_DISCOVERY: - $this->zbxTestDropdownHasOptions('condition_type', [ - 'Host IP', - 'Service type', - 'Service port', - 'Discovery rule', - 'Discovery check', - 'Discovery object', - 'Discovery status', - 'Uptime/Downtime', - 'Received value', - 'Proxy' - ]); - break; - case EVENT_SOURCE_AUTOREGISTRATION: - $this->zbxTestDropdownHasOptions('condition_type', [ - 'Host name', - 'Proxy', - 'Host metadata' - ]); - break; - case EVENT_SOURCE_INTERNAL: - $this->zbxTestDropdownHasOptions('condition_type', [ - 'Tag name', - 'Tag value', - 'Event type', - 'Host group', - 'Template', - 'Host' - ]); - break; - } - - if (isset($data['new_condition_conditiontype'])) { - $this->zbxTestDropdownAssertSelected('condition_type', $new_condition_conditiontype); - } - - switch ($new_condition_conditiontype) { - case 'Tag name': - case 'Tag value': - case 'Service tag name': - case 'Service tag value': - $this->zbxTestTextPresent([ - 'equals', - 'does not equal', - 'contains', - 'does not contain' - ]); - break; - case 'Host group': - case 'Template': - case 'Host': - case 'Trigger': - case 'Host IP': - case 'Service type': - case 'Service': - case 'Discovery rule': - case 'Discovery check': - case 'Proxy': - $this->zbxTestTextPresent([ - 'equals', - 'does not equal' - ]); - break; - case 'Trigger name': - case 'Service name': - case 'Host name': - case 'Host metadata': - $this->zbxTestTextPresent([ - 'contains', - 'does not contain' - ]); - break; - case 'Trigger severity': - $this->zbxTestTextPresent([ - 'equals', - 'does not equal', - 'is greater than or equals', - 'is less than or equals' - ]); - break; - case 'Trigger value': - case 'Discovery object': - case 'Discovery status': - case 'Event type': - $this->zbxTestIsElementPresent('//td[@colspan="1" and text()="equals"]'); - break; - case 'Time period': - $this->zbxTestTextPresent([ - 'in', - 'not in' - ]); - break; - case 'Problem is suppressed': - $this->zbxTestTextPresent([ - 'No', - 'Yes' - ]); - break; - case 'Uptime/Downtime': - $this->zbxTestTextPresent([ - 'is greater than or equals', - 'is less than or equals' - ]); - break; - case 'Received value': - $this->zbxTestDropdownHasOptions('operator', [ - 'equals', - 'does not equal', - 'is greater than or equals', - 'is less than or equals', - 'contains', - 'does not contain' - ]); - break; - } - - switch ($new_condition_conditiontype) { - case 'Tag name': - case 'Tag value': - case 'Service tag name': - case 'Service tag value': - case 'Service name': - case 'Trigger name': - case 'Time period': - case 'Host IP': - case 'Uptime/Downtime': - case 'Received value': - case 'Host name': - case 'Host metadata': - case 'Service port': - $this->zbxTestAssertElementPresentXpath('//input[@id="value"] | //textarea[@id="value"]'); - break; - default: - $this->zbxTestAssertElementNotPresentXpath('//input[@id="value"] | //textarea[@id="value"]'); - break; - } - - switch ($new_condition_conditiontype) { - case 'Tag name': - case 'Tag value': - case 'Trigger name': - case 'Service tag name': - case 'Service tag value': - case 'Service name': - case 'Time period': - case 'Host IP': - case 'Received value': - case 'Host name': - case 'Host metadata': - case 'Service port': - $this->zbxTestAssertAttribute('//textarea[@id="value"] | //input[@id="value"]', 'maxlength', 255); - break; - case 'Uptime/Downtime': - $this->zbxTestAssertAttribute('//input[@id="value"]', 'maxlength', 15); - break; - } - - switch ($new_condition_conditiontype) { - case 'Tag name': - case 'Tag value': - case 'Trigger name': - case 'Service tag name': - case 'Service tag value': - case 'Service name': - case 'Received value': - case 'Host name': - case 'Host metadata': - $this->zbxTestAssertElementValue('value', ""); - break; - case 'Time period': - $this->zbxTestAssertElementValue('value', '1-7,00:00-24:00'); - break; - case 'Service port': - $this->zbxTestAssertElementValue('value', '0-1023,1024-49151'); - break; - case 'Host IP': - $this->zbxTestAssertElementValue('value', '192.168.0.1-127,192.168.2.1'); - break; - case 'Uptime/Downtime': - $this->zbxTestAssertElementValue('value', 600); - break; - } - - switch ($new_condition_conditiontype) { - case 'Host group': - case 'Service': - case 'Template': - case 'Host': - case 'Trigger': - case 'Discovery rule': - case 'Proxy': - $this->zbxTestAssertElementPresentXpath('//div[@class="multiselect"]/input[@placeholder]'); - break; - default: - $this->zbxTestAssertElementNotPresentXpath('//div[@id=\'new_condition_value_\']/input[@placeholder]'); - $this->zbxTestAssertElementNotPresentXpath('//div[@id=\'new_condition_value\']/input[@placeholder]'); - break; - } - - switch ($new_condition_conditiontype) { - case 'Trigger severity': - case 'Trigger value': - case 'Discovery object': - case 'Discovery status': - $this->zbxTestAssertElementPresentXpath('//ul[@id="value" and contains(@class, "radio")]'); - break; - case 'Event type': - case 'Service type': - $this->zbxTestAssertElementPresentXpath('//input[@type="radio" and contains(@id, "0") and @checked]'); - $this->zbxTestAssertElementPresentXpath('//z-select[@name="value"]'); - break; - default: - $this->zbxTestAssertElementNotPresentXpath('//ul[@id="value" and contains(@class, "radio")]'); - break; - } - - switch ($new_condition_conditiontype) { - case 'Trigger severity': - $this->zbxTestTextPresent([ - 'Not classified', - 'Information', - 'Warning', - 'Average', - 'High', - 'Disaster' - ]); - break; - case 'Trigger value': - $this->zbxTestDropdownHasOptions('new_condition_value', [ - 'OK', - 'PROBLEM' - ]); - break; - case 'Service type': - $this->zbxTestDropdownHasOptions('value', [ - 'SSH', - 'LDAP', - 'SMTP', - 'FTP', - 'HTTP', - 'HTTPS', - 'POP', - 'NNTP', - 'IMAP', - 'TCP', - 'Zabbix agent', - 'SNMPv1 agent', - 'SNMPv2 agent', - 'SNMPv3 agent', - 'ICMP ping', - 'Telnet' - ]); - break; - case 'Discovery object': - $this->zbxTestTextPresent([ - 'Device', - 'Service' - ]); - break; - case 'Discovery status': - $this->zbxTestTextPresent([ - 'Up', - 'Down', - 'Discovered', - 'Lost' - ]); - break; - case 'Event type': - $this->zbxTestDropdownHasOptions('value', [ - 'Item in "not supported" state', - 'Low-level discovery rule in "not supported" state', - 'Trigger in "unknown" state' - ]); - break; - } - - switch ($new_condition_conditiontype) { - case 'Trigger severity': - $this->zbxTestAssertElementPresentXpath('//label[text()="Not classified"]/../input[@checked]'); - break; - case 'Event type': - $this->zbxTestDropdownAssertSelected('value', 'Item in "not supported" state'); - break; - } - - $this->zbxTestAssertElementNotPresentXpath('//input[@id=\'drule\']'); - - switch ($new_condition_conditiontype) { - case 'Discovery check': - $this->zbxTestAssertElementPresentXpath('//input[@id=\'dcheck\']'); - $this->zbxTestAssertAttribute('//input[@id=\'dcheck\']', 'maxlength', 255); - $this->zbxTestAssertAttribute('//input[@id=\'dcheck\']', 'readonly'); - $this->zbxTestAssertElementPresentXpath('//button[@id=\'btn1\']'); - $this->zbxTestAssertElementText('//button[@id=\'btn1\']', 'Select'); - break; - - default: - $this->zbxTestAssertElementNotPresentXpath('//input[@id=\'dcheck\']'); - $this->zbxTestAssertElementNotPresentXpath('//button[@id=\'btn1\']'); - break; - } - - $this->zbxTestAssertElementPresentXpath("//div[@class='overlay-dialogue-footer']//button[text()='Add']"); - $this->zbxTestClickXpath("//div[@class='overlay-dialogue-footer']//button[text()='Cancel']"); - - $this->zbxTestTabSwitch('Operations'); - - $form = $this->query('id:action-form')->asForm()->waitUntilVisible()->one(); - $operations_field = $form->getField('Operations')->asTable(); - - switch ($eventsource) { - case EVENT_SOURCE_TRIGGERS: - case EVENT_SOURCE_SERVICE: - $this->assertEquals('1h', $form->getField('Default operation step duration')->getValue()); - $this->zbxTestAssertVisibleId('esc_period'); - $this->zbxTestAssertAttribute('//input[@id=\'esc_period\']', 'maxlength', 255); - - $this->assertEquals($operations_field->getHeadersText(), ['Steps', 'Details', 'Start in', 'Duration', 'Action']); - - $checkboxes = [ - 'Pause operations for suppressed problems' => 'id:pause_suppressed', - 'Notify about canceled escalations' => 'id:notify_if_canceled' - ]; - foreach ($checkboxes as $label => $locator) { - if ($eventsource === EVENT_SOURCE_TRIGGERS) { - $this->assertTrue($form->getField($label)->getValue()); - } - else { - $this->assertFalse($form->query($locator)->one(false)->isValid()); - } - } - - $recovery_field = $form->getField('Recovery operations')->asTable(); - $this->assertEquals($recovery_field->getHeadersText(), ['Details', 'Action']); - $update_field = $form->getField('Update operations')->asTable(); - $this->assertEquals($update_field->getHeadersText(), ['Details', 'Action']); - break; - - case EVENT_SOURCE_DISCOVERY: - case EVENT_SOURCE_AUTOREGISTRATION: - $this->zbxTestTextNotPresent(['Default operation step duration', 'Pause operations for suppressed problems', - 'Notify about canceled escalations', 'Recovery operations', 'Update operations']); - $this->zbxTestAssertElementNotPresentId('esc_period'); - $this->zbxTestAssertElementNotPresentId('pause_suppressed'); - break; - - case EVENT_SOURCE_INTERNAL: - $this->assertEquals('1h', $form->getField('Default operation step duration')->getValue()); - $this->zbxTestAssertVisibleId('esc_period'); - $this->zbxTestAssertAttribute('//input[@id=\'esc_period\']', 'maxlength', 255); - - $this->assertEquals($operations_field->getHeadersText(), ['Steps', 'Details', 'Start in', 'Duration', 'Action']); - $recovery_field = $form->getField('Recovery operations')->asTable(); - $this->assertEquals($recovery_field->getHeadersText(), ['Details', 'Action']); - $this->zbxTestTextNotPresent(['Pause operations for suppressed problems', 'Notify about canceled escalations', - 'Update operations'] - ); - $this->zbxTestAssertElementNotPresentId('pause_suppressed'); - break; - } - - if (isset($data['new_operation_operationtype'])) { - $new_operation_operationtype = $data['new_operation_operationtype']; - $operations_field->query('button:Add')->one()->click(); - COverlayDialogElement::find()->one()->waitUntilReady(); - - if ($eventsource === EVENT_SOURCE_INTERNAL) { - $this->zbxTestTextPresent('Send message'); - } - else { - $this->zbxTestWaitUntilElementPresent(webDriverBy::id('operationtype')); - $this->zbxTestDropdownSelectWait('operation-type-select', $new_operation_operationtype); - COverlayDialogElement::find()->one()->waitUntilReady(); - } - } - else { - $new_operation_operationtype = null; - } - - if (isset($data['new_operation_opmessage_custom_msg'])) { - $new_operation_opmessage_custom_msg = $data['new_operation_opmessage_custom_msg']; - $this->assertFalse($this->zbxTestCheckboxSelected('operation_opmessage_default_msg')); - } - elseif ($new_operation_operationtype == 'Send message') { - $new_operation_opmessage_custom_msg = 'checked'; - $this->zbxTestCheckboxSelect('operation_opmessage_default_msg'); - } - else { - $new_operation_opmessage_custom_msg = null; - } - - if (isset($data['add_opcondition'])) { - $this->query('xpath://tr[@id="operation-condition-list-footer"]//button[text()="Add"]')->one()->click(true); - $this->page->query('xpath://div[contains(@class, "overlay-dialogue modal")][2]') - ->asOverlayDialog()->waitUntilReady(); - $add_opcondition = $data['add_opcondition']; - } - else { - $add_opcondition = null; - } - - if ($eventsource === EVENT_SOURCE_SERVICE) { - $this->assertFalse($this->query('id:operation-condition-list')->one(false)->isValid()); - } - - if ($new_operation_operationtype != null - && in_array($eventsource, [EVENT_SOURCE_TRIGGERS, EVENT_SOURCE_SERVICE, EVENT_SOURCE_INTERNAL])) { - switch ($new_operation_operationtype) { - case 'Send message': - case 'Reboot': - $this->zbxTestTextPresent('Steps'); - $this->zbxTestAssertVisibleId('operation_esc_step_from'); - $this->zbxTestAssertAttribute('//input[@id=\'operation_esc_step_from\']', 'maxlength', 5); - $this->zbxTestAssertAttribute('//input[@id=\'operation_esc_step_from\']', 'value', 1); - - $this->zbxTestTextPresent('(0 - infinitely)'); - $this->zbxTestAssertVisibleId('operation_esc_step_to'); - $this->zbxTestAssertAttribute('//input[@id=\'operation_esc_step_to\']', 'maxlength', 5); - $this->zbxTestAssertAttribute('//input[@id=\'operation_esc_step_to\']', 'value', 1); - - $this->zbxTestTextPresent(['Step duration', '(0 - use action default)']); - $this->zbxTestAssertVisibleId('operation_esc_period'); - $this->zbxTestAssertAttribute('//input[@id=\'operation_esc_period\']', 'maxlength', 255); - $this->zbxTestAssertAttribute('//input[@id=\'operation_esc_period\']', 'value', 0); - break; - } - } - else { - $this->zbxTestAssertElementNotPresentId('operation_esc_step_from'); - $this->zbxTestAssertElementNotPresentId('operation_esc_step_to'); - $this->zbxTestAssertElementNotPresentId('operation_esc_period'); - } - - if (isset($data['new_operation_operationtype']) && $eventsource != EVENT_SOURCE_INTERNAL) { - $this->zbxTestTextPresent('Operations'); - $this->zbxTestAssertVisibleXpath('//z-select[@id=\'operation-type-select\']'); - } - else { - $this->zbxTestAssertElementNotPresentXpath('//z-select[@id=\'operation-type-select\']'); - } - - if (isset($data['check_operationtype']) && $eventsource === EVENT_SOURCE_INTERNAL) { - $this->assertFalse($this->query('id:operation-type-select')->one(false)->isValid()); - $this->assertTrue($this->query('xpath://label[text()="Operation"]/../../div[text()="Send message"]')->one()->isValid()); - } - elseif (isset($data['check_operationtype'])) { - $options = $this->query('id:operation-type-select')->asDropdown()->one(); - switch ($eventsource) { - case EVENT_SOURCE_TRIGGERS: - case EVENT_SOURCE_SERVICE: - $this->assertEquals($options->getOptions()->asText(), ['Send message', 'Reboot', 'Selenium script']); - break; - - case EVENT_SOURCE_DISCOVERY: - case EVENT_SOURCE_AUTOREGISTRATION: - $this->assertEquals($options->getOptions()->asText(), [ - 'Send message', - 'Add host', - 'Remove host', - 'Add to host group', - 'Remove from host group', - 'Link to template', - 'Unlink from template', - 'Enable host', - 'Disable host', - 'Set host inventory mode', - 'Reboot', - 'Selenium script' - ]); - break; - } - $this->assertEquals($new_operation_operationtype, $options->getValue()); - } - - if ($new_operation_operationtype === 'Reboot' && $eventsource !== EVENT_SOURCE_SERVICE) { - $this->zbxTestTextPresent(['Target list', 'Current host', 'Host', 'Host group']); - $this->query('id:operation-command-chst')->one()->isSelected(false); - $this->zbxTestAssertVisibleId('operation_opcommand_hst__hostid'); - $this->zbxTestAssertVisibleId('operation_opcommand_grp__groupid'); - } - else { - $this->zbxTestAssertElementNotPresentId('opCmdList'); - $this->zbxTestAssertElementNotPresentXpath('//li[@id="operation-command-targets"]//label[text()="Target list"]'); - $this->zbxTestAssertElementNotPresentXpath('//li[@id="operation-command-script-target"]//label[text()="Execute on"]'); - } - - if ($new_operation_operationtype == 'Send message') { - $this->zbxTestTextPresent([ - 'Send to user groups', 'User group', 'Action', - 'Send to users' - ]); - $this->zbxTestAssertVisibleXpath('//tr[@id=\'operation-message-user-groups-footer\']//button[@class=\'btn-link\']'); - $this->zbxTestAssertElementText('//tr[@id=\'operation-message-user-groups-footer\']//button[@class=\'btn-link\']', 'Add'); - $this->zbxTestAssertVisibleXpath('//tr[@id=\'operation-message-users-footer\']//button[@class=\'btn-link\']'); - $this->zbxTestAssertElementText('//tr[@id=\'operation-message-users-footer\']//button[@class=\'btn-link\']', 'Add'); - - $this->zbxTestTextPresent('Send only to'); - $this->zbxTestAssertVisibleId('operation-opmessage-mediatypeid'); - $this->zbxTestDropdownAssertSelected('operation[opmessage][mediatypeid]', '- All -'); - $this->zbxTestDropdownHasOptions('operation[opmessage][mediatypeid]', [ - '- All -', - 'Email', - 'SMS' - ]); - - $this->zbxTestTextPresent('Custom message'); - $this->zbxTestAssertElementPresentId('operation_opmessage_default_msg'); - $this->zbxTestAssertElementPresentXpath('//input[@type=\'checkbox\' and @id=\'operation_opmessage_default_msg\']'); - if ($new_operation_opmessage_custom_msg == 'checked') { - $this->assertTrue($this->zbxTestCheckboxSelected('operation_opmessage_default_msg')); - } - else { - $this->assertFalse($this->zbxTestCheckboxSelected('operation_opmessage_default_msg')); - } - } - else { - $this->zbxTestAssertElementNotPresentId('addusrgrpbtn'); - $this->zbxTestAssertElementNotPresentId('adduserbtn'); - $this->zbxTestAssertElementNotPresentXpath('//z-select[@name=\'operation[opmessage][mediatypeid]\']'); - $this->zbxTestAssertElementNotPresentId('operation_opmessage_default_msg'); - } - - switch ($new_operation_opmessage_custom_msg) { - case 'unchecked': - $this->zbxTestAssertNotVisibleId('operation_opmessage_subject'); - $this->zbxTestAssertNotVisibleId('operation_opmessage_message'); - break; - case 'checked': - $this->zbxTestTextPresent('Subject'); - $this->zbxTestAssertVisibleId('operation_opmessage_subject'); - $this->zbxTestAssertAttribute('//input[@id=\'operation_opmessage_subject\']', 'maxlength', 255); - - $this->zbxTestTextPresent('Message'); - $this->zbxTestAssertVisibleId('operation_opmessage_message'); - $this->zbxTestAssertAttribute('//textarea[@id=\'operation_opmessage_message\']', 'rows', 7); - break; - default: - $this->zbxTestAssertElementNotPresentId('operation_opmessage_subject'); - $this->zbxTestAssertElementNotPresentId('operation_opmessage_message'); - break; - } - - if ($eventsource == EVENT_SOURCE_TRIGGERS && $new_operation_operationtype != null) { - $this->zbxTestTextPresent(['Conditions', 'Label', 'Name', 'Action']); - - if ($add_opcondition == null) { - $this->zbxTestAssertVisibleXpath('//div[@id="operationTab"]//button[text()="Add"]'); - } - else { - $this->zbxTestTextPresent('New condition'); - $this->query('xpath://div[contains(@class, "overlay-dialogue modal")][2]'. - '//button[text()="Cancel"]')->one()->waitUntilVisible(); - - $this->zbxTestAssertVisibleXpath('//z-select[@id="condition-type"]'); - $this->zbxTestDropdownAssertSelected('condition_type', 'Event acknowledged'); - $this->zbxTestDropdownHasOptions('condition_type', ['Event acknowledged']); - - $this->zbxTestAssertVisibleXpath('//div[contains(@class, "overlay-dialogue modal")]'. - '//label[text()="equals"]'); - $this->zbxTestAssertVisibleXpath('//div[contains(@class, "overlay-dialogue modal")]'. - '//ul[@id="value" and @class="radio-list-control"]'); - $this->zbxTestAssertElementPresentXpath('//label[text()="No"]/../input[@checked]'); - $this->zbxTestClickXpathWait('//div[contains(@class, "overlay-dialogue modal")][2]'. - '//button[text()="Add"]'); - $this->zbxTestWaitUntilElementNotVisible(WebDriverBy::xpath('//div[contains(@class, "overlay-dialogue '. - 'modal")][2]')); - } - } - else { - $this->zbxTestAssertElementNotPresentXpath('//li[@id="operation-condition-list"]'); - $this->zbxTestAssertElementNotPresentXpath('//tr[@id="operation-condition-list-footer"]'); - } - - switch ($new_operation_operationtype) { - case 'Add to host group': - case 'Remove from host group': - $this->zbxTestAssertElementPresentXpath('//div[@id=\'operation_opgroup__groupid\']/input'); - $this->zbxTestAssertElementNotPresentXpath('//div[@id=\'operation_optemplate__templateid\']/input'); - break; - case 'Link to template': - case 'Unlink from template': - $this->zbxTestAssertElementPresentXpath('//div[@id=\'operation_optemplate__templateid\']/input'); - $this->zbxTestAssertElementNotPresentXpath('//div[@id=\'operation_opgroup__groupid\']/input'); - break; - default: - $this->zbxTestAssertElementNotPresentXpath('//div[@id=\'operation_groupids_\']/input'); - $this->zbxTestAssertElementNotPresentXpath('//div[@id=\'operation_templateids_\']/input'); - break; - } - - if ($new_operation_operationtype != null) { - $this->zbxTestAssertVisibleXpath('//div[@class="overlay-dialogue-footer"]//button[text()="Add"]'); - $this->zbxTestAssertVisibleXpath('//div[@class="overlay-dialogue-footer"]//button[text()="Cancel"]'); - } - else { - $this->zbxTestAssertElementNotPresentXpath('//div[@id="operationTab"]//button[contains(@onclick,"add_operation")]'); - $this->zbxTestAssertElementNotPresentXpath('//div[@id="operationTab"]//button[contains(@onclick,"cancel_new_operation")]'); - } - - if (CTestArrayHelper::get($data, 'recovery_msg', false)) { - $this->checkRecoveryUpdateOperations($recovery_field, $eventsource); - } - - if (CTestArrayHelper::get($data, 'acknowledge_msg', false)) { - $this->checkRecoveryUpdateOperations($update_field, $eventsource); - } - - $this->zbxTestAssertVisibleId('add'); - $this->zbxTestAssertAttribute('//button[@id="add" and @type="submit"]', 'value', 'Add'); - - $this->zbxTestAssertVisibleId('cancel'); - $this->zbxTestAssertAttribute('//button[@id=\'cancel\']', 'name', 'cancel'); - } - - /* - * Function that checks possible operation types and custom message related fields for recovery and update operations. - */ - private function checkRecoveryUpdateOperations($operation_field, $eventsource) { - $operation_field->query('button:Add')->one()->click(); - COverlayDialogElement::find()->one()->waitUntilReady(); - $operation_details = $this->query('name:popup.operation')->asForm()->one(); - // Check available operation types depending on event source and the selected operation type. - $message_types = ($eventsource === EVENT_SOURCE_INTERNAL) - ? ['Send message', 'Notify all involved'] - : ['Send message', 'Notify all involved', 'Reboot', 'Selenium script']; - $this->assertEquals($message_types, $operation_details->query('id:operation-type-select') - ->asDropdown()->one()->getOptions()->asText()); - $this->assertEquals('Send message', $operation_details->getField('Operation')->getValue()); - // Make sure that Custom message is unchecked and that message related fields are not visible. - $this->assertFalse($operation_details->getField('Custom message')->getValue()); - $this->zbxTestTextNotVisible(['Subject','Message']); - // Set the Custom message option and check Subject and Message fields. - $operation_details->getField('Custom message')->set(true); - $this->assertEquals(255, $operation_details->getField('Subject')->waitUntilVisible()->getAttribute('maxlength')); - $this->assertFalse($operation_details->getField('Message')->isAttributePresent('maxlength')); - COverlayDialogElement::find()->one()->close(); - } - - public static function update() { - return CDBHelper::getDataProvider('SELECT name, eventsource FROM actions'); - } - - public static function updateServiceAction() { - return [ - [ - [ - 'name' => self::$action_name, - 'eventsource' => '4' - ] - ] - ]; - } - - /** - * @dataProvider update - * @dataProvider updateServiceAction - */ - public function testFormAction_SimpleUpdate($data) { - $name = $data['name']; - $eventsource = $data['eventsource']; - - if ($name == 'Auto discovery. Linux servers.') { - $sqlActions = 'SELECT actionid, name, eventsource, evaltype, status FROM actions ORDER BY actionid'; - } - else { - $sqlActions = 'SELECT * FROM actions ORDER BY actionid'; - } - $oldHashActions = CDBHelper::getHash($sqlActions); - - $this->page->login()->open('actionconf.php?eventsource='.$eventsource); - $this->zbxTestClickLinkTextWait($name); - $this->zbxTestClickWait('update'); - $this->zbxTestCheckTitle('Configuration of actions'); - - $this->zbxTestCheckHeader($this->event_sources[$data['eventsource']]); - $this->zbxTestWaitUntilMessageTextPresent('msg-good', 'Action updated'); - $this->zbxTestTextPresent([ - 'Action updated', - 'Actions', - $name - ]); - - $this->assertEquals($oldHashActions, CDBHelper::getHash($sqlActions)); - } - - public static function create() { - return [ - [ - [ - 'expected' => ACTION_GOOD, - 'eventsource' => EVENT_SOURCE_TRIGGERS, - 'name' => 'TestFormAction Triggers 001', - 'esc_period' => '123', - 'conditions' => [ - [ - 'Type' => CFormElement::RELOADABLE_FILL('Trigger name'), - 'Value' => 'trigger' - ], - [ - 'Type' => CFormElement::RELOADABLE_FILL('Trigger severity'), - 'Severity' => 'Warning' - ], - [ - 'Type' => CFormElement::RELOADABLE_FILL('Tag name'), - 'Operator' => 'does not contain', - 'Tag' => 'Does not contain Tag' - ] - ], - 'expected conditions' => [ - 'A' => 'Tag name does not contain Does not contain Tag', - 'B' => 'Trigger severity equals Warning', - 'C' => 'Trigger name contains trigger' - ], - 'operations' => [ - [ - 'type' => 'Send message', - 'media' => 'Email' - ], - [ - 'type' => 'Reboot' - ] - ] - ] - ], - [ - [ - 'expected' => ACTION_BAD, - 'eventsource' => EVENT_SOURCE_TRIGGERS, - 'name' => '', - 'esc_period' => '123', - 'errors' => [ - 'Incorrect value for field "Name": cannot be empty.' - ] - ] - ], - [ - [ - 'expected' => ACTION_GOOD, - 'eventsource' => EVENT_SOURCE_DISCOVERY, - 'name' => 'TestFormAction Discovery 001', - 'conditions' => [ - [ - 'Type' => CFormElement::RELOADABLE_FILL('Service type'), - 'Service type' => 'FTP' - ], - [ - 'Type' => CFormElement::RELOADABLE_FILL('Received value'), - 'Operator' => 'does not contain', - 'Value' => 'Received value' - ] - ], - 'expected conditions' => [ - 'A' => 'Received value does not contain Received value', - 'B' => 'Service type equals FTP' - ], - 'operations' => [ - [ - 'type' => 'Send message', - 'media' => 'Email' - ], - [ - 'type' => 'Reboot' - ] - ] - ] - ], - [ - [ - 'expected' => ACTION_BAD, - 'eventsource' => EVENT_SOURCE_DISCOVERY, - 'name' => '', - 'errors' => [ - 'Incorrect value for field "Name": cannot be empty.' - ] - ] - ], - [ - [ - 'expected' => ACTION_GOOD, - 'eventsource' => EVENT_SOURCE_AUTOREGISTRATION, - 'name' => 'TestFormAction Autoregistration 001', - 'conditions' => [ - [ - 'Type' => CFormElement::RELOADABLE_FILL('Host name'), - 'Value' => 'Zabbix' - ], - [ - 'Type' => CFormElement::RELOADABLE_FILL('Host metadata'), - 'Operator'=> 'does not contain', - 'Value' => 'Zabbix' - ] - ], - 'expected conditions' => [ - 'A' => 'Host metadata does not contain Zabbix', - 'B' => 'Host name contains Zabbix' - ], - 'operations' => [ - [ - 'type' => 'Send message', - 'media' => 'Email' - ], - [ - 'type' => 'Reboot' - ] - ] - ] - ], - [ - [ - 'expected' => ACTION_BAD, - 'eventsource' => EVENT_SOURCE_AUTOREGISTRATION, - 'name' => '', - 'errors' => [ - 'Incorrect value for field "Name": cannot be empty.' - ] - ] - ], - [ - [ - 'expected' => ACTION_GOOD, - 'eventsource' => EVENT_SOURCE_INTERNAL, - 'name' => 'TestFormAction Internal 001', - 'esc_period' => '123', - 'conditions' => [ - [ - 'Type' => CFormElement::RELOADABLE_FILL('Event type'), - 'Event type' => 'Trigger in "unknown" state' - ], - [ - 'Type' => CFormElement::RELOADABLE_FILL('Tag name'), - 'Operator' => 'does not contain', - 'Tag' => 'Does not contain Tag' - ] - ], - 'expected conditions' => [ - 'A' => 'Tag name does not contain Does not contain Tag', - 'B' => 'Event type equals Trigger in "unknown" state' - ], - 'operations' => [ - [ - 'type' => 'Send message', - 'media' => 'Email' - ] - ], - 'expected operations' => [ - 'Send message to users: Admin (Zabbix Administrator) via Email' - ] - ] - ], - [ - [ - 'expected' => ACTION_BAD, - 'eventsource' => EVENT_SOURCE_INTERNAL, - 'name' => '', - 'esc_period' => '123', - 'errors' => [ - 'Incorrect value for field "Name": cannot be empty.' - ] - ] - ], - [ - [ - 'expected' => ACTION_GOOD, - 'eventsource' => EVENT_SOURCE_SERVICE, - 'name' => 'Test Service for Create operation', - 'esc_period' => '666', - 'conditions' => [ - [ - 'Type' => CFormElement::RELOADABLE_FILL('Service'), - 'Operator' => 'does not equal', - 'Services' => 'Reference service' - ], - [ - 'Type' => CFormElement::RELOADABLE_FILL('Service name'), - 'Value' => 'Part of service name' - ], - [ - 'Type' => CFormElement::RELOADABLE_FILL('Service tag name'), - 'Operator' => 'contains', - 'Tag' => 'Service tag name' - ], - [ - 'Type' => CFormElement::RELOADABLE_FILL('Service tag value'), - 'Tag' => 'Service tag', - 'Operator' => 'does not contain', - 'Value' => 'Service tag value' - ] - ], - 'expected conditions' => [ - 'A' => 'Service name contains Part of service name', - 'B' => 'Service does not equal Reference service', - 'C' => 'Value of tag Service tag does not contain Service tag value', - 'D' => 'Tag name contains Service tag name' - ], - 'operations' => [ - [ - 'type' => 'Send message', - 'user_group' => 'Selenium user group' - ], - [ - 'type' => 'Reboot' - ] - ], - 'expected operations' => [ - 'Send message to user groups: Selenium user group via all media', - 'Run script "Reboot" on Zabbix server' - ] - ] - ], - [ - [ - 'expected' => ACTION_BAD, - 'eventsource' => EVENT_SOURCE_SERVICE, - 'name' => '', - 'esc_period' => '666', - 'errors' => [ - 'Incorrect value for field "Name": cannot be empty.' - ] - ] - ], - [ - [ - 'expected' => ACTION_BAD, - 'eventsource' => EVENT_SOURCE_SERVICE, - 'name' => 'No operations action', - 'esc_period' => '666', - 'error_title' => 'Cannot add action', - 'errors' => [ - 'No operations defined for action "No operations action".' - ] - ] - ] - ]; - } - - /** - * @dataProvider create - */ - public function testFormAction_SimpleCreate($data) { - $this->zbxTestLogin('actionconf.php?form=1&eventsource='.$data['eventsource']); - $this->zbxTestCheckTitle('Configuration of actions'); - $this->zbxTestCheckHeader('Actions'); - - $action_form = $this->query('id:action-form')->asForm()->one(); - $action_form->getField('Name')->fill($data['name']); - - if (array_key_exists('conditions', $data)) { - foreach ($data['conditions'] as $condition) { - $action_form->query('xpath:.//table[@id="conditionTable"]//button[text()="Add"]')->one()->click(); - - COverlayDialogElement::find()->waitUntilReady()->one(); - $condition_form = $this->query('id:popup.condition')->asForm()->one(); - $condition_form->fill($condition); - $condition_form->submit(); - COverlayDialogElement::ensureNotPresent(); - } - } - - if (isset($data['operations'])) { - $action_form->selectTab('Operations'); - - foreach ($data['operations'] as $operation) { - $action_form->query('xpath:.//table[@id="op-table"]//button[text()="Add"]')->one()->click(); - - COverlayDialogElement::find()->waitUntilReady()->one(); - $operation_form = $this->query('id:popup.operation')->asForm()->one(); - - if ($data['eventsource'] !== EVENT_SOURCE_INTERNAL) { - $operation_form->getField('Operation')->fill($operation['type']); - } - - if ($operation['type'] === 'Send message') { - if (array_key_exists('user_group', $operation)) { - $field = 'Send to user groups'; - $value = $operation['user_group']; - } - else { - $field = 'Send to users'; - $value = 'Admin'; - } - $operation_form->getField($field)->query('button:Add')->one()->click(); - $list = COverlayDialogElement::find()->all()->last(); - $list->query('link', $value)->waitUntilClickable()->one()->click(); - } - elseif ($data['eventsource'] !== EVENT_SOURCE_SERVICE) { - $operation_form->query('id:operation-command-chst')->asCheckbox()->waitUntilVisible()->one()->check(); - } - - if (array_key_exists('media', $operation)) { - $operation_form->getField('Send only to')->fill($operation['media']); - } - - $operation_form->submit(); - COverlayDialogElement::ensureNotPresent(); - } - - if (array_key_exists('esc_period', $data)) { - $action_form->getField('Default operation step duration')->fill($data['esc_period']); - } - } - - $action_form->submit(); - $sql = 'SELECT actionid FROM actions WHERE name='.zbx_dbstr($data['name']); - - if ($data['expected'] === ACTION_GOOD) { - $this->page->waitUntilReady(); - $this->assertMessage(TEST_GOOD, 'Action added'); - $this->assertEquals(1, CDBHelper::getCount($sql), 'Action has not been created in the DB.'); - - $this->query('link', $data['name'])->waitUntilClickable()->one()->click(); - $this->page->waitUntilReady(); - - if (array_key_exists('conditions', $data)) { - $condition_table = $this->query('id:conditionTable')->waitUntilVisible()->asTable()->one(); - - foreach($data['expected conditions'] as $label => $result) { - $this->assertEquals($result, $condition_table->findRow('Label', $label)->getColumn('Name')->getText()); - } - } - - if (array_key_exists('operations', $data)) { - $expected_operations = [ - 'Send message to users: Admin (Zabbix Administrator) via Email', - 'Run script "Reboot" on current host' - ]; - if (array_key_exists('expected operations', $data)) { - $expected_operations = $data['expected operations']; - } - $action_form->invalidate(); - $action_form->selectTab('Operations'); - $operations_table = $this->query('id:op-table')->waitUntilVisible()->asTable()->one(); - - $saved_operations = []; - $row_count = count($expected_operations); - for ($i = 0; $i < $row_count; $i++) { - $saved_operations[] = $operations_table->getRow($i)->getColumn('Details')->getText(); - } - $this->assertEquals($expected_operations, $saved_operations); - } - } - else { - $title = CTestArrayHelper::get($data, 'error_title', 'Page received incorrect data'); - $this->assertMessage(TEST_BAD, $title, $data['errors']); - $this->assertEquals(0, CDBHelper::getCount($sql), 'Action has not been created in the DB.'); - } - } - - public function testFormAction_Create() { - $this->zbxTestLogin('actionconf.php?form=1&eventsource=0'); - $this->zbxTestCheckTitle('Configuration of actions'); - - $this->zbxTestInputTypeWait('name', 'action test'); - - // adding conditions - $this->zbxTestClickXpathWait('//button[text()="Add" and contains(@onclick, "popup.condition.actions")]'); - $this->zbxTestLaunchOverlayDialog('New condition'); - $this->zbxTestDropdownSelectWait('condition_type', 'Trigger name'); - $this->zbxTestInputTypeWait('value', 'trigger'); - $this->zbxTestClickXpath("//div[@class='overlay-dialogue-footer']//button[text()='Add']"); - $this->zbxTestAssertElementText("//tr[@id='conditions_0']/td[2]", 'Trigger name contains trigger'); - - $this->zbxTestClickXpathWait('//button[text()="Add" and contains(@onclick, "popup.condition.actions")]'); - $this->zbxTestLaunchOverlayDialog('New condition'); - $this->zbxTestDropdownSelectWait('condition_type', 'Trigger severity'); - $this->zbxTestClickXpathWait('//label[text()="Average"]'); - $this->zbxTestClickXpath("//div[@class='overlay-dialogue-footer']//button[text()='Add']"); - $this->zbxTestAssertElementText("//tr[@id='conditions_1']/td[2]", 'Trigger severity equals Average'); - - $this->zbxTestClickXpathWait('//button[text()="Add" and contains(@onclick, "popup.condition.actions")]'); - $this->zbxTestLaunchOverlayDialog('New condition'); - $this->zbxTestWaitUntilElementVisible(WebDriverBy::id('condition-type')); - $this->zbxTestDropdownSelectWait('condition_type', 'Tag name'); - $this->zbxTestInputTypeWait('value', 'zabbix'); - $this->zbxTestClickXpath("//div[@class='overlay-dialogue-footer']//button[text()='Add']"); - $this->zbxTestAssertElementText("//tr[@id='conditions_2']/td[2]", 'Tag name equals zabbix'); - - // adding operations - $this->zbxTestTabSwitch('Operations'); - $this->zbxTestClickXpathWait('//div[@id="operationTab"]//button[text()="Add"]'); - - $this->zbxTestClickXpathWait('//tr[@id="operation-message-user-groups-footer"]//button'); - $this->zbxTestLaunchOverlayDialog('User groups'); - $this->zbxTestCheckboxSelect('item_7'); - $this->zbxTestCheckboxSelect('item_11'); - $this->zbxTestClickXpath('//div[@class="overlay-dialogue-footer"]//button[text()="Select"]'); - - $this->zbxTestClickXpath('//tr[@id="operation-message-users-footer"]//button'); - $this->zbxTestLaunchOverlayDialog('Users'); - $this->zbxTestCheckboxSelect('item_1'); - $this->zbxTestClickXpath('//div[@class="overlay-dialogue-footer"]//button[text()="Select"]'); - - $this->zbxTestDropdownSelect('operation[opmessage][mediatypeid]', 'SMS'); - $this->zbxTestClickXpathWait('//div[@class="overlay-dialogue-footer"]//button[text()="Add"]'); - $this->zbxTestAssertElementText("//tr[@id='operations_0']//span", - "Send message to users: Admin (Zabbix Administrator) via SMS ". - "Send message to user groups: Enabled debug mode, Zabbix administrators via SMS"); - - $this->zbxTestClickXpathWait('//div[@id="operationTab"]//button[text()="Add"]'); - $this->zbxTestWaitUntilElementVisible(WebDriverBy::xpath('//div[@class="overlay-dialogue-footer"]//button[text()="Add"]')); - $this->zbxTestDropdownSelectWait('operation-type-select', 'Reboot'); - - // add target current host - $this->zbxTestCheckboxSelect('operation-command-chst'); - - // add target host Zabbix server - $this->zbxTestClickButtonMultiselect('operation_opcommand_hst__hostid'); - $this->zbxTestLaunchOverlayDialog('Hosts'); - $this->zbxTestClickButtonMultiselect('popup_host_group'); - $this->zbxTestLaunchOverlayDialog('Host groups'); - $this->query('link:Zabbix servers')->one()->waitUntilClickable()->click(); - - $this->zbxTestClickLinkTextWait('Simple form test host'); - // add target group Zabbix servers - $this->zbxTestClickButtonMultiselect('operation_opcommand_grp__groupid'); - $this->zbxTestLaunchOverlayDialog('Host groups'); - $this->zbxTestClickLinkTextWait('Zabbix servers'); - - $this->zbxTestClickXpathWait('//div[@class="overlay-dialogue-footer"]//button[text()="Add"]'); - COverlayDialogElement::ensureNotPresent(); - $this->page->waitUntilReady(); - $this->zbxTestWaitUntilElementClickable(WebDriverBy::id('add')); - $this->zbxTestAssertElementText("//tr[@id='operations_0']//span", - "Send message to users: Admin (Zabbix Administrator) via SMS ". - "Send message to user groups: Enabled debug mode, Zabbix administrators via SMS"); - $this->zbxTestAssertElementText("//tr[@id='operations_1']//span", - "Run script \"Reboot\" on current host ". - "Run script \"Reboot\" on hosts: Simple form test host ". - "Run script \"Reboot\" on host groups: Zabbix servers"); - - $this->zbxTestClickXpathWait('//div[@id="operationTab"]//button[text()="Add"]'); - $this->zbxTestWaitUntilElementVisible(WebDriverBy::xpath('//div[@class="overlay-dialogue-footer"]//button[text()="Add"]')); - $this->zbxTestInputTypeOverwrite('operation_esc_step_to', '2'); - $this->zbxTestDropdownSelectWait('operation-type-select', 'Reboot'); - $this->zbxTestCheckboxSelect('operation-command-chst'); - - $this->zbxTestClickXpathWait('//div[@class="overlay-dialogue-footer"]//button[text()="Add"]'); - $this->page->waitUntilReady(); - $this->zbxTestAssertElementText("//tr[@id='operations_0']//span", - "Send message to users: Admin (Zabbix Administrator) via SMS ". - "Send message to user groups: Enabled debug mode, Zabbix administrators via SMS"); - $this->zbxTestAssertElementText("//tr[@id='operations_1']//span", - "Run script \"Reboot\" on current host ". - "Run script \"Reboot\" on hosts: Simple form test host ". - "Run script \"Reboot\" on host groups: Zabbix servers"); - $this->zbxTestAssertElementText("//tr[@id='operations_2']//span", - "Run script \"Reboot\" on current host"); - $this->zbxTestAssertElementText('//tr[@id="operations_2"]//td', '1 - 2'); - - $this->zbxTestInputTypeOverwrite('esc_period', '123'); - // Fire onchange event. - $this->webDriver->executeScript('var event = document.createEvent("HTMLEvents");'. - 'event.initEvent("change", false, true);'. - 'document.getElementById("esc_period").dispatchEvent(event);' - ); - $this->zbxTestWaitForPageToLoad(); - - $this->zbxTestAssertElementValue('esc_period', '123'); - $this->zbxTestClickXpath('//div[@id="operationTab"]//button[text()="Add"]'); - - $this->zbxTestWaitUntilElementClickable(WebDriverBy::xpath('//tr[@id="operation-message-users-footer"]//button')); - - $this->zbxTestClickXpath('//tr[@id="operation-message-users-footer"]//button'); - $this->page->query('xpath://div[contains(@class, "overlay-dialogue modal")][2]'. - '//button[text()="Cancel"]')->waitUntilClickable()->one()->click(); - $this->zbxTestClickXpath('//div[@class="overlay-dialogue-footer"]//button[text()="Cancel"]'); - $this->zbxTestWaitUntilElementClickable(WebDriverBy::id('add')); - - $this->zbxTestDoubleClickBeforeMessage('add', 'filter_name'); - $this->zbxTestWaitUntilMessageTextPresent('msg-good', 'Action added'); - - $sql = "SELECT actionid FROM actions WHERE name='action test'"; - $this->assertEquals(1, CDBHelper::getCount($sql), 'Action has not been created in the DB.'); - } - - public function testFormAction_Clone() { - $id = self::$actionid; - $sql = 'SELECT a.eventsource, a.evaltype, a.status, a.esc_period, a.formula, a.pause_suppressed, '. - 'c.conditiontype, c.operator, c.value, c.value2, '. - 'o.operationtype, o.esc_period, o.esc_step_from, o.esc_step_to, o.evaltype, o.recovery '. - 'FROM actions a '. - 'INNER JOIN conditions c ON c.actionid = a.actionid '. - 'INNER JOIN operations o on o.actionid = c.actionid '. - 'WHERE a.actionid='.zbx_dbstr($id).' ORDER BY o.operationid'; - - $original_hash = CDBHelper::getHash($sql); - - $this->page->login()->open('actionconf.php?eventsource=4&form=update&actionid='.$id)->waitUntilReady(); - $this->query('button:Clone')->waitUntilClickable()->one()->click(); - - $form = $this->query('id:action-form')->asForm()->one(); - $form->getField('Name')->fill(self::$action_name.' Clone'); - $form->submit(); - $this->assertMessage(TEST_GOOD, 'Action added'); - - $id = CDBHelper::getValue('SELECT actionid FROM actions WHERE name='.zbx_dbstr(self::$action_name.' Clone')); - $this->assertEquals($original_hash, CDBHelper::getHash($sql)); - } -} diff --git a/ui/tests/selenium/testPageActions.php b/ui/tests/selenium/testPageActions.php deleted file mode 100644 index b12e0550af3..00000000000 --- a/ui/tests/selenium/testPageActions.php +++ /dev/null @@ -1,321 +0,0 @@ - 'Trigger actions', - EVENT_SOURCE_DISCOVERY => 'Discovery actions', - EVENT_SOURCE_AUTOREGISTRATION => 'Autoregistration actions', - EVENT_SOURCE_INTERNAL => 'Internal actions' - ]; - - private function calculateHash($actionid) { - $this->sqlHashAction = 'SELECT actionid,name,eventsource,evaltype,status,formula,pause_suppressed FROM actions ' - . 'WHERE actionid='.$actionid; - $this->oldHashAction = CDBHelper::getHash($this->sqlHashAction); - $this->sqlHashConditions = 'SELECT * FROM conditions WHERE actionid='.$actionid.' AND actionid>2 ORDER BY conditionid'; - $this->oldHashConditions = CDBHelper::getHash($this->sqlHashConditions); - $this->sqlHashOperations = 'SELECT * FROM operations WHERE actionid='.$actionid.' ORDER BY operationid'; - $this->oldHashOperations = CDBHelper::getHash($this->sqlHashOperations); - $this->sqlHashOpMessage = - 'SELECT om.* FROM opmessage om,operations o'. - ' WHERE om.operationid=o.operationid'. - ' AND o.actionid='.$actionid. - ' ORDER BY om.operationid'; - $this->oldHashOpMessage = CDBHelper::getHash($this->sqlHashOpMessage); - $this->sqlHashOpMessageGrp = - 'SELECT omg.* FROM opmessage_grp omg,operations o'. - ' WHERE omg.operationid=o.operationid'. - ' AND o.actionid='.$actionid. - ' ORDER BY omg.opmessage_grpid'; - $this->oldHashOpMessageGrp = CDBHelper::getHash($this->sqlHashOpMessageGrp); - $this->sqlHashOpMessageUsr = - 'SELECT omu.* FROM opmessage_usr omu,operations o'. - ' WHERE omu.operationid=o.operationid'. - ' AND o.actionid='.$actionid. - ' ORDER BY omu.opmessage_usrid'; - $this->oldHashOpMessageUsr = CDBHelper::getHash($this->sqlHashOpMessageUsr); - $this->sqlHashOpCommand = - 'SELECT oc.* FROM opcommand oc,operations o'. - ' WHERE oc.operationid=o.operationid'. - ' AND o.actionid='.$actionid. - ' ORDER BY oc.operationid'; - $this->oldHashOpCommand = CDBHelper::getHash($this->sqlHashOpCommand); - $this->sqlHashOpCommandHst = - 'SELECT och.* FROM opcommand_hst och,operations o'. - ' WHERE och.operationid=o.operationid'. - ' AND o.actionid='.$actionid. - ' ORDER BY och.opcommand_hstid'; - $this->oldHashOpCommandHst = CDBHelper::getHash($this->sqlHashOpCommandHst); - $this->sqlHashOpCommandGrp = - 'SELECT ocg.* FROM opcommand_grp ocg,operations o'. - ' WHERE ocg.operationid=o.operationid'. - ' AND o.actionid='.$actionid. - ' ORDER BY ocg.opcommand_grpid'; - $this->oldHashOpCommandGrp = CDBHelper::getHash($this->sqlHashOpCommandGrp); - $this->sqlHashOpGroup = - 'SELECT og.* FROM opgroup og,operations o'. - ' WHERE og.operationid=o.operationid'. - ' AND o.actionid='.$actionid. - ' ORDER BY og.opgroupid'; - $this->oldHashOpGroup = CDBHelper::getHash($this->sqlHashOpGroup); - $this->sqlHashOpTemplate = - 'SELECT ot.* FROM optemplate ot,operations o'. - ' WHERE ot.operationid=o.operationid'. - ' AND o.actionid='.$actionid. - ' ORDER BY ot.optemplateid'; - $this->oldHashOpTemplate = CDBHelper::getHash($this->sqlHashOpTemplate); - $this->sqlHashOpConditions = - 'SELECT oc.* FROM opconditions oc,operations o'. - ' WHERE oc.operationid=o.operationid'. - ' AND o.actionid='.$actionid. - ' ORDER BY oc.opconditionid'; - $this->oldHashOpConditions = CDBHelper::getHash($this->sqlHashOpConditions); - } - - private function verifyHash() { - $this->assertEquals($this->oldHashAction, CDBHelper::getHash($this->sqlHashAction)); - $this->assertEquals($this->oldHashConditions, CDBHelper::getHash($this->sqlHashConditions)); - $this->assertEquals($this->oldHashOperations, CDBHelper::getHash($this->sqlHashOperations)); - $this->assertEquals($this->oldHashOpMessage, CDBHelper::getHash($this->sqlHashOpMessage)); - $this->assertEquals($this->oldHashOpMessageGrp, CDBHelper::getHash($this->sqlHashOpMessageGrp)); - $this->assertEquals($this->oldHashOpMessageUsr, CDBHelper::getHash($this->sqlHashOpMessageUsr)); - $this->assertEquals($this->oldHashOpCommand, CDBHelper::getHash($this->sqlHashOpCommand)); - $this->assertEquals($this->oldHashOpCommandHst, CDBHelper::getHash($this->sqlHashOpCommandHst)); - $this->assertEquals($this->oldHashOpCommandGrp, CDBHelper::getHash($this->sqlHashOpCommandGrp)); - $this->assertEquals($this->oldHashOpGroup, CDBHelper::getHash($this->sqlHashOpGroup)); - $this->assertEquals($this->oldHashOpTemplate, CDBHelper::getHash($this->sqlHashOpTemplate)); - $this->assertEquals($this->oldHashOpConditions, CDBHelper::getHash($this->sqlHashOpConditions)); - } - - public static function allEventSources() { - return [ - [EVENT_SOURCE_TRIGGERS], - [EVENT_SOURCE_DISCOVERY], - [EVENT_SOURCE_AUTOREGISTRATION], - [EVENT_SOURCE_INTERNAL] - ]; - } - - public static function allActions() { - return CDBHelper::getDataProvider( - 'SELECT actionid,eventsource,name,status'. - ' FROM actions'. - ' ORDER BY actionid' - ); - } - - /** - * @dataProvider allEventSources - */ - public function testPageActions_CheckLayout($eventsource) { - $this->zbxTestLogin('actionconf.php?eventsource='.$eventsource); - $this->zbxTestCheckTitle('Configuration of actions'); - - $this->zbxTestCheckHeader($this->event_sources[$eventsource]); - $this->zbxTestTextPresent('Displaying'); - - $this->zbxTestTextPresent(['Name', 'Conditions', 'Operations', 'Status']); - - $dbResult = DBselect( - 'SELECT name,status'. - ' FROM actions'. - ' WHERE eventsource='.$eventsource. - ' ORDER BY actionid' - ); - - while ($dbRow = DBfetch($dbResult)) { - $statusStr = ($dbRow['status'] == ACTION_STATUS_ENABLED ? 'Enabled' : 'Disabled'); - - $this->zbxTestTextPresent([$dbRow['name'], $statusStr]); - } - - $this->zbxTestTextPresent(['Enable', 'Disable', 'Delete']); - } - - /** - * @dataProvider allActions - */ - public function testPageActions_SimpleUpdate($action) { - $this->calculateHash($action['actionid']); - - $this->zbxTestLogin('actionconf.php?eventsource='.$action['eventsource']); - $this->zbxTestClickLinkText($action['name']); - $this->zbxTestClickWait('update'); - $this->zbxTestCheckTitle('Configuration of actions'); - $this->zbxTestTextPresent('Action updated'); - $this->zbxTestTextPresent($action['name']); - - $this->verifyHash(); - } - - /** - * @dataProvider allActions - */ - public function testPageActions_SingleEnableDisable($action) { - $this->sqlHashAction = 'SELECT * FROM actions WHERE actionid<>'.$action['actionid'].' ORDER BY actionid'; - $this->oldHashAction = CDBHelper::getHash($this->sqlHashAction); - - $this->zbxTestLogin('actionconf.php?eventsource='.$action['eventsource']); - $this->zbxTestCheckTitle('Configuration of actions'); - - switch ($action['status']) { - case ACTION_STATUS_ENABLED: - $this->zbxTestClickXpathWait("//a[contains(@onclick,'actionid[]=".$action['actionid']."')]"); - $this->zbxTestTextPresent('Action disabled'); - $newStatus = ACTION_STATUS_DISABLED; - break; - case ACTION_STATUS_DISABLED: - $this->zbxTestClickXpath("//a[contains(@onclick,'actionid[]=".$action['actionid']."')]"); - $this->zbxTestTextPresent('Action enabled'); - $newStatus = ACTION_STATUS_ENABLED; - break; - default: - $this->assertTrue(false); - } - - $this->zbxTestCheckTitle('Configuration of actions'); - - $this->assertEquals(1, CDBHelper::getCount( - 'SELECT NULL'. - ' FROM actions'. - ' WHERE actionid='.$action['actionid']. - ' AND status='.$newStatus - )); - - $this->assertEquals($this->oldHashAction, CDBHelper::getHash($this->sqlHashAction)); - } - - /** - * @dataProvider allActions - */ - public function testPageActions_MassDisable($action) { - $this->sqlHashAction = 'SELECT * FROM actions WHERE actionid<>'.$action['actionid'].' ORDER BY actionid'; - $this->oldHashAction = CDBHelper::getHash($this->sqlHashAction); - - $this->zbxTestLogin('actionconf.php?eventsource='.$action['eventsource']); - $this->zbxTestCheckTitle('Configuration of actions'); - - $this->zbxTestCheckHeader($this->event_sources[$action['eventsource']]); - - $this->zbxTestCheckboxSelect('g_actionid_'.$action['actionid']); - $this->zbxTestClickButton('action.massdisable'); - - $this->zbxTestAcceptAlert(); - - $this->zbxTestCheckTitle('Configuration of actions'); - $this->zbxTestTextPresent('Action disabled'); - $this->zbxTestTextPresent('Disabled'); - - $this->assertEquals(1, CDBHelper::getCount( - 'SELECT NULL'. - ' FROM actions'. - ' WHERE actionid='.$action['actionid']. - ' AND status='.ACTION_STATUS_DISABLED - )); - - $this->assertEquals($this->oldHashAction, CDBHelper::getHash($this->sqlHashAction)); - } - - /** - * @dataProvider allActions - */ - public function testPageActions_MassEnable($action) { - $this->sqlHashAction = 'SELECT * FROM actions WHERE actionid<>'.$action['actionid'].' ORDER BY actionid'; - $this->oldHashAction = CDBHelper::getHash($this->sqlHashAction); - - $this->zbxTestLogin('actionconf.php?eventsource='.$action['eventsource']); - $this->zbxTestCheckTitle('Configuration of actions'); - - $this->zbxTestCheckHeader($this->event_sources[$action['eventsource']]); - - $this->zbxTestCheckboxSelect('g_actionid_'.$action['actionid']); - $this->zbxTestClickButton('action.massenable'); - - $this->zbxTestAcceptAlert(); - - $this->zbxTestCheckTitle('Configuration of actions'); - $this->zbxTestWaitUntilMessageTextPresent('msg-good', 'Action enabled'); - $this->zbxTestTextPresent('Enabled'); - - $this->assertEquals(1, CDBHelper::getCount( - 'SELECT NULL'. - ' FROM actions'. - ' WHERE actionid='.$action['actionid']. - ' AND status='.ACTION_STATUS_ENABLED - )); - - $this->assertEquals($this->oldHashAction, CDBHelper::getHash($this->sqlHashAction)); - } - - /** - * @dataProvider allActions - * @backupOnce actions - */ - public function testPageActions_MassDelete($action) { - $this->sqlHashAction = 'SELECT * FROM actions WHERE actionid<>'.$action['actionid'].' ORDER BY actionid'; - $this->oldHashAction = CDBHelper::getHash($this->sqlHashAction); - - $this->zbxTestLogin('actionconf.php?eventsource='.$action['eventsource']); - $this->zbxTestCheckTitle('Configuration of actions'); - - $this->zbxTestCheckHeader($this->event_sources[$action['eventsource']]); - - $this->zbxTestCheckboxSelect('g_actionid_'.$action['actionid']); - $this->zbxTestClickButton('action.massdelete'); - - $this->zbxTestAcceptAlert(); - - $this->zbxTestCheckTitle('Configuration of actions'); - $this->zbxTestWaitUntilMessageTextPresent('msg-good', 'Selected actions deleted'); - - $this->assertEquals(0, CDBHelper::getCount('SELECT * FROM actions WHERE actionid='.$action['actionid'])); - - $this->assertEquals($this->oldHashAction, CDBHelper::getHash($this->sqlHashAction)); - } -} -- cgit v1.2.3 From b315b63a5c1e2506acadc54ece38cbb5526bb7ba Mon Sep 17 00:00:00 2001 From: Larisa Grigorjeva Date: Thu, 30 Jun 2022 22:11:09 +0100 Subject: .......... [DEV-2073] reorganized tests vol. 4 --- ui/tests/selenium/SeleniumTests.php | 41 +- .../selenium/hosts/testFormHostLinkTemplates.php | 161 +++ ui/tests/selenium/hosts/testFormHostPrototype.php | 1088 ++++++++++++++++++ ui/tests/selenium/hosts/testPageHostInterfaces.php | 487 ++++++++ ui/tests/selenium/hosts/testPageHostPrototypes.php | 225 ++++ ui/tests/selenium/hosts/testPageHosts.php | 704 ++++++++++++ .../selenium/hosts/testPageMonitoringHosts.php | 1184 ++++++++++++++++++++ ui/tests/selenium/testFormHostLinkTemplates.php | 161 --- ui/tests/selenium/testFormHostPrototype.php | 1088 ------------------ ui/tests/selenium/testPageHostInterfaces.php | 487 -------- ui/tests/selenium/testPageHostPrototypes.php | 225 ---- ui/tests/selenium/testPageHosts.php | 704 ------------ ui/tests/selenium/testPageMonitoringHosts.php | 1184 -------------------- 13 files changed, 3872 insertions(+), 3867 deletions(-) create mode 100644 ui/tests/selenium/hosts/testFormHostLinkTemplates.php create mode 100644 ui/tests/selenium/hosts/testFormHostPrototype.php create mode 100644 ui/tests/selenium/hosts/testPageHostInterfaces.php create mode 100644 ui/tests/selenium/hosts/testPageHostPrototypes.php create mode 100644 ui/tests/selenium/hosts/testPageHosts.php create mode 100644 ui/tests/selenium/hosts/testPageMonitoringHosts.php delete mode 100644 ui/tests/selenium/testFormHostLinkTemplates.php delete mode 100644 ui/tests/selenium/testFormHostPrototype.php delete mode 100644 ui/tests/selenium/testPageHostInterfaces.php delete mode 100644 ui/tests/selenium/testPageHostPrototypes.php delete mode 100644 ui/tests/selenium/testPageHosts.php delete mode 100644 ui/tests/selenium/testPageMonitoringHosts.php diff --git a/ui/tests/selenium/SeleniumTests.php b/ui/tests/selenium/SeleniumTests.php index 0728a5fd9ab..974b9fcef28 100644 --- a/ui/tests/selenium/SeleniumTests.php +++ b/ui/tests/selenium/SeleniumTests.php @@ -58,6 +58,18 @@ require_once dirname(__FILE__).'/filterTabs/testFormFilterProblems.php'; require_once dirname(__FILE__).'/geomaps/testFormAdministrationGeneralGeomaps.php'; require_once dirname(__FILE__).'/geomaps/testGeomapWidgetScreenshots.php'; +// Hosts. +require_once dirname(__FILE__).'/hosts/testFormHostConfiguration.php'; +require_once dirname(__FILE__).'/hosts/testFormHostLinkTemplates.php'; +require_once dirname(__FILE__).'/hosts/testFormHostMonitoring.php'; +require_once dirname(__FILE__).'/hosts/testFormHostPrototype.php'; +require_once dirname(__FILE__).'/hosts/testFormHostStandalone.php'; +require_once dirname(__FILE__).'/hosts/testPageHostInterfaces.php'; +require_once dirname(__FILE__).'/hosts/testPageHostPrototypes.php'; +require_once dirname(__FILE__).'/hosts/testPageHosts.php'; +require_once dirname(__FILE__).'/hosts/testPageMonitoringHosts.php'; + + require_once dirname(__FILE__).'/testExecuteNow.php'; require_once dirname(__FILE__).'/testGraphAxis.php'; @@ -76,9 +88,6 @@ require_once dirname(__FILE__).'/testPageEventCorrelation.php'; require_once dirname(__FILE__).'/testPageGraphPrototypes.php'; require_once dirname(__FILE__).'/testPageHistory.php'; require_once dirname(__FILE__).'/testPageHostGraph.php'; -require_once dirname(__FILE__).'/testPageHostInterfaces.php'; -require_once dirname(__FILE__).'/testPageHostPrototypes.php'; -require_once dirname(__FILE__).'/testPageHosts.php'; require_once dirname(__FILE__).'/testPageInventory.php'; require_once dirname(__FILE__).'/items/testPageItems.php'; require_once dirname(__FILE__).'/items/testPageItemPrototypes.php'; @@ -89,7 +98,6 @@ require_once dirname(__FILE__).'/testPageMaintenance.php'; require_once dirname(__FILE__).'/testPageMaps.php'; require_once dirname(__FILE__).'/testPageMassUpdateItems.php'; require_once dirname(__FILE__).'/testPageMassUpdateItemPrototypes.php'; -require_once dirname(__FILE__).'/testPageMonitoringHosts.php'; require_once dirname(__FILE__).'/testPageNetworkDiscovery.php'; require_once dirname(__FILE__).'/lld/testPageLowLevelDiscovery.php'; require_once dirname(__FILE__).'/testPasswordComplexity.php'; @@ -128,12 +136,7 @@ require_once dirname(__FILE__).'/filterTabs/testFormFilterLatestData.php'; require_once dirname(__FILE__).'/filterTabs/testFormFilterProblems.php'; require_once dirname(__FILE__).'/testFormGraph.php'; require_once dirname(__FILE__).'/testFormGraphPrototype.php'; -require_once dirname(__FILE__).'/hosts/testFormHostConfiguration.php'; -require_once dirname(__FILE__).'/hosts/testFormHostMonitoring.php'; -require_once dirname(__FILE__).'/hosts/testFormHostStandalone.php'; require_once dirname(__FILE__).'/testFormHostGroup.php'; -require_once dirname(__FILE__).'/testFormHostLinkTemplates.php'; -require_once dirname(__FILE__).'/testFormHostPrototype.php'; require_once dirname(__FILE__).'/items/testFormItem.php'; require_once dirname(__FILE__).'/items/testFormItemHttpAgent.php'; require_once dirname(__FILE__).'/items/testFormItemPrototype.php'; @@ -267,6 +270,17 @@ class SeleniumTests { $suite->addTestSuite('testFormAdministrationGeneralGeomaps'); $suite->addTestSuite('testGeomapWidgetScreenshots'); + // Hosts. + $suite->addTestSuite('testFormHostConfiguration'); + $suite->addTestSuite('testFormHostLinkTemplates'); + $suite->addTestSuite('testFormHostMonitoring'); + $suite->addTestSuite('testFormHostPrototype'); + $suite->addTestSuite('testFormHostStandalone'); + $suite->addTestSuite('testPageHostInterfaces'); + $suite->addTestSuite('testPageHostPrototypes'); + $suite->addTestSuite('testPageHosts'); + $suite->addTestSuite('testPageMonitoringHosts'); + $suite->addTestSuite('testExecuteNow'); $suite->addTestSuite('testGraphAxis'); @@ -283,9 +297,6 @@ class SeleniumTests { $suite->addTestSuite('testPageProblems'); $suite->addTestSuite('testPageHistory'); $suite->addTestSuite('testPageHostGraph'); - $suite->addTestSuite('testPageHostInterfaces'); - $suite->addTestSuite('testPageHostPrototypes'); - $suite->addTestSuite('testPageHosts'); $suite->addTestSuite('testPageInventory'); $suite->addTestSuite('testPageItems'); $suite->addTestSuite('testPageItemPrototypes'); @@ -299,7 +310,6 @@ class SeleniumTests { $suite->addTestSuite('testPageMaps'); $suite->addTestSuite('testPageMassUpdateItems'); $suite->addTestSuite('testPageMassUpdateItemPrototypes'); - $suite->addTestSuite('testPageMonitoringHosts'); $suite->addTestSuite('testPageServicesServices'); $suite->addTestSuite('testPageServicesServicesMassUpdate'); $suite->addTestSuite('testPageNetworkDiscovery'); @@ -341,12 +351,7 @@ class SeleniumTests { $suite->addTestSuite('testFormEventCorrelation'); $suite->addTestSuite('testFormGraph'); $suite->addTestSuite('testFormGraphPrototype'); - $suite->addTestSuite('testFormHostConfiguration'); - $suite->addTestSuite('testFormHostMonitoring'); - $suite->addTestSuite('testFormHostStandalone'); $suite->addTestSuite('testFormHostGroup'); - $suite->addTestSuite('testFormHostLinkTemplates'); - $suite->addTestSuite('testFormHostPrototype'); $suite->addTestSuite('testFormItem'); $suite->addTestSuite('testFormItemHttpAgent'); $suite->addTestSuite('testFormItemPrototype'); diff --git a/ui/tests/selenium/hosts/testFormHostLinkTemplates.php b/ui/tests/selenium/hosts/testFormHostLinkTemplates.php new file mode 100644 index 00000000000..3fd15d0a343 --- /dev/null +++ b/ui/tests/selenium/hosts/testFormHostLinkTemplates.php @@ -0,0 +1,161 @@ +page->login()->open('zabbix.php?action=host.list')->waitUntilReady(); + $this->query('button:Create host')->one()->click(); + $form = COverlayDialogElement::find()->asForm()->one()->waitUntilVisible(); + $form->selectTab('Inventory'); + + $inventoryFields = getHostInventories(); + $inventoryFields = zbx_toHash($inventoryFields, 'db_field'); + foreach ($inventoryFields as $fieldId => $fieldName) { + $this->zbxTestTextPresent($fieldName['title']); + $this->zbxTestAssertElementPresentId('host_inventory_'.$fieldId.''); + } + COverlayDialogElement::find()->one()->close(); + } + + public function testFormHostLinkTemplates_TemplateLink() { + $this->zbxTestLogin(self::HOST_LIST_PAGE); + $this->query('button:Reset')->one()->click(); + $this->zbxTestClickLinkTextWait($this->host_for_template); + + $dialog = COverlayDialogElement::find()->asForm()->waitUntilReady()->one(); + $dialog->fill(['Templates' => 'Linux by Zabbix agent active']); + + $this->zbxTestTextPresent('Linux by Zabbix agent active'); + $dialog->submit(); + $this->zbxTestCheckTitle('Configuration of hosts'); + $this->zbxTestWaitUntilMessageTextPresent('msg-good', 'Host updated'); + $this->zbxTestTextPresent($this->host_for_template); + } + + /** + * @depends testFormHostLinkTemplates_TemplateLink + */ + public function testFormHostLinkTemplates_TemplateUnlink() { + // Unlink a template from a host from host properties page + + $template = 'Linux by Zabbix agent active'; + $host = 'Template linkage test host'; + + $sql = 'select hostid from hosts where host='.zbx_dbstr($host).' and status in ('.HOST_STATUS_MONITORED.','.HOST_STATUS_NOT_MONITORED.')'; + $this->assertEquals(1, CDBHelper::getCount($sql)); + $row = DBfetch(DBselect($sql)); + $hostid = $row['hostid']; + + $sql2 = "select hostid from hosts where host='".$template."';"; + $this->assertEquals(1, CDBHelper::getCount($sql2)); + + $this->zbxTestLogin(self::HOST_LIST_PAGE); + $this->query('button:Reset')->one()->click(); + $this->zbxTestClickLinkTextWait($this->host_for_template); + + $dialog = COverlayDialogElement::find()->asForm()->waitUntilReady()->one(); + + // Clicks button named "Unlink" next to a template by name. + $this->assertTrue($dialog->query('link', $template)->exists()); + $dialog->query('id:linked-templates')->asTable()->one()->findRow('Name', $template)->getColumn('Action') + ->query('button:Unlink')->one()->click(); + $this->assertFalse($dialog->query('link', $template)->exists()); + + $dialog->submit(); + $this->zbxTestCheckTitle('Configuration of hosts'); + $this->zbxTestWaitUntilMessageTextPresent('msg-good', 'Host updated'); + + // this should be a separate test + // should check that items, triggers and graphs are not linked to the template anymore + $this->zbxTestClickXpathWait("//a[contains(@href,'items.php?filter_set=1&filter_hostids%5B0%5D=".$hostid."')]"); + $this->page->waitUntilReady(); + $this->zbxTestTextNotPresent($template.':'); + // using "host navigation bar" at the top of entity list + $this->zbxTestHrefClickWait('triggers.php?filter_set=1&filter_hostids%5B0%5D='.$hostid); + $this->zbxTestTextNotPresent($template.':'); + $this->zbxTestHrefClickWait('graphs.php?filter_set=1&filter_hostids%5B0%5D='.$hostid); + $this->zbxTestTextNotPresent($template.':'); + } + + public function testFormHostLinkTemplates_TemplateLinkUpdate() { + $this->zbxTestLogin(self::HOST_LIST_PAGE); + $this->query('button:Reset')->one()->click(); + $this->zbxTestClickLinkTextWait($this->host_for_template); + + $form = $this->query('name:host-form')->asForm()->waitUntilReady()->one(); + $form->fill(['Templates' => 'Linux by Zabbix agent active']); + + $this->zbxTestTextPresent('Linux by Zabbix agent active'); + $form->submit(); + $this->zbxTestCheckTitle('Configuration of hosts'); + $this->zbxTestWaitUntilMessageTextPresent('msg-good', 'Host updated'); + $this->zbxTestTextPresent($this->host_for_template); + } + + /** + * @depends testFormHostLinkTemplates_TemplateLinkUpdate + */ + public function testFormHostLinkTemplates_TemplateUnlinkAndClear() { + // Unlink and clear a template from a host from host properties page + + $template = 'Linux by Zabbix agent active'; + $host = 'Template linkage test host'; + + $sql = 'select hostid from hosts where host='.zbx_dbstr($host).' and status in ('.HOST_STATUS_MONITORED.','.HOST_STATUS_NOT_MONITORED.')'; + $this->assertEquals(1, CDBHelper::getCount($sql)); + $row = DBfetch(DBselect($sql)); + $hostid = $row['hostid']; + + $sql2 = "select hostid from hosts where host='".$template."';"; + $this->assertEquals(1, CDBHelper::getCount($sql2)); + + $this->zbxTestLogin(self::HOST_LIST_PAGE); + $this->query('button:Reset')->one()->click(); + $this->zbxTestClickLinkTextWait($this->host_for_template); + + $dialog = COverlayDialogElement::find()->asForm()->waitUntilReady()->one(); + + // Clicks button named "Unlink and clear" next to a template by name. + $this->assertTrue($dialog->query('link', $template)->exists()); + $dialog->query('id:linked-templates')->asTable()->one()->findRow('Name', $template)->getColumn('Action') + ->query('button:Unlink and clear')->one()->click(); + $this->assertFalse($dialog->query('link', $template)->exists()); + + $dialog->submit(); + $this->zbxTestCheckTitle('Configuration of hosts'); + $this->zbxTestWaitUntilMessageTextPresent('msg-good', 'Host updated'); + + $this->zbxTestClickXpathWait("//a[contains(@href,'items.php?filter_set=1&filter_hostids%5B0%5D=".$hostid."')]"); + $this->page->waitUntilReady(); + $this->zbxTestTextNotPresent($template.':'); + + $this->zbxTestHrefClickWait('triggers.php?filter_set=1&filter_hostids%5B0%5D='.$hostid); + $this->zbxTestTextNotPresent($template.':'); + $this->zbxTestHrefClickWait('graphs.php?filter_set=1&filter_hostids%5B0%5D='.$hostid); + $this->zbxTestTextNotPresent($template.':'); + } +} diff --git a/ui/tests/selenium/hosts/testFormHostPrototype.php b/ui/tests/selenium/hosts/testFormHostPrototype.php new file mode 100644 index 00000000000..676e5a7f3bd --- /dev/null +++ b/ui/tests/selenium/hosts/testFormHostPrototype.php @@ -0,0 +1,1088 @@ +zbxTestLogin('host_prototypes.php?parent_discoveryid='.self::DISCOVERY_RULE_ID.'&context=host'); + $visible_name = 'Host prototype visible name'; + $name = 'Host prototype {#33}'; + + $this->zbxTestClickLinkTextWait($visible_name); + $this->zbxTestWaitForPageToLoad(); + // Check layout at Host tab. + $this->zbxTestAssertElementValue('host', $name); + $this->zbxTestAssertElementValue('name', $visible_name); + $this->zbxTestAssertElementPresentXpath('//div[contains(@class,"interface-cell-ip")]/input[@readonly]'); + $this->zbxTestAssertElementPresentXpath('//div[contains(@class,"interface-cell-dns")]/input[@readonly]'); + $this->zbxTestAssertElementPresentXpath('//label[@for="interfaces_50024_useip_1" and text()="IP"]/../input[@disabled]'); + $this->zbxTestAssertElementPresentXpath('//label[@for="interfaces_50024_useip_0" and text()="DNS"]/../input[@disabled]'); + $this->zbxTestAssertElementPresentXpath('//div[contains(@class,"interface-cell-port")]/input[@type="text"][@readonly]'); + $this->zbxTestAssertElementPresentXpath('//div[contains(@class,"interface-cell-default")]/input[@disabled]'); + + foreach (['SNMP', 'JMX', 'IPMI'] as $interface) { + $this->zbxTestAssertElementNotPresentXpath('//div[contains(@class,"interface-cell-type") and contains(text(),"'.$interface.'")]'); + } + + // Check layout at IPMI tab. + $this->zbxTestTabSwitch('IPMI'); + foreach (['ipmi_authtype', 'ipmi_privilege', 'ipmi_username', 'ipmi_password'] as $id) { + $this->zbxTestAssertElementPresentXpath('//input[@id="'.$id.'"][@readonly]'); + } + + // Check layout at Macros tab. + $this->zbxTestTabSwitch('Macros'); + $this->zbxTestAssertElementPresentXpath('//input[@id="show_inherited_macros_0"]'); + // Compare host prototype's macros from DB and frontend. + $expected_macros = CDBHelper::getAll( + 'SELECT macro,value,description,type FROM hostmacro WHERE hostid='.self::HOST_PROTOTYPE_ID.' ORDER BY macro' + ); + + // Get host prototype macros from macros tab. + $actual_macros = $this->getMacros(); + $macros_count = count($actual_macros); + $macro_types = CDBHelper::getAll('SELECT macro, type FROM hostmacro'); + + // Add Type from DB to array with actual macros + $types = []; + foreach ($macro_types as $macro_type) { + $types[$macro_type['macro']] = $macro_type['type']; + } + + for ($i = 0; $i < $macros_count; $i++) { + $actual_macros[$i]['type'] = $types[$actual_macros[$i]['macro']]; + } + + $this->assertEquals($expected_macros, $actual_macros); + + // Check global macros. + $this->zbxTestClickXpath('//label[@for="show_inherited_macros_1"]'); + $this->zbxTestWaitForPageToLoad(); + + // Create two macros arrays: from DB and from Frontend form. + $macros = [ + 'database' => array_merge( + CDBHelper::getAll('SELECT macro, value, description, type FROM globalmacro'), + $expected_macros + ), + 'frontend' => [] + ]; + + // If the macro is expected to have type "Secret text", replace the value from db with the secret macro pattern. + for ($i = 0; $i < count($macros['database']); $i++) { + if ($macros['database'][$i]['type'] === '1') { + $macros['database'][$i]['value'] = '******'; + } + } + + // Write macros rows from Frontend to array. + $table = $this->query('id:tbl_macros')->waitUntilVisible()->asTable()->one(); + $count = $table->getRows()->count() - 1; + for ($i = 0; $i < $count; $i += 2) { + $macro = []; + $row = $table->getRow($i); + $macro['macro'] = $row->query('xpath:./td[1]/textarea')->one()->getValue(); + $macro['value'] = $this->getValueField($macro['macro'])->getValue(); + $macro['description'] = $table->getRow($i + 1)->query('tag:textarea')->one()->getValue(); + $macro['type'] = ($this->getValueField($macro['macro'])->getInputType() === 'Secret text') ? '1' : '0'; + + $macros['frontend'][] = $macro; + } + + // Sort arrays by Macros. + foreach ($macros as &$array) { + usort($array, function ($a, $b) { + return strcmp($a['macro'], $b['macro']); + }); + } + unset($array); + + // Compare macros from DB with macros from Frontend. + $this->assertEquals($macros['database'], $macros['frontend']); + + // Check layout at Encryption tab. + $this->zbxTestTabSwitch('Encryption'); + foreach (['tls_connect_0', 'tls_connect_1', 'tls_connect_2', 'tls_in_none', 'tls_in_cert', 'tls_in_psk'] as $id) { + $this->zbxTestAssertElementPresentXpath('//input[@id="'.$id.'"][@disabled]'); + } + } + + public static function getCreateValidationData() { + return [ + // Create host prototype with empty name. + [ + [ + 'error' => 'Page received incorrect data', + 'error_message' => 'Incorrect value for field "Host name": cannot be empty.', + 'check_db' => false + ] + ], + // Create host prototype with space in name field. + [ + [ + 'name' => ' ', + 'error' => 'Page received incorrect data', + 'error_message' => 'Incorrect value for field "Host name": cannot be empty.' + ] + ], + // Create host prototype with invalid name. + [ + [ + 'name' => 'Host prototype {#3}', + 'hostgroup' => 'Discovered hosts', + 'error' => 'Cannot add host prototype', + 'error_message' => 'Host prototype with host name "Host prototype {#3}" already exists in discovery rule "Discovery rule 1".', + 'check_db' => false + ] + ], + [ + [ + 'name' => 'Host prototype with existen visible {#NAME}', + 'visible_name' => 'Host prototype visible name', + 'hostgroup' => 'Discovered hosts', + 'error' => 'Cannot add host prototype', + 'error_message' => 'Host prototype with visible name "Host prototype visible name" already exists in discovery rule "Discovery rule 1".', + 'check_db' => false + ] + ], + [ + [ + 'name' => 'Кириллица Прототип хоста {#FSNAME}', + 'error' => 'Cannot add host prototype', + 'error_message' => 'Invalid parameter "/1/host": invalid host name.' + ] + ], + [ + [ + 'name' => 'Host prototype without macro in name', + 'error' => 'Cannot add host prototype', + 'error_message' => 'Invalid parameter "/1/host": must contain at least one low-level discovery macro.' + ] + ], + [ + [ + 'name' => 'Host prototype with / in name', + 'hostgroup' => 'Linux servers', + 'error' => 'Cannot add host prototype', + 'error_message' => 'Invalid parameter "/1/host": invalid host name.' + ] + ], + // Create host prototype with invalid group. + [ + [ + 'name' => 'Host prototype {#GROUP_EMPTY}', + 'error' => 'Cannot add host prototype', + 'error_message' => 'Invalid parameter "/1/groupLinks": cannot be empty.' + ] + ], + [ + [ + 'name' => 'Host prototype without macro in group prototype', + 'hostgroup' => 'Linux servers', + 'group_prototypes' => [ + 'Group prototype' + ], + 'error' => 'Cannot add host prototype', + 'error_message' => 'Invalid parameter "/1/host": must contain at least one low-level discovery macro.' + ] + ], + [ + [ + 'name' => '{#HOST} prototype with duplicated Group prototypes', + 'hostgroup' => 'Linux servers', + 'group_prototypes' => [ + 'Group prototype {#MACRO}', + 'Group prototype {#MACRO}' + ], + 'error' => 'Cannot add host prototype', + 'error_message' => 'Invalid parameter "/1/groupPrototypes/2": value (name)=(Group prototype {#MACRO}) already exists.' + ] + ] + ]; + } + + /** + * Test validation of host prototype creation. + * + * @dataProvider getCreateValidationData + */ + public function testFormHostPrototype_CreateValidation($data) { + $this->zbxTestLogin('host_prototypes.php?parent_discoveryid='.self::DISCOVERY_RULE_ID.'&context=host&form=create'); + $this->zbxTestCheckHeader('Host prototypes'); + $this->zbxTestCheckTitle('Configuration of host prototypes'); + + if (array_key_exists('name', $data)) { + $this->zbxTestInputType('host', $data['name']); + } + + if (array_key_exists('visible_name', $data)) { + $this->zbxTestInputType('name', $data['visible_name']); + } + + if (array_key_exists('hostgroup', $data)) { + $this->zbxTestClickButtonMultiselect('group_links_'); + $this->zbxTestLaunchOverlayDialog('Host groups'); + $this->zbxTestClickLinkText($data['hostgroup']); + } + + if (array_key_exists('group_prototypes', $data)) { + foreach ($data['group_prototypes'] as $i => $group) { + $this->zbxTestInputTypeByXpath('//*[@name="group_prototypes['.$i.'][name]"]', $group); + $this->zbxTestClick('group_prototype_add'); + } + } + + $this->zbxTestClick('add'); + + // Check the results in frontend. + $this->zbxTestWaitUntilMessageTextPresent('msg-bad', $data['error']); + $this->zbxTestTextPresentInMessageDetails($data['error_message']); + + if (!array_key_exists('check_db', $data) || $data['check_db'] === true) { + $this->assertEquals(0, CDBHelper::getCount('SELECT NULL FROM hosts WHERE flags=2 AND name='.zbx_dbstr($data['name']))); + } + } + + public static function getValidationData() { + return [ + [ + [ + 'name' => '', + 'error' => 'Page received incorrect data', + 'error_message' => 'Incorrect value for field "Host name": cannot be empty.' + ] + ], + [ + [ + 'name' => 'Host prototype {#3}', + 'hostgroup' => 'Discovered hosts', + 'error_message' => 'Host prototype with host name "Host prototype {#3}" already exists in discovery rule "Discovery rule 1".' + ] + ], + [ + [ + 'name' => 'Host prototype with existen visible {#NAME}', + 'visible_name' => 'Host prototype visible name', + 'error_message' => 'Host prototype with visible name "Host prototype visible name" already exists in discovery rule "Discovery rule 1".' + ] + ], + [ + [ + 'name' => 'Кириллица Прототип хоста {#FSNAME}', + 'error_message' => 'Invalid parameter "/1/host": invalid host name.' + ] + ], + [ + [ + 'name' => 'Host prototype without macro in name', + 'error_message' => 'Invalid parameter "/1/host": must contain at least one low-level discovery macro.' + ] + ], + [ + [ + 'name' => 'Host prototype with / in name', + 'error_message' => 'Invalid parameter "/1/host": invalid host name.' + ] + ], + [ + [ + 'name' => 'Host prototype {#GROUP_EMPTY}', + 'clear_groups' => true, + 'error_message' => 'Invalid parameter "/1/groupLinks": cannot be empty.' + ] + ], + [ + [ + 'name' => 'Host prototype without macro in group prototype', + 'clear_groups' => true, + 'group_prototypes' => [ + 'Group prototype' + ], + 'error_message' => 'Invalid parameter "/1/host": must contain at least one low-level discovery macro.' + ] + ], + [ + [ + 'name' => '{#HOST} prototype with duplicated Group prototypes', + 'group_prototypes' => [ + 'Group prototype {#MACRO}', + 'Group prototype {#MACRO}' + ], + 'error_message' => 'Invalid parameter "/1/groupPrototypes/2": value (name)=(Group prototype {#MACRO}) already exists.' + ] + ] + ]; + } + + /** + * Test form validation. + */ + public function executeValidation($data, $action) { + $sql_hash = 'SELECT * FROM hosts ORDER BY hostid'; + $old_hash = CDBHelper::getHash($sql_hash); + + $this->zbxTestLogin('host_prototypes.php?parent_discoveryid='.self::DISCOVERY_RULE_ID.'&context=host'); + + switch ($action) { + case 'update': + $update_prototype = 'Host prototype {#2}'; + $this->zbxTestClickLinkTextWait($update_prototype); + break; + + case 'clone': + $clone_prototype = 'Host prototype {#1}'; + $this->zbxTestClickLinkTextWait($clone_prototype); + $this->zbxTestClickWait('clone'); + break; + } + + if (array_key_exists('name', $data)) { + $this->zbxTestInputClearAndTypeByXpath('//input[@id="host"]', $data['name']); + } + + if (array_key_exists('visible_name', $data)) { + $this->zbxTestInputClearAndTypeByXpath('//input[@id="name"]', $data['visible_name']); + } + + if (array_key_exists('clear_groups', $data)) { + $this->zbxTestMultiselectClear('group_links_'); + } + + if (array_key_exists('group_prototypes', $data)) { + foreach ($data['group_prototypes'] as $i => $group) { + $this->zbxTestInputClearAndTypeByXpath('//*[@name="group_prototypes['.$i.'][name]"]', $group); + $this->zbxTestClick('group_prototype_add'); + } + } + + // Press action button. + switch ($action) { + case 'update': + $this->zbxTestClickWait('update'); + if (!array_key_exists('error', $data)) { + $data['error'] = 'Cannot update host prototype'; + } + break; + + case 'clone': + $this->zbxTestClickWait('add'); + if (!array_key_exists('error', $data)) { + $data['error'] = 'Cannot add host prototype'; + } + break; + } + + // Check the results in frontend. + $this->zbxTestWaitUntilMessageTextPresent('msg-bad', $data['error']); + $this->zbxTestTextPresentInMessageDetails($data['error_message']); + + $this->assertEquals($old_hash, CDBHelper::getHash($sql_hash)); + } + + /** + * Test host prototype form validation when updating. + * + * @dataProvider getValidationData + */ + public function testFormHostPrototype_UpdateValidation($data) { + $this->executeValidation($data, 'update'); + } + + /** + * Test host prototype form validation when cloning. + * + * @dataProvider getValidationData + */ + public function testFormHostPrototype_CloneValidation($data) { + $this->executeValidation($data, 'clone'); + } + + public static function getCreateData() { + return [ + [ + [ + 'name' => 'Host with minimum fields {#FSNAME}', + 'hostgroup' => 'Virtual machines' + ] + ], + [ + [ + 'name' => 'Host with all fields {#FSNAME}', + 'visible_name' => 'Host with all fields visible name', + 'hostgroup' => 'Virtual machines', + 'group_prototype' => '{#FSNAME}', + 'template' => 'Template-layout-test-001', + 'inventory' => 'Automatic', + 'checkbox' => false, + 'macros' => [ + [ + 'action' => USER_ACTION_UPDATE, + 'index' => 0, + 'macro' => '{$NEW_MACRO}', + 'value' => 'Macro_Value', + 'description' => 'Macro Description' + ] + ] + ] + ] + ]; + } + + /** + * Test creation of a host prototype with all possible fields and with default values. + * + * @dataProvider getCreateData + */ + public function testFormHostPrototype_Create($data) { + $this->zbxTestLogin('host_prototypes.php?parent_discoveryid='.self::DISCOVERY_RULE_ID.'&context=host&form=create'); + $this->zbxTestInputTypeWait('host', $data['name']); + + if (array_key_exists('visible_name', $data)) { + $this->zbxTestInputType('name', $data['visible_name']); + } + + if (array_key_exists('checkbox', $data)) { + $this->zbxTestCheckboxSelect('status', $data['checkbox']); + } + + $this->zbxTestClickButtonMultiselect('group_links_'); + $this->zbxTestLaunchOverlayDialog('Host groups'); + $this->zbxTestClickLinkTextWait($data['hostgroup']); + + if (array_key_exists('group_prototype', $data)) { + $this->zbxTestInputTypeByXpath('//*[@name="group_prototypes[0][name]"]', $data['group_prototype']); + } + + if (array_key_exists('template', $data)) { + $this->zbxTestClickButtonMultiselect('add_templates_'); + $this->zbxTestLaunchOverlayDialog('Templates'); + COverlayDialogElement::find()->one()->setDataContext('Templates'); + $this->zbxTestClickLinkTextWait($data['template']); + } + + + if (array_key_exists('macros', $data)) { + $this->zbxTestTabSwitch('Macros'); + $this->page->waitUntilReady(); + $this->fillMacros($data['macros']); + } + + if (array_key_exists('inventory', $data)) { + $this->zbxTestTabSwitch('Inventory'); + $this->zbxTestClickXpathWait('//label[text()="'.$data['inventory'].'"]'); + } + + $this->zbxTestClick('add'); + + $this->zbxTestWaitUntilMessageTextPresent('msg-good', 'Host prototype added'); + + if (array_key_exists('visible_name', $data)) { + $this->zbxTestAssertElementPresentXpath('//a[contains(@href, "form") and text()="'.$data['visible_name'].'"]'); + } + else { + $this->zbxTestAssertElementPresentXpath('//a[contains(@href, "form") and text()="'.$data['name'].'"]'); + } + + $hostid = CDBHelper::getValue('SELECT hostid FROM hosts WHERE host='.zbx_dbstr($data['name'])); + // Check the results in form. + $this->checkFormFields($data); + + // Check the results in DB. + $this->assertEquals(1, CDBHelper::getCount('SELECT NULL FROM hosts WHERE host='.zbx_dbstr($data['name']))); + } + + /** + * Test update without any modification of host prototype. + */ + public function testFormHostPrototype_SimpleUpdate() { + $sql = 'SELECT name'. + ' FROM hosts'. + ' WHERE hostid IN ('. + 'SELECT hostid'. + ' FROM host_discovery'. + ' WHERE parent_itemid='.self::DISCOVERY_RULE_ID. + ')'. + 'LIMIT 2'; + $sql_hash = 'SELECT * FROM hosts ORDER BY hostid'; + $old_hash = CDBHelper::getHash($sql_hash); + + $this->zbxTestLogin('host_prototypes.php?parent_discoveryid='.self::DISCOVERY_RULE_ID.'&context=host'); + foreach (CDBHelper::getAll($sql) as $host) { + $this->zbxTestClickLinkTextWait($host['name']); + $this->zbxTestWaitForPageToLoad(); + $this->zbxTestClickWait('update'); + + $this->zbxTestWaitUntilMessageTextPresent('msg-good', 'Host prototype updated'); + $this->zbxTestAssertElementPresentXpath('//a[contains(@href, "form") and text()="'.$host['name'].'"]'); + } + + $this->assertEquals($old_hash, CDBHelper::getHash($sql_hash)); + } + + public static function getUpdateData() { + return [ + [ + [ + 'old_name' => 'Host prototype {#2}', + 'name' => 'New Host prototype {#2}', + 'checkbox' => true, + 'hostgroup' => 'Virtual machines', + 'group_prototype' => 'New test {#MACRO}', + 'template' => 'Windows by Zabbix agent', + 'inventory' => 'Automatic' + ] + ], + [ + [ + 'old_visible_name' => 'Host prototype visible name', + 'visible_name' => 'New prototype visible name' + ] + ] + ]; + } + + /** + * Test update of a host prototype with all possible fields. + * + * @dataProvider getUpdateData + */ + public function testFormHostPrototype_Update($data) { + $this->zbxTestLogin('host_prototypes.php?parent_discoveryid='.self::DISCOVERY_RULE_ID.'&context=host'); + $this->zbxTestClickLinkTextWait(array_key_exists('old_visible_name', $data) ? $data['old_visible_name'] : $data['old_name']); + + // Change name and visible name. + if (array_key_exists('name', $data)) { + $this->zbxTestInputTypeOverwrite('host', $data['name']); + } + if (array_key_exists('visible_name', $data)) { + $this->zbxTestInputTypeOverwrite('name', $data['visible_name']); + } + // Change status. + if (array_key_exists('checkbox', $data)) { + $this->zbxTestCheckboxSelect('status', $data['checkbox']); + } + + // Change Host group and Group prototype. + if (array_key_exists('hostgroup', $data)) { + $this->zbxTestMultiselectClear('group_links_'); + $this->zbxTestClickButtonMultiselect('group_links_'); + $this->zbxTestLaunchOverlayDialog('Host groups'); + $this->zbxTestClickLinkText($data['hostgroup']); + $this->zbxTestInputClearAndTypeByXpath('//*[@name="group_prototypes[0][name]"]', $data['group_prototype']); + } + + // Change template. + if (array_key_exists('template', $data)) { + $this->zbxTestClickXpathWait('//button[contains(@onclick,"unlink")]'); + $this->zbxTestClickButtonMultiselect('add_templates_'); + $this->zbxTestLaunchOverlayDialog('Templates'); + COverlayDialogElement::find()->one()->setDataContext('Templates'); + $this->query('link', $data['template'])->waitUntilClickable()->one()->click(); + } + + // Change inventory mode. + if (array_key_exists('inventory', $data)) { + $this->zbxTestTabSwitch('Inventory'); + $this->zbxTestClickXpathWait('//label[text()="'.$data['inventory'].'"]'); + } + + $this->zbxTestClick('update'); + + $this->zbxTestWaitUntilMessageTextPresent('msg-good', 'Host prototype updated'); + if (array_key_exists('visible_name', $data)) { + $this->zbxTestTextPresent($data['visible_name']); + } + if (array_key_exists('name', $data)) { + $this->zbxTestTextPresent($data['name']); + } + + // Check the results in form + $this->checkFormFields($data); + + if (array_key_exists('name', $data)) { + $this->assertEquals(1, CDBHelper::getCount('SELECT NULL FROM hosts WHERE host = '.zbx_dbstr($data['name']))); + $this->assertEquals(0, CDBHelper::getCount('SELECT NULL FROM hosts WHERE host = '.zbx_dbstr($data['old_name']))); + } + + if (array_key_exists('visible_name', $data)) { + $this->assertEquals(1, CDBHelper::getCount('SELECT NULL FROM hosts WHERE name = '.zbx_dbstr($data['visible_name']))); + $this->assertEquals(0, CDBHelper::getCount('SELECT NULL FROM hosts WHERE name = '.zbx_dbstr($data['old_visible_name']))); + } + } + + /** + * Check IPMI tab before and after changes on parent host. + */ + public function testFormHostPrototype_CheckIPMIFromHost() { + $this->page->login()->open('host_prototypes.php?form=update&parent_discoveryid='.self::DISCOVERY_RULE_ID. + '&context=host&hostid='.self::HOST_PROTOTYPE_ID); + $this->zbxTestWaitForPageToLoad(); + + // Check IPMI settings on prototype before changes on host. + $this->zbxTestTabSwitch('IPMI'); + $this->zbxTestTextPresent(['Authentication algorithm', 'Privilege level', 'Username', 'Password']); + + $old_values = [ + ['field' => 'authtype', 'value' => 'Default'], + ['field' => 'privilege', 'value' => 'User'], + ['field' => 'username', 'value' => ''], + ['field' => 'password', 'value' => ''] + ]; + + foreach ($old_values as $old_value) { + $this->zbxTestAssertElementValue('ipmi_'.$old_value['field'], $old_value['value']); + } + + // Go to host and change IPMI settings. + $this->page->open('zabbix.php?action=host.edit&hostid='.self::HOST_ID); + $form = $this->query('id:host-form')->asForm()->one()->waitUntilVisible(); + $form->selectTab('IPMI'); + + $new_values = [ + ['field' => 'authtype', 'value' => 'MD2'], + ['field' => 'privilege', 'value' => 'Operator'], + ['field' => 'username', 'value' => 'TestUsername'], + ['field' => 'password', 'value' => 'TestPassword'] + ]; + foreach ($new_values as $new_value) { + $tag = $this->webDriver->findElement(WebDriverBy::id('ipmi_'.$new_value['field']))->getTagName(); + if ($tag === 'select') { + $this->zbxTestDropdownSelect('ipmi_'.$new_value['field'], $new_value['value']); + } + else { + $this->zbxTestInputType('ipmi_'.$new_value['field'], $new_value['value']); + } + } + $form->submit(); + $this->assertMessage(TEST_GOOD, 'Host updated'); + + // Go back to prototype and check changes. + $this->page->open('host_prototypes.php?form=update&parent_discoveryid='.self::DISCOVERY_RULE_ID. + '&context=host&hostid='.self::HOST_PROTOTYPE_ID); + $prototype_form = $this->query('id:host-prototype-form')->asForm()->one()->waitUntilVisible(); + $prototype_form->selectTab('IPMI'); + + foreach ($new_values as $new_value) { + $this->zbxTestAssertElementValue('ipmi_'.$new_value['field'], $new_value['value']); + } + } + + public static function getCheckEncryptionFromHostData() { + return [ + [ + [ + 'connection_to_host' => 'PSK', + 'connection_from_host' => ['No encryption' => false, 'PSK' => true], + 'psk' => ['identity' => 'Test_Identity', 'number' => '16777216000000000000000000000000'] + ] + ], + [ + [ + 'connection_to_host' => 'Certificate', + 'connection_from_host' => ['No encryption' => false, 'PSK' => false, 'Certificate' => true], + 'issuer' => 'Test_Issuer', + 'subject' => 'Test_Subject' + ] + ], + [ + [ + 'connection_to_host' => 'Certificate', + 'connection_from_host' => ['No encryption' => false, 'PSK' => true, 'Certificate' => true], + 'psk' => ['identity' => 'Test_Identity2', 'number' => '16777216000000000000000000000000'], + 'issuer' => 'Test_Issuer_2', + 'subject' => 'Test_Subject_2' + ] + ] + ]; + } + + /** + * Check Encryption tab before and after changes on parent host. + * + * @dataProvider getCheckEncryptionFromHostData + */ + public function testFormHostPrototype_CheckEncryptionFromHost($data) { + $this->zbxTestLogin('host_prototypes.php?form=update&parent_discoveryid='.self::DISCOVERY_RULE_ID. + '&context=host&hostid='.self::HOST_PROTOTYPE_ID); + $this->zbxTestWaitForPageToLoad(); + + // Check Encryption settings on prototype before changes on host. + $this->zbxTestTabSwitch('Encryption'); + $this->zbxTestTextPresent(['Connections to host', 'Connections from host']); + + $labels = [ + ['type' => 'radio', 'value' => 'No encryption'], + ['type' => 'radio', 'value' => 'PSK'], + ['type' => 'radio', 'value' => 'Certificate'], + ['type' => 'checkbox', 'value' => 'No encryption'], + ['type' => 'checkbox', 'value' => 'PSK'], + ['type' => 'checkbox', 'value' => 'Certificate'] + ]; + + foreach ($labels as $label) { + $this->zbxTestAssertElementPresentXpath('//label[text()="'.$label['value'].'"]/../input[@type="'.$label['type'].'"][@disabled]'); + } + + // Go to host and change Encryption settings. + $this->page->open('zabbix.php?action=host.edit&hostid='.self::HOST_ID); + $form = $this->query('id:host-form')->asForm()->one()->waitUntilVisible(); + $form->selectTab('Encryption'); + $form->fill(['Connections to host' => $data['connection_to_host']]); + + foreach ($data['connection_from_host'] as $label => $state) { + $id = $this->zbxTestGetAttributeValue('//div[@class="form-field"]//label[text()="'.$label. + '"]/..//input[@class="checkbox-radio"]', 'id'); + $this->zbxTestCheckboxSelect($id, $state); + } + + if (array_key_exists('psk', $data)) { + $this->zbxTestInputTypeOverwrite('tls_psk_identity', $data['psk']['identity']); + $this->zbxTestInputTypeOverwrite('tls_psk', $data['psk']['number']); + } + if (array_key_exists('issuer', $data)) { + $this->zbxTestInputTypeOverwrite('tls_issuer', $data['issuer']); + } + if (array_key_exists('subject', $data)) { + $this->zbxTestInputTypeOverwrite('tls_subject', $data['subject']); + } + $form->submit(); + $this->assertMessage(TEST_GOOD, 'Host updated'); + + // Go back to prototype and check changes. + $this->zbxTestOpen('host_prototypes.php?form=update&parent_discoveryid='.self::DISCOVERY_RULE_ID. + '&context=host&hostid='.self::HOST_PROTOTYPE_ID); + $this->zbxTestTabSwitch('Encryption'); + $this->zbxTestWaitForPageToLoad(); + + // Check correct radio is selected. + $this->zbxTestAssertElementPresentXpath('//label[text()="'.$data['connection_to_host'].'"]/../input[@type="radio"][@checked][@disabled]'); + + // Check checkboxes. + foreach ($data['connection_from_host'] as $label => $state) { + $id = $this->zbxTestGetAttributeValue('//ul[@class="list-check-radio"]//label[text()="'.$label.'"]/../input', 'id'); + $this->assertEquals($state, $this->zbxTestCheckboxSelected($id)); + } + + // Check input fields. + if (array_key_exists('psk', $data)) { + $this->assertTrue($this->query('button:Change PSK')->exists()); + } + if (array_key_exists('issuer', $data)) { + $this->zbxTestAssertElementValue('tls_issuer', $data['issuer']); + } + if (array_key_exists('subject', $data)) { + $this->zbxTestAssertElementValue('tls_subject', $data['subject']); + } + } + + public static function getCloneData() { + return [ + [ + [ + 'name' => 'Clone_3 of Host prototype {#1}', + 'visible_name' => 'Clone_3 Host prototype visible name', + 'inventory' => 'Automatic', + 'checkbox' => false + ] + ], + [ + [ + 'name' => 'Clone_4 of Host prototype {#1}', + 'hostgroup' => 'Hypervisors' + ] + ], + [ + [ + 'name' => 'Clone_5 of Host prototype {#1}', + 'group_prototype' => 'Clone group prototype {#MACRO}' + ] + ] + , + [ + [ + 'name' => 'Clone_6 of Host prototype {#1}', + 'template' => 'Alcatel Timetra TiMOS SNMP' + ] + ], + [ + [ + 'name' => 'Clone_7 of Host prototype {#1}', + 'inventory' => 'Manual' + ] + ] + ]; + } + + /** + * Test clone of a host prototype with update all possible fields. + * + * @dataProvider getCloneData + */ + public function testFormHostPrototype_Clone($data) { + $hostname = 'Host prototype {#1}'; + + $this->zbxTestLogin('host_prototypes.php?parent_discoveryid='.self::DISCOVERY_RULE_ID.'&context=host'); + $this->zbxTestClickLinkTextWait($hostname); + $this->zbxTestClickWait('clone'); + + // Change name and visible name. + $this->zbxTestInputTypeOverwrite('host', $data['name']); + if (array_key_exists('visible_name', $data)) { + $this->zbxTestInputType('name', $data['visible_name']); + } + // Change status. + if (array_key_exists('checkbox', $data)) { + $this->zbxTestCheckboxSelect('status', $data['checkbox']); + } + // Change host group. + if (array_key_exists('hostgroup', $data)) { + $this->zbxTestClickXpathWait('//span[@class="subfilter-disable-btn"]'); + $this->zbxTestMultiselectClear('group_links_'); + $this->zbxTestClickButtonMultiselect('group_links_'); + $this->zbxTestLaunchOverlayDialog('Host groups'); + $this->zbxTestClickLinkTextWait($data['hostgroup']); + } + // Change host group prototype. + if (array_key_exists('group_prototype', $data)) { + $this->zbxTestInputClearAndTypeByXpath('//*[@name="group_prototypes[0][name]"]', $data['group_prototype']); + } + + // Change template. + if (array_key_exists('template', $data)) { + $this->zbxTestClickButtonMultiselect('add_templates_'); + $this->zbxTestLaunchOverlayDialog('Templates'); + COverlayDialogElement::find()->one()->setDataContext('Templates'); + $this->zbxTestClickLinkTextWait($data['template']); + } + + // Change inventory mode. + if (array_key_exists('inventory', $data)) { + $this->zbxTestTabSwitch('Inventory'); + $this->zbxTestClickXpathWait('//label[text()="'.$data['inventory'].'"]'); + } + + $this->zbxTestClick('add'); + + $this->zbxTestWaitUntilMessageTextPresent('msg-good', 'Host prototype added'); + + if (array_key_exists('visible_name', $data)) { + $this->zbxTestAssertElementPresentXpath('//a[contains(@href, "form") and text()="'.$data['visible_name'].'"]'); + $this->zbxTestAssertElementPresentXpath('//a[contains(@href, "form") and text()="'.$hostname.'"]'); + } + else { + $this->zbxTestAssertElementPresentXpath('//a[contains(@href, "form") and text()="'.$data['name'].'"]'); + $this->zbxTestAssertElementPresentXpath('//a[contains(@href, "form") and text()="'.$hostname.'"]'); + } + + // Check the results in form + $this->checkFormFields($data); + + $this->assertEquals(1, CDBHelper::getCount('SELECT NULL FROM hosts WHERE host='.zbx_dbstr($data['name']))); + $this->assertEquals(1, CDBHelper::getCount('SELECT NULL FROM hosts WHERE host='.zbx_dbstr($hostname))); + } + + private function checkFormFields($data) { + if (array_key_exists('visible_name', $data)) { + $this->zbxTestClickLinkTextWait($data['visible_name']); + $this->zbxTestAssertElementValue('name', $data['visible_name']); + } + else { + $this->zbxTestClickLinkTextWait($data['name']); + $this->zbxTestAssertElementValue('host', $data['name']); + } + + if (array_key_exists('checkbox', $data)) { + $this->assertEquals($data['checkbox'], $this->zbxTestCheckboxSelected('status')); + } + + if (array_key_exists('hostgroup', $data)) { + $this->zbxTestMultiselectAssertSelected('group_links_', $data['hostgroup']); + if (array_key_exists('group_prototype', $data)) { + $this->assertEquals($data['group_prototype'], $this->zbxTestGetValue('//input[@name="group_prototypes[0][name]"]')); + } + } + + if (array_key_exists('template', $data)) { + $this->query('link', $data['template']); + } + + if (array_key_exists('macros', $data)) { + $this->zbxTestTabSwitch('Macros'); + $this->assertMacros($data['macros']); + } + + if (array_key_exists('inventory', $data)) { + $this->zbxTestTabSwitch('Inventory'); + $this->zbxTestAssertElementPresentXpath('//label[text()="'.$data['inventory'].'"]/../input[@checked]'); + } + } + + public function testFormHostPrototype_Delete() { + $prototype_name = 'Host prototype {#3}'; + + $this->zbxTestLogin('host_prototypes.php?parent_discoveryid='.self::DISCOVERY_RULE_ID.'&context=host'); + $this->zbxTestClickLinkTextWait($prototype_name); + + $this->zbxTestClickAndAcceptAlert('delete'); + + $this->zbxTestWaitUntilMessageTextPresent('msg-good', 'Host prototype deleted'); + + $this->assertEquals(0, CDBHelper::getCount('SELECT NULL FROM hosts WHERE host='.zbx_dbstr($prototype_name))); + } + + public function testFormHostPrototype_CancelCreation() { + $host = 'Host for host prototype tests'; + $discovery_rule = 'Discovery rule 1'; + $name = 'Host prototype {#FSNAME}'; + $group = 'Virtual machines'; + + $sql_hash = 'SELECT * FROM hosts ORDER BY hostid'; + $old_hash = CDBHelper::getHash($sql_hash); + + $this->zbxTestLogin(self::HOST_LIST_PAGE); + + $form = $this->query('name:zbx_filter')->asForm()->waitUntilReady()->one(); + $form->fill(['Name' => $host]); + $this->query('button:Apply')->one()->waitUntilClickable()->click(); + $this->query('xpath://table[@class="list-table"]')->asTable()->one()->findRow('Name', $host) + ->getColumn('Discovery')->query('link:Discovery')->one()->click(); + + $this->zbxTestClickLinkTextWait($discovery_rule); + $this->zbxTestClickLinkTextWait('Host prototypes'); + $this->zbxTestContentControlButtonClickTextWait('Create host prototype'); + + $this->zbxTestInputType('host', $name); + $this->zbxTestClickButtonMultiselect('group_links_'); + $this->zbxTestLaunchOverlayDialog('Host groups'); + $this->zbxTestClickLinkText($group); + + $this->zbxTestClick('cancel'); + + // Check the results in frontend. + $this->zbxTestCheckHeader('Host prototypes'); + $this->zbxTestCheckTitle('Configuration of host prototypes'); + $this->zbxTestTextNotPresent($name); + + $this->assertEquals($old_hash, CDBHelper::getHash($sql_hash)); + } + + /** + * Cancel updating, cloning or deleting of host prototype. + */ + private function executeCancelAction($action) { + $sql_hash = 'SELECT * FROM hosts ORDER BY hostid'; + $old_hash = CDBHelper::getHash($sql_hash); + + $this->zbxTestLogin('host_prototypes.php?parent_discoveryid='.self::DISCOVERY_RULE_ID.'&context=host'); + + $sql = 'SELECT name'. + ' FROM hosts'. + ' WHERE hostid IN ('. + 'SELECT hostid'. + ' FROM host_discovery'. + ' WHERE parent_itemid='.self::DISCOVERY_RULE_ID. + ')'. + 'LIMIT 1'; + + foreach (CDBHelper::getAll($sql) as $host) { + $name = $host['name']; + $this->zbxTestClickLinkText($name); + + switch ($action) { + case 'update': + $name .= ' (updated)'; + $this->zbxTestInputTypeOverwrite('host', $name); + $this->zbxTestClick('cancel'); + break; + + case 'clone': + $name .= ' (cloned)'; + $this->zbxTestInputTypeOverwrite('host', $name); + $this->zbxTestClickWait('clone'); + $this->zbxTestClickWait('cancel'); + break; + + case 'delete': + $this->zbxTestClickWait('delete'); + $this->webDriver->switchTo()->alert()->dismiss(); + break; + } + + $this->zbxTestCheckHeader('Host prototypes'); + $this->zbxTestCheckTitle('Configuration of host prototypes'); + + if ($action !== 'delete') { + $this->zbxTestTextNotPresent($name); + } + else { + $this->zbxTestTextPresent($name); + } + } + $this->assertEquals($old_hash, CDBHelper::getHash($sql_hash)); + } + + /** + * Cancel update of host prototype. + */ + public function testFormHostPrototype_CancelUpdating() { + $this->executeCancelAction('update'); + } + + /** + * Cancel cloning of host prototype. + */ + public function testFormHostPrototype_CancelCloning() { + $this->executeCancelAction('clone'); + } + + /** + * Cancel deleting of host prototype. + */ + public function testFormHostPrototype_CancelDelete() { + $this->executeCancelAction('delete'); + } +} diff --git a/ui/tests/selenium/hosts/testPageHostInterfaces.php b/ui/tests/selenium/hosts/testPageHostInterfaces.php new file mode 100644 index 00000000000..8919b9570c3 --- /dev/null +++ b/ui/tests/selenium/hosts/testPageHostInterfaces.php @@ -0,0 +1,487 @@ + 1, + 'main' => 1, + 'useip' => 0, + 'ip' => '127.1.1.1', + 'dns' => '1available.zabbix.com', + 'port' => '10050', + 'available' => 1 + ], + [ + 'type' => 1, + 'main' => 0, + 'useip' => 0, + 'ip' => '127.1.1.2', + 'dns' => '2available.zabbix.com', + 'port' => '10051', + 'available' => 1 + ], + [ + 'type' => 2, + 'main' => 1, + 'useip' => 1, + 'ip' => '127.0.0.98', + 'dns' => 'snmpv3zabbix.com', + 'port' => '163', + 'details' => [ + 'version' => '3', + 'bulk' => '1', + 'securityname' => 'zabbix' + ], + 'available' => 1 + ], + [ + 'type' => 2, + 'main' => 0, + 'useip' => 0, + 'ip' => '', + 'dns' => 'snmpv3auth.com', + 'port' => '163', + 'details' => [ + 'version' => '3', + 'bulk' => '1', + 'securitylevel' => 2, + 'authprotocol' => 2, + 'privprotocol' => 4 + ], + 'available' => 1 + ], + [ + 'type' => 2, + 'main' => 0, + 'useip' => 1, + 'ip' => '127.0.0.99', + 'dns' => 'snmpv2zabbix.com', + 'port' => '162', + 'details' => [ + 'version' => '2', + 'bulk' => '1', + 'community' => '{$SNMP_COMMUNITY}' + ], + 'available' => 2 + ], + [ + 'type' => 3, + 'main' => 1, + 'useip' => 0, + 'ip' => '127.0.0.1', + 'dns' => '1unavail.IPMI.zabbix.com', + 'port' => '623', + 'available' => 2, + 'error' => '1 Error IPMI' + ], + [ + 'type' => 3, + 'main' => 0, + 'useip' => 0, + 'ip' => '127.0.0.1', + 'dns' => '2unavail.IPMI.zabbix.com', + 'port' => '624', + 'available' => 2, + 'error' => '2 Error IPMI' + ] + ]; + + $groups = [ + [ + 'groupid' => 4 + ] + ]; + + CDataHelper::createHosts([ + [ + 'host' => 'Host with Orange interface', + 'name' => 'Host with Orange interface', + 'description' => 'API Created Host with Orange interface for Host availability test', + 'interfaces' => $interfaces, + 'groups' => $groups, + 'status' => HOST_STATUS_MONITORED + ] + ]); + } + + public function getCheckInterfacesData() { + return [ + [ + [ + 'host' => 'Not available host', + 'interfaces' => [ + 'ZBX' => [ + 'color' => self::RED, + 'rows' => [ + [ + 'Interface' => 'zabbixzabbixzabbix.com:10050', + 'Status' => [ + 'text' => 'Not available', + 'color' => self::RED + ], + 'Error' => 'ERROR Agent' + ] + ] + ], + 'SNMP' => [ + 'color' => self::RED, + 'rows' => [ + [ + 'Interface' => "zabbixzabbixzabbix.com:10050\nSNMPv2, Community: {\$SNMP_COMMUNITY}", + 'Status' => [ + 'text' => 'Not available', + 'color' => self::RED + ], + 'Error' => 'ERROR SNMP' + ] + ] + ], + 'IPMI' => [ + 'color' => self::RED, + 'rows' => [ + [ + 'Interface' => 'zabbixzabbixzabbix.com:10050', + 'Status' => [ + 'text' => 'Not available', + 'color' => self::RED + ], + 'Error' => 'ERROR IPMI' + ] + ] + ], + 'JMX' => [ + 'color' => self::RED, + 'rows' => [ + [ + 'Interface' => 'zabbixzabbixzabbix.com:10050', + 'Status' => [ + 'text' => 'Not available', + 'color' => self::RED + ], + 'Error' => 'ERROR JMX' + ] + ] + ] + ] + ] + ], + [ + [ + 'host' => 'Host with Orange interface', + 'interfaces' => [ + 'ZBX' => [ + 'color' => self::GREEN, + 'rows' => [ + [ + 'Interface' => '1available.zabbix.com:10050', + 'Status' => [ + 'text' => 'Available', + 'color' => self::GREEN + ], + 'Error' => '' + ], + [ + 'Interface' => '2available.zabbix.com:10051', + 'Status' => [ + 'text' => 'Available', + 'color' => self::GREEN + ], + 'Error' => '' + ] + ] + ], + 'SNMP' => [ + 'color' => self::ORANGE, + 'rows' => [ + [ + 'Interface' => "127.0.0.98:163\nSNMPv3, Context name:", + 'Status' => [ + 'text' => 'Available', + 'color' => self::GREEN + ], + 'Error' => '' + ], + [ + 'Interface' => "127.0.0.99:162\nSNMPv2, Community: {\$SNMP_COMMUNITY}", + 'Status' => [ + 'text' => 'Not available', + 'color' => self::RED + ], + 'Error' => '' + ], + [ + 'Interface' => "snmpv3auth.com:163\nSNMPv3, Context name: , (priv: AES192C, auth: SHA224)", + 'Status' => [ + 'text' => 'Available', + 'color' => self::GREEN + ], + 'Error' => '' + ] + ] + ], + 'IPMI' => [ + 'color' => self::RED, + 'rows' => [ + [ + 'Interface' => '1unavail.IPMI.zabbix.com:623', + 'Status' => [ + 'text' => 'Not available', + 'color' => self::RED + ], + 'Error' => '1 Error IPMI' + ], + [ + 'Interface' => '2unavail.IPMI.zabbix.com:624', + 'Status' => [ + 'text' => 'Not available', + 'color' => self::RED + ], + 'Error' => '2 Error IPMI' + ] + ] + ] + ] + ] + ], + [ + [ + 'host' => 'Template inheritance test host', + 'interfaces' => [ + 'ZBX' => [ + 'color' => self::GREY, + 'rows' => [ + [ + 'Interface' => '127.0.0.1:10051', + 'Status' => [ + 'text' => 'Unknown', + 'color' => self::GREY + ], + 'Error' => '' + ], + [ + 'Interface' => '127.0.0.2:10052', + 'Status' => [ + 'text' => 'Unknown', + 'color' => self::GREY + ], + 'Error' => '' + ] + ] + ], + 'SNMP' => [ + 'color' => self::GREY, + 'rows' => [ + [ + 'Interface' => "127.0.0.3:10053\nSNMPv2, Community: {\$SNMP_COMMUNITY}", + 'Status' => [ + 'text' => 'Unknown', + 'color' => self::GREY + ], + 'Error' => '' + ] + ] + ], + 'IPMI' => [ + 'color' => self::GREY, + 'rows' => [ + [ + 'Interface' => '127.0.0.4:10054', + 'Status' => [ + 'text' => 'Unknown', + 'color' => self::GREY + ], + 'Error' => '' + ] + ] + ], + 'JMX' => [ + 'color' => self::GREY, + 'rows' => [ + [ + 'Interface' => '127.0.0.5:10055', + 'Status' => [ + 'text' => 'Unknown', + 'color' => self::GREY + ], + 'Error' => '' + ] + ] + ] + ] + ] + ], + [ + [ + 'host' => 'Available host', + 'interfaces' => [ + 'ZBX' => [ + 'color' => self::GREEN, + 'rows' => [ + [ + 'Interface' => '127.0.0.1:10050', + 'Status' => [ + 'text' => 'Available', + 'color' => self::GREEN + ], + 'Error' => '' + ] + ] + ], + 'SNMP' => [ + 'color' => self::GREEN, + 'rows' => [ + [ + 'Interface' => "zabbixzabbixzabbix.com:10050\nSNMPv2, Community: {\$SNMP_COMMUNITY}", + 'Status' => [ + 'text' => 'Available', + 'color' => self::GREEN + ], + 'Error' => '' + ] + ] + ], + 'IPMI' => [ + 'color' => self::GREEN, + 'rows' => [ + [ + 'Interface' => 'zabbixzabbixzabbix.com:10050', + 'Status' => [ + 'text' => 'Available', + 'color' => self::GREEN + ], + 'Error' => '' + ] + ] + ], + 'JMX' => [ + 'color' => self::GREEN, + 'rows' => [ + [ + 'Interface' => 'zabbixzabbixzabbix.com:10050', + 'Status' => [ + 'text' => 'Available', + 'color' => self::GREEN + ], + 'Error' => '' + ] + ] + ] + ] + ] + ] + ]; + } + + /** + * Test displaying host interfaces on Monitoring->Hosts page. + * + * @dataProvider getCheckInterfacesData + */ + public function testPageHostInterfaces_MonitoringHosts($data) { + $this->checkInterfaces($data, 'zabbix.php?action=host.view', 'host_view'); + } + + /** + * Test displaying host interfaces on Configuration->Hosts page. + * + * @dataProvider getCheckInterfacesData + */ + public function testPageHostInterfaces_ConfigurationHosts($data) { + $this->checkInterfaces($data, self::HOST_LIST_PAGE, 'hosts'); + } + + /** + * Test displaying host interfaces on Discovery rules page. + * + * @dataProvider getCheckInterfacesData + */ + public function testPageHostInterfaces_DiscoveryPage($data) { + $id = CDBHelper::getValue('SELECT hostid FROM hosts WHERE host ='.zbx_dbstr($data['host'])); + $link = 'host_discovery.php?filter_set=1&filter_hostids%5B0%5D='.$id.'&context=host'; + $this->checkInterfaces($data, $link, $selector = null, true); + } + + /** + * Function for checking interfaces. + * + * @param array $data data from data provider + * @param string $link checked page link + * @param string $selector table selector on page + * @param boolean $navigation is it upper navigation block or not + */ + private function checkInterfaces($data, $link, $selector = null, $navigation = false) { + if ($navigation) { + $this->page->login()->open($link)->waitUntilReady(); + $availability = $this->query('xpath://div[@class="status-container"]')->waitUntilPresent()->one(); + } + else { + $this->page->login()->open($link)->waitUntilReady(); + $table = $this->query('xpath://form[@name='.zbx_dbstr($selector).']/table[@class="list-table"]') + ->waitUntilReady()->asTable()->one(); + $availability = $table->findRow('Name', $data['host'])->getColumn('Availability'); + } + + $host_interfaces = []; + foreach ($availability->query('xpath:.//span[@data-hintbox="1"]')->all() as $interface) { + $interface_name = $interface->getText(); + // Write interfaces names into array. + $host_interfaces[] = $interface_name; + // Check interface color in availability column. + $this->assertEquals($data['interfaces'][$interface_name]['color'], $interface->getCSSValue('background-color')); + // Open interface popup. + $interface->click(); + $overlay = $this->query('xpath://div[@class="overlay-dialogue"]')->asOverlayDialog()->waitUntilPresent()->one(); + $interface_table = $overlay->query('xpath:.//table[@class="list-table"]')->asTable()->one(); + // Check table headers in popup. + $this->assertSame(['Interface', 'Status', 'Error'], $interface_table->getHeadersText()); + + // Check every interface row. + foreach ($interface_table->getRows() as $i => $row) { + $interface_details = $data['interfaces'][$interface_name]['rows'][$i]; + $this->assertEquals($interface_details['Interface'], $row->getColumn('Interface')->getText()); + $this->assertEquals($interface_details['Status']['text'], $row->getColumn('Status')->getText()); + $this->assertEquals($interface_details['Status']['color'], $row->getColumn('Status') + ->query('xpath:.//span[contains(@class, "status")]')->one()->getCSSValue('background-color')); + $this->assertEquals($interface_details['Error'], $row->getColumn('Error')->getText()); + } + + $overlay->close(); + $overlay->waitUntilNotPresent(); + } + // Assert interface names in Availability column. + $this->assertEquals(array_keys($data['interfaces']), $host_interfaces); + } +} diff --git a/ui/tests/selenium/hosts/testPageHostPrototypes.php b/ui/tests/selenium/hosts/testPageHostPrototypes.php new file mode 100644 index 00000000000..10e0c5cfc0a --- /dev/null +++ b/ui/tests/selenium/hosts/testPageHostPrototypes.php @@ -0,0 +1,225 @@ +zbxTestLogin('host_prototypes.php?parent_discoveryid='.self::DICROVERY_RULE_ID.'&context=host'); + $this->zbxTestCheckTitle('Configuration of host prototypes'); + $this->zbxTestCheckHeader('Host prototypes'); + + $table = $this->query('xpath://form[@name="hosts"]/table[@class="list-table"]')->asTable()->one(); + $headers = ['', 'Name', 'Templates', 'Create enabled', 'Discover', 'Tags']; + $this->assertSame($headers, $table->getHeadersText()); + + foreach (['Create enabled', 'Create disabled', 'Delete'] as $button) { + $element = $this->query('button', $button)->one(); + $this->assertTrue($element->isPresent()); + $this->assertFalse($element->isEnabled()); + } + + $this->assertTableStats(self::HOST_PROTOTYPES_COUNT); + + // Check tags on the specific host prototype. + $tags = $table->findRow('Name', 'Host prototype {#1}')->getColumn('Tags')->query('class:tag')->all(); + $this->assertEquals(['host_proto_tag_1: value1', 'host_proto_tag_2: value2'], $tags->asText()); + + foreach ($tags as $tag) { + $tag->click(); + $hint = $this->query('xpath://div[@data-hintboxid]') + ->asOverlayDialog()->waitUntilPresent()->all()->last(); + $this->assertEquals($tag->getText(), $hint->getText()); + $hint->close(); + } + } + + public static function getSelectedData() { + return [ + [ + [ + 'item' => 'Discovery rule 1', + 'hosts' => [ + 'Host prototype {#1}' + ] + ] + ], + [ + [ + 'item' => 'Discovery rule 2', + 'hosts' => 'all' + ] + ], + [ + [ + 'item' => 'Discovery rule 3', + 'hosts' => [ + 'Host prototype {#7}', + 'Host prototype {#9}', + 'Host prototype {#10}' + ] + ] + ] + ]; + } + + /** + * Select specified hosts from host prototype page. + * + * @param array $data test case data from data provider + */ + private function selectHostPrototype($data) { + $discoveryid = DBfetch(DBselect("SELECT itemid FROM items WHERE name=".zbx_dbstr($data['item']))); + $this->zbxTestLogin("host_prototypes.php?parent_discoveryid=".$discoveryid['itemid'].'&context=host'); + + if ($data['hosts'] === 'all') { + $this->zbxTestCheckboxSelect('all_hosts'); + return; + } + + foreach ($data['hosts'] as $host) { + $result = DBselect('SELECT hostid FROM hosts WHERE host='.zbx_dbstr($host)); + while ($row = DBfetch($result)) { + $this->zbxTestCheckboxSelect('group_hostid_'.$row['hostid']); + } + } + } + + /** + * Check specific page action. + * Actions are defined by buttons pressed on page. + * + * @param array $data test case data from data provider + * @param string $action button text (action to be executed) + * @param int $status host status to be checked in DB + */ + protected function checkPageAction($data, $action, $status = null) { + // Click on button with required action. + if ($action === 'Click on state') { + foreach ($data['hosts'] as $host) { + $id = DBfetch(DBselect('SELECT hostid FROM hosts WHERE name='.zbx_dbstr($host))); + $this->zbxTestClickXpathWait("//a[contains(@onclick,'group_hostid=".$id['hostid']."')]"); + } + } + else { + $this->selectHostPrototype($data); + $this->zbxTestClickButtonText($action); + $this->zbxTestAcceptAlert(); + } + + $this->zbxTestIsElementPresent('//*[@class="msg-good"]'); + $this->zbxTestCheckTitle('Configuration of host prototypes'); + $this->zbxTestCheckHeader('Host prototypes'); + + // Create query part for status (if any). + $status_criteria = ($status !== null) ? (' AND status='.$status) : ''; + + // Check the results in DB. + if ($data['hosts'] === 'all') { + $sql = 'SELECT NULL'. + ' FROM hosts'. + ' WHERE hostid IN ('. + 'SELECT hostid'. + ' FROM host_discovery'. + ' WHERE parent_itemid IN ('. + 'SELECT itemid'. + ' FROM items'. + ' WHERE name='.zbx_dbstr($data['item']). + ')'. + ')'; + } + else { + $names = []; + foreach ($data['hosts'] as $host) { + $names[] = zbx_dbstr($host); + } + + $sql = 'SELECT NULL'. + ' FROM hosts'. + ' WHERE host IN ('.implode(',', $names).')'; + } + + $this->assertEquals(0, CDBHelper::getCount($sql.$status_criteria)); + } + + /** + * @dataProvider getSelectedData + */ + public function testPageHostPrototypes_DisableSelected($data) { + $this->checkPageAction($data, 'Create disabled', HOST_STATUS_MONITORED); + } + + /** + * @dataProvider getSelectedData + */ + public function testPageHostPrototypes_EnableSelected($data) { + $this->checkPageAction($data, 'Create enabled', HOST_STATUS_NOT_MONITORED); + } + + /** + * @dataProvider getSelectedData + */ + public function testPageHostPrototypes_DeleteSelected($data) { + $this->checkPageAction($data, 'Delete'); + } + + public static function getHostPrototypeData() { + return [ + [ + [ + 'item' => 'Discovery rule 1', + 'hosts' => [ + 'Host prototype {#2}' + ], + 'status' => HOST_STATUS_NOT_MONITORED + ] + ], + [ + [ + 'item' => 'Discovery rule 1', + 'hosts' => [ + 'Host prototype {#3}' + ], + 'status' => HOST_STATUS_MONITORED + ] + ] + ]; + } + + /** + * @dataProvider getHostPrototypeData + */ + public function testPageHostPrototypes_SingleEnableDisable($data) { + $discoveryid = DBfetch(DBselect("SELECT itemid FROM items WHERE name=".zbx_dbstr($data['item']))); + $this->zbxTestLogin("host_prototypes.php?parent_discoveryid=".$discoveryid['itemid'].'&context=host'); + + $this->checkPageAction($data, 'Click on state', $data['status']); + } +} diff --git a/ui/tests/selenium/hosts/testPageHosts.php b/ui/tests/selenium/hosts/testPageHosts.php new file mode 100644 index 00000000000..578bef2f116 --- /dev/null +++ b/ui/tests/selenium/hosts/testPageHosts.php @@ -0,0 +1,704 @@ +zbxTestLogin(self::HOST_LIST_PAGE); + $this->zbxTestCheckTitle('Configuration of hosts'); + $this->zbxTestCheckHeader('Hosts'); + $filter = $this->query('name:zbx_filter')->asForm()->one(); + $filter->query('button:Reset')->one()->click(); + $filter->getField('Host groups')->select($this->HostGroup); + $filter->submit(); + + $this->zbxTestTextPresent($this->HostName); + $this->zbxTestTextPresent('Simple form test host'); + $this->zbxTestTextNotPresent('ZBX6648 All Triggers Host'); + + // Check that proxy field is disabled. + $this->zbxTestAssertElementNotPresentId('filter_proxyids__ms'); + $this->zbxTestAssertElementPresentXpath('//div[@id="filter_proxyids_"]/..//button[@disabled]'); + + $this->zbxTestAssertElementPresentXpath("//thead//th/a[text()='Name']"); + $this->zbxTestAssertElementPresentXpath("//thead//th[contains(text(),'Items')]"); + $this->zbxTestAssertElementPresentXpath("//thead//th[contains(text(),'Triggers')]"); + $this->zbxTestAssertElementPresentXpath("//thead//th[contains(text(),'Graphs')]"); + $this->zbxTestAssertElementPresentXpath("//thead//th[contains(text(),'Discovery')]"); + $this->zbxTestAssertElementPresentXpath("//thead//th[contains(text(),'Web')]"); + $this->zbxTestAssertElementPresentXpath("//thead//th[contains(text(),'Interface')]"); + $this->zbxTestAssertElementPresentXpath("//thead//th[contains(text(),'Proxy')]"); + $this->zbxTestAssertElementPresentXpath("//thead//th[contains(text(),'Templates')]"); + $this->zbxTestAssertElementPresentXpath("//thead//th/a[contains(text(),'Status')]"); + $this->zbxTestAssertElementPresentXpath("//thead//th[contains(text(),'Availability')]"); + $this->zbxTestAssertElementPresentXpath("//thead//th[contains(text(),'Agent encryption')]"); + $this->zbxTestAssertElementPresentXpath("//thead//th[contains(text(),'Info')]"); + + $this->zbxTestTextNotPresent('Displaying 0 of 0 found'); + $this->zbxTestAssertElementPresentXpath("//div[@class='table-stats'][contains(text(),'Displaying')]"); + + $this->zbxTestAssertElementPresentXpath("//button[text()='Export'][@disabled]"); + $this->zbxTestAssertElementPresentXpath("//button[text()='Mass update'][@disabled]"); + $this->zbxTestAssertElementPresentXpath("//button[text()='Enable'][@disabled]"); + $this->zbxTestAssertElementPresentXpath("//button[text()='Disable'][@disabled]"); + $this->zbxTestAssertElementPresentXpath("//button[text()='Delete'][@disabled]"); + } + + /** + * @dataProvider allHosts + */ + public function testPageHosts_SimpleUpdate($host) { + $hostid = $host['hostid']; + $name = $host['name']; + + $sqlHosts = + 'SELECT hostid,proxy_hostid,host,status,ipmi_authtype,ipmi_privilege,ipmi_username,'. + 'ipmi_password,maintenanceid,maintenance_status,maintenance_type,maintenance_from,'. + 'name,flags,templateid,description,tls_connect,tls_accept'. + ' FROM hosts'. + ' WHERE hostid='.$hostid; + $oldHashHosts = CDBHelper::getHash($sqlHosts); + $sqlItems = "select * from items where hostid=$hostid order by itemid"; + $oldHashItems = CDBHelper::getHash($sqlItems); + $sqlInterface = "select * from interface where hostid=$hostid order by interfaceid"; + $oldHashInterface = CDBHelper::getHash($sqlInterface); + $sqlHostMacro = "select * from hostmacro where hostid=$hostid order by hostmacroid"; + $oldHashHostMacro = CDBHelper::getHash($sqlHostMacro); + $sqlHostsGroups = "select * from hosts_groups where hostid=$hostid order by hostgroupid"; + $oldHashHostsGroups = CDBHelper::getHash($sqlHostsGroups); + $sqlHostsTemplates = "select * from hosts_templates where hostid=$hostid order by hosttemplateid"; + $oldHashHostsTemplates = CDBHelper::getHash($sqlHostsTemplates); + $sqlMaintenancesHosts = "select * from maintenances_hosts where hostid=$hostid order by maintenance_hostid"; + $oldHashMaintenancesHosts = CDBHelper::getHash($sqlMaintenancesHosts); + $sqlHostInventory = "select * from host_inventory where hostid=$hostid"; + $oldHashHostInventory = CDBHelper::getHash($sqlHostInventory); + + $this->zbxTestLogin(self::HOST_LIST_PAGE); + $this->query('button:Reset')->one()->click(); + $this->zbxTestCheckTitle('Configuration of hosts'); + $this->zbxTestCheckHeader('Hosts'); + + $this->zbxTestTextPresent($name); + $this->zbxTestClickLinkText($name); + $form = COverlayDialogElement::find()->asForm()->one()->waitUntilReady(); + $form->submit(); + $this->zbxTestCheckTitle('Configuration of hosts'); + $this->zbxTestWaitUntilMessageTextPresent('msg-good', 'Host updated'); + $this->zbxTestTextPresent($name); + + $this->assertEquals($oldHashHosts, CDBHelper::getHash($sqlHosts)); + $this->assertEquals($oldHashItems, CDBHelper::getHash($sqlItems)); + $this->assertEquals($oldHashInterface, CDBHelper::getHash($sqlInterface)); + $this->assertEquals($oldHashHostMacro, CDBHelper::getHash($sqlHostMacro)); + $this->assertEquals($oldHashHostsGroups, CDBHelper::getHash($sqlHostsGroups)); + $this->assertEquals($oldHashHostsTemplates, CDBHelper::getHash($sqlHostsTemplates)); + $this->assertEquals($oldHashMaintenancesHosts, CDBHelper::getHash($sqlMaintenancesHosts)); + $this->assertEquals($oldHashHostInventory, CDBHelper::getHash($sqlHostInventory)); + } + + + public function testPageHosts_MassDisableAll() { + DBexecute("update hosts set status=".HOST_STATUS_MONITORED." where status=".HOST_STATUS_NOT_MONITORED); + + $this->zbxTestLogin(self::HOST_LIST_PAGE); + $this->zbxTestCheckTitle('Configuration of hosts'); + $this->query('button:Reset')->one()->click(); + + $this->zbxTestCheckboxSelect('all_hosts'); + $this->zbxTestClickButtonText('Disable'); + $this->zbxTestAcceptAlert(); + + $this->zbxTestCheckTitle('Configuration of hosts'); + $this->zbxTestWaitUntilMessageTextPresent('msg-good', 'Hosts disabled'); + + $sql = "select * from hosts where status=".HOST_STATUS_MONITORED. + " and NOT flags = 2"; + $this->assertEquals(0, CDBHelper::getCount($sql), "Chuck Norris: all hosts disabled but DB does not match"); + } + + /** + * @dataProvider allHosts + */ + public function testPageHosts_MassDisable($host) { + DBexecute("update hosts set status=".HOST_STATUS_MONITORED." where status=".HOST_STATUS_NOT_MONITORED); + + $hostid = $host['hostid']; + + $this->zbxTestLogin(self::HOST_LIST_PAGE); + $this->zbxTestCheckTitle('Configuration of hosts'); + $this->query('button:Reset')->one()->click(); + + $this->zbxTestCheckboxSelect('hostids_'.$hostid); + $this->zbxTestClickButtonText('Disable'); + $this->zbxTestAcceptAlert(); + + $this->zbxTestCheckTitle('Configuration of hosts'); + $this->zbxTestWaitUntilMessageTextPresent('msg-good', 'Host disabled'); + + $sql = "select * from hosts where hostid=$hostid and status=".HOST_STATUS_NOT_MONITORED; + $this->assertEquals(1, CDBHelper::getCount($sql), "Chuck Norris: host $hostid disabled but status is wrong in the DB"); + } + + /** + * @dataProvider allHosts + */ + public function testPageHosts_MassActivate($host) { + DBexecute("update hosts set status=".HOST_STATUS_NOT_MONITORED." where status=".HOST_STATUS_MONITORED); + + $hostid = $host['hostid']; + + $this->zbxTestLogin(self::HOST_LIST_PAGE); + $this->zbxTestCheckTitle('Configuration of hosts'); + $this->query('button:Reset')->one()->click(); + + $this->zbxTestCheckboxSelect('hostids_'.$hostid); + $this->zbxTestClickButtonText('Enable'); + $this->zbxTestAcceptAlert(); + + $this->zbxTestCheckTitle('Configuration of hosts'); + $this->zbxTestWaitUntilMessageTextPresent('msg-good', 'Host enabled'); + + $sql = "select * from hosts where hostid=$hostid and status=".HOST_STATUS_MONITORED; + $this->assertEquals(1, CDBHelper::getCount($sql), "Chuck Norris: host $hostid activated but status is wrong in the DB"); + } + + public function testPageHosts_MassActivateAll() { + DBexecute("update hosts set status=".HOST_STATUS_NOT_MONITORED." where status=".HOST_STATUS_MONITORED); + + $this->zbxTestLogin(self::HOST_LIST_PAGE); + $this->zbxTestCheckTitle('Configuration of hosts'); + $this->query('button:Reset')->one()->click(); + + $this->zbxTestCheckboxSelect('all_hosts'); + $this->zbxTestClickButtonText('Enable'); + $this->zbxTestAcceptAlert(); + + $this->zbxTestCheckTitle('Configuration of hosts'); + $this->zbxTestWaitUntilMessageTextPresent('msg-good', 'Hosts enabled'); + + $sql = "select host from hosts where status=".HOST_STATUS_NOT_MONITORED. + " and NOT flags = 2"; + $this->assertEquals(0, CDBHelper::getCount($sql), "Chuck Norris: all hosts activated but DB does not match"); + } + + public function testPageHosts_FilterByName() { + $this->zbxTestLogin(self::HOST_LIST_PAGE); + $filter = $this->query('name:zbx_filter')->asForm()->one(); + $filter->query('button:Reset')->one()->click(); + $filter->getField('Name')->fill($this->HostName); + $filter->submit(); + $this->zbxTestTextPresent($this->HostName); + $this->zbxTestTextNotPresent('Displaying 0 of 0 found'); + } + + public function testPageHosts_FilterByTemplates() { + $this->zbxTestLogin(self::HOST_LIST_PAGE); + $filter = $this->query('name:zbx_filter')->asForm()->one(); + $filter->query('button:Reset')->one()->click(); + $filter->fill([ + 'Templates' => [ + 'values' =>'Form test template', + 'context' => 'Templates'] + ]); + $filter->submit(); + $this->zbxTestWaitForPageToLoad(); + $this->zbxTestAssertElementPresentXpath("//tbody//a[text()='Simple form test host']"); + $this->zbxTestAssertElementPresentXpath("//div[@class='table-stats'][text()='Displaying 1 of 1 found']"); + } + + public function testPageHosts_FilterByProxy() { + $this->zbxTestLogin(self::HOST_LIST_PAGE); + $filter = $this->query('name:zbx_filter')->asForm()->one(); + $filter->query('button:Reset')->one()->click(); + + $this->zbxTestClickXpathWait('//label[text()="Proxy"]'); + $this->zbxTestClickButtonText('Apply'); + $this->zbxTestAssertElementPresentXpath("//tbody//a[text()='Host_1 with proxy']"); + $this->zbxTestAssertElementPresentXpath("//tbody//td[text()='Proxy_1 for filter']"); + $this->zbxTestAssertElementPresentXpath("//tbody//a[text()='Host_2 with proxy']"); + $this->zbxTestAssertElementPresentXpath("//tbody//td[text()='Proxy_2 for filter']"); + $this->zbxTestAssertElementPresentXpath("//div[@class='table-stats'][text()='Displaying 3 of 3 found']"); + $this->zbxTestClickButtonMultiselect('filter_proxyids_'); + $this->zbxTestLaunchOverlayDialog('Proxies'); + $this->zbxTestClickLinkTextWait('Proxy_1 for filter'); + $this->zbxTestClickButtonText('Apply'); + $this->zbxTestWaitForPageToLoad(); + $this->zbxTestAssertElementPresentXpath("//tbody//a[text()='Host_1 with proxy']"); + $this->zbxTestAssertElementPresentXpath("//div[@class='table-stats'][text()='Displaying 1 of 1 found']"); + } + + public function testPageHosts_FilterNone() { + $this->zbxTestLogin(self::HOST_LIST_PAGE); + $filter = $this->query('name:zbx_filter')->asForm()->one(); + $filter->query('button:Reset')->one()->click(); + $filter->getField('Name')->fill('1928379128ksdhksdjfh'); + $filter->submit(); + $this->zbxTestAssertElementPresentXpath("//div[@class='table-stats'][text()='Displaying 0 of 0 found']"); + $filter->invalidate(); + $filter->getField('Name')->fill('%'); + $filter->submit(); + $this->zbxTestAssertElementPresentXpath("//div[@class='table-stats'][text()='Displaying 0 of 0 found']"); + } + + public function testPageHosts_FilterByAllFields() { + $this->zbxTestLogin(self::HOST_LIST_PAGE); + $filter = $this->query('name:zbx_filter')->asForm()->one(); + $filter->query('button:Reset')->one()->click(); + $filter->getField('Host groups')->select($this->HostGroup); + $filter->getField('Name')->fill($this->HostName); + $filter->getField('IP')->fill($this->HostIp); + $filter->getField('Port')->fill($this->HostPort); + $filter->submit(); + $this->zbxTestTextPresent($this->HostName); + $this->zbxTestAssertElementPresentXpath("//div[@class='table-stats'][text()='Displaying 1 of 1 found']"); + } + + public function testPageHosts_FilterReset() { + $this->zbxTestLogin(self::HOST_LIST_PAGE); + $this->query('button:Reset')->one()->click(); + $this->zbxTestTextNotPresent('Displaying 0 of 0 found'); + } + + public static function getFilterByTagsData() { + return [ + // "And" and "And/Or" checks. + [ + [ + 'evaluation_type' => 'And/Or', + 'tags' => [ + ['name' => 'tag', 'operator' => 'Contains', 'value' => 'host'], + ['name' => 'test', 'operator' => 'Contains', 'value' => 'test_tag'] + ], + 'result' => [ + [ + 'Name' => 'Host for tags filtering', + 'Tags' => [ + 'selector' => 'class:tag', + 'text' => ['tag: HOST', 'test: test_tag', 'action: simple'] + ] + ] + ] + ] + ], + [ + [ + 'evaluation_type' => 'Or', + 'tags' => [ + ['name' => 'tag', 'operator' => 'Contains', 'value' => 'host'], + ['name' => 'test', 'operator' => 'Contains', 'value' => 'test_tag'] + ], + 'result' => [ + [ + 'Name' => 'Host for tags filtering', + 'Tags' => [ + 'selector' => 'class:tag', + 'text' => ['tag: HOST', 'test: test_tag', 'action: simple'] + ] + ], + [ + 'Name' => 'Host for tags filtering - clone', + 'Tags' => [ + 'selector' => 'class:tag', + 'text' => ['tag: host', 'action: clone'] + ] + ], + [ + 'Name' => 'Host for tags filtering - update', + 'Tags' => [ + 'selector' => 'class:tag', + 'text' => ['tag: host', 'action: update'] + ] + ] + ] + ] + ], + // "Contains" and "Equals" checks. + [ + [ + 'evaluation_type' => 'And/Or', + 'tags' => [ + ['name' => 'tag', 'operator' => 'Contains', 'value' => 'HOST'] + ], + 'result' => [ + ['Name' => 'Host for tags filtering', 'Templates' => 'Template for tags filtering'], + ['Name' => 'Host for tags filtering - clone', 'Templates' => ''], + ['Name' => 'Host for tags filtering - update', 'Templates' => ''] + ] + ] + ], + [ + [ + 'evaluation_type' => 'And/Or', + 'tags' => [ + ['name' => 'tag', 'operator' => 'Equals', 'value' => 'HOST'] + ], + 'result' => [ + ['Name' => 'Host for tags filtering'] + ] + ] + ], + [ + [ + 'evaluation_type' => 'And/Or', + 'tags' => [ + ['name' => 'action', 'operator' => 'Contains'] + ], + 'result' => [ + ['Name' => 'Host for tags filtering'], + ['Name' => 'Host for tags filtering - clone'], + ['Name' => 'Host for tags filtering - update'] + ] + ] + ], + [ + [ + 'evaluation_type' => 'And/Or', + 'tags' => [ + ['name' => 'action', 'operator' => 'Equals'] + ] + ] + ], + [ + [ + 'evaluation_type' => 'And/Or', + 'tags' => [ + ['name' => 'tag', 'operator' => 'Exists'], + ['name' => 'test', 'operator' => 'Exists'] + ], + 'result' => [ + ['Name' => 'Host for tags filtering'] + ] + ] + ], + [ + [ + 'evaluation_type' => 'Or', + 'tags' => [ + ['name' => 'tag', 'operator' => 'Exists'], + ['name' => 'test', 'operator' => 'Exists'] + ], + 'result' => [ + ['Name' => 'Host for tags filtering'], + ['Name' => 'Host for tags filtering - clone'], + ['Name' => 'Host for tags filtering - update'] + ] + ] + ], + [ + [ + 'evaluation_type' => 'And/Or', + 'tags' => [ + ['name' => 'test', 'operator' => 'Exists'] + ], + 'result' => [ + ['Name' => 'Host for tags filtering'] + ] + ] + ], + [ + [ + 'evaluation_type' => 'Or', + 'tags' => [ + ['name' => 'action', 'operator' => 'Exists'] + ], + 'result' => [ + ['Name' => 'Host for tags filtering'], + ['Name' => 'Host for tags filtering - clone'], + ['Name' => 'Host for tags filtering - update'] + ] + ] + ], + [ + [ + 'evaluation_type' => 'And/Or', + 'tags' => [ + ['name' => 'test', 'operator' => 'Does not exist'] + ], + 'result' => [ + ['Name' => 'Host for tags filtering - clone'], + ['Name' => 'Host for tags filtering - update'], + ['Name' => 'Simple form test host'], + ['Name' => 'SLA reports host'], + ['Name' => 'Template inheritance test host'] + ] + ] + ], + [ + [ + 'evaluation_type' => 'Or', + 'tags' => [ + ['name' => 'test', 'operator' => 'Does not exist'] + ], + 'result' => [ + ['Name' => 'Host for tags filtering - clone'], + ['Name' => 'Host for tags filtering - update'], + ['Name' => 'Simple form test host'], + ['Name' => 'SLA reports host'], + ['Name' => 'Template inheritance test host'] + ] + ] + ], + [ + [ + 'evaluation_type' => 'Or', + 'tags' => [ + ['name' => 'test', 'operator' => 'Does not exist'], + ['name' => 'tag', 'operator' => 'Does not exist'] + ], + 'result' => [ + ['Name' => 'Host for tags filtering - clone'], + ['Name' => 'Host for tags filtering - update'], + ['Name' => 'Simple form test host'], + ['Name' => 'SLA reports host'], + ['Name' => 'Template inheritance test host'] + ] + ] + ], + [ + [ + 'evaluation_type' => 'And/Or', + 'tags' => [ + ['name' => 'test', 'operator' => 'Does not exist'], + ['name' => 'tag', 'operator' => 'Does not exist'] + ], + 'result' => [ + ['Name' => 'Simple form test host'], + ['Name' => 'SLA reports host'], + ['Name' => 'Template inheritance test host'] + ] + ] + ], + [ + [ + 'evaluation_type' => 'And/Or', + 'tags' => [ + ['name' => 'test', 'operator' => 'Does not equal', 'value' => 'test_tag'] + ], + 'result' => [ + ['Name' => 'Host for tags filtering - clone'], + ['Name' => 'Host for tags filtering - update'], + ['Name' => 'Simple form test host'], + ['Name' => 'SLA reports host'], + ['Name' => 'Template inheritance test host'] + ] + ] + ], + [ + [ + 'evaluation_type' => 'Or', + 'tags' => [ + ['name' => 'test', 'operator' => 'Does not equal', 'value' => 'test_tag'] + ], + 'result' => [ + ['Name' => 'Host for tags filtering - clone'], + ['Name' => 'Host for tags filtering - update'], + ['Name' => 'Simple form test host'], + ['Name' => 'SLA reports host'], + ['Name' => 'Template inheritance test host'] + ] + ] + ], + [ + [ + 'evaluation_type' => 'And/Or', + 'tags' => [ + ['name' => 'test', 'operator' => 'Does not equal'] + ], + 'result' => [ + ['Name' => 'Host for tags filtering'], + ['Name' => 'Host for tags filtering - clone'], + ['Name' => 'Host for tags filtering - update'], + ['Name' => 'Simple form test host'], + ['Name' => 'SLA reports host'], + ['Name' => 'Template inheritance test host'] + ] + ] + ], + [ + [ + 'evaluation_type' => 'And/Or', + 'tags' => [ + ['name' => 'action', 'operator' => 'Does not equal', 'value' => 'update'], + ['name' => 'action', 'operator' => 'Does not equal', 'value' => 'simple'] + ], + 'result' => [ + ['Name' => 'Host for tags filtering - clone'], + ['Name' => 'Simple form test host'], + ['Name' => 'SLA reports host'], + ['Name' => 'Template inheritance test host'] + ] + ] + ], + [ + [ + 'evaluation_type' => 'Or', + 'tags' => [ + ['name' => 'action', 'operator' => 'Does not equal', 'value' => 'update'], + ['name' => 'action', 'operator' => 'Does not equal', 'value' => 'simple'] + ], + 'result' => [ + ['Name' => 'Host for tags filtering - clone'], + ['Name' => 'Simple form test host'], + ['Name' => 'SLA reports host'], + ['Name' => 'Template inheritance test host'] + ] + ] + ], + [ + [ + 'evaluation_type' => 'And/Or', + 'tags' => [ + ['name' => 'action', 'operator' => 'Does not contain', 'value' => 'clone'] + ], + 'result' => [ + ['Name' => 'Host for tags filtering'], + ['Name' => 'Host for tags filtering - update'], + ['Name' => 'Simple form test host'], + ['Name' => 'SLA reports host'], + ['Name' => 'Template inheritance test host'] + ] + ] + ], + [ + [ + 'evaluation_type' => 'Or', + 'tags' => [ + ['name' => 'action', 'operator' => 'Does not contain', 'value' => 'clone'] + ], + 'result' => [ + ['Name' => 'Host for tags filtering'], + ['Name' => 'Host for tags filtering - update'], + ['Name' => 'Simple form test host'], + ['Name' => 'SLA reports host'], + ['Name' => 'Template inheritance test host'] + ] + ] + ], + [ + [ + 'evaluation_type' => 'And/Or', + 'tags' => [ + ['name' => 'action', 'operator' => 'Does not contain', 'value' => 'clo'], + ['name' => 'tag', 'operator' => 'Does not contain', 'value' => 'ho'] + ], + 'result' => [ + ['Name' => 'Simple form test host'], + ['Name' => 'SLA reports host'], + ['Name' => 'Template inheritance test host'] + ] + ] + ], + [ + [ + 'evaluation_type' => 'Or', + 'tags' => [ + ['name' => 'action', 'operator' => 'Does not contain', 'value' => 'clo'], + ['name' => 'tag', 'operator' => 'Does not contain', 'value' => 'ho'] + ], + 'result' => [ + ['Name' => 'Host for tags filtering'], + ['Name' => 'Host for tags filtering - update'], + ['Name' => 'Simple form test host'], + ['Name' => 'SLA reports host'], + ['Name' => 'Template inheritance test host'] + ] + ] + ], + [ + [ + 'evaluation_type' => 'And/Or', + 'tags' => [ + ['name' => 'action', 'operator' => 'Does not contain', 'value' => 'clone'], + ['name' => 'tag', 'operator' => 'Equals', 'value' => 'host'] + ], + 'result' => [ + ['Name' => 'Host for tags filtering - update'] + ] + ] + ], + [ + [ + 'evaluation_type' => 'And/Or', + 'tags' => [ + ['name' => 'action', 'operator' => 'Does not contain', 'value' => 'clone'], + ['name' => 'tag', 'operator' => 'Exists'] + ], + 'result' => [ + ['Name' => 'Host for tags filtering'], + ['Name' => 'Host for tags filtering - update'] + ] + ] + ] + ]; + } + + /** + * Test filtering hosts by tags. + * + * @dataProvider getFilterByTagsData + */ + public function testPageHosts_FilterByTags($data) { + $this->page->login()->open((new CUrl('zabbix.php')) + ->setArgument('action', 'host.list') + ->setArgument('filter_groups[]', 4) + ->setArgument('filter_host', 'host') + ->setArgument('filter_port', 10051) + ->setArgument('filter_set', 1) + ->getUrl() + ); + $form = $this->query('name:zbx_filter')->waitUntilPresent()->asForm()->one(); + $form->fill(['id:filter_evaltype' => $data['evaluation_type']]); + $this->setTags($data['tags']); + $form->submit(); + $this->page->waitUntilReady(); + // Check filtered result. + $this->assertTableData(CTestArrayHelper::get($data, 'result', [])); + + // Reset filter due to not influence further tests. + $form->query('button:Reset')->one()->click(); + } +} diff --git a/ui/tests/selenium/hosts/testPageMonitoringHosts.php b/ui/tests/selenium/hosts/testPageMonitoringHosts.php new file mode 100644 index 00000000000..5dee0ef8e5f --- /dev/null +++ b/ui/tests/selenium/hosts/testPageMonitoringHosts.php @@ -0,0 +1,1184 @@ +page->login()->open('zabbix.php?action=host.view')->waitUntilReady(); + $form = $this->query('name:zbx_filter')->waitUntilPresent()->asForm()->one(); + $table = $this->query('class:list-table')->asTable()->one(); + + // Checking Title, Header and Column names. + $this->page->assertTitle('Hosts'); + $this->page->assertHeader('Hosts'); + $headers = ['Name', 'Interface', 'Availability', 'Tags', 'Status', 'Latest data', 'Problems','Graphs', + 'Dashboards', 'Web']; + $this->assertSame($headers, ($this->query('class:list-table')->asTable()->one())->getHeadersText()); + + // Check filter collapse/expand. + foreach ([true, false] as $status) { + $this->assertTrue($this->query('xpath://ul[@class="ui-sortable-container ui-sortable"]//li[contains(@class, "selected")]') + ->one()->isPresent($status) + ); + $this->query('xpath://a[@aria-label="Home"]')->one()->click(); + } + + // Check fields maximum length. + foreach(['tags[0][tag]', 'tags[0][value]'] as $field) { + $this->assertEquals(255, $form->query('xpath:.//input[@name="'.$field.'"]') + ->one()->getAttribute('maxlength')); + } + + // Check tags maximum length. + foreach(['name', 'ip', 'dns', 'port'] as $field) { + $this->assertEquals(255, $form->query('xpath:.//input[@id="'.$field.'_0"]') + ->one()->getAttribute('maxlength')); + } + + // Check disabled links. + foreach (['Graphs', 'Dashboards', 'Web'] as $disabled) { + $row = $table->findRow('Name', 'Available host'); + $this->assertTrue($row->query('xpath://following::td/span[@class="disabled" and text()="'.$disabled.'"]')->exists()); + } + + // Check tags on the specific host. + $tags = $table->findRow('Name', 'Host for tags filtering - clone')->getColumn('Tags')->query('class:tag')->all(); + $this->assertEquals(['action: clone', 'tag: host'], $tags->asText()); + + foreach ($tags as $tag) { + $tag->click(); + $hint = $this->query('xpath://div[@data-hintboxid]')->asOverlayDialog()->waitUntilPresent()->all()->last(); + $this->assertEquals($tag->getText(), $hint->getText()); + $hint->close(); + } + } + + public static function getCheckFilterData() { + return [ + [ + [ + 'filter' => [ + 'Name' => 'Empty host' + ], + 'expected' => [ + 'Empty host' + ] + ] + ], + [ + [ + 'filter' => [ + 'Host groups' => [ + 'Group to copy all graph' + ] + ], + 'expected' => [ + 'Host with item to copy all graphs 1', + 'Host with item to copy all graphs 2' + ] + ] + ], + [ + [ + 'filter' => [ + 'IP' => '127.0.0.3' + ], + 'expected' => [ + 'Template inheritance test host', + 'Test item host' + ] + ] + ], + [ + [ + 'filter' => [ + 'DNS' => 'zabbixzabbixzabbix.com' + ], + 'expected' => [ + 'Available host', + 'Not available host', + 'Not available host in maintenance', + 'Unknown host', + 'Unknown host in maintenance' + ] + ] + ], + [ + [ + 'filter' => [ + 'Port' => '161' + ], + 'expected' => [ + 'Test item host', + 'Visible host for template linkage' + ] + ] + ], + [ + [ + 'filter' => [ + 'Severity' => [ + 'Not classified' + ] + ], + 'expected' => [ + '1_Host_to_check_Monitoring_Overview', + 'Host for tag permissions' + ] + ] + ], + [ + [ + 'filter' => [ + 'Severity' => [ + 'Warning' + ] + ], + 'expected' => [ + '1_Host_to_check_Monitoring_Overview', + 'ЗАББИКС Сервер' + ] + ] + ], + [ + [ + 'filter' => [ + 'Severity' => [ + 'High' + ] + ], + 'expected' => [ + '1_Host_to_check_Monitoring_Overview' + ] + ] + ], + [ + [ + 'filter' => [ + 'Severity' => [ + 'Information' + ] + ], + 'expected' => [ + '1_Host_to_check_Monitoring_Overview' + ] + ] + ], + [ + [ + 'filter' => [ + 'Severity' => [ + 'Average' + ] + ], + 'expected' => [ + '1_Host_to_check_Monitoring_Overview', + '3_Host_to_check_Monitoring_Overview', + '4_Host_to_check_Monitoring_Overview', + 'Host for triggers filtering', + 'ЗАББИКС Сервер' + ] + ] + ], + [ + [ + 'filter' => [ + 'Severity' => 'Disaster' + ], + 'expected' => [ + '1_Host_to_check_Monitoring_Overview' + ] + ] + ], + [ + [ + 'filter' => [ + 'Status' => 'Disabled' + ], + 'expected' => [ + 'No data found.' + ] + ] + ], + [ + [ + 'filter' => [ + 'Name' => 'available', + 'Host groups' => [ + 'Group for Host availability widget' + ] + ], + 'expected' => [ + 'Available host', + 'Not available host' + ] + ] + ], + [ + [ + 'filter' => [ + 'Name' => 'for', + 'Host groups' => [ + 'Zabbix servers' + ], + 'IP' => '127.0.5.1' + ], + 'expected' => [ + 'Simple form test host' + ] + ] + ], + [ + [ + 'filter' => [ + 'Name' => 'Unknown', + 'Host groups' => [ + 'Group for Host availability widget'], + 'IP' => '127.0.0.1', + 'DNS' => 'zabbix.com' + ], + 'expected' => [ + 'Unknown host' + ] + ] + ], + [ + [ + 'filter' => [ + 'Name' => 'maintenance', + 'Host groups' => [ + 'Group in maintenance for Host availability widget' + ], + 'IP' => '127.0.0.1', + 'DNS' => 'zab', + 'Port' => '10050' + ], + 'expected' => [ + 'Not available host in maintenance', + 'Unknown host in maintenance' + ] + ] + ], + [ + [ + 'filter' => [ + 'Severity' => [ + 'Not classified', + 'Warning', + 'High', + 'Information', + 'Average', + 'Disaster' + ] + ], + 'expected' => [ + '1_Host_to_check_Monitoring_Overview', + '3_Host_to_check_Monitoring_Overview', + '4_Host_to_check_Monitoring_Overview', + 'Host for tag permissions', + 'Host for triggers filtering', + 'ЗАББИКС Сервер' + ] + ] + ], + [ + [ + 'filter' => [ + 'Name' => 'Tommy' + ], + 'expected' => [] + ] + ], + // With name 'maintenance', exists 3 hosts in maintenance status. Unchecking 'Show hosts in maintenance'. + [ + [ + 'filter' => [ + 'Name' => 'maintenance', + 'Show hosts in maintenance' => false + ], + 'expected' => [] + ] + ], + [ + [ + 'filter' => [ + 'Name' => 'maintenance' + ], + 'expected' => [ + 'Available host in maintenance', + 'Not available host in maintenance', + 'Unknown host in maintenance' + ] + ] + ] + ]; + } + + /** + * @dataProvider getCheckFilterData + */ + public function testPageMonitoringHosts_CheckFilter($data) { + $this->page->login()->open('zabbix.php?action=host.view&filter_reset=1'); + $form = $this->query('name:zbx_filter')->waitUntilPresent()->asForm()->one(); + $form->fill($data['filter']); + $table = $this->query('class:list-table')->waitUntilPresent()->asTable()->one(); + $this->query('button:Apply')->waitUntilClickable()->one()->click(); + $table->waitUntilReloaded(); + $this->assertTableDataColumn($data['expected']); + $this->query('button:Reset')->waitUntilClickable()->one()->click(); + $table->waitUntilReloaded(); + } + + public static function getTagsFilterData() { + return [ + [ + [ + 'tag_options' => [ + 'type' => 'And/Or', + 'tags' => [ + ['name' => 'test', 'value' => 'test_tag', 'operator' => 'Equals'] + ] + ], + 'result' => [ + 'Host for tags filtering' + ] + ] + ], + [ + [ + 'tag_options' => [ + 'type' => 'And/Or', + 'tags' => [ + ['name' => 'test', 'value' => '', 'operator' => 'Contains'] + ] + ], + 'result' => [ + 'Host for tags filtering' + ] + ] + ], + [ + [ + 'tag_options' => [ + 'type' => 'Or', + 'tags' => [ + ['name' => 'test', 'value' => 'test_tag', 'operator' => 'Equals'], + ['name' => 'action', 'value' => 'clone', 'operator' => 'Contains'] + ] + ], + 'result' => [ + 'Host for tags filtering', + 'Host for tags filtering - clone' + ] + ] + ], + [ + [ + 'tag_options' => [ + 'type' => 'Or', + 'tags' => [ + ['name' => 'action', 'value' => 'clone', 'operator' => 'Equals'], + ['name' => 'tag', 'value' => 'host', 'operator' => 'Equals'] + ] + ], + 'result' => [ + 'Host for tags filtering - clone', + 'Host for tags filtering - update' + ] + ] + ], + [ + [ + 'tag_options' => [ + 'type' => 'And/Or', + 'tags' => [ + ['name' => 'action', 'value' => 'clone', 'operator' => 'Contains'], + ['name' => 'tag', 'value' => 'host', 'operator' => 'Contains'] + ] + ], + 'result' => [ + 'Host for tags filtering - clone' + ] + ] + ], + [ + [ + 'tag_options' => [ + 'type' => 'Or', + 'tags' => [ + ['name' => 'action', 'value' => 'clone', 'operator' => 'Equals'], + ['name' => 'action', 'value' => 'update', 'operator' => 'Equals'], + ['name' => 'tag', 'value' => 'TEMPLATE', 'operator' => 'Equals'] + ] + ], + 'result' => [ + 'Host for tags filtering', + 'Host for tags filtering - clone', + 'Host for tags filtering - update' + ] + ] + ], + // Wrote 'template' in lowercase. + [ + [ + 'tag_options' => [ + 'type' => 'And/Or', + 'tags' => [ + ['name' => 'tag', 'value' => 'template', 'operator' => 'Equals'] + ] + ], + 'result' => [] + ] + ], + // Non-existing tag. + [ + [ + 'tag_options' => [ + 'type' => 'And/Or', + 'tags' => [ + ['name' => 'Tommy', 'value' => 'train', 'operator' => 'Contains'] + ] + ], + 'result' => [] + ] + ], + [ + [ + 'tag_options' => [ + 'type' => 'And/Or', + 'tags' => [ + ['name' => 'test', 'operator' => 'Exists'] + ] + ], + 'result' => [ + 'Host for tags filtering' + ] + ] + ], + [ + [ + 'tag_options' => [ + 'type' => 'Or', + 'tags' => [ + ['name' => 'test', 'operator' => 'Exists'] + ] + ], + 'result' => [ + 'Host for tags filtering' + ] + ] + ], + [ + [ + 'tag_options' => [ + 'type' => 'And/Or', + 'tags' => [ + ['name' => 'tag', 'operator' => 'Exists'], + ['name' => 'test', 'operator' => 'Exists'] + ] + ], + 'result' => [ + 'Host for tags filtering' + ] + ] + ], + [ + [ + 'tag_options' => [ + 'type' => 'Or', + 'tags' => [ + ['name' => 'tag', 'operator' => 'Exists'], + ['name' => 'test', 'operator' => 'Exists'] + ] + ], + 'result' => [ + 'Host for tags filtering', + 'Host for tags filtering - clone', + 'Host for tags filtering - update' + ] + ] + ], + [ + [ + 'tag_options' => [ + 'type' => 'And/Or', + 'tags' => [ + ['name' => 'test', 'operator' => 'Does not exist'] + ] + ], + 'result' => [ + 'Host for tags filtering - clone', + 'Host for tags filtering - update', + 'Simple form test host', + 'SLA reports host', + 'Template inheritance test host', + 'ЗАББИКС Сервер' + ] + ] + ], + [ + [ + 'tag_options' => [ + 'type' => 'Or', + 'tags' => [ + ['name' => 'test', 'operator' => 'Does not exist'] + ] + ], + 'result' => [ + 'Host for tags filtering - clone', + 'Host for tags filtering - update', + 'Simple form test host', + 'SLA reports host', + 'Template inheritance test host', + 'ЗАББИКС Сервер' + ] + ] + ], + [ + [ + 'tag_options' => [ + 'type' => 'Or', + 'tags' => [ + ['name' => 'action', 'operator' => 'Does not exist'], + ['name' => 'tag', 'operator' => 'Does not exist'] + ] + ], + 'result' => [ + 'Simple form test host', + 'SLA reports host', + 'Template inheritance test host', + 'ЗАББИКС Сервер' + ] + ] + ], + [ + [ + 'tag_options' => [ + 'type' => 'And/Or', + 'tags' => [ + ['name' => 'action', 'operator' => 'Does not exist'], + ['name' => 'tag', 'operator' => 'Does not exist'] + ] + ], + 'result' => [ + 'Simple form test host', + 'SLA reports host', + 'Template inheritance test host', + 'ЗАББИКС Сервер' + ] + ] + ], + [ + [ + 'tag_options' => [ + 'type' => 'And/Or', + 'tags' => [ + ['name' => 'test', 'operator' => 'Does not equal', 'value' => 'test_tag'] + ] + ], + 'result' => [ + 'Host for tags filtering - clone', + 'Host for tags filtering - update', + 'Simple form test host', + 'SLA reports host', + 'Template inheritance test host', + 'ЗАББИКС Сервер' + ] + ] + ], + [ + [ + 'tag_options' => [ + 'type' => 'Or', + 'tags' => [ + ['name' => 'test', 'operator' => 'Does not equal', 'value' => 'test_tag'] + ] + ], + 'result' => [ + 'Host for tags filtering - clone', + 'Host for tags filtering - update', + 'Simple form test host', + 'SLA reports host', + 'Template inheritance test host', + 'ЗАББИКС Сервер' + ] + ] + ], + [ + [ + 'tag_options' => [ + 'type' => 'And/Or', + 'tags' => [ + ['name' => 'test', 'operator' => 'Does not equal', 'value' => 'test_tag'], + ['name' => 'action', 'operator' => 'Does not equal', 'value' => 'clone'] + ] + ], + 'result' => [ + 'Host for tags filtering - update', + 'Simple form test host', + 'SLA reports host', + 'Template inheritance test host', + 'ЗАББИКС Сервер' + ] + ] + ], + [ + [ + 'tag_options' => [ + 'type' => 'Or', + 'tags' => [ + ['name' => 'test', 'operator' => 'Does not equal', 'value' => 'test_tag'], + ['name' => 'action', 'operator' => 'Does not equal', 'value' => 'clone'] + ] + ], + 'result' => [ + 'Host for tags filtering', + 'Host for tags filtering - clone', + 'Host for tags filtering - update', + 'Simple form test host', + 'SLA reports host', + 'Template inheritance test host', + 'ЗАББИКС Сервер' + ] + ] + ], + [ + [ + 'tag_options' => [ + 'type' => 'And/Or', + 'tags' => [ + ['name' => 'tag', 'operator' => 'Does not contain', 'value' => 'host'] + ] + ], + 'result' => [ + 'Simple form test host', + 'SLA reports host', + 'Template inheritance test host', + 'ЗАББИКС Сервер' + ] + ] + ], + [ + [ + 'tag_options' => [ + 'type' => 'Or', + 'tags' => [ + ['name' => 'tag', 'operator' => 'Does not contain', 'value' => 'host'] + ] + ], + 'result' => [ + 'Simple form test host', + 'SLA reports host', + 'Template inheritance test host', + 'ЗАББИКС Сервер' + ] + ] + ], + [ + [ + 'tag_options' => [ + 'type' => 'And/Or', + 'tags' => [ + ['name' => 'action', 'operator' => 'Does not contain', 'value' => 'clone'], + ['name' => 'tag', 'operator' => 'Does not contain', 'value' => 'host'] + ] + ], + 'result' => [ + 'Simple form test host', + 'SLA reports host', + 'Template inheritance test host', + 'ЗАББИКС Сервер' + ] + ] + ], + [ + [ + 'tag_options' => [ + 'type' => 'Or', + 'tags' => [ + ['name' => 'action', 'operator' => 'Does not contain', 'value' => 'clone'], + ['name' => 'tag', 'operator' => 'Does not contain', 'value' => 'host'] + ] + ], + 'result' => [ + 'Host for tags filtering', + 'Host for tags filtering - update', + 'Simple form test host', + 'SLA reports host', + 'Template inheritance test host', + 'ЗАББИКС Сервер' + ] + ] + ], + [ + [ + 'tag_options' => [ + 'type' => 'And/Or', + 'tags' => [ + ['name' => 'action', 'operator' => 'Does not contain', 'value' => 'clone'], + ['name' => 'tag', 'operator' => 'Equals', 'value' => 'host'] + ] + ], + 'result' => [ + 'Host for tags filtering - update' + ] + ] + ], + [ + [ + 'tag_options' => [ + 'type' => 'And/Or', + 'tags' => [ + ['name' => 'action', 'operator' => 'Does not contain', 'value' => 'clone'], + ['name' => 'tag', 'operator' => 'Exists'] + ] + ], + 'result' => [ + 'Host for tags filtering', + 'Host for tags filtering - update' + ] + ] + ] + ]; + } + + /** + * @dataProvider getTagsFilterData + */ + public function testPageMonitoringHosts_TagsFilter($data) { + $this->page->login()->open('zabbix.php?port=10051&action=host.view&groupids%5B%5D=4'); + $form = $this->query('name:zbx_filter')->waitUntilPresent()->asForm()->one(); + $table = $this->query('class:list-table')->waitUntilPresent()->one(); + $form->fill(['id:evaltype_0' => $data['tag_options']['type']]); + $this->setTagSelector('id:tags_0'); + $this->setTags($data['tag_options']['tags']); + $this->query('button:Apply')->one()->waitUntilClickable()->click(); + $table->waitUntilReloaded(); + $this->assertTableDataColumn(CTestArrayHelper::get($data, 'result', [])); + $this->query('button:Reset')->one()->waitUntilClickable()->click(); + $table->waitUntilReloaded(); + } + + public function testPageMonitoringHosts_ResetButtonCheck() { + $this->page->login()->open('zabbix.php?action=host.view&filter_reset=1'); + $form = $this->query('name:zbx_filter')->waitUntilPresent()->asForm()->one(); + $this->page->waitUntilReady(); + $table = $this->query('class:list-table')->asTable()->one(); + + // Check table contents before filtering. + $start_rows_count = $table->getRows()->count(); + $this->assertTableStats($start_rows_count); + $start_contents = $this->getTableResult('Name'); + + // Filter hosts. + $form->fill(['Name' => 'Empty host']); + $this->query('button:Apply')->one()->waitUntilClickable()->click(); + $table->waitUntilReloaded(); + + // Check that filtered count matches expected. + $this->assertEquals(1, $table->getRows()->count()); + $this->assertTableStats(1); + + // After pressing reset button, check that previous hosts are displayed again. + $this->query('button:Reset')->one()->click(); + $table->waitUntilReloaded(); + $reset_rows_count = $table->getRows()->count(); + $this->assertEquals($start_rows_count, $reset_rows_count); + $this->assertTableStats($reset_rows_count); + $this->assertEquals($start_contents, $this->getTableResult('Name')); + } + + // Checking that Show suppressed problems filter works. + public function testPageMonitoringHosts_ShowSuppresed() { + $this->page->login()->open('zabbix.php?action=host.view&filter_reset=1'); + $form = $this->query('name:zbx_filter')->waitUntilPresent()->asForm()->one(); + $this->page->waitUntilReady(); + $table = $this->query('class:list-table')->asTable()->one(); + $form->fill(['Severity' => ['Not classified', 'Information', 'Warning', 'Average', 'High', 'Disaster']]); + $this->query('button:Apply')->one()->waitUntilClickable()->click(); + $table->waitUntilReloaded(); + foreach ([true, false] as $show) { + $form->query('id:show_suppressed_0')->asCheckbox()->one()->fill($show); + $this->query('button:Apply')->one()->waitUntilClickable()->click(); + $table->waitUntilReloaded(); + $this->assertTrue($table->findRow('Name', 'Host for suppression')->isPresent($show)); + } + $this->query('button:Reset')->one()->click(); + } + + public static function getEnabledLinksData() { + return [ + [ + [ + 'name' => 'Dynamic widgets H1', + 'link_name' => 'Graphs', + 'page_header' => 'Graphs' + ] + ], + [ + [ + 'name' => 'Host ZBX6663', + 'link_name' => 'Web', + 'page_header' => 'Web monitoring' + ] + ], + [ + [ + 'name' => 'ЗАББИКС Сервер', + 'link_name' => 'Dashboards', + 'page_header' => 'Network interfaces' + ] + ], + [ + [ + 'name' => 'Empty host', + 'link_name' => 'Problems', + 'page_header' => 'Problems' + ] + ], + [ + [ + 'name' => 'Available host', + 'link_name' => 'Latest data', + 'page_header' => 'Latest data' + ] + ] + ]; + } + + /** + * @dataProvider getEnabledLinksData + * + * Check enabled links and that correct host is displayed. + */ + public function testPageMonitoringHosts_EnabledLinks($data) { + $this->page->login()->open('zabbix.php?action=host.view&filter_reset=1'); + $form = $this->query('name:zbx_filter')->waitUntilPresent()->asForm()->one(); + switch ($data['name']) { + case 'Dynamic widgets H1': + case 'Host ZBX6663': + case 'Available host': + $this->selectLink($data['name'], $data['link_name'], $data['page_header']); + $this->page->waitUntilReady(); + $filter_form = $this->query('name:zbx_filter')->waitUntilPresent()->asForm()->one(); + $filter_form->checkValue(['Hosts' => $data['name']]); + $this->query('button:Reset')->one()->click(); + break; + case 'ЗАББИКС Сервер': + $this->selectLink($data['name'], $data['link_name'], $data['page_header']); + break; + case 'Empty host': + $this->page->waitUntilReady(); + $this->query('xpath://td/a[text()="'.$data['name'].'"]/following::td/a[text()="'.$data['link_name'].'"]') + ->one()->click(); + $this->page->waitUntilReady(); + $this->page->assertHeader($data['page_header']); + $form->checkValue(['Hosts' => $data['name']]); + $this->query('button:Reset')->one()->click(); + break; + } + } + + public static function getHostContextMenuData() { + return [ + [ + [ + 'name' => 'ЗАББИКС Сервер', + 'disabled' => ['Web'], + 'titles' => [ + 'Inventory', + 'Latest data', + 'Problems', + 'Graphs', + 'Dashboards', + 'Web', + 'Configuration', + 'Detect operating system', + 'Ping', + 'Script for Clone', + 'Script for Delete', + 'Script for Update', + 'Traceroute' + ] + ] + ], + [ + [ + 'name' => 'Available host', + 'disabled' => ['Web', 'Graphs', 'Dashboards'], + 'titles' => [ + 'Inventory', + 'Latest data', + 'Problems', + 'Graphs', + 'Dashboards', + 'Web', + 'Configuration', + 'Detect operating system', + 'Ping', + 'Script for Clone', + 'Script for Delete', + 'Script for Update', + 'Traceroute' + ] + ] + ], + [ + [ + 'name' => 'Dynamic widgets H1', + 'disabled' => ['Dashboards', 'Web'], + 'titles' => [ + 'Inventory', + 'Latest data', + 'Problems', + 'Graphs', + 'Dashboards', + 'Web', + 'Configuration', + 'Detect operating system', + 'Ping', + 'Script for Clone', + 'Script for Delete', + 'Script for Update', + 'Traceroute' + ] + ] + ], + [ + [ + 'name' => 'Host ZBX6663', + 'disabled' => ['Dashboards'], + 'titles' => [ + 'Inventory', + 'Latest data', + 'Problems', + 'Graphs', + 'Dashboards', + 'Web', + 'Configuration', + 'Detect operating system', + 'Ping', + 'Script for Clone', + 'Script for Delete', + 'Script for Update', + 'Traceroute' + ] + ] + ] + ]; + } + + /** + * @dataProvider getHostContextMenuData + * + * Click on host name from the table and check displayed popup context. + */ + public function testPageMonitoringHosts_HostContextMenu($data) { + $this->page->login()->open('zabbix.php?action=host.view&filter_reset=1')->waitUntilReady(); + $row = $this->query('class:list-table')->asTable()->one()->findRow('Name', $data['name']); + $row->query('link', $data['name'])->one()->click(); + $this->page->waitUntilReady(); + $popup = CPopupMenuElement::find()->waitUntilVisible()->one(); + $this->assertEquals(['HOST', 'SCRIPTS'], $popup->getTitles()->asText()); + $this->assertTrue($popup->hasItems($data['titles'])); + foreach ($data['disabled'] as $disabled) { + $this->assertTrue($popup->query('xpath://a[@aria-label="Host, '. + $disabled.'" and @class="menu-popup-item disabled"]')->one()->isPresent()); + } + } + + /** + * Check number of problems displayed on Hosts and Problems page. + */ + public function testPageMonitoringHosts_CountProblems() { + $this->page->login(); + $hosts_names = ['1_Host_to_check_Monitoring_Overview', 'ЗАББИКС Сервер', 'Host for tag permissions', 'Empty host']; + foreach ($hosts_names as $host) { + $this->page->open('zabbix.php?action=host.view&name='.$host)->waitUntilReady(); + $table = $this->query('class:list-table')->asTable()->one(); + + // Get number of problems displayed on icon and it severity level. + if ($host !== 'Empty host') { + $icons = $table->query('xpath:.//*[contains(@class, "problem-icon-list-item")]')->all(); + $results = []; + + foreach ($icons as $icon) { + $amount = $icon->getText(); + $severity = $icon->getAttribute('title'); + $results[$severity] = $amount; + } + } + else { + $this->assertEquals('Problems', $table->getRow(0)->getColumn('Problems')->getText()); + } + + // Navigate to Problems page from Hosts. + $table->getRow(0)->getColumn('Problems')->query('xpath:.//a')->one()->click(); + $this->page->waitUntilReady(); + $this->page->assertTitle('Problems'); + $this->query('name:zbx_filter')->waitUntilPresent()->asForm()->one()->checkValue(['Hosts' => $host]); + + // Count problems of each severity and compare it with problems count from Hosts page. + if ($host !== 'Empty host') { + foreach ($results as $severity => $count) { + $problem_count = $table->query('xpath:.//td[contains(@class, "-bg") and text()="'.$severity.'"]') + ->all()->count(); + $this->assertEquals(strval($problem_count), $count); + } + } + + // Check that table is empty and No data found displayed. + else { + $this->assertTableData(); + } + } + } + + public function prepareUpdateData() { + $response = CDataHelper::call('host.update', ['hostid' => '99013', 'status' => 1]); + $this->assertArrayHasKey('hostids', $response); + self::$hostid = $response['hostids'][0]; + } + + /** + * @backup hosts + * + * @onBeforeOnce prepareUpdateData + */ + public function testPageMonitoringHosts_TableSorting() { + // Sort by name and status. + $this->page->login()->open('zabbix.php?action=host.view&filter_reset=1')->waitUntilReady(); + foreach (['Name', 'Status'] as $listing) { + $query = $this->query('xpath://a[@href and text()="'.$listing.'"]'); + $query->one()->click(); + $this->page->waitUntilReady(); + $after_listing = $this->getTableResult($listing); + $query->one()->click(); + $this->page->waitUntilReady(); + $this->assertEquals(array_reverse($after_listing), $this->getTableResult($listing)); + } + } + + /** + * Clicking on link from the table and then checking page header + * + * @param string $host_name Host name + * @param string $column Column name + * @param string $page_header Page header name + */ + private function selectLink($host_name, $column, $page_header) { + $this->page->waitUntilReady(); + $this->query('class:list-table')->asTable()->one()->findRow('Name', $host_name)->query('link', $column)->one()->click(); + $this->page->waitUntilReady(); + if ($page_header !== null) { + $this->page->assertHeader($page_header); + } + if ($host_name === 'Dynamic widgets H1' && $this->query('xpath://li[@aria-labelledby="ui-id-2"'. + ' and @aria-selected="false"]')->exists()) { + $this->query('id:ui-id-2')->one()->click(); + } + if ($host_name === 'ЗАББИКС Сервер' && $column === 'Dashboards') { + $this->assertEquals('ЗАББИКС Сервер', $this->query('xpath://ul[@class="breadcrumbs"]/li[2]')->one()->getText()); + } + } + + public static function getCheckCountersData() { + return [ + [ + [ + 'host' => 'Host ZBX6663', + 'counters' => [ + [ + 'column' => 'Latest data', + 'counter' => 14 + ], + [ + 'column' => 'Problems', + 'counter' => null + ], + [ + 'column' => 'Graphs', + 'counter' => 2 + ], + [ + 'column' => 'Web', + 'counter' => 2 + ] + ] + ] + ], + [ + [ + 'host' => 'ЗАББИКС Сервер', + 'counters' => [ + [ + 'column' => 'Dashboards', + 'counter' => 4 + ], + [ + 'column' => 'Problems', + 'counter' => "1\n5" + ] + ] + ] + ] + ]; + } + + /** + * @dataProvider getCheckCountersData + */ + public function testPageMonitoringHosts_CheckCounters($data) { + $this->page->login()->open('zabbix.php?action=host.view')->waitUntilReady(); + $row = $this->query('class:list-table')->asTable()->one()->findRow('Name', $data['host']); + + foreach ($data['counters'] as $counter) { + if ($counter['column'] === 'Problems') { + $text = ($counter['counter'] === null) ? $counter['column'] : $counter['counter']; + $this->assertEquals($text, $row->getColumn($counter['column'])->getText()); + } + else { + $this->assertEquals($counter['column'].' '.$counter['counter'], + $row->getColumn($counter['column'])->getText() + ); + } + } + } +} diff --git a/ui/tests/selenium/testFormHostLinkTemplates.php b/ui/tests/selenium/testFormHostLinkTemplates.php deleted file mode 100644 index 77477017ce9..00000000000 --- a/ui/tests/selenium/testFormHostLinkTemplates.php +++ /dev/null @@ -1,161 +0,0 @@ -page->login()->open('zabbix.php?action=host.list')->waitUntilReady(); - $this->query('button:Create host')->one()->click(); - $form = COverlayDialogElement::find()->asForm()->one()->waitUntilVisible(); - $form->selectTab('Inventory'); - - $inventoryFields = getHostInventories(); - $inventoryFields = zbx_toHash($inventoryFields, 'db_field'); - foreach ($inventoryFields as $fieldId => $fieldName) { - $this->zbxTestTextPresent($fieldName['title']); - $this->zbxTestAssertElementPresentId('host_inventory_'.$fieldId.''); - } - COverlayDialogElement::find()->one()->close(); - } - - public function testFormHostLinkTemplates_TemplateLink() { - $this->zbxTestLogin(self::HOST_LIST_PAGE); - $this->query('button:Reset')->one()->click(); - $this->zbxTestClickLinkTextWait($this->host_for_template); - - $dialog = COverlayDialogElement::find()->asForm()->waitUntilReady()->one(); - $dialog->fill(['Templates' => 'Linux by Zabbix agent active']); - - $this->zbxTestTextPresent('Linux by Zabbix agent active'); - $dialog->submit(); - $this->zbxTestCheckTitle('Configuration of hosts'); - $this->zbxTestWaitUntilMessageTextPresent('msg-good', 'Host updated'); - $this->zbxTestTextPresent($this->host_for_template); - } - - /** - * @depends testFormHostLinkTemplates_TemplateLink - */ - public function testFormHostLinkTemplates_TemplateUnlink() { - // Unlink a template from a host from host properties page - - $template = 'Linux by Zabbix agent active'; - $host = 'Template linkage test host'; - - $sql = 'select hostid from hosts where host='.zbx_dbstr($host).' and status in ('.HOST_STATUS_MONITORED.','.HOST_STATUS_NOT_MONITORED.')'; - $this->assertEquals(1, CDBHelper::getCount($sql)); - $row = DBfetch(DBselect($sql)); - $hostid = $row['hostid']; - - $sql2 = "select hostid from hosts where host='".$template."';"; - $this->assertEquals(1, CDBHelper::getCount($sql2)); - - $this->zbxTestLogin(self::HOST_LIST_PAGE); - $this->query('button:Reset')->one()->click(); - $this->zbxTestClickLinkTextWait($this->host_for_template); - - $dialog = COverlayDialogElement::find()->asForm()->waitUntilReady()->one(); - - // Clicks button named "Unlink" next to a template by name. - $this->assertTrue($dialog->query('link', $template)->exists()); - $dialog->query('id:linked-templates')->asTable()->one()->findRow('Name', $template)->getColumn('Action') - ->query('button:Unlink')->one()->click(); - $this->assertFalse($dialog->query('link', $template)->exists()); - - $dialog->submit(); - $this->zbxTestCheckTitle('Configuration of hosts'); - $this->zbxTestWaitUntilMessageTextPresent('msg-good', 'Host updated'); - - // this should be a separate test - // should check that items, triggers and graphs are not linked to the template anymore - $this->zbxTestClickXpathWait("//a[contains(@href,'items.php?filter_set=1&filter_hostids%5B0%5D=".$hostid."')]"); - $this->page->waitUntilReady(); - $this->zbxTestTextNotPresent($template.':'); - // using "host navigation bar" at the top of entity list - $this->zbxTestHrefClickWait('triggers.php?filter_set=1&filter_hostids%5B0%5D='.$hostid); - $this->zbxTestTextNotPresent($template.':'); - $this->zbxTestHrefClickWait('graphs.php?filter_set=1&filter_hostids%5B0%5D='.$hostid); - $this->zbxTestTextNotPresent($template.':'); - } - - public function testFormHostLinkTemplates_TemplateLinkUpdate() { - $this->zbxTestLogin(self::HOST_LIST_PAGE); - $this->query('button:Reset')->one()->click(); - $this->zbxTestClickLinkTextWait($this->host_for_template); - - $form = $this->query('name:host-form')->asForm()->waitUntilReady()->one(); - $form->fill(['Templates' => 'Linux by Zabbix agent active']); - - $this->zbxTestTextPresent('Linux by Zabbix agent active'); - $form->submit(); - $this->zbxTestCheckTitle('Configuration of hosts'); - $this->zbxTestWaitUntilMessageTextPresent('msg-good', 'Host updated'); - $this->zbxTestTextPresent($this->host_for_template); - } - - /** - * @depends testFormHostLinkTemplates_TemplateLinkUpdate - */ - public function testFormHostLinkTemplates_TemplateUnlinkAndClear() { - // Unlink and clear a template from a host from host properties page - - $template = 'Linux by Zabbix agent active'; - $host = 'Template linkage test host'; - - $sql = 'select hostid from hosts where host='.zbx_dbstr($host).' and status in ('.HOST_STATUS_MONITORED.','.HOST_STATUS_NOT_MONITORED.')'; - $this->assertEquals(1, CDBHelper::getCount($sql)); - $row = DBfetch(DBselect($sql)); - $hostid = $row['hostid']; - - $sql2 = "select hostid from hosts where host='".$template."';"; - $this->assertEquals(1, CDBHelper::getCount($sql2)); - - $this->zbxTestLogin(self::HOST_LIST_PAGE); - $this->query('button:Reset')->one()->click(); - $this->zbxTestClickLinkTextWait($this->host_for_template); - - $dialog = COverlayDialogElement::find()->asForm()->waitUntilReady()->one(); - - // Clicks button named "Unlink and clear" next to a template by name. - $this->assertTrue($dialog->query('link', $template)->exists()); - $dialog->query('id:linked-templates')->asTable()->one()->findRow('Name', $template)->getColumn('Action') - ->query('button:Unlink and clear')->one()->click(); - $this->assertFalse($dialog->query('link', $template)->exists()); - - $dialog->submit(); - $this->zbxTestCheckTitle('Configuration of hosts'); - $this->zbxTestWaitUntilMessageTextPresent('msg-good', 'Host updated'); - - $this->zbxTestClickXpathWait("//a[contains(@href,'items.php?filter_set=1&filter_hostids%5B0%5D=".$hostid."')]"); - $this->page->waitUntilReady(); - $this->zbxTestTextNotPresent($template.':'); - - $this->zbxTestHrefClickWait('triggers.php?filter_set=1&filter_hostids%5B0%5D='.$hostid); - $this->zbxTestTextNotPresent($template.':'); - $this->zbxTestHrefClickWait('graphs.php?filter_set=1&filter_hostids%5B0%5D='.$hostid); - $this->zbxTestTextNotPresent($template.':'); - } -} diff --git a/ui/tests/selenium/testFormHostPrototype.php b/ui/tests/selenium/testFormHostPrototype.php deleted file mode 100644 index d9d5eb0a8e1..00000000000 --- a/ui/tests/selenium/testFormHostPrototype.php +++ /dev/null @@ -1,1088 +0,0 @@ -zbxTestLogin('host_prototypes.php?parent_discoveryid='.self::DISCOVERY_RULE_ID.'&context=host'); - $visible_name = 'Host prototype visible name'; - $name = 'Host prototype {#33}'; - - $this->zbxTestClickLinkTextWait($visible_name); - $this->zbxTestWaitForPageToLoad(); - // Check layout at Host tab. - $this->zbxTestAssertElementValue('host', $name); - $this->zbxTestAssertElementValue('name', $visible_name); - $this->zbxTestAssertElementPresentXpath('//div[contains(@class,"interface-cell-ip")]/input[@readonly]'); - $this->zbxTestAssertElementPresentXpath('//div[contains(@class,"interface-cell-dns")]/input[@readonly]'); - $this->zbxTestAssertElementPresentXpath('//label[@for="interfaces_50024_useip_1" and text()="IP"]/../input[@disabled]'); - $this->zbxTestAssertElementPresentXpath('//label[@for="interfaces_50024_useip_0" and text()="DNS"]/../input[@disabled]'); - $this->zbxTestAssertElementPresentXpath('//div[contains(@class,"interface-cell-port")]/input[@type="text"][@readonly]'); - $this->zbxTestAssertElementPresentXpath('//div[contains(@class,"interface-cell-default")]/input[@disabled]'); - - foreach (['SNMP', 'JMX', 'IPMI'] as $interface) { - $this->zbxTestAssertElementNotPresentXpath('//div[contains(@class,"interface-cell-type") and contains(text(),"'.$interface.'")]'); - } - - // Check layout at IPMI tab. - $this->zbxTestTabSwitch('IPMI'); - foreach (['ipmi_authtype', 'ipmi_privilege', 'ipmi_username', 'ipmi_password'] as $id) { - $this->zbxTestAssertElementPresentXpath('//input[@id="'.$id.'"][@readonly]'); - } - - // Check layout at Macros tab. - $this->zbxTestTabSwitch('Macros'); - $this->zbxTestAssertElementPresentXpath('//input[@id="show_inherited_macros_0"]'); - // Compare host prototype's macros from DB and frontend. - $expected_macros = CDBHelper::getAll( - 'SELECT macro,value,description,type FROM hostmacro WHERE hostid='.self::HOST_PROTOTYPE_ID.' ORDER BY macro' - ); - - // Get host prototype macros from macros tab. - $actual_macros = $this->getMacros(); - $macros_count = count($actual_macros); - $macro_types = CDBHelper::getAll('SELECT macro, type FROM hostmacro'); - - // Add Type from DB to array with actual macros - $types = []; - foreach ($macro_types as $macro_type) { - $types[$macro_type['macro']] = $macro_type['type']; - } - - for ($i = 0; $i < $macros_count; $i++) { - $actual_macros[$i]['type'] = $types[$actual_macros[$i]['macro']]; - } - - $this->assertEquals($expected_macros, $actual_macros); - - // Check global macros. - $this->zbxTestClickXpath('//label[@for="show_inherited_macros_1"]'); - $this->zbxTestWaitForPageToLoad(); - - // Create two macros arrays: from DB and from Frontend form. - $macros = [ - 'database' => array_merge( - CDBHelper::getAll('SELECT macro, value, description, type FROM globalmacro'), - $expected_macros - ), - 'frontend' => [] - ]; - - // If the macro is expected to have type "Secret text", replace the value from db with the secret macro pattern. - for ($i = 0; $i < count($macros['database']); $i++) { - if ($macros['database'][$i]['type'] === '1') { - $macros['database'][$i]['value'] = '******'; - } - } - - // Write macros rows from Frontend to array. - $table = $this->query('id:tbl_macros')->waitUntilVisible()->asTable()->one(); - $count = $table->getRows()->count() - 1; - for ($i = 0; $i < $count; $i += 2) { - $macro = []; - $row = $table->getRow($i); - $macro['macro'] = $row->query('xpath:./td[1]/textarea')->one()->getValue(); - $macro['value'] = $this->getValueField($macro['macro'])->getValue(); - $macro['description'] = $table->getRow($i + 1)->query('tag:textarea')->one()->getValue(); - $macro['type'] = ($this->getValueField($macro['macro'])->getInputType() === 'Secret text') ? '1' : '0'; - - $macros['frontend'][] = $macro; - } - - // Sort arrays by Macros. - foreach ($macros as &$array) { - usort($array, function ($a, $b) { - return strcmp($a['macro'], $b['macro']); - }); - } - unset($array); - - // Compare macros from DB with macros from Frontend. - $this->assertEquals($macros['database'], $macros['frontend']); - - // Check layout at Encryption tab. - $this->zbxTestTabSwitch('Encryption'); - foreach (['tls_connect_0', 'tls_connect_1', 'tls_connect_2', 'tls_in_none', 'tls_in_cert', 'tls_in_psk'] as $id) { - $this->zbxTestAssertElementPresentXpath('//input[@id="'.$id.'"][@disabled]'); - } - } - - public static function getCreateValidationData() { - return [ - // Create host prototype with empty name. - [ - [ - 'error' => 'Page received incorrect data', - 'error_message' => 'Incorrect value for field "Host name": cannot be empty.', - 'check_db' => false - ] - ], - // Create host prototype with space in name field. - [ - [ - 'name' => ' ', - 'error' => 'Page received incorrect data', - 'error_message' => 'Incorrect value for field "Host name": cannot be empty.' - ] - ], - // Create host prototype with invalid name. - [ - [ - 'name' => 'Host prototype {#3}', - 'hostgroup' => 'Discovered hosts', - 'error' => 'Cannot add host prototype', - 'error_message' => 'Host prototype with host name "Host prototype {#3}" already exists in discovery rule "Discovery rule 1".', - 'check_db' => false - ] - ], - [ - [ - 'name' => 'Host prototype with existen visible {#NAME}', - 'visible_name' => 'Host prototype visible name', - 'hostgroup' => 'Discovered hosts', - 'error' => 'Cannot add host prototype', - 'error_message' => 'Host prototype with visible name "Host prototype visible name" already exists in discovery rule "Discovery rule 1".', - 'check_db' => false - ] - ], - [ - [ - 'name' => 'Кириллица Прототип хоста {#FSNAME}', - 'error' => 'Cannot add host prototype', - 'error_message' => 'Invalid parameter "/1/host": invalid host name.' - ] - ], - [ - [ - 'name' => 'Host prototype without macro in name', - 'error' => 'Cannot add host prototype', - 'error_message' => 'Invalid parameter "/1/host": must contain at least one low-level discovery macro.' - ] - ], - [ - [ - 'name' => 'Host prototype with / in name', - 'hostgroup' => 'Linux servers', - 'error' => 'Cannot add host prototype', - 'error_message' => 'Invalid parameter "/1/host": invalid host name.' - ] - ], - // Create host prototype with invalid group. - [ - [ - 'name' => 'Host prototype {#GROUP_EMPTY}', - 'error' => 'Cannot add host prototype', - 'error_message' => 'Invalid parameter "/1/groupLinks": cannot be empty.' - ] - ], - [ - [ - 'name' => 'Host prototype without macro in group prototype', - 'hostgroup' => 'Linux servers', - 'group_prototypes' => [ - 'Group prototype' - ], - 'error' => 'Cannot add host prototype', - 'error_message' => 'Invalid parameter "/1/host": must contain at least one low-level discovery macro.' - ] - ], - [ - [ - 'name' => '{#HOST} prototype with duplicated Group prototypes', - 'hostgroup' => 'Linux servers', - 'group_prototypes' => [ - 'Group prototype {#MACRO}', - 'Group prototype {#MACRO}' - ], - 'error' => 'Cannot add host prototype', - 'error_message' => 'Invalid parameter "/1/groupPrototypes/2": value (name)=(Group prototype {#MACRO}) already exists.' - ] - ] - ]; - } - - /** - * Test validation of host prototype creation. - * - * @dataProvider getCreateValidationData - */ - public function testFormHostPrototype_CreateValidation($data) { - $this->zbxTestLogin('host_prototypes.php?parent_discoveryid='.self::DISCOVERY_RULE_ID.'&context=host&form=create'); - $this->zbxTestCheckHeader('Host prototypes'); - $this->zbxTestCheckTitle('Configuration of host prototypes'); - - if (array_key_exists('name', $data)) { - $this->zbxTestInputType('host', $data['name']); - } - - if (array_key_exists('visible_name', $data)) { - $this->zbxTestInputType('name', $data['visible_name']); - } - - if (array_key_exists('hostgroup', $data)) { - $this->zbxTestClickButtonMultiselect('group_links_'); - $this->zbxTestLaunchOverlayDialog('Host groups'); - $this->zbxTestClickLinkText($data['hostgroup']); - } - - if (array_key_exists('group_prototypes', $data)) { - foreach ($data['group_prototypes'] as $i => $group) { - $this->zbxTestInputTypeByXpath('//*[@name="group_prototypes['.$i.'][name]"]', $group); - $this->zbxTestClick('group_prototype_add'); - } - } - - $this->zbxTestClick('add'); - - // Check the results in frontend. - $this->zbxTestWaitUntilMessageTextPresent('msg-bad', $data['error']); - $this->zbxTestTextPresentInMessageDetails($data['error_message']); - - if (!array_key_exists('check_db', $data) || $data['check_db'] === true) { - $this->assertEquals(0, CDBHelper::getCount('SELECT NULL FROM hosts WHERE flags=2 AND name='.zbx_dbstr($data['name']))); - } - } - - public static function getValidationData() { - return [ - [ - [ - 'name' => '', - 'error' => 'Page received incorrect data', - 'error_message' => 'Incorrect value for field "Host name": cannot be empty.' - ] - ], - [ - [ - 'name' => 'Host prototype {#3}', - 'hostgroup' => 'Discovered hosts', - 'error_message' => 'Host prototype with host name "Host prototype {#3}" already exists in discovery rule "Discovery rule 1".' - ] - ], - [ - [ - 'name' => 'Host prototype with existen visible {#NAME}', - 'visible_name' => 'Host prototype visible name', - 'error_message' => 'Host prototype with visible name "Host prototype visible name" already exists in discovery rule "Discovery rule 1".' - ] - ], - [ - [ - 'name' => 'Кириллица Прототип хоста {#FSNAME}', - 'error_message' => 'Invalid parameter "/1/host": invalid host name.' - ] - ], - [ - [ - 'name' => 'Host prototype without macro in name', - 'error_message' => 'Invalid parameter "/1/host": must contain at least one low-level discovery macro.' - ] - ], - [ - [ - 'name' => 'Host prototype with / in name', - 'error_message' => 'Invalid parameter "/1/host": invalid host name.' - ] - ], - [ - [ - 'name' => 'Host prototype {#GROUP_EMPTY}', - 'clear_groups' => true, - 'error_message' => 'Invalid parameter "/1/groupLinks": cannot be empty.' - ] - ], - [ - [ - 'name' => 'Host prototype without macro in group prototype', - 'clear_groups' => true, - 'group_prototypes' => [ - 'Group prototype' - ], - 'error_message' => 'Invalid parameter "/1/host": must contain at least one low-level discovery macro.' - ] - ], - [ - [ - 'name' => '{#HOST} prototype with duplicated Group prototypes', - 'group_prototypes' => [ - 'Group prototype {#MACRO}', - 'Group prototype {#MACRO}' - ], - 'error_message' => 'Invalid parameter "/1/groupPrototypes/2": value (name)=(Group prototype {#MACRO}) already exists.' - ] - ] - ]; - } - - /** - * Test form validation. - */ - public function executeValidation($data, $action) { - $sql_hash = 'SELECT * FROM hosts ORDER BY hostid'; - $old_hash = CDBHelper::getHash($sql_hash); - - $this->zbxTestLogin('host_prototypes.php?parent_discoveryid='.self::DISCOVERY_RULE_ID.'&context=host'); - - switch ($action) { - case 'update': - $update_prototype = 'Host prototype {#2}'; - $this->zbxTestClickLinkTextWait($update_prototype); - break; - - case 'clone': - $clone_prototype = 'Host prototype {#1}'; - $this->zbxTestClickLinkTextWait($clone_prototype); - $this->zbxTestClickWait('clone'); - break; - } - - if (array_key_exists('name', $data)) { - $this->zbxTestInputClearAndTypeByXpath('//input[@id="host"]', $data['name']); - } - - if (array_key_exists('visible_name', $data)) { - $this->zbxTestInputClearAndTypeByXpath('//input[@id="name"]', $data['visible_name']); - } - - if (array_key_exists('clear_groups', $data)) { - $this->zbxTestMultiselectClear('group_links_'); - } - - if (array_key_exists('group_prototypes', $data)) { - foreach ($data['group_prototypes'] as $i => $group) { - $this->zbxTestInputClearAndTypeByXpath('//*[@name="group_prototypes['.$i.'][name]"]', $group); - $this->zbxTestClick('group_prototype_add'); - } - } - - // Press action button. - switch ($action) { - case 'update': - $this->zbxTestClickWait('update'); - if (!array_key_exists('error', $data)) { - $data['error'] = 'Cannot update host prototype'; - } - break; - - case 'clone': - $this->zbxTestClickWait('add'); - if (!array_key_exists('error', $data)) { - $data['error'] = 'Cannot add host prototype'; - } - break; - } - - // Check the results in frontend. - $this->zbxTestWaitUntilMessageTextPresent('msg-bad', $data['error']); - $this->zbxTestTextPresentInMessageDetails($data['error_message']); - - $this->assertEquals($old_hash, CDBHelper::getHash($sql_hash)); - } - - /** - * Test host prototype form validation when updating. - * - * @dataProvider getValidationData - */ - public function testFormHostPrototype_UpdateValidation($data) { - $this->executeValidation($data, 'update'); - } - - /** - * Test host prototype form validation when cloning. - * - * @dataProvider getValidationData - */ - public function testFormHostPrototype_CloneValidation($data) { - $this->executeValidation($data, 'clone'); - } - - public static function getCreateData() { - return [ - [ - [ - 'name' => 'Host with minimum fields {#FSNAME}', - 'hostgroup' => 'Virtual machines' - ] - ], - [ - [ - 'name' => 'Host with all fields {#FSNAME}', - 'visible_name' => 'Host with all fields visible name', - 'hostgroup' => 'Virtual machines', - 'group_prototype' => '{#FSNAME}', - 'template' => 'Template-layout-test-001', - 'inventory' => 'Automatic', - 'checkbox' => false, - 'macros' => [ - [ - 'action' => USER_ACTION_UPDATE, - 'index' => 0, - 'macro' => '{$NEW_MACRO}', - 'value' => 'Macro_Value', - 'description' => 'Macro Description' - ] - ] - ] - ] - ]; - } - - /** - * Test creation of a host prototype with all possible fields and with default values. - * - * @dataProvider getCreateData - */ - public function testFormHostPrototype_Create($data) { - $this->zbxTestLogin('host_prototypes.php?parent_discoveryid='.self::DISCOVERY_RULE_ID.'&context=host&form=create'); - $this->zbxTestInputTypeWait('host', $data['name']); - - if (array_key_exists('visible_name', $data)) { - $this->zbxTestInputType('name', $data['visible_name']); - } - - if (array_key_exists('checkbox', $data)) { - $this->zbxTestCheckboxSelect('status', $data['checkbox']); - } - - $this->zbxTestClickButtonMultiselect('group_links_'); - $this->zbxTestLaunchOverlayDialog('Host groups'); - $this->zbxTestClickLinkTextWait($data['hostgroup']); - - if (array_key_exists('group_prototype', $data)) { - $this->zbxTestInputTypeByXpath('//*[@name="group_prototypes[0][name]"]', $data['group_prototype']); - } - - if (array_key_exists('template', $data)) { - $this->zbxTestClickButtonMultiselect('add_templates_'); - $this->zbxTestLaunchOverlayDialog('Templates'); - COverlayDialogElement::find()->one()->setDataContext('Templates'); - $this->zbxTestClickLinkTextWait($data['template']); - } - - - if (array_key_exists('macros', $data)) { - $this->zbxTestTabSwitch('Macros'); - $this->page->waitUntilReady(); - $this->fillMacros($data['macros']); - } - - if (array_key_exists('inventory', $data)) { - $this->zbxTestTabSwitch('Inventory'); - $this->zbxTestClickXpathWait('//label[text()="'.$data['inventory'].'"]'); - } - - $this->zbxTestClick('add'); - - $this->zbxTestWaitUntilMessageTextPresent('msg-good', 'Host prototype added'); - - if (array_key_exists('visible_name', $data)) { - $this->zbxTestAssertElementPresentXpath('//a[contains(@href, "form") and text()="'.$data['visible_name'].'"]'); - } - else { - $this->zbxTestAssertElementPresentXpath('//a[contains(@href, "form") and text()="'.$data['name'].'"]'); - } - - $hostid = CDBHelper::getValue('SELECT hostid FROM hosts WHERE host='.zbx_dbstr($data['name'])); - // Check the results in form. - $this->checkFormFields($data); - - // Check the results in DB. - $this->assertEquals(1, CDBHelper::getCount('SELECT NULL FROM hosts WHERE host='.zbx_dbstr($data['name']))); - } - - /** - * Test update without any modification of host prototype. - */ - public function testFormHostPrototype_SimpleUpdate() { - $sql = 'SELECT name'. - ' FROM hosts'. - ' WHERE hostid IN ('. - 'SELECT hostid'. - ' FROM host_discovery'. - ' WHERE parent_itemid='.self::DISCOVERY_RULE_ID. - ')'. - 'LIMIT 2'; - $sql_hash = 'SELECT * FROM hosts ORDER BY hostid'; - $old_hash = CDBHelper::getHash($sql_hash); - - $this->zbxTestLogin('host_prototypes.php?parent_discoveryid='.self::DISCOVERY_RULE_ID.'&context=host'); - foreach (CDBHelper::getAll($sql) as $host) { - $this->zbxTestClickLinkTextWait($host['name']); - $this->zbxTestWaitForPageToLoad(); - $this->zbxTestClickWait('update'); - - $this->zbxTestWaitUntilMessageTextPresent('msg-good', 'Host prototype updated'); - $this->zbxTestAssertElementPresentXpath('//a[contains(@href, "form") and text()="'.$host['name'].'"]'); - } - - $this->assertEquals($old_hash, CDBHelper::getHash($sql_hash)); - } - - public static function getUpdateData() { - return [ - [ - [ - 'old_name' => 'Host prototype {#2}', - 'name' => 'New Host prototype {#2}', - 'checkbox' => true, - 'hostgroup' => 'Virtual machines', - 'group_prototype' => 'New test {#MACRO}', - 'template' => 'Windows by Zabbix agent', - 'inventory' => 'Automatic' - ] - ], - [ - [ - 'old_visible_name' => 'Host prototype visible name', - 'visible_name' => 'New prototype visible name' - ] - ] - ]; - } - - /** - * Test update of a host prototype with all possible fields. - * - * @dataProvider getUpdateData - */ - public function testFormHostPrototype_Update($data) { - $this->zbxTestLogin('host_prototypes.php?parent_discoveryid='.self::DISCOVERY_RULE_ID.'&context=host'); - $this->zbxTestClickLinkTextWait(array_key_exists('old_visible_name', $data) ? $data['old_visible_name'] : $data['old_name']); - - // Change name and visible name. - if (array_key_exists('name', $data)) { - $this->zbxTestInputTypeOverwrite('host', $data['name']); - } - if (array_key_exists('visible_name', $data)) { - $this->zbxTestInputTypeOverwrite('name', $data['visible_name']); - } - // Change status. - if (array_key_exists('checkbox', $data)) { - $this->zbxTestCheckboxSelect('status', $data['checkbox']); - } - - // Change Host group and Group prototype. - if (array_key_exists('hostgroup', $data)) { - $this->zbxTestMultiselectClear('group_links_'); - $this->zbxTestClickButtonMultiselect('group_links_'); - $this->zbxTestLaunchOverlayDialog('Host groups'); - $this->zbxTestClickLinkText($data['hostgroup']); - $this->zbxTestInputClearAndTypeByXpath('//*[@name="group_prototypes[0][name]"]', $data['group_prototype']); - } - - // Change template. - if (array_key_exists('template', $data)) { - $this->zbxTestClickXpathWait('//button[contains(@onclick,"unlink")]'); - $this->zbxTestClickButtonMultiselect('add_templates_'); - $this->zbxTestLaunchOverlayDialog('Templates'); - COverlayDialogElement::find()->one()->setDataContext('Templates'); - $this->query('link', $data['template'])->waitUntilClickable()->one()->click(); - } - - // Change inventory mode. - if (array_key_exists('inventory', $data)) { - $this->zbxTestTabSwitch('Inventory'); - $this->zbxTestClickXpathWait('//label[text()="'.$data['inventory'].'"]'); - } - - $this->zbxTestClick('update'); - - $this->zbxTestWaitUntilMessageTextPresent('msg-good', 'Host prototype updated'); - if (array_key_exists('visible_name', $data)) { - $this->zbxTestTextPresent($data['visible_name']); - } - if (array_key_exists('name', $data)) { - $this->zbxTestTextPresent($data['name']); - } - - // Check the results in form - $this->checkFormFields($data); - - if (array_key_exists('name', $data)) { - $this->assertEquals(1, CDBHelper::getCount('SELECT NULL FROM hosts WHERE host = '.zbx_dbstr($data['name']))); - $this->assertEquals(0, CDBHelper::getCount('SELECT NULL FROM hosts WHERE host = '.zbx_dbstr($data['old_name']))); - } - - if (array_key_exists('visible_name', $data)) { - $this->assertEquals(1, CDBHelper::getCount('SELECT NULL FROM hosts WHERE name = '.zbx_dbstr($data['visible_name']))); - $this->assertEquals(0, CDBHelper::getCount('SELECT NULL FROM hosts WHERE name = '.zbx_dbstr($data['old_visible_name']))); - } - } - - /** - * Check IPMI tab before and after changes on parent host. - */ - public function testFormHostPrototype_CheckIPMIFromHost() { - $this->page->login()->open('host_prototypes.php?form=update&parent_discoveryid='.self::DISCOVERY_RULE_ID. - '&context=host&hostid='.self::HOST_PROTOTYPE_ID); - $this->zbxTestWaitForPageToLoad(); - - // Check IPMI settings on prototype before changes on host. - $this->zbxTestTabSwitch('IPMI'); - $this->zbxTestTextPresent(['Authentication algorithm', 'Privilege level', 'Username', 'Password']); - - $old_values = [ - ['field' => 'authtype', 'value' => 'Default'], - ['field' => 'privilege', 'value' => 'User'], - ['field' => 'username', 'value' => ''], - ['field' => 'password', 'value' => ''] - ]; - - foreach ($old_values as $old_value) { - $this->zbxTestAssertElementValue('ipmi_'.$old_value['field'], $old_value['value']); - } - - // Go to host and change IPMI settings. - $this->page->open('zabbix.php?action=host.edit&hostid='.self::HOST_ID); - $form = $this->query('id:host-form')->asForm()->one()->waitUntilVisible(); - $form->selectTab('IPMI'); - - $new_values = [ - ['field' => 'authtype', 'value' => 'MD2'], - ['field' => 'privilege', 'value' => 'Operator'], - ['field' => 'username', 'value' => 'TestUsername'], - ['field' => 'password', 'value' => 'TestPassword'] - ]; - foreach ($new_values as $new_value) { - $tag = $this->webDriver->findElement(WebDriverBy::id('ipmi_'.$new_value['field']))->getTagName(); - if ($tag === 'select') { - $this->zbxTestDropdownSelect('ipmi_'.$new_value['field'], $new_value['value']); - } - else { - $this->zbxTestInputType('ipmi_'.$new_value['field'], $new_value['value']); - } - } - $form->submit(); - $this->assertMessage(TEST_GOOD, 'Host updated'); - - // Go back to prototype and check changes. - $this->page->open('host_prototypes.php?form=update&parent_discoveryid='.self::DISCOVERY_RULE_ID. - '&context=host&hostid='.self::HOST_PROTOTYPE_ID); - $prototype_form = $this->query('id:host-prototype-form')->asForm()->one()->waitUntilVisible(); - $prototype_form->selectTab('IPMI'); - - foreach ($new_values as $new_value) { - $this->zbxTestAssertElementValue('ipmi_'.$new_value['field'], $new_value['value']); - } - } - - public static function getCheckEncryptionFromHostData() { - return [ - [ - [ - 'connection_to_host' => 'PSK', - 'connection_from_host' => ['No encryption' => false, 'PSK' => true], - 'psk' => ['identity' => 'Test_Identity', 'number' => '16777216000000000000000000000000'] - ] - ], - [ - [ - 'connection_to_host' => 'Certificate', - 'connection_from_host' => ['No encryption' => false, 'PSK' => false, 'Certificate' => true], - 'issuer' => 'Test_Issuer', - 'subject' => 'Test_Subject' - ] - ], - [ - [ - 'connection_to_host' => 'Certificate', - 'connection_from_host' => ['No encryption' => false, 'PSK' => true, 'Certificate' => true], - 'psk' => ['identity' => 'Test_Identity2', 'number' => '16777216000000000000000000000000'], - 'issuer' => 'Test_Issuer_2', - 'subject' => 'Test_Subject_2' - ] - ] - ]; - } - - /** - * Check Encryption tab before and after changes on parent host. - * - * @dataProvider getCheckEncryptionFromHostData - */ - public function testFormHostPrototype_CheckEncryptionFromHost($data) { - $this->zbxTestLogin('host_prototypes.php?form=update&parent_discoveryid='.self::DISCOVERY_RULE_ID. - '&context=host&hostid='.self::HOST_PROTOTYPE_ID); - $this->zbxTestWaitForPageToLoad(); - - // Check Encryption settings on prototype before changes on host. - $this->zbxTestTabSwitch('Encryption'); - $this->zbxTestTextPresent(['Connections to host', 'Connections from host']); - - $labels = [ - ['type' => 'radio', 'value' => 'No encryption'], - ['type' => 'radio', 'value' => 'PSK'], - ['type' => 'radio', 'value' => 'Certificate'], - ['type' => 'checkbox', 'value' => 'No encryption'], - ['type' => 'checkbox', 'value' => 'PSK'], - ['type' => 'checkbox', 'value' => 'Certificate'] - ]; - - foreach ($labels as $label) { - $this->zbxTestAssertElementPresentXpath('//label[text()="'.$label['value'].'"]/../input[@type="'.$label['type'].'"][@disabled]'); - } - - // Go to host and change Encryption settings. - $this->page->open('zabbix.php?action=host.edit&hostid='.self::HOST_ID); - $form = $this->query('id:host-form')->asForm()->one()->waitUntilVisible(); - $form->selectTab('Encryption'); - $form->fill(['Connections to host' => $data['connection_to_host']]); - - foreach ($data['connection_from_host'] as $label => $state) { - $id = $this->zbxTestGetAttributeValue('//div[@class="form-field"]//label[text()="'.$label. - '"]/..//input[@class="checkbox-radio"]', 'id'); - $this->zbxTestCheckboxSelect($id, $state); - } - - if (array_key_exists('psk', $data)) { - $this->zbxTestInputTypeOverwrite('tls_psk_identity', $data['psk']['identity']); - $this->zbxTestInputTypeOverwrite('tls_psk', $data['psk']['number']); - } - if (array_key_exists('issuer', $data)) { - $this->zbxTestInputTypeOverwrite('tls_issuer', $data['issuer']); - } - if (array_key_exists('subject', $data)) { - $this->zbxTestInputTypeOverwrite('tls_subject', $data['subject']); - } - $form->submit(); - $this->assertMessage(TEST_GOOD, 'Host updated'); - - // Go back to prototype and check changes. - $this->zbxTestOpen('host_prototypes.php?form=update&parent_discoveryid='.self::DISCOVERY_RULE_ID. - '&context=host&hostid='.self::HOST_PROTOTYPE_ID); - $this->zbxTestTabSwitch('Encryption'); - $this->zbxTestWaitForPageToLoad(); - - // Check correct radio is selected. - $this->zbxTestAssertElementPresentXpath('//label[text()="'.$data['connection_to_host'].'"]/../input[@type="radio"][@checked][@disabled]'); - - // Check checkboxes. - foreach ($data['connection_from_host'] as $label => $state) { - $id = $this->zbxTestGetAttributeValue('//ul[@class="list-check-radio"]//label[text()="'.$label.'"]/../input', 'id'); - $this->assertEquals($state, $this->zbxTestCheckboxSelected($id)); - } - - // Check input fields. - if (array_key_exists('psk', $data)) { - $this->assertTrue($this->query('button:Change PSK')->exists()); - } - if (array_key_exists('issuer', $data)) { - $this->zbxTestAssertElementValue('tls_issuer', $data['issuer']); - } - if (array_key_exists('subject', $data)) { - $this->zbxTestAssertElementValue('tls_subject', $data['subject']); - } - } - - public static function getCloneData() { - return [ - [ - [ - 'name' => 'Clone_3 of Host prototype {#1}', - 'visible_name' => 'Clone_3 Host prototype visible name', - 'inventory' => 'Automatic', - 'checkbox' => false - ] - ], - [ - [ - 'name' => 'Clone_4 of Host prototype {#1}', - 'hostgroup' => 'Hypervisors' - ] - ], - [ - [ - 'name' => 'Clone_5 of Host prototype {#1}', - 'group_prototype' => 'Clone group prototype {#MACRO}' - ] - ] - , - [ - [ - 'name' => 'Clone_6 of Host prototype {#1}', - 'template' => 'Alcatel Timetra TiMOS SNMP' - ] - ], - [ - [ - 'name' => 'Clone_7 of Host prototype {#1}', - 'inventory' => 'Manual' - ] - ] - ]; - } - - /** - * Test clone of a host prototype with update all possible fields. - * - * @dataProvider getCloneData - */ - public function testFormHostPrototype_Clone($data) { - $hostname = 'Host prototype {#1}'; - - $this->zbxTestLogin('host_prototypes.php?parent_discoveryid='.self::DISCOVERY_RULE_ID.'&context=host'); - $this->zbxTestClickLinkTextWait($hostname); - $this->zbxTestClickWait('clone'); - - // Change name and visible name. - $this->zbxTestInputTypeOverwrite('host', $data['name']); - if (array_key_exists('visible_name', $data)) { - $this->zbxTestInputType('name', $data['visible_name']); - } - // Change status. - if (array_key_exists('checkbox', $data)) { - $this->zbxTestCheckboxSelect('status', $data['checkbox']); - } - // Change host group. - if (array_key_exists('hostgroup', $data)) { - $this->zbxTestClickXpathWait('//span[@class="subfilter-disable-btn"]'); - $this->zbxTestMultiselectClear('group_links_'); - $this->zbxTestClickButtonMultiselect('group_links_'); - $this->zbxTestLaunchOverlayDialog('Host groups'); - $this->zbxTestClickLinkTextWait($data['hostgroup']); - } - // Change host group prototype. - if (array_key_exists('group_prototype', $data)) { - $this->zbxTestInputClearAndTypeByXpath('//*[@name="group_prototypes[0][name]"]', $data['group_prototype']); - } - - // Change template. - if (array_key_exists('template', $data)) { - $this->zbxTestClickButtonMultiselect('add_templates_'); - $this->zbxTestLaunchOverlayDialog('Templates'); - COverlayDialogElement::find()->one()->setDataContext('Templates'); - $this->zbxTestClickLinkTextWait($data['template']); - } - - // Change inventory mode. - if (array_key_exists('inventory', $data)) { - $this->zbxTestTabSwitch('Inventory'); - $this->zbxTestClickXpathWait('//label[text()="'.$data['inventory'].'"]'); - } - - $this->zbxTestClick('add'); - - $this->zbxTestWaitUntilMessageTextPresent('msg-good', 'Host prototype added'); - - if (array_key_exists('visible_name', $data)) { - $this->zbxTestAssertElementPresentXpath('//a[contains(@href, "form") and text()="'.$data['visible_name'].'"]'); - $this->zbxTestAssertElementPresentXpath('//a[contains(@href, "form") and text()="'.$hostname.'"]'); - } - else { - $this->zbxTestAssertElementPresentXpath('//a[contains(@href, "form") and text()="'.$data['name'].'"]'); - $this->zbxTestAssertElementPresentXpath('//a[contains(@href, "form") and text()="'.$hostname.'"]'); - } - - // Check the results in form - $this->checkFormFields($data); - - $this->assertEquals(1, CDBHelper::getCount('SELECT NULL FROM hosts WHERE host='.zbx_dbstr($data['name']))); - $this->assertEquals(1, CDBHelper::getCount('SELECT NULL FROM hosts WHERE host='.zbx_dbstr($hostname))); - } - - private function checkFormFields($data) { - if (array_key_exists('visible_name', $data)) { - $this->zbxTestClickLinkTextWait($data['visible_name']); - $this->zbxTestAssertElementValue('name', $data['visible_name']); - } - else { - $this->zbxTestClickLinkTextWait($data['name']); - $this->zbxTestAssertElementValue('host', $data['name']); - } - - if (array_key_exists('checkbox', $data)) { - $this->assertEquals($data['checkbox'], $this->zbxTestCheckboxSelected('status')); - } - - if (array_key_exists('hostgroup', $data)) { - $this->zbxTestMultiselectAssertSelected('group_links_', $data['hostgroup']); - if (array_key_exists('group_prototype', $data)) { - $this->assertEquals($data['group_prototype'], $this->zbxTestGetValue('//input[@name="group_prototypes[0][name]"]')); - } - } - - if (array_key_exists('template', $data)) { - $this->query('link', $data['template']); - } - - if (array_key_exists('macros', $data)) { - $this->zbxTestTabSwitch('Macros'); - $this->assertMacros($data['macros']); - } - - if (array_key_exists('inventory', $data)) { - $this->zbxTestTabSwitch('Inventory'); - $this->zbxTestAssertElementPresentXpath('//label[text()="'.$data['inventory'].'"]/../input[@checked]'); - } - } - - public function testFormHostPrototype_Delete() { - $prototype_name = 'Host prototype {#3}'; - - $this->zbxTestLogin('host_prototypes.php?parent_discoveryid='.self::DISCOVERY_RULE_ID.'&context=host'); - $this->zbxTestClickLinkTextWait($prototype_name); - - $this->zbxTestClickAndAcceptAlert('delete'); - - $this->zbxTestWaitUntilMessageTextPresent('msg-good', 'Host prototype deleted'); - - $this->assertEquals(0, CDBHelper::getCount('SELECT NULL FROM hosts WHERE host='.zbx_dbstr($prototype_name))); - } - - public function testFormHostPrototype_CancelCreation() { - $host = 'Host for host prototype tests'; - $discovery_rule = 'Discovery rule 1'; - $name = 'Host prototype {#FSNAME}'; - $group = 'Virtual machines'; - - $sql_hash = 'SELECT * FROM hosts ORDER BY hostid'; - $old_hash = CDBHelper::getHash($sql_hash); - - $this->zbxTestLogin(self::HOST_LIST_PAGE); - - $form = $this->query('name:zbx_filter')->asForm()->waitUntilReady()->one(); - $form->fill(['Name' => $host]); - $this->query('button:Apply')->one()->waitUntilClickable()->click(); - $this->query('xpath://table[@class="list-table"]')->asTable()->one()->findRow('Name', $host) - ->getColumn('Discovery')->query('link:Discovery')->one()->click(); - - $this->zbxTestClickLinkTextWait($discovery_rule); - $this->zbxTestClickLinkTextWait('Host prototypes'); - $this->zbxTestContentControlButtonClickTextWait('Create host prototype'); - - $this->zbxTestInputType('host', $name); - $this->zbxTestClickButtonMultiselect('group_links_'); - $this->zbxTestLaunchOverlayDialog('Host groups'); - $this->zbxTestClickLinkText($group); - - $this->zbxTestClick('cancel'); - - // Check the results in frontend. - $this->zbxTestCheckHeader('Host prototypes'); - $this->zbxTestCheckTitle('Configuration of host prototypes'); - $this->zbxTestTextNotPresent($name); - - $this->assertEquals($old_hash, CDBHelper::getHash($sql_hash)); - } - - /** - * Cancel updating, cloning or deleting of host prototype. - */ - private function executeCancelAction($action) { - $sql_hash = 'SELECT * FROM hosts ORDER BY hostid'; - $old_hash = CDBHelper::getHash($sql_hash); - - $this->zbxTestLogin('host_prototypes.php?parent_discoveryid='.self::DISCOVERY_RULE_ID.'&context=host'); - - $sql = 'SELECT name'. - ' FROM hosts'. - ' WHERE hostid IN ('. - 'SELECT hostid'. - ' FROM host_discovery'. - ' WHERE parent_itemid='.self::DISCOVERY_RULE_ID. - ')'. - 'LIMIT 1'; - - foreach (CDBHelper::getAll($sql) as $host) { - $name = $host['name']; - $this->zbxTestClickLinkText($name); - - switch ($action) { - case 'update': - $name .= ' (updated)'; - $this->zbxTestInputTypeOverwrite('host', $name); - $this->zbxTestClick('cancel'); - break; - - case 'clone': - $name .= ' (cloned)'; - $this->zbxTestInputTypeOverwrite('host', $name); - $this->zbxTestClickWait('clone'); - $this->zbxTestClickWait('cancel'); - break; - - case 'delete': - $this->zbxTestClickWait('delete'); - $this->webDriver->switchTo()->alert()->dismiss(); - break; - } - - $this->zbxTestCheckHeader('Host prototypes'); - $this->zbxTestCheckTitle('Configuration of host prototypes'); - - if ($action !== 'delete') { - $this->zbxTestTextNotPresent($name); - } - else { - $this->zbxTestTextPresent($name); - } - } - $this->assertEquals($old_hash, CDBHelper::getHash($sql_hash)); - } - - /** - * Cancel update of host prototype. - */ - public function testFormHostPrototype_CancelUpdating() { - $this->executeCancelAction('update'); - } - - /** - * Cancel cloning of host prototype. - */ - public function testFormHostPrototype_CancelCloning() { - $this->executeCancelAction('clone'); - } - - /** - * Cancel deleting of host prototype. - */ - public function testFormHostPrototype_CancelDelete() { - $this->executeCancelAction('delete'); - } -} diff --git a/ui/tests/selenium/testPageHostInterfaces.php b/ui/tests/selenium/testPageHostInterfaces.php deleted file mode 100644 index dd1e25eec6b..00000000000 --- a/ui/tests/selenium/testPageHostInterfaces.php +++ /dev/null @@ -1,487 +0,0 @@ - 1, - 'main' => 1, - 'useip' => 0, - 'ip' => '127.1.1.1', - 'dns' => '1available.zabbix.com', - 'port' => '10050', - 'available' => 1 - ], - [ - 'type' => 1, - 'main' => 0, - 'useip' => 0, - 'ip' => '127.1.1.2', - 'dns' => '2available.zabbix.com', - 'port' => '10051', - 'available' => 1 - ], - [ - 'type' => 2, - 'main' => 1, - 'useip' => 1, - 'ip' => '127.0.0.98', - 'dns' => 'snmpv3zabbix.com', - 'port' => '163', - 'details' => [ - 'version' => '3', - 'bulk' => '1', - 'securityname' => 'zabbix' - ], - 'available' => 1 - ], - [ - 'type' => 2, - 'main' => 0, - 'useip' => 0, - 'ip' => '', - 'dns' => 'snmpv3auth.com', - 'port' => '163', - 'details' => [ - 'version' => '3', - 'bulk' => '1', - 'securitylevel' => 2, - 'authprotocol' => 2, - 'privprotocol' => 4 - ], - 'available' => 1 - ], - [ - 'type' => 2, - 'main' => 0, - 'useip' => 1, - 'ip' => '127.0.0.99', - 'dns' => 'snmpv2zabbix.com', - 'port' => '162', - 'details' => [ - 'version' => '2', - 'bulk' => '1', - 'community' => '{$SNMP_COMMUNITY}' - ], - 'available' => 2 - ], - [ - 'type' => 3, - 'main' => 1, - 'useip' => 0, - 'ip' => '127.0.0.1', - 'dns' => '1unavail.IPMI.zabbix.com', - 'port' => '623', - 'available' => 2, - 'error' => '1 Error IPMI' - ], - [ - 'type' => 3, - 'main' => 0, - 'useip' => 0, - 'ip' => '127.0.0.1', - 'dns' => '2unavail.IPMI.zabbix.com', - 'port' => '624', - 'available' => 2, - 'error' => '2 Error IPMI' - ] - ]; - - $groups = [ - [ - 'groupid' => 4 - ] - ]; - - CDataHelper::createHosts([ - [ - 'host' => 'Host with Orange interface', - 'name' => 'Host with Orange interface', - 'description' => 'API Created Host with Orange interface for Host availability test', - 'interfaces' => $interfaces, - 'groups' => $groups, - 'status' => HOST_STATUS_MONITORED - ] - ]); - } - - public function getCheckInterfacesData() { - return [ - [ - [ - 'host' => 'Not available host', - 'interfaces' => [ - 'ZBX' => [ - 'color' => self::RED, - 'rows' => [ - [ - 'Interface' => 'zabbixzabbixzabbix.com:10050', - 'Status' => [ - 'text' => 'Not available', - 'color' => self::RED - ], - 'Error' => 'ERROR Agent' - ] - ] - ], - 'SNMP' => [ - 'color' => self::RED, - 'rows' => [ - [ - 'Interface' => "zabbixzabbixzabbix.com:10050\nSNMPv2, Community: {\$SNMP_COMMUNITY}", - 'Status' => [ - 'text' => 'Not available', - 'color' => self::RED - ], - 'Error' => 'ERROR SNMP' - ] - ] - ], - 'IPMI' => [ - 'color' => self::RED, - 'rows' => [ - [ - 'Interface' => 'zabbixzabbixzabbix.com:10050', - 'Status' => [ - 'text' => 'Not available', - 'color' => self::RED - ], - 'Error' => 'ERROR IPMI' - ] - ] - ], - 'JMX' => [ - 'color' => self::RED, - 'rows' => [ - [ - 'Interface' => 'zabbixzabbixzabbix.com:10050', - 'Status' => [ - 'text' => 'Not available', - 'color' => self::RED - ], - 'Error' => 'ERROR JMX' - ] - ] - ] - ] - ] - ], - [ - [ - 'host' => 'Host with Orange interface', - 'interfaces' => [ - 'ZBX' => [ - 'color' => self::GREEN, - 'rows' => [ - [ - 'Interface' => '1available.zabbix.com:10050', - 'Status' => [ - 'text' => 'Available', - 'color' => self::GREEN - ], - 'Error' => '' - ], - [ - 'Interface' => '2available.zabbix.com:10051', - 'Status' => [ - 'text' => 'Available', - 'color' => self::GREEN - ], - 'Error' => '' - ] - ] - ], - 'SNMP' => [ - 'color' => self::ORANGE, - 'rows' => [ - [ - 'Interface' => "127.0.0.98:163\nSNMPv3, Context name:", - 'Status' => [ - 'text' => 'Available', - 'color' => self::GREEN - ], - 'Error' => '' - ], - [ - 'Interface' => "127.0.0.99:162\nSNMPv2, Community: {\$SNMP_COMMUNITY}", - 'Status' => [ - 'text' => 'Not available', - 'color' => self::RED - ], - 'Error' => '' - ], - [ - 'Interface' => "snmpv3auth.com:163\nSNMPv3, Context name: , (priv: AES192C, auth: SHA224)", - 'Status' => [ - 'text' => 'Available', - 'color' => self::GREEN - ], - 'Error' => '' - ] - ] - ], - 'IPMI' => [ - 'color' => self::RED, - 'rows' => [ - [ - 'Interface' => '1unavail.IPMI.zabbix.com:623', - 'Status' => [ - 'text' => 'Not available', - 'color' => self::RED - ], - 'Error' => '1 Error IPMI' - ], - [ - 'Interface' => '2unavail.IPMI.zabbix.com:624', - 'Status' => [ - 'text' => 'Not available', - 'color' => self::RED - ], - 'Error' => '2 Error IPMI' - ] - ] - ] - ] - ] - ], - [ - [ - 'host' => 'Template inheritance test host', - 'interfaces' => [ - 'ZBX' => [ - 'color' => self::GREY, - 'rows' => [ - [ - 'Interface' => '127.0.0.1:10051', - 'Status' => [ - 'text' => 'Unknown', - 'color' => self::GREY - ], - 'Error' => '' - ], - [ - 'Interface' => '127.0.0.2:10052', - 'Status' => [ - 'text' => 'Unknown', - 'color' => self::GREY - ], - 'Error' => '' - ] - ] - ], - 'SNMP' => [ - 'color' => self::GREY, - 'rows' => [ - [ - 'Interface' => "127.0.0.3:10053\nSNMPv2, Community: {\$SNMP_COMMUNITY}", - 'Status' => [ - 'text' => 'Unknown', - 'color' => self::GREY - ], - 'Error' => '' - ] - ] - ], - 'IPMI' => [ - 'color' => self::GREY, - 'rows' => [ - [ - 'Interface' => '127.0.0.4:10054', - 'Status' => [ - 'text' => 'Unknown', - 'color' => self::GREY - ], - 'Error' => '' - ] - ] - ], - 'JMX' => [ - 'color' => self::GREY, - 'rows' => [ - [ - 'Interface' => '127.0.0.5:10055', - 'Status' => [ - 'text' => 'Unknown', - 'color' => self::GREY - ], - 'Error' => '' - ] - ] - ] - ] - ] - ], - [ - [ - 'host' => 'Available host', - 'interfaces' => [ - 'ZBX' => [ - 'color' => self::GREEN, - 'rows' => [ - [ - 'Interface' => '127.0.0.1:10050', - 'Status' => [ - 'text' => 'Available', - 'color' => self::GREEN - ], - 'Error' => '' - ] - ] - ], - 'SNMP' => [ - 'color' => self::GREEN, - 'rows' => [ - [ - 'Interface' => "zabbixzabbixzabbix.com:10050\nSNMPv2, Community: {\$SNMP_COMMUNITY}", - 'Status' => [ - 'text' => 'Available', - 'color' => self::GREEN - ], - 'Error' => '' - ] - ] - ], - 'IPMI' => [ - 'color' => self::GREEN, - 'rows' => [ - [ - 'Interface' => 'zabbixzabbixzabbix.com:10050', - 'Status' => [ - 'text' => 'Available', - 'color' => self::GREEN - ], - 'Error' => '' - ] - ] - ], - 'JMX' => [ - 'color' => self::GREEN, - 'rows' => [ - [ - 'Interface' => 'zabbixzabbixzabbix.com:10050', - 'Status' => [ - 'text' => 'Available', - 'color' => self::GREEN - ], - 'Error' => '' - ] - ] - ] - ] - ] - ] - ]; - } - - /** - * Test displaying host interfaces on Monitoring->Hosts page. - * - * @dataProvider getCheckInterfacesData - */ - public function testPageHostInterfaces_MonitoringHosts($data) { - $this->checkInterfaces($data, 'zabbix.php?action=host.view', 'host_view'); - } - - /** - * Test displaying host interfaces on Configuration->Hosts page. - * - * @dataProvider getCheckInterfacesData - */ - public function testPageHostInterfaces_ConfigurationHosts($data) { - $this->checkInterfaces($data, self::HOST_LIST_PAGE, 'hosts'); - } - - /** - * Test displaying host interfaces on Discovery rules page. - * - * @dataProvider getCheckInterfacesData - */ - public function testPageHostInterfaces_DiscoveryPage($data) { - $id = CDBHelper::getValue('SELECT hostid FROM hosts WHERE host ='.zbx_dbstr($data['host'])); - $link = 'host_discovery.php?filter_set=1&filter_hostids%5B0%5D='.$id.'&context=host'; - $this->checkInterfaces($data, $link, $selector = null, true); - } - - /** - * Function for checking interfaces. - * - * @param array $data data from data provider - * @param string $link checked page link - * @param string $selector table selector on page - * @param boolean $navigation is it upper navigation block or not - */ - private function checkInterfaces($data, $link, $selector = null, $navigation = false) { - if ($navigation) { - $this->page->login()->open($link)->waitUntilReady(); - $availability = $this->query('xpath://div[@class="status-container"]')->waitUntilPresent()->one(); - } - else { - $this->page->login()->open($link)->waitUntilReady(); - $table = $this->query('xpath://form[@name='.zbx_dbstr($selector).']/table[@class="list-table"]') - ->waitUntilReady()->asTable()->one(); - $availability = $table->findRow('Name', $data['host'])->getColumn('Availability'); - } - - $host_interfaces = []; - foreach ($availability->query('xpath:.//span[@data-hintbox="1"]')->all() as $interface) { - $interface_name = $interface->getText(); - // Write interfaces names into array. - $host_interfaces[] = $interface_name; - // Check interface color in availability column. - $this->assertEquals($data['interfaces'][$interface_name]['color'], $interface->getCSSValue('background-color')); - // Open interface popup. - $interface->click(); - $overlay = $this->query('xpath://div[@class="overlay-dialogue"]')->asOverlayDialog()->waitUntilPresent()->one(); - $interface_table = $overlay->query('xpath:.//table[@class="list-table"]')->asTable()->one(); - // Check table headers in popup. - $this->assertSame(['Interface', 'Status', 'Error'], $interface_table->getHeadersText()); - - // Check every interface row. - foreach ($interface_table->getRows() as $i => $row) { - $interface_details = $data['interfaces'][$interface_name]['rows'][$i]; - $this->assertEquals($interface_details['Interface'], $row->getColumn('Interface')->getText()); - $this->assertEquals($interface_details['Status']['text'], $row->getColumn('Status')->getText()); - $this->assertEquals($interface_details['Status']['color'], $row->getColumn('Status') - ->query('xpath:.//span[contains(@class, "status")]')->one()->getCSSValue('background-color')); - $this->assertEquals($interface_details['Error'], $row->getColumn('Error')->getText()); - } - - $overlay->close(); - $overlay->waitUntilNotPresent(); - } - // Assert interface names in Availability column. - $this->assertEquals(array_keys($data['interfaces']), $host_interfaces); - } -} diff --git a/ui/tests/selenium/testPageHostPrototypes.php b/ui/tests/selenium/testPageHostPrototypes.php deleted file mode 100644 index 62e0db5685a..00000000000 --- a/ui/tests/selenium/testPageHostPrototypes.php +++ /dev/null @@ -1,225 +0,0 @@ -zbxTestLogin('host_prototypes.php?parent_discoveryid='.self::DICROVERY_RULE_ID.'&context=host'); - $this->zbxTestCheckTitle('Configuration of host prototypes'); - $this->zbxTestCheckHeader('Host prototypes'); - - $table = $this->query('xpath://form[@name="hosts"]/table[@class="list-table"]')->asTable()->one(); - $headers = ['', 'Name', 'Templates', 'Create enabled', 'Discover', 'Tags']; - $this->assertSame($headers, $table->getHeadersText()); - - foreach (['Create enabled', 'Create disabled', 'Delete'] as $button) { - $element = $this->query('button', $button)->one(); - $this->assertTrue($element->isPresent()); - $this->assertFalse($element->isEnabled()); - } - - $this->assertTableStats(self::HOST_PROTOTYPES_COUNT); - - // Check tags on the specific host prototype. - $tags = $table->findRow('Name', 'Host prototype {#1}')->getColumn('Tags')->query('class:tag')->all(); - $this->assertEquals(['host_proto_tag_1: value1', 'host_proto_tag_2: value2'], $tags->asText()); - - foreach ($tags as $tag) { - $tag->click(); - $hint = $this->query('xpath://div[@data-hintboxid]') - ->asOverlayDialog()->waitUntilPresent()->all()->last(); - $this->assertEquals($tag->getText(), $hint->getText()); - $hint->close(); - } - } - - public static function getSelectedData() { - return [ - [ - [ - 'item' => 'Discovery rule 1', - 'hosts' => [ - 'Host prototype {#1}' - ] - ] - ], - [ - [ - 'item' => 'Discovery rule 2', - 'hosts' => 'all' - ] - ], - [ - [ - 'item' => 'Discovery rule 3', - 'hosts' => [ - 'Host prototype {#7}', - 'Host prototype {#9}', - 'Host prototype {#10}' - ] - ] - ] - ]; - } - - /** - * Select specified hosts from host prototype page. - * - * @param array $data test case data from data provider - */ - private function selectHostPrototype($data) { - $discoveryid = DBfetch(DBselect("SELECT itemid FROM items WHERE name=".zbx_dbstr($data['item']))); - $this->zbxTestLogin("host_prototypes.php?parent_discoveryid=".$discoveryid['itemid'].'&context=host'); - - if ($data['hosts'] === 'all') { - $this->zbxTestCheckboxSelect('all_hosts'); - return; - } - - foreach ($data['hosts'] as $host) { - $result = DBselect('SELECT hostid FROM hosts WHERE host='.zbx_dbstr($host)); - while ($row = DBfetch($result)) { - $this->zbxTestCheckboxSelect('group_hostid_'.$row['hostid']); - } - } - } - - /** - * Check specific page action. - * Actions are defined by buttons pressed on page. - * - * @param array $data test case data from data provider - * @param string $action button text (action to be executed) - * @param int $status host status to be checked in DB - */ - protected function checkPageAction($data, $action, $status = null) { - // Click on button with required action. - if ($action === 'Click on state') { - foreach ($data['hosts'] as $host) { - $id = DBfetch(DBselect('SELECT hostid FROM hosts WHERE name='.zbx_dbstr($host))); - $this->zbxTestClickXpathWait("//a[contains(@onclick,'group_hostid=".$id['hostid']."')]"); - } - } - else { - $this->selectHostPrototype($data); - $this->zbxTestClickButtonText($action); - $this->zbxTestAcceptAlert(); - } - - $this->zbxTestIsElementPresent('//*[@class="msg-good"]'); - $this->zbxTestCheckTitle('Configuration of host prototypes'); - $this->zbxTestCheckHeader('Host prototypes'); - - // Create query part for status (if any). - $status_criteria = ($status !== null) ? (' AND status='.$status) : ''; - - // Check the results in DB. - if ($data['hosts'] === 'all') { - $sql = 'SELECT NULL'. - ' FROM hosts'. - ' WHERE hostid IN ('. - 'SELECT hostid'. - ' FROM host_discovery'. - ' WHERE parent_itemid IN ('. - 'SELECT itemid'. - ' FROM items'. - ' WHERE name='.zbx_dbstr($data['item']). - ')'. - ')'; - } - else { - $names = []; - foreach ($data['hosts'] as $host) { - $names[] = zbx_dbstr($host); - } - - $sql = 'SELECT NULL'. - ' FROM hosts'. - ' WHERE host IN ('.implode(',', $names).')'; - } - - $this->assertEquals(0, CDBHelper::getCount($sql.$status_criteria)); - } - - /** - * @dataProvider getSelectedData - */ - public function testPageHostPrototypes_DisableSelected($data) { - $this->checkPageAction($data, 'Create disabled', HOST_STATUS_MONITORED); - } - - /** - * @dataProvider getSelectedData - */ - public function testPageHostPrototypes_EnableSelected($data) { - $this->checkPageAction($data, 'Create enabled', HOST_STATUS_NOT_MONITORED); - } - - /** - * @dataProvider getSelectedData - */ - public function testPageHostPrototypes_DeleteSelected($data) { - $this->checkPageAction($data, 'Delete'); - } - - public static function getHostPrototypeData() { - return [ - [ - [ - 'item' => 'Discovery rule 1', - 'hosts' => [ - 'Host prototype {#2}' - ], - 'status' => HOST_STATUS_NOT_MONITORED - ] - ], - [ - [ - 'item' => 'Discovery rule 1', - 'hosts' => [ - 'Host prototype {#3}' - ], - 'status' => HOST_STATUS_MONITORED - ] - ] - ]; - } - - /** - * @dataProvider getHostPrototypeData - */ - public function testPageHostPrototypes_SingleEnableDisable($data) { - $discoveryid = DBfetch(DBselect("SELECT itemid FROM items WHERE name=".zbx_dbstr($data['item']))); - $this->zbxTestLogin("host_prototypes.php?parent_discoveryid=".$discoveryid['itemid'].'&context=host'); - - $this->checkPageAction($data, 'Click on state', $data['status']); - } -} diff --git a/ui/tests/selenium/testPageHosts.php b/ui/tests/selenium/testPageHosts.php deleted file mode 100644 index 5d6d642dc6d..00000000000 --- a/ui/tests/selenium/testPageHosts.php +++ /dev/null @@ -1,704 +0,0 @@ -zbxTestLogin(self::HOST_LIST_PAGE); - $this->zbxTestCheckTitle('Configuration of hosts'); - $this->zbxTestCheckHeader('Hosts'); - $filter = $this->query('name:zbx_filter')->asForm()->one(); - $filter->query('button:Reset')->one()->click(); - $filter->getField('Host groups')->select($this->HostGroup); - $filter->submit(); - - $this->zbxTestTextPresent($this->HostName); - $this->zbxTestTextPresent('Simple form test host'); - $this->zbxTestTextNotPresent('ZBX6648 All Triggers Host'); - - // Check that proxy field is disabled. - $this->zbxTestAssertElementNotPresentId('filter_proxyids__ms'); - $this->zbxTestAssertElementPresentXpath('//div[@id="filter_proxyids_"]/..//button[@disabled]'); - - $this->zbxTestAssertElementPresentXpath("//thead//th/a[text()='Name']"); - $this->zbxTestAssertElementPresentXpath("//thead//th[contains(text(),'Items')]"); - $this->zbxTestAssertElementPresentXpath("//thead//th[contains(text(),'Triggers')]"); - $this->zbxTestAssertElementPresentXpath("//thead//th[contains(text(),'Graphs')]"); - $this->zbxTestAssertElementPresentXpath("//thead//th[contains(text(),'Discovery')]"); - $this->zbxTestAssertElementPresentXpath("//thead//th[contains(text(),'Web')]"); - $this->zbxTestAssertElementPresentXpath("//thead//th[contains(text(),'Interface')]"); - $this->zbxTestAssertElementPresentXpath("//thead//th[contains(text(),'Proxy')]"); - $this->zbxTestAssertElementPresentXpath("//thead//th[contains(text(),'Templates')]"); - $this->zbxTestAssertElementPresentXpath("//thead//th/a[contains(text(),'Status')]"); - $this->zbxTestAssertElementPresentXpath("//thead//th[contains(text(),'Availability')]"); - $this->zbxTestAssertElementPresentXpath("//thead//th[contains(text(),'Agent encryption')]"); - $this->zbxTestAssertElementPresentXpath("//thead//th[contains(text(),'Info')]"); - - $this->zbxTestTextNotPresent('Displaying 0 of 0 found'); - $this->zbxTestAssertElementPresentXpath("//div[@class='table-stats'][contains(text(),'Displaying')]"); - - $this->zbxTestAssertElementPresentXpath("//button[text()='Export'][@disabled]"); - $this->zbxTestAssertElementPresentXpath("//button[text()='Mass update'][@disabled]"); - $this->zbxTestAssertElementPresentXpath("//button[text()='Enable'][@disabled]"); - $this->zbxTestAssertElementPresentXpath("//button[text()='Disable'][@disabled]"); - $this->zbxTestAssertElementPresentXpath("//button[text()='Delete'][@disabled]"); - } - - /** - * @dataProvider allHosts - */ - public function testPageHosts_SimpleUpdate($host) { - $hostid = $host['hostid']; - $name = $host['name']; - - $sqlHosts = - 'SELECT hostid,proxy_hostid,host,status,ipmi_authtype,ipmi_privilege,ipmi_username,'. - 'ipmi_password,maintenanceid,maintenance_status,maintenance_type,maintenance_from,'. - 'name,flags,templateid,description,tls_connect,tls_accept'. - ' FROM hosts'. - ' WHERE hostid='.$hostid; - $oldHashHosts = CDBHelper::getHash($sqlHosts); - $sqlItems = "select * from items where hostid=$hostid order by itemid"; - $oldHashItems = CDBHelper::getHash($sqlItems); - $sqlInterface = "select * from interface where hostid=$hostid order by interfaceid"; - $oldHashInterface = CDBHelper::getHash($sqlInterface); - $sqlHostMacro = "select * from hostmacro where hostid=$hostid order by hostmacroid"; - $oldHashHostMacro = CDBHelper::getHash($sqlHostMacro); - $sqlHostsGroups = "select * from hosts_groups where hostid=$hostid order by hostgroupid"; - $oldHashHostsGroups = CDBHelper::getHash($sqlHostsGroups); - $sqlHostsTemplates = "select * from hosts_templates where hostid=$hostid order by hosttemplateid"; - $oldHashHostsTemplates = CDBHelper::getHash($sqlHostsTemplates); - $sqlMaintenancesHosts = "select * from maintenances_hosts where hostid=$hostid order by maintenance_hostid"; - $oldHashMaintenancesHosts = CDBHelper::getHash($sqlMaintenancesHosts); - $sqlHostInventory = "select * from host_inventory where hostid=$hostid"; - $oldHashHostInventory = CDBHelper::getHash($sqlHostInventory); - - $this->zbxTestLogin(self::HOST_LIST_PAGE); - $this->query('button:Reset')->one()->click(); - $this->zbxTestCheckTitle('Configuration of hosts'); - $this->zbxTestCheckHeader('Hosts'); - - $this->zbxTestTextPresent($name); - $this->zbxTestClickLinkText($name); - $form = COverlayDialogElement::find()->asForm()->one()->waitUntilReady(); - $form->submit(); - $this->zbxTestCheckTitle('Configuration of hosts'); - $this->zbxTestWaitUntilMessageTextPresent('msg-good', 'Host updated'); - $this->zbxTestTextPresent($name); - - $this->assertEquals($oldHashHosts, CDBHelper::getHash($sqlHosts)); - $this->assertEquals($oldHashItems, CDBHelper::getHash($sqlItems)); - $this->assertEquals($oldHashInterface, CDBHelper::getHash($sqlInterface)); - $this->assertEquals($oldHashHostMacro, CDBHelper::getHash($sqlHostMacro)); - $this->assertEquals($oldHashHostsGroups, CDBHelper::getHash($sqlHostsGroups)); - $this->assertEquals($oldHashHostsTemplates, CDBHelper::getHash($sqlHostsTemplates)); - $this->assertEquals($oldHashMaintenancesHosts, CDBHelper::getHash($sqlMaintenancesHosts)); - $this->assertEquals($oldHashHostInventory, CDBHelper::getHash($sqlHostInventory)); - } - - - public function testPageHosts_MassDisableAll() { - DBexecute("update hosts set status=".HOST_STATUS_MONITORED." where status=".HOST_STATUS_NOT_MONITORED); - - $this->zbxTestLogin(self::HOST_LIST_PAGE); - $this->zbxTestCheckTitle('Configuration of hosts'); - $this->query('button:Reset')->one()->click(); - - $this->zbxTestCheckboxSelect('all_hosts'); - $this->zbxTestClickButtonText('Disable'); - $this->zbxTestAcceptAlert(); - - $this->zbxTestCheckTitle('Configuration of hosts'); - $this->zbxTestWaitUntilMessageTextPresent('msg-good', 'Hosts disabled'); - - $sql = "select * from hosts where status=".HOST_STATUS_MONITORED. - " and NOT flags = 2"; - $this->assertEquals(0, CDBHelper::getCount($sql), "Chuck Norris: all hosts disabled but DB does not match"); - } - - /** - * @dataProvider allHosts - */ - public function testPageHosts_MassDisable($host) { - DBexecute("update hosts set status=".HOST_STATUS_MONITORED." where status=".HOST_STATUS_NOT_MONITORED); - - $hostid = $host['hostid']; - - $this->zbxTestLogin(self::HOST_LIST_PAGE); - $this->zbxTestCheckTitle('Configuration of hosts'); - $this->query('button:Reset')->one()->click(); - - $this->zbxTestCheckboxSelect('hostids_'.$hostid); - $this->zbxTestClickButtonText('Disable'); - $this->zbxTestAcceptAlert(); - - $this->zbxTestCheckTitle('Configuration of hosts'); - $this->zbxTestWaitUntilMessageTextPresent('msg-good', 'Host disabled'); - - $sql = "select * from hosts where hostid=$hostid and status=".HOST_STATUS_NOT_MONITORED; - $this->assertEquals(1, CDBHelper::getCount($sql), "Chuck Norris: host $hostid disabled but status is wrong in the DB"); - } - - /** - * @dataProvider allHosts - */ - public function testPageHosts_MassActivate($host) { - DBexecute("update hosts set status=".HOST_STATUS_NOT_MONITORED." where status=".HOST_STATUS_MONITORED); - - $hostid = $host['hostid']; - - $this->zbxTestLogin(self::HOST_LIST_PAGE); - $this->zbxTestCheckTitle('Configuration of hosts'); - $this->query('button:Reset')->one()->click(); - - $this->zbxTestCheckboxSelect('hostids_'.$hostid); - $this->zbxTestClickButtonText('Enable'); - $this->zbxTestAcceptAlert(); - - $this->zbxTestCheckTitle('Configuration of hosts'); - $this->zbxTestWaitUntilMessageTextPresent('msg-good', 'Host enabled'); - - $sql = "select * from hosts where hostid=$hostid and status=".HOST_STATUS_MONITORED; - $this->assertEquals(1, CDBHelper::getCount($sql), "Chuck Norris: host $hostid activated but status is wrong in the DB"); - } - - public function testPageHosts_MassActivateAll() { - DBexecute("update hosts set status=".HOST_STATUS_NOT_MONITORED." where status=".HOST_STATUS_MONITORED); - - $this->zbxTestLogin(self::HOST_LIST_PAGE); - $this->zbxTestCheckTitle('Configuration of hosts'); - $this->query('button:Reset')->one()->click(); - - $this->zbxTestCheckboxSelect('all_hosts'); - $this->zbxTestClickButtonText('Enable'); - $this->zbxTestAcceptAlert(); - - $this->zbxTestCheckTitle('Configuration of hosts'); - $this->zbxTestWaitUntilMessageTextPresent('msg-good', 'Hosts enabled'); - - $sql = "select host from hosts where status=".HOST_STATUS_NOT_MONITORED. - " and NOT flags = 2"; - $this->assertEquals(0, CDBHelper::getCount($sql), "Chuck Norris: all hosts activated but DB does not match"); - } - - public function testPageHosts_FilterByName() { - $this->zbxTestLogin(self::HOST_LIST_PAGE); - $filter = $this->query('name:zbx_filter')->asForm()->one(); - $filter->query('button:Reset')->one()->click(); - $filter->getField('Name')->fill($this->HostName); - $filter->submit(); - $this->zbxTestTextPresent($this->HostName); - $this->zbxTestTextNotPresent('Displaying 0 of 0 found'); - } - - public function testPageHosts_FilterByTemplates() { - $this->zbxTestLogin(self::HOST_LIST_PAGE); - $filter = $this->query('name:zbx_filter')->asForm()->one(); - $filter->query('button:Reset')->one()->click(); - $filter->fill([ - 'Templates' => [ - 'values' =>'Form test template', - 'context' => 'Templates'] - ]); - $filter->submit(); - $this->zbxTestWaitForPageToLoad(); - $this->zbxTestAssertElementPresentXpath("//tbody//a[text()='Simple form test host']"); - $this->zbxTestAssertElementPresentXpath("//div[@class='table-stats'][text()='Displaying 1 of 1 found']"); - } - - public function testPageHosts_FilterByProxy() { - $this->zbxTestLogin(self::HOST_LIST_PAGE); - $filter = $this->query('name:zbx_filter')->asForm()->one(); - $filter->query('button:Reset')->one()->click(); - - $this->zbxTestClickXpathWait('//label[text()="Proxy"]'); - $this->zbxTestClickButtonText('Apply'); - $this->zbxTestAssertElementPresentXpath("//tbody//a[text()='Host_1 with proxy']"); - $this->zbxTestAssertElementPresentXpath("//tbody//td[text()='Proxy_1 for filter']"); - $this->zbxTestAssertElementPresentXpath("//tbody//a[text()='Host_2 with proxy']"); - $this->zbxTestAssertElementPresentXpath("//tbody//td[text()='Proxy_2 for filter']"); - $this->zbxTestAssertElementPresentXpath("//div[@class='table-stats'][text()='Displaying 3 of 3 found']"); - $this->zbxTestClickButtonMultiselect('filter_proxyids_'); - $this->zbxTestLaunchOverlayDialog('Proxies'); - $this->zbxTestClickLinkTextWait('Proxy_1 for filter'); - $this->zbxTestClickButtonText('Apply'); - $this->zbxTestWaitForPageToLoad(); - $this->zbxTestAssertElementPresentXpath("//tbody//a[text()='Host_1 with proxy']"); - $this->zbxTestAssertElementPresentXpath("//div[@class='table-stats'][text()='Displaying 1 of 1 found']"); - } - - public function testPageHosts_FilterNone() { - $this->zbxTestLogin(self::HOST_LIST_PAGE); - $filter = $this->query('name:zbx_filter')->asForm()->one(); - $filter->query('button:Reset')->one()->click(); - $filter->getField('Name')->fill('1928379128ksdhksdjfh'); - $filter->submit(); - $this->zbxTestAssertElementPresentXpath("//div[@class='table-stats'][text()='Displaying 0 of 0 found']"); - $filter->invalidate(); - $filter->getField('Name')->fill('%'); - $filter->submit(); - $this->zbxTestAssertElementPresentXpath("//div[@class='table-stats'][text()='Displaying 0 of 0 found']"); - } - - public function testPageHosts_FilterByAllFields() { - $this->zbxTestLogin(self::HOST_LIST_PAGE); - $filter = $this->query('name:zbx_filter')->asForm()->one(); - $filter->query('button:Reset')->one()->click(); - $filter->getField('Host groups')->select($this->HostGroup); - $filter->getField('Name')->fill($this->HostName); - $filter->getField('IP')->fill($this->HostIp); - $filter->getField('Port')->fill($this->HostPort); - $filter->submit(); - $this->zbxTestTextPresent($this->HostName); - $this->zbxTestAssertElementPresentXpath("//div[@class='table-stats'][text()='Displaying 1 of 1 found']"); - } - - public function testPageHosts_FilterReset() { - $this->zbxTestLogin(self::HOST_LIST_PAGE); - $this->query('button:Reset')->one()->click(); - $this->zbxTestTextNotPresent('Displaying 0 of 0 found'); - } - - public static function getFilterByTagsData() { - return [ - // "And" and "And/Or" checks. - [ - [ - 'evaluation_type' => 'And/Or', - 'tags' => [ - ['name' => 'tag', 'operator' => 'Contains', 'value' => 'host'], - ['name' => 'test', 'operator' => 'Contains', 'value' => 'test_tag'] - ], - 'result' => [ - [ - 'Name' => 'Host for tags filtering', - 'Tags' => [ - 'selector' => 'class:tag', - 'text' => ['tag: HOST', 'test: test_tag', 'action: simple'] - ] - ] - ] - ] - ], - [ - [ - 'evaluation_type' => 'Or', - 'tags' => [ - ['name' => 'tag', 'operator' => 'Contains', 'value' => 'host'], - ['name' => 'test', 'operator' => 'Contains', 'value' => 'test_tag'] - ], - 'result' => [ - [ - 'Name' => 'Host for tags filtering', - 'Tags' => [ - 'selector' => 'class:tag', - 'text' => ['tag: HOST', 'test: test_tag', 'action: simple'] - ] - ], - [ - 'Name' => 'Host for tags filtering - clone', - 'Tags' => [ - 'selector' => 'class:tag', - 'text' => ['tag: host', 'action: clone'] - ] - ], - [ - 'Name' => 'Host for tags filtering - update', - 'Tags' => [ - 'selector' => 'class:tag', - 'text' => ['tag: host', 'action: update'] - ] - ] - ] - ] - ], - // "Contains" and "Equals" checks. - [ - [ - 'evaluation_type' => 'And/Or', - 'tags' => [ - ['name' => 'tag', 'operator' => 'Contains', 'value' => 'HOST'] - ], - 'result' => [ - ['Name' => 'Host for tags filtering', 'Templates' => 'Template for tags filtering'], - ['Name' => 'Host for tags filtering - clone', 'Templates' => ''], - ['Name' => 'Host for tags filtering - update', 'Templates' => ''] - ] - ] - ], - [ - [ - 'evaluation_type' => 'And/Or', - 'tags' => [ - ['name' => 'tag', 'operator' => 'Equals', 'value' => 'HOST'] - ], - 'result' => [ - ['Name' => 'Host for tags filtering'] - ] - ] - ], - [ - [ - 'evaluation_type' => 'And/Or', - 'tags' => [ - ['name' => 'action', 'operator' => 'Contains'] - ], - 'result' => [ - ['Name' => 'Host for tags filtering'], - ['Name' => 'Host for tags filtering - clone'], - ['Name' => 'Host for tags filtering - update'] - ] - ] - ], - [ - [ - 'evaluation_type' => 'And/Or', - 'tags' => [ - ['name' => 'action', 'operator' => 'Equals'] - ] - ] - ], - [ - [ - 'evaluation_type' => 'And/Or', - 'tags' => [ - ['name' => 'tag', 'operator' => 'Exists'], - ['name' => 'test', 'operator' => 'Exists'] - ], - 'result' => [ - ['Name' => 'Host for tags filtering'] - ] - ] - ], - [ - [ - 'evaluation_type' => 'Or', - 'tags' => [ - ['name' => 'tag', 'operator' => 'Exists'], - ['name' => 'test', 'operator' => 'Exists'] - ], - 'result' => [ - ['Name' => 'Host for tags filtering'], - ['Name' => 'Host for tags filtering - clone'], - ['Name' => 'Host for tags filtering - update'] - ] - ] - ], - [ - [ - 'evaluation_type' => 'And/Or', - 'tags' => [ - ['name' => 'test', 'operator' => 'Exists'] - ], - 'result' => [ - ['Name' => 'Host for tags filtering'] - ] - ] - ], - [ - [ - 'evaluation_type' => 'Or', - 'tags' => [ - ['name' => 'action', 'operator' => 'Exists'] - ], - 'result' => [ - ['Name' => 'Host for tags filtering'], - ['Name' => 'Host for tags filtering - clone'], - ['Name' => 'Host for tags filtering - update'] - ] - ] - ], - [ - [ - 'evaluation_type' => 'And/Or', - 'tags' => [ - ['name' => 'test', 'operator' => 'Does not exist'] - ], - 'result' => [ - ['Name' => 'Host for tags filtering - clone'], - ['Name' => 'Host for tags filtering - update'], - ['Name' => 'Simple form test host'], - ['Name' => 'SLA reports host'], - ['Name' => 'Template inheritance test host'] - ] - ] - ], - [ - [ - 'evaluation_type' => 'Or', - 'tags' => [ - ['name' => 'test', 'operator' => 'Does not exist'] - ], - 'result' => [ - ['Name' => 'Host for tags filtering - clone'], - ['Name' => 'Host for tags filtering - update'], - ['Name' => 'Simple form test host'], - ['Name' => 'SLA reports host'], - ['Name' => 'Template inheritance test host'] - ] - ] - ], - [ - [ - 'evaluation_type' => 'Or', - 'tags' => [ - ['name' => 'test', 'operator' => 'Does not exist'], - ['name' => 'tag', 'operator' => 'Does not exist'] - ], - 'result' => [ - ['Name' => 'Host for tags filtering - clone'], - ['Name' => 'Host for tags filtering - update'], - ['Name' => 'Simple form test host'], - ['Name' => 'SLA reports host'], - ['Name' => 'Template inheritance test host'] - ] - ] - ], - [ - [ - 'evaluation_type' => 'And/Or', - 'tags' => [ - ['name' => 'test', 'operator' => 'Does not exist'], - ['name' => 'tag', 'operator' => 'Does not exist'] - ], - 'result' => [ - ['Name' => 'Simple form test host'], - ['Name' => 'SLA reports host'], - ['Name' => 'Template inheritance test host'] - ] - ] - ], - [ - [ - 'evaluation_type' => 'And/Or', - 'tags' => [ - ['name' => 'test', 'operator' => 'Does not equal', 'value' => 'test_tag'] - ], - 'result' => [ - ['Name' => 'Host for tags filtering - clone'], - ['Name' => 'Host for tags filtering - update'], - ['Name' => 'Simple form test host'], - ['Name' => 'SLA reports host'], - ['Name' => 'Template inheritance test host'] - ] - ] - ], - [ - [ - 'evaluation_type' => 'Or', - 'tags' => [ - ['name' => 'test', 'operator' => 'Does not equal', 'value' => 'test_tag'] - ], - 'result' => [ - ['Name' => 'Host for tags filtering - clone'], - ['Name' => 'Host for tags filtering - update'], - ['Name' => 'Simple form test host'], - ['Name' => 'SLA reports host'], - ['Name' => 'Template inheritance test host'] - ] - ] - ], - [ - [ - 'evaluation_type' => 'And/Or', - 'tags' => [ - ['name' => 'test', 'operator' => 'Does not equal'] - ], - 'result' => [ - ['Name' => 'Host for tags filtering'], - ['Name' => 'Host for tags filtering - clone'], - ['Name' => 'Host for tags filtering - update'], - ['Name' => 'Simple form test host'], - ['Name' => 'SLA reports host'], - ['Name' => 'Template inheritance test host'] - ] - ] - ], - [ - [ - 'evaluation_type' => 'And/Or', - 'tags' => [ - ['name' => 'action', 'operator' => 'Does not equal', 'value' => 'update'], - ['name' => 'action', 'operator' => 'Does not equal', 'value' => 'simple'] - ], - 'result' => [ - ['Name' => 'Host for tags filtering - clone'], - ['Name' => 'Simple form test host'], - ['Name' => 'SLA reports host'], - ['Name' => 'Template inheritance test host'] - ] - ] - ], - [ - [ - 'evaluation_type' => 'Or', - 'tags' => [ - ['name' => 'action', 'operator' => 'Does not equal', 'value' => 'update'], - ['name' => 'action', 'operator' => 'Does not equal', 'value' => 'simple'] - ], - 'result' => [ - ['Name' => 'Host for tags filtering - clone'], - ['Name' => 'Simple form test host'], - ['Name' => 'SLA reports host'], - ['Name' => 'Template inheritance test host'] - ] - ] - ], - [ - [ - 'evaluation_type' => 'And/Or', - 'tags' => [ - ['name' => 'action', 'operator' => 'Does not contain', 'value' => 'clone'] - ], - 'result' => [ - ['Name' => 'Host for tags filtering'], - ['Name' => 'Host for tags filtering - update'], - ['Name' => 'Simple form test host'], - ['Name' => 'SLA reports host'], - ['Name' => 'Template inheritance test host'] - ] - ] - ], - [ - [ - 'evaluation_type' => 'Or', - 'tags' => [ - ['name' => 'action', 'operator' => 'Does not contain', 'value' => 'clone'] - ], - 'result' => [ - ['Name' => 'Host for tags filtering'], - ['Name' => 'Host for tags filtering - update'], - ['Name' => 'Simple form test host'], - ['Name' => 'SLA reports host'], - ['Name' => 'Template inheritance test host'] - ] - ] - ], - [ - [ - 'evaluation_type' => 'And/Or', - 'tags' => [ - ['name' => 'action', 'operator' => 'Does not contain', 'value' => 'clo'], - ['name' => 'tag', 'operator' => 'Does not contain', 'value' => 'ho'] - ], - 'result' => [ - ['Name' => 'Simple form test host'], - ['Name' => 'SLA reports host'], - ['Name' => 'Template inheritance test host'] - ] - ] - ], - [ - [ - 'evaluation_type' => 'Or', - 'tags' => [ - ['name' => 'action', 'operator' => 'Does not contain', 'value' => 'clo'], - ['name' => 'tag', 'operator' => 'Does not contain', 'value' => 'ho'] - ], - 'result' => [ - ['Name' => 'Host for tags filtering'], - ['Name' => 'Host for tags filtering - update'], - ['Name' => 'Simple form test host'], - ['Name' => 'SLA reports host'], - ['Name' => 'Template inheritance test host'] - ] - ] - ], - [ - [ - 'evaluation_type' => 'And/Or', - 'tags' => [ - ['name' => 'action', 'operator' => 'Does not contain', 'value' => 'clone'], - ['name' => 'tag', 'operator' => 'Equals', 'value' => 'host'] - ], - 'result' => [ - ['Name' => 'Host for tags filtering - update'] - ] - ] - ], - [ - [ - 'evaluation_type' => 'And/Or', - 'tags' => [ - ['name' => 'action', 'operator' => 'Does not contain', 'value' => 'clone'], - ['name' => 'tag', 'operator' => 'Exists'] - ], - 'result' => [ - ['Name' => 'Host for tags filtering'], - ['Name' => 'Host for tags filtering - update'] - ] - ] - ] - ]; - } - - /** - * Test filtering hosts by tags. - * - * @dataProvider getFilterByTagsData - */ - public function testPageHosts_FilterByTags($data) { - $this->page->login()->open((new CUrl('zabbix.php')) - ->setArgument('action', 'host.list') - ->setArgument('filter_groups[]', 4) - ->setArgument('filter_host', 'host') - ->setArgument('filter_port', 10051) - ->setArgument('filter_set', 1) - ->getUrl() - ); - $form = $this->query('name:zbx_filter')->waitUntilPresent()->asForm()->one(); - $form->fill(['id:filter_evaltype' => $data['evaluation_type']]); - $this->setTags($data['tags']); - $form->submit(); - $this->page->waitUntilReady(); - // Check filtered result. - $this->assertTableData(CTestArrayHelper::get($data, 'result', [])); - - // Reset filter due to not influence further tests. - $form->query('button:Reset')->one()->click(); - } -} diff --git a/ui/tests/selenium/testPageMonitoringHosts.php b/ui/tests/selenium/testPageMonitoringHosts.php deleted file mode 100644 index ee8907833a6..00000000000 --- a/ui/tests/selenium/testPageMonitoringHosts.php +++ /dev/null @@ -1,1184 +0,0 @@ -page->login()->open('zabbix.php?action=host.view')->waitUntilReady(); - $form = $this->query('name:zbx_filter')->waitUntilPresent()->asForm()->one(); - $table = $this->query('class:list-table')->asTable()->one(); - - // Checking Title, Header and Column names. - $this->page->assertTitle('Hosts'); - $this->page->assertHeader('Hosts'); - $headers = ['Name', 'Interface', 'Availability', 'Tags', 'Status', 'Latest data', 'Problems','Graphs', - 'Dashboards', 'Web']; - $this->assertSame($headers, ($this->query('class:list-table')->asTable()->one())->getHeadersText()); - - // Check filter collapse/expand. - foreach ([true, false] as $status) { - $this->assertTrue($this->query('xpath://ul[@class="ui-sortable-container ui-sortable"]//li[contains(@class, "selected")]') - ->one()->isPresent($status) - ); - $this->query('xpath://a[@aria-label="Home"]')->one()->click(); - } - - // Check fields maximum length. - foreach(['tags[0][tag]', 'tags[0][value]'] as $field) { - $this->assertEquals(255, $form->query('xpath:.//input[@name="'.$field.'"]') - ->one()->getAttribute('maxlength')); - } - - // Check tags maximum length. - foreach(['name', 'ip', 'dns', 'port'] as $field) { - $this->assertEquals(255, $form->query('xpath:.//input[@id="'.$field.'_0"]') - ->one()->getAttribute('maxlength')); - } - - // Check disabled links. - foreach (['Graphs', 'Dashboards', 'Web'] as $disabled) { - $row = $table->findRow('Name', 'Available host'); - $this->assertTrue($row->query('xpath://following::td/span[@class="disabled" and text()="'.$disabled.'"]')->exists()); - } - - // Check tags on the specific host. - $tags = $table->findRow('Name', 'Host for tags filtering - clone')->getColumn('Tags')->query('class:tag')->all(); - $this->assertEquals(['action: clone', 'tag: host'], $tags->asText()); - - foreach ($tags as $tag) { - $tag->click(); - $hint = $this->query('xpath://div[@data-hintboxid]')->asOverlayDialog()->waitUntilPresent()->all()->last(); - $this->assertEquals($tag->getText(), $hint->getText()); - $hint->close(); - } - } - - public static function getCheckFilterData() { - return [ - [ - [ - 'filter' => [ - 'Name' => 'Empty host' - ], - 'expected' => [ - 'Empty host' - ] - ] - ], - [ - [ - 'filter' => [ - 'Host groups' => [ - 'Group to copy all graph' - ] - ], - 'expected' => [ - 'Host with item to copy all graphs 1', - 'Host with item to copy all graphs 2' - ] - ] - ], - [ - [ - 'filter' => [ - 'IP' => '127.0.0.3' - ], - 'expected' => [ - 'Template inheritance test host', - 'Test item host' - ] - ] - ], - [ - [ - 'filter' => [ - 'DNS' => 'zabbixzabbixzabbix.com' - ], - 'expected' => [ - 'Available host', - 'Not available host', - 'Not available host in maintenance', - 'Unknown host', - 'Unknown host in maintenance' - ] - ] - ], - [ - [ - 'filter' => [ - 'Port' => '161' - ], - 'expected' => [ - 'Test item host', - 'Visible host for template linkage' - ] - ] - ], - [ - [ - 'filter' => [ - 'Severity' => [ - 'Not classified' - ] - ], - 'expected' => [ - '1_Host_to_check_Monitoring_Overview', - 'Host for tag permissions' - ] - ] - ], - [ - [ - 'filter' => [ - 'Severity' => [ - 'Warning' - ] - ], - 'expected' => [ - '1_Host_to_check_Monitoring_Overview', - 'ЗАББИКС Сервер' - ] - ] - ], - [ - [ - 'filter' => [ - 'Severity' => [ - 'High' - ] - ], - 'expected' => [ - '1_Host_to_check_Monitoring_Overview' - ] - ] - ], - [ - [ - 'filter' => [ - 'Severity' => [ - 'Information' - ] - ], - 'expected' => [ - '1_Host_to_check_Monitoring_Overview' - ] - ] - ], - [ - [ - 'filter' => [ - 'Severity' => [ - 'Average' - ] - ], - 'expected' => [ - '1_Host_to_check_Monitoring_Overview', - '3_Host_to_check_Monitoring_Overview', - '4_Host_to_check_Monitoring_Overview', - 'Host for triggers filtering', - 'ЗАББИКС Сервер' - ] - ] - ], - [ - [ - 'filter' => [ - 'Severity' => 'Disaster' - ], - 'expected' => [ - '1_Host_to_check_Monitoring_Overview' - ] - ] - ], - [ - [ - 'filter' => [ - 'Status' => 'Disabled' - ], - 'expected' => [ - 'No data found.' - ] - ] - ], - [ - [ - 'filter' => [ - 'Name' => 'available', - 'Host groups' => [ - 'Group for Host availability widget' - ] - ], - 'expected' => [ - 'Available host', - 'Not available host' - ] - ] - ], - [ - [ - 'filter' => [ - 'Name' => 'for', - 'Host groups' => [ - 'Zabbix servers' - ], - 'IP' => '127.0.5.1' - ], - 'expected' => [ - 'Simple form test host' - ] - ] - ], - [ - [ - 'filter' => [ - 'Name' => 'Unknown', - 'Host groups' => [ - 'Group for Host availability widget'], - 'IP' => '127.0.0.1', - 'DNS' => 'zabbix.com' - ], - 'expected' => [ - 'Unknown host' - ] - ] - ], - [ - [ - 'filter' => [ - 'Name' => 'maintenance', - 'Host groups' => [ - 'Group in maintenance for Host availability widget' - ], - 'IP' => '127.0.0.1', - 'DNS' => 'zab', - 'Port' => '10050' - ], - 'expected' => [ - 'Not available host in maintenance', - 'Unknown host in maintenance' - ] - ] - ], - [ - [ - 'filter' => [ - 'Severity' => [ - 'Not classified', - 'Warning', - 'High', - 'Information', - 'Average', - 'Disaster' - ] - ], - 'expected' => [ - '1_Host_to_check_Monitoring_Overview', - '3_Host_to_check_Monitoring_Overview', - '4_Host_to_check_Monitoring_Overview', - 'Host for tag permissions', - 'Host for triggers filtering', - 'ЗАББИКС Сервер' - ] - ] - ], - [ - [ - 'filter' => [ - 'Name' => 'Tommy' - ], - 'expected' => [] - ] - ], - // With name 'maintenance', exists 3 hosts in maintenance status. Unchecking 'Show hosts in maintenance'. - [ - [ - 'filter' => [ - 'Name' => 'maintenance', - 'Show hosts in maintenance' => false - ], - 'expected' => [] - ] - ], - [ - [ - 'filter' => [ - 'Name' => 'maintenance' - ], - 'expected' => [ - 'Available host in maintenance', - 'Not available host in maintenance', - 'Unknown host in maintenance' - ] - ] - ] - ]; - } - - /** - * @dataProvider getCheckFilterData - */ - public function testPageMonitoringHosts_CheckFilter($data) { - $this->page->login()->open('zabbix.php?action=host.view&filter_reset=1'); - $form = $this->query('name:zbx_filter')->waitUntilPresent()->asForm()->one(); - $form->fill($data['filter']); - $table = $this->query('class:list-table')->waitUntilPresent()->asTable()->one(); - $this->query('button:Apply')->waitUntilClickable()->one()->click(); - $table->waitUntilReloaded(); - $this->assertTableDataColumn($data['expected']); - $this->query('button:Reset')->waitUntilClickable()->one()->click(); - $table->waitUntilReloaded(); - } - - public static function getTagsFilterData() { - return [ - [ - [ - 'tag_options' => [ - 'type' => 'And/Or', - 'tags' => [ - ['name' => 'test', 'value' => 'test_tag', 'operator' => 'Equals'] - ] - ], - 'result' => [ - 'Host for tags filtering' - ] - ] - ], - [ - [ - 'tag_options' => [ - 'type' => 'And/Or', - 'tags' => [ - ['name' => 'test', 'value' => '', 'operator' => 'Contains'] - ] - ], - 'result' => [ - 'Host for tags filtering' - ] - ] - ], - [ - [ - 'tag_options' => [ - 'type' => 'Or', - 'tags' => [ - ['name' => 'test', 'value' => 'test_tag', 'operator' => 'Equals'], - ['name' => 'action', 'value' => 'clone', 'operator' => 'Contains'] - ] - ], - 'result' => [ - 'Host for tags filtering', - 'Host for tags filtering - clone' - ] - ] - ], - [ - [ - 'tag_options' => [ - 'type' => 'Or', - 'tags' => [ - ['name' => 'action', 'value' => 'clone', 'operator' => 'Equals'], - ['name' => 'tag', 'value' => 'host', 'operator' => 'Equals'] - ] - ], - 'result' => [ - 'Host for tags filtering - clone', - 'Host for tags filtering - update' - ] - ] - ], - [ - [ - 'tag_options' => [ - 'type' => 'And/Or', - 'tags' => [ - ['name' => 'action', 'value' => 'clone', 'operator' => 'Contains'], - ['name' => 'tag', 'value' => 'host', 'operator' => 'Contains'] - ] - ], - 'result' => [ - 'Host for tags filtering - clone' - ] - ] - ], - [ - [ - 'tag_options' => [ - 'type' => 'Or', - 'tags' => [ - ['name' => 'action', 'value' => 'clone', 'operator' => 'Equals'], - ['name' => 'action', 'value' => 'update', 'operator' => 'Equals'], - ['name' => 'tag', 'value' => 'TEMPLATE', 'operator' => 'Equals'] - ] - ], - 'result' => [ - 'Host for tags filtering', - 'Host for tags filtering - clone', - 'Host for tags filtering - update' - ] - ] - ], - // Wrote 'template' in lowercase. - [ - [ - 'tag_options' => [ - 'type' => 'And/Or', - 'tags' => [ - ['name' => 'tag', 'value' => 'template', 'operator' => 'Equals'] - ] - ], - 'result' => [] - ] - ], - // Non-existing tag. - [ - [ - 'tag_options' => [ - 'type' => 'And/Or', - 'tags' => [ - ['name' => 'Tommy', 'value' => 'train', 'operator' => 'Contains'] - ] - ], - 'result' => [] - ] - ], - [ - [ - 'tag_options' => [ - 'type' => 'And/Or', - 'tags' => [ - ['name' => 'test', 'operator' => 'Exists'] - ] - ], - 'result' => [ - 'Host for tags filtering' - ] - ] - ], - [ - [ - 'tag_options' => [ - 'type' => 'Or', - 'tags' => [ - ['name' => 'test', 'operator' => 'Exists'] - ] - ], - 'result' => [ - 'Host for tags filtering' - ] - ] - ], - [ - [ - 'tag_options' => [ - 'type' => 'And/Or', - 'tags' => [ - ['name' => 'tag', 'operator' => 'Exists'], - ['name' => 'test', 'operator' => 'Exists'] - ] - ], - 'result' => [ - 'Host for tags filtering' - ] - ] - ], - [ - [ - 'tag_options' => [ - 'type' => 'Or', - 'tags' => [ - ['name' => 'tag', 'operator' => 'Exists'], - ['name' => 'test', 'operator' => 'Exists'] - ] - ], - 'result' => [ - 'Host for tags filtering', - 'Host for tags filtering - clone', - 'Host for tags filtering - update' - ] - ] - ], - [ - [ - 'tag_options' => [ - 'type' => 'And/Or', - 'tags' => [ - ['name' => 'test', 'operator' => 'Does not exist'] - ] - ], - 'result' => [ - 'Host for tags filtering - clone', - 'Host for tags filtering - update', - 'Simple form test host', - 'SLA reports host', - 'Template inheritance test host', - 'ЗАББИКС Сервер' - ] - ] - ], - [ - [ - 'tag_options' => [ - 'type' => 'Or', - 'tags' => [ - ['name' => 'test', 'operator' => 'Does not exist'] - ] - ], - 'result' => [ - 'Host for tags filtering - clone', - 'Host for tags filtering - update', - 'Simple form test host', - 'SLA reports host', - 'Template inheritance test host', - 'ЗАББИКС Сервер' - ] - ] - ], - [ - [ - 'tag_options' => [ - 'type' => 'Or', - 'tags' => [ - ['name' => 'action', 'operator' => 'Does not exist'], - ['name' => 'tag', 'operator' => 'Does not exist'] - ] - ], - 'result' => [ - 'Simple form test host', - 'SLA reports host', - 'Template inheritance test host', - 'ЗАББИКС Сервер' - ] - ] - ], - [ - [ - 'tag_options' => [ - 'type' => 'And/Or', - 'tags' => [ - ['name' => 'action', 'operator' => 'Does not exist'], - ['name' => 'tag', 'operator' => 'Does not exist'] - ] - ], - 'result' => [ - 'Simple form test host', - 'SLA reports host', - 'Template inheritance test host', - 'ЗАББИКС Сервер' - ] - ] - ], - [ - [ - 'tag_options' => [ - 'type' => 'And/Or', - 'tags' => [ - ['name' => 'test', 'operator' => 'Does not equal', 'value' => 'test_tag'] - ] - ], - 'result' => [ - 'Host for tags filtering - clone', - 'Host for tags filtering - update', - 'Simple form test host', - 'SLA reports host', - 'Template inheritance test host', - 'ЗАББИКС Сервер' - ] - ] - ], - [ - [ - 'tag_options' => [ - 'type' => 'Or', - 'tags' => [ - ['name' => 'test', 'operator' => 'Does not equal', 'value' => 'test_tag'] - ] - ], - 'result' => [ - 'Host for tags filtering - clone', - 'Host for tags filtering - update', - 'Simple form test host', - 'SLA reports host', - 'Template inheritance test host', - 'ЗАББИКС Сервер' - ] - ] - ], - [ - [ - 'tag_options' => [ - 'type' => 'And/Or', - 'tags' => [ - ['name' => 'test', 'operator' => 'Does not equal', 'value' => 'test_tag'], - ['name' => 'action', 'operator' => 'Does not equal', 'value' => 'clone'] - ] - ], - 'result' => [ - 'Host for tags filtering - update', - 'Simple form test host', - 'SLA reports host', - 'Template inheritance test host', - 'ЗАББИКС Сервер' - ] - ] - ], - [ - [ - 'tag_options' => [ - 'type' => 'Or', - 'tags' => [ - ['name' => 'test', 'operator' => 'Does not equal', 'value' => 'test_tag'], - ['name' => 'action', 'operator' => 'Does not equal', 'value' => 'clone'] - ] - ], - 'result' => [ - 'Host for tags filtering', - 'Host for tags filtering - clone', - 'Host for tags filtering - update', - 'Simple form test host', - 'SLA reports host', - 'Template inheritance test host', - 'ЗАББИКС Сервер' - ] - ] - ], - [ - [ - 'tag_options' => [ - 'type' => 'And/Or', - 'tags' => [ - ['name' => 'tag', 'operator' => 'Does not contain', 'value' => 'host'] - ] - ], - 'result' => [ - 'Simple form test host', - 'SLA reports host', - 'Template inheritance test host', - 'ЗАББИКС Сервер' - ] - ] - ], - [ - [ - 'tag_options' => [ - 'type' => 'Or', - 'tags' => [ - ['name' => 'tag', 'operator' => 'Does not contain', 'value' => 'host'] - ] - ], - 'result' => [ - 'Simple form test host', - 'SLA reports host', - 'Template inheritance test host', - 'ЗАББИКС Сервер' - ] - ] - ], - [ - [ - 'tag_options' => [ - 'type' => 'And/Or', - 'tags' => [ - ['name' => 'action', 'operator' => 'Does not contain', 'value' => 'clone'], - ['name' => 'tag', 'operator' => 'Does not contain', 'value' => 'host'] - ] - ], - 'result' => [ - 'Simple form test host', - 'SLA reports host', - 'Template inheritance test host', - 'ЗАББИКС Сервер' - ] - ] - ], - [ - [ - 'tag_options' => [ - 'type' => 'Or', - 'tags' => [ - ['name' => 'action', 'operator' => 'Does not contain', 'value' => 'clone'], - ['name' => 'tag', 'operator' => 'Does not contain', 'value' => 'host'] - ] - ], - 'result' => [ - 'Host for tags filtering', - 'Host for tags filtering - update', - 'Simple form test host', - 'SLA reports host', - 'Template inheritance test host', - 'ЗАББИКС Сервер' - ] - ] - ], - [ - [ - 'tag_options' => [ - 'type' => 'And/Or', - 'tags' => [ - ['name' => 'action', 'operator' => 'Does not contain', 'value' => 'clone'], - ['name' => 'tag', 'operator' => 'Equals', 'value' => 'host'] - ] - ], - 'result' => [ - 'Host for tags filtering - update' - ] - ] - ], - [ - [ - 'tag_options' => [ - 'type' => 'And/Or', - 'tags' => [ - ['name' => 'action', 'operator' => 'Does not contain', 'value' => 'clone'], - ['name' => 'tag', 'operator' => 'Exists'] - ] - ], - 'result' => [ - 'Host for tags filtering', - 'Host for tags filtering - update' - ] - ] - ] - ]; - } - - /** - * @dataProvider getTagsFilterData - */ - public function testPageMonitoringHosts_TagsFilter($data) { - $this->page->login()->open('zabbix.php?port=10051&action=host.view&groupids%5B%5D=4'); - $form = $this->query('name:zbx_filter')->waitUntilPresent()->asForm()->one(); - $table = $this->query('class:list-table')->waitUntilPresent()->one(); - $form->fill(['id:evaltype_0' => $data['tag_options']['type']]); - $this->setTagSelector('id:tags_0'); - $this->setTags($data['tag_options']['tags']); - $this->query('button:Apply')->one()->waitUntilClickable()->click(); - $table->waitUntilReloaded(); - $this->assertTableDataColumn(CTestArrayHelper::get($data, 'result', [])); - $this->query('button:Reset')->one()->waitUntilClickable()->click(); - $table->waitUntilReloaded(); - } - - public function testPageMonitoringHosts_ResetButtonCheck() { - $this->page->login()->open('zabbix.php?action=host.view&filter_reset=1'); - $form = $this->query('name:zbx_filter')->waitUntilPresent()->asForm()->one(); - $this->page->waitUntilReady(); - $table = $this->query('class:list-table')->asTable()->one(); - - // Check table contents before filtering. - $start_rows_count = $table->getRows()->count(); - $this->assertTableStats($start_rows_count); - $start_contents = $this->getTableResult('Name'); - - // Filter hosts. - $form->fill(['Name' => 'Empty host']); - $this->query('button:Apply')->one()->waitUntilClickable()->click(); - $table->waitUntilReloaded(); - - // Check that filtered count matches expected. - $this->assertEquals(1, $table->getRows()->count()); - $this->assertTableStats(1); - - // After pressing reset button, check that previous hosts are displayed again. - $this->query('button:Reset')->one()->click(); - $table->waitUntilReloaded(); - $reset_rows_count = $table->getRows()->count(); - $this->assertEquals($start_rows_count, $reset_rows_count); - $this->assertTableStats($reset_rows_count); - $this->assertEquals($start_contents, $this->getTableResult('Name')); - } - - // Checking that Show suppressed problems filter works. - public function testPageMonitoringHosts_ShowSuppresed() { - $this->page->login()->open('zabbix.php?action=host.view&filter_reset=1'); - $form = $this->query('name:zbx_filter')->waitUntilPresent()->asForm()->one(); - $this->page->waitUntilReady(); - $table = $this->query('class:list-table')->asTable()->one(); - $form->fill(['Severity' => ['Not classified', 'Information', 'Warning', 'Average', 'High', 'Disaster']]); - $this->query('button:Apply')->one()->waitUntilClickable()->click(); - $table->waitUntilReloaded(); - foreach ([true, false] as $show) { - $form->query('id:show_suppressed_0')->asCheckbox()->one()->fill($show); - $this->query('button:Apply')->one()->waitUntilClickable()->click(); - $table->waitUntilReloaded(); - $this->assertTrue($table->findRow('Name', 'Host for suppression')->isPresent($show)); - } - $this->query('button:Reset')->one()->click(); - } - - public static function getEnabledLinksData() { - return [ - [ - [ - 'name' => 'Dynamic widgets H1', - 'link_name' => 'Graphs', - 'page_header' => 'Graphs' - ] - ], - [ - [ - 'name' => 'Host ZBX6663', - 'link_name' => 'Web', - 'page_header' => 'Web monitoring' - ] - ], - [ - [ - 'name' => 'ЗАББИКС Сервер', - 'link_name' => 'Dashboards', - 'page_header' => 'Network interfaces' - ] - ], - [ - [ - 'name' => 'Empty host', - 'link_name' => 'Problems', - 'page_header' => 'Problems' - ] - ], - [ - [ - 'name' => 'Available host', - 'link_name' => 'Latest data', - 'page_header' => 'Latest data' - ] - ] - ]; - } - - /** - * @dataProvider getEnabledLinksData - * - * Check enabled links and that correct host is displayed. - */ - public function testPageMonitoringHosts_EnabledLinks($data) { - $this->page->login()->open('zabbix.php?action=host.view&filter_reset=1'); - $form = $this->query('name:zbx_filter')->waitUntilPresent()->asForm()->one(); - switch ($data['name']) { - case 'Dynamic widgets H1': - case 'Host ZBX6663': - case 'Available host': - $this->selectLink($data['name'], $data['link_name'], $data['page_header']); - $this->page->waitUntilReady(); - $filter_form = $this->query('name:zbx_filter')->waitUntilPresent()->asForm()->one(); - $filter_form->checkValue(['Hosts' => $data['name']]); - $this->query('button:Reset')->one()->click(); - break; - case 'ЗАББИКС Сервер': - $this->selectLink($data['name'], $data['link_name'], $data['page_header']); - break; - case 'Empty host': - $this->page->waitUntilReady(); - $this->query('xpath://td/a[text()="'.$data['name'].'"]/following::td/a[text()="'.$data['link_name'].'"]') - ->one()->click(); - $this->page->waitUntilReady(); - $this->page->assertHeader($data['page_header']); - $form->checkValue(['Hosts' => $data['name']]); - $this->query('button:Reset')->one()->click(); - break; - } - } - - public static function getHostContextMenuData() { - return [ - [ - [ - 'name' => 'ЗАББИКС Сервер', - 'disabled' => ['Web'], - 'titles' => [ - 'Inventory', - 'Latest data', - 'Problems', - 'Graphs', - 'Dashboards', - 'Web', - 'Configuration', - 'Detect operating system', - 'Ping', - 'Script for Clone', - 'Script for Delete', - 'Script for Update', - 'Traceroute' - ] - ] - ], - [ - [ - 'name' => 'Available host', - 'disabled' => ['Web', 'Graphs', 'Dashboards'], - 'titles' => [ - 'Inventory', - 'Latest data', - 'Problems', - 'Graphs', - 'Dashboards', - 'Web', - 'Configuration', - 'Detect operating system', - 'Ping', - 'Script for Clone', - 'Script for Delete', - 'Script for Update', - 'Traceroute' - ] - ] - ], - [ - [ - 'name' => 'Dynamic widgets H1', - 'disabled' => ['Dashboards', 'Web'], - 'titles' => [ - 'Inventory', - 'Latest data', - 'Problems', - 'Graphs', - 'Dashboards', - 'Web', - 'Configuration', - 'Detect operating system', - 'Ping', - 'Script for Clone', - 'Script for Delete', - 'Script for Update', - 'Traceroute' - ] - ] - ], - [ - [ - 'name' => 'Host ZBX6663', - 'disabled' => ['Dashboards'], - 'titles' => [ - 'Inventory', - 'Latest data', - 'Problems', - 'Graphs', - 'Dashboards', - 'Web', - 'Configuration', - 'Detect operating system', - 'Ping', - 'Script for Clone', - 'Script for Delete', - 'Script for Update', - 'Traceroute' - ] - ] - ] - ]; - } - - /** - * @dataProvider getHostContextMenuData - * - * Click on host name from the table and check displayed popup context. - */ - public function testPageMonitoringHosts_HostContextMenu($data) { - $this->page->login()->open('zabbix.php?action=host.view&filter_reset=1')->waitUntilReady(); - $row = $this->query('class:list-table')->asTable()->one()->findRow('Name', $data['name']); - $row->query('link', $data['name'])->one()->click(); - $this->page->waitUntilReady(); - $popup = CPopupMenuElement::find()->waitUntilVisible()->one(); - $this->assertEquals(['HOST', 'SCRIPTS'], $popup->getTitles()->asText()); - $this->assertTrue($popup->hasItems($data['titles'])); - foreach ($data['disabled'] as $disabled) { - $this->assertTrue($popup->query('xpath://a[@aria-label="Host, '. - $disabled.'" and @class="menu-popup-item disabled"]')->one()->isPresent()); - } - } - - /** - * Check number of problems displayed on Hosts and Problems page. - */ - public function testPageMonitoringHosts_CountProblems() { - $this->page->login(); - $hosts_names = ['1_Host_to_check_Monitoring_Overview', 'ЗАББИКС Сервер', 'Host for tag permissions', 'Empty host']; - foreach ($hosts_names as $host) { - $this->page->open('zabbix.php?action=host.view&name='.$host)->waitUntilReady(); - $table = $this->query('class:list-table')->asTable()->one(); - - // Get number of problems displayed on icon and it severity level. - if ($host !== 'Empty host') { - $icons = $table->query('xpath:.//*[contains(@class, "problem-icon-list-item")]')->all(); - $results = []; - - foreach ($icons as $icon) { - $amount = $icon->getText(); - $severity = $icon->getAttribute('title'); - $results[$severity] = $amount; - } - } - else { - $this->assertEquals('Problems', $table->getRow(0)->getColumn('Problems')->getText()); - } - - // Navigate to Problems page from Hosts. - $table->getRow(0)->getColumn('Problems')->query('xpath:.//a')->one()->click(); - $this->page->waitUntilReady(); - $this->page->assertTitle('Problems'); - $this->query('name:zbx_filter')->waitUntilPresent()->asForm()->one()->checkValue(['Hosts' => $host]); - - // Count problems of each severity and compare it with problems count from Hosts page. - if ($host !== 'Empty host') { - foreach ($results as $severity => $count) { - $problem_count = $table->query('xpath:.//td[contains(@class, "-bg") and text()="'.$severity.'"]') - ->all()->count(); - $this->assertEquals(strval($problem_count), $count); - } - } - - // Check that table is empty and No data found displayed. - else { - $this->assertTableData(); - } - } - } - - public function prepareUpdateData() { - $response = CDataHelper::call('host.update', ['hostid' => '99013', 'status' => 1]); - $this->assertArrayHasKey('hostids', $response); - self::$hostid = $response['hostids'][0]; - } - - /** - * @backup hosts - * - * @onBeforeOnce prepareUpdateData - */ - public function testPageMonitoringHosts_TableSorting() { - // Sort by name and status. - $this->page->login()->open('zabbix.php?action=host.view&filter_reset=1')->waitUntilReady(); - foreach (['Name', 'Status'] as $listing) { - $query = $this->query('xpath://a[@href and text()="'.$listing.'"]'); - $query->one()->click(); - $this->page->waitUntilReady(); - $after_listing = $this->getTableResult($listing); - $query->one()->click(); - $this->page->waitUntilReady(); - $this->assertEquals(array_reverse($after_listing), $this->getTableResult($listing)); - } - } - - /** - * Clicking on link from the table and then checking page header - * - * @param string $host_name Host name - * @param string $column Column name - * @param string $page_header Page header name - */ - private function selectLink($host_name, $column, $page_header) { - $this->page->waitUntilReady(); - $this->query('class:list-table')->asTable()->one()->findRow('Name', $host_name)->query('link', $column)->one()->click(); - $this->page->waitUntilReady(); - if ($page_header !== null) { - $this->page->assertHeader($page_header); - } - if ($host_name === 'Dynamic widgets H1' && $this->query('xpath://li[@aria-labelledby="ui-id-2"'. - ' and @aria-selected="false"]')->exists()) { - $this->query('id:ui-id-2')->one()->click(); - } - if ($host_name === 'ЗАББИКС Сервер' && $column === 'Dashboards') { - $this->assertEquals('ЗАББИКС Сервер', $this->query('xpath://ul[@class="breadcrumbs"]/li[2]')->one()->getText()); - } - } - - public static function getCheckCountersData() { - return [ - [ - [ - 'host' => 'Host ZBX6663', - 'counters' => [ - [ - 'column' => 'Latest data', - 'counter' => 14 - ], - [ - 'column' => 'Problems', - 'counter' => null - ], - [ - 'column' => 'Graphs', - 'counter' => 2 - ], - [ - 'column' => 'Web', - 'counter' => 2 - ] - ] - ] - ], - [ - [ - 'host' => 'ЗАББИКС Сервер', - 'counters' => [ - [ - 'column' => 'Dashboards', - 'counter' => 4 - ], - [ - 'column' => 'Problems', - 'counter' => "1\n5" - ] - ] - ] - ] - ]; - } - - /** - * @dataProvider getCheckCountersData - */ - public function testPageMonitoringHosts_CheckCounters($data) { - $this->page->login()->open('zabbix.php?action=host.view')->waitUntilReady(); - $row = $this->query('class:list-table')->asTable()->one()->findRow('Name', $data['host']); - - foreach ($data['counters'] as $counter) { - if ($counter['column'] === 'Problems') { - $text = ($counter['counter'] === null) ? $counter['column'] : $counter['counter']; - $this->assertEquals($text, $row->getColumn($counter['column'])->getText()); - } - else { - $this->assertEquals($counter['column'].' '.$counter['counter'], - $row->getColumn($counter['column'])->getText() - ); - } - } - } -} -- cgit v1.2.3 From 966c040caff1ea674a05e12a68a3693857b3fe76 Mon Sep 17 00:00:00 2001 From: Larisa Grigorjeva Date: Fri, 1 Jul 2022 11:13:05 +0100 Subject: .......... [DEV-2073] renamed some hosts tests --- ui/tests/selenium/SeleniumTests.php | 12 +-- .../selenium/hosts/testFormHostConfiguration.php | 99 -------------------- .../hosts/testFormHostFromConfiguration.php | 99 ++++++++++++++++++++ .../selenium/hosts/testFormHostFromMonitoring.php | 101 ++++++++++++++++++++ .../selenium/hosts/testFormHostFromStandalone.php | 102 +++++++++++++++++++++ ui/tests/selenium/hosts/testFormHostMonitoring.php | 101 -------------------- ui/tests/selenium/hosts/testFormHostStandalone.php | 102 --------------------- 7 files changed, 308 insertions(+), 308 deletions(-) delete mode 100644 ui/tests/selenium/hosts/testFormHostConfiguration.php create mode 100644 ui/tests/selenium/hosts/testFormHostFromConfiguration.php create mode 100644 ui/tests/selenium/hosts/testFormHostFromMonitoring.php create mode 100644 ui/tests/selenium/hosts/testFormHostFromStandalone.php delete mode 100644 ui/tests/selenium/hosts/testFormHostMonitoring.php delete mode 100644 ui/tests/selenium/hosts/testFormHostStandalone.php diff --git a/ui/tests/selenium/SeleniumTests.php b/ui/tests/selenium/SeleniumTests.php index 974b9fcef28..6852c9d80b7 100644 --- a/ui/tests/selenium/SeleniumTests.php +++ b/ui/tests/selenium/SeleniumTests.php @@ -59,11 +59,11 @@ require_once dirname(__FILE__).'/geomaps/testFormAdministrationGeneralGeomaps.ph require_once dirname(__FILE__).'/geomaps/testGeomapWidgetScreenshots.php'; // Hosts. -require_once dirname(__FILE__).'/hosts/testFormHostConfiguration.php'; +require_once dirname(__FILE__).'/hosts/testFormHostFromConfiguration.php'; +require_once dirname(__FILE__).'/hosts/testFormHostFromMonitoring.php'; +require_once dirname(__FILE__).'/hosts/testFormHostFromStandalone.php'; require_once dirname(__FILE__).'/hosts/testFormHostLinkTemplates.php'; -require_once dirname(__FILE__).'/hosts/testFormHostMonitoring.php'; require_once dirname(__FILE__).'/hosts/testFormHostPrototype.php'; -require_once dirname(__FILE__).'/hosts/testFormHostStandalone.php'; require_once dirname(__FILE__).'/hosts/testPageHostInterfaces.php'; require_once dirname(__FILE__).'/hosts/testPageHostPrototypes.php'; require_once dirname(__FILE__).'/hosts/testPageHosts.php'; @@ -271,11 +271,11 @@ class SeleniumTests { $suite->addTestSuite('testGeomapWidgetScreenshots'); // Hosts. - $suite->addTestSuite('testFormHostConfiguration'); + $suite->addTestSuite('testFormHostFromConfiguration'); + $suite->addTestSuite('testFormHostFromMonitoring'); + $suite->addTestSuite('testFormHostFromStandalone'); $suite->addTestSuite('testFormHostLinkTemplates'); - $suite->addTestSuite('testFormHostMonitoring'); $suite->addTestSuite('testFormHostPrototype'); - $suite->addTestSuite('testFormHostStandalone'); $suite->addTestSuite('testPageHostInterfaces'); $suite->addTestSuite('testPageHostPrototypes'); $suite->addTestSuite('testPageHosts'); diff --git a/ui/tests/selenium/hosts/testFormHostConfiguration.php b/ui/tests/selenium/hosts/testFormHostConfiguration.php deleted file mode 100644 index f4a17297640..00000000000 --- a/ui/tests/selenium/hosts/testFormHostConfiguration.php +++ /dev/null @@ -1,99 +0,0 @@ -checkHostLayout(); - } - - /** - * @dataProvider getCreateData - */ - public function testFormHostConfiguration_Create($data) { - $this->checkHostCreate($data); - } - - /** - * @dataProvider getValidationUpdateData - */ - public function testFormHostConfiguration_ValidationUpdate($data) { - $this->checkHostUpdate($data); - } - - /** - * @backup hosts - * - * @dataProvider getUpdateData - */ - public function testFormHostConfiguration_Update($data) { - $this->checkHostUpdate($data); - } - - /** - * Update the host without any changes and check host and interfaces hashes. - */ - public function testFormHostConfiguration_SimpleUpdate() { - $this->checkHostSimpleUpdate(); - } - - /** - * @dataProvider getCloneData - */ - public function testFormHostConfiguration_Clone($data) { - $this->cloneHost($data); - - // Check that items aren't cloned from original host. - $this->assertItemsDBCount($data['Host name'], 0); - } - - /** - * @dataProvider getCloneData - */ - public function testFormHostConfiguration_FullClone($data) { - $this->cloneHost($data, 'Full clone'); - - // Check that items cloned from original host. - $this->assertItemsDBCount($data['Host name'], 3); - } - - /** - * @dataProvider getCancelData - */ - public function testFormHostConfiguration_Cancel($data) { - $this->checkCancel($data); - } - - /** - * @dataProvider getDeleteData - */ - public function testFormHostConfiguration_Delete($data) { - $this->checkDelete($data); - } -} diff --git a/ui/tests/selenium/hosts/testFormHostFromConfiguration.php b/ui/tests/selenium/hosts/testFormHostFromConfiguration.php new file mode 100644 index 00000000000..cca5d62244a --- /dev/null +++ b/ui/tests/selenium/hosts/testFormHostFromConfiguration.php @@ -0,0 +1,99 @@ +checkHostLayout(); + } + + /** + * @dataProvider getCreateData + */ + public function testFormHostFromConfiguration_Create($data) { + $this->checkHostCreate($data); + } + + /** + * @dataProvider getValidationUpdateData + */ + public function testFormHostFromConfiguration_ValidationUpdate($data) { + $this->checkHostUpdate($data); + } + + /** + * @backup hosts + * + * @dataProvider getUpdateData + */ + public function testFormHostFromConfiguration_Update($data) { + $this->checkHostUpdate($data); + } + + /** + * Update the host without any changes and check host and interfaces hashes. + */ + public function testFormHostFromConfiguration_SimpleUpdate() { + $this->checkHostSimpleUpdate(); + } + + /** + * @dataProvider getCloneData + */ + public function testFormHostFromConfiguration_Clone($data) { + $this->cloneHost($data); + + // Check that items aren't cloned from original host. + $this->assertItemsDBCount($data['Host name'], 0); + } + + /** + * @dataProvider getCloneData + */ + public function testFormHostFromConfiguration_FullClone($data) { + $this->cloneHost($data, 'Full clone'); + + // Check that items cloned from original host. + $this->assertItemsDBCount($data['Host name'], 3); + } + + /** + * @dataProvider getCancelData + */ + public function testFormHostFromConfiguration_Cancel($data) { + $this->checkCancel($data); + } + + /** + * @dataProvider getDeleteData + */ + public function testFormHostFromConfiguration_Delete($data) { + $this->checkDelete($data); + } +} diff --git a/ui/tests/selenium/hosts/testFormHostFromMonitoring.php b/ui/tests/selenium/hosts/testFormHostFromMonitoring.php new file mode 100644 index 00000000000..78684ce5a14 --- /dev/null +++ b/ui/tests/selenium/hosts/testFormHostFromMonitoring.php @@ -0,0 +1,101 @@ +checkHostLayout(); + } + + /** + * @dataProvider getCreateData + */ + public function testFormHostFromMonitoring_Create($data) { + $this->checkHostCreate($data); + } + + /** + * @dataProvider getValidationUpdateData + */ + public function testFormHostFromMonitoring_ValidationUpdate($data) { + $this->checkHostUpdate($data); + } + + /** + * @backup hosts + * + * @dataProvider getUpdateData + */ + public function testFormHostFromMonitoring_Update($data) { + $this->checkHostUpdate($data); + } + + /** + * Update the host without any changes and check host and interfaces hashes. + */ + public function testFormHostFromMonitoring_SimpleUpdate() { + $this->checkHostSimpleUpdate(); + } + + /** + * @dataProvider getCloneData + */ + public function testFormHostFromMonitoring_Clone($data) { + $this->cloneHost($data, 'Clone'); + + // Check that items aren't cloned from original host. + $this->assertItemsDBCount($data['Host name'], 0); + } + + /** + * @dataProvider getCloneData + */ + public function testFormHostFromMonitoring_FullClone($data) { + $this->cloneHost($data, 'Full clone'); + + // Check that items cloned from original host. + $this->assertItemsDBCount($data['Host name'], 3); + } + + /** + * @dataProvider getCancelData + */ + public function testFormHostFromMonitoring_Cancel($data) { + $this->checkCancel($data); + } + + /** + * @dataProvider getDeleteData + */ + public function testFormHostFromMonitoring_Delete($data) { + $this->checkDelete($data); + } +} + diff --git a/ui/tests/selenium/hosts/testFormHostFromStandalone.php b/ui/tests/selenium/hosts/testFormHostFromStandalone.php new file mode 100644 index 00000000000..2373cead05c --- /dev/null +++ b/ui/tests/selenium/hosts/testFormHostFromStandalone.php @@ -0,0 +1,102 @@ +checkHostLayout(); + } + + /** + * @dataProvider getCreateData + */ + public function testFormHostFromStandalone_Create($data) { + $this->link = 'zabbix.php?action=host.edit'; + $this->checkHostCreate($data); + } + + /** + * @dataProvider getValidationUpdateData + */ + public function testFormHostFromStandalone_ValidationUpdate($data) { + $this->checkHostUpdate($data); + } + + /** + * @backup hosts + * + * @dataProvider getUpdateData + */ + public function testFormHostFromStandalone_Update($data) { + $this->checkHostUpdate($data); + } + + /** + * Update the host without any changes and check host and interfaces hashes. + */ + public function testFormHostFromStandalone_SimpleUpdate() { + $this->checkHostSimpleUpdate(); + } + + /** + * @dataProvider getCloneData + */ + public function testFormHostFromStandalone_Clone($data) { + $this->cloneHost($data, 'Clone'); + + // Check that items aren't cloned from original host. + $this->assertItemsDBCount($data['Host name'], 0); + } + + /** + * @dataProvider getCloneData + */ + public function testFormHostFromStandalone_FullClone($data) { + $this->cloneHost($data, 'Full clone'); + + // Check that items cloned from original host. + $this->assertItemsDBCount($data['Host name'], 3); + } + + /** + * @dataProvider getCancelData + */ + public function testFormHostFromStandalone_Cancel($data) { + $this->link = 'zabbix.php?action=host.edit'; + $this->checkCancel($data); + } + + /** + * @dataProvider getDeleteData + */ + public function testFormHostFromStandalone_Delete($data) { + $this->checkDelete($data); + } +} diff --git a/ui/tests/selenium/hosts/testFormHostMonitoring.php b/ui/tests/selenium/hosts/testFormHostMonitoring.php deleted file mode 100644 index c0469686874..00000000000 --- a/ui/tests/selenium/hosts/testFormHostMonitoring.php +++ /dev/null @@ -1,101 +0,0 @@ -checkHostLayout(); - } - - /** - * @dataProvider getCreateData - */ - public function testFormHostMonitoring_Create($data) { - $this->checkHostCreate($data); - } - - /** - * @dataProvider getValidationUpdateData - */ - public function testFormHostMonitoring_ValidationUpdate($data) { - $this->checkHostUpdate($data); - } - - /** - * @backup hosts - * - * @dataProvider getUpdateData - */ - public function testFormHostMonitoring_Update($data) { - $this->checkHostUpdate($data); - } - - /** - * Update the host without any changes and check host and interfaces hashes. - */ - public function testFormHostMonitoring_SimpleUpdate() { - $this->checkHostSimpleUpdate(); - } - - /** - * @dataProvider getCloneData - */ - public function testFormHostMonitoring_Clone($data) { - $this->cloneHost($data, 'Clone'); - - // Check that items aren't cloned from original host. - $this->assertItemsDBCount($data['Host name'], 0); - } - - /** - * @dataProvider getCloneData - */ - public function testFormHostMonitoring_FullClone($data) { - $this->cloneHost($data, 'Full clone'); - - // Check that items cloned from original host. - $this->assertItemsDBCount($data['Host name'], 3); - } - - /** - * @dataProvider getCancelData - */ - public function testFormHostMonitoring_Cancel($data) { - $this->checkCancel($data); - } - - /** - * @dataProvider getDeleteData - */ - public function testFormHostMonitoring_Delete($data) { - $this->checkDelete($data); - } -} - diff --git a/ui/tests/selenium/hosts/testFormHostStandalone.php b/ui/tests/selenium/hosts/testFormHostStandalone.php deleted file mode 100644 index 202e69dbae3..00000000000 --- a/ui/tests/selenium/hosts/testFormHostStandalone.php +++ /dev/null @@ -1,102 +0,0 @@ -checkHostLayout(); - } - - /** - * @dataProvider getCreateData - */ - public function testFormHostStandalone_Create($data) { - $this->link = 'zabbix.php?action=host.edit'; - $this->checkHostCreate($data); - } - - /** - * @dataProvider getValidationUpdateData - */ - public function testFormHostStandalone_ValidationUpdate($data) { - $this->checkHostUpdate($data); - } - - /** - * @backup hosts - * - * @dataProvider getUpdateData - */ - public function testFormHostStandalone_Update($data) { - $this->checkHostUpdate($data); - } - - /** - * Update the host without any changes and check host and interfaces hashes. - */ - public function testFormHostStandalone_SimpleUpdate() { - $this->checkHostSimpleUpdate(); - } - - /** - * @dataProvider getCloneData - */ - public function testFormHostStandalone_Clone($data) { - $this->cloneHost($data, 'Clone'); - - // Check that items aren't cloned from original host. - $this->assertItemsDBCount($data['Host name'], 0); - } - - /** - * @dataProvider getCloneData - */ - public function testFormHostStandalone_FullClone($data) { - $this->cloneHost($data, 'Full clone'); - - // Check that items cloned from original host. - $this->assertItemsDBCount($data['Host name'], 3); - } - - /** - * @dataProvider getCancelData - */ - public function testFormHostStandalone_Cancel($data) { - $this->link = 'zabbix.php?action=host.edit'; - $this->checkCancel($data); - } - - /** - * @dataProvider getDeleteData - */ - public function testFormHostStandalone_Delete($data) { - $this->checkDelete($data); - } -} -- cgit v1.2.3 From 494e2af5ef27725a8fca71031193a2c11f0c39a3 Mon Sep 17 00:00:00 2001 From: Larisa Grigorjeva Date: Fri, 1 Jul 2022 11:20:37 +0100 Subject: .......... [DEV-2073] reorganized tests vol. 5 --- ui/tests/selenium/SeleniumTests.php | 53 ++++++++++++++++++++----------------- 1 file changed, 29 insertions(+), 24 deletions(-) diff --git a/ui/tests/selenium/SeleniumTests.php b/ui/tests/selenium/SeleniumTests.php index 6852c9d80b7..5556e622b28 100644 --- a/ui/tests/selenium/SeleniumTests.php +++ b/ui/tests/selenium/SeleniumTests.php @@ -69,6 +69,20 @@ require_once dirname(__FILE__).'/hosts/testPageHostPrototypes.php'; require_once dirname(__FILE__).'/hosts/testPageHosts.php'; require_once dirname(__FILE__).'/hosts/testPageMonitoringHosts.php'; +// Items. +require_once dirname(__FILE__).'/items/testFormItem.php'; +require_once dirname(__FILE__).'/items/testFormItemHttpAgent.php'; +require_once dirname(__FILE__).'/items/testFormItemPrototype.php'; +require_once dirname(__FILE__).'/items/testFormTestItem.php'; +require_once dirname(__FILE__).'/items/testFormTestItemPrototype.php'; +require_once dirname(__FILE__).'/items/testFormulaCalculatedItem.php'; +require_once dirname(__FILE__).'/items/testFormulaCalculatedItemPrototype.php'; +require_once dirname(__FILE__).'/items/testInheritanceItem.php'; +require_once dirname(__FILE__).'/items/testInheritanceItemPrototype.php'; +require_once dirname(__FILE__).'/items/testItemTypeSelection.php'; +require_once dirname(__FILE__).'/items/testPageItemPrototypes.php'; +require_once dirname(__FILE__).'/items/testPageItems.php'; + require_once dirname(__FILE__).'/testExecuteNow.php'; require_once dirname(__FILE__).'/testGraphAxis.php'; @@ -89,8 +103,6 @@ require_once dirname(__FILE__).'/testPageGraphPrototypes.php'; require_once dirname(__FILE__).'/testPageHistory.php'; require_once dirname(__FILE__).'/testPageHostGraph.php'; require_once dirname(__FILE__).'/testPageInventory.php'; -require_once dirname(__FILE__).'/items/testPageItems.php'; -require_once dirname(__FILE__).'/items/testPageItemPrototypes.php'; require_once dirname(__FILE__).'/testPageTriggers.php'; require_once dirname(__FILE__).'/testPageTriggerUrl.php'; require_once dirname(__FILE__).'/testPageTriggerPrototypes.php'; @@ -137,11 +149,6 @@ require_once dirname(__FILE__).'/filterTabs/testFormFilterProblems.php'; require_once dirname(__FILE__).'/testFormGraph.php'; require_once dirname(__FILE__).'/testFormGraphPrototype.php'; require_once dirname(__FILE__).'/testFormHostGroup.php'; -require_once dirname(__FILE__).'/items/testFormItem.php'; -require_once dirname(__FILE__).'/items/testFormItemHttpAgent.php'; -require_once dirname(__FILE__).'/items/testFormItemPrototype.php'; -require_once dirname(__FILE__).'/items/testFormTestItem.php'; -require_once dirname(__FILE__).'/items/testFormTestItemPrototype.php'; require_once dirname(__FILE__).'/lld/testFormTestLowLevelDiscovery.php'; require_once dirname(__FILE__).'/testFormLogin.php'; require_once dirname(__FILE__).'/lld/testFormLowLevelDiscovery.php'; @@ -187,16 +194,11 @@ require_once dirname(__FILE__).'/testFormValueMappingsTemplate.php'; require_once dirname(__FILE__).'/roles/testFormUserRoles.php'; require_once dirname(__FILE__).'/testFormWeb.php'; require_once dirname(__FILE__).'/testFormWebStep.php'; -require_once dirname(__FILE__).'/items/testFormulaCalculatedItem.php'; -require_once dirname(__FILE__).'/items/testFormulaCalculatedItemPrototype.php'; require_once dirname(__FILE__).'/testPageBrowserWarning.php'; -require_once dirname(__FILE__).'/items/testInheritanceItem.php'; require_once dirname(__FILE__).'/testInheritanceTrigger.php'; require_once dirname(__FILE__).'/testInheritanceGraph.php'; require_once dirname(__FILE__).'/testInheritanceWeb.php'; require_once dirname(__FILE__).'/lld/testInheritanceDiscoveryRule.php'; -require_once dirname(__FILE__).'/items/testInheritanceItemPrototype.php'; -require_once dirname(__FILE__).'/items/testItemTypeSelection.php'; require_once dirname(__FILE__).'/testInheritanceTriggerPrototype.php'; require_once dirname(__FILE__).'/testInheritanceGraphPrototype.php'; require_once dirname(__FILE__).'/testInheritanceHostPrototype.php'; @@ -281,6 +283,21 @@ class SeleniumTests { $suite->addTestSuite('testPageHosts'); $suite->addTestSuite('testPageMonitoringHosts'); + // Items. + $suite->addTestSuite('testFormItem'); + $suite->addTestSuite('testFormItemHttpAgent'); + $suite->addTestSuite('testFormItemPrototype'); + $suite->addTestSuite('testFormTestItem'); + $suite->addTestSuite('testFormTestItemPrototype'); + $suite->addTestSuite('testFormulaCalculatedItem'); + $suite->addTestSuite('testFormulaCalculatedItemPrototype'); + $suite->addTestSuite('testInheritanceItem'); + $suite->addTestSuite('testInheritanceItemPrototype'); + $suite->addTestSuite('testItemTypeSelection'); + $suite->addTestSuite('testPageItemPrototypes'); + $suite->addTestSuite('testPageItems'); + + $suite->addTestSuite('testExecuteNow'); $suite->addTestSuite('testGraphAxis'); @@ -298,8 +315,6 @@ class SeleniumTests { $suite->addTestSuite('testPageHistory'); $suite->addTestSuite('testPageHostGraph'); $suite->addTestSuite('testPageInventory'); - $suite->addTestSuite('testPageItems'); - $suite->addTestSuite('testPageItemPrototypes'); $suite->addTestSuite('testPageTriggers'); $suite->addTestSuite('testPageTriggerDescription'); $suite->addTestSuite('testPageTriggerUrl'); @@ -352,11 +367,6 @@ class SeleniumTests { $suite->addTestSuite('testFormGraph'); $suite->addTestSuite('testFormGraphPrototype'); $suite->addTestSuite('testFormHostGroup'); - $suite->addTestSuite('testFormItem'); - $suite->addTestSuite('testFormItemHttpAgent'); - $suite->addTestSuite('testFormItemPrototype'); - $suite->addTestSuite('testFormTestItem'); - $suite->addTestSuite('testFormTestItemPrototype'); $suite->addTestSuite('testFormTestLowLevelDiscovery'); $suite->addTestSuite('testFormLogin'); $suite->addTestSuite('testFormLowLevelDiscovery'); @@ -400,18 +410,13 @@ class SeleniumTests { $suite->addTestSuite('testFormUserRoles'); $suite->addTestSuite('testFormWeb'); $suite->addTestSuite('testFormWebStep'); - $suite->addTestSuite('testFormulaCalculatedItem'); - $suite->addTestSuite('testFormulaCalculatedItemPrototype'); $suite->addTestSuite('testPageBrowserWarning'); - $suite->addTestSuite('testInheritanceItem'); $suite->addTestSuite('testInheritanceTrigger'); $suite->addTestSuite('testInheritanceGraph'); $suite->addTestSuite('testInheritanceGraphPrototype'); $suite->addTestSuite('testInheritanceWeb'); $suite->addTestSuite('testInheritanceDiscoveryRule'); $suite->addTestSuite('testInheritanceHostPrototype'); - $suite->addTestSuite('testInheritanceItemPrototype'); - $suite->addTestSuite('testItemTypeSelection'); $suite->addTestSuite('testInheritanceTriggerPrototype'); $suite->addTestSuite('testLanguage'); $suite->addTestSuite('testMultiselect'); -- cgit v1.2.3 From cdc20813693c8ee956821eb46a0f192847497497 Mon Sep 17 00:00:00 2001 From: Larisa Grigorjeva Date: Mon, 4 Jul 2022 20:59:01 +0100 Subject: .......... [DEV-2073] reorganized tests vol. 6 --- ui/tests/selenium/SeleniumTests.php | 23 +++++++++++++---------- 1 file changed, 13 insertions(+), 10 deletions(-) diff --git a/ui/tests/selenium/SeleniumTests.php b/ui/tests/selenium/SeleniumTests.php index 5556e622b28..4b8b5f73177 100644 --- a/ui/tests/selenium/SeleniumTests.php +++ b/ui/tests/selenium/SeleniumTests.php @@ -83,6 +83,12 @@ require_once dirname(__FILE__).'/items/testItemTypeSelection.php'; require_once dirname(__FILE__).'/items/testPageItemPrototypes.php'; require_once dirname(__FILE__).'/items/testPageItems.php'; +// LLD. +require_once dirname(__FILE__).'/lld/testFormLowLevelDiscovery.php'; +require_once dirname(__FILE__).'/lld/testFormLowLevelDiscoveryOverrides.php'; +require_once dirname(__FILE__).'/lld/testFormTestLowLevelDiscovery.php'; +require_once dirname(__FILE__).'/lld/testInheritanceDiscoveryRule.php'; +require_once dirname(__FILE__).'/lld/testPageLowLevelDiscovery.php'; require_once dirname(__FILE__).'/testExecuteNow.php'; require_once dirname(__FILE__).'/testGraphAxis.php'; @@ -111,7 +117,6 @@ require_once dirname(__FILE__).'/testPageMaps.php'; require_once dirname(__FILE__).'/testPageMassUpdateItems.php'; require_once dirname(__FILE__).'/testPageMassUpdateItemPrototypes.php'; require_once dirname(__FILE__).'/testPageNetworkDiscovery.php'; -require_once dirname(__FILE__).'/lld/testPageLowLevelDiscovery.php'; require_once dirname(__FILE__).'/testPasswordComplexity.php'; /* require_once dirname(__FILE__).'/testPageQueueDetails.php'; @@ -149,10 +154,7 @@ require_once dirname(__FILE__).'/filterTabs/testFormFilterProblems.php'; require_once dirname(__FILE__).'/testFormGraph.php'; require_once dirname(__FILE__).'/testFormGraphPrototype.php'; require_once dirname(__FILE__).'/testFormHostGroup.php'; -require_once dirname(__FILE__).'/lld/testFormTestLowLevelDiscovery.php'; require_once dirname(__FILE__).'/testFormLogin.php'; -require_once dirname(__FILE__).'/lld/testFormLowLevelDiscovery.php'; -require_once dirname(__FILE__).'/lld/testFormLowLevelDiscoveryOverrides.php'; require_once dirname(__FILE__).'/macros/testFormMacrosAdministrationGeneral.php'; require_once dirname(__FILE__).'/macros/testFormMacrosHost.php'; require_once dirname(__FILE__).'/macros/testFormMacrosHostPrototype.php'; @@ -198,7 +200,6 @@ require_once dirname(__FILE__).'/testPageBrowserWarning.php'; require_once dirname(__FILE__).'/testInheritanceTrigger.php'; require_once dirname(__FILE__).'/testInheritanceGraph.php'; require_once dirname(__FILE__).'/testInheritanceWeb.php'; -require_once dirname(__FILE__).'/lld/testInheritanceDiscoveryRule.php'; require_once dirname(__FILE__).'/testInheritanceTriggerPrototype.php'; require_once dirname(__FILE__).'/testInheritanceGraphPrototype.php'; require_once dirname(__FILE__).'/testInheritanceHostPrototype.php'; @@ -297,6 +298,13 @@ class SeleniumTests { $suite->addTestSuite('testPageItemPrototypes'); $suite->addTestSuite('testPageItems'); + // LLD. + $suite->addTestSuite('testFormLowLevelDiscovery'); + $suite->addTestSuite('testFormLowLevelDiscoveryOverrides'); + $suite->addTestSuite('testFormTestLowLevelDiscovery'); + $suite->addTestSuite('testInheritanceDiscoveryRule'); + $suite->addTestSuite('testPageLowLevelDiscovery'); + $suite->addTestSuite('testExecuteNow'); $suite->addTestSuite('testGraphAxis'); @@ -320,7 +328,6 @@ class SeleniumTests { $suite->addTestSuite('testPageTriggerUrl'); $suite->addTestSuite('testPageTriggerPrototypes'); $suite->addTestSuite('testPageLatestData'); - $suite->addTestSuite('testPageLowLevelDiscovery'); $suite->addTestSuite('testPageMaintenance'); $suite->addTestSuite('testPageMaps'); $suite->addTestSuite('testPageMassUpdateItems'); @@ -367,10 +374,7 @@ class SeleniumTests { $suite->addTestSuite('testFormGraph'); $suite->addTestSuite('testFormGraphPrototype'); $suite->addTestSuite('testFormHostGroup'); - $suite->addTestSuite('testFormTestLowLevelDiscovery'); $suite->addTestSuite('testFormLogin'); - $suite->addTestSuite('testFormLowLevelDiscovery'); - $suite->addTestSuite('testFormLowLevelDiscoveryOverrides'); $suite->addTestSuite('testFormMacrosAdministrationGeneral'); $suite->addTestSuite('testFormMacrosHost'); $suite->addTestSuite('testFormMacrosHostPrototype'); @@ -415,7 +419,6 @@ class SeleniumTests { $suite->addTestSuite('testInheritanceGraph'); $suite->addTestSuite('testInheritanceGraphPrototype'); $suite->addTestSuite('testInheritanceWeb'); - $suite->addTestSuite('testInheritanceDiscoveryRule'); $suite->addTestSuite('testInheritanceHostPrototype'); $suite->addTestSuite('testInheritanceTriggerPrototype'); $suite->addTestSuite('testLanguage'); -- cgit v1.2.3 From c5a38d4abd235e7c70404e4dcac28a15a3c41224 Mon Sep 17 00:00:00 2001 From: Larisa Grigorjeva Date: Tue, 5 Jul 2022 09:11:40 +0100 Subject: .......... [DEV-2073] fixed data deletion in top hpsts --- ui/tests/selenium/dashboard/testDashboardTopHostsWidget.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/ui/tests/selenium/dashboard/testDashboardTopHostsWidget.php b/ui/tests/selenium/dashboard/testDashboardTopHostsWidget.php index 0e77d7b9ee1..d5564d24a91 100644 --- a/ui/tests/selenium/dashboard/testDashboardTopHostsWidget.php +++ b/ui/tests/selenium/dashboard/testDashboardTopHostsWidget.php @@ -25,7 +25,7 @@ require_once dirname(__FILE__).'/../../include/helpers/CDataHelper.php'; /** * @dataSource TopHostsWidget * - * @backup widget, profiles, items + * @backup widget, profiles * * @onAfter clearData */ @@ -2146,7 +2146,7 @@ class testDashboardTopHostsWidget extends CWebTest { $dashboardids = CDBHelper::getColumn("SELECT * from dashboard where name LIKE 'top_host_%'", 'dashboardid'); CDataHelper::call('dashboard.delete', $dashboardids); - $itemids = CDBHelper::getColumn("SELECT * from items where name LIKE 'top_host_trap%'", 'itemid'); - CDataHelper::call('dashboard.delete', $dashboardids); + $itemids = CDBHelper::getColumn("SELECT * from items where name LIKE 'top_hosts_trap%'", 'itemid'); + CDataHelper::call('item.delete', $itemids); } } -- cgit v1.2.3 From c6f70d795a886fcea5de4c296edef9e12e474d01 Mon Sep 17 00:00:00 2001 From: Larisa Grigorjeva Date: Tue, 5 Jul 2022 09:49:00 +0100 Subject: .......... [DEV-2073] reorganized tests vol.7 --- ui/tests/selenium/SeleniumTests.php | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/ui/tests/selenium/SeleniumTests.php b/ui/tests/selenium/SeleniumTests.php index 4b8b5f73177..4c3b674704d 100644 --- a/ui/tests/selenium/SeleniumTests.php +++ b/ui/tests/selenium/SeleniumTests.php @@ -90,6 +90,12 @@ require_once dirname(__FILE__).'/lld/testFormTestLowLevelDiscovery.php'; require_once dirname(__FILE__).'/lld/testInheritanceDiscoveryRule.php'; require_once dirname(__FILE__).'/lld/testPageLowLevelDiscovery.php'; +// Macros. +require_once dirname(__FILE__).'/macros/testFormMacrosAdministrationGeneral.php'; +require_once dirname(__FILE__).'/macros/testFormMacrosHost.php'; +require_once dirname(__FILE__).'/macros/testFormMacrosHostPrototype.php'; +require_once dirname(__FILE__).'/macros/testFormMacrosTemplate.php'; + require_once dirname(__FILE__).'/testExecuteNow.php'; require_once dirname(__FILE__).'/testGraphAxis.php'; @@ -155,10 +161,6 @@ require_once dirname(__FILE__).'/testFormGraph.php'; require_once dirname(__FILE__).'/testFormGraphPrototype.php'; require_once dirname(__FILE__).'/testFormHostGroup.php'; require_once dirname(__FILE__).'/testFormLogin.php'; -require_once dirname(__FILE__).'/macros/testFormMacrosAdministrationGeneral.php'; -require_once dirname(__FILE__).'/macros/testFormMacrosHost.php'; -require_once dirname(__FILE__).'/macros/testFormMacrosHostPrototype.php'; -require_once dirname(__FILE__).'/macros/testFormMacrosTemplate.php'; require_once dirname(__FILE__).'/testFormMaintenance.php'; require_once dirname(__FILE__).'/testFormMap.php'; require_once dirname(__FILE__).'/testFormNetworkDiscovery.php'; @@ -305,6 +307,12 @@ class SeleniumTests { $suite->addTestSuite('testInheritanceDiscoveryRule'); $suite->addTestSuite('testPageLowLevelDiscovery'); + // Macros. + $suite->addTestSuite('testFormMacrosAdministrationGeneral'); + $suite->addTestSuite('testFormMacrosHost'); + $suite->addTestSuite('testFormMacrosHostPrototype'); + $suite->addTestSuite('testFormMacrosTemplate'); + $suite->addTestSuite('testExecuteNow'); $suite->addTestSuite('testGraphAxis'); @@ -375,10 +383,6 @@ class SeleniumTests { $suite->addTestSuite('testFormGraphPrototype'); $suite->addTestSuite('testFormHostGroup'); $suite->addTestSuite('testFormLogin'); - $suite->addTestSuite('testFormMacrosAdministrationGeneral'); - $suite->addTestSuite('testFormMacrosHost'); - $suite->addTestSuite('testFormMacrosHostPrototype'); - $suite->addTestSuite('testFormMacrosTemplate'); $suite->addTestSuite('testFormMaintenance'); $suite->addTestSuite('testFormMap'); $suite->addTestSuite('testFormServicesServices'); -- cgit v1.2.3 From ce35b981aabfb6e317dacb8f4313f83d64c9cc41 Mon Sep 17 00:00:00 2001 From: Alexander Shubin Date: Wed, 27 Jul 2022 16:11:08 +0300 Subject: ..F....... [ZBXNEXT-7469] removed unused code --- ui/tr_events.php | 12 +----------- 1 file changed, 1 insertion(+), 11 deletions(-) diff --git a/ui/tr_events.php b/ui/tr_events.php index d088c17f210..cbdeaf635e6 100644 --- a/ui/tr_events.php +++ b/ui/tr_events.php @@ -37,20 +37,10 @@ require_once dirname(__FILE__).'/include/page_header.php'; // VAR TYPE OPTIONAL FLAGS VALIDATION EXCEPTION $fields = [ 'triggerid' => [T_ZBX_INT, O_OPT, P_SYS, DB_ID, PAGE_TYPE_HTML.'=='.$page['type']], - 'eventid' => [T_ZBX_INT, O_OPT, P_SYS, DB_ID, PAGE_TYPE_HTML.'=='.$page['type']], - // Ajax - 'widget' => [T_ZBX_STR, O_OPT, P_ACT, IN('"'.WIDGET_HAT_EVENTACTIONS.'","'.WIDGET_HAT_EVENTLIST.'"'), null], - 'state' => [T_ZBX_INT, O_OPT, P_ACT, IN('0,1'), null] + 'eventid' => [T_ZBX_INT, O_OPT, P_SYS, DB_ID, PAGE_TYPE_HTML.'=='.$page['type']] ]; check_fields($fields); -/* - * Ajax - */ -if (hasRequest('widget') && hasRequest('state')) { - CProfile::update('web.tr_events.hats.'.getRequest('widget').'.state', getRequest('state'), PROFILE_TYPE_INT); -} - if ($page['type'] == PAGE_TYPE_JS || $page['type'] == PAGE_TYPE_HTML_BLOCK) { require_once dirname(__FILE__).'/include/page_footer.php'; exit; -- cgit v1.2.3 From 1f73f4701077d702f6f898202841af6b7121e4ca Mon Sep 17 00:00:00 2001 From: Alexander Shubin Date: Fri, 29 Jul 2022 13:42:53 +0300 Subject: ..F....... [ZBXNEXT-7469] refactored html helpers CUiWidget, CCollapsibleUiWidget to CSection, CSectionCollapsible --- .../sass/components/_columns-wrapper.scss | 79 ++++++++++ sass/stylesheets/sass/components/_section.scss | 72 +++++++++ .../sass/components/dashboard/_dashboard.scss | 4 - sass/stylesheets/sass/hc-dark.scss | 28 +++- sass/stylesheets/sass/hc-light.scss | 24 ++- sass/stylesheets/sass/screen.scss | 71 +-------- ui/app/controllers/CControllerProfileUpdate.php | 10 +- ui/app/views/search.php | 56 ++++--- ui/assets/styles/blue-theme.css | 168 ++++++++++++-------- ui/assets/styles/dark-theme.css | 168 ++++++++++++-------- ui/assets/styles/hc-dark.css | 173 +++++++++++++-------- ui/assets/styles/hc-light.css | 173 +++++++++++++-------- ui/include/classes/html/CCollapsibleUiWidget.php | 103 ------------ ui/include/classes/html/CSection.php | 70 +++++++++ ui/include/classes/html/CSectionCollapsible.php | 59 +++++++ ui/include/classes/html/CUiWidget.php | 136 ---------------- ui/include/defines.inc.php | 22 +-- ui/js/main.js | 32 ++-- ui/tr_events.php | 30 ++-- 19 files changed, 835 insertions(+), 643 deletions(-) create mode 100644 sass/stylesheets/sass/components/_columns-wrapper.scss create mode 100644 sass/stylesheets/sass/components/_section.scss delete mode 100644 ui/include/classes/html/CCollapsibleUiWidget.php create mode 100644 ui/include/classes/html/CSection.php create mode 100755 ui/include/classes/html/CSectionCollapsible.php delete mode 100644 ui/include/classes/html/CUiWidget.php diff --git a/sass/stylesheets/sass/components/_columns-wrapper.scss b/sass/stylesheets/sass/components/_columns-wrapper.scss new file mode 100644 index 00000000000..3f10c77bf29 --- /dev/null +++ b/sass/stylesheets/sass/components/_columns-wrapper.scss @@ -0,0 +1,79 @@ +.columns-wrapper { + $column-count: (2, 3); + $column-size: ( + 5: 5%, + 10: 10%, + 15: 15%, + 20: 20%, + 33: 33.33333%, + 35: 35%, + 40: 40%, + 50: 50%, + 75: 75%, + 90: 90%, + 95: 95% + ); + + display: flex; + flex-wrap: wrap; + align-items: start; + + &.columns-nowrap { + flex-wrap: nowrap; + } + + // Dynamically generated classes for the columns count: + // .columns-2 + // .columns-3 + @each $count in $column-count { + &.columns-#{$count} > { + div, + li { + display: block; + flex: 0 0 (100% / $count); + max-width: (100% / $count); + } + } + } + + // Dynamically generated classes for the column width: + // .column-5 + // .column-10 + // .column-15 + // .column-20 + // .column-33 + // .column-35 + // .column-40 + // .column-50 + // .column-75 + // .column-90 + // .column-95 + @each $class, $width in $column-size { + .column-#{$class} { + flex: 0 0 $width; + max-width: $width; + } + } + + .column-center { + display: flex; + justify-content: center; + text-align: center; + } + + .column-middle { + display: flex; + align-items: center; + } + + & > { + div, + ul { + &:not(:last-child) { + section { + margin-right: 10px; + } + } + } + } +} diff --git a/sass/stylesheets/sass/components/_section.scss b/sass/stylesheets/sass/components/_section.scss new file mode 100644 index 00000000000..e0c21a3aaf2 --- /dev/null +++ b/sass/stylesheets/sass/components/_section.scss @@ -0,0 +1,72 @@ +section { + background-color: $ui-bg-color; + border: 1px solid $ui-border-color; + + .section-head { + display: flex; + height: 32px; + line-height: 32px; + + h4 { + padding: 0 10px; + margin-right: auto; + overflow: hidden; + text-overflow: ellipsis; + font-weight: bold; + line-height: inherit; + color: lighten($font-color, 15%); + } + } + + .section-toggle { + @extend %btn-widget-defaults; + + width: 24px; + height: 24px; + margin: 2px 2px 0 auto; + background: url($sprite-path) no-repeat -6px -654px; + } + + .section-foot { + padding: 0 10px; + text-align: right; + line-height: 32px; + color: $font-alt-color; + } + + &.section-collapsed { + .section-body, + .section-foot { + display: none; + } + + .section-toggle { + background-position: -6px -689px; + } + } + + &:not(:last-child) { + margin-bottom: 10px; + } + + .list-table { + border: 0; + + tbody tr:last-child { + td { + border-bottom: 1px solid $table-border-color; + } + } + + td, + th { + &:first-child { + padding-left: 10px; + } + + &:last-child { + padding-right: 10px; + } + } + } +} diff --git a/sass/stylesheets/sass/components/dashboard/_dashboard.scss b/sass/stylesheets/sass/components/dashboard/_dashboard.scss index 4906bf7bbbf..f08c7efd840 100644 --- a/sass/stylesheets/sass/components/dashboard/_dashboard.scss +++ b/sass/stylesheets/sass/components/dashboard/_dashboard.scss @@ -978,10 +978,6 @@ .msg-warning { margin: 0 10px; } - - &.dashboard-widget-fluid { - margin-right: 0; - } } %dashboard-widget-td { diff --git a/sass/stylesheets/sass/hc-dark.scss b/sass/stylesheets/sass/hc-dark.scss index 8eeabd4c3bf..e4ca649315a 100644 --- a/sass/stylesheets/sass/hc-dark.scss +++ b/sass/stylesheets/sass/hc-dark.scss @@ -1201,6 +1201,7 @@ td.inactive-bg { } // Multiline input control. + .multilineinput-control { button { &::after { @@ -1226,6 +1227,7 @@ td.inactive-bg { } // Time selection. + .ui-tabs-nav { .btn-info { &::after { @@ -1476,6 +1478,7 @@ td.inactive-bg { } // Overrides. + .overrides-options-list { > li > div { border: 1px solid $ui-tab-bg-selected-color; @@ -1506,6 +1509,7 @@ td.inactive-bg { } // Widget "Host availability". + .host-avail-widget { td:not(:first-child) { border-left: 1px solid $ui-border-color; @@ -1519,7 +1523,8 @@ td.inactive-bg { } } -// Widget "Navigation tree" +// Widget "Navigation tree". + .navtree { .tree .tree-item > .tree-row { min-width: 410px; @@ -1527,6 +1532,7 @@ td.inactive-bg { } // Widget "Problems by severity". + .by-severity-widget { > div { min-width: 65px; @@ -1539,13 +1545,13 @@ td.inactive-bg { } } -// InputSecret and ButtonDropdown +// InputSecret and ButtonDropdown. .btn-undo.is-focused { box-shadow: 0 1px 0px $blue, 0 -1px 0px $blue; } -// Tabfilter +// Tabfilter. .filter-container.tabfilter-container { .icon-filter::before { @@ -1569,7 +1575,7 @@ td.inactive-bg { } } -// HOST INTERFACES +// Host interfaces. .interfaces { .interface-row { @@ -1586,3 +1592,17 @@ td.inactive-bg { } } } + +// Section (components/_section.scss). + +section { + .section-toggle { + background-position: -318px -654px; + } + + &.section-collapsed { + .section-toggle { + background-position: -318px -690px; + } + } +} diff --git a/sass/stylesheets/sass/hc-light.scss b/sass/stylesheets/sass/hc-light.scss index fb07e8bb819..39c2e7c2a97 100644 --- a/sass/stylesheets/sass/hc-light.scss +++ b/sass/stylesheets/sass/hc-light.scss @@ -1310,6 +1310,7 @@ td.inactive-bg { } // Overrides. + .overrides-options-list { > li > div { background-color: $ui-bg-selected-color !important; @@ -1339,6 +1340,7 @@ td.inactive-bg { } // Widget "Host availability". + .host-avail-widget { td:not(:first-child) { border-left: 1px solid $ui-border-color; @@ -1352,7 +1354,8 @@ td.inactive-bg { } } -// Widget "Navigation tree" +// Widget "Navigation tree". + .navtree { .tree .tree-item > .tree-row { min-width: 410px; @@ -1360,6 +1363,7 @@ td.inactive-bg { } // Widget "Problems by severity". + .by-severity-widget { > div { min-width: 65px; @@ -1372,7 +1376,7 @@ td.inactive-bg { } } -// InputSecret and ButtonDropdown +// InputSecret and ButtonDropdown. .btn-undo.is-focused { box-shadow: 0 1px 0px $blue, 0 -1px 0px $blue; @@ -1398,7 +1402,7 @@ td.inactive-bg { } } -// HOST INTERFACES +// Host interfaces. .interfaces { .interface-row { @@ -1415,3 +1419,17 @@ td.inactive-bg { } } } + +// Section (components/_section.scss). + +section { + .section-toggle { + background-position: -165px -654px; + } + + &.section-collapsed { + .section-toggle { + background-position: -165px -690px; + } + } +} diff --git a/sass/stylesheets/sass/screen.scss b/sass/stylesheets/sass/screen.scss index 719c4405646..65f33f1c4d8 100644 --- a/sass/stylesheets/sass/screen.scss +++ b/sass/stylesheets/sass/screen.scss @@ -30,6 +30,7 @@ $browser-sprite-path: '../img/browser-sprite.png?20220519'; @import "components/buttons"; @import "components/color-picker"; +@import "components/columns-wrapper"; @import "components/dashboard/dashboard"; @import "components/dashboard/widget-clock"; @import "components/dashboard/widget-item"; @@ -45,6 +46,7 @@ $browser-sprite-path: '../img/browser-sprite.png?20220519'; @import "components/message-box"; @import "components/radio-list-control"; @import "components/range-control"; +@import "components/section"; @import "components/service/info"; @import "components/subfilter"; @import "components/svg-graph"; @@ -4871,75 +4873,6 @@ svg { } } -.columns-wrapper { - $column-count: (2, 3); - $column-size: ( - 5: 5%, - 10: 10%, - 15: 15%, - 20: 20%, - 33: 33.33333%, - 35: 35%, - 40: 40%, - 50: 50%, - 75: 75%, - 90: 90%, - 95: 95% - ); - - display: flex; - flex-wrap: wrap; - align-items: start; - - &.columns-nowrap { - flex-wrap: nowrap; - } - - // Dynamically generated classes for the columns count: - // .columns-2 - // .columns-3 - @each $count in $column-count { - &.columns-#{$count} > { - div, - li { - display: block; - flex: 0 0 (100% / $count); - max-width: (100% / $count); - } - } - } - - // Dynamically generated classes for the column width: - // .column-5 - // .column-10 - // .column-15 - // .column-20 - // .column-33 - // .column-35 - // .column-40 - // .column-50 - // .column-75 - // .column-90 - // .column-95 - @each $class, $width in $column-size { - .column-#{$class} { - flex: 0 0 $width; - max-width: $width; - } - } - - .column-center { - display: flex; - justify-content: center; - text-align: center; - } - - .column-middle { - display: flex; - align-items: center; - } -} - .preprocessing-list { $name-width: 295px; $on-fail-width: 100px; diff --git a/ui/app/controllers/CControllerProfileUpdate.php b/ui/app/controllers/CControllerProfileUpdate.php index aedc4491e8d..1ff1c7b6d2f 100644 --- a/ui/app/controllers/CControllerProfileUpdate.php +++ b/ui/app/controllers/CControllerProfileUpdate.php @@ -63,9 +63,9 @@ class CControllerProfileUpdate extends CController { case 'web.proxies.filter.active': case 'web.scheduledreport.filter.active': case 'web.scripts.filter.active': - case 'web.search.hats.'.WIDGET_SEARCH_HOSTS.'.state': - case 'web.search.hats.'.WIDGET_SEARCH_TEMPLATES.'.state': - case 'web.search.hats.'.WIDGET_SEARCH_HOSTGROUP.'.state': + case 'web.search.hats.'.SECTION_SEARCH_HOSTS.'.state': + case 'web.search.hats.'.SECTION_SEARCH_TEMPLATES.'.state': + case 'web.search.hats.'.SECTION_SEARCH_HOSTGROUP.'.state': case 'web.service.filter.active': case 'web.service_actions.filter.active': case 'web.sidebar.mode': @@ -81,8 +81,8 @@ class CControllerProfileUpdate extends CController { case 'web.templates.triggers.filter.active': case 'web.token.filter.active': case 'web.toptriggers.filter.active': - case 'web.tr_events.hats.'.WIDGET_HAT_EVENTACTIONS.'.state': - case 'web.tr_events.hats.'.WIDGET_HAT_EVENTLIST.'.state': + case 'web.tr_events.hats.'.SECTION_HAT_EVENTACTIONS.'.state': + case 'web.tr_events.hats.'.SECTION_HAT_EVENTLIST.'.state': case 'web.user.filter.active': case 'web.user.token.filter.active': case 'web.usergroup.filter.active': diff --git a/ui/app/views/search.php b/ui/app/views/search.php index c69680f1514..e7a8bf962fb 100644 --- a/ui/app/views/search.php +++ b/ui/app/views/search.php @@ -26,7 +26,7 @@ $this->includeJsFile('search.js.php'); -$widgets = []; +$sections = []; $table = (new CTableInfo()) ->setHeader((new CRowHeader()) @@ -179,13 +179,12 @@ foreach ($data['hosts'] as $hostid => $host) { ]); } -$widgets[] = (new CCollapsibleUiWidget(WIDGET_SEARCH_HOSTS, $table)) - ->addClass(ZBX_STYLE_DASHBOARD_WIDGET_FLUID) - ->setExpanded((bool) CProfile::get('web.search.hats.'.WIDGET_SEARCH_HOSTS.'.state', true)) - ->setHeader(_('Hosts'), [], 'web.search.hats.'.WIDGET_SEARCH_HOSTS.'.state') - ->setFooter(new CList([ - _s('Displaying %1$s of %2$s found', count($data['hosts']), $data['total_hosts_cnt']) - ])); +$sections[] = (new CSectionCollapsible($table)) + ->setId(SECTION_SEARCH_HOSTS) + ->setHeader(new CTag('h4', true, _('Hosts'))) + ->setFooter(_s('Displaying %1$s of %2$s found', count($data['hosts']), $data['total_hosts_cnt'])) + ->setProfileIdx('web.search.hats.'.SECTION_SEARCH_HOSTS.'.state') + ->setExpanded((bool) CProfile::get('web.search.hats.'.SECTION_SEARCH_HOSTS.'.state', true)); $table = (new CTableInfo()) ->setHeader((new CRowHeader()) @@ -260,13 +259,12 @@ foreach ($data['host_groups'] as $groupid => $group) { ]); } -$widgets[] = (new CCollapsibleUiWidget(WIDGET_SEARCH_HOSTGROUP, $table)) - ->addClass(ZBX_STYLE_DASHBOARD_WIDGET_FLUID) - ->setExpanded((bool) CProfile::get('web.search.hats.'.WIDGET_SEARCH_HOSTGROUP.'.state', true)) - ->setHeader(_('Host groups'), [], 'web.search.hats.'.WIDGET_SEARCH_HOSTGROUP.'.state') - ->setFooter(new CList([ - _s('Displaying %1$s of %2$s found', count($data['host_groups']), $data['total_host_groups_cnt']) - ])); +$sections[] = (new CSectionCollapsible($table)) + ->setId(SECTION_SEARCH_HOSTGROUP) + ->setHeader(new CTag('h4', true, _('Host groups'))) + ->setFooter(_s('Displaying %1$s of %2$s found', count($data['host_groups']), $data['total_host_groups_cnt'])) + ->setProfileIdx('web.search.hats.'.SECTION_SEARCH_HOSTGROUP.'.state') + ->setExpanded((bool) CProfile::get('web.search.hats.'.SECTION_SEARCH_HOSTGROUP.'.state', true)); if ($data['admin']) { $table = (new CTableInfo()) @@ -359,13 +357,12 @@ if ($data['admin']) { ]); } - $widgets[] = (new CCollapsibleUiWidget(WIDGET_SEARCH_TEMPLATES, $table)) - ->addClass(ZBX_STYLE_DASHBOARD_WIDGET_FLUID) - ->setExpanded((bool) CProfile::get('web.search.hats.'.WIDGET_SEARCH_TEMPLATES.'.state', true)) - ->setHeader(_('Templates'), [], 'web.search.hats.'.WIDGET_SEARCH_TEMPLATES.'.state') - ->setFooter(new CList([ - _s('Displaying %1$s of %2$s found', count($data['templates']), $data['total_templates_cnt']) - ])); + $sections[] = (new CSectionCollapsible($table)) + ->setId(SECTION_SEARCH_TEMPLATES) + ->setHeader(new CTag('h4', true, _('Templates'))) + ->setFooter(_s('Displaying %1$s of %2$s found', count($data['templates']), $data['total_templates_cnt'])) + ->setProfileIdx('web.search.hats.'.SECTION_SEARCH_TEMPLATES.'.state') + ->setExpanded((bool) CProfile::get('web.search.hats.'.SECTION_SEARCH_TEMPLATES.'.state', true)); } $table = (new CTableInfo()) @@ -404,18 +401,19 @@ foreach ($data['template_groups'] as $groupid => $group) { $table->addRow([$name_link, $templates_link]); } -$widgets[] = (new CCollapsibleUiWidget(WIDGET_SEARCH_TEMPLATEGROUP, $table)) - ->addClass(ZBX_STYLE_DASHBOARD_WIDGET_FLUID) - ->setExpanded((bool) CProfile::get('web.search.hats.'.WIDGET_SEARCH_TEMPLATEGROUP.'.state', true)) - ->setHeader(_('Template groups'), [], 'web.search.hats.'.WIDGET_SEARCH_TEMPLATEGROUP.'.state') - ->setFooter(new CList([ +$sections[] = (new CSectionCollapsible($table)) + ->setId(SECTION_SEARCH_TEMPLATEGROUP) + ->setHeader(new CTag('h4', true, _('Template groups'))) + ->setFooter( _s('Displaying %1$s of %2$s found', count($data['template_groups']), $data['total_template_groups_cnt']) - ])); + ) + ->setProfileIdx('web.search.hats.'.SECTION_SEARCH_TEMPLATEGROUP.'.state') + ->setExpanded((bool) CProfile::get('web.search.hats.'.SECTION_SEARCH_TEMPLATEGROUP.'.state', true)); (new CWidget()) ->setTitle(_('Search').': '.$data['search']) ->setDocUrl(CDocHelper::getUrl(CDocHelper::SEARCH)) - ->addItem(new CDiv($widgets)) + ->addItem(new CDiv($sections)) ->show(); (new CScriptTag('view.init();')) diff --git a/ui/assets/styles/blue-theme.css b/ui/assets/styles/blue-theme.css index 5db150c9bd7..3189d707718 100644 --- a/ui/assets/styles/blue-theme.css +++ b/ui/assets/styles/blue-theme.css @@ -862,6 +862,66 @@ footer { .color-picker-dialogue .color-picker-input input { padding-left: 25px; } +.columns-wrapper { + display: flex; + flex-wrap: wrap; + align-items: start; } + .columns-wrapper.columns-nowrap { + flex-wrap: nowrap; } + .columns-wrapper.columns-2 > div, + .columns-wrapper.columns-2 > li { + display: block; + flex: 0 0 50%; + max-width: 50%; } + .columns-wrapper.columns-3 > div, + .columns-wrapper.columns-3 > li { + display: block; + flex: 0 0 33.33333%; + max-width: 33.33333%; } + .columns-wrapper .column-5 { + flex: 0 0 5%; + max-width: 5%; } + .columns-wrapper .column-10 { + flex: 0 0 10%; + max-width: 10%; } + .columns-wrapper .column-15 { + flex: 0 0 15%; + max-width: 15%; } + .columns-wrapper .column-20 { + flex: 0 0 20%; + max-width: 20%; } + .columns-wrapper .column-33 { + flex: 0 0 33.33333%; + max-width: 33.33333%; } + .columns-wrapper .column-35 { + flex: 0 0 35%; + max-width: 35%; } + .columns-wrapper .column-40 { + flex: 0 0 40%; + max-width: 40%; } + .columns-wrapper .column-50 { + flex: 0 0 50%; + max-width: 50%; } + .columns-wrapper .column-75 { + flex: 0 0 75%; + max-width: 75%; } + .columns-wrapper .column-90 { + flex: 0 0 90%; + max-width: 90%; } + .columns-wrapper .column-95 { + flex: 0 0 95%; + max-width: 95%; } + .columns-wrapper .column-center { + display: flex; + justify-content: center; + text-align: center; } + .columns-wrapper .column-middle { + display: flex; + align-items: center; } + .columns-wrapper > div:not(:last-child) section, + .columns-wrapper > ul:not(:last-child) section { + margin-right: 10px; } + .header-kioskmode-controls .dashboard-kioskmode-controls li { margin-right: 6px; } @@ -1411,8 +1471,6 @@ footer { .dashboard-widget .msg-good, .dashboard-widget .msg-warning { margin: 0 10px; } - .dashboard-widget.dashboard-widget-fluid { - margin-right: 0; } .dashboard-grid-widget-content .list-table th:first-child, .dashboard-grid-widget-content .list-table td:first-child, .dashboard-grid-iterator.iterator-alt-content .dashboard-grid-iterator-content > div .list-table th:first-child, .dashboard-grid-iterator.iterator-alt-content .dashboard-grid-iterator-content > div .list-table td:first-child, .dashboard-widget .list-table th:first-child, .dashboard-widget .list-table td:first-child, .overlay-dialogue .list-table th:first-child, .overlay-dialogue .list-table td:first-child { padding-left: 10px; } @@ -2524,6 +2582,49 @@ div.dashboard-grid-widget-tophosts z-bar-gauge { font-size: 0; border-left: 1px solid #ebeef0; } +section { + background-color: #ffffff; + border: 1px solid #dfe4e7; } + section .section-head { + display: flex; + height: 32px; + line-height: 32px; } + section .section-head h4 { + padding: 0 10px; + margin-right: auto; + overflow: hidden; + text-overflow: ellipsis; + font-weight: bold; + line-height: inherit; + color: #3c5563; } + section .section-toggle { + width: 24px; + height: 24px; + margin: 2px 2px 0 auto; + background: url("../img/icon-sprite.svg?20220519") no-repeat -6px -654px; } + section .section-foot { + padding: 0 10px; + text-align: right; + line-height: 32px; + color: #768d99; } + section.section-collapsed .section-body, + section.section-collapsed .section-foot { + display: none; } + section.section-collapsed .section-toggle { + background-position: -6px -689px; } + section:not(:last-child) { + margin-bottom: 10px; } + section .list-table { + border: 0; } + section .list-table tbody tr:last-child td { + border-bottom: 1px solid #ebeef0; } + section .list-table td:first-child, + section .list-table th:first-child { + padding-left: 10px; } + section .list-table td:last-child, + section .list-table th:last-child { + padding-right: 10px; } + .service-info { margin: -10px 0; border-left: 4px solid #429e47; } @@ -4497,13 +4598,13 @@ button { width: 24px; height: 24px; } -.filter-container.tabfilter-container .icon-edit, .btn-dashboard-page-properties, .btn-iterator-page-previous, .btn-iterator-page-next, .btn-widget-action, .btn-widget-collapse, .list-vertical-accordion .list-accordion-item-opened .list-accordion-item-toggle, .btn-widget-expand, .list-vertical-accordion .list-accordion-item-closed .list-accordion-item-toggle, .btn-widget-edit, .btn-alarm-on, .btn-alarm-off, .btn-sound-on, .btn-sound-off, .btn-info-clock, .btn-dashboard-conf, .interfaces .interface-row[data-type="2"] .interface-btn-toggle { +section .section-toggle, .filter-container.tabfilter-container .icon-edit, .btn-dashboard-page-properties, .btn-iterator-page-previous, .btn-iterator-page-next, .btn-widget-action, .btn-widget-collapse, .list-vertical-accordion .list-accordion-item-opened .list-accordion-item-toggle, .btn-widget-expand, .list-vertical-accordion .list-accordion-item-closed .list-accordion-item-toggle, .btn-widget-edit, .btn-alarm-on, .btn-alarm-off, .btn-sound-on, .btn-sound-off, .btn-info-clock, .btn-dashboard-conf, .interfaces .interface-row[data-type="2"] .interface-btn-toggle { border: 0; min-height: 0; padding: 0; opacity: .5; transition: opacity .2s ease-out; } - .filter-container.tabfilter-container [disabled].icon-edit, [disabled].btn-dashboard-page-properties, [disabled].btn-iterator-page-previous, [disabled].btn-iterator-page-next, [disabled].btn-widget-action, [disabled].btn-widget-collapse, .list-vertical-accordion .list-accordion-item-opened [disabled].list-accordion-item-toggle, [disabled].btn-widget-expand, .list-vertical-accordion .list-accordion-item-closed [disabled].list-accordion-item-toggle, [disabled].btn-widget-edit, [disabled].btn-alarm-on, [disabled].btn-alarm-off, [disabled].btn-sound-on, [disabled].btn-sound-off, [disabled].btn-info-clock, [disabled].btn-dashboard-conf, .interfaces .interface-row[data-type="2"] [disabled].interface-btn-toggle, .filter-container.tabfilter-container [disabled].icon-edit:hover, [disabled].btn-dashboard-page-properties:hover, [disabled].btn-iterator-page-previous:hover, [disabled].btn-iterator-page-next:hover, [disabled].btn-widget-action:hover, [disabled].btn-widget-collapse:hover, .list-vertical-accordion .list-accordion-item-opened [disabled].list-accordion-item-toggle:hover, [disabled].btn-widget-expand:hover, .list-vertical-accordion .list-accordion-item-closed [disabled].list-accordion-item-toggle:hover, [disabled].btn-widget-edit:hover, [disabled].btn-alarm-on:hover, [disabled].btn-alarm-off:hover, [disabled].btn-sound-on:hover, [disabled].btn-sound-off:hover, [disabled].btn-info-clock:hover, [disabled].btn-dashboard-conf:hover, .interfaces .interface-row[data-type="2"] [disabled].interface-btn-toggle:hover, .filter-container.tabfilter-container [disabled].icon-edit:focus, [disabled].btn-dashboard-page-properties:focus, [disabled].btn-iterator-page-previous:focus, [disabled].btn-iterator-page-next:focus, [disabled].btn-widget-action:focus, [disabled].btn-widget-collapse:focus, .list-vertical-accordion .list-accordion-item-opened [disabled].list-accordion-item-toggle:focus, [disabled].btn-widget-expand:focus, .list-vertical-accordion .list-accordion-item-closed [disabled].list-accordion-item-toggle:focus, [disabled].btn-widget-edit:focus, [disabled].btn-alarm-on:focus, [disabled].btn-alarm-off:focus, [disabled].btn-sound-on:focus, [disabled].btn-sound-off:focus, [disabled].btn-info-clock:focus, [disabled].btn-dashboard-conf:focus, .interfaces .interface-row[data-type="2"] [disabled].interface-btn-toggle:focus, .filter-container.tabfilter-container [disabled].icon-edit:active, [disabled].btn-dashboard-page-properties:active, [disabled].btn-iterator-page-previous:active, [disabled].btn-iterator-page-next:active, [disabled].btn-widget-action:active, [disabled].btn-widget-collapse:active, .list-vertical-accordion .list-accordion-item-opened [disabled].list-accordion-item-toggle:active, [disabled].btn-widget-expand:active, .list-vertical-accordion .list-accordion-item-closed [disabled].list-accordion-item-toggle:active, [disabled].btn-widget-edit:active, [disabled].btn-alarm-on:active, [disabled].btn-alarm-off:active, [disabled].btn-sound-on:active, [disabled].btn-sound-off:active, [disabled].btn-info-clock:active, [disabled].btn-dashboard-conf:active, .interfaces .interface-row[data-type="2"] [disabled].interface-btn-toggle:active { + section [disabled].section-toggle, .filter-container.tabfilter-container [disabled].icon-edit, [disabled].btn-dashboard-page-properties, [disabled].btn-iterator-page-previous, [disabled].btn-iterator-page-next, [disabled].btn-widget-action, [disabled].btn-widget-collapse, .list-vertical-accordion .list-accordion-item-opened [disabled].list-accordion-item-toggle, [disabled].btn-widget-expand, .list-vertical-accordion .list-accordion-item-closed [disabled].list-accordion-item-toggle, [disabled].btn-widget-edit, [disabled].btn-alarm-on, [disabled].btn-alarm-off, [disabled].btn-sound-on, [disabled].btn-sound-off, [disabled].btn-info-clock, [disabled].btn-dashboard-conf, .interfaces .interface-row[data-type="2"] [disabled].interface-btn-toggle, section [disabled].section-toggle:hover, .filter-container.tabfilter-container [disabled].icon-edit:hover, [disabled].btn-dashboard-page-properties:hover, [disabled].btn-iterator-page-previous:hover, [disabled].btn-iterator-page-next:hover, [disabled].btn-widget-action:hover, [disabled].btn-widget-collapse:hover, .list-vertical-accordion .list-accordion-item-opened [disabled].list-accordion-item-toggle:hover, [disabled].btn-widget-expand:hover, .list-vertical-accordion .list-accordion-item-closed [disabled].list-accordion-item-toggle:hover, [disabled].btn-widget-edit:hover, [disabled].btn-alarm-on:hover, [disabled].btn-alarm-off:hover, [disabled].btn-sound-on:hover, [disabled].btn-sound-off:hover, [disabled].btn-info-clock:hover, [disabled].btn-dashboard-conf:hover, .interfaces .interface-row[data-type="2"] [disabled].interface-btn-toggle:hover, section [disabled].section-toggle:focus, .filter-container.tabfilter-container [disabled].icon-edit:focus, [disabled].btn-dashboard-page-properties:focus, [disabled].btn-iterator-page-previous:focus, [disabled].btn-iterator-page-next:focus, [disabled].btn-widget-action:focus, [disabled].btn-widget-collapse:focus, .list-vertical-accordion .list-accordion-item-opened [disabled].list-accordion-item-toggle:focus, [disabled].btn-widget-expand:focus, .list-vertical-accordion .list-accordion-item-closed [disabled].list-accordion-item-toggle:focus, [disabled].btn-widget-edit:focus, [disabled].btn-alarm-on:focus, [disabled].btn-alarm-off:focus, [disabled].btn-sound-on:focus, [disabled].btn-sound-off:focus, [disabled].btn-info-clock:focus, [disabled].btn-dashboard-conf:focus, .interfaces .interface-row[data-type="2"] [disabled].interface-btn-toggle:focus, section [disabled].section-toggle:active, .filter-container.tabfilter-container [disabled].icon-edit:active, [disabled].btn-dashboard-page-properties:active, [disabled].btn-iterator-page-previous:active, [disabled].btn-iterator-page-next:active, [disabled].btn-widget-action:active, [disabled].btn-widget-collapse:active, .list-vertical-accordion .list-accordion-item-opened [disabled].list-accordion-item-toggle:active, [disabled].btn-widget-expand:active, .list-vertical-accordion .list-accordion-item-closed [disabled].list-accordion-item-toggle:active, [disabled].btn-widget-edit:active, [disabled].btn-alarm-on:active, [disabled].btn-alarm-off:active, [disabled].btn-sound-on:active, [disabled].btn-sound-off:active, [disabled].btn-info-clock:active, [disabled].btn-dashboard-conf:active, .interfaces .interface-row[data-type="2"] [disabled].interface-btn-toggle:active { background-color: transparent; opacity: .25; } @@ -4531,7 +4632,7 @@ button[disabled], button[disabled]:hover, button[disabled]:active { .inaccessible .subfilter-enabled { color: #bfbfbf; } -.filter-container.tabfilter-container .icon-edit:hover, .btn-dashboard-page-properties:hover, .btn-iterator-page-previous:hover, .btn-iterator-page-next:hover, .btn-widget-action:hover, .btn-widget-collapse:hover, .list-vertical-accordion .list-accordion-item-opened .list-accordion-item-toggle:hover, .btn-widget-expand:hover, .list-vertical-accordion .list-accordion-item-closed .list-accordion-item-toggle:hover, .btn-widget-edit:hover, .btn-alarm-on:hover, .btn-alarm-off:hover, .btn-sound-on:hover, .btn-sound-off:hover, .btn-info-clock:hover, .btn-dashboard-conf:hover, .interfaces .interface-row[data-type="2"] .interface-btn-toggle:hover, .filter-container.tabfilter-container .icon-edit:focus, .btn-dashboard-page-properties:focus, .btn-iterator-page-previous:focus, .btn-iterator-page-next:focus, .btn-widget-action:focus, .btn-widget-collapse:focus, .list-vertical-accordion .list-accordion-item-opened .list-accordion-item-toggle:focus, .btn-widget-expand:focus, .list-vertical-accordion .list-accordion-item-closed .list-accordion-item-toggle:focus, .btn-widget-edit:focus, .btn-alarm-on:focus, .btn-alarm-off:focus, .btn-sound-on:focus, .btn-sound-off:focus, .btn-info-clock:focus, .btn-dashboard-conf:focus, .interfaces .interface-row[data-type="2"] .interface-btn-toggle:focus, .filter-container.tabfilter-container .icon-edit:active, .btn-dashboard-page-properties:active, .btn-iterator-page-previous:active, .btn-iterator-page-next:active, .btn-widget-action:active, .btn-widget-collapse:active, .list-vertical-accordion .list-accordion-item-opened .list-accordion-item-toggle:active, .btn-widget-expand:active, .list-vertical-accordion .list-accordion-item-closed .list-accordion-item-toggle:active, .btn-widget-edit:active, .btn-alarm-on:active, .btn-alarm-off:active, .btn-sound-on:active, .btn-sound-off:active, .btn-info-clock:active, .btn-dashboard-conf:active, .interfaces .interface-row[data-type="2"] .interface-btn-toggle:active { +section .section-toggle:hover, .filter-container.tabfilter-container .icon-edit:hover, .btn-dashboard-page-properties:hover, .btn-iterator-page-previous:hover, .btn-iterator-page-next:hover, .btn-widget-action:hover, .btn-widget-collapse:hover, .list-vertical-accordion .list-accordion-item-opened .list-accordion-item-toggle:hover, .btn-widget-expand:hover, .list-vertical-accordion .list-accordion-item-closed .list-accordion-item-toggle:hover, .btn-widget-edit:hover, .btn-alarm-on:hover, .btn-alarm-off:hover, .btn-sound-on:hover, .btn-sound-off:hover, .btn-info-clock:hover, .btn-dashboard-conf:hover, .interfaces .interface-row[data-type="2"] .interface-btn-toggle:hover, section .section-toggle:focus, .filter-container.tabfilter-container .icon-edit:focus, .btn-dashboard-page-properties:focus, .btn-iterator-page-previous:focus, .btn-iterator-page-next:focus, .btn-widget-action:focus, .btn-widget-collapse:focus, .list-vertical-accordion .list-accordion-item-opened .list-accordion-item-toggle:focus, .btn-widget-expand:focus, .list-vertical-accordion .list-accordion-item-closed .list-accordion-item-toggle:focus, .btn-widget-edit:focus, .btn-alarm-on:focus, .btn-alarm-off:focus, .btn-sound-on:focus, .btn-sound-off:focus, .btn-info-clock:focus, .btn-dashboard-conf:focus, .interfaces .interface-row[data-type="2"] .interface-btn-toggle:focus, section .section-toggle:active, .filter-container.tabfilter-container .icon-edit:active, .btn-dashboard-page-properties:active, .btn-iterator-page-previous:active, .btn-iterator-page-next:active, .btn-widget-action:active, .btn-widget-collapse:active, .list-vertical-accordion .list-accordion-item-opened .list-accordion-item-toggle:active, .btn-widget-expand:active, .list-vertical-accordion .list-accordion-item-closed .list-accordion-item-toggle:active, .btn-widget-edit:active, .btn-alarm-on:active, .btn-alarm-off:active, .btn-sound-on:active, .btn-sound-off:active, .btn-info-clock:active, .btn-dashboard-conf:active, .interfaces .interface-row[data-type="2"] .interface-btn-toggle:active { background-color: transparent; opacity: 1; } @@ -6140,63 +6241,6 @@ svg { text-overflow: ellipsis; line-height: 24px; } -.columns-wrapper { - display: flex; - flex-wrap: wrap; - align-items: start; } - .columns-wrapper.columns-nowrap { - flex-wrap: nowrap; } - .columns-wrapper.columns-2 > div, - .columns-wrapper.columns-2 > li { - display: block; - flex: 0 0 50%; - max-width: 50%; } - .columns-wrapper.columns-3 > div, - .columns-wrapper.columns-3 > li { - display: block; - flex: 0 0 33.33333%; - max-width: 33.33333%; } - .columns-wrapper .column-5 { - flex: 0 0 5%; - max-width: 5%; } - .columns-wrapper .column-10 { - flex: 0 0 10%; - max-width: 10%; } - .columns-wrapper .column-15 { - flex: 0 0 15%; - max-width: 15%; } - .columns-wrapper .column-20 { - flex: 0 0 20%; - max-width: 20%; } - .columns-wrapper .column-33 { - flex: 0 0 33.33333%; - max-width: 33.33333%; } - .columns-wrapper .column-35 { - flex: 0 0 35%; - max-width: 35%; } - .columns-wrapper .column-40 { - flex: 0 0 40%; - max-width: 40%; } - .columns-wrapper .column-50 { - flex: 0 0 50%; - max-width: 50%; } - .columns-wrapper .column-75 { - flex: 0 0 75%; - max-width: 75%; } - .columns-wrapper .column-90 { - flex: 0 0 90%; - max-width: 90%; } - .columns-wrapper .column-95 { - flex: 0 0 95%; - max-width: 95%; } - .columns-wrapper .column-center { - display: flex; - justify-content: center; - text-align: center; } - .columns-wrapper .column-middle { - display: flex; - align-items: center; } - .preprocessing-list { display: block; max-width: 930px; diff --git a/ui/assets/styles/dark-theme.css b/ui/assets/styles/dark-theme.css index d6698fe2bb0..b0b28e580af 100644 --- a/ui/assets/styles/dark-theme.css +++ b/ui/assets/styles/dark-theme.css @@ -875,6 +875,66 @@ footer { .color-picker-dialogue .color-picker-input input { padding-left: 25px; } +.columns-wrapper { + display: flex; + flex-wrap: wrap; + align-items: start; } + .columns-wrapper.columns-nowrap { + flex-wrap: nowrap; } + .columns-wrapper.columns-2 > div, + .columns-wrapper.columns-2 > li { + display: block; + flex: 0 0 50%; + max-width: 50%; } + .columns-wrapper.columns-3 > div, + .columns-wrapper.columns-3 > li { + display: block; + flex: 0 0 33.33333%; + max-width: 33.33333%; } + .columns-wrapper .column-5 { + flex: 0 0 5%; + max-width: 5%; } + .columns-wrapper .column-10 { + flex: 0 0 10%; + max-width: 10%; } + .columns-wrapper .column-15 { + flex: 0 0 15%; + max-width: 15%; } + .columns-wrapper .column-20 { + flex: 0 0 20%; + max-width: 20%; } + .columns-wrapper .column-33 { + flex: 0 0 33.33333%; + max-width: 33.33333%; } + .columns-wrapper .column-35 { + flex: 0 0 35%; + max-width: 35%; } + .columns-wrapper .column-40 { + flex: 0 0 40%; + max-width: 40%; } + .columns-wrapper .column-50 { + flex: 0 0 50%; + max-width: 50%; } + .columns-wrapper .column-75 { + flex: 0 0 75%; + max-width: 75%; } + .columns-wrapper .column-90 { + flex: 0 0 90%; + max-width: 90%; } + .columns-wrapper .column-95 { + flex: 0 0 95%; + max-width: 95%; } + .columns-wrapper .column-center { + display: flex; + justify-content: center; + text-align: center; } + .columns-wrapper .column-middle { + display: flex; + align-items: center; } + .columns-wrapper > div:not(:last-child) section, + .columns-wrapper > ul:not(:last-child) section { + margin-right: 10px; } + .header-kioskmode-controls .dashboard-kioskmode-controls li { margin-right: 6px; } @@ -1424,8 +1484,6 @@ footer { .dashboard-widget .msg-good, .dashboard-widget .msg-warning { margin: 0 10px; } - .dashboard-widget.dashboard-widget-fluid { - margin-right: 0; } .dashboard-grid-widget-content .list-table th:first-child, .dashboard-grid-widget-content .list-table td:first-child, .dashboard-grid-iterator.iterator-alt-content .dashboard-grid-iterator-content > div .list-table th:first-child, .dashboard-grid-iterator.iterator-alt-content .dashboard-grid-iterator-content > div .list-table td:first-child, .dashboard-widget .list-table th:first-child, .dashboard-widget .list-table td:first-child, .overlay-dialogue .list-table th:first-child, .overlay-dialogue .list-table td:first-child { padding-left: 10px; } @@ -2537,6 +2595,49 @@ div.dashboard-grid-widget-tophosts z-bar-gauge { font-size: 0; border-left: 1px solid #0e1012; } +section { + background-color: #2b2b2b; + border: 1px solid #303030; } + section .section-head { + display: flex; + height: 32px; + line-height: 32px; } + section .section-head h4 { + padding: 0 10px; + margin-right: auto; + overflow: hidden; + text-overflow: ellipsis; + font-weight: bold; + line-height: inherit; + color: white; } + section .section-toggle { + width: 24px; + height: 24px; + margin: 2px 2px 0 auto; + background: url("../img/icon-sprite.svg?20220519") no-repeat -6px -654px; } + section .section-foot { + padding: 0 10px; + text-align: right; + line-height: 32px; + color: #737373; } + section.section-collapsed .section-body, + section.section-collapsed .section-foot { + display: none; } + section.section-collapsed .section-toggle { + background-position: -6px -689px; } + section:not(:last-child) { + margin-bottom: 10px; } + section .list-table { + border: 0; } + section .list-table tbody tr:last-child td { + border-bottom: 1px solid #383838; } + section .list-table td:first-child, + section .list-table th:first-child { + padding-left: 10px; } + section .list-table td:last-child, + section .list-table th:last-child { + padding-right: 10px; } + .service-info { margin: -10px 0; border-left: 4px solid #59db8f; } @@ -4508,13 +4609,13 @@ button { width: 24px; height: 24px; } -.filter-container.tabfilter-container .icon-edit, .btn-dashboard-page-properties, .btn-iterator-page-previous, .btn-iterator-page-next, .btn-widget-action, .btn-widget-collapse, .list-vertical-accordion .list-accordion-item-opened .list-accordion-item-toggle, .btn-widget-expand, .list-vertical-accordion .list-accordion-item-closed .list-accordion-item-toggle, .btn-widget-edit, .btn-alarm-on, .btn-alarm-off, .btn-sound-on, .btn-sound-off, .btn-info-clock, .btn-dashboard-conf, .interfaces .interface-row[data-type="2"] .interface-btn-toggle { +section .section-toggle, .filter-container.tabfilter-container .icon-edit, .btn-dashboard-page-properties, .btn-iterator-page-previous, .btn-iterator-page-next, .btn-widget-action, .btn-widget-collapse, .list-vertical-accordion .list-accordion-item-opened .list-accordion-item-toggle, .btn-widget-expand, .list-vertical-accordion .list-accordion-item-closed .list-accordion-item-toggle, .btn-widget-edit, .btn-alarm-on, .btn-alarm-off, .btn-sound-on, .btn-sound-off, .btn-info-clock, .btn-dashboard-conf, .interfaces .interface-row[data-type="2"] .interface-btn-toggle { border: 0; min-height: 0; padding: 0; opacity: .5; transition: opacity .2s ease-out; } - .filter-container.tabfilter-container [disabled].icon-edit, [disabled].btn-dashboard-page-properties, [disabled].btn-iterator-page-previous, [disabled].btn-iterator-page-next, [disabled].btn-widget-action, [disabled].btn-widget-collapse, .list-vertical-accordion .list-accordion-item-opened [disabled].list-accordion-item-toggle, [disabled].btn-widget-expand, .list-vertical-accordion .list-accordion-item-closed [disabled].list-accordion-item-toggle, [disabled].btn-widget-edit, [disabled].btn-alarm-on, [disabled].btn-alarm-off, [disabled].btn-sound-on, [disabled].btn-sound-off, [disabled].btn-info-clock, [disabled].btn-dashboard-conf, .interfaces .interface-row[data-type="2"] [disabled].interface-btn-toggle, .filter-container.tabfilter-container [disabled].icon-edit:hover, [disabled].btn-dashboard-page-properties:hover, [disabled].btn-iterator-page-previous:hover, [disabled].btn-iterator-page-next:hover, [disabled].btn-widget-action:hover, [disabled].btn-widget-collapse:hover, .list-vertical-accordion .list-accordion-item-opened [disabled].list-accordion-item-toggle:hover, [disabled].btn-widget-expand:hover, .list-vertical-accordion .list-accordion-item-closed [disabled].list-accordion-item-toggle:hover, [disabled].btn-widget-edit:hover, [disabled].btn-alarm-on:hover, [disabled].btn-alarm-off:hover, [disabled].btn-sound-on:hover, [disabled].btn-sound-off:hover, [disabled].btn-info-clock:hover, [disabled].btn-dashboard-conf:hover, .interfaces .interface-row[data-type="2"] [disabled].interface-btn-toggle:hover, .filter-container.tabfilter-container [disabled].icon-edit:focus, [disabled].btn-dashboard-page-properties:focus, [disabled].btn-iterator-page-previous:focus, [disabled].btn-iterator-page-next:focus, [disabled].btn-widget-action:focus, [disabled].btn-widget-collapse:focus, .list-vertical-accordion .list-accordion-item-opened [disabled].list-accordion-item-toggle:focus, [disabled].btn-widget-expand:focus, .list-vertical-accordion .list-accordion-item-closed [disabled].list-accordion-item-toggle:focus, [disabled].btn-widget-edit:focus, [disabled].btn-alarm-on:focus, [disabled].btn-alarm-off:focus, [disabled].btn-sound-on:focus, [disabled].btn-sound-off:focus, [disabled].btn-info-clock:focus, [disabled].btn-dashboard-conf:focus, .interfaces .interface-row[data-type="2"] [disabled].interface-btn-toggle:focus, .filter-container.tabfilter-container [disabled].icon-edit:active, [disabled].btn-dashboard-page-properties:active, [disabled].btn-iterator-page-previous:active, [disabled].btn-iterator-page-next:active, [disabled].btn-widget-action:active, [disabled].btn-widget-collapse:active, .list-vertical-accordion .list-accordion-item-opened [disabled].list-accordion-item-toggle:active, [disabled].btn-widget-expand:active, .list-vertical-accordion .list-accordion-item-closed [disabled].list-accordion-item-toggle:active, [disabled].btn-widget-edit:active, [disabled].btn-alarm-on:active, [disabled].btn-alarm-off:active, [disabled].btn-sound-on:active, [disabled].btn-sound-off:active, [disabled].btn-info-clock:active, [disabled].btn-dashboard-conf:active, .interfaces .interface-row[data-type="2"] [disabled].interface-btn-toggle:active { + section [disabled].section-toggle, .filter-container.tabfilter-container [disabled].icon-edit, [disabled].btn-dashboard-page-properties, [disabled].btn-iterator-page-previous, [disabled].btn-iterator-page-next, [disabled].btn-widget-action, [disabled].btn-widget-collapse, .list-vertical-accordion .list-accordion-item-opened [disabled].list-accordion-item-toggle, [disabled].btn-widget-expand, .list-vertical-accordion .list-accordion-item-closed [disabled].list-accordion-item-toggle, [disabled].btn-widget-edit, [disabled].btn-alarm-on, [disabled].btn-alarm-off, [disabled].btn-sound-on, [disabled].btn-sound-off, [disabled].btn-info-clock, [disabled].btn-dashboard-conf, .interfaces .interface-row[data-type="2"] [disabled].interface-btn-toggle, section [disabled].section-toggle:hover, .filter-container.tabfilter-container [disabled].icon-edit:hover, [disabled].btn-dashboard-page-properties:hover, [disabled].btn-iterator-page-previous:hover, [disabled].btn-iterator-page-next:hover, [disabled].btn-widget-action:hover, [disabled].btn-widget-collapse:hover, .list-vertical-accordion .list-accordion-item-opened [disabled].list-accordion-item-toggle:hover, [disabled].btn-widget-expand:hover, .list-vertical-accordion .list-accordion-item-closed [disabled].list-accordion-item-toggle:hover, [disabled].btn-widget-edit:hover, [disabled].btn-alarm-on:hover, [disabled].btn-alarm-off:hover, [disabled].btn-sound-on:hover, [disabled].btn-sound-off:hover, [disabled].btn-info-clock:hover, [disabled].btn-dashboard-conf:hover, .interfaces .interface-row[data-type="2"] [disabled].interface-btn-toggle:hover, section [disabled].section-toggle:focus, .filter-container.tabfilter-container [disabled].icon-edit:focus, [disabled].btn-dashboard-page-properties:focus, [disabled].btn-iterator-page-previous:focus, [disabled].btn-iterator-page-next:focus, [disabled].btn-widget-action:focus, [disabled].btn-widget-collapse:focus, .list-vertical-accordion .list-accordion-item-opened [disabled].list-accordion-item-toggle:focus, [disabled].btn-widget-expand:focus, .list-vertical-accordion .list-accordion-item-closed [disabled].list-accordion-item-toggle:focus, [disabled].btn-widget-edit:focus, [disabled].btn-alarm-on:focus, [disabled].btn-alarm-off:focus, [disabled].btn-sound-on:focus, [disabled].btn-sound-off:focus, [disabled].btn-info-clock:focus, [disabled].btn-dashboard-conf:focus, .interfaces .interface-row[data-type="2"] [disabled].interface-btn-toggle:focus, section [disabled].section-toggle:active, .filter-container.tabfilter-container [disabled].icon-edit:active, [disabled].btn-dashboard-page-properties:active, [disabled].btn-iterator-page-previous:active, [disabled].btn-iterator-page-next:active, [disabled].btn-widget-action:active, [disabled].btn-widget-collapse:active, .list-vertical-accordion .list-accordion-item-opened [disabled].list-accordion-item-toggle:active, [disabled].btn-widget-expand:active, .list-vertical-accordion .list-accordion-item-closed [disabled].list-accordion-item-toggle:active, [disabled].btn-widget-edit:active, [disabled].btn-alarm-on:active, [disabled].btn-alarm-off:active, [disabled].btn-sound-on:active, [disabled].btn-sound-off:active, [disabled].btn-info-clock:active, [disabled].btn-dashboard-conf:active, .interfaces .interface-row[data-type="2"] [disabled].interface-btn-toggle:active { background-color: transparent; opacity: .25; } @@ -4542,7 +4643,7 @@ button[disabled], button[disabled]:hover, button[disabled]:active { .inaccessible .subfilter-enabled { color: #b2b2b2; } -.filter-container.tabfilter-container .icon-edit:hover, .btn-dashboard-page-properties:hover, .btn-iterator-page-previous:hover, .btn-iterator-page-next:hover, .btn-widget-action:hover, .btn-widget-collapse:hover, .list-vertical-accordion .list-accordion-item-opened .list-accordion-item-toggle:hover, .btn-widget-expand:hover, .list-vertical-accordion .list-accordion-item-closed .list-accordion-item-toggle:hover, .btn-widget-edit:hover, .btn-alarm-on:hover, .btn-alarm-off:hover, .btn-sound-on:hover, .btn-sound-off:hover, .btn-info-clock:hover, .btn-dashboard-conf:hover, .interfaces .interface-row[data-type="2"] .interface-btn-toggle:hover, .filter-container.tabfilter-container .icon-edit:focus, .btn-dashboard-page-properties:focus, .btn-iterator-page-previous:focus, .btn-iterator-page-next:focus, .btn-widget-action:focus, .btn-widget-collapse:focus, .list-vertical-accordion .list-accordion-item-opened .list-accordion-item-toggle:focus, .btn-widget-expand:focus, .list-vertical-accordion .list-accordion-item-closed .list-accordion-item-toggle:focus, .btn-widget-edit:focus, .btn-alarm-on:focus, .btn-alarm-off:focus, .btn-sound-on:focus, .btn-sound-off:focus, .btn-info-clock:focus, .btn-dashboard-conf:focus, .interfaces .interface-row[data-type="2"] .interface-btn-toggle:focus, .filter-container.tabfilter-container .icon-edit:active, .btn-dashboard-page-properties:active, .btn-iterator-page-previous:active, .btn-iterator-page-next:active, .btn-widget-action:active, .btn-widget-collapse:active, .list-vertical-accordion .list-accordion-item-opened .list-accordion-item-toggle:active, .btn-widget-expand:active, .list-vertical-accordion .list-accordion-item-closed .list-accordion-item-toggle:active, .btn-widget-edit:active, .btn-alarm-on:active, .btn-alarm-off:active, .btn-sound-on:active, .btn-sound-off:active, .btn-info-clock:active, .btn-dashboard-conf:active, .interfaces .interface-row[data-type="2"] .interface-btn-toggle:active { +section .section-toggle:hover, .filter-container.tabfilter-container .icon-edit:hover, .btn-dashboard-page-properties:hover, .btn-iterator-page-previous:hover, .btn-iterator-page-next:hover, .btn-widget-action:hover, .btn-widget-collapse:hover, .list-vertical-accordion .list-accordion-item-opened .list-accordion-item-toggle:hover, .btn-widget-expand:hover, .list-vertical-accordion .list-accordion-item-closed .list-accordion-item-toggle:hover, .btn-widget-edit:hover, .btn-alarm-on:hover, .btn-alarm-off:hover, .btn-sound-on:hover, .btn-sound-off:hover, .btn-info-clock:hover, .btn-dashboard-conf:hover, .interfaces .interface-row[data-type="2"] .interface-btn-toggle:hover, section .section-toggle:focus, .filter-container.tabfilter-container .icon-edit:focus, .btn-dashboard-page-properties:focus, .btn-iterator-page-previous:focus, .btn-iterator-page-next:focus, .btn-widget-action:focus, .btn-widget-collapse:focus, .list-vertical-accordion .list-accordion-item-opened .list-accordion-item-toggle:focus, .btn-widget-expand:focus, .list-vertical-accordion .list-accordion-item-closed .list-accordion-item-toggle:focus, .btn-widget-edit:focus, .btn-alarm-on:focus, .btn-alarm-off:focus, .btn-sound-on:focus, .btn-sound-off:focus, .btn-info-clock:focus, .btn-dashboard-conf:focus, .interfaces .interface-row[data-type="2"] .interface-btn-toggle:focus, section .section-toggle:active, .filter-container.tabfilter-container .icon-edit:active, .btn-dashboard-page-properties:active, .btn-iterator-page-previous:active, .btn-iterator-page-next:active, .btn-widget-action:active, .btn-widget-collapse:active, .list-vertical-accordion .list-accordion-item-opened .list-accordion-item-toggle:active, .btn-widget-expand:active, .list-vertical-accordion .list-accordion-item-closed .list-accordion-item-toggle:active, .btn-widget-edit:active, .btn-alarm-on:active, .btn-alarm-off:active, .btn-sound-on:active, .btn-sound-off:active, .btn-info-clock:active, .btn-dashboard-conf:active, .interfaces .interface-row[data-type="2"] .interface-btn-toggle:active { background-color: transparent; opacity: 1; } @@ -6151,63 +6252,6 @@ svg { text-overflow: ellipsis; line-height: 24px; } -.columns-wrapper { - display: flex; - flex-wrap: wrap; - align-items: start; } - .columns-wrapper.columns-nowrap { - flex-wrap: nowrap; } - .columns-wrapper.columns-2 > div, - .columns-wrapper.columns-2 > li { - display: block; - flex: 0 0 50%; - max-width: 50%; } - .columns-wrapper.columns-3 > div, - .columns-wrapper.columns-3 > li { - display: block; - flex: 0 0 33.33333%; - max-width: 33.33333%; } - .columns-wrapper .column-5 { - flex: 0 0 5%; - max-width: 5%; } - .columns-wrapper .column-10 { - flex: 0 0 10%; - max-width: 10%; } - .columns-wrapper .column-15 { - flex: 0 0 15%; - max-width: 15%; } - .columns-wrapper .column-20 { - flex: 0 0 20%; - max-width: 20%; } - .columns-wrapper .column-33 { - flex: 0 0 33.33333%; - max-width: 33.33333%; } - .columns-wrapper .column-35 { - flex: 0 0 35%; - max-width: 35%; } - .columns-wrapper .column-40 { - flex: 0 0 40%; - max-width: 40%; } - .columns-wrapper .column-50 { - flex: 0 0 50%; - max-width: 50%; } - .columns-wrapper .column-75 { - flex: 0 0 75%; - max-width: 75%; } - .columns-wrapper .column-90 { - flex: 0 0 90%; - max-width: 90%; } - .columns-wrapper .column-95 { - flex: 0 0 95%; - max-width: 95%; } - .columns-wrapper .column-center { - display: flex; - justify-content: center; - text-align: center; } - .columns-wrapper .column-middle { - display: flex; - align-items: center; } - .preprocessing-list { display: block; max-width: 930px; diff --git a/ui/assets/styles/hc-dark.css b/ui/assets/styles/hc-dark.css index 354f5ea6705..6f0d15f23f8 100644 --- a/ui/assets/styles/hc-dark.css +++ b/ui/assets/styles/hc-dark.css @@ -862,6 +862,66 @@ footer { .color-picker-dialogue .color-picker-input input { padding-left: 25px; } +.columns-wrapper { + display: flex; + flex-wrap: wrap; + align-items: start; } + .columns-wrapper.columns-nowrap { + flex-wrap: nowrap; } + .columns-wrapper.columns-2 > div, + .columns-wrapper.columns-2 > li { + display: block; + flex: 0 0 50%; + max-width: 50%; } + .columns-wrapper.columns-3 > div, + .columns-wrapper.columns-3 > li { + display: block; + flex: 0 0 33.33333%; + max-width: 33.33333%; } + .columns-wrapper .column-5 { + flex: 0 0 5%; + max-width: 5%; } + .columns-wrapper .column-10 { + flex: 0 0 10%; + max-width: 10%; } + .columns-wrapper .column-15 { + flex: 0 0 15%; + max-width: 15%; } + .columns-wrapper .column-20 { + flex: 0 0 20%; + max-width: 20%; } + .columns-wrapper .column-33 { + flex: 0 0 33.33333%; + max-width: 33.33333%; } + .columns-wrapper .column-35 { + flex: 0 0 35%; + max-width: 35%; } + .columns-wrapper .column-40 { + flex: 0 0 40%; + max-width: 40%; } + .columns-wrapper .column-50 { + flex: 0 0 50%; + max-width: 50%; } + .columns-wrapper .column-75 { + flex: 0 0 75%; + max-width: 75%; } + .columns-wrapper .column-90 { + flex: 0 0 90%; + max-width: 90%; } + .columns-wrapper .column-95 { + flex: 0 0 95%; + max-width: 95%; } + .columns-wrapper .column-center { + display: flex; + justify-content: center; + text-align: center; } + .columns-wrapper .column-middle { + display: flex; + align-items: center; } + .columns-wrapper > div:not(:last-child) section, + .columns-wrapper > ul:not(:last-child) section { + margin-right: 10px; } + .header-kioskmode-controls .dashboard-kioskmode-controls li { margin-right: 6px; } @@ -1411,8 +1471,6 @@ footer { .dashboard-widget .msg-good, .dashboard-widget .msg-warning { margin: 0 10px; } - .dashboard-widget.dashboard-widget-fluid { - margin-right: 0; } .dashboard-grid-widget-content .list-table th:first-child, .dashboard-grid-widget-content .list-table td:first-child, .dashboard-grid-iterator.iterator-alt-content .dashboard-grid-iterator-content > div .list-table th:first-child, .dashboard-grid-iterator.iterator-alt-content .dashboard-grid-iterator-content > div .list-table td:first-child, .dashboard-widget .list-table th:first-child, .dashboard-widget .list-table td:first-child, .overlay-dialogue .list-table th:first-child, .overlay-dialogue .list-table td:first-child { padding-left: 10px; } @@ -2513,6 +2571,49 @@ div.dashboard-grid-widget-tophosts z-bar-gauge { font-size: 0; border-left: 1px solid #111111; } +section { + background-color: #000000; + border: 1px solid #444444; } + section .section-head { + display: flex; + height: 32px; + line-height: 32px; } + section .section-head h4 { + padding: 0 10px; + margin-right: auto; + overflow: hidden; + text-overflow: ellipsis; + font-weight: bold; + line-height: inherit; + color: white; } + section .section-toggle { + width: 24px; + height: 24px; + margin: 2px 2px 0 auto; + background: url("../img/icon-sprite.svg?20220519") no-repeat -6px -654px; } + section .section-foot { + padding: 0 10px; + text-align: right; + line-height: 32px; + color: #cacaca; } + section.section-collapsed .section-body, + section.section-collapsed .section-foot { + display: none; } + section.section-collapsed .section-toggle { + background-position: -6px -689px; } + section:not(:last-child) { + margin-bottom: 10px; } + section .list-table { + border: 0; } + section .list-table tbody tr:last-child td { + border-bottom: 1px solid #333333; } + section .list-table td:first-child, + section .list-table th:first-child { + padding-left: 10px; } + section .list-table td:last-child, + section .list-table th:last-child { + padding-right: 10px; } + .service-info { margin: -10px 0; border-left: 4px solid #23d545; } @@ -4463,13 +4564,13 @@ button { width: 24px; height: 24px; } -.filter-container.tabfilter-container .icon-edit, .btn-dashboard-page-properties, .btn-iterator-page-previous, .btn-iterator-page-next, .btn-widget-action, .btn-widget-collapse, .list-vertical-accordion .list-accordion-item-opened .list-accordion-item-toggle, .btn-widget-expand, .list-vertical-accordion .list-accordion-item-closed .list-accordion-item-toggle, .btn-widget-edit, .btn-alarm-on, .btn-alarm-off, .btn-sound-on, .btn-sound-off, .btn-info-clock, .btn-dashboard-conf, .interfaces .interface-row[data-type="2"] .interface-btn-toggle { +section .section-toggle, .filter-container.tabfilter-container .icon-edit, .btn-dashboard-page-properties, .btn-iterator-page-previous, .btn-iterator-page-next, .btn-widget-action, .btn-widget-collapse, .list-vertical-accordion .list-accordion-item-opened .list-accordion-item-toggle, .btn-widget-expand, .list-vertical-accordion .list-accordion-item-closed .list-accordion-item-toggle, .btn-widget-edit, .btn-alarm-on, .btn-alarm-off, .btn-sound-on, .btn-sound-off, .btn-info-clock, .btn-dashboard-conf, .interfaces .interface-row[data-type="2"] .interface-btn-toggle { border: 0; min-height: 0; padding: 0; opacity: .5; transition: opacity .2s ease-out; } - .filter-container.tabfilter-container [disabled].icon-edit, [disabled].btn-dashboard-page-properties, [disabled].btn-iterator-page-previous, [disabled].btn-iterator-page-next, [disabled].btn-widget-action, [disabled].btn-widget-collapse, .list-vertical-accordion .list-accordion-item-opened [disabled].list-accordion-item-toggle, [disabled].btn-widget-expand, .list-vertical-accordion .list-accordion-item-closed [disabled].list-accordion-item-toggle, [disabled].btn-widget-edit, [disabled].btn-alarm-on, [disabled].btn-alarm-off, [disabled].btn-sound-on, [disabled].btn-sound-off, [disabled].btn-info-clock, [disabled].btn-dashboard-conf, .interfaces .interface-row[data-type="2"] [disabled].interface-btn-toggle, .filter-container.tabfilter-container [disabled].icon-edit:hover, [disabled].btn-dashboard-page-properties:hover, [disabled].btn-iterator-page-previous:hover, [disabled].btn-iterator-page-next:hover, [disabled].btn-widget-action:hover, [disabled].btn-widget-collapse:hover, .list-vertical-accordion .list-accordion-item-opened [disabled].list-accordion-item-toggle:hover, [disabled].btn-widget-expand:hover, .list-vertical-accordion .list-accordion-item-closed [disabled].list-accordion-item-toggle:hover, [disabled].btn-widget-edit:hover, [disabled].btn-alarm-on:hover, [disabled].btn-alarm-off:hover, [disabled].btn-sound-on:hover, [disabled].btn-sound-off:hover, [disabled].btn-info-clock:hover, [disabled].btn-dashboard-conf:hover, .interfaces .interface-row[data-type="2"] [disabled].interface-btn-toggle:hover, .filter-container.tabfilter-container [disabled].icon-edit:focus, [disabled].btn-dashboard-page-properties:focus, [disabled].btn-iterator-page-previous:focus, [disabled].btn-iterator-page-next:focus, [disabled].btn-widget-action:focus, [disabled].btn-widget-collapse:focus, .list-vertical-accordion .list-accordion-item-opened [disabled].list-accordion-item-toggle:focus, [disabled].btn-widget-expand:focus, .list-vertical-accordion .list-accordion-item-closed [disabled].list-accordion-item-toggle:focus, [disabled].btn-widget-edit:focus, [disabled].btn-alarm-on:focus, [disabled].btn-alarm-off:focus, [disabled].btn-sound-on:focus, [disabled].btn-sound-off:focus, [disabled].btn-info-clock:focus, [disabled].btn-dashboard-conf:focus, .interfaces .interface-row[data-type="2"] [disabled].interface-btn-toggle:focus, .filter-container.tabfilter-container [disabled].icon-edit:active, [disabled].btn-dashboard-page-properties:active, [disabled].btn-iterator-page-previous:active, [disabled].btn-iterator-page-next:active, [disabled].btn-widget-action:active, [disabled].btn-widget-collapse:active, .list-vertical-accordion .list-accordion-item-opened [disabled].list-accordion-item-toggle:active, [disabled].btn-widget-expand:active, .list-vertical-accordion .list-accordion-item-closed [disabled].list-accordion-item-toggle:active, [disabled].btn-widget-edit:active, [disabled].btn-alarm-on:active, [disabled].btn-alarm-off:active, [disabled].btn-sound-on:active, [disabled].btn-sound-off:active, [disabled].btn-info-clock:active, [disabled].btn-dashboard-conf:active, .interfaces .interface-row[data-type="2"] [disabled].interface-btn-toggle:active { + section [disabled].section-toggle, .filter-container.tabfilter-container [disabled].icon-edit, [disabled].btn-dashboard-page-properties, [disabled].btn-iterator-page-previous, [disabled].btn-iterator-page-next, [disabled].btn-widget-action, [disabled].btn-widget-collapse, .list-vertical-accordion .list-accordion-item-opened [disabled].list-accordion-item-toggle, [disabled].btn-widget-expand, .list-vertical-accordion .list-accordion-item-closed [disabled].list-accordion-item-toggle, [disabled].btn-widget-edit, [disabled].btn-alarm-on, [disabled].btn-alarm-off, [disabled].btn-sound-on, [disabled].btn-sound-off, [disabled].btn-info-clock, [disabled].btn-dashboard-conf, .interfaces .interface-row[data-type="2"] [disabled].interface-btn-toggle, section [disabled].section-toggle:hover, .filter-container.tabfilter-container [disabled].icon-edit:hover, [disabled].btn-dashboard-page-properties:hover, [disabled].btn-iterator-page-previous:hover, [disabled].btn-iterator-page-next:hover, [disabled].btn-widget-action:hover, [disabled].btn-widget-collapse:hover, .list-vertical-accordion .list-accordion-item-opened [disabled].list-accordion-item-toggle:hover, [disabled].btn-widget-expand:hover, .list-vertical-accordion .list-accordion-item-closed [disabled].list-accordion-item-toggle:hover, [disabled].btn-widget-edit:hover, [disabled].btn-alarm-on:hover, [disabled].btn-alarm-off:hover, [disabled].btn-sound-on:hover, [disabled].btn-sound-off:hover, [disabled].btn-info-clock:hover, [disabled].btn-dashboard-conf:hover, .interfaces .interface-row[data-type="2"] [disabled].interface-btn-toggle:hover, section [disabled].section-toggle:focus, .filter-container.tabfilter-container [disabled].icon-edit:focus, [disabled].btn-dashboard-page-properties:focus, [disabled].btn-iterator-page-previous:focus, [disabled].btn-iterator-page-next:focus, [disabled].btn-widget-action:focus, [disabled].btn-widget-collapse:focus, .list-vertical-accordion .list-accordion-item-opened [disabled].list-accordion-item-toggle:focus, [disabled].btn-widget-expand:focus, .list-vertical-accordion .list-accordion-item-closed [disabled].list-accordion-item-toggle:focus, [disabled].btn-widget-edit:focus, [disabled].btn-alarm-on:focus, [disabled].btn-alarm-off:focus, [disabled].btn-sound-on:focus, [disabled].btn-sound-off:focus, [disabled].btn-info-clock:focus, [disabled].btn-dashboard-conf:focus, .interfaces .interface-row[data-type="2"] [disabled].interface-btn-toggle:focus, section [disabled].section-toggle:active, .filter-container.tabfilter-container [disabled].icon-edit:active, [disabled].btn-dashboard-page-properties:active, [disabled].btn-iterator-page-previous:active, [disabled].btn-iterator-page-next:active, [disabled].btn-widget-action:active, [disabled].btn-widget-collapse:active, .list-vertical-accordion .list-accordion-item-opened [disabled].list-accordion-item-toggle:active, [disabled].btn-widget-expand:active, .list-vertical-accordion .list-accordion-item-closed [disabled].list-accordion-item-toggle:active, [disabled].btn-widget-edit:active, [disabled].btn-alarm-on:active, [disabled].btn-alarm-off:active, [disabled].btn-sound-on:active, [disabled].btn-sound-off:active, [disabled].btn-info-clock:active, [disabled].btn-dashboard-conf:active, .interfaces .interface-row[data-type="2"] [disabled].interface-btn-toggle:active { background-color: transparent; opacity: .25; } @@ -4497,7 +4598,7 @@ button[disabled], button[disabled]:hover, button[disabled]:active { .inaccessible .subfilter-enabled { color: #bfbfbf; } -.filter-container.tabfilter-container .icon-edit:hover, .btn-dashboard-page-properties:hover, .btn-iterator-page-previous:hover, .btn-iterator-page-next:hover, .btn-widget-action:hover, .btn-widget-collapse:hover, .list-vertical-accordion .list-accordion-item-opened .list-accordion-item-toggle:hover, .btn-widget-expand:hover, .list-vertical-accordion .list-accordion-item-closed .list-accordion-item-toggle:hover, .btn-widget-edit:hover, .btn-alarm-on:hover, .btn-alarm-off:hover, .btn-sound-on:hover, .btn-sound-off:hover, .btn-info-clock:hover, .btn-dashboard-conf:hover, .interfaces .interface-row[data-type="2"] .interface-btn-toggle:hover, .filter-container.tabfilter-container .icon-edit:focus, .btn-dashboard-page-properties:focus, .btn-iterator-page-previous:focus, .btn-iterator-page-next:focus, .btn-widget-action:focus, .btn-widget-collapse:focus, .list-vertical-accordion .list-accordion-item-opened .list-accordion-item-toggle:focus, .btn-widget-expand:focus, .list-vertical-accordion .list-accordion-item-closed .list-accordion-item-toggle:focus, .btn-widget-edit:focus, .btn-alarm-on:focus, .btn-alarm-off:focus, .btn-sound-on:focus, .btn-sound-off:focus, .btn-info-clock:focus, .btn-dashboard-conf:focus, .interfaces .interface-row[data-type="2"] .interface-btn-toggle:focus, .filter-container.tabfilter-container .icon-edit:active, .btn-dashboard-page-properties:active, .btn-iterator-page-previous:active, .btn-iterator-page-next:active, .btn-widget-action:active, .btn-widget-collapse:active, .list-vertical-accordion .list-accordion-item-opened .list-accordion-item-toggle:active, .btn-widget-expand:active, .list-vertical-accordion .list-accordion-item-closed .list-accordion-item-toggle:active, .btn-widget-edit:active, .btn-alarm-on:active, .btn-alarm-off:active, .btn-sound-on:active, .btn-sound-off:active, .btn-info-clock:active, .btn-dashboard-conf:active, .interfaces .interface-row[data-type="2"] .interface-btn-toggle:active { +section .section-toggle:hover, .filter-container.tabfilter-container .icon-edit:hover, .btn-dashboard-page-properties:hover, .btn-iterator-page-previous:hover, .btn-iterator-page-next:hover, .btn-widget-action:hover, .btn-widget-collapse:hover, .list-vertical-accordion .list-accordion-item-opened .list-accordion-item-toggle:hover, .btn-widget-expand:hover, .list-vertical-accordion .list-accordion-item-closed .list-accordion-item-toggle:hover, .btn-widget-edit:hover, .btn-alarm-on:hover, .btn-alarm-off:hover, .btn-sound-on:hover, .btn-sound-off:hover, .btn-info-clock:hover, .btn-dashboard-conf:hover, .interfaces .interface-row[data-type="2"] .interface-btn-toggle:hover, section .section-toggle:focus, .filter-container.tabfilter-container .icon-edit:focus, .btn-dashboard-page-properties:focus, .btn-iterator-page-previous:focus, .btn-iterator-page-next:focus, .btn-widget-action:focus, .btn-widget-collapse:focus, .list-vertical-accordion .list-accordion-item-opened .list-accordion-item-toggle:focus, .btn-widget-expand:focus, .list-vertical-accordion .list-accordion-item-closed .list-accordion-item-toggle:focus, .btn-widget-edit:focus, .btn-alarm-on:focus, .btn-alarm-off:focus, .btn-sound-on:focus, .btn-sound-off:focus, .btn-info-clock:focus, .btn-dashboard-conf:focus, .interfaces .interface-row[data-type="2"] .interface-btn-toggle:focus, section .section-toggle:active, .filter-container.tabfilter-container .icon-edit:active, .btn-dashboard-page-properties:active, .btn-iterator-page-previous:active, .btn-iterator-page-next:active, .btn-widget-action:active, .btn-widget-collapse:active, .list-vertical-accordion .list-accordion-item-opened .list-accordion-item-toggle:active, .btn-widget-expand:active, .list-vertical-accordion .list-accordion-item-closed .list-accordion-item-toggle:active, .btn-widget-edit:active, .btn-alarm-on:active, .btn-alarm-off:active, .btn-sound-on:active, .btn-sound-off:active, .btn-info-clock:active, .btn-dashboard-conf:active, .interfaces .interface-row[data-type="2"] .interface-btn-toggle:active { background-color: transparent; opacity: 1; } @@ -6097,63 +6198,6 @@ svg { text-overflow: ellipsis; line-height: 24px; } -.columns-wrapper { - display: flex; - flex-wrap: wrap; - align-items: start; } - .columns-wrapper.columns-nowrap { - flex-wrap: nowrap; } - .columns-wrapper.columns-2 > div, - .columns-wrapper.columns-2 > li { - display: block; - flex: 0 0 50%; - max-width: 50%; } - .columns-wrapper.columns-3 > div, - .columns-wrapper.columns-3 > li { - display: block; - flex: 0 0 33.33333%; - max-width: 33.33333%; } - .columns-wrapper .column-5 { - flex: 0 0 5%; - max-width: 5%; } - .columns-wrapper .column-10 { - flex: 0 0 10%; - max-width: 10%; } - .columns-wrapper .column-15 { - flex: 0 0 15%; - max-width: 15%; } - .columns-wrapper .column-20 { - flex: 0 0 20%; - max-width: 20%; } - .columns-wrapper .column-33 { - flex: 0 0 33.33333%; - max-width: 33.33333%; } - .columns-wrapper .column-35 { - flex: 0 0 35%; - max-width: 35%; } - .columns-wrapper .column-40 { - flex: 0 0 40%; - max-width: 40%; } - .columns-wrapper .column-50 { - flex: 0 0 50%; - max-width: 50%; } - .columns-wrapper .column-75 { - flex: 0 0 75%; - max-width: 75%; } - .columns-wrapper .column-90 { - flex: 0 0 90%; - max-width: 90%; } - .columns-wrapper .column-95 { - flex: 0 0 95%; - max-width: 95%; } - .columns-wrapper .column-center { - display: flex; - justify-content: center; - text-align: center; } - .columns-wrapper .column-middle { - display: flex; - align-items: center; } - .preprocessing-list { display: block; max-width: 930px; @@ -8035,3 +8079,8 @@ td.inactive-bg { background-position: -318px -690px; } .interfaces .interface-row[data-type="2"].list-accordion-item-opened .interface-btn-toggle { background-position: -318px -655px; } + +section .section-toggle { + background-position: -318px -654px; } +section.section-collapsed .section-toggle { + background-position: -318px -690px; } diff --git a/ui/assets/styles/hc-light.css b/ui/assets/styles/hc-light.css index 39de33b24b7..45b874c15c1 100644 --- a/ui/assets/styles/hc-light.css +++ b/ui/assets/styles/hc-light.css @@ -862,6 +862,66 @@ footer { .color-picker-dialogue .color-picker-input input { padding-left: 25px; } +.columns-wrapper { + display: flex; + flex-wrap: wrap; + align-items: start; } + .columns-wrapper.columns-nowrap { + flex-wrap: nowrap; } + .columns-wrapper.columns-2 > div, + .columns-wrapper.columns-2 > li { + display: block; + flex: 0 0 50%; + max-width: 50%; } + .columns-wrapper.columns-3 > div, + .columns-wrapper.columns-3 > li { + display: block; + flex: 0 0 33.33333%; + max-width: 33.33333%; } + .columns-wrapper .column-5 { + flex: 0 0 5%; + max-width: 5%; } + .columns-wrapper .column-10 { + flex: 0 0 10%; + max-width: 10%; } + .columns-wrapper .column-15 { + flex: 0 0 15%; + max-width: 15%; } + .columns-wrapper .column-20 { + flex: 0 0 20%; + max-width: 20%; } + .columns-wrapper .column-33 { + flex: 0 0 33.33333%; + max-width: 33.33333%; } + .columns-wrapper .column-35 { + flex: 0 0 35%; + max-width: 35%; } + .columns-wrapper .column-40 { + flex: 0 0 40%; + max-width: 40%; } + .columns-wrapper .column-50 { + flex: 0 0 50%; + max-width: 50%; } + .columns-wrapper .column-75 { + flex: 0 0 75%; + max-width: 75%; } + .columns-wrapper .column-90 { + flex: 0 0 90%; + max-width: 90%; } + .columns-wrapper .column-95 { + flex: 0 0 95%; + max-width: 95%; } + .columns-wrapper .column-center { + display: flex; + justify-content: center; + text-align: center; } + .columns-wrapper .column-middle { + display: flex; + align-items: center; } + .columns-wrapper > div:not(:last-child) section, + .columns-wrapper > ul:not(:last-child) section { + margin-right: 10px; } + .header-kioskmode-controls .dashboard-kioskmode-controls li { margin-right: 6px; } @@ -1411,8 +1471,6 @@ footer { .dashboard-widget .msg-good, .dashboard-widget .msg-warning { margin: 0 10px; } - .dashboard-widget.dashboard-widget-fluid { - margin-right: 0; } .dashboard-grid-widget-content .list-table th:first-child, .dashboard-grid-widget-content .list-table td:first-child, .dashboard-grid-iterator.iterator-alt-content .dashboard-grid-iterator-content > div .list-table th:first-child, .dashboard-grid-iterator.iterator-alt-content .dashboard-grid-iterator-content > div .list-table td:first-child, .dashboard-widget .list-table th:first-child, .dashboard-widget .list-table td:first-child, .overlay-dialogue .list-table th:first-child, .overlay-dialogue .list-table td:first-child { padding-left: 10px; } @@ -2513,6 +2571,49 @@ div.dashboard-grid-widget-tophosts z-bar-gauge { font-size: 0; border-left: 1px solid #ffffff; } +section { + background-color: #ffffff; + border: 1px solid #9f9f9f; } + section .section-head { + display: flex; + height: 32px; + line-height: 32px; } + section .section-head h4 { + padding: 0 10px; + margin-right: auto; + overflow: hidden; + text-overflow: ellipsis; + font-weight: bold; + line-height: inherit; + color: #262626; } + section .section-toggle { + width: 24px; + height: 24px; + margin: 2px 2px 0 auto; + background: url("../img/icon-sprite.svg?20220519") no-repeat -6px -654px; } + section .section-foot { + padding: 0 10px; + text-align: right; + line-height: 32px; + color: #333333; } + section.section-collapsed .section-body, + section.section-collapsed .section-foot { + display: none; } + section.section-collapsed .section-toggle { + background-position: -6px -689px; } + section:not(:last-child) { + margin-bottom: 10px; } + section .list-table { + border: 0; } + section .list-table tbody tr:last-child td { + border-bottom: 1px solid #888888; } + section .list-table td:first-child, + section .list-table th:first-child { + padding-left: 10px; } + section .list-table td:last-child, + section .list-table th:last-child { + padding-right: 10px; } + .service-info { margin: -10px 0; border-left: 4px solid #009900; } @@ -4463,13 +4564,13 @@ button { width: 24px; height: 24px; } -.filter-container.tabfilter-container .icon-edit, .btn-dashboard-page-properties, .btn-iterator-page-previous, .btn-iterator-page-next, .btn-widget-action, .btn-widget-collapse, .list-vertical-accordion .list-accordion-item-opened .list-accordion-item-toggle, .btn-widget-expand, .list-vertical-accordion .list-accordion-item-closed .list-accordion-item-toggle, .btn-widget-edit, .btn-alarm-on, .btn-alarm-off, .btn-sound-on, .btn-sound-off, .btn-info-clock, .btn-dashboard-conf, .interfaces .interface-row[data-type="2"] .interface-btn-toggle { +section .section-toggle, .filter-container.tabfilter-container .icon-edit, .btn-dashboard-page-properties, .btn-iterator-page-previous, .btn-iterator-page-next, .btn-widget-action, .btn-widget-collapse, .list-vertical-accordion .list-accordion-item-opened .list-accordion-item-toggle, .btn-widget-expand, .list-vertical-accordion .list-accordion-item-closed .list-accordion-item-toggle, .btn-widget-edit, .btn-alarm-on, .btn-alarm-off, .btn-sound-on, .btn-sound-off, .btn-info-clock, .btn-dashboard-conf, .interfaces .interface-row[data-type="2"] .interface-btn-toggle { border: 0; min-height: 0; padding: 0; opacity: .5; transition: opacity .2s ease-out; } - .filter-container.tabfilter-container [disabled].icon-edit, [disabled].btn-dashboard-page-properties, [disabled].btn-iterator-page-previous, [disabled].btn-iterator-page-next, [disabled].btn-widget-action, [disabled].btn-widget-collapse, .list-vertical-accordion .list-accordion-item-opened [disabled].list-accordion-item-toggle, [disabled].btn-widget-expand, .list-vertical-accordion .list-accordion-item-closed [disabled].list-accordion-item-toggle, [disabled].btn-widget-edit, [disabled].btn-alarm-on, [disabled].btn-alarm-off, [disabled].btn-sound-on, [disabled].btn-sound-off, [disabled].btn-info-clock, [disabled].btn-dashboard-conf, .interfaces .interface-row[data-type="2"] [disabled].interface-btn-toggle, .filter-container.tabfilter-container [disabled].icon-edit:hover, [disabled].btn-dashboard-page-properties:hover, [disabled].btn-iterator-page-previous:hover, [disabled].btn-iterator-page-next:hover, [disabled].btn-widget-action:hover, [disabled].btn-widget-collapse:hover, .list-vertical-accordion .list-accordion-item-opened [disabled].list-accordion-item-toggle:hover, [disabled].btn-widget-expand:hover, .list-vertical-accordion .list-accordion-item-closed [disabled].list-accordion-item-toggle:hover, [disabled].btn-widget-edit:hover, [disabled].btn-alarm-on:hover, [disabled].btn-alarm-off:hover, [disabled].btn-sound-on:hover, [disabled].btn-sound-off:hover, [disabled].btn-info-clock:hover, [disabled].btn-dashboard-conf:hover, .interfaces .interface-row[data-type="2"] [disabled].interface-btn-toggle:hover, .filter-container.tabfilter-container [disabled].icon-edit:focus, [disabled].btn-dashboard-page-properties:focus, [disabled].btn-iterator-page-previous:focus, [disabled].btn-iterator-page-next:focus, [disabled].btn-widget-action:focus, [disabled].btn-widget-collapse:focus, .list-vertical-accordion .list-accordion-item-opened [disabled].list-accordion-item-toggle:focus, [disabled].btn-widget-expand:focus, .list-vertical-accordion .list-accordion-item-closed [disabled].list-accordion-item-toggle:focus, [disabled].btn-widget-edit:focus, [disabled].btn-alarm-on:focus, [disabled].btn-alarm-off:focus, [disabled].btn-sound-on:focus, [disabled].btn-sound-off:focus, [disabled].btn-info-clock:focus, [disabled].btn-dashboard-conf:focus, .interfaces .interface-row[data-type="2"] [disabled].interface-btn-toggle:focus, .filter-container.tabfilter-container [disabled].icon-edit:active, [disabled].btn-dashboard-page-properties:active, [disabled].btn-iterator-page-previous:active, [disabled].btn-iterator-page-next:active, [disabled].btn-widget-action:active, [disabled].btn-widget-collapse:active, .list-vertical-accordion .list-accordion-item-opened [disabled].list-accordion-item-toggle:active, [disabled].btn-widget-expand:active, .list-vertical-accordion .list-accordion-item-closed [disabled].list-accordion-item-toggle:active, [disabled].btn-widget-edit:active, [disabled].btn-alarm-on:active, [disabled].btn-alarm-off:active, [disabled].btn-sound-on:active, [disabled].btn-sound-off:active, [disabled].btn-info-clock:active, [disabled].btn-dashboard-conf:active, .interfaces .interface-row[data-type="2"] [disabled].interface-btn-toggle:active { + section [disabled].section-toggle, .filter-container.tabfilter-container [disabled].icon-edit, [disabled].btn-dashboard-page-properties, [disabled].btn-iterator-page-previous, [disabled].btn-iterator-page-next, [disabled].btn-widget-action, [disabled].btn-widget-collapse, .list-vertical-accordion .list-accordion-item-opened [disabled].list-accordion-item-toggle, [disabled].btn-widget-expand, .list-vertical-accordion .list-accordion-item-closed [disabled].list-accordion-item-toggle, [disabled].btn-widget-edit, [disabled].btn-alarm-on, [disabled].btn-alarm-off, [disabled].btn-sound-on, [disabled].btn-sound-off, [disabled].btn-info-clock, [disabled].btn-dashboard-conf, .interfaces .interface-row[data-type="2"] [disabled].interface-btn-toggle, section [disabled].section-toggle:hover, .filter-container.tabfilter-container [disabled].icon-edit:hover, [disabled].btn-dashboard-page-properties:hover, [disabled].btn-iterator-page-previous:hover, [disabled].btn-iterator-page-next:hover, [disabled].btn-widget-action:hover, [disabled].btn-widget-collapse:hover, .list-vertical-accordion .list-accordion-item-opened [disabled].list-accordion-item-toggle:hover, [disabled].btn-widget-expand:hover, .list-vertical-accordion .list-accordion-item-closed [disabled].list-accordion-item-toggle:hover, [disabled].btn-widget-edit:hover, [disabled].btn-alarm-on:hover, [disabled].btn-alarm-off:hover, [disabled].btn-sound-on:hover, [disabled].btn-sound-off:hover, [disabled].btn-info-clock:hover, [disabled].btn-dashboard-conf:hover, .interfaces .interface-row[data-type="2"] [disabled].interface-btn-toggle:hover, section [disabled].section-toggle:focus, .filter-container.tabfilter-container [disabled].icon-edit:focus, [disabled].btn-dashboard-page-properties:focus, [disabled].btn-iterator-page-previous:focus, [disabled].btn-iterator-page-next:focus, [disabled].btn-widget-action:focus, [disabled].btn-widget-collapse:focus, .list-vertical-accordion .list-accordion-item-opened [disabled].list-accordion-item-toggle:focus, [disabled].btn-widget-expand:focus, .list-vertical-accordion .list-accordion-item-closed [disabled].list-accordion-item-toggle:focus, [disabled].btn-widget-edit:focus, [disabled].btn-alarm-on:focus, [disabled].btn-alarm-off:focus, [disabled].btn-sound-on:focus, [disabled].btn-sound-off:focus, [disabled].btn-info-clock:focus, [disabled].btn-dashboard-conf:focus, .interfaces .interface-row[data-type="2"] [disabled].interface-btn-toggle:focus, section [disabled].section-toggle:active, .filter-container.tabfilter-container [disabled].icon-edit:active, [disabled].btn-dashboard-page-properties:active, [disabled].btn-iterator-page-previous:active, [disabled].btn-iterator-page-next:active, [disabled].btn-widget-action:active, [disabled].btn-widget-collapse:active, .list-vertical-accordion .list-accordion-item-opened [disabled].list-accordion-item-toggle:active, [disabled].btn-widget-expand:active, .list-vertical-accordion .list-accordion-item-closed [disabled].list-accordion-item-toggle:active, [disabled].btn-widget-edit:active, [disabled].btn-alarm-on:active, [disabled].btn-alarm-off:active, [disabled].btn-sound-on:active, [disabled].btn-sound-off:active, [disabled].btn-info-clock:active, [disabled].btn-dashboard-conf:active, .interfaces .interface-row[data-type="2"] [disabled].interface-btn-toggle:active { background-color: transparent; opacity: .25; } @@ -4497,7 +4598,7 @@ button[disabled], button[disabled]:hover, button[disabled]:active { .inaccessible .subfilter-enabled { color: #bfbfbf; } -.filter-container.tabfilter-container .icon-edit:hover, .btn-dashboard-page-properties:hover, .btn-iterator-page-previous:hover, .btn-iterator-page-next:hover, .btn-widget-action:hover, .btn-widget-collapse:hover, .list-vertical-accordion .list-accordion-item-opened .list-accordion-item-toggle:hover, .btn-widget-expand:hover, .list-vertical-accordion .list-accordion-item-closed .list-accordion-item-toggle:hover, .btn-widget-edit:hover, .btn-alarm-on:hover, .btn-alarm-off:hover, .btn-sound-on:hover, .btn-sound-off:hover, .btn-info-clock:hover, .btn-dashboard-conf:hover, .interfaces .interface-row[data-type="2"] .interface-btn-toggle:hover, .filter-container.tabfilter-container .icon-edit:focus, .btn-dashboard-page-properties:focus, .btn-iterator-page-previous:focus, .btn-iterator-page-next:focus, .btn-widget-action:focus, .btn-widget-collapse:focus, .list-vertical-accordion .list-accordion-item-opened .list-accordion-item-toggle:focus, .btn-widget-expand:focus, .list-vertical-accordion .list-accordion-item-closed .list-accordion-item-toggle:focus, .btn-widget-edit:focus, .btn-alarm-on:focus, .btn-alarm-off:focus, .btn-sound-on:focus, .btn-sound-off:focus, .btn-info-clock:focus, .btn-dashboard-conf:focus, .interfaces .interface-row[data-type="2"] .interface-btn-toggle:focus, .filter-container.tabfilter-container .icon-edit:active, .btn-dashboard-page-properties:active, .btn-iterator-page-previous:active, .btn-iterator-page-next:active, .btn-widget-action:active, .btn-widget-collapse:active, .list-vertical-accordion .list-accordion-item-opened .list-accordion-item-toggle:active, .btn-widget-expand:active, .list-vertical-accordion .list-accordion-item-closed .list-accordion-item-toggle:active, .btn-widget-edit:active, .btn-alarm-on:active, .btn-alarm-off:active, .btn-sound-on:active, .btn-sound-off:active, .btn-info-clock:active, .btn-dashboard-conf:active, .interfaces .interface-row[data-type="2"] .interface-btn-toggle:active { +section .section-toggle:hover, .filter-container.tabfilter-container .icon-edit:hover, .btn-dashboard-page-properties:hover, .btn-iterator-page-previous:hover, .btn-iterator-page-next:hover, .btn-widget-action:hover, .btn-widget-collapse:hover, .list-vertical-accordion .list-accordion-item-opened .list-accordion-item-toggle:hover, .btn-widget-expand:hover, .list-vertical-accordion .list-accordion-item-closed .list-accordion-item-toggle:hover, .btn-widget-edit:hover, .btn-alarm-on:hover, .btn-alarm-off:hover, .btn-sound-on:hover, .btn-sound-off:hover, .btn-info-clock:hover, .btn-dashboard-conf:hover, .interfaces .interface-row[data-type="2"] .interface-btn-toggle:hover, section .section-toggle:focus, .filter-container.tabfilter-container .icon-edit:focus, .btn-dashboard-page-properties:focus, .btn-iterator-page-previous:focus, .btn-iterator-page-next:focus, .btn-widget-action:focus, .btn-widget-collapse:focus, .list-vertical-accordion .list-accordion-item-opened .list-accordion-item-toggle:focus, .btn-widget-expand:focus, .list-vertical-accordion .list-accordion-item-closed .list-accordion-item-toggle:focus, .btn-widget-edit:focus, .btn-alarm-on:focus, .btn-alarm-off:focus, .btn-sound-on:focus, .btn-sound-off:focus, .btn-info-clock:focus, .btn-dashboard-conf:focus, .interfaces .interface-row[data-type="2"] .interface-btn-toggle:focus, section .section-toggle:active, .filter-container.tabfilter-container .icon-edit:active, .btn-dashboard-page-properties:active, .btn-iterator-page-previous:active, .btn-iterator-page-next:active, .btn-widget-action:active, .btn-widget-collapse:active, .list-vertical-accordion .list-accordion-item-opened .list-accordion-item-toggle:active, .btn-widget-expand:active, .list-vertical-accordion .list-accordion-item-closed .list-accordion-item-toggle:active, .btn-widget-edit:active, .btn-alarm-on:active, .btn-alarm-off:active, .btn-sound-on:active, .btn-sound-off:active, .btn-info-clock:active, .btn-dashboard-conf:active, .interfaces .interface-row[data-type="2"] .interface-btn-toggle:active { background-color: transparent; opacity: 1; } @@ -6097,63 +6198,6 @@ svg { text-overflow: ellipsis; line-height: 24px; } -.columns-wrapper { - display: flex; - flex-wrap: wrap; - align-items: start; } - .columns-wrapper.columns-nowrap { - flex-wrap: nowrap; } - .columns-wrapper.columns-2 > div, - .columns-wrapper.columns-2 > li { - display: block; - flex: 0 0 50%; - max-width: 50%; } - .columns-wrapper.columns-3 > div, - .columns-wrapper.columns-3 > li { - display: block; - flex: 0 0 33.33333%; - max-width: 33.33333%; } - .columns-wrapper .column-5 { - flex: 0 0 5%; - max-width: 5%; } - .columns-wrapper .column-10 { - flex: 0 0 10%; - max-width: 10%; } - .columns-wrapper .column-15 { - flex: 0 0 15%; - max-width: 15%; } - .columns-wrapper .column-20 { - flex: 0 0 20%; - max-width: 20%; } - .columns-wrapper .column-33 { - flex: 0 0 33.33333%; - max-width: 33.33333%; } - .columns-wrapper .column-35 { - flex: 0 0 35%; - max-width: 35%; } - .columns-wrapper .column-40 { - flex: 0 0 40%; - max-width: 40%; } - .columns-wrapper .column-50 { - flex: 0 0 50%; - max-width: 50%; } - .columns-wrapper .column-75 { - flex: 0 0 75%; - max-width: 75%; } - .columns-wrapper .column-90 { - flex: 0 0 90%; - max-width: 90%; } - .columns-wrapper .column-95 { - flex: 0 0 95%; - max-width: 95%; } - .columns-wrapper .column-center { - display: flex; - justify-content: center; - text-align: center; } - .columns-wrapper .column-middle { - display: flex; - align-items: center; } - .preprocessing-list { display: block; max-width: 930px; @@ -7946,3 +7990,8 @@ td.inactive-bg { background-position: -165px -690px; } .interfaces .interface-row[data-type="2"].list-accordion-item-opened .interface-btn-toggle { background-position: -165px -655px; } + +section .section-toggle { + background-position: -165px -654px; } +section.section-collapsed .section-toggle { + background-position: -165px -690px; } diff --git a/ui/include/classes/html/CCollapsibleUiWidget.php b/ui/include/classes/html/CCollapsibleUiWidget.php deleted file mode 100644 index 58fb46c8fd4..00000000000 --- a/ui/include/classes/html/CCollapsibleUiWidget.php +++ /dev/null @@ -1,103 +0,0 @@ -setId($this->id.'_icon') - ->onClick('changeWidgetState(this, "'.$this->id.'", "'.$idx.'");'); - - if ($this->expanded) { - $icon - ->addClass(ZBX_STYLE_BTN_WIDGET_COLLAPSE) - ->setTitle(_('Collapse')); - } - else { - $icon - ->addClass(ZBX_STYLE_BTN_WIDGET_EXPAND) - ->setTitle(_('Expand')); - } - - $controls[] = $icon; - - parent::setHeader($caption, $controls); - - return $this; - } - - /** - * Display the widget in expanded or collapsed state. - */ - protected function build() { - $body = (new CDiv($this->body)) - ->addClass('body') - ->setId($this->id); - - if (!$this->expanded) { - $body->setAttribute('style', 'display: none;'); - - if ($this->footer) { - $this->footer->setAttribute('style', 'display: none;'); - } - } - - $this->cleanItems(); - $this->addItem($this->header); - $this->addItem($body); - $this->addItem($this->footer); - - return $this; - } - - /** - * Sets expanded or collapsed state of the widget. - * - * @param bool - */ - public function setExpanded($expanded) { - $this->expanded = $expanded; - return $this; - } -} diff --git a/ui/include/classes/html/CSection.php b/ui/include/classes/html/CSection.php new file mode 100644 index 00000000000..d5c7e7e24d7 --- /dev/null +++ b/ui/include/classes/html/CSection.php @@ -0,0 +1,70 @@ +items[] = $item; + } + + return $this; + } + + public function setHeader($header_items): self { + if ($header_items !== null) { + $this->header = (new CDiv($header_items))->addClass(self::ZBX_STYLE_HEAD); + } + + return $this; + } + + public function setFooter($footer_items): self { + if ($footer_items !== null) { + $this->footer = (new CDiv($footer_items))->addClass(self::ZBX_STYLE_FOOT); + } + + return $this; + } + + public function toString($destroy = true): string { + $body = (new CDiv($this->items))->addClass(self::ZBX_STYLE_BODY); + + $this->cleanItems(); + + parent::addItem([$this->header, $body, $this->footer]); + + return parent::toString($destroy); + } +} diff --git a/ui/include/classes/html/CSectionCollapsible.php b/ui/include/classes/html/CSectionCollapsible.php new file mode 100755 index 00000000000..8dc58ac1e0d --- /dev/null +++ b/ui/include/classes/html/CSectionCollapsible.php @@ -0,0 +1,59 @@ +is_expanded = $is_expanded; + + return $this; + } + + public function setProfileIdx(string $profile_key): self { + $this->profile_key = $profile_key; + + return $this; + } + + public function toString($destroy = true): string { + $this->addClass($this->is_expanded ? null : self::ZBX_STYLE_COLLAPSED); + + $toggle = (new CSimpleButton()) + ->addClass(self::ZBX_STYLE_TOGGLE) + ->setTitle($this->is_expanded ? _('Collapse') : _('Expand')) + ->onClick('toggleSection("'.$this->getId().'", "'.$this->profile_key.'");'); + + if ($this->header === null) { + $this->setHeader($toggle); + } + else { + $this->header->addItem($toggle); + } + + return parent::toString($destroy); + } +} diff --git a/ui/include/classes/html/CUiWidget.php b/ui/include/classes/html/CUiWidget.php deleted file mode 100644 index 0823642534b..00000000000 --- a/ui/include/classes/html/CUiWidget.php +++ /dev/null @@ -1,136 +0,0 @@ -id = $id; - $this->body = $body ? [$body] : []; - - parent::__construct(); - - $this->addClass(ZBX_STYLE_DASHBOARD_WIDGET); - $this->setId($this->id.'_widget'); - } - - /** - * Set widget header. - * - * @param string $caption - * @param array $controls - * - * @return $this - */ - public function setHeader($caption, array $controls = []) { - $this->header = (new CDiv()) - ->addClass(ZBX_STYLE_DASHBOARD_WIDGET_HEAD) - ->addItem( - (new CTag('h4', true, $caption))->setId($this->id.'_header') - ); - - if ($controls) { - $this->header->addItem(new CList($controls)); - } - - return $this; - } - - /** - * Set widget footer. - * - * @param string|array|CTag $footer - * @param bool $right - */ - public function setFooter($list) { - $this->footer = $list; - $this->footer->addClass(ZBX_STYLE_DASHBOARD_WIDGET_FOOT); - return $this; - } - - /** - * Build widget header, body and footer. - */ - protected function build() { - $body = (new CDiv($this->body)) - ->setId($this->id); - - $this->cleanItems(); - - $this->addItem($this->header); - $this->addItem($body); - $this->addItem($this->footer); - return $this; - } - - /** - * Get widget html. - */ - public function toString($destroy = true) { - $this->build(); - - return parent::toString($destroy); - } -} diff --git a/ui/include/defines.inc.php b/ui/include/defines.inc.php index 68ec1e42c8a..d0f66edf0e6 100644 --- a/ui/include/defines.inc.php +++ b/ui/include/defines.inc.php @@ -1646,16 +1646,17 @@ define('WIDGET_FIELD_SELECT_RES_SYSMAP', 1); // max depth of navigation tree define('WIDGET_NAVIGATION_TREE_MAX_DEPTH', 10); -// event details widgets -define('WIDGET_HAT_TRIGGERDETAILS', 'hat_triggerdetails'); -define('WIDGET_HAT_EVENTDETAILS', 'hat_eventdetails'); -define('WIDGET_HAT_EVENTACTIONS', 'hat_eventactions'); -define('WIDGET_HAT_EVENTLIST', 'hat_eventlist'); -// search widget -define('WIDGET_SEARCH_HOSTS', 'search_hosts'); -define('WIDGET_SEARCH_HOSTGROUP', 'search_hostgroup'); -define('WIDGET_SEARCH_TEMPLATES', 'search_templates'); -define('WIDGET_SEARCH_TEMPLATEGROUP', 'search_templategroup'); +// event details sections +define('SECTION_HAT_TRIGGERDETAILS', 'hat_triggerdetails'); +define('SECTION_HAT_EVENTDETAILS', 'hat_eventdetails'); +define('SECTION_HAT_EVENTACTIONS', 'hat_eventactions'); +define('SECTION_HAT_EVENTLIST', 'hat_eventlist'); + +// search sections +define('SECTION_SEARCH_HOSTS', 'search_hosts'); +define('SECTION_SEARCH_HOSTGROUP', 'search_hostgroup'); +define('SECTION_SEARCH_TEMPLATES', 'search_templates'); +define('SECTION_SEARCH_TEMPLATEGROUP', 'search_templategroup'); // dashboard widget dynamic state define('WIDGET_SIMPLE_ITEM', 0); @@ -1891,7 +1892,6 @@ define('ZBX_STYLE_DASHBOARD_PREVIOUS_PAGE', 'dashboard-previous-page'); define('ZBX_STYLE_DASHBOARD_NEXT_PAGE', 'dashboard-next-page'); define('ZBX_STYLE_DASHBOARD_TOGGLE_SLIDESHOW', 'dashboard-toggle-slideshow'); define('ZBX_STYLE_DASHBOARD_WIDGET', 'dashboard-widget'); -define('ZBX_STYLE_DASHBOARD_WIDGET_FLUID', 'dashboard-widget-fluid'); define('ZBX_STYLE_DASHBOARD_WIDGET_HEAD', 'dashboard-widget-head'); define('ZBX_STYLE_DASHBOARD_WIDGET_FOOT', 'dashboard-widget-foot'); define('ZBX_STYLE_DASHBOARD_EDIT', 'dashboard-edit'); diff --git a/ui/js/main.js b/ui/js/main.js index 0ce1b032736..e2f19e5739a 100644 --- a/ui/js/main.js +++ b/ui/js/main.js @@ -688,25 +688,23 @@ function updateUserProfile(idx, value, idx2, profile_type = PROFILE_TYPE_INT) { }); } -function changeWidgetState(obj, widgetId, idx) { - var widgetObj = jQuery('#' + widgetId + '_widget'), - css = switchElementClass(obj, 'btn-widget-collapse', 'btn-widget-expand'), - state = 0; - - if (css === 'btn-widget-expand') { - jQuery('.body', widgetObj).slideUp(50); - jQuery('.dashboard-widget-foot', widgetObj).slideUp(50); - } - else { - jQuery('.body', widgetObj).slideDown(50); - jQuery('.dashboard-widget-foot', widgetObj).slideDown(50); +/** + * Section collapse toggle. + * + * @param {string} id + * @param {string|null} profile_idx If not null, stores state in profile. + */ +function toggleSection(id, profile_idx) { + const section = document.getElementById(id); + const toggle = section.querySelector('.section-toggle'); - state = 1; - } + let is_collapsed = section.classList.contains('section-collapsed'); + + section.classList.toggle('section-collapsed', !is_collapsed); + toggle.setAttribute('title', is_collapsed ? t('S_COLLAPSE') : t('S_EXPAND')); - obj.title = (state == 1) ? t('S_COLLAPSE') : t('S_EXPAND'); - if (idx !== '' && typeof idx !== 'undefined') { - updateUserProfile(idx, state, []); + if (profile_idx !== null) { + updateUserProfile(profile_idx, is_collapsed ? '1' : '0', []); } } diff --git a/ui/tr_events.php b/ui/tr_events.php index cbdeaf635e6..8e0c8814885 100644 --- a/ui/tr_events.php +++ b/ui/tr_events.php @@ -161,22 +161,24 @@ require_once dirname(__FILE__).'/include/views/js/tr_events.js.php'; $event_tab = (new CDiv([ new CDiv([ - (new CUiWidget(WIDGET_HAT_TRIGGERDETAILS, make_trigger_details($trigger, $event['eventid']))) - ->setHeader(_('Trigger details')), - (new CUiWidget(WIDGET_HAT_EVENTDETAILS, make_event_details($event, $allowed))) - ->setHeader(_('Event details')) + (new CSection(make_trigger_details($trigger, $event['eventid']))) + ->setId(SECTION_HAT_TRIGGERDETAILS) + ->setHeader(new CTag('h4', true, _('Trigger details'))), + (new CSection(make_event_details($event, $allowed))) + ->setId(SECTION_HAT_EVENTDETAILS) + ->setHeader(new CTag('h4', true, _('Event details'))) ]), new CDiv([ - (new CCollapsibleUiWidget(WIDGET_HAT_EVENTACTIONS, - makeEventDetailsActionsTable($actions, $users, $mediatypes) - )) - ->setExpanded((bool) CProfile::get('web.tr_events.hats.'.WIDGET_HAT_EVENTACTIONS.'.state', true)) - ->setHeader(_('Actions'), [], 'web.tr_events.hats.'.WIDGET_HAT_EVENTACTIONS.'.state') - ->addClass(ZBX_STYLE_DASHBOARD_WIDGET_FLUID), - (new CCollapsibleUiWidget(WIDGET_HAT_EVENTLIST, make_small_eventlist($event, $allowed))) - ->setExpanded((bool) CProfile::get('web.tr_events.hats.'.WIDGET_HAT_EVENTLIST.'.state', true)) - ->setHeader(_('Event list [previous 20]'), [], 'web.tr_events.hats.'.WIDGET_HAT_EVENTLIST.'.state') - ->addClass(ZBX_STYLE_DASHBOARD_WIDGET_FLUID) + (new CSectionCollapsible(makeEventDetailsActionsTable($actions, $users, $mediatypes))) + ->setId(SECTION_HAT_EVENTACTIONS) + ->setHeader(new CTag('h4', true, _('Actions'))) + ->setProfileIdx('web.tr_events.hats.'.SECTION_HAT_EVENTACTIONS.'.state') + ->setExpanded((bool) CProfile::get('web.tr_events.hats.'.SECTION_HAT_EVENTACTIONS.'.state', true)), + (new CSectionCollapsible(make_small_eventlist($event, $allowed))) + ->setId(SECTION_HAT_EVENTLIST) + ->setHeader(new CTag('h4', true, _('Event list [previous 20]'))) + ->setProfileIdx('web.tr_events.hats.'.SECTION_HAT_EVENTLIST.'.state') + ->setExpanded((bool) CProfile::get('web.tr_events.hats.'.SECTION_HAT_EVENTLIST.'.state', true)), ]) ])) ->addClass(ZBX_STYLE_COLUMNS) -- cgit v1.2.3 From f8f875bea95e75c312100eef2b50f52a7e53fe95 Mon Sep 17 00:00:00 2001 From: Alexander Shubin Date: Mon, 1 Aug 2022 12:23:31 +0300 Subject: ..F....... [ZBXNEXT-7469] refactored CWidget class to CHtmlPage; fixed CSection item adding --- .../partials/configuration.hostgroup.edit.html.php | 2 +- .../configuration.templategroup.edit.html.php | 2 +- .../views/administration.audit.settings.edit.php | 6 +- .../views/administration.authentication.edit.php | 6 +- ui/app/views/administration.autoreg.edit.php | 6 +- ui/app/views/administration.geomaps.edit.php | 6 +- ui/app/views/administration.gui.edit.php | 6 +- ui/app/views/administration.housekeeping.edit.php | 6 +- ui/app/views/administration.iconmap.edit.php | 6 +- ui/app/views/administration.iconmap.list.php | 4 +- ui/app/views/administration.image.edit.php | 6 +- ui/app/views/administration.image.list.php | 8 +- ui/app/views/administration.macros.edit.php | 6 +- ui/app/views/administration.mediatype.edit.php | 8 +- ui/app/views/administration.mediatype.list.php | 4 +- ui/app/views/administration.miscconfig.edit.php | 6 +- ui/app/views/administration.module.edit.php | 13 +- ui/app/views/administration.module.list.php | 11 +- ui/app/views/administration.queue.details.php | 4 +- ui/app/views/administration.queue.overview.php | 4 +- .../views/administration.queue.overview.proxy.php | 4 +- ui/app/views/administration.regex.edit.php | 6 +- ui/app/views/administration.regex.list.php | 4 +- ui/app/views/administration.script.edit.php | 8 +- ui/app/views/administration.script.list.php | 4 +- ui/app/views/administration.token.list.php | 4 +- ui/app/views/administration.trigdisplay.edit.php | 6 +- ui/app/views/administration.user.edit.php | 11 +- ui/app/views/administration.user.list.php | 4 +- ui/app/views/administration.user.token.list.php | 4 +- ui/app/views/administration.usergroup.edit.php | 10 +- ui/app/views/administration.usergroup.list.php | 7 +- ui/app/views/administration.userrole.edit.php | 10 +- ui/app/views/administration.userrole.list.php | 7 +- ui/app/views/configuration.correlation.edit.php | 10 +- ui/app/views/configuration.correlation.list.php | 8 +- ui/app/views/configuration.dashboard.edit.php | 4 +- ui/app/views/configuration.dashboard.list.php | 2 +- ui/app/views/configuration.discovery.edit.php | 10 +- ui/app/views/configuration.discovery.list.php | 9 +- ui/app/views/configuration.host.edit.php | 2 +- ui/app/views/configuration.host.list.php | 6 +- ui/app/views/configuration.hostgroup.edit.php | 2 +- ui/app/views/configuration.hostgroup.list.php | 4 +- ui/app/views/configuration.templategroup.edit.php | 2 +- ui/app/views/configuration.templategroup.list.php | 4 +- ui/app/views/js/monitoring.dashboard.view.js.php | 2 +- ui/app/views/monitoring.charts.view.php | 12 +- ui/app/views/monitoring.dashboard.list.php | 9 +- ui/app/views/monitoring.dashboard.print.php | 2 +- ui/app/views/monitoring.dashboard.view.php | 6 +- ui/app/views/monitoring.discovery.view.php | 4 +- ui/app/views/monitoring.host.dashboard.view.php | 10 +- ui/app/views/monitoring.host.view.php | 17 +- ui/app/views/monitoring.latest.view.php | 18 +- ui/app/views/monitoring.map.view.php | 2 +- ui/app/views/monitoring.problem.view.php | 6 +- ui/app/views/monitoring.web.view.php | 2 +- ui/app/views/popup.condition.common.php | 2 +- ui/app/views/popup.import.php | 2 +- ui/app/views/popup.massupdate.host.php | 2 +- ui/app/views/popup.massupdate.item.php | 2 +- ui/app/views/popup.massupdate.template.php | 2 +- ui/app/views/popup.massupdate.trigger.php | 2 +- ui/app/views/popup.token.edit.php | 2 +- ui/app/views/popup.token.view.php | 2 +- ui/app/views/popup.view.php | 2 +- ui/app/views/proxy.list.php | 2 +- ui/app/views/report.status.php | 2 +- ui/app/views/reports.auditlog.list.php | 4 +- ui/app/views/reports.scheduledreport.edit.php | 6 +- ui/app/views/reports.scheduledreport.list.php | 4 +- ui/app/views/search.php | 2 +- ui/app/views/service.list.edit.php | 2 +- ui/app/views/service.list.php | 2 +- ui/app/views/sla.list.php | 2 +- ui/app/views/slareport.list.php | 4 +- ui/hostinventoriesoverview.php | 2 +- ui/httpdetails.php | 2 +- ui/include/classes/helpers/CDocHelper.php | 6 +- ui/include/classes/html/CHtmlPage.php | 186 ++++++++++++++++++ ui/include/classes/html/CSection.php | 6 +- ui/include/classes/html/CSectionCollapsible.php | 4 +- ui/include/classes/html/widget/CWidget.php | 207 --------------------- ui/include/defines.inc.php | 1 - ui/include/func.inc.php | 2 +- ui/include/html.inc.php | 4 +- ui/include/validate.inc.php | 2 +- ui/include/views/administration.auditacts.list.php | 11 +- ui/include/views/configuration.action.edit.php | 11 +- ui/include/views/configuration.action.list.php | 9 +- ui/include/views/configuration.copy.elements.php | 10 +- ui/include/views/configuration.graph.edit.php | 15 +- ui/include/views/configuration.graph.list.php | 15 +- .../views/configuration.host.discovery.edit.php | 8 +- .../views/configuration.host.discovery.list.php | 13 +- .../views/configuration.host.prototype.edit.php | 9 +- .../views/configuration.host.prototype.list.php | 9 +- ui/include/views/configuration.httpconf.edit.php | 10 +- ui/include/views/configuration.httpconf.list.php | 13 +- ui/include/views/configuration.item.edit.php | 10 +- ui/include/views/configuration.item.list.php | 13 +- .../views/configuration.item.prototype.edit.php | 10 +- .../views/configuration.item.prototype.list.php | 9 +- .../views/configuration.maintenance.edit.php | 10 +- .../views/configuration.maintenance.list.php | 9 +- ui/include/views/configuration.template.edit.php | 11 +- ui/include/views/configuration.template.list.php | 8 +- .../views/configuration.trigger.prototype.edit.php | 10 +- .../views/configuration.trigger.prototype.list.php | 9 +- ui/include/views/configuration.triggers.edit.php | 12 +- ui/include/views/configuration.triggers.list.php | 13 +- ui/include/views/inventory.host.list.php | 10 +- ui/include/views/inventory.host.view.php | 9 +- ui/include/views/monitoring.history.php | 18 +- ui/include/views/monitoring.sysmap.constructor.php | 2 +- ui/include/views/monitoring.sysmap.edit.php | 9 +- ui/include/views/monitoring.sysmap.list.php | 9 +- ui/include/views/reports.toptriggers.php | 2 +- ui/js/main.js | 2 +- ui/report2.php | 12 +- ui/report4.php | 6 +- .../modules/module_number_1/views/first.module.php | 2 +- .../module_number_2/views/second.module.php | 2 +- .../modules/module_number_3/views/third.module.php | 2 +- .../modules/module_number_4/views/forth.module.php | 2 +- .../modules/module_number_5/views/fifth.module.php | 2 +- ui/tr_events.php | 5 +- 128 files changed, 582 insertions(+), 601 deletions(-) create mode 100644 ui/include/classes/html/CHtmlPage.php delete mode 100644 ui/include/classes/html/widget/CWidget.php diff --git a/ui/app/partials/configuration.hostgroup.edit.html.php b/ui/app/partials/configuration.hostgroup.edit.html.php index 4f8c5fdeffe..af6969964dd 100644 --- a/ui/app/partials/configuration.hostgroup.edit.html.php +++ b/ui/app/partials/configuration.hostgroup.edit.html.php @@ -27,7 +27,7 @@ $form = (new CForm()) ->setId('hostgroupForm') ->setName('hostgroupForm') - ->setAttribute('aria-labeledby', ZBX_STYLE_PAGE_TITLE) + ->setAttribute('aria-labeledby', CHtmlPage::PAGE_TITLE_ID) ->addVar('groupid', $data['groupid']) ->addItem((new CInput('submit', null))->addStyle('display: none;')); diff --git a/ui/app/partials/configuration.templategroup.edit.html.php b/ui/app/partials/configuration.templategroup.edit.html.php index 6a1fe66758d..165a4693bd0 100644 --- a/ui/app/partials/configuration.templategroup.edit.html.php +++ b/ui/app/partials/configuration.templategroup.edit.html.php @@ -27,7 +27,7 @@ $form = (new CForm()) ->setId('templategroupForm') ->setName('templategroupForm') - ->setAttribute('aria-labeledby', ZBX_STYLE_PAGE_TITLE) + ->setAttribute('aria-labeledby', CHtmlPage::PAGE_TITLE_ID) ->addVar('groupid', $data['groupid']) ->addItem((new CInput('submit'))->addStyle('display: none;')); diff --git a/ui/app/views/administration.audit.settings.edit.php b/ui/app/views/administration.audit.settings.edit.php index 04f88ba6286..c3df20beaef 100644 --- a/ui/app/views/administration.audit.settings.edit.php +++ b/ui/app/views/administration.audit.settings.edit.php @@ -25,7 +25,7 @@ $this->includeJsFile('administration.audit.settings.edit.js.php'); -$widget = (new CWidget()) +$html_page = (new CHtmlPage()) ->setTitle(_('Audit log')) ->setTitleSubmenu(getAdministrationGeneralSubmenu()) ->setDocUrl(CDocHelper::getUrl(CDocHelper::ADMINISTRATION_AUDIT_SETTINGS_EDIT)); @@ -37,7 +37,7 @@ $form = (new CForm()) ->setArgument('action', 'audit.settings.update') ->getUrl() ) - ->setAttribute('aria-labeledby', ZBX_STYLE_PAGE_TITLE); + ->setAttribute('aria-labeledby', CHtmlPage::PAGE_TITLE_ID); $audit_settings_tab = (new CFormGrid()) ->addItem([ @@ -67,6 +67,6 @@ $form->addItem( )) ); -$widget +$html_page ->addItem($form) ->show(); diff --git a/ui/app/views/administration.authentication.edit.php b/ui/app/views/administration.authentication.edit.php index 92d44770ce5..316cff63e65 100644 --- a/ui/app/views/administration.authentication.edit.php +++ b/ui/app/views/administration.authentication.edit.php @@ -333,14 +333,14 @@ $saml_tab = (new CFormGrid()) ) ]); -(new CWidget()) +(new CHtmlPage()) ->setTitle(_('Authentication')) ->setDocUrl(CDocHelper::getUrl(CDocHelper::ADMINISTRATION_AUTHENTICATION_EDIT)) ->addItem((new CForm()) ->addVar('action', $data['action_submit']) ->addVar('ldap_removed_userdirectoryids', $data['ldap_removed_userdirectoryids']) ->setId('authentication-form') - ->setAttribute('aria-labeledby', ZBX_STYLE_PAGE_TITLE) + ->setAttribute('aria-labeledby', CHtmlPage::PAGE_TITLE_ID) ->disablePasswordAutofill() ->addItem((new CTabView()) ->setSelected($data['form_refresh'] ? null : 0) @@ -356,7 +356,7 @@ $saml_tab = (new CFormGrid()) ->show(); (new CScriptTag( - 'view.init('. json_encode([ + 'view.init('.json_encode([ 'ldap_servers' => $data['ldap_servers'], 'ldap_default_row_index' => $data['ldap_default_row_index'], 'db_authentication_type' => $data['db_authentication_type'] diff --git a/ui/app/views/administration.autoreg.edit.php b/ui/app/views/administration.autoreg.edit.php index 77513a28b4d..a37509e4382 100644 --- a/ui/app/views/administration.autoreg.edit.php +++ b/ui/app/views/administration.autoreg.edit.php @@ -25,7 +25,7 @@ $this->includeJsFile('administration.autoreg.edit.js.php'); -$widget = (new CWidget()) +$html_page = (new CHtmlPage()) ->setTitle(_('Autoregistration')) ->setTitleSubmenu(getAdministrationGeneralSubmenu()) ->setDocUrl(CDocHelper::getUrl(CDocHelper::ADMINISTRATION_AUTOREG_EDIT)); @@ -37,7 +37,7 @@ $autoreg_form = (new CForm()) ->setArgument('action', 'autoreg.edit') ->getUrl() ) - ->setAttribute('aria-labeledby', ZBX_STYLE_PAGE_TITLE) + ->setAttribute('aria-labeledby', CHtmlPage::PAGE_TITLE_ID) ->addVar('tls_accept', $data['tls_accept']); $autoreg_tab = (new CFormList()) @@ -92,6 +92,6 @@ $autoreg_view = (new CTabView()) $autoreg_form->addItem($autoreg_view); -$widget +$html_page ->addItem($autoreg_form) ->show(); diff --git a/ui/app/views/administration.geomaps.edit.php b/ui/app/views/administration.geomaps.edit.php index 1f06ff0bd24..7ae2553a34c 100644 --- a/ui/app/views/administration.geomaps.edit.php +++ b/ui/app/views/administration.geomaps.edit.php @@ -114,7 +114,7 @@ $form = (new CForm()) ->setArgument('action', 'geomaps.update') ->getUrl() ) - ->setAttribute('aria-labeledby', ZBX_STYLE_PAGE_TITLE) + ->setAttribute('aria-labeledby', CHtmlPage::PAGE_TITLE_ID) ->addItem( (new CTabView()) ->addTab('geomaps_tab', _('Geographical maps'), $form_grid) @@ -123,7 +123,7 @@ $form = (new CForm()) )) ); -(new CWidget()) +(new CHtmlPage()) ->setTitle(_('Geographical maps')) ->setTitleSubmenu(getAdministrationGeneralSubmenu()) ->setDocUrl(CDocHelper::getUrl(CDocHelper::ADMINISTRATION_GEOMAPS_EDIT)) @@ -131,7 +131,7 @@ $form = (new CForm()) ->show(); (new CScriptTag( - 'view.init('. json_encode([ + 'view.init('.json_encode([ 'tile_providers' => $data['tile_providers'] ]).');' )) diff --git a/ui/app/views/administration.gui.edit.php b/ui/app/views/administration.gui.edit.php index 21a51aa0d57..c0fede58649 100644 --- a/ui/app/views/administration.gui.edit.php +++ b/ui/app/views/administration.gui.edit.php @@ -25,7 +25,7 @@ $this->includeJsFile('administration.gui.edit.js.php'); -$widget = (new CWidget()) +$html_page = (new CHtmlPage()) ->setTitle(_('GUI')) ->setTitleSubmenu(getAdministrationGeneralSubmenu()) ->setDocUrl(CDocHelper::getUrl(CDocHelper::ADMINISTRATION_GUI_EDIT)); @@ -149,13 +149,13 @@ $gui_view = (new CTabView()) )); $form = (new CForm()) - ->setAttribute('aria-labeledby', ZBX_STYLE_PAGE_TITLE) + ->setAttribute('aria-labeledby', CHtmlPage::PAGE_TITLE_ID) ->setAction((new CUrl('zabbix.php')) ->setArgument('action', 'gui.update') ->getUrl() ) ->addItem($gui_view); -$widget +$html_page ->addItem($form) ->show(); diff --git a/ui/app/views/administration.housekeeping.edit.php b/ui/app/views/administration.housekeeping.edit.php index 1fcfa05cfa0..f44e95b2e07 100644 --- a/ui/app/views/administration.housekeeping.edit.php +++ b/ui/app/views/administration.housekeeping.edit.php @@ -25,7 +25,7 @@ $this->includeJsFile('administration.housekeeping.edit.js.php'); -$widget = (new CWidget()) +$html_page = (new CHtmlPage()) ->setTitle(_('Housekeeping')) ->setTitleSubmenu(getAdministrationGeneralSubmenu()) ->setDocUrl(CDocHelper::getUrl(CDocHelper::ADMINISTRATION_HOUSEKEEPING_EDIT)); @@ -36,7 +36,7 @@ $form = (new CForm()) ->setArgument('action', 'housekeeping.update') ->getUrl() ) - ->setAttribute('aria-labeledby', ZBX_STYLE_PAGE_TITLE); + ->setAttribute('aria-labeledby', CHtmlPage::PAGE_TITLE_ID); $house_keeper_tab = (new CFormList()) ->addRow((new CTag('h4', true, _('Events and alerts')))->addClass('input-section-header')) @@ -240,6 +240,6 @@ $form->addItem( )) ); -$widget +$html_page ->addItem($form) ->show(); diff --git a/ui/app/views/administration.iconmap.edit.php b/ui/app/views/administration.iconmap.edit.php index 4c807b49329..72b3308c6e6 100644 --- a/ui/app/views/administration.iconmap.edit.php +++ b/ui/app/views/administration.iconmap.edit.php @@ -25,7 +25,7 @@ $this->includeJsFile('administration.iconmap.edit.js.php'); -$widget = (new CWidget()) +$html_page = (new CHtmlPage()) ->setTitle(_('Icon mapping')) ->setTitleSubmenu(getAdministrationGeneralSubmenu()) ->setDocUrl(CDocHelper::getUrl(CDocHelper::ADMINISTRATION_ICONMAP_EDIT)); @@ -46,7 +46,7 @@ $form = (new CForm()) ->setArgument('action', ($data['iconmapid'] != 0) ? 'iconmap.update' : 'iconmap.create') ->getUrl() ) - ->setAttribute('aria-labeledby', ZBX_STYLE_PAGE_TITLE) + ->setAttribute('aria-labeledby', CHtmlPage::PAGE_TITLE_ID) ->addVar('form', 1); if ($data['iconmapid'] != 0) { @@ -162,4 +162,4 @@ else { $form->addItem($tab); -$widget->addItem($form)->show(); +$html_page->addItem($form)->show(); diff --git a/ui/app/views/administration.iconmap.list.php b/ui/app/views/administration.iconmap.list.php index f3aca4fac78..69d978214c7 100644 --- a/ui/app/views/administration.iconmap.list.php +++ b/ui/app/views/administration.iconmap.list.php @@ -23,7 +23,7 @@ * @var CView $this */ -$widget = (new CWidget()) +$html_page = (new CHtmlPage()) ->setTitle(_('Icon mapping')) ->setTitleSubmenu(getAdministrationGeneralSubmenu()) ->setDocUrl(CDocHelper::getUrl(CDocHelper::ADMINISTRATION_ICONMAP_LIST)) @@ -52,4 +52,4 @@ foreach ($data['iconmaps'] as $icon_map) { ), $row]); } -$widget->addItem($table)->show(); +$html_page->addItem($table)->show(); diff --git a/ui/app/views/administration.image.edit.php b/ui/app/views/administration.image.edit.php index dbcb256673a..d37b7514bb2 100644 --- a/ui/app/views/administration.image.edit.php +++ b/ui/app/views/administration.image.edit.php @@ -25,7 +25,7 @@ $this->includeJsFile('administration.image.edit.js.php'); -$widget = (new CWidget()) +$html_page = (new CHtmlPage()) ->setTitle(_('Images')) ->setTitleSubmenu(getAdministrationGeneralSubmenu()) ->setDocUrl(CDocHelper::getUrl(CDocHelper::ADMINISTRATION_IMAGE_EDIT)); @@ -34,7 +34,7 @@ $form = (new CForm('post', (new CUrl('zabbix.php')) ->setArgument('action', ($data['imageid'] == 0) ? 'image.create' : 'image.update') ->getUrl(), 'multipart/form-data') ) - ->setAttribute('aria-labeledby', ZBX_STYLE_PAGE_TITLE) + ->setAttribute('aria-labeledby', CHtmlPage::PAGE_TITLE_ID) ->addVar('imagetype', $data['imagetype']); if ($data['imageid'] != 0) { @@ -103,4 +103,4 @@ else { )); } -$widget->addItem($form->addItem($tab_view))->show(); +$html_page->addItem($form->addItem($tab_view))->show(); diff --git a/ui/app/views/administration.image.list.php b/ui/app/views/administration.image.list.php index 742da721d01..de68260aa3c 100644 --- a/ui/app/views/administration.image.list.php +++ b/ui/app/views/administration.image.list.php @@ -26,7 +26,7 @@ $this->includeJsFile('administration.image.list.js.php'); $page_url = (new CUrl('zabbix.php'))->setArgument('action', 'image.list'); -$widget = (new CWidget()) +$html_page = (new CHtmlPage()) ->setTitle(_('Images')) ->setTitleSubmenu(getAdministrationGeneralSubmenu()) ->setDocUrl(CDocHelper::getUrl(CDocHelper::ADMINISTRATION_IMAGE_LIST)) @@ -72,7 +72,7 @@ $widget = (new CWidget()) ); if (!$data['images']) { - $widget->addItem(new CTableInfo()); + $html_page->addItem(new CTableInfo()); } else { $image_table = (new CDiv()) @@ -113,14 +113,14 @@ else { $image_table->addItem($image_row); } - $widget->addItem( + $html_page->addItem( (new CForm())->addItem( (new CTabView())->addTab('image', null, $image_table) ) ); } -$widget->show(); +$html_page->show(); (new CScriptTag(' view.init('.json_encode([ diff --git a/ui/app/views/administration.macros.edit.php b/ui/app/views/administration.macros.edit.php index 06728efbac2..846465e4bce 100644 --- a/ui/app/views/administration.macros.edit.php +++ b/ui/app/views/administration.macros.edit.php @@ -25,7 +25,7 @@ $this->includeJsFile('administration.macros.edit.js.php'); -$widget = (new CWidget()) +$html_page = (new CHtmlPage()) ->setTitle(_('Macros')) ->setTitleSubmenu(getAdministrationGeneralSubmenu()) ->setDocUrl(CDocHelper::getUrl(CDocHelper::ADMINISTRATION_MACROS_EDIT)); @@ -104,9 +104,9 @@ $form = (new CForm()) ->setName('macrosForm') ->disablePasswordAutofill() ->setAction((new CUrl('zabbix.php'))->setArgument('action', 'macros.update')->getUrl()) - ->setAttribute('aria-labeledby', ZBX_STYLE_PAGE_TITLE) + ->setAttribute('aria-labeledby', CHtmlPage::PAGE_TITLE_ID) ->addItem($tab_view); -$widget +$html_page ->addItem($form) ->show(); diff --git a/ui/app/views/administration.mediatype.edit.php b/ui/app/views/administration.mediatype.edit.php index c14bc4cf0e2..ea7e7515553 100644 --- a/ui/app/views/administration.mediatype.edit.php +++ b/ui/app/views/administration.mediatype.edit.php @@ -27,7 +27,7 @@ $this->addJsFile('multilineinput.js'); $this->includeJsFile('administration.mediatype.edit.js.php'); -$widget = (new CWidget()) +$html_page = (new CHtmlPage()) ->setTitle(_('Media types')) ->setDocUrl(CDocHelper::getUrl(CDocHelper::ADMINISTRATION_MEDIATYPE_EDIT)); @@ -44,7 +44,7 @@ $mediaTypeForm = (new CForm()) ->addVar('mediatypeid', $data['mediatypeid']) ->addItem((new CVar('status', MEDIA_TYPE_STATUS_DISABLED))->removeId()) ->disablePasswordAutofill() - ->setAttribute('aria-labeledby', ZBX_STYLE_PAGE_TITLE); + ->setAttribute('aria-labeledby', CHtmlPage::PAGE_TITLE_ID); // Create form list. $mediatype_formlist = (new CFormList()) @@ -195,7 +195,7 @@ $row_template = (new CTag('script', true)) ]))->addClass('form_row') ); -$widget->addItem($row_template); +$html_page->addItem($row_template); $parameters_table->addRow([(new CButton('parameter_add', _('Add'))) ->addClass(ZBX_STYLE_BTN_LINK) @@ -383,4 +383,4 @@ else { $mediaTypeForm->addItem($tabs); // append form to widget -$widget->addItem($mediaTypeForm)->show(); +$html_page->addItem($mediaTypeForm)->show(); diff --git a/ui/app/views/administration.mediatype.list.php b/ui/app/views/administration.mediatype.list.php index 61ae9bdc5fd..6926fa1a02d 100644 --- a/ui/app/views/administration.mediatype.list.php +++ b/ui/app/views/administration.mediatype.list.php @@ -27,7 +27,7 @@ if ($data['uncheck']) { uncheckTableRows('mediatype'); } -$widget = (new CWidget()) +$html_page = (new CHtmlPage()) ->setTitle(_('Media types')) ->setDocUrl(CDocHelper::getUrl(CDocHelper::ADMINISTRATION_MEDIATYPE_LIST)) ->setControls((new CTag('nav', true, @@ -194,4 +194,4 @@ $mediaTypeForm->addItem([ ]); // append form to widget -$widget->addItem($mediaTypeForm)->show(); +$html_page->addItem($mediaTypeForm)->show(); diff --git a/ui/app/views/administration.miscconfig.edit.php b/ui/app/views/administration.miscconfig.edit.php index 83969f4db77..2c715f5edb9 100644 --- a/ui/app/views/administration.miscconfig.edit.php +++ b/ui/app/views/administration.miscconfig.edit.php @@ -26,7 +26,7 @@ $this->includeJsFile('administration.miscconfig.edit.js.php'); -$widget = (new CWidget()) +$html_page = (new CHtmlPage()) ->setTitle(_('Other configuration parameters')) ->setTitleSubmenu(getAdministrationGeneralSubmenu()) ->setDocUrl(CDocHelper::getUrl(CDocHelper::ADMINISTRATION_MISCCONFIG_EDIT)); @@ -189,7 +189,7 @@ $form = (new CForm()) ->setArgument('action', 'miscconfig.update') ->getUrl() ) - ->setAttribute('aria-labeledby', ZBX_STYLE_PAGE_TITLE) + ->setAttribute('aria-labeledby', CHtmlPage::PAGE_TITLE_ID) ->addItem( (new CTabView()) ->addTab('other', _('Other parameters'), $from_list) @@ -199,7 +199,7 @@ $form = (new CForm()) )) ); -$widget +$html_page ->addItem($form) ->show(); diff --git a/ui/app/views/administration.module.edit.php b/ui/app/views/administration.module.edit.php index 0eadadab2fb..173a12d08c5 100644 --- a/ui/app/views/administration.module.edit.php +++ b/ui/app/views/administration.module.edit.php @@ -19,7 +19,12 @@ **/ -$widget = (new CWidget()) +/** + * @var CView $this + * @var array $data + */ + +$html_page = (new CHtmlPage()) ->setTitle(_('Modules')) ->setDocUrl(CDocHelper::getUrl(CDocHelper::ADMINISTRATION_MODULE_EDIT)) ->setTitleSubmenu(getAdministrationGeneralSubmenu()); @@ -32,7 +37,7 @@ $form = (new CForm()) ->setArgument('moduleids[]', $data['moduleid']) ->getUrl() ) - ->setAttribute('aria-labeledby', ZBX_STYLE_PAGE_TITLE); + ->setAttribute('aria-labeledby', CHtmlPage::PAGE_TITLE_ID); // create module tab $module_tab = (new CFormList()) @@ -70,6 +75,6 @@ $tabs->setFooter(makeFormFooter( $form->addItem($tabs); // append form to widget -$widget->addItem($form); +$html_page->addItem($form); -$widget->show(); +$html_page->show(); diff --git a/ui/app/views/administration.module.list.php b/ui/app/views/administration.module.list.php index 8dec962295e..66d1671fb72 100644 --- a/ui/app/views/administration.module.list.php +++ b/ui/app/views/administration.module.list.php @@ -19,11 +19,16 @@ **/ +/** + * @var CView $this + * @var array $data + */ + if ($data['uncheck']) { uncheckTableRows('modules'); } -$widget = (new CWidget()) +$html_page = (new CHtmlPage()) ->setTitle(_('Modules')) ->setTitleSubmenu(getAdministrationGeneralSubmenu()) ->setDocUrl(CDocHelper::getUrl(CDocHelper::ADMINISTRATION_MODULE_LIST)) @@ -127,6 +132,6 @@ $form->addItem([ ]); // append form to widget -$widget->addItem($form); +$html_page->addItem($form); -$widget->show(); +$html_page->show(); diff --git a/ui/app/views/administration.queue.details.php b/ui/app/views/administration.queue.details.php index ca7401d07b3..efd243912a5 100644 --- a/ui/app/views/administration.queue.details.php +++ b/ui/app/views/administration.queue.details.php @@ -23,7 +23,7 @@ * @var CView $this */ -$widget = (new CWidget()) +$html_page = (new CHtmlPage()) ->setTitle(_('Queue details')) ->setTitleSubmenu([ 'main_section' => [ @@ -75,7 +75,7 @@ if (CWebUser::getRefresh()) { ->show(); } -$widget +$html_page ->addItem($table) ->addItem((new CDiv()) ->addClass(ZBX_STYLE_TABLE_PAGING) diff --git a/ui/app/views/administration.queue.overview.php b/ui/app/views/administration.queue.overview.php index 70f6479f84c..10f70776376 100644 --- a/ui/app/views/administration.queue.overview.php +++ b/ui/app/views/administration.queue.overview.php @@ -23,7 +23,7 @@ * @var CView $this */ -$widget = (new CWidget()) +$html_page = (new CHtmlPage()) ->setTitle(_('Queue overview')) ->setTitleSubmenu([ 'main_section' => [ @@ -87,6 +87,6 @@ if (CWebUser::getRefresh()) { ->show(); } -$widget +$html_page ->addItem($table) ->show(); diff --git a/ui/app/views/administration.queue.overview.proxy.php b/ui/app/views/administration.queue.overview.proxy.php index e0bc7d038cd..0d8d286aa89 100644 --- a/ui/app/views/administration.queue.overview.proxy.php +++ b/ui/app/views/administration.queue.overview.proxy.php @@ -23,7 +23,7 @@ * @var CView $this */ -$widget = (new CWidget()) +$html_page = (new CHtmlPage()) ->setTitle(_('Queue overview by proxy')) ->setTitleSubmenu([ 'main_section' => [ @@ -87,7 +87,7 @@ if (CWebUser::getRefresh()) { ->show(); } -$widget +$html_page ->addItem($table) ->addItem((new CDiv()) ->addClass(ZBX_STYLE_TABLE_PAGING) diff --git a/ui/app/views/administration.regex.edit.php b/ui/app/views/administration.regex.edit.php index d09ce3dde19..1624236147c 100644 --- a/ui/app/views/administration.regex.edit.php +++ b/ui/app/views/administration.regex.edit.php @@ -25,7 +25,7 @@ $this->includeJsFile('administration.regex.edit.js.php'); -$widget = (new CWidget()) +$html_page = (new CHtmlPage()) ->setTitle(_('Regular expressions')) ->setTitleSubmenu(getAdministrationGeneralSubmenu()) ->setDocUrl(CDocHelper::getUrl(CDocHelper::ADMINISTRATION_REGEX_EDIT)); @@ -39,7 +39,7 @@ if ($data['regexid'] != 0) { $form = (new CForm()) ->setId('regex') ->setAction($action->getUrl()) - ->setAttribute('aria-labeledby', ZBX_STYLE_PAGE_TITLE); + ->setAttribute('aria-labeledby', CHtmlPage::PAGE_TITLE_ID); $table = (new CTable()) ->setId('tbl_expr') @@ -172,6 +172,6 @@ else { $form->addItem($reg_exp_view); -$widget +$html_page ->addItem($form) ->show(); diff --git a/ui/app/views/administration.regex.list.php b/ui/app/views/administration.regex.list.php index a018be5308b..0084f79667c 100644 --- a/ui/app/views/administration.regex.list.php +++ b/ui/app/views/administration.regex.list.php @@ -27,7 +27,7 @@ if ($data['uncheck']) { uncheckTableRows('regex'); } -$widget = (new CWidget()) +$html_page = (new CHtmlPage()) ->setTitle(_('Regular expressions')) ->setTitleSubmenu(getAdministrationGeneralSubmenu()) ->setDocUrl(CDocHelper::getUrl(CDocHelper::ADMINISTRATION_REGEX_LIST)) @@ -82,4 +82,4 @@ $form->addItem([ ], 'regex') ]); -$widget->addItem($form)->show(); +$html_page->addItem($form)->show(); diff --git a/ui/app/views/administration.script.edit.php b/ui/app/views/administration.script.edit.php index 3b3335430b2..06848815045 100644 --- a/ui/app/views/administration.script.edit.php +++ b/ui/app/views/administration.script.edit.php @@ -27,7 +27,7 @@ $this->addJsFile('multilineinput.js'); $this->includeJsFile('administration.script.edit.js.php'); -$widget = (new CWidget()) +$html_page = (new CHtmlPage()) ->setTitle(_('Scripts')) ->setDocUrl(CDocHelper::getUrl(CDocHelper::ADMINISTRATION_SCRIPT_EDIT)); @@ -50,12 +50,12 @@ $row_template = (new CTag('script', true)) ]))->addClass('form_row') ); -$widget->addItem($row_template); +$html_page->addItem($row_template); $form = (new CForm()) ->setId('script-form') ->setName('scripts') - ->setAttribute('aria-labeledby', ZBX_STYLE_PAGE_TITLE) + ->setAttribute('aria-labeledby', CHtmlPage::PAGE_TITLE_ID) ->addVar('form', 1) ->addVar('scriptid', $data['scriptid']); @@ -303,4 +303,4 @@ else { $form->addItem($scriptView); -$widget->addItem($form)->show(); +$html_page->addItem($form)->show(); diff --git a/ui/app/views/administration.script.list.php b/ui/app/views/administration.script.list.php index 303b5d19a82..faad1830b33 100644 --- a/ui/app/views/administration.script.list.php +++ b/ui/app/views/administration.script.list.php @@ -27,7 +27,7 @@ if ($data['uncheck']) { uncheckTableRows('script'); } -$widget = (new CWidget()) +$html_page = (new CHtmlPage()) ->setTitle(_('Scripts')) ->setDocUrl(CDocHelper::getUrl(CDocHelper::ADMINISTRATION_SCRIPT_LIST)) ->setControls((new CTag('nav', true, @@ -205,6 +205,6 @@ $scriptsForm->addItem([ ]); // append form to widget -$widget +$html_page ->addItem($scriptsForm) ->show(); diff --git a/ui/app/views/administration.token.list.php b/ui/app/views/administration.token.list.php index 6295605b658..557c394074a 100644 --- a/ui/app/views/administration.token.list.php +++ b/ui/app/views/administration.token.list.php @@ -100,7 +100,7 @@ $filter = (new CFilter()) ) ]); -$widget = (new CWidget()) +$html_page = (new CHtmlPage()) ->setTitle(_('API tokens')) ->setTitleSubmenu(getAdministrationGeneralSubmenu()) ->setDocUrl(CDocHelper::getUrl(CDocHelper::ADMINISTRATION_TOKEN_LIST)) @@ -211,7 +211,7 @@ $token_form->addItem([ ], 'token') ]); -$widget +$html_page ->addItem($token_form) ->show(); diff --git a/ui/app/views/administration.trigdisplay.edit.php b/ui/app/views/administration.trigdisplay.edit.php index 1a267908a90..23528229815 100644 --- a/ui/app/views/administration.trigdisplay.edit.php +++ b/ui/app/views/administration.trigdisplay.edit.php @@ -27,7 +27,7 @@ $this->addJsFile('colorpicker.js'); $this->includeJsFile('administration.trigdisplay.edit.js.php'); -$widget = (new CWidget()) +$html_page = (new CHtmlPage()) ->setTitle(_('Trigger displaying options')) ->setTitleSubmenu(getAdministrationGeneralSubmenu()) ->setDocUrl(CDocHelper::getUrl(CDocHelper::ADMINISTRATION_TRIGDISPLAY_EDIT)); @@ -156,7 +156,7 @@ $form_list = (new CFormList()) ->addInfo(_('Custom severity names affect all locales and require manual translation!')); $form = (new CForm()) - ->setAttribute('aria-labeledby', ZBX_STYLE_PAGE_TITLE) + ->setAttribute('aria-labeledby', CHtmlPage::PAGE_TITLE_ID) ->setAction((new CUrl('zabbix.php')) ->setArgument('action', 'trigdisplay.update') ->getUrl() @@ -170,4 +170,4 @@ $form = (new CForm()) )) ); -$widget->addItem($form)->show(); +$html_page->addItem($form)->show(); diff --git a/ui/app/views/administration.user.edit.php b/ui/app/views/administration.user.edit.php index dbd9aa6ced1..0290f35f148 100644 --- a/ui/app/views/administration.user.edit.php +++ b/ui/app/views/administration.user.edit.php @@ -29,7 +29,7 @@ $this->includeJsFile(($data['action'] === 'user.edit') : 'administration.userprofile.edit.js.php' ); -$widget = new CWidget(); +$html_page = new CHtmlPage(); if ($data['action'] === 'user.edit') { $widget_name = _('Users'); @@ -40,13 +40,14 @@ else { $widget_name .= ($data['name'] !== '' || $data['surname'] !== '') ? $data['name'].' '.$data['surname'] : $data['username']; - $widget->setTitleSubmenu(getUserSettingsSubmenu()); + $html_page->setTitleSubmenu(getUserSettingsSubmenu()); $doc_url = CDocHelper::ADMINISTRATION_USERPROFILE_EDIT; } -$widget +$html_page ->setTitle($widget_name) ->setDocUrl(CDocHelper::getUrl($doc_url)); + $tabs = new CTabView(); if ($data['form_refresh'] == 0) { @@ -57,7 +58,7 @@ if ($data['form_refresh'] == 0) { $user_form = (new CForm()) ->setId('user-form') ->setName('user_form') - ->setAttribute('aria-labeledby', ZBX_STYLE_PAGE_TITLE) + ->setAttribute('aria-labeledby', CHtmlPage::PAGE_TITLE_ID) ->addVar('action', $data['action']) ->addVar('userid', $data['userid']); @@ -805,6 +806,6 @@ else { // Append tab to form. $user_form->addItem($tabs); -$widget +$html_page ->addItem($user_form) ->show(); diff --git a/ui/app/views/administration.user.list.php b/ui/app/views/administration.user.list.php index 6ee72264d4f..3b3529fb08c 100644 --- a/ui/app/views/administration.user.list.php +++ b/ui/app/views/administration.user.list.php @@ -29,7 +29,7 @@ if ($data['uncheck']) { uncheckTableRows('user'); } -$widget = (new CWidget()) +$html_page = (new CHtmlPage()) ->setTitle(_('Users')) ->setDocUrl(CDocHelper::getUrl(CDocHelper::ADMINISTRATION_USER_LIST)) ->setControls((new CList([ @@ -253,6 +253,6 @@ $form->addItem([ ]); // Append form to widget. -$widget +$html_page ->addItem($form) ->show(); diff --git a/ui/app/views/administration.user.token.list.php b/ui/app/views/administration.user.token.list.php index 691974ad128..05503198f00 100644 --- a/ui/app/views/administration.user.token.list.php +++ b/ui/app/views/administration.user.token.list.php @@ -66,7 +66,7 @@ $filter = (new CFilter()) ) ]); -$widget = (new CWidget()) +$html_page = (new CHtmlPage()) ->setTitle(_('API tokens')) ->setTitleSubmenu(getUserSettingsSubmenu()) ->setDocUrl(CDocHelper::getUrl(CDocHelper::ADMINISTRATION_USER_TOKEN_LIST)) @@ -163,7 +163,7 @@ $token_form->addItem([ ], 'user.token') ]); -$widget +$html_page ->addItem($token_form) ->show(); diff --git a/ui/app/views/administration.usergroup.edit.php b/ui/app/views/administration.usergroup.edit.php index 96145a013d3..912d318f11d 100644 --- a/ui/app/views/administration.usergroup.edit.php +++ b/ui/app/views/administration.usergroup.edit.php @@ -25,14 +25,14 @@ $this->includeJsFile('administration.usergroup.edit.js.php'); -$widget = (new CWidget()) +$html_page = (new CHtmlPage()) ->setTitle(_('User groups')) ->setDocUrl(CDocHelper::getUrl(CDocHelper::ADMINISTRATION_USERGROUP_EDIT)); $form = (new CForm()) ->setId('user-group-form') ->setName('user_group_form') - ->setAttribute('aria-labeledby', ZBX_STYLE_PAGE_TITLE); + ->setAttribute('aria-labeledby', CHtmlPage::PAGE_TITLE_ID); if ($data['usrgrpid'] != 0) { $form->addVar('usrgrpid', $data['usrgrpid']); @@ -306,5 +306,7 @@ else { // append tab to form $form->addItem($tabs); -$widget->addItem($form); -$widget->show(); + +$html_page + ->addItem($form) + ->show(); diff --git a/ui/app/views/administration.usergroup.list.php b/ui/app/views/administration.usergroup.list.php index ebcf31c850f..88f07b67e78 100644 --- a/ui/app/views/administration.usergroup.list.php +++ b/ui/app/views/administration.usergroup.list.php @@ -27,7 +27,7 @@ if ($data['uncheck']) { uncheckTableRows('usergroup'); } -$widget = (new CWidget()) +$html_page = (new CHtmlPage()) ->setTitle(_('User groups')) ->setDocUrl(CDocHelper::getUrl(CDocHelper::ADMINISTRATION_USERGROUP_LIST)) ->setControls( @@ -240,5 +240,6 @@ $form->addItem([ ], 'usergroup') ]); -$widget->addItem($form); -$widget->show(); +$html_page + ->addItem($form) + ->show(); diff --git a/ui/app/views/administration.userrole.edit.php b/ui/app/views/administration.userrole.edit.php index d9472a780e4..90f95822289 100644 --- a/ui/app/views/administration.userrole.edit.php +++ b/ui/app/views/administration.userrole.edit.php @@ -26,14 +26,14 @@ $this->includeJsFile('administration.userrole.edit.js.php'); -$widget = (new CWidget()) +$html_page = (new CHtmlPage()) ->setTitle(_('User roles')) ->setDocUrl(CDocHelper::getUrl(CDocHelper::ADMINISTRATION_USERROLE_EDIT)); $form = (new CForm()) ->setId('userrole-form') ->setName('user_role_form') - ->setAttribute('aria-labeledby', ZBX_STYLE_PAGE_TITLE); + ->setAttribute('aria-labeledby', CHtmlPage::PAGE_TITLE_ID); if ($data['roleid'] !== null) { $form->addVar('roleid', $data['roleid']); @@ -388,8 +388,10 @@ $form_grid->addItem( $tabs = (new CTabView())->addTab('user_role_tab', _('User role'), $form_grid); $form->addItem((new CTabView())->addTab('user_role_tab', _('User role'), $form_grid)); -$widget->addItem($form); -$widget->show(); + +$html_page + ->addItem($form) + ->show(); (new CScriptTag(' view.init('.json_encode([ diff --git a/ui/app/views/administration.userrole.list.php b/ui/app/views/administration.userrole.list.php index a31dfd2e17e..0e21948777e 100644 --- a/ui/app/views/administration.userrole.list.php +++ b/ui/app/views/administration.userrole.list.php @@ -27,7 +27,7 @@ if ($data['uncheck']) { uncheckTableRows('userrole'); } -$widget = (new CWidget()) +$html_page = (new CHtmlPage()) ->setTitle(_('User roles')) ->setDocUrl(CDocHelper::getUrl(CDocHelper::ADMINISTRATION_USERROLE_LIST)) ->setControls( @@ -130,5 +130,6 @@ $form->addItem([ ], 'userrole') ]); -$widget->addItem($form); -$widget->show(); +$html_page + ->addItem($form) + ->show(); diff --git a/ui/app/views/configuration.correlation.edit.php b/ui/app/views/configuration.correlation.edit.php index c2455566661..9bb9777a3f8 100644 --- a/ui/app/views/configuration.correlation.edit.php +++ b/ui/app/views/configuration.correlation.edit.php @@ -26,7 +26,7 @@ $this->addJsFile('popup.condition.common.js'); $this->includeJsFile('configuration.correlation.edit.js.php'); -$widget = (new CWidget()) +$html_page = (new CHtmlPage()) ->setTitle(_('Event correlation rules')) ->setDocUrl(CDocHelper::getUrl(CDocHelper::CONFIGURATION_CORRELATION_EDIT)); @@ -37,7 +37,7 @@ $form = (new CForm()) ->setArgument('action', 'correlation.condition.add') ->getUrl() ) - ->setAttribute('aria-labeledby', ZBX_STYLE_PAGE_TITLE); + ->setAttribute('aria-labeledby', CHtmlPage::PAGE_TITLE_ID); if ($data['correlationid'] != 0) { $form->addVar('correlationid', $data['correlationid']); @@ -193,6 +193,6 @@ else { $form->addItem($correlation_tabs); -$widget->addItem($form); - -$widget->show(); +$html_page + ->addItem($form) + ->show(); diff --git a/ui/app/views/configuration.correlation.list.php b/ui/app/views/configuration.correlation.list.php index fd4b794983a..4c2dd5d882b 100644 --- a/ui/app/views/configuration.correlation.list.php +++ b/ui/app/views/configuration.correlation.list.php @@ -27,7 +27,7 @@ if ($data['uncheck']) { uncheckTableRows('correlation'); } -$widget = (new CWidget()) +$html_page = (new CHtmlPage()) ->setTitle(_('Event correlation')) ->setDocUrl(CDocHelper::getUrl(CDocHelper::CONFIGURATION_CORRELATION_LIST)) ->setControls( @@ -148,6 +148,6 @@ $form->addItem([ ], 'correlation') ]); -$widget->addItem($form); - -$widget->show(); +$html_page + ->addItem($form) + ->show(); diff --git a/ui/app/views/configuration.dashboard.edit.php b/ui/app/views/configuration.dashboard.edit.php index 0b08ee5888e..b915f6b8ddb 100644 --- a/ui/app/views/configuration.dashboard.edit.php +++ b/ui/app/views/configuration.dashboard.edit.php @@ -46,7 +46,7 @@ $this->addJsFile('class.sortable.js'); $this->includeJsFile('configuration.dashboard.edit.js.php'); -$widget = (new CWidget()) +$html_page = (new CHtmlPage()) ->setTitle(_('Dashboards')) ->setDocUrl(CDocHelper::getUrl(CDocHelper::CONFIGURATION_DASHBOARD_EDIT)) ->setControls( @@ -105,7 +105,7 @@ $dashboard->addItem( $dashboard->addItem((new CDiv())->addClass(ZBX_STYLE_DASHBOARD_GRID)); -$widget +$html_page ->addItem($dashboard) ->show(); diff --git a/ui/app/views/configuration.dashboard.list.php b/ui/app/views/configuration.dashboard.list.php index 8dde48f6c58..b73ea6e2687 100644 --- a/ui/app/views/configuration.dashboard.list.php +++ b/ui/app/views/configuration.dashboard.list.php @@ -70,7 +70,7 @@ $form->addItem([ ], $checkbox_hash) ]); -(new CWidget()) +(new CHtmlPage()) ->setTitle(_('Dashboards')) ->setDocUrl(CDocHelper::getUrl(CDocHelper::CONFIGURATION_DASHBOARD_LIST)) ->setControls( diff --git a/ui/app/views/configuration.discovery.edit.php b/ui/app/views/configuration.discovery.edit.php index bc6887d7644..453121854c8 100644 --- a/ui/app/views/configuration.discovery.edit.php +++ b/ui/app/views/configuration.discovery.edit.php @@ -25,7 +25,7 @@ require_once dirname(__FILE__).'/js/configuration.discovery.edit.js.php'; -$widget = (new CWidget()) +$html_page = (new CHtmlPage()) ->setTitle(_('Discovery rules')) ->setDocUrl(CDocHelper::getUrl(CDocHelper::CONFIGURATION_DISCOVERY_EDIT)); @@ -33,7 +33,7 @@ $widget = (new CWidget()) $discoveryForm = (new CForm()) ->setId('discoveryForm') ->setName('discoveryForm') - ->setAttribute('aria-labeledby', ZBX_STYLE_PAGE_TITLE); + ->setAttribute('aria-labeledby', CHtmlPage::PAGE_TITLE_ID); if (!empty($this->data['druleid'])) { $discoveryForm->addVar('druleid', $this->data['druleid']); @@ -174,6 +174,6 @@ else { $discoveryForm->addItem($discoveryTabs); -$widget->addItem($discoveryForm); - -$widget->show(); +$html_page + ->addItem($discoveryForm) + ->show(); diff --git a/ui/app/views/configuration.discovery.list.php b/ui/app/views/configuration.discovery.list.php index ea64d870a55..a3ceba30849 100644 --- a/ui/app/views/configuration.discovery.list.php +++ b/ui/app/views/configuration.discovery.list.php @@ -27,7 +27,7 @@ if ($data['uncheck']) { uncheckTableRows('discovery'); } -$widget = (new CWidget()) +$html_page = (new CHtmlPage()) ->setTitle(_('Discovery rules')) ->setDocUrl(CDocHelper::getUrl(CDocHelper::CONFIGURATION_DISCOVERY_LIST)) ->setControls( @@ -121,7 +121,6 @@ $discoveryForm->addItem([ ], 'discovery') ]); -// append form to widget -$widget->addItem($discoveryForm); - -$widget->show(); +$html_page + ->addItem($discoveryForm) + ->show(); diff --git a/ui/app/views/configuration.host.edit.php b/ui/app/views/configuration.host.edit.php index 6bdb0c6ba29..84c16b0b105 100644 --- a/ui/app/views/configuration.host.edit.php +++ b/ui/app/views/configuration.host.edit.php @@ -62,7 +62,7 @@ if ($data['warning']) { $data['warning'] = null; } -(new CWidget()) +(new CHtmlPage()) ->setTitle(($data['hostid'] == 0) ? _('New host') : _('Host')) ->setDocUrl(CDocHelper::getUrl(CDocHelper::CONFIGURATION_HOST_EDIT)) ->addItem(new CPartial('configuration.host.edit.html', $data)) diff --git a/ui/app/views/configuration.host.list.php b/ui/app/views/configuration.host.list.php index 3a4391e54f5..50283dbcab8 100644 --- a/ui/app/views/configuration.host.list.php +++ b/ui/app/views/configuration.host.list.php @@ -31,7 +31,7 @@ if ($data['uncheck']) { uncheckTableRows('hosts'); } -$widget = (new CWidget()) +$html_page = (new CHtmlPage()) ->setTitle(_('Hosts')) ->setDocUrl(CDocHelper::getUrl(CDocHelper::CONFIGURATION_HOST_LIST)) ->setControls((new CTag('nav', true, (new CList()) @@ -166,7 +166,7 @@ $filter = (new CFilter()) ]) ]); -$widget->addItem($filter); +$html_page->addItem($filter); // table hosts $form = (new CForm())->setName('hosts'); @@ -537,7 +537,7 @@ $form->addItem([ ], 'hosts') ]); -$widget +$html_page ->addItem($form) ->show(); diff --git a/ui/app/views/configuration.hostgroup.edit.php b/ui/app/views/configuration.hostgroup.edit.php index 0bdd9b611d1..74bc16ba4dd 100644 --- a/ui/app/views/configuration.hostgroup.edit.php +++ b/ui/app/views/configuration.hostgroup.edit.php @@ -48,7 +48,7 @@ $data += [ ] ]; -(new CWidget()) +(new CHtmlPage()) ->setTitle(($data['groupid'] == 0) ? _('New host group') : _('Host group')) ->setDocUrl(CDocHelper::getUrl(CDocHelper::CONFIGURATION_HOSTGROUPS_EDIT)) ->addItem(new CPartial('configuration.hostgroup.edit.html', $data)) diff --git a/ui/app/views/configuration.hostgroup.list.php b/ui/app/views/configuration.hostgroup.list.php index 10ffbaf85e0..bea24bd1642 100644 --- a/ui/app/views/configuration.hostgroup.list.php +++ b/ui/app/views/configuration.hostgroup.list.php @@ -26,7 +26,7 @@ $this->includeJsFile('configuration.hostgroup.list.js.php'); -$widget = (new CWidget()) +$html_page = (new CHtmlPage()) ->setTitle(_('Host groups')) ->setDocUrl(CDocHelper::getUrl(CDocHelper::CONFIGURATION_HOSTGROUPS_LIST)) ->setControls( @@ -191,7 +191,7 @@ $form->addItem([ ], 'hostgroup') ]); -$widget +$html_page ->addItem($form) ->show(); diff --git a/ui/app/views/configuration.templategroup.edit.php b/ui/app/views/configuration.templategroup.edit.php index 732a8abe1b7..9ee12f1b36a 100644 --- a/ui/app/views/configuration.templategroup.edit.php +++ b/ui/app/views/configuration.templategroup.edit.php @@ -48,7 +48,7 @@ $data += [ ] ]; -(new CWidget()) +(new CHtmlPage()) ->setTitle(($data['groupid'] == 0) ? _('New template group') : _('Template group')) ->addItem(new CPartial('configuration.templategroup.edit.html', $data)) ->show(); diff --git a/ui/app/views/configuration.templategroup.list.php b/ui/app/views/configuration.templategroup.list.php index add2c591c7c..6e5c81b9384 100644 --- a/ui/app/views/configuration.templategroup.list.php +++ b/ui/app/views/configuration.templategroup.list.php @@ -26,7 +26,7 @@ $this->includeJsFile('configuration.templategroup.list.js.php'); -$widget = (new CWidget()) +$html_page = (new CHtmlPage()) ->setTitle(_('Template groups')) ->setControls((new CTag('nav', true, (new CList()) ->addItem(CWebUser::getType() == USER_TYPE_SUPER_ADMIN @@ -148,7 +148,7 @@ $form->addItem([ ], 'templategroup') ]); -$widget +$html_page ->addItem($filter) ->addItem($form) ->show(); diff --git a/ui/app/views/js/monitoring.dashboard.view.js.php b/ui/app/views/js/monitoring.dashboard.view.js.php index 9f6dc5cd740..e73582379b1 100644 --- a/ui/app/views/js/monitoring.dashboard.view.js.php +++ b/ui/app/views/js/monitoring.dashboard.view.js.php @@ -380,7 +380,7 @@ applyProperties() { const dashboard_data = ZABBIX.Dashboard.getData(); - document.getElementById('').textContent = dashboard_data.name; + document.getElementById('').textContent = dashboard_data.name; document.getElementById('dashboard-direct-link').textContent = dashboard_data.name; }, diff --git a/ui/app/views/monitoring.charts.view.php b/ui/app/views/monitoring.charts.view.php index e031f3c433e..7fe528b8638 100644 --- a/ui/app/views/monitoring.charts.view.php +++ b/ui/app/views/monitoring.charts.view.php @@ -36,7 +36,7 @@ $this->includeJsFile('monitoring.charts.view.js.php'); $this->enableLayoutModes(); $web_layout_mode = $this->getLayoutMode(); -$widget = (new CWidget()) +$html_page = (new CHtmlPage()) ->setTitle(_('Graphs')) ->setWebLayoutMode($web_layout_mode) ->setDocUrl(CDocHelper::getUrl(CDocHelper::MONITORING_CHARTS_VIEW)) @@ -89,24 +89,24 @@ if ($web_layout_mode == ZBX_LAYOUT_NORMAL) { new CPartial('monitoring.charts.subfilter', $data['subfilters'])); } -$widget->addItem($filter); +$html_page->addItem($filter); if (!$data['filter_hostids']) { - $widget->addItem((new CTableInfo())->setNoDataMessage(_('Specify host to see the graphs.'))); + $html_page->addItem((new CTableInfo())->setNoDataMessage(_('Specify host to see the graphs.'))); } elseif ($data['charts']) { $table = (new CTable()) ->setAttribute('style', 'width: 100%;') ->setId('charts'); - $widget + $html_page ->addItem($table) ->addItem($data['paging']); } else { - $widget->addItem(new CTableInfo()); + $html_page->addItem(new CTableInfo()); } -$widget->show(); +$html_page->show(); (new CScriptTag(' view.init('.json_encode([ diff --git a/ui/app/views/monitoring.dashboard.list.php b/ui/app/views/monitoring.dashboard.list.php index fce06114159..1249d327d8b 100644 --- a/ui/app/views/monitoring.dashboard.list.php +++ b/ui/app/views/monitoring.dashboard.list.php @@ -31,7 +31,7 @@ $this->addJsFile('layout.mode.js'); $this->enableLayoutModes(); $web_layout_mode = $this->getLayoutMode(); -$widget = (new CWidget()) +$html_page = (new CHtmlPage()) ->setTitle(_('Dashboards')) ->setWebLayoutMode($web_layout_mode) ->setDocUrl(CDocHelper::getUrl(CDocHelper::MONITORING_DASHBOARD_LIST)) @@ -52,7 +52,7 @@ $widget = (new CWidget()) ); if ($web_layout_mode == ZBX_LAYOUT_NORMAL) { - $widget + $html_page ->addItem((new CFilter()) ->setResetUrl((new CUrl('zabbix.php'))->setArgument('action', 'dashboard.list')) ->setProfile($data['profileIdx']) @@ -128,5 +128,6 @@ $form->addItem([ ], 'dashboard') ]); -$widget->addItem($form); -$widget->show(); +$html_page + ->addItem($form) + ->show(); diff --git a/ui/app/views/monitoring.dashboard.print.php b/ui/app/views/monitoring.dashboard.print.php index d0fb077c6b8..52cc8e986ae 100644 --- a/ui/app/views/monitoring.dashboard.print.php +++ b/ui/app/views/monitoring.dashboard.print.php @@ -63,7 +63,7 @@ $this->addCssFile('assets/styles/vendors/Leaflet/Leaflet/leaflet.css'); $this->enableLayoutModes(); $this->setLayoutMode(ZBX_LAYOUT_KIOSKMODE); -(new CWidget()) +(new CHtmlPage()) ->addItem( (new CDiv()) ->addClass(ZBX_STYLE_DASHBOARD) diff --git a/ui/app/views/monitoring.dashboard.view.php b/ui/app/views/monitoring.dashboard.view.php index 927d7188212..838a4274b10 100644 --- a/ui/app/views/monitoring.dashboard.view.php +++ b/ui/app/views/monitoring.dashboard.view.php @@ -100,7 +100,7 @@ if ($data['dynamic']['has_dynamic_widgets']) { ]); } -$widget = (new CWidget()) +$html_page = (new CHtmlPage()) ->setTitle($data['dashboard']['name']) ->setWebLayoutMode($web_layout_mode) ->setDocUrl(CDocHelper::getUrl(CDocHelper::MONITORING_DASHBOARD_VIEW)) @@ -197,7 +197,7 @@ $widget = (new CWidget()) ]))); if ($data['has_time_selector']) { - $widget->addItem( + $html_page->addItem( (new CFilter()) ->setProfile($data['time_period']['profileIdx'], $data['time_period']['profileIdx2']) ->setActiveTab($data['active_tab']) @@ -252,7 +252,7 @@ if ($web_layout_mode != ZBX_LAYOUT_KIOSKMODE) { $dashboard->addItem((new CDiv())->addClass(ZBX_STYLE_DASHBOARD_GRID)); -$widget +$html_page ->addItem($dashboard) ->show(); diff --git a/ui/app/views/monitoring.discovery.view.php b/ui/app/views/monitoring.discovery.view.php index bd156a5824f..76cf3e5db47 100644 --- a/ui/app/views/monitoring.discovery.view.php +++ b/ui/app/views/monitoring.discovery.view.php @@ -30,7 +30,7 @@ $this->addJsFile('layout.mode.js'); $this->enableLayoutModes(); $web_layout_mode = $this->getLayoutMode(); -$widget = (new CWidget()) +$html_page = (new CHtmlPage()) ->setTitle(_('Status of discovery')) ->setWebLayoutMode($web_layout_mode) ->setDocUrl(CDocHelper::getUrl(CDocHelper::MONITORING_DISCOVERY_VIEW)) @@ -77,4 +77,4 @@ $discovery_table = CScreenBuilder::getScreen([ ] ])->get(); -$widget->addItem($discovery_table)->show(); +$html_page->addItem($discovery_table)->show(); diff --git a/ui/app/views/monitoring.host.dashboard.view.php b/ui/app/views/monitoring.host.dashboard.view.php index 95461164381..33857382a95 100644 --- a/ui/app/views/monitoring.host.dashboard.view.php +++ b/ui/app/views/monitoring.host.dashboard.view.php @@ -28,7 +28,7 @@ if (array_key_exists('error', $data)) { } if (array_key_exists('no_data', $data)) { - (new CWidget()) + (new CHtmlPage()) ->setTitle(_('Dashboards')) ->setDocUrl(CDocHelper::getUrl(CDocHelper::MONITORING_HOST_DASHBOARD_VIEW)) ->addItem(new CTableInfo()) @@ -64,7 +64,7 @@ $this->includeJsFile('monitoring.host.dashboard.view.js.php'); $this->enableLayoutModes(); $web_layout_mode = $this->getLayoutMode(); -$widget = (new CWidget()) +$html_page = (new CHtmlPage()) ->setTitle($data['dashboard']['name']) ->setWebLayoutMode($web_layout_mode) ->setDocUrl(CDocHelper::getUrl(CDocHelper::MONITORING_HOST_DASHBOARD_VIEW)) @@ -129,7 +129,7 @@ $widget = (new CWidget()) ]))); if ($data['has_time_selector']) { - $widget->addItem( + $html_page->addItem( (new CFilter()) ->setProfile($data['time_period']['profileIdx'], $data['time_period']['profileIdx2']) ->setActiveTab($data['active_tab']) @@ -182,7 +182,7 @@ if (count($data['dashboard']['pages']) > 1 $dashboard->addItem((new CDiv())->addClass(ZBX_STYLE_DASHBOARD_GRID)); - $widget + $html_page ->addItem($dashboard) ->show(); @@ -199,7 +199,7 @@ if (count($data['dashboard']['pages']) > 1 ->show(); } else { - $widget + $html_page ->addItem(new CTableInfo()) ->show(); } diff --git a/ui/app/views/monitoring.host.view.php b/ui/app/views/monitoring.host.view.php index f50e9c56edd..fcee4d1d6ed 100644 --- a/ui/app/views/monitoring.host.view.php +++ b/ui/app/views/monitoring.host.view.php @@ -45,7 +45,7 @@ if ($data['can_create_hosts']) { $nav_items->addItem(get_icon('kioskmode', ['mode' => $web_layout_mode])); -$widget = (new CWidget()) +$html_page = (new CHtmlPage()) ->setTitle(_('Hosts')) ->setWebLayoutMode($web_layout_mode) ->setDocUrl(CDocHelper::getUrl(CDocHelper::MONITORING_HOST_VIEW)) @@ -66,18 +66,19 @@ if ($web_layout_mode == ZBX_LAYOUT_NORMAL) { // Set javascript options for tab filter initialization in monitoring.host.view.js.php file. $data['filter_options'] = $filter->options; - $widget->addItem($filter); + $html_page->addItem($filter); } else { $data['filter_options'] = null; } -$widget->addItem((new CForm()) - ->setName('host_view') - ->addClass('is-loading') -); - -$widget->show(); +$html_page + ->addItem( + (new CForm()) + ->setName('host_view') + ->addClass('is-loading') + ) + ->show(); (new CScriptTag(' view.init('.json_encode([ diff --git a/ui/app/views/monitoring.latest.view.php b/ui/app/views/monitoring.latest.view.php index 26488a0f79f..76f4ef9422a 100644 --- a/ui/app/views/monitoring.latest.view.php +++ b/ui/app/views/monitoring.latest.view.php @@ -34,7 +34,7 @@ $this->includeJsFile('monitoring.latest.view.js.php'); $this->enableLayoutModes(); $web_layout_mode = $this->getLayoutMode(); -$widget = (new CWidget()) +$html_page = (new CHtmlPage()) ->setTitle(_('Latest data')) ->setWebLayoutMode($web_layout_mode) ->setDocUrl(CDocHelper::getUrl(CDocHelper::MONITORING_LATEST_VIEW)) @@ -59,19 +59,19 @@ if ($web_layout_mode == ZBX_LAYOUT_NORMAL) { // Set javascript options for tab filter initialization in monitoring.latest.view.js.php file. $data['filter_options'] = $filter->options; - $widget->addItem($filter); + $html_page->addItem($filter); } else { $data['filter_options'] = null; } -$widget->addItem(new CPartial('monitoring.latest.view.html', array_intersect_key($data, - array_flip(['filter', 'sort_field', 'sort_order', 'view_curl', 'paging', 'hosts', 'items', 'history', 'config', - 'tags', 'maintenances', 'items_rw' - ]) -))); - -$widget->show(); +$html_page + ->addItem(new CPartial('monitoring.latest.view.html', array_intersect_key($data, + array_flip(['filter', 'sort_field', 'sort_order', 'view_curl', 'paging', 'hosts', 'items', 'history', 'config', + 'tags', 'maintenances', 'items_rw' + ]) + ))) + ->show(); (new CScriptTag(' view.init('.json_encode([ diff --git a/ui/app/views/monitoring.map.view.php b/ui/app/views/monitoring.map.view.php index 5afe2dcf90a..5ef7db8812e 100644 --- a/ui/app/views/monitoring.map.view.php +++ b/ui/app/views/monitoring.map.view.php @@ -33,7 +33,7 @@ $this->includeJsFile('monitoring.map.view.js.php'); $this->enableLayoutModes(); $web_layout_mode = $this->getLayoutMode(); -(new CWidget()) +(new CHtmlPage()) ->setTitle(_('Maps')) ->setDocUrl(CDocHelper::getUrl(CDocHelper::MONITORING_MAP_VIEW)) ->setWebLayoutMode($web_layout_mode) diff --git a/ui/app/views/monitoring.problem.view.php b/ui/app/views/monitoring.problem.view.php index a7c4c2bd51a..79abd9623c9 100644 --- a/ui/app/views/monitoring.problem.view.php +++ b/ui/app/views/monitoring.problem.view.php @@ -90,7 +90,7 @@ if ($data['action'] === 'problem.view') { uncheckTableRows('problem'); } - $widget = (new CWidget()) + $html_page = (new CHtmlPage()) ->setTitle(_('Problems')) ->setWebLayoutMode($web_layout_mode) ->setDocUrl(CDocHelper::getUrl(CDocHelper::MONITORING_PROBLEM_VIEW)) @@ -117,14 +117,14 @@ if ($data['action'] === 'problem.view') { // Set javascript options for tab filter initialization in monitoring.problem.view.js.php file. $data['filter_options'] = $filter->options; - $widget->addItem($filter); + $html_page->addItem($filter); } else { $data['filter_options'] = null; } $this->includeJsFile('monitoring.problem.view.js.php', $data); - $widget + $html_page ->addItem($screen->get()) ->show(); diff --git a/ui/app/views/monitoring.web.view.php b/ui/app/views/monitoring.web.view.php index 20595245dfb..242e54f0703 100644 --- a/ui/app/views/monitoring.web.view.php +++ b/ui/app/views/monitoring.web.view.php @@ -33,7 +33,7 @@ $this->includeJsFile('monitoring.web.view.js.php'); $this->enableLayoutModes(); $web_layout_mode = $this->getLayoutMode(); -(new CWidget()) +(new CHtmlPage()) ->setTitle(_('Web monitoring')) ->setWebLayoutMode($web_layout_mode) ->setDocUrl(CDocHelper::getUrl(CDocHelper::MONITORING_WEB_VIEW)) diff --git a/ui/app/views/popup.condition.common.php b/ui/app/views/popup.condition.common.php index 197cc813a87..32e102ecc87 100644 --- a/ui/app/views/popup.condition.common.php +++ b/ui/app/views/popup.condition.common.php @@ -30,7 +30,7 @@ $form = (new CForm()) ->cleanItems() ->setId('popup.condition') ->setName('popup.condition') - ->setAttribute('aria-labeledby', ZBX_STYLE_PAGE_TITLE) + ->setAttribute('aria-labeledby', CHtmlPage::PAGE_TITLE_ID) ->addVar('action', $data['action']) ->addVar('type', $data['type']); diff --git a/ui/app/views/popup.import.php b/ui/app/views/popup.import.php index b10a129ccf9..c4b10c7d0d9 100644 --- a/ui/app/views/popup.import.php +++ b/ui/app/views/popup.import.php @@ -160,7 +160,7 @@ $form_list = (new CFormList()) $form = (new CForm('post', null, 'multipart/form-data')) ->setId('import-form') - ->setAttribute('aria-labeledby', ZBX_STYLE_PAGE_TITLE) + ->setAttribute('aria-labeledby', CHtmlPage::PAGE_TITLE_ID) ->addVar('import', 1) ->addVar('rules_preset', $data['rules_preset']) ->addItem($form_list); diff --git a/ui/app/views/popup.massupdate.host.php b/ui/app/views/popup.massupdate.host.php index fd051160426..522ebcb3ab4 100644 --- a/ui/app/views/popup.massupdate.host.php +++ b/ui/app/views/popup.massupdate.host.php @@ -26,7 +26,7 @@ // create form $form = (new CForm()) ->setId('massupdate-form') - ->setAttribute('aria-labeledby', ZBX_STYLE_PAGE_TITLE) + ->setAttribute('aria-labeledby', CHtmlPage::PAGE_TITLE_ID) ->addVar('action', 'popup.massupdate.host') ->addVar('hostids', $data['hostids'], 'ids') ->addVar('tls_accept', HOST_ENCRYPTION_NONE) diff --git a/ui/app/views/popup.massupdate.item.php b/ui/app/views/popup.massupdate.item.php index 33650ea9578..3d3dd093cae 100644 --- a/ui/app/views/popup.massupdate.item.php +++ b/ui/app/views/popup.massupdate.item.php @@ -27,7 +27,7 @@ $form = (new CForm()) ->setId('massupdate-form') ->setName('massupdate-form') - ->setAttribute('aria-labeledby', ZBX_STYLE_PAGE_TITLE) + ->setAttribute('aria-labeledby', CHtmlPage::PAGE_TITLE_ID) ->addVar('ids', $data['ids']) ->addVar('action', $data['action']) ->addVar('prototype', $data['prototype']) diff --git a/ui/app/views/popup.massupdate.template.php b/ui/app/views/popup.massupdate.template.php index 9410290b6a6..4181d7433f9 100644 --- a/ui/app/views/popup.massupdate.template.php +++ b/ui/app/views/popup.massupdate.template.php @@ -26,7 +26,7 @@ // Create form. $form = (new CForm()) ->setId('massupdate-form') - ->setAttribute('aria-labeledby', ZBX_STYLE_PAGE_TITLE) + ->setAttribute('aria-labeledby', CHtmlPage::PAGE_TITLE_ID) ->addVar('action', 'popup.massupdate.template') ->addVar('update', '1') ->addVar('ids', $data['ids']) diff --git a/ui/app/views/popup.massupdate.trigger.php b/ui/app/views/popup.massupdate.trigger.php index 9cd33140031..52afb11a5fd 100644 --- a/ui/app/views/popup.massupdate.trigger.php +++ b/ui/app/views/popup.massupdate.trigger.php @@ -27,7 +27,7 @@ // Create form. $form = (new CForm()) ->setId('massupdate-form') - ->setAttribute('aria-labeledby', ZBX_STYLE_PAGE_TITLE) + ->setAttribute('aria-labeledby', CHtmlPage::PAGE_TITLE_ID) ->addVar('action', $data['prototype'] ? 'popup.massupdate.triggerprototype' : 'popup.massupdate.trigger') ->addVar('ids', $data['ids']) ->addVar('update', '1') diff --git a/ui/app/views/popup.token.edit.php b/ui/app/views/popup.token.edit.php index 5401d548d3b..4254f6c53ba 100644 --- a/ui/app/views/popup.token.edit.php +++ b/ui/app/views/popup.token.edit.php @@ -31,7 +31,7 @@ $url = (new CUrl('zabbix.php')) $token_form = (new CForm('post', $url)) ->setId('token_form') ->setName('token') - ->setAttribute('aria-labeledby', ZBX_STYLE_PAGE_TITLE) + ->setAttribute('aria-labeledby', CHtmlPage::PAGE_TITLE_ID) ->addVar('admin_mode', $data['admin_mode']) ->addVar('tokenid', $data['tokenid']) ->addItem((new CInput('submit', null))->addStyle('display: none;')); diff --git a/ui/app/views/popup.token.view.php b/ui/app/views/popup.token.view.php index d721247312b..2ac5151c45d 100644 --- a/ui/app/views/popup.token.view.php +++ b/ui/app/views/popup.token.view.php @@ -27,7 +27,7 @@ $token_form = (new CForm()) ->setId('token_form') ->setName('token') - ->setAttribute('aria-labeledby', ZBX_STYLE_PAGE_TITLE) + ->setAttribute('aria-labeledby', CHtmlPage::PAGE_TITLE_ID) ->addItem(makeMessageBox(ZBX_STYLE_MSG_GOOD, [], $data['message'])); $token_from_grid = (new CFormGrid()) diff --git a/ui/app/views/popup.view.php b/ui/app/views/popup.view.php index e616e7f2b58..51f560851b4 100644 --- a/ui/app/views/popup.view.php +++ b/ui/app/views/popup.view.php @@ -25,7 +25,7 @@ $this->addJsFile('class.calendar.js'); -(new CWidget())->show(); +(new CHtmlPage())->show(); (new CScriptTag( 'PopUp("'.$data['popup']['action'].'", '.json_encode($data['popup']['options']).');'. diff --git a/ui/app/views/proxy.list.php b/ui/app/views/proxy.list.php index af69a6abf22..1d57bf31cf2 100644 --- a/ui/app/views/proxy.list.php +++ b/ui/app/views/proxy.list.php @@ -201,7 +201,7 @@ $form->addItem( ], 'proxy') ); -(new CWidget()) +(new CHtmlPage()) ->setTitle(_('Proxies')) ->setDocUrl(CDocHelper::getUrl(CDocHelper::ADMINISTRATION_PROXY_LIST)) ->setControls( diff --git a/ui/app/views/report.status.php b/ui/app/views/report.status.php index ae5f6c38152..0658436199b 100644 --- a/ui/app/views/report.status.php +++ b/ui/app/views/report.status.php @@ -26,7 +26,7 @@ require_once __DIR__.'/../../include/blocks.inc.php'; -(new CWidget()) +(new CHtmlPage()) ->setTitle(_('System information')) ->setDocUrl(CDocHelper::getUrl(CDocHelper::REPORT_STATUS)) ->addItem( diff --git a/ui/app/views/reports.auditlog.list.php b/ui/app/views/reports.auditlog.list.php index 15c20d8b442..72cf315768e 100644 --- a/ui/app/views/reports.auditlog.list.php +++ b/ui/app/views/reports.auditlog.list.php @@ -82,7 +82,7 @@ $filter_form = (new CFormList()) ) ->addRow(_('Actions'), $filter_actions); -$widget = (new CWidget()) +$html_page = (new CHtmlPage()) ->setTitle(_('Audit log')) ->setDocUrl(CDocHelper::getUrl(CDocHelper::REPORTS_AUDITLOG_LIST)) ->addItem($filter @@ -154,7 +154,7 @@ $obj = [ 'timeControl.processObjects();') )->show(); -$widget +$html_page ->addItem( (new CForm('get')) ->setName('auditForm') diff --git a/ui/app/views/reports.scheduledreport.edit.php b/ui/app/views/reports.scheduledreport.edit.php index f98a66e7eb4..fa5a22ec8b0 100644 --- a/ui/app/views/reports.scheduledreport.edit.php +++ b/ui/app/views/reports.scheduledreport.edit.php @@ -29,7 +29,7 @@ $this->includeJsFile('reports.scheduledreport.edit.js.php', [ 'dashboard_inaccessible' => $data['dashboard_inaccessible'] ]); -$widget = (new CWidget()) +$html_page = (new CHtmlPage()) ->setTitle(_('Scheduled reports')) ->setDocUrl(CDocHelper::getUrl(CDocHelper::REPORTS_SCHEDULEDREPORT_EDIT)); @@ -41,7 +41,7 @@ $form = (new CForm()) ->setArgument('action', ($data['reportid'] == 0) ? 'scheduledreport.create' : 'scheduledreport.update') ->getUrl() ) - ->setAttribute('aria-labeledby', ZBX_STYLE_PAGE_TITLE); + ->setAttribute('aria-labeledby', CHtmlPage::PAGE_TITLE_ID); if ($data['reportid'] != 0) { $form->addVar('reportid', $data['reportid']); @@ -58,6 +58,6 @@ $form_grid = new CPartial('scheduledreport.formgrid.html', [ $form->addItem((new CTabView())->addTab('scheduledreport_tab', _('Scheduled report'), $form_grid)); -$widget +$html_page ->addItem($form) ->show(); diff --git a/ui/app/views/reports.scheduledreport.list.php b/ui/app/views/reports.scheduledreport.list.php index 9f645997285..6bcfd395267 100644 --- a/ui/app/views/reports.scheduledreport.list.php +++ b/ui/app/views/reports.scheduledreport.list.php @@ -27,7 +27,7 @@ if ($data['uncheck']) { uncheckTableRows('scheduledreport'); } -$widget = (new CWidget()) +$html_page = (new CHtmlPage()) ->setTitle(_('Scheduled reports')) ->setDocUrl(CDocHelper::getUrl(CDocHelper::REPORTS_SCHEDULEDREPORT_LIST)) ->setControls( @@ -100,6 +100,6 @@ $form->addItem([ ], 'scheduledreport') ]); -$widget +$html_page ->addItem($form) ->show(); diff --git a/ui/app/views/search.php b/ui/app/views/search.php index e7a8bf962fb..13553001022 100644 --- a/ui/app/views/search.php +++ b/ui/app/views/search.php @@ -410,7 +410,7 @@ $sections[] = (new CSectionCollapsible($table)) ->setProfileIdx('web.search.hats.'.SECTION_SEARCH_TEMPLATEGROUP.'.state') ->setExpanded((bool) CProfile::get('web.search.hats.'.SECTION_SEARCH_TEMPLATEGROUP.'.state', true)); -(new CWidget()) +(new CHtmlPage()) ->setTitle(_('Search').': '.$data['search']) ->setDocUrl(CDocHelper::getUrl(CDocHelper::SEARCH)) ->addItem(new CDiv($sections)) diff --git a/ui/app/views/service.list.edit.php b/ui/app/views/service.list.edit.php index e55b09b0578..41be4dabf5d 100644 --- a/ui/app/views/service.list.edit.php +++ b/ui/app/views/service.list.edit.php @@ -119,7 +119,7 @@ $filter->addFilterTab(_('Filter'), [ ]) ]); -(new CWidget()) +(new CHtmlPage()) ->setTitle(_('Services')) ->setDocUrl(CDocHelper::getUrl(CDocHelper::SERVICE_LIST_EDIT)) ->setControls( diff --git a/ui/app/views/service.list.php b/ui/app/views/service.list.php index 40e97de0acb..3dd8ae66ac3 100644 --- a/ui/app/views/service.list.php +++ b/ui/app/views/service.list.php @@ -101,7 +101,7 @@ if ($web_layout_mode == ZBX_LAYOUT_NORMAL) { ]); } -(new CWidget()) +(new CHtmlPage()) ->setTitle(_('Services')) ->setWebLayoutMode($web_layout_mode) ->setDocUrl(CDocHelper::getUrl(CDocHelper::SERVICE_LIST)) diff --git a/ui/app/views/sla.list.php b/ui/app/views/sla.list.php index 2d91209265e..a317fb023d2 100644 --- a/ui/app/views/sla.list.php +++ b/ui/app/views/sla.list.php @@ -181,7 +181,7 @@ if ($data['has_access'][CRoleHelper::ACTIONS_MANAGE_SLA]) { ); } -(new CWidget()) +(new CHtmlPage()) ->setTitle(_('SLA')) ->setDocUrl(CDocHelper::getUrl(CDocHelper::SLA_LIST)) ->setControls( diff --git a/ui/app/views/slareport.list.php b/ui/app/views/slareport.list.php index fba41cdcdca..bfd3c812ee7 100644 --- a/ui/app/views/slareport.list.php +++ b/ui/app/views/slareport.list.php @@ -88,7 +88,7 @@ $filter = (new CFilter()) ]) ]); -$widget = (new CWidget()) +$html_page = (new CHtmlPage()) ->setTitle(_('SLA report')) ->setDocUrl(CDocHelper::getUrl(CDocHelper::SLAREPORT_LIST)) ->addItem($filter); @@ -196,7 +196,7 @@ else { $form->addItem($report); } -$widget +$html_page ->addItem($form) ->show(); diff --git a/ui/hostinventoriesoverview.php b/ui/hostinventoriesoverview.php index 97750f5e7b2..d1e3ed30286 100644 --- a/ui/hostinventoriesoverview.php +++ b/ui/hostinventoriesoverview.php @@ -142,7 +142,7 @@ $select_groupby = (new CSelect('filter_groupby')) ->addOption(new CSelectOption('', _('not selected'))) ->addOptions(CSelect::createOptionsFromArray($inventories)); -(new CWidget()) +(new CHtmlPage()) ->setTitle(_('Host inventory overview')) ->setDocUrl(CDocHelper::getUrl(CDocHelper::INVENTORY_HOST_OVERVIEW)) ->addItem( diff --git a/ui/httpdetails.php b/ui/httpdetails.php index 0aa84c36788..61a14f9a76b 100644 --- a/ui/httpdetails.php +++ b/ui/httpdetails.php @@ -181,7 +181,7 @@ $graph_time->insertFlickerfreeJs(); CScreenBuilder::insertScreenStandardJs($graph_in->timeline); // Create graphs widget. -$widget = (new CWidget()) +(new CHtmlPage()) ->setTitle(_('Details of web scenario').': '.$http_test_name) ->setWebLayoutMode($page['web_layout_mode']) ->setControls((new CTag('nav', true, diff --git a/ui/include/classes/helpers/CDocHelper.php b/ui/include/classes/helpers/CDocHelper.php index cb482048457..5c854ac7f00 100644 --- a/ui/include/classes/helpers/CDocHelper.php +++ b/ui/include/classes/helpers/CDocHelper.php @@ -154,15 +154,15 @@ class CDocHelper { const SLAREPORT_LIST = 'web_interface/frontend_sections/services/sla_report#overview'; const TR_EVENTS = 'web_interface/frontend_sections/monitoring/problems#viewing-details'; - public static function getUrl($path): ?string { + public static function getUrl($path): string { if (CBrandHelper::isRebranded()) { - return null; + return ''; } if (preg_match('/^\d+\.\d+/', ZABBIX_VERSION, $version)) { return ZBX_DOCUMENTATION_URL.'/'.$version[0].'/en/manual/'.$path; } - return null; + return ''; } } diff --git a/ui/include/classes/html/CHtmlPage.php b/ui/include/classes/html/CHtmlPage.php new file mode 100644 index 00000000000..e36e9c5118a --- /dev/null +++ b/ui/include/classes/html/CHtmlPage.php @@ -0,0 +1,186 @@ +title = $title; + + return $this; + } + + public function setTitleSubmenu(array $title_submenu): self { + $this->title_submenu = $title_submenu; + + return $this; + } + + public function setDocUrl(string $doc_url): self { + $this->doc_url = $doc_url; + + return $this; + } + + public function setControls(CTag $controls): self { + $this->controls = $controls; + + return $this; + } + + public function setKioskModeControls(?CList $kiosk_mode_controls): self { + $this->kiosk_mode_controls = $kiosk_mode_controls; + + return $this; + } + + public function setWebLayoutMode(int $web_layout_mode): self { + $this->web_layout_mode = $web_layout_mode; + + return $this; + } + + public function setNavigation(?CList $navigation): self { + $this->navigation = $navigation; + + return $this; + } + + public function addItem($value): self { + if ($value !== null) { + $this->items[] = $value; + } + + return $this; + } + + public function show(): self { + echo $this->toString(); + + return $this; + } + + private function toString() { + $items = []; + + if ($this->web_layout_mode == ZBX_LAYOUT_KIOSKMODE) { + $this->addItem( + (new CList()) + ->addClass(self::ZBX_STYLE_HEADER_KIOSKMODE_CONTROLS) + ->addItem($this->kiosk_mode_controls) + ->addItem( + get_icon('kioskmode', ['mode' => ZBX_LAYOUT_KIOSKMODE]) + ->setAttribute('aria-label', _('Content controls')) + ) + ); + } + elseif ($this->title !== '' || $this->doc_url !== '' || $this->controls !== null) { + $items[] = $this->createTopHeader(); + } + + $items[] = get_prepared_messages([ + 'with_auth_warning' => true, + 'with_session_messages' => true, + 'with_current_messages' => true + ]); + + $navigation = ($this->navigation !== null && $this->web_layout_mode == ZBX_LAYOUT_NORMAL) + ? (new CDiv($this->navigation))->addClass(self::ZBX_STYLE_HEADER_NAVIGATION) + : null; + + $items[] = new CTag('main', true, [$navigation, $this->items]); + + return unpack_object($items); + } + + private function createTopHeader(): CTag { + $divs = [ + (new CTag('nav', true, + (new CButton(null, _('Show sidebar'))) + ->setId('sidebar-button-toggle') + ->addClass('button-toggle') + ->setAttribute('title', _('Show sidebar')) + )) + ->addClass('sidebar-nav-toggle') + ->setAttribute('role', 'navigation') + ->setAttribute('aria-label', _('Sidebar control')) + ]; + + if ($this->title !== '') { + $title_tag = (new CTag('h1', true, $this->title))->setId(self::PAGE_TITLE_ID); + + if ($this->title_submenu) { + $title_tag = (new CLinkAction($title_tag)) + ->setMenuPopup([ + 'type' => 'submenu', + 'data' => [ + 'submenu' => $this->title_submenu + ], + 'options' => [ + 'class' => ZBX_STYLE_PAGE_TITLE_SUBMENU + ] + ]) + ->setAttribute('aria-label', _('Content controls: header')); + } + + $divs[] = new CDiv($title_tag); + } + + if ($this->doc_url !== '') { + $divs[] = (new CDiv( + (new CLink(null, $this->doc_url)) + ->setTitle(_('Help')) + ->setTarget('_blank') + ->addClass(ZBX_STYLE_ICON_DOC_LINK) + ))->addClass(self::ZBX_STYLE_HEADER_DOC_LINK); + } + + if ($this->controls !== null) { + $divs[] = (new CDiv($this->controls))->addClass(self::ZBX_STYLE_HEADER_CONTROLS); + } + + return (new CTag('header', true, $divs))->addClass(self::ZBX_STYLE_HEADER_TITLE); + } +} diff --git a/ui/include/classes/html/CSection.php b/ui/include/classes/html/CSection.php index d5c7e7e24d7..18c77db3930 100644 --- a/ui/include/classes/html/CSection.php +++ b/ui/include/classes/html/CSection.php @@ -33,10 +33,8 @@ class CSection extends CTag { } public function addItem($value): self { - $items = is_array($value) ? $value : [$value]; - - foreach ($items as $item) { - $this->items[] = $item; + if ($value !== null) { + $this->items[] = $value; } return $this; diff --git a/ui/include/classes/html/CSectionCollapsible.php b/ui/include/classes/html/CSectionCollapsible.php index 8dc58ac1e0d..55d3ebf1171 100755 --- a/ui/include/classes/html/CSectionCollapsible.php +++ b/ui/include/classes/html/CSectionCollapsible.php @@ -22,10 +22,10 @@ class CSectionCollapsible extends CSection { private const ZBX_STYLE_COLLAPSED = 'section-collapsed'; - private const ZBX_STYLE_TOGGLE = 'section-toggle'; + private const ZBX_STYLE_TOGGLE = 'section-toggle'; private bool $is_expanded = true; - private string $profile_key; + private string $profile_key = ''; public function setExpanded(bool $is_expanded): self { $this->is_expanded = $is_expanded; diff --git a/ui/include/classes/html/widget/CWidget.php b/ui/include/classes/html/widget/CWidget.php deleted file mode 100644 index 70dbac9f539..00000000000 --- a/ui/include/classes/html/widget/CWidget.php +++ /dev/null @@ -1,207 +0,0 @@ -title = $title; - - return $this; - } - - public function setTitleSubmenu($title_submenu) { - $this->title_submenu = $title_submenu; - - return $this; - } - - public function setDocUrl($doc_url) { - $this->doc_url = $doc_url; - - return $this; - } - - public function setControls($controls) { - $this->controls = $controls; - - return $this; - } - - public function setKioskModeControls($kiosk_mode_controls) { - $this->kiosk_mode_controls = $kiosk_mode_controls; - - return $this; - } - - /** - * Set layout mode. - * - * @param integer $web_layout_mode - * - * @return CWidget - */ - public function setWebLayoutMode($web_layout_mode) { - $this->web_layout_mode = $web_layout_mode; - - return $this; - } - - /** - * Set navigation for displaying exclusively in ZBX_LAYOUT_NORMAL mode. - * - * @param mixed $navigation - * - * @return CWidget - */ - public function setNavigation($navigation) { - $this->navigation = $navigation; - - return $this; - } - - public function addItem($items = null) { - if (!is_null($items)) { - $this->body[] = $items; - } - - return $this; - } - - public function show() { - echo $this->toString(); - - return $this; - } - - public function toString() { - $items = []; - - if ($this->web_layout_mode == ZBX_LAYOUT_KIOSKMODE) { - $this->addItem( - (new CList()) - ->addClass(self::ZBX_STYLE_HEADER_KIOSKMODE_CONTROLS) - ->addItem($this->kiosk_mode_controls) - ->addItem( - get_icon('kioskmode', ['mode' => ZBX_LAYOUT_KIOSKMODE]) - ->setAttribute('aria-label', _('Content controls')) - ) - ); - } - elseif ($this->title !== null || $this->controls !== null || $this->doc_url !== null) { - $items[] = $this->createTopHeader(); - } - - $items[] = get_prepared_messages([ - 'with_auth_warning' => true, - 'with_session_messages' => true, - 'with_current_messages' => true - ]); - - $navigation = ($this->navigation !== null && $this->web_layout_mode == ZBX_LAYOUT_NORMAL) - ? (new CDiv($this->navigation))->addClass(self::ZBX_STYLE_HEADER_NAVIGATION) - : null; - - $items[] = new CTag('main', true, [$navigation, $this->body]); - - return unpack_object($items); - } - - private function createTopHeader(): CTag { - $divs = [ - (new CTag('nav', true, (new CButton(null, _('Show sidebar'))) - ->setId('sidebar-button-toggle') - ->addClass('button-toggle') - ->setAttribute('title', _('Show sidebar')) - )) - ->addClass('sidebar-nav-toggle') - ->setAttribute('role', 'navigation') - ->setAttribute('aria-label', _('Sidebar control')) - ]; - - if ($this->title !== null) { - $title_tag = (new CTag('h1', true, $this->title))->setId(ZBX_STYLE_PAGE_TITLE); - - if ($this->title_submenu) { - $title_tag = (new CLinkAction($title_tag)) - ->setMenuPopup([ - 'type' => 'submenu', - 'data' => [ - 'submenu' => $this->title_submenu - ], - 'options' => [ - 'class' => ZBX_STYLE_PAGE_TITLE_SUBMENU - ] - ]) - ->setAttribute('aria-label', _('Content controls: header')); - } - - $divs[] = new CDiv($title_tag); - } - - if ($this->doc_url !== null) { - $divs[] = (new CDiv( - (new CLink(null, $this->doc_url)) - ->setTitle(_('Help')) - ->setTarget('_blank') - ->addClass(ZBX_STYLE_ICON_DOC_LINK) - ))->addClass(self::ZBX_STYLE_HEADER_DOC_LINK); - } - - if ($this->controls !== null) { - $divs[] = (new CDiv($this->controls))->addClass(self::ZBX_STYLE_HEADER_CONTROLS); - } - - return (new CTag('header', true, $divs))->addClass(self::ZBX_STYLE_HEADER_TITLE); - } -} diff --git a/ui/include/defines.inc.php b/ui/include/defines.inc.php index 2ec06e39d65..a0ca86a053f 100644 --- a/ui/include/defines.inc.php +++ b/ui/include/defines.inc.php @@ -2035,7 +2035,6 @@ define('ZBX_STYLE_OVERLAY_DESCR_URL', 'overlay-descr-url'); define('ZBX_STYLE_OVERFLOW_ELLIPSIS', 'overflow-ellipsis'); define('ZBX_STYLE_PAGING_BTN_CONTAINER', 'paging-btn-container'); define('ZBX_STYLE_PAGING_SELECTED', 'paging-selected'); -define('ZBX_STYLE_PAGE_TITLE', 'page-title-general'); define('ZBX_STYLE_PAGE_TITLE_SUBMENU', 'page-title-submenu'); define('ZBX_STYLE_RED', 'red'); define('ZBX_STYLE_RED_BG', 'red-bg'); diff --git a/ui/include/func.inc.php b/ui/include/func.inc.php index 2d7a397fb31..72090d4e2f9 100644 --- a/ui/include/func.inc.php +++ b/ui/include/func.inc.php @@ -1559,7 +1559,7 @@ function access_deny($mode = ACCESS_DENY_OBJECT) { show_error_message(_('No permissions to referred object or it does not exist!')); require_once dirname(__FILE__).'/page_header.php'; - (new CWidget())->show(); + (new CHtmlPage())->show(); require_once dirname(__FILE__).'/page_footer.php'; } // deny access to a page diff --git a/ui/include/html.inc.php b/ui/include/html.inc.php index c743aab530d..9ce39ff9758 100644 --- a/ui/include/html.inc.php +++ b/ui/include/html.inc.php @@ -806,7 +806,7 @@ function makePageFooter($with_version = true) { /** * Get drop-down submenu item list for the User settings section. * - * @return array|null Menu definition for CWidget::setTitleSubmenu. + * @return array|null Menu definition for CHtmlPage::setTitleSubmenu. */ function getUserSettingsSubmenu(): ?array { if (!CWebUser::checkAccess(CRoleHelper::ACTIONS_MANAGE_API_TOKENS)) { @@ -834,7 +834,7 @@ function getUserSettingsSubmenu(): ?array { /** * Get drop-down submenu item list for the Administration->General section. * - * @return array Menu definition for CWidget::setTitleSubmenu. + * @return array Menu definition for CHtmlPage::setTitleSubmenu. */ function getAdministrationGeneralSubmenu() { $gui_url = (new CUrl('zabbix.php')) diff --git a/ui/include/validate.inc.php b/ui/include/validate.inc.php index af7fa11b066..f777d2aab02 100644 --- a/ui/include/validate.inc.php +++ b/ui/include/validate.inc.php @@ -378,7 +378,7 @@ function invalid_url($msg = null) { unset_all(); show_error_message($msg); - (new CWidget())->show(); + (new CHtmlPage())->show(); require_once dirname(__FILE__).'/page_footer.php'; } diff --git a/ui/include/views/administration.auditacts.list.php b/ui/include/views/administration.auditacts.list.php index 241b33fa074..16527340b71 100644 --- a/ui/include/views/administration.auditacts.list.php +++ b/ui/include/views/administration.auditacts.list.php @@ -23,7 +23,7 @@ * @var CView $this */ -$auditWidget = (new CWidget()) +$html_page = (new CHtmlPage()) ->setTitle(_('Action log')) ->setDocUrl(CDocHelper::getUrl(CDocHelper::ADMINISTRATION_AUDITACTS_LIST)); @@ -47,7 +47,7 @@ $filterColumn->addRow(new CLabel(_('Recipients'), 'filter_userids__ms'), [ ]))->setWidth(ZBX_TEXTAREA_FILTER_STANDARD_WIDTH) ]); -$auditWidget->addItem( +$html_page->addItem( (new CFilter()) ->setResetUrl(new CUrl('auditacts.php')) ->setProfile($data['timeline']['profileIdx']) @@ -141,7 +141,6 @@ $objData = [ zbx_add_post_js('timeControl.addObject("events", '.zbx_jsvalue($data['timeline']).', '.zbx_jsvalue($objData).');'); zbx_add_post_js('timeControl.processObjects();'); -// append form to widget -$auditWidget->addItem($auditForm); - -$auditWidget->show(); +$html_page + ->addItem($auditForm) + ->show(); diff --git a/ui/include/views/configuration.action.edit.php b/ui/include/views/configuration.action.edit.php index 498ab82b198..01e5c413f85 100644 --- a/ui/include/views/configuration.action.edit.php +++ b/ui/include/views/configuration.action.edit.php @@ -25,7 +25,7 @@ require_once dirname(__FILE__).'/js/configuration.action.edit.js.php'; -$widget = (new CWidget()) +$html_page = (new CHtmlPage()) ->setTitle(_('Actions')) ->setDocUrl(CDocHelper::getUrl(CDocHelper::CONFIGURATION_ACTION_EDIT)); @@ -37,7 +37,7 @@ $actionForm = (new CForm()) ->setArgument('eventsource', $data['eventsource']) ->getUrl() ) - ->setAttribute('aria-labeledby', ZBX_STYLE_PAGE_TITLE) + ->setAttribute('aria-labeledby', CHtmlPage::PAGE_TITLE_ID) ->addVar('form', $data['form']); if ($data['actionid']) { @@ -539,7 +539,6 @@ $action_tabs->setFooter([ ]); $actionForm->addItem($action_tabs); -// Append form to widget. -$widget->addItem($actionForm); - -$widget->show(); +$html_page + ->addItem($actionForm) + ->show(); diff --git a/ui/include/views/configuration.action.list.php b/ui/include/views/configuration.action.list.php index 71289750870..f7a8498f1f3 100644 --- a/ui/include/views/configuration.action.list.php +++ b/ui/include/views/configuration.action.list.php @@ -52,7 +52,7 @@ else { $current_url = (new CUrl('actionconf.php'))->setArgument('eventsource', $data['eventsource']); -$widget = (new CWidget()) +$html_page = (new CHtmlPage()) ->setTitle($title) ->setTitleSubmenu($submenu ? ['main_section' => ['items' => $submenu]] : null) ->setDocUrl(CDocHelper::getUrl($doc_url)) @@ -173,7 +173,6 @@ $actionForm->addItem([ ], $data['eventsource']) ]); -// append form to widget -$widget->addItem($actionForm); - -$widget->show(); +$html_page + ->addItem($actionForm) + ->show(); diff --git a/ui/include/views/configuration.copy.elements.php b/ui/include/views/configuration.copy.elements.php index a46fcf7a508..fe7f5f6acf1 100644 --- a/ui/include/views/configuration.copy.elements.php +++ b/ui/include/views/configuration.copy.elements.php @@ -24,7 +24,7 @@ * @var array $data */ -$widget = (new CWidget())->setTitle($data['title']); +$html_page = (new CHtmlPage())->setTitle($data['title']); // append host summary to widget header if ($data['hostid'] != 0) { @@ -42,13 +42,13 @@ if ($data['hostid'] != 0) { $host_table_element = ''; } - $widget->setNavigation(getHostNavigation($host_table_element, $data['hostid'])); + $html_page->setNavigation(getHostNavigation($host_table_element, $data['hostid'])); } // create form $form = (new CForm('post', (new CUrl())->getUrl())) ->setName('elements_form') - ->setAttribute('aria-labeledby', ZBX_STYLE_PAGE_TITLE) + ->setAttribute('aria-labeledby', CHtmlPage::PAGE_TITLE_ID) ->addVar('action', $data['action']) ->addVar($data['elements_field'], $data['elements']) ->addVar('hostid', $data['hostid']); @@ -81,11 +81,11 @@ $tab_view->setFooter(makeFormFooter( )); $form->addItem($tab_view); -$widget->addItem($form); +$html_page->addItem($form); require_once dirname(__FILE__).'/js/configuration.copy.elements.js.php'; -$widget->show(); +$html_page->show(); (new CScriptTag(' view.init('.json_encode([ diff --git a/ui/include/views/configuration.graph.edit.php b/ui/include/views/configuration.graph.edit.php index 1226b813223..4219cf4b57c 100644 --- a/ui/include/views/configuration.graph.edit.php +++ b/ui/include/views/configuration.graph.edit.php @@ -23,16 +23,16 @@ * @var CView $this */ -$widget = new CWidget(); +$html_page = new CHtmlPage(); if ($data['parent_discoveryid'] === null) { - $widget + $html_page ->setTitle(_('Graphs')) ->setDocUrl(CDocHelper::getUrl(CDocHelper::CONFIGURATION_GRAPH_EDIT)) ->setNavigation(getHostNavigation('graphs', $data['hostid'])); } else { - $widget + $html_page ->setTitle(_('Graph prototypes')) ->setDocUrl(CDocHelper::getUrl(CDocHelper::CONFIGURATION_PROTOTYPE_GRAPH_EDIT)) ->setNavigation(getHostNavigation('graphs', $data['hostid'], $data['parent_discoveryid'])); @@ -46,7 +46,7 @@ $url = (new CUrl('graphs.php')) // Create form. $graphForm = (new CForm('post', $url)) ->setName('graphForm') - ->setAttribute('aria-labeledby', ZBX_STYLE_PAGE_TITLE) + ->setAttribute('aria-labeledby', CHtmlPage::PAGE_TITLE_ID) ->addVar('form', $data['form']) ->addVar('hostid', $data['hostid']); @@ -533,10 +533,9 @@ require_once dirname(__FILE__).'/js/configuration.graph.edit.js.php'; $graphForm->addItem($graphTab); -// Append form to widget. -$widget->addItem($graphForm); - -$widget->show(); +$html_page + ->addItem($graphForm) + ->show(); (new CScriptTag(' view.init('.json_encode([ diff --git a/ui/include/views/configuration.graph.list.php b/ui/include/views/configuration.graph.list.php index 0f49c9f6250..91a96e3ba35 100644 --- a/ui/include/views/configuration.graph.list.php +++ b/ui/include/views/configuration.graph.list.php @@ -26,7 +26,7 @@ $this->includeJsFile('configuration.graph.list.js.php'); if (!empty($this->data['parent_discoveryid'])) { - $widget = (new CWidget()) + $html_page = (new CHtmlPage()) ->setTitle(_('Graph prototypes')) ->setDocUrl(CDocHelper::getUrl($data['context'] === 'host' ? CDocHelper::CONFIGURATION_HOST_GRAPH_PROTOTYPE_LIST @@ -48,7 +48,7 @@ if (!empty($this->data['parent_discoveryid'])) { ->setNavigation(getHostNavigation('graphs', $this->data['hostid'], $this->data['parent_discoveryid'])); } else { - $widget = (new CWidget()) + $html_page = (new CHtmlPage()) ->setTitle(_('Graphs')) ->setDocUrl(CDocHelper::getUrl($data['context'] === 'host' ? CDocHelper::CONFIGURATION_HOST_GRAPH_LIST @@ -75,13 +75,13 @@ else { ); if (!empty($this->data['hostid'])) { - $widget->setNavigation(getHostNavigation('graphs', $this->data['hostid'])); + $html_page->setNavigation(getHostNavigation('graphs', $this->data['hostid'])); } // Add filter tab. $hg_ms_params = $data['context'] === 'host' ? ['with_hosts' => true] : ['with_templates' => true]; - $widget->addItem( + $html_page->addItem( (new CFilter()) ->setResetUrl((new CUrl('graphs.php'))->setArgument('context', $data['context'])) ->setProfile($data['profileIdx']) @@ -269,7 +269,6 @@ $graphForm->addItem([ ) ]); -// append form to widget -$widget->addItem($graphForm); - -$widget->show(); +$html_page + ->addItem($graphForm) + ->show(); diff --git a/ui/include/views/configuration.host.discovery.edit.php b/ui/include/views/configuration.host.discovery.edit.php index ae9cf267aa6..6db79dd43f1 100644 --- a/ui/include/views/configuration.host.discovery.edit.php +++ b/ui/include/views/configuration.host.discovery.edit.php @@ -24,7 +24,7 @@ * @var array $data */ -$widget = (new CWidget()) +$html_page = (new CHtmlPage()) ->setTitle(_('Discovery rules')) ->setDocUrl(CDocHelper::getUrl(CDocHelper::CONFIGURATION_HOST_DISCOVERY_EDIT)) ->setNavigation(getHostNavigation('discoveries', $data['hostid'], @@ -38,7 +38,7 @@ $url = (new CUrl('host_discovery.php')) $form = (new CForm('post', $url)) ->setId('host-discovery-form') ->setName('itemForm') - ->setAttribute('aria-labeledby', ZBX_STYLE_PAGE_TITLE) + ->setAttribute('aria-labeledby', CHtmlPage::PAGE_TITLE_ID) ->addVar('form', $data['form']) ->addVar('hostid', $data['hostid']) ->addVar('backurl', $data['backurl']); @@ -1021,11 +1021,11 @@ else { $tab->setFooter(new CFormGrid($form_actions)); $form->addItem($tab); -$widget->addItem($form); +$html_page->addItem($form); require_once __DIR__.'/js/configuration.host.discovery.edit.js.php'; -$widget->show(); +$html_page->show(); (new CScriptTag(' item_form.init('.json_encode([ diff --git a/ui/include/views/configuration.host.discovery.list.php b/ui/include/views/configuration.host.discovery.list.php index 60045bb440d..cd2d5b92ae3 100644 --- a/ui/include/views/configuration.host.discovery.list.php +++ b/ui/include/views/configuration.host.discovery.list.php @@ -25,7 +25,7 @@ require_once dirname(__FILE__).'/js/configuration.host.discovery.list.js.php'; -$widget = (new CWidget()) +$html_page = (new CHtmlPage()) ->setTitle(_('Discovery rules')) ->setDocUrl(CDocHelper::getUrl($data['context'] === 'host' ? CDocHelper::CONFIGURATION_HOST_DISCOVERY_LIST @@ -52,7 +52,7 @@ $widget = (new CWidget()) ); if ($data['hostid'] != 0) { - $widget->setNavigation(getHostNavigation('discoveries', $data['hostid'])); + $html_page->setNavigation(getHostNavigation('discoveries', $data['hostid'])); } // Add filter tab. @@ -176,7 +176,7 @@ $filter_column3->addRow(_('Status'), $filter->addFilterTab(_('Filter'), [$filter_column1, $filter_column2, $filter_column3]); -$widget->addItem($filter); +$html_page->addItem($filter); $url = (new CUrl('host_discovery.php')) ->setArgument('context', $data['context']) @@ -360,10 +360,9 @@ $discoveryForm->addItem([$discoveryTable, $data['paging'], new CActionButtonList $button_list, $data['checkbox_hash'] )]); -// Append form to widget. -$widget->addItem($discoveryForm); - -$widget->show(); +$html_page + ->addItem($discoveryForm) + ->show(); (new CScriptTag(' view.init('.json_encode([ diff --git a/ui/include/views/configuration.host.prototype.edit.php b/ui/include/views/configuration.host.prototype.edit.php index 551e86d4776..794d5f3f52a 100644 --- a/ui/include/views/configuration.host.prototype.edit.php +++ b/ui/include/views/configuration.host.prototype.edit.php @@ -29,7 +29,7 @@ require_once __DIR__.'/js/common.template.edit.js.php'; $host_prototype = $data['host_prototype']; $parent_host = $data['parent_host']; -$widget = (new CWidget()) +$html_page = (new CHtmlPage()) ->setTitle(_('Host prototypes')) ->setDocUrl(CDocHelper::getUrl(CDocHelper::CONFIGURATION_HOST_PROTOTYPE_EDIT)) ->setNavigation(getHostNavigation('hosts', $data['discovery_rule']['hostid'], $data['discovery_rule']['itemid'])); @@ -48,7 +48,7 @@ $url = (new CUrl('host_prototypes.php')) $form = (new CForm('post', $url)) ->setId('host-prototype-form') ->setName('hostPrototypeForm') - ->setAttribute('aria-labeledby', ZBX_STYLE_PAGE_TITLE) + ->setAttribute('aria-labeledby', CHtmlPage::PAGE_TITLE_ID) ->addVar('form', getRequest('form', 1)) ->addVar('parent_discoveryid', $data['discovery_rule']['itemid']) ->addVar('tls_accept', $parent_host['tls_accept']) @@ -434,6 +434,7 @@ else { } $form->addItem($tabs); -$widget->addItem($form); -$widget->show(); +$html_page + ->addItem($form) + ->show(); diff --git a/ui/include/views/configuration.host.prototype.list.php b/ui/include/views/configuration.host.prototype.list.php index 1344730ab71..f8a56e01094 100644 --- a/ui/include/views/configuration.host.prototype.list.php +++ b/ui/include/views/configuration.host.prototype.list.php @@ -25,7 +25,7 @@ require_once dirname(__FILE__).'/js/configuration.host.prototype.list.js.php'; -$widget = (new CWidget()) +$html_page = (new CHtmlPage()) ->setTitle(_('Host prototypes')) ->setDocUrl(CDocHelper::getUrl($data['context'] === 'host' ? CDocHelper::CONFIGURATION_HOST_PROTOTYPE_LIST @@ -206,7 +206,6 @@ $itemForm->addItem([ ) ]); -// append form to widget -$widget->addItem($itemForm); - -$widget->show(); +$html_page + ->addItem($itemForm) + ->show(); diff --git a/ui/include/views/configuration.httpconf.edit.php b/ui/include/views/configuration.httpconf.edit.php index cf81d82faec..f1bdfc91851 100644 --- a/ui/include/views/configuration.httpconf.edit.php +++ b/ui/include/views/configuration.httpconf.edit.php @@ -23,13 +23,13 @@ * @var CView $this */ -$widget = (new CWidget()) +$html_page = (new CHtmlPage()) ->setTitle(_('Web monitoring')) ->setDocUrl(CDocHelper::getUrl(CDocHelper::CONFIGURATION_HTTPCONF_EDIT)); // append host summary to widget header if (!empty($this->data['hostid'])) { - $widget->setNavigation(getHostNavigation('web', $this->data['hostid'])); + $html_page->setNavigation(getHostNavigation('web', $this->data['hostid'])); } $url = (new CUrl('httpconf.php')) @@ -40,7 +40,7 @@ $url = (new CUrl('httpconf.php')) $http_form = (new CForm('post', $url)) ->setId('http-form') ->setName('httpForm') - ->setAttribute('aria-labeledby', ZBX_STYLE_PAGE_TITLE) + ->setAttribute('aria-labeledby', CHtmlPage::PAGE_TITLE_ID) ->addVar('form', $this->data['form']) ->addVar('hostid', $this->data['hostid']) ->addVar('templated', $this->data['templated']); @@ -280,7 +280,7 @@ else { } $http_form->addItem($http_tab); -$widget->addItem($http_form); +$html_page->addItem($http_form); $this->data['scenario_tab_data'] = [ 'agent_visibility' => [], @@ -299,7 +299,7 @@ zbx_subarray_push($this->data['scenario_tab_data']['agent_visibility'], ZBX_AGEN require_once dirname(__FILE__).'/js/configuration.httpconf.edit.js.php'; -$widget->show(); +$html_page->show(); (new CScriptTag(' view.init('.json_encode([ diff --git a/ui/include/views/configuration.httpconf.list.php b/ui/include/views/configuration.httpconf.list.php index fa6a2665e69..02d31839b70 100644 --- a/ui/include/views/configuration.httpconf.list.php +++ b/ui/include/views/configuration.httpconf.list.php @@ -87,7 +87,7 @@ $filter = (new CFilter()) ->addvar('context', $data['context']) ->addFilterTab(_('Filter'), [$filter_column_left, $filter_column_right]); -$widget = (new CWidget()) +$html_page = (new CHtmlPage()) ->setTitle(_('Web monitoring')) ->setDocUrl(CDocHelper::getUrl($data['context'] === 'host' ? CDocHelper::CONFIGURATION_HOST_HTTPCONF_LIST @@ -114,10 +114,10 @@ $widget = (new CWidget()) ); if (!empty($this->data['hostid'])) { - $widget->setNavigation(getHostNavigation('web', $this->data['hostid'])); + $html_page->setNavigation(getHostNavigation('web', $this->data['hostid'])); } -$widget->addItem($filter); +$html_page->addItem($filter); $url = (new CUrl('httpconf.php')) ->setArgument('context', $data['context']) @@ -236,10 +236,9 @@ $httpForm->addItem([$httpTable, $data['paging'], new CActionButtonList('action', $data['hostid'] )]); -// Append form to widget. -$widget->addItem($httpForm); - -$widget->show(); +$html_page + ->addItem($httpForm) + ->show(); (new CScriptTag('view.init();')) ->setOnDocumentReady() diff --git a/ui/include/views/configuration.item.edit.php b/ui/include/views/configuration.item.edit.php index bc7bddf1ef1..e74cd4c16cc 100644 --- a/ui/include/views/configuration.item.edit.php +++ b/ui/include/views/configuration.item.edit.php @@ -24,14 +24,14 @@ * @var array $data */ -$widget = (new CWidget()) +$html_page = (new CHtmlPage()) ->setTitle(_('Items')) ->setDocUrl(CDocHelper::getUrl(CDocHelper::CONFIGURATION_ITEM_EDIT)); $host = $data['host']; if (!empty($data['hostid'])) { - $widget->setNavigation(getHostNavigation('items', $data['hostid'])); + $html_page->setNavigation(getHostNavigation('items', $data['hostid'])); } $url = (new CUrl('items.php')) @@ -42,7 +42,7 @@ $url = (new CUrl('items.php')) $form = (new CForm('post', $url)) ->setId('item-form') ->setName('itemForm') - ->setAttribute('aria-labeledby', ZBX_STYLE_PAGE_TITLE) + ->setAttribute('aria-labeledby', CHtmlPage::PAGE_TITLE_ID) ->addVar('form', $data['form']) ->addVar('hostid', $data['hostid']); @@ -1102,11 +1102,11 @@ else { } $form->addItem($item_tabs); -$widget->addItem($form); +$html_page->addItem($form); require_once __DIR__.'/js/configuration.item.edit.js.php'; -$widget->show(); +$html_page->show(); (new CScriptTag(' item_form.init('.json_encode([ diff --git a/ui/include/views/configuration.item.list.php b/ui/include/views/configuration.item.list.php index a3f23be2c7f..5301b2ce33c 100644 --- a/ui/include/views/configuration.item.list.php +++ b/ui/include/views/configuration.item.list.php @@ -25,7 +25,7 @@ require_once dirname(__FILE__).'/js/configuration.item.list.js.php'; -$widget = (new CWidget()) +$html_page = (new CHtmlPage()) ->setTitle(_('Items')) ->setDocUrl(CDocHelper::getUrl($data['context'] === 'host' ? CDocHelper::CONFIGURATION_HOST_ITEM_LIST @@ -52,10 +52,10 @@ $widget = (new CWidget()) ); if ($data['hostid'] != 0) { - $widget->setNavigation(getHostNavigation('items', $data['hostid'])); + $html_page->setNavigation(getHostNavigation('items', $data['hostid'])); } -$widget->addItem(new CPartial('configuration.filter.items', [ +$html_page->addItem(new CPartial('configuration.filter.items', [ 'filter_data' => $data['filter_data'], 'subfilter' => $data['subfilter'], 'context' => $data['context'] @@ -343,10 +343,9 @@ $itemForm->addItem([$itemTable, $data['paging'], new CActionButtonList('action', $data['checkbox_hash'] )]); -// Append form to widget. -$widget->addItem($itemForm); - -$widget->show(); +$html_page + ->addItem($itemForm) + ->show(); (new CScriptTag(' view.init('.json_encode([ diff --git a/ui/include/views/configuration.item.prototype.edit.php b/ui/include/views/configuration.item.prototype.edit.php index 86ed2e3c1ff..63771e51bd5 100644 --- a/ui/include/views/configuration.item.prototype.edit.php +++ b/ui/include/views/configuration.item.prototype.edit.php @@ -24,12 +24,12 @@ * @var array $data */ -$widget = (new CWidget()) +$html_page = (new CHtmlPage()) ->setTitle(_('Item prototypes')) ->setDocUrl(CDocHelper::getUrl(CDocHelper::CONFIGURATION_ITEM_PROTOTYPE_EDIT)); if (!empty($data['hostid'])) { - $widget->setNavigation(getHostNavigation('items', $data['hostid'], $data['parent_discoveryid'])); + $html_page->setNavigation(getHostNavigation('items', $data['hostid'], $data['parent_discoveryid'])); } $url = (new CUrl('disc_prototypes.php')) @@ -40,7 +40,7 @@ $url = (new CUrl('disc_prototypes.php')) $form = (new CForm('post', $url)) ->setId('item-prototype-form') ->setName('itemForm') - ->setAttribute('aria-labeledby', ZBX_STYLE_PAGE_TITLE) + ->setAttribute('aria-labeledby', CHtmlPage::PAGE_TITLE_ID) ->addVar('form', $data['form']) ->addVar('parent_discoveryid', $data['parent_discoveryid']); @@ -939,11 +939,11 @@ else { } $form->addItem($item_tabs); -$widget->addItem($form); +$html_page->addItem($form); require_once __DIR__.'/js/configuration.item.prototype.edit.js.php'; -$widget->show(); +$html_page->show(); (new CScriptTag(' item_form.init('.json_encode([ diff --git a/ui/include/views/configuration.item.prototype.list.php b/ui/include/views/configuration.item.prototype.list.php index fc948b014b7..812b28de5cf 100644 --- a/ui/include/views/configuration.item.prototype.list.php +++ b/ui/include/views/configuration.item.prototype.list.php @@ -25,7 +25,7 @@ require_once dirname(__FILE__).'/js/configuration.item.prototype.list.js.php'; -$widget = (new CWidget()) +$html_page = (new CHtmlPage()) ->setTitle(_('Item prototypes')) ->setDocUrl(CDocHelper::getUrl($data['context'] === 'host' ? CDocHelper::CONFIGURATION_HOST_ITEM_PROTOTYPE_LIST @@ -226,7 +226,6 @@ $itemForm->addItem([ ) ]); -// append form to widget -$widget->addItem($itemForm); - -$widget->show(); +$html_page + ->addItem($itemForm) + ->show(); diff --git a/ui/include/views/configuration.maintenance.edit.php b/ui/include/views/configuration.maintenance.edit.php index d932c9e7fe4..bf87235d160 100644 --- a/ui/include/views/configuration.maintenance.edit.php +++ b/ui/include/views/configuration.maintenance.edit.php @@ -25,14 +25,14 @@ require_once dirname(__FILE__).'/js/configuration.maintenance.edit.js.php'; -$widget = (new CWidget()) +$html_page = (new CHtmlPage()) ->setTitle(_('Maintenance periods')) ->setDocUrl(CDocHelper::getUrl(CDocHelper::CONFIGURATION_MAINTENANCE_EDIT)); $maintenance_form = (new CForm()) ->setId('maintenance-form') ->setName('maintenanceForm') - ->setAttribute('aria-labeledby', ZBX_STYLE_PAGE_TITLE) + ->setAttribute('aria-labeledby', CHtmlPage::PAGE_TITLE_ID) ->addVar('form', $data['form']); if (array_key_exists('maintenanceid', $data) && $data['maintenanceid']) { @@ -281,6 +281,6 @@ else { $maintenance_form->addItem($maintenance_tab); -$widget->addItem($maintenance_form); - -$widget->show(); +$html_page + ->addItem($maintenance_form) + ->show(); diff --git a/ui/include/views/configuration.maintenance.list.php b/ui/include/views/configuration.maintenance.list.php index 4da46f3646a..450576650f7 100644 --- a/ui/include/views/configuration.maintenance.list.php +++ b/ui/include/views/configuration.maintenance.list.php @@ -23,7 +23,7 @@ * @var CView $this */ -$widget = (new CWidget()) +$html_page = (new CHtmlPage()) ->setTitle(_('Maintenance periods')) ->setDocUrl(CDocHelper::getUrl(CDocHelper::CONFIGURATION_MAINTENANCE_LIST)) ->setControls( @@ -129,7 +129,6 @@ $maintenanceForm->addItem([ ]) ]); -// append form to widget -$widget->addItem($maintenanceForm); - -$widget->show(); +$html_page + ->addItem($maintenanceForm) + ->show(); diff --git a/ui/include/views/configuration.template.edit.php b/ui/include/views/configuration.template.edit.php index 6b45a2bd10d..b70bb4f1eab 100644 --- a/ui/include/views/configuration.template.edit.php +++ b/ui/include/views/configuration.template.edit.php @@ -25,12 +25,12 @@ require_once __DIR__.'/js/common.template.edit.js.php'; -$widget = (new CWidget()) +$html_page = (new CHtmlPage()) ->setTitle(_('Templates')) ->setDocUrl(CDocHelper::getUrl(CDocHelper::CONFIGURATION_TEMPLATES_EDIT)); if ($data['form'] !== 'clone' && $data['form'] !== 'full_clone') { - $widget->setNavigation(getHostNavigation('', $data['templateid'])); + $html_page->setNavigation(getHostNavigation('', $data['templateid'])); } $tabs = new CTabView(); @@ -42,7 +42,7 @@ if (!hasRequest('form_refresh')) { $form = (new CForm()) ->setId('templates-form') ->setName('templatesForm') - ->setAttribute('aria-labeledby', ZBX_STYLE_PAGE_TITLE) + ->setAttribute('aria-labeledby', CHtmlPage::PAGE_TITLE_ID) ->addVar('form', $data['form']); if ($data['templateid'] != 0) { @@ -235,6 +235,7 @@ else { } $form->addItem($tabs); -$widget->addItem($form); -$widget->show(); +$html_page + ->addItem($form) + ->show(); diff --git a/ui/include/views/configuration.template.list.php b/ui/include/views/configuration.template.list.php index 2f4e4fd8a8c..a2c69e92676 100644 --- a/ui/include/views/configuration.template.list.php +++ b/ui/include/views/configuration.template.list.php @@ -83,7 +83,7 @@ $filter = (new CFilter()) (new CFormList())->addRow(_('Tags'), $filter_tags_table) ]); -$widget = (new CWidget()) +$html_page = (new CHtmlPage()) ->setTitle(_('Templates')) ->setDocUrl(CDocHelper::getUrl(CDocHelper::CONFIGURATION_TEMPLATES_LIST)) ->setControls((new CTag('nav', true, @@ -296,6 +296,6 @@ $form->addItem([ ) ]); -$widget->addItem($form); - -$widget->show(); +$html_page + ->addItem($form) + ->show(); diff --git a/ui/include/views/configuration.trigger.prototype.edit.php b/ui/include/views/configuration.trigger.prototype.edit.php index 940ab27f2fb..b2d10ac3189 100644 --- a/ui/include/views/configuration.trigger.prototype.edit.php +++ b/ui/include/views/configuration.trigger.prototype.edit.php @@ -25,7 +25,7 @@ require_once dirname(__FILE__).'/js/configuration.triggers.edit.js.php'; -$triggersWidget = (new CWidget()) +$html_page = (new CHtmlPage()) ->setTitle(_('Trigger prototypes')) ->setDocUrl(CDocHelper::getUrl(CDocHelper::CONFIGURATION_TRIGGER_PROTOTYPE_EDIT)) ->setNavigation(getHostNavigation('triggers', $data['hostid'], $data['parent_discoveryid'])); @@ -39,7 +39,7 @@ $url = (new CUrl('trigger_prototypes.php')) $triggersForm = (new CForm('post', $url)) ->setId('triggers-prototype-form') ->setName('triggersForm') - ->setAttribute('aria-labeledby', ZBX_STYLE_PAGE_TITLE) + ->setAttribute('aria-labeledby', CHtmlPage::PAGE_TITLE_ID) ->addVar('form', $data['form']) ->addItem((new CVar('parent_discoveryid', $data['parent_discoveryid']))->removeId()) ->addVar('expression_constructor', $data['expression_constructor']) @@ -735,9 +735,9 @@ else { // append tabs to form $triggersForm->addItem($triggersTab); -$triggersWidget->addItem($triggersForm); - -$triggersWidget->show(); +$html_page + ->addItem($triggersForm) + ->show(); (new CScriptTag(' view.init('.json_encode([ diff --git a/ui/include/views/configuration.trigger.prototype.list.php b/ui/include/views/configuration.trigger.prototype.list.php index 5c3c4202bfc..4221190028a 100644 --- a/ui/include/views/configuration.trigger.prototype.list.php +++ b/ui/include/views/configuration.trigger.prototype.list.php @@ -25,7 +25,7 @@ require_once dirname(__FILE__).'/js/configuration.trigger.prototype.list.js.php'; -$widget = (new CWidget()) +$html_page = (new CHtmlPage()) ->setTitle(_('Trigger prototypes')) ->setDocUrl(CDocHelper::getUrl($data['context'] === 'host' ? CDocHelper::CONFIGURATION_HOST_TRIGGER_PROTOTYPE_LIST @@ -226,7 +226,6 @@ $triggersForm->addItem([ ) ]); -// append form to widget -$widget->addItem($triggersForm); - -$widget->show(); +$html_page + ->addItem($triggersForm) + ->show(); diff --git a/ui/include/views/configuration.triggers.edit.php b/ui/include/views/configuration.triggers.edit.php index c12a6c9e1e7..fa874160c0c 100644 --- a/ui/include/views/configuration.triggers.edit.php +++ b/ui/include/views/configuration.triggers.edit.php @@ -25,13 +25,13 @@ require_once dirname(__FILE__).'/js/configuration.triggers.edit.js.php'; -$widget = (new CWidget()) +$html_page = (new CHtmlPage()) ->setTitle(_('Triggers')) ->setDocUrl(CDocHelper::getUrl(CDocHelper::CONFIGURATION_TRIGGERS_EDIT)); // Append host summary to widget header. if ($data['hostid'] != 0) { - $widget->setNavigation(getHostNavigation('triggers', $data['hostid'])); + $html_page->setNavigation(getHostNavigation('triggers', $data['hostid'])); } $url = (new CUrl('triggers.php')) @@ -42,7 +42,7 @@ $url = (new CUrl('triggers.php')) $triggersForm = (new CForm('post', $url)) ->setid('triggers-form') ->setName('triggersForm') - ->setAttribute('aria-labeledby', ZBX_STYLE_PAGE_TITLE) + ->setAttribute('aria-labeledby', CHtmlPage::PAGE_TITLE_ID) ->addVar('form', $data['form']) ->addVar('hostid', $data['hostid']) ->addVar('expression_constructor', $data['expression_constructor']) @@ -716,9 +716,9 @@ else { // Append tabs to form. $triggersForm->addItem($triggersTab); -$widget->addItem($triggersForm); - -$widget->show(); +$html_page + ->addItem($triggersForm) + ->show(); (new CScriptTag(' view.init('.json_encode([ diff --git a/ui/include/views/configuration.triggers.list.php b/ui/include/views/configuration.triggers.list.php index 72a18efeff9..15c00d4a843 100644 --- a/ui/include/views/configuration.triggers.list.php +++ b/ui/include/views/configuration.triggers.list.php @@ -145,7 +145,7 @@ $filter = (new CFilter()) ->addvar('context', $data['context'], 'filter_context') ->addFilterTab(_('Filter'), [$filter_column1, $filter_column2]); -$widget = (new CWidget()) +$html_page = (new CHtmlPage()) ->setTitle(_('Triggers')) ->setDocUrl(CDocHelper::getUrl($data['context'] === 'host' ? CDocHelper::CONFIGURATION_HOST_TRIGGERS_LIST @@ -172,10 +172,10 @@ $widget = (new CWidget()) ); if ($data['single_selected_hostid'] != 0) { - $widget->setNavigation(getHostNavigation('triggers', $data['single_selected_hostid'])); + $html_page->setNavigation(getHostNavigation('triggers', $data['single_selected_hostid'])); } -$widget->addItem($filter); +$html_page->addItem($filter); $url = (new CUrl('triggers.php')) ->setArgument('context', $data['context']) @@ -369,10 +369,9 @@ $triggers_form->addItem([ ) ]); -// append form to widget -$widget->addItem($triggers_form); - -$widget->show(); +$html_page + ->addItem($triggers_form) + ->show(); (new CScriptTag('view.init();')) ->setOnDocumentReady() diff --git a/ui/include/views/inventory.host.list.php b/ui/include/views/inventory.host.list.php index 4809399d35b..9ddcfa202ba 100644 --- a/ui/include/views/inventory.host.list.php +++ b/ui/include/views/inventory.host.list.php @@ -23,7 +23,7 @@ * @var CView $this */ -$widget = (new CWidget()) +$html_page = (new CHtmlPage()) ->setTitle(_('Host inventory')) ->setDocUrl(CDocHelper::getUrl(CDocHelper::INVENTORY_HOST_LIST)); @@ -37,7 +37,7 @@ foreach ($data['host_inventories'] as $inventoryField) { } // filter -$widget->addItem( +$html_page->addItem( (new CFilter()) ->setResetUrl(new CUrl('hostinventories.php')) ->setProfile($data['profileIdx']) @@ -112,6 +112,6 @@ foreach ($this->data['hosts'] as $host) { $table->addRow($row); } -$widget->addItem([$table, $this->data['paging']]); - -$widget->show(); +$html_page + ->addItem([$table, $this->data['paging']]) + ->show(); diff --git a/ui/include/views/inventory.host.view.php b/ui/include/views/inventory.host.view.php index 3c80ccd3086..653fc335589 100644 --- a/ui/include/views/inventory.host.view.php +++ b/ui/include/views/inventory.host.view.php @@ -260,12 +260,13 @@ $hostInventoriesTab->setFooter(makeFormFooter(null, [new CButtonCancel()])); $web_layout_mode = CViewHelper::loadLayoutMode(); -(new CWidget()) +(new CHtmlPage()) ->setTitle(_('Host inventory')) ->setWebLayoutMode($web_layout_mode) ->setControls((new CList())->addItem(get_icon('kioskmode', ['mode' => $web_layout_mode]))) - ->addItem((new CForm()) - ->setAttribute('aria-labeledby', ZBX_STYLE_PAGE_TITLE) - ->addItem($hostInventoriesTab) + ->addItem( + (new CForm()) + ->setAttribute('aria-labeledby', CHtmlPage::PAGE_TITLE_ID) + ->addItem($hostInventoriesTab) ) ->show(); diff --git a/ui/include/views/monitoring.history.php b/ui/include/views/monitoring.history.php index f20ef746389..114ce28f49e 100644 --- a/ui/include/views/monitoring.history.php +++ b/ui/include/views/monitoring.history.php @@ -26,7 +26,7 @@ $this->includeJsFile('monitoring.history.js.php'); $web_layout_mode = CViewHelper::loadLayoutMode(); -$historyWidget = (new CWidget())->setWebLayoutMode($web_layout_mode); +$html_page = (new CHtmlPage())->setWebLayoutMode($web_layout_mode); $header = [ 'left' => _n('%1$s item', '%1$s items', count($data['items'])), @@ -222,7 +222,7 @@ if ($data['itemids']) { // append plaintext to widget if ($data['plaintext']) { foreach ($header_row as $text) { - $historyWidget->addItem([new CSpan($text), BR()]); + $html_page->addItem([new CSpan($text), BR()]); } if ($data['itemids']) { @@ -231,11 +231,11 @@ if ($data['plaintext']) { foreach ($screen as $text) { $pre->addItem([$text, BR()]); } - $historyWidget->addItem($pre); + $html_page->addItem($pre); } } else { - $historyWidget + $html_page ->setTitle($header['left']) ->setDocUrl(CDocHelper::getUrl(CDocHelper::MONITORING_HISTORY)) ->setControls((new CTag('nav', true, $header['right']))->setAttribute('aria-label', _('Content controls'))); @@ -272,10 +272,10 @@ else { if ($data['itemids']) { if ($data['action'] !== HISTORY_LATEST) { - $historyWidget->addItem($filter_form); + $html_page->addItem($filter_form); } - $historyWidget->addItem($screen->get()); + $html_page->addItem($screen->get()); if ($data['action'] !== HISTORY_LATEST) { CScreenBuilder::insertScreenStandardJs($screen->timeline); @@ -283,10 +283,10 @@ else { } else { if ($filter_tab) { - $historyWidget->addItem($filter_form); + $html_page->addItem($filter_form); } - $historyWidget->addItem( + $html_page->addItem( (new CTableInfo()) ->setHeader([ (new CColHeader(_('Timestamp')))->addClass(ZBX_STYLE_CELL_WIDTH), @@ -298,4 +298,4 @@ else { } } -$historyWidget->show(); +$html_page->show(); diff --git a/ui/include/views/monitoring.sysmap.constructor.php b/ui/include/views/monitoring.sysmap.constructor.php index cdc039c2f87..430eeb0b700 100644 --- a/ui/include/views/monitoring.sysmap.constructor.php +++ b/ui/include/views/monitoring.sysmap.constructor.php @@ -87,7 +87,7 @@ zbx_add_post_js('ZABBIX.apps.map.run("'.ZBX_STYLE_MAP_AREA.'", '.json_encode([ 'defaultIconName' => $data['defaultIconName'] ], JSON_FORCE_OBJECT).');'); -(new CWidget()) +(new CHtmlPage()) ->setTitle(_('Network maps')) ->setDocUrl(CDocHelper::getUrl(CDocHelper::MONITORING_SYSMAP_CONSTRUCTOR)) ->setNavigation($menu) diff --git a/ui/include/views/monitoring.sysmap.edit.php b/ui/include/views/monitoring.sysmap.edit.php index 0d0883731c8..3ffc716d352 100644 --- a/ui/include/views/monitoring.sysmap.edit.php +++ b/ui/include/views/monitoring.sysmap.edit.php @@ -25,7 +25,7 @@ require_once dirname(__FILE__).'/js/monitoring.sysmap.edit.js.php'; -$widget = (new CWidget()) +$html_page = (new CHtmlPage()) ->setTitle(_('Network maps')) ->setDocUrl(CDocHelper::getUrl(CDocHelper::MONITORING_SYSMAP_EDIT)); @@ -436,7 +436,6 @@ else { $form->addItem($tabs); -// Append form to widget. -$widget->addItem($form); - -$widget->show(); +$html_page + ->addItem($form) + ->show(); diff --git a/ui/include/views/monitoring.sysmap.list.php b/ui/include/views/monitoring.sysmap.list.php index 37c54a4d4e0..2401f0bd819 100644 --- a/ui/include/views/monitoring.sysmap.list.php +++ b/ui/include/views/monitoring.sysmap.list.php @@ -23,7 +23,7 @@ * @var CView $this */ -$widget = (new CWidget()) +$html_page = (new CHtmlPage()) ->setTitle(_('Maps')) ->setDocUrl(CDocHelper::getUrl(CDocHelper::MONITORING_SYSMAP_LIST)) ->setControls( @@ -123,7 +123,6 @@ $sysmapForm->addItem([ ]) ]); -// append form to widget -$widget->addItem($sysmapForm); - -$widget->show(); +$html_page + ->addItem($sysmapForm) + ->show(); diff --git a/ui/include/views/reports.toptriggers.php b/ui/include/views/reports.toptriggers.php index 10fd81c8b6f..98c6e83e4bc 100644 --- a/ui/include/views/reports.toptriggers.php +++ b/ui/include/views/reports.toptriggers.php @@ -114,7 +114,7 @@ $obj_data = [ zbx_add_post_js('timeControl.addObject("toptriggers", '.zbx_jsvalue($data['filter']).', '.zbx_jsvalue($obj_data).');'); zbx_add_post_js('timeControl.processObjects();'); -(new CWidget()) +(new CHtmlPage()) ->setTitle(_('100 busiest triggers')) ->setDocUrl(CDocHelper::getUrl(CDocHelper::REPORTS_TOPTRIGGERS)) ->addItem($filterForm) diff --git a/ui/js/main.js b/ui/js/main.js index e2f19e5739a..7c4bfb93b34 100644 --- a/ui/js/main.js +++ b/ui/js/main.js @@ -703,7 +703,7 @@ function toggleSection(id, profile_idx) { section.classList.toggle('section-collapsed', !is_collapsed); toggle.setAttribute('title', is_collapsed ? t('S_COLLAPSE') : t('S_EXPAND')); - if (profile_idx !== null) { + if (profile_idx !== '') { updateUserProfile(profile_idx, is_collapsed ? '1' : '0', []); } } diff --git a/ui/report2.php b/ui/report2.php index 09807fe42a7..ee1d02801c0 100644 --- a/ui/report2.php +++ b/ui/report2.php @@ -156,7 +156,7 @@ $triggerData = isset($_REQUEST['triggerid']) ]) : null; -$reportWidget = (new CWidget()) +$html_page = (new CHtmlPage()) ->setTitle(_('Availability report')) ->setDocUrl(CDocHelper::getUrl(CDocHelper::REPORT2)); @@ -167,7 +167,7 @@ if ($triggerData) { $triggerData['hostid'] = $host['hostid']; $triggerData['hostname'] = $host['name']; - $reportWidget->setControls((new CTag('nav', true, + $html_page->setControls((new CTag('nav', true, (new CList()) ->addItem(new CLink($triggerData['hostname'], (new CUrl('report2.php')) ->setArgument('page', CPagerHelper::loadPage('report2.php', null)) @@ -180,7 +180,7 @@ if ($triggerData) { $table = (new CTableInfo()) ->addRow(new CImg('chart4.php?triggerid='.$_REQUEST['triggerid'])); - $reportWidget->addItem(BR()) + $html_page->addItem(BR()) ->addItem($table) ->show(); } @@ -195,7 +195,7 @@ else { ->addOption(new CSelectOption(AVAILABILITY_REPORT_BY_HOST, _('By host'))) ->addOption(new CSelectOption(AVAILABILITY_REPORT_BY_TEMPLATE, _('By trigger template'))); - $reportWidget->setControls((new CForm('get')) + $html_page->setControls((new CForm('get')) ->cleanItems() ->setAttribute('aria-label', _('Main filter')) ->addItem((new CList()) @@ -493,7 +493,7 @@ else { } unset($trigger); - $reportWidget->addItem( + $html_page->addItem( (new CFilter()) ->setResetUrl(new CUrl('report2.php')) ->setProfile($data['filter']['timeline']['profileIdx']) @@ -562,7 +562,7 @@ else { ); zbx_add_post_js('timeControl.processObjects();'); - $reportWidget + $html_page ->addItem([$triggerTable, $paging]) ->show(); } diff --git a/ui/report4.php b/ui/report4.php index 9fa0c9f2cd6..281cb753a75 100644 --- a/ui/report4.php +++ b/ui/report4.php @@ -61,7 +61,7 @@ CArrayHelper::sort($db_media_types, ['name']); $media_types = array_column($db_media_types, 'name', 'mediatypeid'); -$widget = (new CWidget()) +$html_page = (new CHtmlPage()) ->setTitle(_('Notifications')) ->setDocUrl(CDocHelper::getUrl(CDocHelper::REPORT4)); @@ -121,7 +121,7 @@ if ($media_types) { ]); } - $widget->setControls((new CForm('get')) + $html_page->setControls((new CForm('get')) ->cleanItems() ->setAttribute('aria-label', _('Main filter')) ->addItem($controls) @@ -258,7 +258,7 @@ else { $table = new CTableInfo(); } -$widget +$html_page ->addItem($table) ->show(); diff --git a/ui/tests/selenium/modules/module_number_1/views/first.module.php b/ui/tests/selenium/modules/module_number_1/views/first.module.php index 241c411bb00..253dfb54ba9 100644 --- a/ui/tests/selenium/modules/module_number_1/views/first.module.php +++ b/ui/tests/selenium/modules/module_number_1/views/first.module.php @@ -1,6 +1,6 @@ addItem( (new CTag('h1', true, 'If You see this message - 1st module is working')) )->show(); diff --git a/ui/tests/selenium/modules/module_number_2/views/second.module.php b/ui/tests/selenium/modules/module_number_2/views/second.module.php index 39b7f7acfb2..b16e7f3a6ef 100644 --- a/ui/tests/selenium/modules/module_number_2/views/second.module.php +++ b/ui/tests/selenium/modules/module_number_2/views/second.module.php @@ -1,6 +1,6 @@ addItem( (new CTag('h1', true, '2nd module is also working')) )->show(); diff --git a/ui/tests/selenium/modules/module_number_3/views/third.module.php b/ui/tests/selenium/modules/module_number_3/views/third.module.php index b3a60b195d0..085a1ee086e 100644 --- a/ui/tests/selenium/modules/module_number_3/views/third.module.php +++ b/ui/tests/selenium/modules/module_number_3/views/third.module.php @@ -1,6 +1,6 @@ addItem( (new CTag('h1', true, 'You should not see this message')) )->show(); diff --git a/ui/tests/selenium/modules/module_number_4/views/forth.module.php b/ui/tests/selenium/modules/module_number_4/views/forth.module.php index bd1000cc1b6..f0ba934eaa8 100644 --- a/ui/tests/selenium/modules/module_number_4/views/forth.module.php +++ b/ui/tests/selenium/modules/module_number_4/views/forth.module.php @@ -1,6 +1,6 @@ addItem( (new CTag('h1', true, '4th module - cannot be enabled together with 1st module')) )->show(); diff --git a/ui/tests/selenium/modules/module_number_5/views/fifth.module.php b/ui/tests/selenium/modules/module_number_5/views/fifth.module.php index 5f702c5a5a5..5cd1eee6bea 100644 --- a/ui/tests/selenium/modules/module_number_5/views/fifth.module.php +++ b/ui/tests/selenium/modules/module_number_5/views/fifth.module.php @@ -1,6 +1,6 @@ addItem( (new CTag('h1', true, 'Если ты это читаешь то 5ый модуль работает')) )->show(); diff --git a/ui/tr_events.php b/ui/tr_events.php index 8e0c8814885..30c2a5c175e 100644 --- a/ui/tr_events.php +++ b/ui/tr_events.php @@ -184,14 +184,13 @@ $event_tab = (new CDiv([ ->addClass(ZBX_STYLE_COLUMNS) ->addClass(ZBX_STYLE_COLUMNS_2); -(new CWidget()) +(new CHtmlPage()) ->setTitle(_('Event details')) ->setWebLayoutMode($page['web_layout_mode']) ->setDocUrl(CDocHelper::getUrl(CDocHelper::TR_EVENTS)) ->setControls( (new CTag('nav', true, - (new CList()) - ->addItem(get_icon('kioskmode', ['mode' => $page['web_layout_mode']])) + (new CList())->addItem(get_icon('kioskmode', ['mode' => $page['web_layout_mode']])) ))->setAttribute('aria-label', _('Content controls')) ) ->addItem($event_tab) -- cgit v1.2.3 From dfadde621afd0bf57884b6bb13de10071039fc51 Mon Sep 17 00:00:00 2001 From: Alexander Shubin Date: Mon, 1 Aug 2022 12:38:24 +0300 Subject: ..F....... [ZBXNEXT-7469] fixed title controls setter in CHtmlPage class --- ui/include/classes/html/CHtmlPage.php | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/ui/include/classes/html/CHtmlPage.php b/ui/include/classes/html/CHtmlPage.php index e36e9c5118a..4aa89911906 100644 --- a/ui/include/classes/html/CHtmlPage.php +++ b/ui/include/classes/html/CHtmlPage.php @@ -30,10 +30,13 @@ class CHtmlPage { private const ZBX_STYLE_HEADER_KIOSKMODE_CONTROLS = 'header-kioskmode-controls'; private string $title = ''; - private array $title_submenu = []; - private string $doc_url = ''; + private ?array $title_submenu = null; + private ?CTag $controls = null; private ?CList $kiosk_mode_controls = null; + + private string $doc_url = ''; + private array $items = []; /** @@ -52,7 +55,7 @@ class CHtmlPage { return $this; } - public function setTitleSubmenu(array $title_submenu): self { + public function setTitleSubmenu(?array $title_submenu): self { $this->title_submenu = $title_submenu; return $this; @@ -151,7 +154,7 @@ class CHtmlPage { if ($this->title !== '') { $title_tag = (new CTag('h1', true, $this->title))->setId(self::PAGE_TITLE_ID); - if ($this->title_submenu) { + if ($this->title_submenu !== null) { $title_tag = (new CLinkAction($title_tag)) ->setMenuPopup([ 'type' => 'submenu', -- cgit v1.2.3 From 179d4f5d676b3f4763556f35a5603f7ea9507a96 Mon Sep 17 00:00:00 2001 From: Alexander Shubin Date: Mon, 1 Aug 2022 13:05:15 +0300 Subject: ..F....... [ZBXNEXT-7469] fixed page title on history page --- ui/include/views/monitoring.history.php | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/ui/include/views/monitoring.history.php b/ui/include/views/monitoring.history.php index 114ce28f49e..0ca461b7dd9 100644 --- a/ui/include/views/monitoring.history.php +++ b/ui/include/views/monitoring.history.php @@ -52,12 +52,8 @@ if ($data['items']) { } if ((count($data['items']) == 1 || $same_host) && $data['itemids']) { - $header['left'] = [ - $host_name, - NAME_DELIMITER, - count($data['items']) == 1 ? $item['name'] : $header['left'] - ]; - $header_row[] = implode('', $header['left']); + $header['left'] = $host_name.NAME_DELIMITER.(count($data['items']) == 1 ? $item['name'] : $header['left']); + $header_row[] = $header['left']; } else { $header_row[] = $header['left']; -- cgit v1.2.3 From ac73d629967d0b9b6b7e2f0d13724f70bb78d99d Mon Sep 17 00:00:00 2001 From: Alexander Shubin Date: Mon, 1 Aug 2022 15:26:04 +0300 Subject: ..F....... [ZBXNEXT-7469] renamed generic widget view controller --- .../controllers/CControllerDashboardWidgetView.php | 148 +++++++++++++++++++++ ui/app/controllers/CControllerWidget.php | 148 --------------------- .../controllers/CControllerWidgetActionLogView.php | 2 +- ui/app/controllers/CControllerWidgetClockView.php | 2 +- .../controllers/CControllerWidgetDataOverView.php | 2 +- .../controllers/CControllerWidgetDiscoveryView.php | 2 +- .../controllers/CControllerWidgetFavGraphsView.php | 2 +- .../controllers/CControllerWidgetFavMapsView.php | 2 +- ui/app/controllers/CControllerWidgetGeoMapView.php | 2 +- ui/app/controllers/CControllerWidgetGraphView.php | 2 +- .../controllers/CControllerWidgetHostAvailView.php | 2 +- ui/app/controllers/CControllerWidgetItemView.php | 2 +- ui/app/controllers/CControllerWidgetIterator.php | 2 +- ui/app/controllers/CControllerWidgetMapView.php | 2 +- .../controllers/CControllerWidgetNavTreeView.php | 2 +- .../controllers/CControllerWidgetPlainTextView.php | 2 +- .../CControllerWidgetProblemHostsView.php | 2 +- .../CControllerWidgetProblemsBySvView.php | 2 +- .../controllers/CControllerWidgetProblemsView.php | 2 +- .../controllers/CControllerWidgetSlaReportView.php | 2 +- .../controllers/CControllerWidgetSvgGraphView.php | 2 +- .../CControllerWidgetSystemInfoView.php | 2 +- .../controllers/CControllerWidgetTopHostsView.php | 2 +- .../controllers/CControllerWidgetTrigOverView.php | 2 +- ui/app/controllers/CControllerWidgetUrlView.php | 2 +- ui/app/controllers/CControllerWidgetWebView.php | 2 +- 26 files changed, 172 insertions(+), 172 deletions(-) create mode 100644 ui/app/controllers/CControllerDashboardWidgetView.php delete mode 100644 ui/app/controllers/CControllerWidget.php diff --git a/ui/app/controllers/CControllerDashboardWidgetView.php b/ui/app/controllers/CControllerDashboardWidgetView.php new file mode 100644 index 00000000000..c3b2de09136 --- /dev/null +++ b/ui/app/controllers/CControllerDashboardWidgetView.php @@ -0,0 +1,148 @@ +setPostContentType(self::POST_CONTENT_TYPE_JSON); + } + + /** + * Check user permissions. + * + * @return bool + */ + protected function checkPermissions() { + return ($this->getUserType() >= USER_TYPE_ZABBIX_USER); + } + + /** + * Set widget type. + * + * @param int $type Widget type WIDGET_*. + * + * @return object + */ + protected function setType($type) { + $this->type = $type; + + return $this; + } + + protected function getContext(): string { + return $this->hasInput('templateid') + ? CWidgetConfig::CONTEXT_TEMPLATE_DASHBOARD + : CWidgetConfig::CONTEXT_DASHBOARD; + } + + /** + * Set validation rules for input parameters. + * + * @param array $validation_rules Validation rules for input parameters. + * + * @return object + */ + protected function setValidationRules(array $validation_rules) { + $this->validation_rules = $validation_rules; + + return $this; + } + + /** + * Returns default widget name. + * + * @return string + */ + protected function getDefaultName() { + return CWidgetConfig::getKnownWidgetTypes($this->getContext())[$this->type]; + } + + /** + * Validate input parameters. + * + * @return bool + */ + protected function checkInput() { + $validation_rules = $this->validation_rules; + + if (CWidgetConfig::isWidgetTypeSupportedInContext($this->type, CWidgetConfig::CONTEXT_TEMPLATE_DASHBOARD)) { + $validation_rules['templateid'] = 'db dashboard.templateid'; + } + + $ret = $this->validateInput($validation_rules); + + if ($ret) { + $this->form = CWidgetConfig::getForm($this->type, $this->getInput('fields', '{}'), + $this->hasInput('templateid') ? $this->getInput('templateid') : null + ); + + if ($errors = $this->form->validate()) { + foreach ($errors as $error) { + error($error); + } + + $ret = false; + } + } + + if (!$ret) { + $this->setResponse( + (new CControllerResponseData(['main_block' => json_encode([ + 'error' => [ + 'messages' => array_column(get_and_clear_messages(), 'message') + ] + ])]))->disableView() + ); + } + + return $ret; + } + + /** + * Returns form object. + * + * @return object + */ + protected function getForm() { + return $this->form; + } +} diff --git a/ui/app/controllers/CControllerWidget.php b/ui/app/controllers/CControllerWidget.php deleted file mode 100644 index 2c9404ed442..00000000000 --- a/ui/app/controllers/CControllerWidget.php +++ /dev/null @@ -1,148 +0,0 @@ -setPostContentType(self::POST_CONTENT_TYPE_JSON); - } - - /** - * Check user permissions. - * - * @return bool - */ - protected function checkPermissions() { - return ($this->getUserType() >= USER_TYPE_ZABBIX_USER); - } - - /** - * Set widget type. - * - * @param int $type Widget type WIDGET_*. - * - * @return object - */ - protected function setType($type) { - $this->type = $type; - - return $this; - } - - protected function getContext(): string { - return $this->hasInput('templateid') - ? CWidgetConfig::CONTEXT_TEMPLATE_DASHBOARD - : CWidgetConfig::CONTEXT_DASHBOARD; - } - - /** - * Set validation rules for input parameters. - * - * @param array $validation_rules Validation rules for input parameters. - * - * @return object - */ - protected function setValidationRules(array $validation_rules) { - $this->validation_rules = $validation_rules; - - return $this; - } - - /** - * Returns default widget name. - * - * @return string - */ - protected function getDefaultName() { - return CWidgetConfig::getKnownWidgetTypes($this->getContext())[$this->type]; - } - - /** - * Validate input parameters. - * - * @return bool - */ - protected function checkInput() { - $validation_rules = $this->validation_rules; - - if (CWidgetConfig::isWidgetTypeSupportedInContext($this->type, CWidgetConfig::CONTEXT_TEMPLATE_DASHBOARD)) { - $validation_rules['templateid'] = 'db dashboard.templateid'; - } - - $ret = $this->validateInput($validation_rules); - - if ($ret) { - $this->form = CWidgetConfig::getForm($this->type, $this->getInput('fields', '{}'), - $this->hasInput('templateid') ? $this->getInput('templateid') : null - ); - - if ($errors = $this->form->validate()) { - foreach ($errors as $error) { - error($error); - } - - $ret = false; - } - } - - if (!$ret) { - $this->setResponse( - (new CControllerResponseData(['main_block' => json_encode([ - 'error' => [ - 'messages' => array_column(get_and_clear_messages(), 'message') - ] - ])]))->disableView() - ); - } - - return $ret; - } - - /** - * Returns form object. - * - * @return object - */ - protected function getForm() { - return $this->form; - } -} diff --git a/ui/app/controllers/CControllerWidgetActionLogView.php b/ui/app/controllers/CControllerWidgetActionLogView.php index 9c17ba7e272..9bacab4bda0 100644 --- a/ui/app/controllers/CControllerWidgetActionLogView.php +++ b/ui/app/controllers/CControllerWidgetActionLogView.php @@ -19,7 +19,7 @@ **/ -class CControllerWidgetActionLogView extends CControllerWidget { +class CControllerWidgetActionLogView extends CControllerDashboardWidgetView { public function __construct() { parent::__construct(); diff --git a/ui/app/controllers/CControllerWidgetClockView.php b/ui/app/controllers/CControllerWidgetClockView.php index f3fb20a7210..c0beb326b65 100644 --- a/ui/app/controllers/CControllerWidgetClockView.php +++ b/ui/app/controllers/CControllerWidgetClockView.php @@ -19,7 +19,7 @@ **/ -class CControllerWidgetClockView extends CControllerWidget { +class CControllerWidgetClockView extends CControllerDashboardWidgetView { public function __construct() { parent::__construct(); diff --git a/ui/app/controllers/CControllerWidgetDataOverView.php b/ui/app/controllers/CControllerWidgetDataOverView.php index abc140e7f1b..a1b41c1e899 100644 --- a/ui/app/controllers/CControllerWidgetDataOverView.php +++ b/ui/app/controllers/CControllerWidgetDataOverView.php @@ -19,7 +19,7 @@ **/ -class CControllerWidgetDataOverView extends CControllerWidget { +class CControllerWidgetDataOverView extends CControllerDashboardWidgetView { public function __construct() { parent::__construct(); diff --git a/ui/app/controllers/CControllerWidgetDiscoveryView.php b/ui/app/controllers/CControllerWidgetDiscoveryView.php index 92e30c38eb9..a0bcb00b567 100644 --- a/ui/app/controllers/CControllerWidgetDiscoveryView.php +++ b/ui/app/controllers/CControllerWidgetDiscoveryView.php @@ -21,7 +21,7 @@ require_once dirname(__FILE__).'/../../include/blocks.inc.php'; -class CControllerWidgetDiscoveryView extends CControllerWidget { +class CControllerWidgetDiscoveryView extends CControllerDashboardWidgetView { public function __construct() { parent::__construct(); diff --git a/ui/app/controllers/CControllerWidgetFavGraphsView.php b/ui/app/controllers/CControllerWidgetFavGraphsView.php index aafc056e4a1..7098c92f66a 100644 --- a/ui/app/controllers/CControllerWidgetFavGraphsView.php +++ b/ui/app/controllers/CControllerWidgetFavGraphsView.php @@ -21,7 +21,7 @@ require_once dirname(__FILE__).'/../../include/blocks.inc.php'; -class CControllerWidgetFavGraphsView extends CControllerWidget { +class CControllerWidgetFavGraphsView extends CControllerDashboardWidgetView { public function __construct() { parent::__construct(); diff --git a/ui/app/controllers/CControllerWidgetFavMapsView.php b/ui/app/controllers/CControllerWidgetFavMapsView.php index ca139c25f7f..7be5884b5fd 100644 --- a/ui/app/controllers/CControllerWidgetFavMapsView.php +++ b/ui/app/controllers/CControllerWidgetFavMapsView.php @@ -21,7 +21,7 @@ require_once dirname(__FILE__).'/../../include/blocks.inc.php'; -class CControllerWidgetFavMapsView extends CControllerWidget { +class CControllerWidgetFavMapsView extends CControllerDashboardWidgetView { public function __construct() { parent::__construct(); diff --git a/ui/app/controllers/CControllerWidgetGeoMapView.php b/ui/app/controllers/CControllerWidgetGeoMapView.php index a0264e2e9ea..1b0e39acb7b 100644 --- a/ui/app/controllers/CControllerWidgetGeoMapView.php +++ b/ui/app/controllers/CControllerWidgetGeoMapView.php @@ -19,7 +19,7 @@ **/ -class CControllerWidgetGeoMapView extends CControllerWidget { +class CControllerWidgetGeoMapView extends CControllerDashboardWidgetView { const NO_PROBLEMS_MARKER_COLOR = '#009900'; diff --git a/ui/app/controllers/CControllerWidgetGraphView.php b/ui/app/controllers/CControllerWidgetGraphView.php index ea69a05caa7..53ff658cf59 100644 --- a/ui/app/controllers/CControllerWidgetGraphView.php +++ b/ui/app/controllers/CControllerWidgetGraphView.php @@ -19,7 +19,7 @@ **/ -class CControllerWidgetGraphView extends CControllerWidget { +class CControllerWidgetGraphView extends CControllerDashboardWidgetView { public function __construct() { parent::__construct(); diff --git a/ui/app/controllers/CControllerWidgetHostAvailView.php b/ui/app/controllers/CControllerWidgetHostAvailView.php index db696075f0e..438e89ba243 100644 --- a/ui/app/controllers/CControllerWidgetHostAvailView.php +++ b/ui/app/controllers/CControllerWidgetHostAvailView.php @@ -19,7 +19,7 @@ **/ -class CControllerWidgetHostAvailView extends CControllerWidget { +class CControllerWidgetHostAvailView extends CControllerDashboardWidgetView { public function __construct() { parent::__construct(); diff --git a/ui/app/controllers/CControllerWidgetItemView.php b/ui/app/controllers/CControllerWidgetItemView.php index df35e9baeb8..6af8576fd05 100644 --- a/ui/app/controllers/CControllerWidgetItemView.php +++ b/ui/app/controllers/CControllerWidgetItemView.php @@ -19,7 +19,7 @@ **/ -class CControllerWidgetItemView extends CControllerWidget { +class CControllerWidgetItemView extends CControllerDashboardWidgetView { public const CHANGE_INDICATOR_UP = 1; public const CHANGE_INDICATOR_DOWN = 2; diff --git a/ui/app/controllers/CControllerWidgetIterator.php b/ui/app/controllers/CControllerWidgetIterator.php index 5ac5b1169cb..eb405f549eb 100644 --- a/ui/app/controllers/CControllerWidgetIterator.php +++ b/ui/app/controllers/CControllerWidgetIterator.php @@ -22,7 +22,7 @@ /** * Class containing methods for operations with widget iterators. */ -abstract class CControllerWidgetIterator extends CControllerWidget { +abstract class CControllerWidgetIterator extends CControllerDashboardWidgetView { /** * @var array $iterator_validation_rules Validation rules for input parameters of the iterator. diff --git a/ui/app/controllers/CControllerWidgetMapView.php b/ui/app/controllers/CControllerWidgetMapView.php index 58e2504268a..52527d82db2 100644 --- a/ui/app/controllers/CControllerWidgetMapView.php +++ b/ui/app/controllers/CControllerWidgetMapView.php @@ -20,7 +20,7 @@ require_once dirname(__FILE__).'/../../include/blocks.inc.php'; -class CControllerWidgetMapView extends CControllerWidget { +class CControllerWidgetMapView extends CControllerDashboardWidgetView { public function __construct() { parent::__construct(); diff --git a/ui/app/controllers/CControllerWidgetNavTreeView.php b/ui/app/controllers/CControllerWidgetNavTreeView.php index 1b29eab5df4..adefe41c0e5 100644 --- a/ui/app/controllers/CControllerWidgetNavTreeView.php +++ b/ui/app/controllers/CControllerWidgetNavTreeView.php @@ -21,7 +21,7 @@ require_once dirname(__FILE__).'/../../include/blocks.inc.php'; -class CControllerWidgetNavTreeView extends CControllerWidget { +class CControllerWidgetNavTreeView extends CControllerDashboardWidgetView { private $problems_per_severity_tpl; diff --git a/ui/app/controllers/CControllerWidgetPlainTextView.php b/ui/app/controllers/CControllerWidgetPlainTextView.php index 71b445664d2..f88b732c7ae 100644 --- a/ui/app/controllers/CControllerWidgetPlainTextView.php +++ b/ui/app/controllers/CControllerWidgetPlainTextView.php @@ -22,7 +22,7 @@ /** * Class for Dashboard Plain-text widget view. */ -class CControllerWidgetPlainTextView extends CControllerWidget { +class CControllerWidgetPlainTextView extends CControllerDashboardWidgetView { public function __construct() { parent::__construct(); diff --git a/ui/app/controllers/CControllerWidgetProblemHostsView.php b/ui/app/controllers/CControllerWidgetProblemHostsView.php index 5bbebf8efe1..10ffb4aa2e0 100644 --- a/ui/app/controllers/CControllerWidgetProblemHostsView.php +++ b/ui/app/controllers/CControllerWidgetProblemHostsView.php @@ -21,7 +21,7 @@ require_once dirname(__FILE__).'/../../include/blocks.inc.php'; -class CControllerWidgetProblemHostsView extends CControllerWidget { +class CControllerWidgetProblemHostsView extends CControllerDashboardWidgetView { public function __construct() { parent::__construct(); diff --git a/ui/app/controllers/CControllerWidgetProblemsBySvView.php b/ui/app/controllers/CControllerWidgetProblemsBySvView.php index 0478bd98a75..ae4deca918c 100644 --- a/ui/app/controllers/CControllerWidgetProblemsBySvView.php +++ b/ui/app/controllers/CControllerWidgetProblemsBySvView.php @@ -21,7 +21,7 @@ require_once dirname(__FILE__).'/../../include/blocks.inc.php'; -class CControllerWidgetProblemsBySvView extends CControllerWidget { +class CControllerWidgetProblemsBySvView extends CControllerDashboardWidgetView { public function __construct() { parent::__construct(); diff --git a/ui/app/controllers/CControllerWidgetProblemsView.php b/ui/app/controllers/CControllerWidgetProblemsView.php index ee71c1ce81d..72599a2f9ef 100644 --- a/ui/app/controllers/CControllerWidgetProblemsView.php +++ b/ui/app/controllers/CControllerWidgetProblemsView.php @@ -19,7 +19,7 @@ **/ -class CControllerWidgetProblemsView extends CControllerWidget { +class CControllerWidgetProblemsView extends CControllerDashboardWidgetView { public function __construct() { parent::__construct(); diff --git a/ui/app/controllers/CControllerWidgetSlaReportView.php b/ui/app/controllers/CControllerWidgetSlaReportView.php index fd69b91ee65..ca1e627db9b 100644 --- a/ui/app/controllers/CControllerWidgetSlaReportView.php +++ b/ui/app/controllers/CControllerWidgetSlaReportView.php @@ -19,7 +19,7 @@ **/ -class CControllerWidgetSlaReportView extends CControllerWidget { +class CControllerWidgetSlaReportView extends CControllerDashboardWidgetView { public function __construct() { parent::__construct(); diff --git a/ui/app/controllers/CControllerWidgetSvgGraphView.php b/ui/app/controllers/CControllerWidgetSvgGraphView.php index 50913d4110a..34b00e8a9a9 100644 --- a/ui/app/controllers/CControllerWidgetSvgGraphView.php +++ b/ui/app/controllers/CControllerWidgetSvgGraphView.php @@ -21,7 +21,7 @@ require_once dirname(__FILE__).'/../../include/blocks.inc.php'; -class CControllerWidgetSvgGraphView extends CControllerWidget { +class CControllerWidgetSvgGraphView extends CControllerDashboardWidgetView { const GRAPH_WIDTH_MIN = 1; const GRAPH_WIDTH_MAX = 65535; diff --git a/ui/app/controllers/CControllerWidgetSystemInfoView.php b/ui/app/controllers/CControllerWidgetSystemInfoView.php index f79b2b17557..3a75b677ec8 100644 --- a/ui/app/controllers/CControllerWidgetSystemInfoView.php +++ b/ui/app/controllers/CControllerWidgetSystemInfoView.php @@ -21,7 +21,7 @@ require_once __DIR__.'/../../include/blocks.inc.php'; -class CControllerWidgetSystemInfoView extends CControllerWidget { +class CControllerWidgetSystemInfoView extends CControllerDashboardWidgetView { public function __construct() { parent::__construct(); diff --git a/ui/app/controllers/CControllerWidgetTopHostsView.php b/ui/app/controllers/CControllerWidgetTopHostsView.php index 1eed40c3514..9d4cd37c47e 100644 --- a/ui/app/controllers/CControllerWidgetTopHostsView.php +++ b/ui/app/controllers/CControllerWidgetTopHostsView.php @@ -19,7 +19,7 @@ **/ -class CControllerWidgetTopHostsView extends CControllerWidget { +class CControllerWidgetTopHostsView extends CControllerDashboardWidgetView { public function __construct() { parent::__construct(); diff --git a/ui/app/controllers/CControllerWidgetTrigOverView.php b/ui/app/controllers/CControllerWidgetTrigOverView.php index bd2a6590536..27bde6fdab2 100644 --- a/ui/app/controllers/CControllerWidgetTrigOverView.php +++ b/ui/app/controllers/CControllerWidgetTrigOverView.php @@ -19,7 +19,7 @@ **/ -class CControllerWidgetTrigOverView extends CControllerWidget { +class CControllerWidgetTrigOverView extends CControllerDashboardWidgetView { public function __construct() { parent::__construct(); diff --git a/ui/app/controllers/CControllerWidgetUrlView.php b/ui/app/controllers/CControllerWidgetUrlView.php index e09881d5dd1..04f9c33dbb9 100644 --- a/ui/app/controllers/CControllerWidgetUrlView.php +++ b/ui/app/controllers/CControllerWidgetUrlView.php @@ -19,7 +19,7 @@ **/ -class CControllerWidgetUrlView extends CControllerWidget { +class CControllerWidgetUrlView extends CControllerDashboardWidgetView { public function __construct() { parent::__construct(); diff --git a/ui/app/controllers/CControllerWidgetWebView.php b/ui/app/controllers/CControllerWidgetWebView.php index 2ba1f59accc..c8eee3b5ff8 100644 --- a/ui/app/controllers/CControllerWidgetWebView.php +++ b/ui/app/controllers/CControllerWidgetWebView.php @@ -19,7 +19,7 @@ **/ -class CControllerWidgetWebView extends CControllerWidget { +class CControllerWidgetWebView extends CControllerDashboardWidgetView { public function __construct() { parent::__construct(); -- cgit v1.2.3 From 075523d4c76e39208b9e44b644dca65cdaabda88 Mon Sep 17 00:00:00 2001 From: Alexander Shubin Date: Tue, 2 Aug 2022 10:34:43 +0300 Subject: ..F....... [ZBXNEXT-7469] fixed CHtmlPage property type --- ui/include/classes/html/CHtmlPage.php | 8 ++++---- ui/include/html.inc.php | 6 +++--- ui/include/views/configuration.action.list.php | 2 +- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/ui/include/classes/html/CHtmlPage.php b/ui/include/classes/html/CHtmlPage.php index 4aa89911906..4fc21fe8b9a 100644 --- a/ui/include/classes/html/CHtmlPage.php +++ b/ui/include/classes/html/CHtmlPage.php @@ -30,7 +30,7 @@ class CHtmlPage { private const ZBX_STYLE_HEADER_KIOSKMODE_CONTROLS = 'header-kioskmode-controls'; private string $title = ''; - private ?array $title_submenu = null; + private array $title_submenu = []; private ?CTag $controls = null; private ?CList $kiosk_mode_controls = null; @@ -55,7 +55,7 @@ class CHtmlPage { return $this; } - public function setTitleSubmenu(?array $title_submenu): self { + public function setTitleSubmenu(array $title_submenu): self { $this->title_submenu = $title_submenu; return $this; @@ -67,7 +67,7 @@ class CHtmlPage { return $this; } - public function setControls(CTag $controls): self { + public function setControls(?CTag $controls): self { $this->controls = $controls; return $this; @@ -154,7 +154,7 @@ class CHtmlPage { if ($this->title !== '') { $title_tag = (new CTag('h1', true, $this->title))->setId(self::PAGE_TITLE_ID); - if ($this->title_submenu !== null) { + if ($this->title_submenu !== []) { $title_tag = (new CLinkAction($title_tag)) ->setMenuPopup([ 'type' => 'submenu', diff --git a/ui/include/html.inc.php b/ui/include/html.inc.php index 9ce39ff9758..a8d6912feb9 100644 --- a/ui/include/html.inc.php +++ b/ui/include/html.inc.php @@ -806,11 +806,11 @@ function makePageFooter($with_version = true) { /** * Get drop-down submenu item list for the User settings section. * - * @return array|null Menu definition for CHtmlPage::setTitleSubmenu. + * @return array Menu definition for CHtmlPage::setTitleSubmenu. */ -function getUserSettingsSubmenu(): ?array { +function getUserSettingsSubmenu(): array { if (!CWebUser::checkAccess(CRoleHelper::ACTIONS_MANAGE_API_TOKENS)) { - return null; + return []; } $profile_url = (new CUrl('zabbix.php')) diff --git a/ui/include/views/configuration.action.list.php b/ui/include/views/configuration.action.list.php index f7a8498f1f3..6ab1bd89269 100644 --- a/ui/include/views/configuration.action.list.php +++ b/ui/include/views/configuration.action.list.php @@ -54,7 +54,7 @@ $current_url = (new CUrl('actionconf.php'))->setArgument('eventsource', $data['e $html_page = (new CHtmlPage()) ->setTitle($title) - ->setTitleSubmenu($submenu ? ['main_section' => ['items' => $submenu]] : null) + ->setTitleSubmenu($submenu ? ['main_section' => ['items' => $submenu]] : []) ->setDocUrl(CDocHelper::getUrl($doc_url)) ->setControls((new CTag('nav', true, (new CForm('get')) -- cgit v1.2.3 From 8c22815e966e6b6cb6d8d7958272d82efc0e0531 Mon Sep 17 00:00:00 2001 From: Larisa Grigorjeva Date: Fri, 12 Aug 2022 22:43:29 +0100 Subject: .......... [DEV-2073] fixed tests dependency --- ui/tests/selenium/data/sources/DiscoveredHosts.php | 10 +++++++++- ui/tests/selenium/lld/testPageLowLevelDiscovery.php | 9 +++++++-- 2 files changed, 16 insertions(+), 3 deletions(-) diff --git a/ui/tests/selenium/data/sources/DiscoveredHosts.php b/ui/tests/selenium/data/sources/DiscoveredHosts.php index 7ae307eb8e0..269c7261b4d 100644 --- a/ui/tests/selenium/data/sources/DiscoveredHosts.php +++ b/ui/tests/selenium/data/sources/DiscoveredHosts.php @@ -38,10 +38,18 @@ class DiscoveredHosts { * @return array */ public static function load() { + // Create hostgroup for discovered host test. + $hostgroups = CDataHelper::call('hostgroup.create', [ + [ + 'name' => 'Group for discovered host test' + ] + ]); + $hostgroupid = $hostgroups['groupids'][0]; + $hosts = CDataHelper::call('host.create', [ 'host' => 'Test of discovered host', 'groups' => [ - ['groupid' => 4] + ['groupid' => $hostgroupid] ], 'interfaces' => [ 'type'=> 1, diff --git a/ui/tests/selenium/lld/testPageLowLevelDiscovery.php b/ui/tests/selenium/lld/testPageLowLevelDiscovery.php index 5a32d597b10..a64d2a6c921 100644 --- a/ui/tests/selenium/lld/testPageLowLevelDiscovery.php +++ b/ui/tests/selenium/lld/testPageLowLevelDiscovery.php @@ -24,7 +24,8 @@ require_once dirname(__FILE__).'/../behaviors/CMessageBehavior.php'; /** * @backup items - * @dataSource ExecuteNowAction + * + * @dataSource ExecuteNowAction, DiscoveredHosts */ class testPageLowLevelDiscovery extends CWebTest { @@ -422,8 +423,12 @@ class testPageLowLevelDiscovery extends CWebTest { 'I2-lvl1-trap-num: DR4-I2-dep-trap', 'Last error message of scenario "Web scenario for execute now".: DR5-web-dep', 'Zabbix server health: Zabbix stats cluster: High availability cluster node discovery', + 'LLD for Discovered host tests', 'Linux by Zabbix agent: Mounted filesystem discovery', - 'Linux by Zabbix agent: Network interface discovery' + 'Linux by Zabbix agent: Network interface discovery', + 'Test of discovered host 1 template for unlink: Template1 discovery rule', + 'Test of discovered host 2 template for clear: Template2 discovery rule', + 'Test of discovered host Template: Template discovery rule' ] ] ], -- cgit v1.2.3 From 58a48bc0a248baff96fc6c14b019da15b9e92920 Mon Sep 17 00:00:00 2001 From: Larisa Grigorjeva Date: Fri, 12 Aug 2022 22:53:25 +0100 Subject: .......... [DEV-2073] reorganized tests vol.8, fixed static function for on after --- ui/tests/selenium/SeleniumTests.php | 30 +++++++++++++--------- .../testFormAdministrationAuthenticationHttp.php | 4 +-- ui/tests/selenium/testFormLogin.php | 3 +++ 3 files changed, 23 insertions(+), 14 deletions(-) diff --git a/ui/tests/selenium/SeleniumTests.php b/ui/tests/selenium/SeleniumTests.php index 432d359e8e1..bf3b4cb325e 100644 --- a/ui/tests/selenium/SeleniumTests.php +++ b/ui/tests/selenium/SeleniumTests.php @@ -96,6 +96,15 @@ require_once dirname(__FILE__).'/macros/testFormMacrosHost.php'; require_once dirname(__FILE__).'/macros/testFormMacrosHostPrototype.php'; require_once dirname(__FILE__).'/macros/testFormMacrosTemplate.php'; +// Preprocessing. +require_once dirname(__FILE__).'/preprocessing/testFormPreprocessingCloneHost.php'; +require_once dirname(__FILE__).'/preprocessing/testFormPreprocessingCloneTemplate.php'; +require_once dirname(__FILE__).'/preprocessing/testFormPreprocessingItem.php'; +require_once dirname(__FILE__).'/preprocessing/testFormPreprocessingItemPrototype.php'; +require_once dirname(__FILE__).'/preprocessing/testFormPreprocessingLowLevelDiscovery.php'; +require_once dirname(__FILE__).'/preprocessing/testFormPreprocessingTest.php'; + + require_once dirname(__FILE__).'/testExecuteNow.php'; require_once dirname(__FILE__).'/testGraphAxis.php'; @@ -165,12 +174,6 @@ require_once dirname(__FILE__).'/testFormLogin.php'; require_once dirname(__FILE__).'/testFormMaintenance.php'; require_once dirname(__FILE__).'/testFormMap.php'; require_once dirname(__FILE__).'/testFormNetworkDiscovery.php'; -require_once dirname(__FILE__).'/preprocessing/testFormPreprocessingCloneHost.php'; -require_once dirname(__FILE__).'/preprocessing/testFormPreprocessingCloneTemplate.php'; -require_once dirname(__FILE__).'/preprocessing/testFormPreprocessingItem.php'; -require_once dirname(__FILE__).'/preprocessing/testFormPreprocessingItemPrototype.php'; -require_once dirname(__FILE__).'/preprocessing/testFormPreprocessingLowLevelDiscovery.php'; -require_once dirname(__FILE__).'/preprocessing/testFormPreprocessingTest.php'; require_once dirname(__FILE__).'/services/testFormServicesServices.php'; require_once dirname(__FILE__).'/services/testPageServicesServices.php'; require_once dirname(__FILE__).'/services/testPageServicesServicesMassUpdate.php'; @@ -314,6 +317,15 @@ class SeleniumTests { $suite->addTestSuite('testFormMacrosHostPrototype'); $suite->addTestSuite('testFormMacrosTemplate'); + // Preprocessing. + $suite->addTestSuite('testFormPreprocessingCloneHost'); + $suite->addTestSuite('testFormPreprocessingCloneTemplate'); + $suite->addTestSuite('testFormPreprocessingItem'); + $suite->addTestSuite('testFormPreprocessingItemPrototype'); + $suite->addTestSuite('testFormPreprocessingLowLevelDiscovery'); + $suite->addTestSuite('testFormPreprocessingTest'); + + $suite->addTestSuite('testExecuteNow'); $suite->addTestSuite('testGraphAxis'); @@ -389,12 +401,6 @@ class SeleniumTests { $suite->addTestSuite('testFormMap'); $suite->addTestSuite('testFormServicesServices'); $suite->addTestSuite('testFormNetworkDiscovery'); - $suite->addTestSuite('testFormPreprocessingCloneHost'); - $suite->addTestSuite('testFormPreprocessingCloneTemplate'); - $suite->addTestSuite('testFormPreprocessingItem'); - $suite->addTestSuite('testFormPreprocessingItemPrototype'); - $suite->addTestSuite('testFormPreprocessingLowLevelDiscovery'); - $suite->addTestSuite('testFormPreprocessingTest'); $suite->addTestSuite('testFormSetup'); $suite->addTestSuite('testFormSysmap'); $suite->addTestSuite('testFormTabIndicators'); diff --git a/ui/tests/selenium/testFormAdministrationAuthenticationHttp.php b/ui/tests/selenium/testFormAdministrationAuthenticationHttp.php index 5bd91b6974b..8f7a8be678d 100644 --- a/ui/tests/selenium/testFormAdministrationAuthenticationHttp.php +++ b/ui/tests/selenium/testFormAdministrationAuthenticationHttp.php @@ -678,11 +678,11 @@ class testFormAdministrationAuthenticationHttp extends CLegacyWebTest { /** * Guest user needs to be out of "Disabled" group to have access to frontend. */ - public static function removeGuestFromDisabledGroup() { + public function removeGuestFromDisabledGroup() { DBexecute('DELETE FROM users_groups WHERE userid=2 AND usrgrpid=9'); } - public function addGuestToDisabledGroup() { + public static function addGuestToDisabledGroup() { DBexecute('INSERT INTO users_groups (id, usrgrpid, userid) VALUES (150, 9, 2)'); } } diff --git a/ui/tests/selenium/testFormLogin.php b/ui/tests/selenium/testFormLogin.php index db40bac030b..f3888b84669 100644 --- a/ui/tests/selenium/testFormLogin.php +++ b/ui/tests/selenium/testFormLogin.php @@ -20,6 +20,9 @@ require_once dirname(__FILE__).'/../include/CLegacyWebTest.php'; +/** + * @backup users + */ class testFormLogin extends CLegacyWebTest { public static function data() { -- cgit v1.2.3 From 5820883ae31267e067f3acdb576f55ff02590de0 Mon Sep 17 00:00:00 2001 From: Larisa Grigorjeva Date: Sat, 13 Aug 2022 13:36:58 +0100 Subject: .......... [DEV-2073] fixed after 8 reorganization --- ui/tests/selenium/common/testFormHost.php | 2 +- ui/tests/selenium/data/sources/DiscoveredHosts.php | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/ui/tests/selenium/common/testFormHost.php b/ui/tests/selenium/common/testFormHost.php index 36552e91179..61a1040a4fe 100644 --- a/ui/tests/selenium/common/testFormHost.php +++ b/ui/tests/selenium/common/testFormHost.php @@ -1984,7 +1984,7 @@ class testFormHost extends CWebTest { ['name' => 'Host name', 'value' => self::DISCOVERED_HOST, 'maxlength' => 128, 'enabled' => false], ['name' => 'Visible name', 'value' => '', 'maxlength' => 128, 'enabled' => false], ['name' => 'id:add_templates_', 'value' => '', 'enabled' => true], - ['name' => 'Host groups', 'value' => ['Zabbix servers'], 'enabled' => false], + ['name' => 'Host groups', 'value' => ['Group for discovered host test'], 'enabled' => false], ['name' => 'id:interfaces_'.$discovered_interface_id.'_ip', 'value' => '127.0.0.1', 'maxlength' => 64, 'enabled' => false], ['name' => 'id:interfaces_'.$discovered_interface_id.'_dns', 'value' => '', diff --git a/ui/tests/selenium/data/sources/DiscoveredHosts.php b/ui/tests/selenium/data/sources/DiscoveredHosts.php index 269c7261b4d..96c686796e3 100644 --- a/ui/tests/selenium/data/sources/DiscoveredHosts.php +++ b/ui/tests/selenium/data/sources/DiscoveredHosts.php @@ -80,7 +80,7 @@ class DiscoveredHosts { $host_prototypes = CDataHelper::call('hostprototype.create', [ 'host' => 'Host created from host prototype {#KEY}', 'ruleid' => $lldid, - 'groupLinks' => [['groupid' => 4]], + 'groupLinks' => [['groupid' => $hostgroupid]], 'tags' => [ 'tag' => 'prototype', 'value' => 'true' @@ -100,7 +100,7 @@ class DiscoveredHosts { zbx_dbstr(self::DISCOVERED_INTERFACEID).",".zbx_dbstr(self::DISCOVERED_HOSTID).", 1, 1, 1, '127.0.0.1', '', '10050')" ); DBexecute("INSERT INTO hosts_groups (hostgroupid, hostid, groupid) VALUES (".zbx_dbstr(self::DISCOVERED_HOST_GROUPID). - ", ".zbx_dbstr(self::DISCOVERED_HOSTID).", 4)" + ", ".zbx_dbstr(self::DISCOVERED_HOSTID).", ".$hostgroupid.")" ); DBexecute("INSERT INTO host_tag (hosttagid, hostid, tag, value) VALUES (90000082, ". zbx_dbstr(self::DISCOVERED_HOSTID).", 'discovered', 'true')" -- cgit v1.2.3 From fb870bed66c4c30c99b45df9c911b731b1029deb Mon Sep 17 00:00:00 2001 From: Larisa Grigorjeva Date: Tue, 16 Aug 2022 20:32:54 +0100 Subject: .......... [DEV-2073] reorganized tests vol.9 --- ui/tests/selenium/SeleniumTests.php | 51 +++--- .../reports/testPageAvailabilityReport.php | 172 +++++++++++++++++++++ ui/tests/selenium/testPageAvailabilityReport.php | 172 --------------------- 3 files changed, 204 insertions(+), 191 deletions(-) create mode 100644 ui/tests/selenium/reports/testPageAvailabilityReport.php delete mode 100644 ui/tests/selenium/testPageAvailabilityReport.php diff --git a/ui/tests/selenium/SeleniumTests.php b/ui/tests/selenium/SeleniumTests.php index fc1bc248520..2c993540841 100644 --- a/ui/tests/selenium/SeleniumTests.php +++ b/ui/tests/selenium/SeleniumTests.php @@ -104,6 +104,23 @@ require_once dirname(__FILE__).'/preprocessing/testFormPreprocessingItemPrototyp require_once dirname(__FILE__).'/preprocessing/testFormPreprocessingLowLevelDiscovery.php'; require_once dirname(__FILE__).'/preprocessing/testFormPreprocessingTest.php'; +// Proxies. +require_once dirname(__FILE__).'/proxies/testFormAdministrationGeneralProxies.php'; +require_once dirname(__FILE__).'/proxies/testPageAdministrationGeneralProxies.php'; + + +// Reports. +require_once dirname(__FILE__).'/reports/testFormScheduledReport.php'; +require_once dirname(__FILE__).'/reports/testPageAvailabilityReport.php'; +require_once dirname(__FILE__).'/reports/testPageReportsActionLog.php'; +require_once dirname(__FILE__).'/reports/testPageReportsAudit.php'; +require_once dirname(__FILE__).'/reports/testPageReportsNotifications.php'; +require_once dirname(__FILE__).'/reports/testPageReportsSystemInformation.php'; +require_once dirname(__FILE__).'/reports/testPageReportsTriggerTop.php'; +require_once dirname(__FILE__).'/reports/testPageScheduledReport.php'; +require_once dirname(__FILE__).'/reports/testScheduledReportPermissions.php'; + + require_once dirname(__FILE__).'/testExecuteNow.php'; require_once dirname(__FILE__).'/testGraphAxis.php'; @@ -118,7 +135,6 @@ require_once dirname(__FILE__).'/testPageAdministrationGeneralModules.php'; require_once dirname(__FILE__).'/testPageAdministrationGeneralRegexp.php'; require_once dirname(__FILE__).'/testPageAdministrationMediaTypes.php'; require_once dirname(__FILE__).'/testPageAdministrationScripts.php'; -require_once dirname(__FILE__).'/testPageAvailabilityReport.php'; require_once dirname(__FILE__).'/testPageEventCorrelation.php'; require_once dirname(__FILE__).'/testPageGraphPrototypes.php'; require_once dirname(__FILE__).'/testPageHistory.php'; @@ -148,8 +164,7 @@ require_once dirname(__FILE__).'/testExpandExpressionMacros.php'; require_once dirname(__FILE__).'/testFormAdministrationAuthenticationHttp.php'; require_once dirname(__FILE__).'/testFormAdministrationAuthenticationLdap.php'; require_once dirname(__FILE__).'/testFormAdministrationAuthenticationSaml.php'; -require_once dirname(__FILE__).'/proxies/testFormAdministrationGeneralProxies.php'; -require_once dirname(__FILE__).'/proxies/testPageAdministrationGeneralProxies.php'; + require_once dirname(__FILE__).'/testFormAdministrationGeneralAuditLog.php'; require_once dirname(__FILE__).'/testFormAdministrationGeneralGUI.php'; require_once dirname(__FILE__).'/testFormAdministrationGeneralIconMapping.php'; @@ -223,14 +238,6 @@ require_once dirname(__FILE__).'/testZBX6648.php'; require_once dirname(__FILE__).'/testZBX6663.php'; require_once dirname(__FILE__).'/roles/testPageUserRoles.php'; require_once dirname(__FILE__).'/roles/testUserRolesPermissions.php'; -require_once dirname(__FILE__).'/reports/testPageReportsActionLog.php'; -require_once dirname(__FILE__).'/reports/testPageReportsAudit.php'; -require_once dirname(__FILE__).'/reports/testPageReportsNotifications.php'; -require_once dirname(__FILE__).'/reports/testPageReportsSystemInformation.php'; -require_once dirname(__FILE__).'/reports/testPageReportsTriggerTop.php'; -require_once dirname(__FILE__).'/reports/testFormScheduledReport.php'; -require_once dirname(__FILE__).'/reports/testPageScheduledReport.php'; -require_once dirname(__FILE__).'/reports/testScheduledReportPermissions.php'; require_once dirname(__FILE__).'/testSID.php'; use PHPUnit\Framework\TestSuite; @@ -325,6 +332,20 @@ class SeleniumTests { $suite->addTestSuite('testFormPreprocessingLowLevelDiscovery'); $suite->addTestSuite('testFormPreprocessingTest'); + // Proxies. + $suite->addTestSuite('testFormAdministrationGeneralProxies'); + $suite->addTestSuite('testPageAdministrationGeneralProxies'); + + // Reports. + $suite->addTestSuite('testFormScheduledReport'); + $suite->addTestSuite('testPageAvailabilityReport'); + $suite->addTestSuite('testPageReportsActionLog'); + $suite->addTestSuite('testPageReportsAudit'); + $suite->addTestSuite('testPageReportsNotifications'); + $suite->addTestSuite('testPageReportsSystemInformation'); + $suite->addTestSuite('testPageReportsTriggerTop'); + $suite->addTestSuite('testPageScheduledReport'); + $suite->addTestSuite('testScheduledReportPermissions'); $suite->addTestSuite('testExecuteNow'); @@ -337,7 +358,6 @@ class SeleniumTests { $suite->addTestSuite('testPageAdministrationGeneralRegexp'); $suite->addTestSuite('testPageAdministrationMediaTypes'); $suite->addTestSuite('testPageAdministrationScripts'); - $suite->addTestSuite('testPageAvailabilityReport'); $suite->addTestSuite('testPageEventCorrelation'); $suite->addTestSuite('testPageGraphPrototypes'); $suite->addTestSuite('testPageProblems'); @@ -361,11 +381,6 @@ class SeleniumTests { $suite->addTestSuite('testPageQueueOverview'); $suite->addTestSuite('testPageQueueOverviewByProxy'); */ - $suite->addTestSuite('testPageReportsActionLog'); - $suite->addTestSuite('testPageReportsAudit'); - $suite->addTestSuite('testPageReportsNotifications'); - $suite->addTestSuite('testPageReportsSystemInformation'); - $suite->addTestSuite('testPageReportsTriggerTop'); $suite->addTestSuite('testPageSearch'); $suite->addTestSuite('testPageStatusOfZabbix'); $suite->addTestSuite('testPageTemplates'); @@ -377,8 +392,6 @@ class SeleniumTests { $suite->addTestSuite('testFormAdministrationAuthenticationSaml'); $suite->addTestSuite('testFormAdministrationAuthenticationHttp'); $suite->addTestSuite('testFormAdministrationAuthenticationLdap'); - $suite->addTestSuite('testFormAdministrationGeneralProxies'); - $suite->addTestSuite('testPageAdministrationGeneralProxies'); $suite->addTestSuite('testFormAdministrationGeneralAuditLog'); $suite->addTestSuite('testFormAdministrationGeneralGUI'); $suite->addTestSuite('testFormAdministrationGeneralIconMapping'); diff --git a/ui/tests/selenium/reports/testPageAvailabilityReport.php b/ui/tests/selenium/reports/testPageAvailabilityReport.php new file mode 100644 index 00000000000..5f91672f7a8 --- /dev/null +++ b/ui/tests/selenium/reports/testPageAvailabilityReport.php @@ -0,0 +1,172 @@ + date('Y-m-d H:i:s', strtotime($start_time)), + 'to' => date('Y-m-d H:i:s', strtotime($end_time)), + 'filter_hostids' => 50014 + ]; + + $this->zbxTestLogin('report2.php?'.http_build_query($args)); + $table_rows =$this->webDriver->findElements(WebDriverBy::xpath('//table[@class="list-table"]/tbody/tr')); + if (!$table_rows) { + $this->fail("Failed to get SLA reports table."); + } + + foreach ($table_rows as $row) { + $cells = $row->findElements(WebDriverBy::xpath('td')); + $cells_values = []; + + foreach ($cells as $cell) { + $cells_values[] = $cell->getText(); + } + + // Check only cells 2,3,4 in every row: Label, Problem state value, Ok state value. + $this->assertContains(array_slice($cells_values, 1, 3), $sla_item_values); + } + } + + public function testPageAvailabilityReport_ByHost_CheckLayout() { + $this->zbxTestLogin('report2.php?config=0'); + $this->zbxTestCheckTitle('Availability report'); + $this->zbxTestCheckHeader('Availability report'); + $this->zbxTestTextPresent('Mode'); + $this->zbxTestTextPresent('Filter'); + $this->zbxTestTextPresent(['Host', 'Name', 'Problems', 'Ok', 'Graph']); + } + +// Check that no real host or template names displayed + public function testPageAvailabilityReport_ByHost_NoHostNames() { + $this->zbxTestLogin('report2.php?config=0'); + $this->zbxTestCheckTitle('Availability report'); + $this->zbxTestCheckNoRealHostnames(); + } + + public function testPageAvailabilityReport_ByTriggerTemplate_CheckLayout() { + $this->zbxTestLogin('report2.php?config=1'); + $this->zbxTestCheckTitle('Availability report'); + $this->zbxTestCheckHeader('Availability report'); + $this->zbxTestTextPresent('Mode'); + $this->zbxTestTextPresent('Filter'); + $this->zbxTestTextPresent(['Host', 'Name', 'Problems', 'Ok', 'Graph']); + } + +// Check that no real host or template names displayed + public function testPageAvailabilityReport_ByTriggerTemplate_NoHostNames() { + $this->zbxTestLogin('report2.php?config=1'); + $this->zbxTestCheckNoRealHostnames(); + } +} diff --git a/ui/tests/selenium/testPageAvailabilityReport.php b/ui/tests/selenium/testPageAvailabilityReport.php deleted file mode 100644 index 75e93cc281b..00000000000 --- a/ui/tests/selenium/testPageAvailabilityReport.php +++ /dev/null @@ -1,172 +0,0 @@ - date('Y-m-d H:i:s', strtotime($start_time)), - 'to' => date('Y-m-d H:i:s', strtotime($end_time)), - 'filter_hostids' => 50014 - ]; - - $this->zbxTestLogin('report2.php?'.http_build_query($args)); - $table_rows =$this->webDriver->findElements(WebDriverBy::xpath('//table[@class="list-table"]/tbody/tr')); - if (!$table_rows) { - $this->fail("Failed to get SLA reports table."); - } - - foreach ($table_rows as $row) { - $cells = $row->findElements(WebDriverBy::xpath('td')); - $cells_values = []; - - foreach ($cells as $cell) { - $cells_values[] = $cell->getText(); - } - - // Check only cells 2,3,4 in every row: Label, Problem state value, Ok state value. - $this->assertContains(array_slice($cells_values, 1, 3), $sla_item_values); - } - } - - public function testPageAvailabilityReport_ByHost_CheckLayout() { - $this->zbxTestLogin('report2.php?config=0'); - $this->zbxTestCheckTitle('Availability report'); - $this->zbxTestCheckHeader('Availability report'); - $this->zbxTestTextPresent('Mode'); - $this->zbxTestTextPresent('Filter'); - $this->zbxTestTextPresent(['Host', 'Name', 'Problems', 'Ok', 'Graph']); - } - -// Check that no real host or template names displayed - public function testPageAvailabilityReport_ByHost_NoHostNames() { - $this->zbxTestLogin('report2.php?config=0'); - $this->zbxTestCheckTitle('Availability report'); - $this->zbxTestCheckNoRealHostnames(); - } - - public function testPageAvailabilityReport_ByTriggerTemplate_CheckLayout() { - $this->zbxTestLogin('report2.php?config=1'); - $this->zbxTestCheckTitle('Availability report'); - $this->zbxTestCheckHeader('Availability report'); - $this->zbxTestTextPresent('Mode'); - $this->zbxTestTextPresent('Filter'); - $this->zbxTestTextPresent(['Host', 'Name', 'Problems', 'Ok', 'Graph']); - } - -// Check that no real host or template names displayed - public function testPageAvailabilityReport_ByTriggerTemplate_NoHostNames() { - $this->zbxTestLogin('report2.php?config=1'); - $this->zbxTestCheckNoRealHostnames(); - } -} -- cgit v1.2.3 From 3a50aba8b0cac3b1848c6386c649d5f14224cd9e Mon Sep 17 00:00:00 2001 From: Alexander Shubin Date: Wed, 17 Aug 2022 17:58:13 +0300 Subject: ..F....... [ZBXNEXT-7469] reworked widgets (part 1) --- .../sass/components/dashboard/_widget-clock.scss | 52 +- ui/app/controllers/CControllerDashboardView.php | 3 + .../CControllerDashboardWidgetCheck.php | 8 +- .../CControllerDashboardWidgetConfigure.php | 10 +- .../controllers/CControllerDashboardWidgetEdit.php | 88 ++- .../controllers/CControllerDashboardWidgetView.php | 2 +- .../CControllerDashboardWidgetsSanitize.php | 2 +- ui/app/controllers/CControllerHintboxEventlist.php | 2 +- ui/app/controllers/CControllerModuleList.php | 3 +- ui/app/controllers/CControllerProblem.php | 2 +- ui/app/controllers/CControllerProblemView.php | 2 +- ui/app/controllers/CControllerProfileUpdate.php | 11 + .../CControllerTemplateDashboardEdit.php | 3 + .../controllers/CControllerWidgetActionLogView.php | 4 +- ui/app/controllers/CControllerWidgetClockView.php | 4 +- .../controllers/CControllerWidgetDataOverView.php | 4 +- .../controllers/CControllerWidgetDiscoveryView.php | 2 +- .../controllers/CControllerWidgetFavGraphsView.php | 2 +- .../controllers/CControllerWidgetFavMapsView.php | 2 +- ui/app/controllers/CControllerWidgetGeoMapView.php | 4 +- ui/app/controllers/CControllerWidgetGraphView.php | 4 +- .../controllers/CControllerWidgetHostAvailView.php | 4 +- ui/app/controllers/CControllerWidgetItemView.php | 4 +- ui/app/controllers/CControllerWidgetIterator.php | 2 +- ...CControllerWidgetIteratorGraphPrototypeView.php | 4 +- ui/app/controllers/CControllerWidgetMapView.php | 4 +- .../controllers/CControllerWidgetNavTreeView.php | 4 +- .../controllers/CControllerWidgetPlainTextView.php | 4 +- .../CControllerWidgetProblemHostsView.php | 4 +- .../CControllerWidgetProblemsBySvView.php | 4 +- .../controllers/CControllerWidgetProblemsView.php | 4 +- .../controllers/CControllerWidgetSlaReportView.php | 4 +- .../controllers/CControllerWidgetSvgGraphView.php | 12 +- .../CControllerWidgetSystemInfoView.php | 4 +- .../controllers/CControllerWidgetTopHostsView.php | 8 +- .../controllers/CControllerWidgetTrigOverView.php | 4 +- ui/app/controllers/CControllerWidgetUrlView.php | 4 +- ui/app/controllers/CControllerWidgetWebView.php | 4 +- ui/app/partials/monitoring.host.filter.php | 4 +- ui/app/partials/monitoring.latest.filter.php | 4 +- ui/app/partials/monitoring.problem.filter.php | 8 +- ui/app/views/administration.mediatype.list.php | 4 +- ui/app/views/configuration.dashboard.edit.php | 1 + .../views/js/configuration.dashboard.edit.js.php | 7 +- ui/app/views/js/monitoring.dashboard.view.js.php | 7 +- .../js/monitoring.dashboard.widget.edit.js.php | 37 - .../views/js/monitoring.widget.clock.edit.js.php | 102 +++ ui/app/views/js/popup.massupdate.tmpl.js.php | 2 +- ui/app/views/js/widget.form.view.js.php | 38 ++ ui/app/views/monitoring.dashboard.view.php | 1 + ui/app/views/monitoring.dashboard.widget.edit.php | 84 --- ui/app/views/monitoring.widget.actionlog.edit.php | 36 + ui/app/views/monitoring.widget.clock.edit.php | 60 ++ ui/app/views/monitoring.widget.dataover.edit.php | 30 + ui/app/views/monitoring.widget.discovery.edit.php | 30 + ui/app/views/monitoring.widget.favgraphs.edit.php | 30 + ui/app/views/monitoring.widget.favmaps.edit.php | 30 + ui/app/views/monitoring.widget.geomap.edit.php | 30 + ui/app/views/monitoring.widget.graph.edit.php | 30 + ui/app/views/monitoring.widget.hostavail.edit.php | 30 + ui/app/views/monitoring.widget.item.edit.php | 30 + ui/app/views/monitoring.widget.map.edit.php | 30 + ui/app/views/monitoring.widget.navtree.edit.php | 30 + ui/app/views/monitoring.widget.plaintext.edit.php | 30 + .../views/monitoring.widget.problemhosts.edit.php | 30 + ui/app/views/monitoring.widget.problems.edit.php | 30 + .../views/monitoring.widget.problemsbysv.edit.php | 30 + ui/app/views/monitoring.widget.slareport.edit.php | 30 + ui/app/views/monitoring.widget.svggraph.edit.php | 30 + ui/app/views/monitoring.widget.systeminfo.edit.php | 30 + ui/app/views/monitoring.widget.tophosts.edit.php | 30 + ui/app/views/monitoring.widget.trigover.edit.php | 30 + ui/app/views/monitoring.widget.url.edit.php | 30 + ui/app/views/monitoring.widget.web.edit.php | 30 + ui/app/views/popup.massupdate.service.php | 2 +- ui/app/views/popup.service.edit.php | 4 +- ui/app/views/popup.sla.edit.php | 2 +- ui/app/views/popup.tophosts.column.edit.php | 2 +- ui/assets/styles/blue-theme.css | 18 +- ui/assets/styles/dark-theme.css | 18 +- ui/assets/styles/hc-dark.css | 18 +- ui/assets/styles/hc-light.css | 18 +- ui/include/classes/api/services/CItem.php | 12 +- ui/include/classes/core/ZBase.php | 2 +- ui/include/classes/helpers/CDashboardHelper.php | 6 +- ui/include/classes/helpers/CSvgGraphHelper.php | 2 +- ui/include/classes/html/CColor.php | 6 +- ui/include/classes/html/CLabel.php | 12 +- ui/include/classes/html/CRadioButtonList.php | 2 +- ui/include/classes/html/CScriptTemplate.php | 52 -- ui/include/classes/html/CTemplateTag.php | 32 + .../html/widgets/CWidgetFieldCheckBoxListView.php | 57 ++ .../html/widgets/CWidgetFieldCheckBoxView.php | 38 ++ .../classes/html/widgets/CWidgetFieldColorView.php | 33 + .../html/widgets/CWidgetFieldIntegerBoxView.php | 35 + .../widgets/CWidgetFieldMultiSelectHostView.php | 38 ++ .../widgets/CWidgetFieldMultiSelectItemView.php | 35 + .../html/widgets/CWidgetFieldMultiSelectView.php | 65 ++ .../widgets/CWidgetFieldRadioButtonListView.php | 41 ++ .../html/widgets/CWidgetFieldSelectView.php | 37 + .../classes/html/widgets/CWidgetFieldView.php | 65 ++ .../classes/html/widgets/CWidgetFormView.php | 226 +++++++ ui/include/classes/mvc/CRouter.php | 61 +- ui/include/classes/mvc/CView.php | 8 + ui/include/classes/widgets/CWidgetConfig.php | 65 +- ui/include/classes/widgets/CWidgetHelper.php | 438 +++++------- ui/include/classes/widgets/fields/CWidgetField.php | 260 ++++--- .../widgets/fields/CWidgetFieldCheckBox.php | 25 +- .../widgets/fields/CWidgetFieldCheckBoxList.php | 27 +- .../classes/widgets/fields/CWidgetFieldColor.php | 34 +- .../widgets/fields/CWidgetFieldColumnsList.php | 128 ++-- .../widgets/fields/CWidgetFieldDatePicker.php | 43 +- .../widgets/fields/CWidgetFieldGraphDataSet.php | 102 +-- .../widgets/fields/CWidgetFieldGraphOverride.php | 107 +-- .../classes/widgets/fields/CWidgetFieldHidden.php | 35 - .../fields/CWidgetFieldHostPatternSelect.php | 37 +- .../widgets/fields/CWidgetFieldIntegerBox.php | 44 +- .../classes/widgets/fields/CWidgetFieldLatLng.php | 29 +- .../classes/widgets/fields/CWidgetFieldMs.php | 126 ---- .../classes/widgets/fields/CWidgetFieldMsGraph.php | 40 -- .../fields/CWidgetFieldMsGraphPrototype.php | 40 -- .../classes/widgets/fields/CWidgetFieldMsGroup.php | 29 - .../classes/widgets/fields/CWidgetFieldMsHost.php | 43 -- .../classes/widgets/fields/CWidgetFieldMsItem.php | 40 -- .../widgets/fields/CWidgetFieldMsItemPrototype.php | 40 -- .../widgets/fields/CWidgetFieldMsService.php | 40 -- .../classes/widgets/fields/CWidgetFieldMsSla.php | 40 -- .../widgets/fields/CWidgetFieldMultiSelect.php | 88 +++ .../fields/CWidgetFieldMultiSelectGraph.php | 36 + .../CWidgetFieldMultiSelectGraphPrototype.php | 36 + .../fields/CWidgetFieldMultiSelectGroup.php | 29 + .../widgets/fields/CWidgetFieldMultiSelectHost.php | 29 + .../widgets/fields/CWidgetFieldMultiSelectItem.php | 36 + .../CWidgetFieldMultiSelectItemPrototype.php | 36 + .../fields/CWidgetFieldMultiSelectService.php | 29 + .../widgets/fields/CWidgetFieldMultiSelectSla.php | 29 + .../classes/widgets/fields/CWidgetFieldNavTree.php | 65 +- .../widgets/fields/CWidgetFieldNumericBox.php | 31 +- .../widgets/fields/CWidgetFieldRadioButtonList.php | 33 +- .../widgets/fields/CWidgetFieldRangeControl.php | 55 +- .../widgets/fields/CWidgetFieldReference.php | 18 +- .../classes/widgets/fields/CWidgetFieldSelect.php | 29 +- .../widgets/fields/CWidgetFieldSelectResource.php | 90 ++- .../widgets/fields/CWidgetFieldSeverities.php | 4 +- .../classes/widgets/fields/CWidgetFieldTags.php | 72 +- .../widgets/fields/CWidgetFieldTextArea.php | 39 +- .../classes/widgets/fields/CWidgetFieldTextBox.php | 46 +- .../widgets/fields/CWidgetFieldTimeZone.php | 52 +- .../classes/widgets/fields/CWidgetFieldUrl.php | 30 +- .../widgets/fields/CWidgetFieldWidgetSelect.php | 40 +- ui/include/classes/widgets/forms/CWidgetForm.php | 195 +++--- .../classes/widgets/forms/CWidgetFormActionLog.php | 57 +- .../classes/widgets/forms/CWidgetFormClock.php | 323 +++------ .../classes/widgets/forms/CWidgetFormDataOver.php | 101 +-- .../classes/widgets/forms/CWidgetFormGeoMap.php | 79 +-- .../classes/widgets/forms/CWidgetFormGraph.php | 85 +-- .../widgets/forms/CWidgetFormGraphPrototype.php | 104 ++- .../classes/widgets/forms/CWidgetFormHostAvail.php | 66 +- .../classes/widgets/forms/CWidgetFormItem.php | 550 +++++---------- .../classes/widgets/forms/CWidgetFormMap.php | 78 +-- .../classes/widgets/forms/CWidgetFormNavTree.php | 49 +- .../classes/widgets/forms/CWidgetFormPlainText.php | 91 +-- .../widgets/forms/CWidgetFormProblemHosts.php | 155 ++--- .../classes/widgets/forms/CWidgetFormProblems.php | 321 +++------ .../widgets/forms/CWidgetFormProblemsBySv.php | 260 +++---- .../classes/widgets/forms/CWidgetFormSlaReport.php | 91 +-- .../classes/widgets/forms/CWidgetFormSvgGraph.php | 749 ++++++++------------- .../widgets/forms/CWidgetFormSystemInfo.php | 26 +- .../classes/widgets/forms/CWidgetFormTopHosts.php | 177 ++--- .../classes/widgets/forms/CWidgetFormTrigOver.php | 124 ++-- .../classes/widgets/forms/CWidgetFormUrl.php | 39 +- .../classes/widgets/forms/CWidgetFormWeb.php | 94 +-- .../views/js/widget.svggraph.form.view.js.php | 2 +- .../widgets/views/widget.clock.form.view.php | 84 +-- .../widgets/views/widget.dataover.form.view.php | 2 +- .../widgets/views/widget.geomap.form.view.php | 2 +- .../classes/widgets/views/widget.map.form.view.php | 2 +- .../views/widget.problemhosts.form.view.php | 9 +- .../widgets/views/widget.problems.form.view.php | 2 +- .../views/widget.problemsbysv.form.view.php | 2 +- .../widgets/views/widget.svggraph.form.view.php | 4 +- .../widgets/views/widget.systeminfo.form.view.php | 6 +- .../widgets/views/widget.tophosts.form.view.php | 2 +- .../widgets/views/widget.trigover.form.view.php | 2 +- .../classes/widgets/views/widget.web.form.view.php | 2 +- ui/include/defines.inc.php | 14 +- ui/js/class.dashboard.js | 30 +- ui/js/common.js | 10 +- ui/js/main.js | 2 +- ui/js/widgets/class.widget.js | 2 +- ui/tests/selenium/testSID.php | 2 +- 191 files changed, 4421 insertions(+), 4602 deletions(-) delete mode 100644 ui/app/views/js/monitoring.dashboard.widget.edit.js.php create mode 100755 ui/app/views/js/monitoring.widget.clock.edit.js.php create mode 100644 ui/app/views/js/widget.form.view.js.php delete mode 100644 ui/app/views/monitoring.dashboard.widget.edit.php create mode 100755 ui/app/views/monitoring.widget.actionlog.edit.php create mode 100755 ui/app/views/monitoring.widget.clock.edit.php create mode 100755 ui/app/views/monitoring.widget.dataover.edit.php create mode 100755 ui/app/views/monitoring.widget.discovery.edit.php create mode 100755 ui/app/views/monitoring.widget.favgraphs.edit.php create mode 100755 ui/app/views/monitoring.widget.favmaps.edit.php create mode 100755 ui/app/views/monitoring.widget.geomap.edit.php create mode 100755 ui/app/views/monitoring.widget.graph.edit.php create mode 100755 ui/app/views/monitoring.widget.hostavail.edit.php create mode 100755 ui/app/views/monitoring.widget.item.edit.php create mode 100755 ui/app/views/monitoring.widget.map.edit.php create mode 100755 ui/app/views/monitoring.widget.navtree.edit.php create mode 100755 ui/app/views/monitoring.widget.plaintext.edit.php create mode 100755 ui/app/views/monitoring.widget.problemhosts.edit.php create mode 100755 ui/app/views/monitoring.widget.problems.edit.php create mode 100755 ui/app/views/monitoring.widget.problemsbysv.edit.php create mode 100755 ui/app/views/monitoring.widget.slareport.edit.php create mode 100755 ui/app/views/monitoring.widget.svggraph.edit.php create mode 100755 ui/app/views/monitoring.widget.systeminfo.edit.php create mode 100755 ui/app/views/monitoring.widget.tophosts.edit.php create mode 100755 ui/app/views/monitoring.widget.trigover.edit.php create mode 100755 ui/app/views/monitoring.widget.url.edit.php create mode 100755 ui/app/views/monitoring.widget.web.edit.php delete mode 100644 ui/include/classes/html/CScriptTemplate.php create mode 100644 ui/include/classes/html/CTemplateTag.php create mode 100755 ui/include/classes/html/widgets/CWidgetFieldCheckBoxListView.php create mode 100755 ui/include/classes/html/widgets/CWidgetFieldCheckBoxView.php create mode 100755 ui/include/classes/html/widgets/CWidgetFieldColorView.php create mode 100755 ui/include/classes/html/widgets/CWidgetFieldIntegerBoxView.php create mode 100755 ui/include/classes/html/widgets/CWidgetFieldMultiSelectHostView.php create mode 100755 ui/include/classes/html/widgets/CWidgetFieldMultiSelectItemView.php create mode 100755 ui/include/classes/html/widgets/CWidgetFieldMultiSelectView.php create mode 100755 ui/include/classes/html/widgets/CWidgetFieldRadioButtonListView.php create mode 100755 ui/include/classes/html/widgets/CWidgetFieldSelectView.php create mode 100755 ui/include/classes/html/widgets/CWidgetFieldView.php create mode 100755 ui/include/classes/html/widgets/CWidgetFormView.php delete mode 100644 ui/include/classes/widgets/fields/CWidgetFieldHidden.php delete mode 100644 ui/include/classes/widgets/fields/CWidgetFieldMs.php delete mode 100644 ui/include/classes/widgets/fields/CWidgetFieldMsGraph.php delete mode 100644 ui/include/classes/widgets/fields/CWidgetFieldMsGraphPrototype.php delete mode 100644 ui/include/classes/widgets/fields/CWidgetFieldMsGroup.php delete mode 100644 ui/include/classes/widgets/fields/CWidgetFieldMsHost.php delete mode 100644 ui/include/classes/widgets/fields/CWidgetFieldMsItem.php delete mode 100644 ui/include/classes/widgets/fields/CWidgetFieldMsItemPrototype.php delete mode 100644 ui/include/classes/widgets/fields/CWidgetFieldMsService.php delete mode 100644 ui/include/classes/widgets/fields/CWidgetFieldMsSla.php create mode 100644 ui/include/classes/widgets/fields/CWidgetFieldMultiSelect.php create mode 100644 ui/include/classes/widgets/fields/CWidgetFieldMultiSelectGraph.php create mode 100644 ui/include/classes/widgets/fields/CWidgetFieldMultiSelectGraphPrototype.php create mode 100644 ui/include/classes/widgets/fields/CWidgetFieldMultiSelectGroup.php create mode 100644 ui/include/classes/widgets/fields/CWidgetFieldMultiSelectHost.php create mode 100644 ui/include/classes/widgets/fields/CWidgetFieldMultiSelectItem.php create mode 100644 ui/include/classes/widgets/fields/CWidgetFieldMultiSelectItemPrototype.php create mode 100644 ui/include/classes/widgets/fields/CWidgetFieldMultiSelectService.php create mode 100644 ui/include/classes/widgets/fields/CWidgetFieldMultiSelectSla.php diff --git a/sass/stylesheets/sass/components/dashboard/_widget-clock.scss b/sass/stylesheets/sass/components/dashboard/_widget-clock.scss index 41497454cf9..1f282fe2020 100644 --- a/sass/stylesheets/sass/components/dashboard/_widget-clock.scss +++ b/sass/stylesheets/sass/components/dashboard/_widget-clock.scss @@ -1,39 +1,41 @@ // Widget configuration. form.dashboard-widget-clock { - .fields-group-date, - .fields-group-time, - .fields-group-tzone { - display: grid; - grid-template-columns: 60px 120px repeat(2, minmax(60px, max-content) auto); - align-items: center; - column-gap: 10px; - row-gap: 5px; + .fields-group { + &.fields-group-date, + &.fields-group-time, + &.fields-group-tzone { + display: grid; + grid-template-columns: 60px 120px repeat(2, minmax(60px, max-content) auto); + align-items: center; + column-gap: 10px; + row-gap: 5px; - label { - text-align: right; - } + label { + text-align: right; + } - .field-size { - input { - margin-right: 5px; + .field-size { + input { + margin-right: 5px; + } } } - } - .fields-group-time { - .field-format { - grid-column: 4 / -1; + &.fields-group-time { + .field-format { + grid-column: 4 / -1; + } } - } - .fields-group-tzone { - .field-format { - grid-column: 2 / -1; - } + &.fields-group-tzone { + .field-format { + grid-column: 2 / -1; + } - .field-timezone { - grid-column: 2 / -1; + .field-timezone { + grid-column: 2 / -1; + } } } } diff --git a/ui/app/controllers/CControllerDashboardView.php b/ui/app/controllers/CControllerDashboardView.php index 6cf3c325f25..26fd8d7ba60 100644 --- a/ui/app/controllers/CControllerDashboardView.php +++ b/ui/app/controllers/CControllerDashboardView.php @@ -104,9 +104,12 @@ class CControllerDashboardView extends CController { updateTimeSelectorPeriod($time_selector_options); + $widget_known_types = array_keys(CWidgetConfig::getKnownWidgetTypes(CWidgetConfig::CONTEXT_DASHBOARD)); + $data = [ 'dashboard' => $dashboard, 'widget_defaults' => CWidgetConfig::getDefaults(CWidgetConfig::CONTEXT_DASHBOARD), + 'widget_last_type' => CProfile::get('web.dashboard.last_widget_type', $widget_known_types[0]), 'has_time_selector' => CDashboardHelper::hasTimeSelector($dashboard['pages']), 'time_period' => getTimeSelectorPeriod($time_selector_options), 'active_tab' => CProfile::get('web.dashboard.filter.active', 1) diff --git a/ui/app/controllers/CControllerDashboardWidgetCheck.php b/ui/app/controllers/CControllerDashboardWidgetCheck.php index 5c1c159bddc..d035fafad16 100644 --- a/ui/app/controllers/CControllerDashboardWidgetCheck.php +++ b/ui/app/controllers/CControllerDashboardWidgetCheck.php @@ -29,10 +29,10 @@ class CControllerDashboardWidgetCheck extends CController { protected function checkInput() { $fields = [ - 'templateid' => 'db dashboard.templateid', 'type' => 'required|string', - 'name' => 'required|string', - 'fields' => 'json' + 'fields' => 'array', + 'templateid' => 'db dashboard.templateid', + 'name' => 'required|string' ]; $ret = $this->validateInput($fields); @@ -67,7 +67,7 @@ class CControllerDashboardWidgetCheck extends CController { } protected function doAction() { - $form = CWidgetConfig::getForm($this->getInput('type'), $this->getInput('fields', '{}'), + $form = CWidgetConfig::getForm($this->getInput('type'), $this->getInput('fields', []), ($this->context === CWidgetConfig::CONTEXT_TEMPLATE_DASHBOARD) ? $this->getInput('templateid') : null ); diff --git a/ui/app/controllers/CControllerDashboardWidgetConfigure.php b/ui/app/controllers/CControllerDashboardWidgetConfigure.php index 9c34138eac8..7777f5dcdf9 100644 --- a/ui/app/controllers/CControllerDashboardWidgetConfigure.php +++ b/ui/app/controllers/CControllerDashboardWidgetConfigure.php @@ -29,9 +29,9 @@ class CControllerDashboardWidgetConfigure extends CController { protected function checkInput() { $fields = [ - 'templateid' => 'db dashboard.templateid', 'type' => 'required|string', - 'fields' => 'json', + 'fields' => 'array', + 'templateid' => 'db dashboard.templateid', 'view_mode' => 'required|in '.implode(',', [ZBX_WIDGET_VIEW_MODE_NORMAL, ZBX_WIDGET_VIEW_MODE_HIDDEN_HEADER]) ]; @@ -67,9 +67,7 @@ class CControllerDashboardWidgetConfigure extends CController { } protected function doAction() { - $type = $this->getInput('type'); - - $form = CWidgetConfig::getForm($type, $this->getInput('fields', '{}'), + $form = CWidgetConfig::getForm($this->getInput('type'), $this->getInput('fields', []), ($this->context === CWidgetConfig::CONTEXT_TEMPLATE_DASHBOARD) ? $this->getInput('templateid') : null ); @@ -77,7 +75,7 @@ class CControllerDashboardWidgetConfigure extends CController { $form->validate(); $output = [ - 'configuration' => CWidgetConfig::getConfiguration($type, $form->getFieldsData(), + 'configuration' => CWidgetConfig::getConfiguration($this->getInput('type'), $form->getFieldsValues(), $this->getInput('view_mode') ) ]; diff --git a/ui/app/controllers/CControllerDashboardWidgetEdit.php b/ui/app/controllers/CControllerDashboardWidgetEdit.php index bf020dfe72d..8e49f2a16dc 100644 --- a/ui/app/controllers/CControllerDashboardWidgetEdit.php +++ b/ui/app/controllers/CControllerDashboardWidgetEdit.php @@ -25,12 +25,11 @@ class CControllerDashboardWidgetEdit extends CController { protected function checkInput() { $fields = [ + 'type' => 'string|required', + 'fields' => 'array', 'templateid' => 'db dashboard.templateid', - 'type' => 'string', 'name' => 'string', 'view_mode' => 'in '.implode(',', [ZBX_WIDGET_VIEW_MODE_NORMAL, ZBX_WIDGET_VIEW_MODE_HIDDEN_HEADER]), - 'prev_type' => 'string', - 'fields' => 'json', 'unique_id' => 'string', 'dashboard_page_unique_id' => 'string' ]; @@ -42,22 +41,23 @@ class CControllerDashboardWidgetEdit extends CController { ? CWidgetConfig::CONTEXT_TEMPLATE_DASHBOARD : CWidgetConfig::CONTEXT_DASHBOARD; - if ($this->hasInput('type')) { - if (!CWidgetConfig::isWidgetTypeSupportedInContext($this->getInput('type'), $this->context)) { - error(_('Widget type is not supported in this context.')); + if (!CWidgetConfig::isWidgetTypeSupportedInContext($this->getInput('type'), $this->context)) { + error(_('Widget type is not supported in this context.')); - $ret = false; - } + $ret = false; } } if (!$ret) { $this->setResponse( - (new CControllerResponseData(['main_block' => json_encode([ - 'error' => [ - 'messages' => array_column(get_and_clear_messages(), 'message') - ] - ])]))->disableView() + (new CControllerResponseData([ + 'main_block' => json_encode([ + 'header' => $this->hasInput('unique_id') ? _('Edit widget') : _('Add widget'), + 'error' => [ + 'messages' => array_column(get_and_clear_messages(), 'message') + ] + ]) + ]))->disableView() ); } @@ -71,50 +71,38 @@ class CControllerDashboardWidgetEdit extends CController { } protected function doAction() { - $known_widget_types = CWidgetConfig::getKnownWidgetTypes($this->context); - - natsort($known_widget_types); + $known_types = CWidgetConfig::getKnownWidgetTypes($this->context); + natsort($known_types); - if ($this->hasInput('type')) { - $type = $this->getInput('type'); - - if (!array_key_exists($type, $known_widget_types) || $this->getInput('prev_type', $type) !== $type) { - CProfile::update('web.dashboard.last_widget_type', $type, PROFILE_TYPE_STR); - } - } - else { - $type = CProfile::get('web.dashboard.last_widget_type'); - if (!array_key_exists($type, $known_widget_types)) { - $type = array_keys($known_widget_types)[0]; - } - } + $deprecated_types = array_intersect_key($known_types, + array_flip(CWidgetConfig::DEPRECATED_WIDGETS) + ); $templateid = ($this->context === CWidgetConfig::CONTEXT_TEMPLATE_DASHBOARD) ? $this->getInput('templateid') : null; - $form = CWidgetConfig::getForm($type, $this->getInput('fields', '{}'), $templateid); + $form = CWidgetConfig::getForm($this->getInput('type'), $this->getInput('fields', []), $templateid); // Transforms corrupted data to default values. $form->validate(); $this->setResponse(new CControllerResponseData([ - 'user' => [ - 'debug_mode' => $this->getDebugMode() - ], - 'dialogue' => [ - 'type' => $type, - 'name' => $this->getInput('name', ''), - 'view_mode' => $this->getInput('view_mode', ZBX_WIDGET_VIEW_MODE_NORMAL), - 'fields' => $form->getFields() - ], - 'templateid' => $templateid, + 'name' => $this->getInput('name', ''), + 'type' => $this->getInput('type'), + 'known_types' => array_diff_key($known_types, $deprecated_types), + 'deprecated_types' => $deprecated_types, + 'fields' => $form->getFields(), + 'view_mode' => $this->getInput('view_mode', ZBX_WIDGET_VIEW_MODE_NORMAL), 'unique_id' => $this->hasInput('unique_id') ? $this->getInput('unique_id') : null, 'dashboard_page_unique_id' => $this->hasInput('dashboard_page_unique_id') ? $this->getInput('dashboard_page_unique_id') : null, - 'known_widget_types' => $known_widget_types, - 'captions' => $this->getCaptions($form) + 'captions' => $this->getCaptions($form), + 'user' => [ + 'debug_mode' => $this->getDebugMode() + ], +// 'templateid' => $templateid, // TODO: AS - really needs templateid? ])); } @@ -182,35 +170,35 @@ class CControllerDashboardWidgetEdit extends CController { ]; foreach ($form->getFields() as $field) { - if ($field instanceof CWidgetFieldMsGroup) { + if ($field instanceof CWidgetFieldMultiSelectGroup) { $key = 'groups'; $var = 'group'; } - elseif ($field instanceof CWidgetFieldMsHost) { + elseif ($field instanceof CWidgetFieldMultiSelectHost) { $key = 'hosts'; $var = 'host'; } - elseif ($field instanceof CWidgetFieldMsItem) { + elseif ($field instanceof CWidgetFieldMultiSelectItem) { $key = 'items'; $var = 'item'; } - elseif ($field instanceof CWidgetFieldMsGraph) { + elseif ($field instanceof CWidgetFieldMultiSelectGraph) { $key = 'graphs'; $var = 'graph'; } - elseif ($field instanceof CWidgetFieldMsItemPrototype) { + elseif ($field instanceof CWidgetFieldMultiSelectItemPrototype) { $key = 'item_prototypes'; $var = 'prototype_item'; } - elseif ($field instanceof CWidgetFieldMsGraphPrototype) { + elseif ($field instanceof CWidgetFieldMultiSelectGraphPrototype) { $key = 'graph_prototypes'; $var = 'prototype_graph'; } - elseif ($field instanceof CWidgetFieldMsService) { + elseif ($field instanceof CWidgetFieldMultiSelectService) { $key = 'services'; $var = 'service'; } - elseif ($field instanceof CWidgetFieldMsSla) { + elseif ($field instanceof CWidgetFieldMultiSelectSla) { $key = 'slas'; $var = 'sla'; } diff --git a/ui/app/controllers/CControllerDashboardWidgetView.php b/ui/app/controllers/CControllerDashboardWidgetView.php index c3b2de09136..6678a5f8339 100644 --- a/ui/app/controllers/CControllerDashboardWidgetView.php +++ b/ui/app/controllers/CControllerDashboardWidgetView.php @@ -111,7 +111,7 @@ abstract class CControllerDashboardWidgetView extends CController { $ret = $this->validateInput($validation_rules); if ($ret) { - $this->form = CWidgetConfig::getForm($this->type, $this->getInput('fields', '{}'), + $this->form = CWidgetConfig::getForm($this->type, $this->getInput('fields', []), $this->hasInput('templateid') ? $this->getInput('templateid') : null ); diff --git a/ui/app/controllers/CControllerDashboardWidgetsSanitize.php b/ui/app/controllers/CControllerDashboardWidgetsSanitize.php index 5d2f8d8a07a..7bf88f4b614 100644 --- a/ui/app/controllers/CControllerDashboardWidgetsSanitize.php +++ b/ui/app/controllers/CControllerDashboardWidgetsSanitize.php @@ -47,7 +47,7 @@ class CControllerDashboardWidgetsSanitize extends CController { foreach ($this->getInput('widgets', []) as $widget) { $validator = new CNewValidator($widget, [ 'type' => 'required|string', - 'fields' => 'required|json' + 'fields' => 'required|array' ]); foreach ($validator->getAllErrors() as $error) { diff --git a/ui/app/controllers/CControllerHintboxEventlist.php b/ui/app/controllers/CControllerHintboxEventlist.php index 73f20d4f297..a6ccad55510 100644 --- a/ui/app/controllers/CControllerHintboxEventlist.php +++ b/ui/app/controllers/CControllerHintboxEventlist.php @@ -34,7 +34,7 @@ class CControllerHintboxEventlist extends CController { $fields = [ 'triggerid' => 'required|db triggers.triggerid', 'eventid_till' => 'required|db events.eventid', - 'show_timeline' => 'required|in 0,1', + 'show_timeline' => 'required|in '.implode(',', [ZBX_TIMELINE_OFF, ZBX_TIMELINE_ON]), 'show_tags' => 'required|in '.implode(',', [SHOW_TAGS_NONE, SHOW_TAGS_1, SHOW_TAGS_2, SHOW_TAGS_3]), 'filter_tags' => 'array', 'tag_name_format' => 'required|in '.implode(',', [TAG_NAME_FULL, TAG_NAME_SHORTENED, TAG_NAME_NONE]), diff --git a/ui/app/controllers/CControllerModuleList.php b/ui/app/controllers/CControllerModuleList.php index 9c953b870a9..fe9b7e5b296 100644 --- a/ui/app/controllers/CControllerModuleList.php +++ b/ui/app/controllers/CControllerModuleList.php @@ -93,7 +93,8 @@ class CControllerModuleList extends CController { foreach ($db_modules as $moduleid => $db_module) { $manifest = $module_manager->addModule($db_module['relative_path']); - if ($manifest && ($filter['name'] === '' || mb_stripos($manifest['name'], $filter['name']) !== false)) { + if ($manifest !== null + && ($filter['name'] === '' || mb_stripos($manifest['name'], $filter['name']) !== false)) { $modules[$moduleid] = $db_module + $manifest; } } diff --git a/ui/app/controllers/CControllerProblem.php b/ui/app/controllers/CControllerProblem.php index a2451fc28ba..4b883991f2e 100644 --- a/ui/app/controllers/CControllerProblem.php +++ b/ui/app/controllers/CControllerProblem.php @@ -44,7 +44,7 @@ abstract class CControllerProblem extends CController { 'show_suppressed' => 0, 'unacknowledged' => 0, 'compact_view' => 0, - 'show_timeline' => 1, + 'show_timeline' => ZBX_TIMELINE_ON, 'details' => 0, 'highlight_row' => 0, 'show_opdata' => OPERATIONAL_DATA_SHOW_NONE, diff --git a/ui/app/controllers/CControllerProblemView.php b/ui/app/controllers/CControllerProblemView.php index 509dae31dee..9ce460910d6 100644 --- a/ui/app/controllers/CControllerProblemView.php +++ b/ui/app/controllers/CControllerProblemView.php @@ -42,7 +42,7 @@ class CControllerProblemView extends CControllerProblem { 'show_suppressed' => 'in 0,1', 'unacknowledged' => 'in 0,1', 'compact_view' => 'in 0,1', - 'show_timeline' => 'in 0,1', + 'show_timeline' => 'in '.ZBX_TIMELINE_OFF.', '.ZBX_TIMELINE_ON, 'details' => 'in 0,1', 'highlight_row' => 'in 0,1', 'show_opdata' => 'in '.OPERATIONAL_DATA_SHOW_NONE.','.OPERATIONAL_DATA_SHOW_SEPARATELY.','.OPERATIONAL_DATA_SHOW_WITH_PROBLEM, diff --git a/ui/app/controllers/CControllerProfileUpdate.php b/ui/app/controllers/CControllerProfileUpdate.php index 1ff1c7b6d2f..c164d456109 100644 --- a/ui/app/controllers/CControllerProfileUpdate.php +++ b/ui/app/controllers/CControllerProfileUpdate.php @@ -41,6 +41,7 @@ class CControllerProfileUpdate extends CController { case 'web.correlation.filter.active': case 'web.dashboard.filter.active': case 'web.dashboard.hostid': + case 'web.dashboard.last_widget_type': case 'web.discovery.filter.active': case 'web.discoveryconf.filter.active': case 'web.hostgroups.filter.active': @@ -104,6 +105,7 @@ class CControllerProfileUpdate extends CController { if ($ret) { switch ($this->getInput('idx')) { + case 'web.dashboard.last_widget_type': case 'web.dashboard.widget.geomap.default_view': case 'web.dashboard.widget.geomap.severity_filter': $ret = $this->hasInput('value_str'); @@ -132,6 +134,15 @@ class CControllerProfileUpdate extends CController { DBstart(); switch ($idx) { // PROFILE_TYPE_STR + case 'web.dashboard.last_widget_type': + $value_str = $this->getInput('value_str'); + if ($value_str === '') { + CProfile::delete($idx); + } + else { + CProfile::update($idx, $value_str, PROFILE_TYPE_STR); + } + break; case 'web.dashboard.widget.geomap.default_view': case 'web.dashboard.widget.geomap.severity_filter': $value_str = $this->getInput('value_str'); diff --git a/ui/app/controllers/CControllerTemplateDashboardEdit.php b/ui/app/controllers/CControllerTemplateDashboardEdit.php index b500e89857e..b27c999177d 100644 --- a/ui/app/controllers/CControllerTemplateDashboardEdit.php +++ b/ui/app/controllers/CControllerTemplateDashboardEdit.php @@ -91,9 +91,12 @@ class CControllerTemplateDashboardEdit extends CController { ]; } + $widget_known_types = array_keys(CWidgetConfig::getKnownWidgetTypes(CWidgetConfig::CONTEXT_DASHBOARD)); + $data = [ 'dashboard' => $dashboard, 'widget_defaults' => CWidgetConfig::getDefaults(CWidgetConfig::CONTEXT_TEMPLATE_DASHBOARD), + 'widget_last_type' => CProfile::get('web.dashboard.last_widget_type', $widget_known_types[0]), 'time_period' => getTimeSelectorPeriod([]), 'page' => CPagerHelper::loadPage('template.dashboard.list', null) ]; diff --git a/ui/app/controllers/CControllerWidgetActionLogView.php b/ui/app/controllers/CControllerWidgetActionLogView.php index 9bacab4bda0..b7c41d9ce87 100644 --- a/ui/app/controllers/CControllerWidgetActionLogView.php +++ b/ui/app/controllers/CControllerWidgetActionLogView.php @@ -27,12 +27,12 @@ class CControllerWidgetActionLogView extends CControllerDashboardWidgetView { $this->setType(WIDGET_ACTION_LOG); $this->setValidationRules([ 'name' => 'string', - 'fields' => 'json' + 'fields' => 'required|array' ]); } protected function doAction() { - $fields = $this->getForm()->getFieldsData(); + $fields = $this->getForm()->getFieldsValues(); list($sortfield, $sortorder) = self::getSorting($fields['sort_triggers']); $alerts = $this->getAlerts($sortfield, $sortorder, $fields['show_lines']); diff --git a/ui/app/controllers/CControllerWidgetClockView.php b/ui/app/controllers/CControllerWidgetClockView.php index c0beb326b65..96a070a932f 100644 --- a/ui/app/controllers/CControllerWidgetClockView.php +++ b/ui/app/controllers/CControllerWidgetClockView.php @@ -27,13 +27,13 @@ class CControllerWidgetClockView extends CControllerDashboardWidgetView { $this->setType(WIDGET_CLOCK); $this->setValidationRules([ 'name' => 'string', - 'fields' => 'json', + 'fields' => 'required|array', 'dynamic_hostid' => 'db hosts.hostid' ]); } protected function doAction() { - $fields = $this->getForm()->getFieldsData(); + $fields = $this->getForm()->getFieldsValues(); $config_defaults = [ 'name' => $this->getDefaultName(), 'type' => $fields['clock_type'], diff --git a/ui/app/controllers/CControllerWidgetDataOverView.php b/ui/app/controllers/CControllerWidgetDataOverView.php index a1b41c1e899..a95ec51f341 100644 --- a/ui/app/controllers/CControllerWidgetDataOverView.php +++ b/ui/app/controllers/CControllerWidgetDataOverView.php @@ -27,12 +27,12 @@ class CControllerWidgetDataOverView extends CControllerDashboardWidgetView { $this->setType(WIDGET_DATA_OVER); $this->setValidationRules([ 'name' => 'string', - 'fields' => 'json' + 'fields' => 'required|array' ]); } protected function doAction() { - $fields = $this->getForm()->getFieldsData(); + $fields = $this->getForm()->getFieldsValues(); $groupids = $fields['groupids'] ? getSubGroups($fields['groupids']) : null; $hostids = $fields['hostids'] ? $fields['hostids'] : null; diff --git a/ui/app/controllers/CControllerWidgetDiscoveryView.php b/ui/app/controllers/CControllerWidgetDiscoveryView.php index a0bcb00b567..c1145be45f2 100644 --- a/ui/app/controllers/CControllerWidgetDiscoveryView.php +++ b/ui/app/controllers/CControllerWidgetDiscoveryView.php @@ -29,7 +29,7 @@ class CControllerWidgetDiscoveryView extends CControllerDashboardWidgetView { $this->setType(WIDGET_DISCOVERY); $this->setValidationRules([ 'name' => 'string', - 'fields' => 'json' + 'fields' => 'required|array' ]); } diff --git a/ui/app/controllers/CControllerWidgetFavGraphsView.php b/ui/app/controllers/CControllerWidgetFavGraphsView.php index 7098c92f66a..324b5c55841 100644 --- a/ui/app/controllers/CControllerWidgetFavGraphsView.php +++ b/ui/app/controllers/CControllerWidgetFavGraphsView.php @@ -29,7 +29,7 @@ class CControllerWidgetFavGraphsView extends CControllerDashboardWidgetView { $this->setType(WIDGET_FAV_GRAPHS); $this->setValidationRules([ 'name' => 'string', - 'fields' => 'json' + 'fields' => 'required|array' ]); } diff --git a/ui/app/controllers/CControllerWidgetFavMapsView.php b/ui/app/controllers/CControllerWidgetFavMapsView.php index 7be5884b5fd..49a7d50a13c 100644 --- a/ui/app/controllers/CControllerWidgetFavMapsView.php +++ b/ui/app/controllers/CControllerWidgetFavMapsView.php @@ -29,7 +29,7 @@ class CControllerWidgetFavMapsView extends CControllerDashboardWidgetView { $this->setType(WIDGET_FAV_MAPS); $this->setValidationRules([ 'name' => 'string', - 'fields' => 'json' + 'fields' => 'required|array' ]); } diff --git a/ui/app/controllers/CControllerWidgetGeoMapView.php b/ui/app/controllers/CControllerWidgetGeoMapView.php index 1b0e39acb7b..1e3db5d2264 100644 --- a/ui/app/controllers/CControllerWidgetGeoMapView.php +++ b/ui/app/controllers/CControllerWidgetGeoMapView.php @@ -53,13 +53,13 @@ class CControllerWidgetGeoMapView extends CControllerDashboardWidgetView { 'initial_load' => 'in 0,1', 'widgetid' => 'db widget.widgetid', 'unique_id' => 'required|string', - 'fields' => 'json' + 'fields' => 'required|array' ]); } protected function doAction() { $this->widgetid = $this->getInput('widgetid', 0); - $this->fields = $this->getForm()->getFieldsData(); + $this->fields = $this->getForm()->getFieldsValues(); $data = [ 'name' => $this->getInput('name', $this->getDefaultName()), diff --git a/ui/app/controllers/CControllerWidgetGraphView.php b/ui/app/controllers/CControllerWidgetGraphView.php index 53ff658cf59..f1336ee566a 100644 --- a/ui/app/controllers/CControllerWidgetGraphView.php +++ b/ui/app/controllers/CControllerWidgetGraphView.php @@ -29,7 +29,7 @@ class CControllerWidgetGraphView extends CControllerDashboardWidgetView { 'name' => 'string', 'edit_mode' => 'in 0,1', 'dashboardid' => 'db dashboard.dashboardid', - 'fields' => 'json', + 'fields' => 'required|array', 'dynamic_hostid' => 'db hosts.hostid', 'content_width' => 'int32', 'content_height' => 'int32' @@ -37,7 +37,7 @@ class CControllerWidgetGraphView extends CControllerDashboardWidgetView { } protected function doAction() { - $fields = $this->getForm()->getFieldsData(); + $fields = $this->getForm()->getFieldsValues(); $edit_mode = (int) $this->getInput('edit_mode', 0); $width = (int) $this->getInput('content_width', 100); diff --git a/ui/app/controllers/CControllerWidgetHostAvailView.php b/ui/app/controllers/CControllerWidgetHostAvailView.php index 438e89ba243..9bc75a4101c 100644 --- a/ui/app/controllers/CControllerWidgetHostAvailView.php +++ b/ui/app/controllers/CControllerWidgetHostAvailView.php @@ -27,12 +27,12 @@ class CControllerWidgetHostAvailView extends CControllerDashboardWidgetView { $this->setType(WIDGET_HOST_AVAIL); $this->setValidationRules([ 'name' => 'string', - 'fields' => 'json' + 'fields' => 'required|array' ]); } protected function doAction() { - $fields = $this->getForm()->getFieldsData(); + $fields = $this->getForm()->getFieldsValues(); $interface_types = CItem::INTERFACE_TYPES_BY_PRIORITY; diff --git a/ui/app/controllers/CControllerWidgetItemView.php b/ui/app/controllers/CControllerWidgetItemView.php index 6af8576fd05..0f820ed34cc 100644 --- a/ui/app/controllers/CControllerWidgetItemView.php +++ b/ui/app/controllers/CControllerWidgetItemView.php @@ -31,7 +31,7 @@ class CControllerWidgetItemView extends CControllerDashboardWidgetView { $this->setType(WIDGET_ITEM); $this->setValidationRules([ 'name' => 'string', - 'fields' => 'json', + 'fields' => 'required|array', 'dynamic_hostid' => 'db hosts.hostid' ]); } @@ -41,7 +41,7 @@ class CControllerWidgetItemView extends CControllerDashboardWidgetView { $cells = []; $url = null; $error = ''; - $fields = $this->getForm()->getFieldsData(); + $fields = $this->getForm()->getFieldsValues(); $history_period = timeUnitToSeconds(CSettingsHelper::get(CSettingsHelper::HISTORY_PERIOD)); $description = ''; $value = null; diff --git a/ui/app/controllers/CControllerWidgetIterator.php b/ui/app/controllers/CControllerWidgetIterator.php index eb405f549eb..20840e6effc 100644 --- a/ui/app/controllers/CControllerWidgetIterator.php +++ b/ui/app/controllers/CControllerWidgetIterator.php @@ -65,7 +65,7 @@ abstract class CControllerWidgetIterator extends CControllerDashboardWidgetView * @return int Number of child widgets. */ protected function getIteratorPageSize() { - $fields_data = $this->getForm()->getFieldsData(); + $fields_data = $this->getForm()->getFieldsValues(); return min($fields_data['rows'] * $fields_data['columns'], floor(DASHBOARD_MAX_COLUMNS * DASHBOARD_WIDGET_MAX_ROWS / DASHBOARD_WIDGET_MIN_ROWS) diff --git a/ui/app/controllers/CControllerWidgetIteratorGraphPrototypeView.php b/ui/app/controllers/CControllerWidgetIteratorGraphPrototypeView.php index 367d8120a2a..63bedae0b62 100644 --- a/ui/app/controllers/CControllerWidgetIteratorGraphPrototypeView.php +++ b/ui/app/controllers/CControllerWidgetIteratorGraphPrototypeView.php @@ -27,14 +27,14 @@ class CControllerWidgetIteratorGraphPrototypeView extends CControllerWidgetItera $this->setType(WIDGET_GRAPH_PROTOTYPE); $this->setValidationRules([ 'name' => 'string', - 'fields' => 'json', + 'fields' => 'required|array', 'view_mode' => 'in '.implode(',', [ZBX_WIDGET_VIEW_MODE_NORMAL, ZBX_WIDGET_VIEW_MODE_HIDDEN_HEADER]), 'dynamic_hostid' => 'db hosts.hostid' ]); } protected function doAction() { - $fields = $this->getForm()->getFieldsData(); + $fields = $this->getForm()->getFieldsValues(); if ($fields['source_type'] == ZBX_WIDGET_FIELD_RESOURCE_GRAPH_PROTOTYPE) { $data = $this->doGraphPrototype($fields); diff --git a/ui/app/controllers/CControllerWidgetMapView.php b/ui/app/controllers/CControllerWidgetMapView.php index 52527d82db2..1af460f76b9 100644 --- a/ui/app/controllers/CControllerWidgetMapView.php +++ b/ui/app/controllers/CControllerWidgetMapView.php @@ -29,7 +29,7 @@ class CControllerWidgetMapView extends CControllerDashboardWidgetView { $this->setValidationRules([ 'name' => 'string', 'initial_load' => 'in 0,1', - 'fields' => 'json', + 'fields' => 'required|array', 'current_sysmapid' => 'db sysmaps.sysmapid', 'unique_id' => 'string', 'previous_maps' => 'array' @@ -37,7 +37,7 @@ class CControllerWidgetMapView extends CControllerDashboardWidgetView { } protected function doAction() { - $fields = $this->getForm()->getFieldsData(); + $fields = $this->getForm()->getFieldsValues(); $sysmap_data = null; $previous_map = null; $sysmapid = null; diff --git a/ui/app/controllers/CControllerWidgetNavTreeView.php b/ui/app/controllers/CControllerWidgetNavTreeView.php index adefe41c0e5..1aeacec3af2 100644 --- a/ui/app/controllers/CControllerWidgetNavTreeView.php +++ b/ui/app/controllers/CControllerWidgetNavTreeView.php @@ -33,7 +33,7 @@ class CControllerWidgetNavTreeView extends CControllerDashboardWidgetView { 'name' => 'string', 'widgetid' => 'db widget.widgetid', 'initial_load' => 'in 0,1', - 'fields' => 'json' + 'fields' => 'required|array' ]); } @@ -403,7 +403,7 @@ class CControllerWidgetNavTreeView extends CControllerDashboardWidgetView { } protected function doAction() { - $fields = $this->getForm()->getFieldsData(); + $fields = $this->getForm()->getFieldsValues(); $error = null; // Get list of sysmapids. diff --git a/ui/app/controllers/CControllerWidgetPlainTextView.php b/ui/app/controllers/CControllerWidgetPlainTextView.php index f88b732c7ae..5f7a3e2a91a 100644 --- a/ui/app/controllers/CControllerWidgetPlainTextView.php +++ b/ui/app/controllers/CControllerWidgetPlainTextView.php @@ -30,13 +30,13 @@ class CControllerWidgetPlainTextView extends CControllerDashboardWidgetView { $this->setType(WIDGET_PLAIN_TEXT); $this->setValidationRules([ 'name' => 'string', - 'fields' => 'json', + 'fields' => 'required|array', 'dynamic_hostid' => 'db hosts.hostid' ]); } protected function doAction() { - $fields = $this->getForm()->getFieldsData(); + $fields = $this->getForm()->getFieldsValues(); $error = null; $dynamic_widget_name = $this->getDefaultName(); diff --git a/ui/app/controllers/CControllerWidgetProblemHostsView.php b/ui/app/controllers/CControllerWidgetProblemHostsView.php index 10ffb4aa2e0..6b8971b56bb 100644 --- a/ui/app/controllers/CControllerWidgetProblemHostsView.php +++ b/ui/app/controllers/CControllerWidgetProblemHostsView.php @@ -29,12 +29,12 @@ class CControllerWidgetProblemHostsView extends CControllerDashboardWidgetView { $this->setType(WIDGET_PROBLEM_HOSTS); $this->setValidationRules([ 'name' => 'string', - 'fields' => 'json' + 'fields' => 'required|array' ]); } protected function doAction() { - $fields = $this->getForm()->getFieldsData(); + $fields = $this->getForm()->getFieldsValues(); $filter_groupids = $fields['groupids'] ? getSubGroups($fields['groupids']) : null; $filter_hostids = $fields['hostids'] ? $fields['hostids'] : null; diff --git a/ui/app/controllers/CControllerWidgetProblemsBySvView.php b/ui/app/controllers/CControllerWidgetProblemsBySvView.php index ae4deca918c..c83cf527eed 100644 --- a/ui/app/controllers/CControllerWidgetProblemsBySvView.php +++ b/ui/app/controllers/CControllerWidgetProblemsBySvView.php @@ -29,13 +29,13 @@ class CControllerWidgetProblemsBySvView extends CControllerDashboardWidgetView { $this->setType(WIDGET_PROBLEMS_BY_SV); $this->setValidationRules([ 'name' => 'string', - 'fields' => 'json', + 'fields' => 'required|array', 'initial_load' => 'in 0,1' ]); } protected function doAction() { - $fields = $this->getForm()->getFieldsData(); + $fields = $this->getForm()->getFieldsValues(); $filter = [ 'groupids' => getSubGroups($fields['groupids']), diff --git a/ui/app/controllers/CControllerWidgetProblemsView.php b/ui/app/controllers/CControllerWidgetProblemsView.php index 72599a2f9ef..f934eeae0fc 100644 --- a/ui/app/controllers/CControllerWidgetProblemsView.php +++ b/ui/app/controllers/CControllerWidgetProblemsView.php @@ -27,13 +27,13 @@ class CControllerWidgetProblemsView extends CControllerDashboardWidgetView { $this->setType(WIDGET_PROBLEMS); $this->setValidationRules([ 'name' => 'string', - 'fields' => 'json', + 'fields' => 'required|array', 'initial_load' => 'in 0,1' ]); } protected function doAction() { - $fields = $this->getForm()->getFieldsData(); + $fields = $this->getForm()->getFieldsValues(); $data = CScreenProblem::getData([ 'show' => $fields['show'], diff --git a/ui/app/controllers/CControllerWidgetSlaReportView.php b/ui/app/controllers/CControllerWidgetSlaReportView.php index ca1e627db9b..a7535de6838 100644 --- a/ui/app/controllers/CControllerWidgetSlaReportView.php +++ b/ui/app/controllers/CControllerWidgetSlaReportView.php @@ -27,7 +27,7 @@ class CControllerWidgetSlaReportView extends CControllerDashboardWidgetView { $this->setType(WIDGET_SLA_REPORT); $this->setValidationRules([ 'name' => 'string', - 'fields' => 'json' + 'fields' => 'required|array' ]); } @@ -35,7 +35,7 @@ class CControllerWidgetSlaReportView extends CControllerDashboardWidgetView { * @throws APIException */ protected function doAction(): void { - $fields = $this->getForm()->getFieldsData(); + $fields = $this->getForm()->getFieldsValues(); $data = [ 'name' => $this->getInput('name', $this->getDefaultName()), diff --git a/ui/app/controllers/CControllerWidgetSvgGraphView.php b/ui/app/controllers/CControllerWidgetSvgGraphView.php index 34b00e8a9a9..a12313c12cb 100644 --- a/ui/app/controllers/CControllerWidgetSvgGraphView.php +++ b/ui/app/controllers/CControllerWidgetSvgGraphView.php @@ -40,12 +40,12 @@ class CControllerWidgetSvgGraphView extends CControllerDashboardWidgetView { 'preview' => 'in 1', 'from' => 'string', 'to' => 'string', - 'fields' => 'json' + 'fields' => 'required|array' ]); } protected function doAction(): void { - $fields = $this->getForm()->getFieldsData(); + $fields = $this->getForm()->getFieldsValues(); $edit_mode = $this->getInput('edit_mode', 0); $width = (int) $this->getInput('content_width', self::GRAPH_WIDTH_MIN); $height = (int) $this->getInput('content_height', self::GRAPH_HEIGHT_MIN); @@ -102,19 +102,19 @@ class CControllerWidgetSvgGraphView extends CControllerDashboardWidgetView { 'time_to' => $time_to ], 'axes' => [ - 'show_left_y_axis' => $fields['lefty'] == SVG_GRAPH_AXIS_SHOW, + 'show_left_y_axis' => $fields['lefty'] == SVG_GRAPH_AXIS_ON, 'left_y_min' => $lefty_min, 'left_y_max' => $lefty_max, 'left_y_units' => $fields['lefty_units'] == SVG_GRAPH_AXIS_UNITS_STATIC ? $fields['lefty_static_units'] : null, - 'show_right_y_axis' => $fields['righty'] == SVG_GRAPH_AXIS_SHOW, + 'show_right_y_axis' => $fields['righty'] == SVG_GRAPH_AXIS_ON, 'right_y_min' => $righty_min, 'right_y_max' => $righty_max, 'right_y_units' => $fields['righty_units'] == SVG_GRAPH_AXIS_UNITS_STATIC ? $fields['righty_static_units'] : null, - 'show_x_axis' => $fields['axisx'] == SVG_GRAPH_AXIS_SHOW + 'show_x_axis' => $fields['axisx'] == SVG_GRAPH_AXIS_ON ], 'legend' => [ 'show_legend' => $fields['legend'] == SVG_GRAPH_LEGEND_ON, @@ -123,7 +123,7 @@ class CControllerWidgetSvgGraphView extends CControllerDashboardWidgetView { 'legend_statistic' => $fields['legend_statistic'] ], 'problems' => [ - 'show_problems' => $fields['show_problems'] == SVG_GRAPH_PROBLEMS_SHOW, + 'show_problems' => $fields['show_problems'] == SVG_GRAPH_PROBLEMS_ON, 'graph_item_problems' => $fields['graph_item_problems'] == SVG_GRAPH_SELECTED_ITEM_PROBLEMS, 'problemhosts' => $fields['problemhosts'], 'severities' => $fields['severities'], diff --git a/ui/app/controllers/CControllerWidgetSystemInfoView.php b/ui/app/controllers/CControllerWidgetSystemInfoView.php index 3a75b677ec8..038ed0527fb 100644 --- a/ui/app/controllers/CControllerWidgetSystemInfoView.php +++ b/ui/app/controllers/CControllerWidgetSystemInfoView.php @@ -29,12 +29,12 @@ class CControllerWidgetSystemInfoView extends CControllerDashboardWidgetView { $this->setType(WIDGET_SYSTEM_INFO); $this->setValidationRules([ 'name' => 'string', - 'fields' => 'json' + 'fields' => 'required|array' ]); } protected function doAction() { - $fields = $this->getForm()->getFieldsData(); + $fields = $this->getForm()->getFieldsValues(); $this->setResponse(new CControllerResponseData([ 'name' => $this->getInput('name', $this->getDefaultName()), diff --git a/ui/app/controllers/CControllerWidgetTopHostsView.php b/ui/app/controllers/CControllerWidgetTopHostsView.php index 9d4cd37c47e..e7f1444d53c 100644 --- a/ui/app/controllers/CControllerWidgetTopHostsView.php +++ b/ui/app/controllers/CControllerWidgetTopHostsView.php @@ -27,7 +27,7 @@ class CControllerWidgetTopHostsView extends CControllerDashboardWidgetView { $this->setType(WIDGET_TOP_HOSTS); $this->setValidationRules([ 'name' => 'string', - 'fields' => 'json' + 'fields' => 'required|array' ]); } @@ -39,7 +39,7 @@ class CControllerWidgetTopHostsView extends CControllerDashboardWidgetView { ] ]; - $data += self::getData($this->getForm()->getFieldsData()); + $data += self::getData($this->getForm()->getFieldsValues()); $this->setResponse(new CControllerResponseData($data)); } @@ -95,7 +95,7 @@ class CControllerWidgetTopHostsView extends CControllerDashboardWidgetView { } ); - if ($fields['order'] == CWidgetFormTopHosts::ORDER_TOPN) { + if ($fields['order'] == CWidgetFormTopHosts::ORDER_TOP_N) { if ($master_items_only_numeric_present) { arsort($master_item_values, SORT_NUMERIC); @@ -174,7 +174,7 @@ class CControllerWidgetTopHostsView extends CControllerDashboardWidgetView { } else { $numeric_only = self::isNumericOnlyColumn($column); - $column_items = !$calc_extremes || $column['min'] !== '' && $column['max'] !== '' + $column_items = !$calc_extremes || ($column['min'] !== '' && $column['max'] !== '') ? self::getItems($column['item'], $numeric_only, $groupids, array_keys($master_hostids)) : self::getItems($column['item'], $numeric_only, $groupids, $hostids); diff --git a/ui/app/controllers/CControllerWidgetTrigOverView.php b/ui/app/controllers/CControllerWidgetTrigOverView.php index 27bde6fdab2..98bd73d2780 100644 --- a/ui/app/controllers/CControllerWidgetTrigOverView.php +++ b/ui/app/controllers/CControllerWidgetTrigOverView.php @@ -27,13 +27,13 @@ class CControllerWidgetTrigOverView extends CControllerDashboardWidgetView { $this->setType(WIDGET_TRIG_OVER); $this->setValidationRules([ 'name' => 'string', - 'fields' => 'json', + 'fields' => 'required|array', 'initial_load' => 'in 0,1' ]); } protected function doAction() { - $fields = $this->getForm()->getFieldsData(); + $fields = $this->getForm()->getFieldsValues(); $data = [ 'name' => $this->getInput('name', $this->getDefaultName()), diff --git a/ui/app/controllers/CControllerWidgetUrlView.php b/ui/app/controllers/CControllerWidgetUrlView.php index 04f9c33dbb9..70ff0eed9ae 100644 --- a/ui/app/controllers/CControllerWidgetUrlView.php +++ b/ui/app/controllers/CControllerWidgetUrlView.php @@ -27,13 +27,13 @@ class CControllerWidgetUrlView extends CControllerDashboardWidgetView { $this->setType(WIDGET_URL); $this->setValidationRules([ 'name' => 'string', - 'fields' => 'json', + 'fields' => 'required|array', 'dynamic_hostid' => 'db hosts.hostid' ]); } protected function doAction() { - $fields = $this->getForm()->getFieldsData(); + $fields = $this->getForm()->getFieldsValues(); $error = null; $is_template_dashboard = ($this->getContext() === CWidgetConfig::CONTEXT_TEMPLATE_DASHBOARD); diff --git a/ui/app/controllers/CControllerWidgetWebView.php b/ui/app/controllers/CControllerWidgetWebView.php index c8eee3b5ff8..02a7c7103b3 100644 --- a/ui/app/controllers/CControllerWidgetWebView.php +++ b/ui/app/controllers/CControllerWidgetWebView.php @@ -27,12 +27,12 @@ class CControllerWidgetWebView extends CControllerDashboardWidgetView { $this->setType(WIDGET_WEB); $this->setValidationRules([ 'name' => 'string', - 'fields' => 'json' + 'fields' => 'required|array' ]); } protected function doAction() { - $fields = $this->getForm()->getFieldsData(); + $fields = $this->getForm()->getFieldsValues(); $filter_groupids = $fields['groupids'] ? getSubGroups($fields['groupids']) : null; $filter_hostids = $fields['hostids'] ? $fields['hostids'] : null; diff --git a/ui/app/partials/monitoring.host.filter.php b/ui/app/partials/monitoring.host.filter.php index 9395bcb62da..abf6c43f0bc 100644 --- a/ui/app/partials/monitoring.host.filter.php +++ b/ui/app/partials/monitoring.host.filter.php @@ -178,12 +178,12 @@ if (array_key_exists('render_html', $data)) { return; } -(new CScriptTemplate('filter-monitoring-hosts')) +(new CTemplateTag('filter-monitoring-hosts')) ->setAttribute('data-template', 'monitoring.host.filter') ->addItem($template) ->show(); -(new CScriptTemplate('filter-tag-row-tmpl')) +(new CTemplateTag('filter-tag-row-tmpl')) ->addItem( (new CRow([ (new CTextBox('tags[#{rowNum}][tag]', '#{tag}')) diff --git a/ui/app/partials/monitoring.latest.filter.php b/ui/app/partials/monitoring.latest.filter.php index b3d48aad273..d76afaa1ed0 100644 --- a/ui/app/partials/monitoring.latest.filter.php +++ b/ui/app/partials/monitoring.latest.filter.php @@ -219,12 +219,12 @@ if (array_key_exists('render_html', $data)) { return; } -(new CScriptTemplate('filter-monitoring-latest')) +(new CTemplateTag('filter-monitoring-latest')) ->setAttribute('data-template', 'monitoring.latest.filter') ->addItem($template) ->show(); -(new CScriptTemplate('filter-tag-row-tmpl')) +(new CTemplateTag('filter-tag-row-tmpl')) ->addItem( (new CRow([ (new CTextBox('tags[#{rowNum}][tag]', '#{tag}')) diff --git a/ui/app/partials/monitoring.problem.filter.php b/ui/app/partials/monitoring.problem.filter.php index fec77d958cb..4a4242b9567 100644 --- a/ui/app/partials/monitoring.problem.filter.php +++ b/ui/app/partials/monitoring.problem.filter.php @@ -266,7 +266,7 @@ $right_column = (new CFormList()) (new CDiv([ (new CLabel(_('Show timeline'), 'show_timeline_#{uniqid}'))->addClass(ZBX_STYLE_SECOND_COLUMN_LABEL), (new CCheckBox('show_timeline')) - ->setChecked($data['show_timeline'] == 1) + ->setChecked($data['show_timeline'] == ZBX_TIMELINE_ON) ->setEnabled($data['compact_view'] == 0) ->setUncheckedValue(0) ->setId('show_timeline_#{uniqid}') @@ -321,12 +321,12 @@ if (array_key_exists('render_html', $data)) { return; } -(new CScriptTemplate('filter-monitoring-problem')) +(new CTemplateTag('filter-monitoring-problem')) ->setAttribute('data-template', 'monitoring.problem.filter') ->addItem($template) ->show(); -(new CScriptTemplate('filter-inventory-row')) +(new CTemplateTag('filter-inventory-row')) ->addItem( (new CRow([ (new CSelect('inventory[#{rowNum}][field]')) @@ -344,7 +344,7 @@ if (array_key_exists('render_html', $data)) { ) ->show(); -(new CScriptTemplate('filter-tag-row-tmpl')) +(new CTemplateTag('filter-tag-row-tmpl')) ->addItem( (new CRow([ (new CTextBox('tags[#{rowNum}][tag]', '#{tag}')) diff --git a/ui/app/views/administration.mediatype.list.php b/ui/app/views/administration.mediatype.list.php index 6926fa1a02d..8897cb10c76 100644 --- a/ui/app/views/administration.mediatype.list.php +++ b/ui/app/views/administration.mediatype.list.php @@ -194,4 +194,6 @@ $mediaTypeForm->addItem([ ]); // append form to widget -$html_page->addItem($mediaTypeForm)->show(); +$html_page + ->addItem($mediaTypeForm) + ->show(); diff --git a/ui/app/views/configuration.dashboard.edit.php b/ui/app/views/configuration.dashboard.edit.php index b915f6b8ddb..ae91f55a2f2 100644 --- a/ui/app/views/configuration.dashboard.edit.php +++ b/ui/app/views/configuration.dashboard.edit.php @@ -113,6 +113,7 @@ $html_page view.init('.json_encode([ 'dashboard' => $data['dashboard'], 'widget_defaults' => $data['widget_defaults'], + 'widget_last_type' => $data['widget_last_type'], 'time_period' => $data['time_period'], 'page' => $data['page'] ]).'); diff --git a/ui/app/views/js/configuration.dashboard.edit.js.php b/ui/app/views/js/configuration.dashboard.edit.js.php index 6bfa2ab1a9c..0db369b0e6a 100644 --- a/ui/app/views/js/configuration.dashboard.edit.js.php +++ b/ui/app/views/js/configuration.dashboard.edit.js.php @@ -31,7 +31,7 @@ is_busy: false, is_busy_saving: false, - init({dashboard, widget_defaults, time_period, page}) { + init({dashboard, widget_defaults, widget_last_type, time_period, page}) { this.dashboard = dashboard; this.page = page; @@ -60,12 +60,13 @@ max_rows: , widget_min_rows: , widget_max_rows: , - widget_defaults: widget_defaults, + widget_defaults, + widget_last_type, is_editable: true, is_edit_mode: true, can_edit_dashboards: true, is_kiosk_mode: false, - time_period: time_period, + time_period, dynamic_hostid: null }); diff --git a/ui/app/views/js/monitoring.dashboard.view.js.php b/ui/app/views/js/monitoring.dashboard.view.js.php index e73582379b1..87fd2738376 100644 --- a/ui/app/views/js/monitoring.dashboard.view.js.php +++ b/ui/app/views/js/monitoring.dashboard.view.js.php @@ -33,7 +33,7 @@ is_busy: false, is_busy_saving: false, - init({dashboard, time_period, dynamic, has_time_selector, widget_defaults, web_layout_mode}) { + init({dashboard, time_period, dynamic, has_time_selector, widget_defaults, widget_last_type, web_layout_mode}) { this.dashboard = dashboard; this.time_period = time_period; this.dynamic = dynamic; @@ -73,13 +73,14 @@ max_rows: , widget_min_rows: , widget_max_rows: , - widget_defaults: widget_defaults, + widget_defaults, + widget_last_type, is_editable: dashboard.can_edit_dashboards && dashboard.editable && web_layout_mode != , is_edit_mode: dashboard.dashboardid === null, can_edit_dashboards: dashboard.can_edit_dashboards, is_kiosk_mode: web_layout_mode == , - time_period: time_period, + time_period, dynamic_hostid: dynamic.host ? dynamic.host.id : null }); diff --git a/ui/app/views/js/monitoring.dashboard.widget.edit.js.php b/ui/app/views/js/monitoring.dashboard.widget.edit.js.php deleted file mode 100644 index b0f46f671e7..00000000000 --- a/ui/app/views/js/monitoring.dashboard.widget.edit.js.php +++ /dev/null @@ -1,37 +0,0 @@ - - - -window.widget_form = new class { - init() { - document.getElementById('type').addEventListener('change', () => ZABBIX.Dashboard.reloadWidgetProperties()); - - document.getElementById('widget-dialogue-form').addEventListener('change', (e) => { - const is_trimmable = e.target.matches( - 'input[type="text"]:not([data-no-trim="1"]), textarea:not([data-no-trim="1"])' - ); - - if (is_trimmable) { - e.target.value = e.target.value.trim(); - } - }, {capture: true}); - } -}; diff --git a/ui/app/views/js/monitoring.widget.clock.edit.js.php b/ui/app/views/js/monitoring.widget.clock.edit.js.php new file mode 100755 index 00000000000..02368d89d46 --- /dev/null +++ b/ui/app/views/js/monitoring.widget.clock.edit.js.php @@ -0,0 +1,102 @@ + + + +window.widget_clock_form = new class { + + init() { + this.form = document.getElementById('widget-dialogue-form'); + this.time_type = document.getElementById('time_type'); + this.clock_type = document.getElementById('clock_type'); + + this.show_date = document.getElementById('show_1'); + this.show_time = document.getElementById('show_2'); + this.show_tzone = document.getElementById('show_3'); + + this.advanced_configuration = document.getElementById('adv_conf'); + + for (const colorpicker of this.form.querySelectorAll('. input')) { + $(colorpicker).colorpicker({ + appendTo: '.overlay-dialogue-body', + use_default: true, + onUpdate: window.setIndicatorColor + }); + } + + this.time_type.addEventListener('change', () => { + ZABBIX.Dashboard.reloadWidgetProperties(); + this.updateForm(); + }); + + for (const checkbox of this.clock_type.querySelectorAll('input')) { + checkbox.addEventListener('change', () => this.updateForm()); + } + + const show = [this.show_date, this.show_time, this.show_tzone]; + + for (const checkbox of show) { + checkbox.addEventListener('change', (e) => { + if (show.filter((checkbox) => checkbox.checked).length > 0) { + this.updateForm(); + } + else { + e.target.checked = true; + } + }); + } + + this.advanced_configuration.addEventListener('change', () => this.updateForm()); + + this.updateForm(); + } + + updateForm() { + const is_digital = this.clock_type.querySelector('input:checked').value == ; + + const show_date_row = is_digital && this.advanced_configuration.checked && this.show_date.checked; + const show_time_row = is_digital && this.advanced_configuration.checked && this.show_time.checked; + const show_tzone_row = is_digital && this.advanced_configuration.checked && this.show_tzone.checked; + + for (const element of this.form.querySelectorAll('.js-row-show, .js-row-adv-conf')) { + element.style.display = is_digital ? '' : 'none'; + } + + for (const element of this.form.querySelectorAll('.js-row-bg-color')) { + element.style.display = is_digital && this.advanced_configuration.checked ? '' : 'none'; + } + + for (const element of this.form.querySelectorAll('.fields-group-date')) { + element.style.display = show_date_row ? '' : 'none'; + } + + for (const element of this.form.querySelectorAll('.js-row-time')) { + element.style.display = show_time_row ? '' : 'none'; + } + + for (const element of this.form.querySelectorAll('.js-row-tzone')) { + element.style.display = show_tzone_row ? '' : 'none'; + } + + for (const element of this.form.querySelectorAll('.js-row-tzone-timezone, .js-row-tzone-format')) { + element.style.display = this.time_type.value != ? '' : 'none'; + } + } +}; diff --git a/ui/app/views/js/popup.massupdate.tmpl.js.php b/ui/app/views/js/popup.massupdate.tmpl.js.php index f4761332b6c..b792eb51230 100644 --- a/ui/app/views/js/popup.massupdate.tmpl.js.php +++ b/ui/app/views/js/popup.massupdate.tmpl.js.php @@ -24,7 +24,7 @@ * @var array $data */ ?> -addItem( +addItem( (new CRow([ (new CTextBox('valuemap_rename[#{rowNum}][from]', '', false, DB::getFieldLength('valuemap', 'name'))) ->addStyle('width: 100%;'), diff --git a/ui/app/views/js/widget.form.view.js.php b/ui/app/views/js/widget.form.view.js.php new file mode 100644 index 00000000000..d6caedade1b --- /dev/null +++ b/ui/app/views/js/widget.form.view.js.php @@ -0,0 +1,38 @@ + + + +window.widget_form = new class { + + init() { + document.getElementById('type').addEventListener('change', () => ZABBIX.Dashboard.reloadWidgetProperties()); + + document.getElementById('widget-dialogue-form').addEventListener('change', (e) => { + const is_trimmable = e.target.matches( + 'input[type="text"]:not([data-no-trim="1"]), textarea:not([data-no-trim="1"])' + ); + + if (is_trimmable) { + e.target.value = e.target.value.trim(); + } + }, {capture: true}); + } +}; diff --git a/ui/app/views/monitoring.dashboard.view.php b/ui/app/views/monitoring.dashboard.view.php index 838a4274b10..755baf71c82 100644 --- a/ui/app/views/monitoring.dashboard.view.php +++ b/ui/app/views/monitoring.dashboard.view.php @@ -260,6 +260,7 @@ $html_page view.init('.json_encode([ 'dashboard' => $data['dashboard'], 'widget_defaults' => $data['widget_defaults'], + 'widget_last_type' => $data['widget_last_type'], 'has_time_selector' => $data['has_time_selector'], 'time_period' => $data['time_period'], 'dynamic' => $data['dynamic'], diff --git a/ui/app/views/monitoring.dashboard.widget.edit.php b/ui/app/views/monitoring.dashboard.widget.edit.php deleted file mode 100644 index 1f0c5e66cbc..00000000000 --- a/ui/app/views/monitoring.dashboard.widget.edit.php +++ /dev/null @@ -1,84 +0,0 @@ -addClass('dashboard-widget-'.$data['dialogue']['type']); - -// Submit button is needed to enable submit event on Enter on inputs. -$form->addItem((new CInput('submit', 'dashboard_widget_config_submit'))->addStyle('display: none;')); - -$output = [ - 'header' => $data['unique_id'] !== null ? _s('Edit widget') : _s('Add widget'), - 'doc_url' => CDocHelper::getUrl(CDocHelper::MONITORING_DASHBOARD_WIDGET_EDIT), - 'body' => '', - 'buttons' => [ - [ - 'title' => $data['unique_id'] !== null ? _s('Apply') : _s('Add'), - 'class' => 'dialogue-widget-save', - 'keepOpen' => true, - 'isSubmit' => true, - 'action' => 'ZABBIX.Dashboard.applyWidgetProperties();' - ] - ], - 'data' => [ - 'original_properties' => [ - 'type' => $data['dialogue']['type'], - 'unique_id' => $data['unique_id'], - 'dashboard_page_unique_id' => $data['dashboard_page_unique_id'] - ] - ] -]; - -if (($messages = getMessages()) !== null) { - $output['body'] .= $messages->toString(); -} - -$output['body'] .= $form->toString(); - -if (array_key_exists('jq_templates', $widget_view)) { - foreach ($widget_view['jq_templates'] as $id => $jq_template) { - $output['body'] .= ''; - } -} - -$scripts = [ - $this->readJsFile('monitoring.dashboard.widget.edit.js.php'), - 'widget_form.init();' -]; - -if (array_key_exists('scripts', $widget_view)) { - $scripts = array_merge($scripts, $widget_view['scripts']); -} - -$output['body'] .= get_js(implode("\n", $scripts)); - -if ($data['user']['debug_mode'] == GROUP_DEBUG_MODE_ENABLED) { - CProfiler::getInstance()->stop(); - $output['debug'] = CProfiler::getInstance()->make()->toString(); -} - -echo json_encode($output); diff --git a/ui/app/views/monitoring.widget.actionlog.edit.php b/ui/app/views/monitoring.widget.actionlog.edit.php new file mode 100755 index 00000000000..8d31e76fb11 --- /dev/null +++ b/ui/app/views/monitoring.widget.actionlog.edit.php @@ -0,0 +1,36 @@ +addField( + new CWidgetFieldSelectView($data['fields']['sort_triggers']) + ) + ->addField( + new CWidgetFieldIntegerBoxView($data['fields']['show_lines']) + ) + ->show(); diff --git a/ui/app/views/monitoring.widget.clock.edit.php b/ui/app/views/monitoring.widget.clock.edit.php new file mode 100755 index 00000000000..61c0fba4512 --- /dev/null +++ b/ui/app/views/monitoring.widget.clock.edit.php @@ -0,0 +1,60 @@ +addField( + new CWidgetFieldSelectView($data['fields']['time_type']) + ) + ->addField(array_key_exists('itemid', $data['fields']) + ? new CWidgetFieldMultiSelectItemView($data['fields']['itemid'], $data['captions']['ms']['items']['itemid']) + : null + ) + ->addField( + new CWidgetFieldRadioButtonListView($data['fields']['clock_type']) + ) + ->addField( + new CWidgetFieldCheckBoxListView($data['fields']['show']), + 'js-row-show' + ) + ->addField( + new CWidgetFieldCheckBoxView($data['fields']['adv_conf']), + 'js-row-adv-conf' + ) + ->addField( + new CWidgetFieldColorView($data['fields']['bg_color']), + 'js-row-bg-color' + ) + ->addFieldGroup(_('Date'), [ + new CWidgetFieldColorView($data['fields']['tzone_color']), + new CWidgetFieldColorView($data['fields']['time_color']) + ], 'fields-group-date') + ->includeJsFile('js/monitoring.widget.clock.edit.js.php') + ->addJavaScript(' + widget_clock_form.init(); + ') + ->show(); diff --git a/ui/app/views/monitoring.widget.dataover.edit.php b/ui/app/views/monitoring.widget.dataover.edit.php new file mode 100755 index 00000000000..08e8611c74b --- /dev/null +++ b/ui/app/views/monitoring.widget.dataover.edit.php @@ -0,0 +1,30 @@ +show(); diff --git a/ui/app/views/monitoring.widget.discovery.edit.php b/ui/app/views/monitoring.widget.discovery.edit.php new file mode 100755 index 00000000000..08e8611c74b --- /dev/null +++ b/ui/app/views/monitoring.widget.discovery.edit.php @@ -0,0 +1,30 @@ +show(); diff --git a/ui/app/views/monitoring.widget.favgraphs.edit.php b/ui/app/views/monitoring.widget.favgraphs.edit.php new file mode 100755 index 00000000000..08e8611c74b --- /dev/null +++ b/ui/app/views/monitoring.widget.favgraphs.edit.php @@ -0,0 +1,30 @@ +show(); diff --git a/ui/app/views/monitoring.widget.favmaps.edit.php b/ui/app/views/monitoring.widget.favmaps.edit.php new file mode 100755 index 00000000000..08e8611c74b --- /dev/null +++ b/ui/app/views/monitoring.widget.favmaps.edit.php @@ -0,0 +1,30 @@ +show(); diff --git a/ui/app/views/monitoring.widget.geomap.edit.php b/ui/app/views/monitoring.widget.geomap.edit.php new file mode 100755 index 00000000000..08e8611c74b --- /dev/null +++ b/ui/app/views/monitoring.widget.geomap.edit.php @@ -0,0 +1,30 @@ +show(); diff --git a/ui/app/views/monitoring.widget.graph.edit.php b/ui/app/views/monitoring.widget.graph.edit.php new file mode 100755 index 00000000000..08e8611c74b --- /dev/null +++ b/ui/app/views/monitoring.widget.graph.edit.php @@ -0,0 +1,30 @@ +show(); diff --git a/ui/app/views/monitoring.widget.hostavail.edit.php b/ui/app/views/monitoring.widget.hostavail.edit.php new file mode 100755 index 00000000000..08e8611c74b --- /dev/null +++ b/ui/app/views/monitoring.widget.hostavail.edit.php @@ -0,0 +1,30 @@ +show(); diff --git a/ui/app/views/monitoring.widget.item.edit.php b/ui/app/views/monitoring.widget.item.edit.php new file mode 100755 index 00000000000..08e8611c74b --- /dev/null +++ b/ui/app/views/monitoring.widget.item.edit.php @@ -0,0 +1,30 @@ +show(); diff --git a/ui/app/views/monitoring.widget.map.edit.php b/ui/app/views/monitoring.widget.map.edit.php new file mode 100755 index 00000000000..08e8611c74b --- /dev/null +++ b/ui/app/views/monitoring.widget.map.edit.php @@ -0,0 +1,30 @@ +show(); diff --git a/ui/app/views/monitoring.widget.navtree.edit.php b/ui/app/views/monitoring.widget.navtree.edit.php new file mode 100755 index 00000000000..08e8611c74b --- /dev/null +++ b/ui/app/views/monitoring.widget.navtree.edit.php @@ -0,0 +1,30 @@ +show(); diff --git a/ui/app/views/monitoring.widget.plaintext.edit.php b/ui/app/views/monitoring.widget.plaintext.edit.php new file mode 100755 index 00000000000..08e8611c74b --- /dev/null +++ b/ui/app/views/monitoring.widget.plaintext.edit.php @@ -0,0 +1,30 @@ +show(); diff --git a/ui/app/views/monitoring.widget.problemhosts.edit.php b/ui/app/views/monitoring.widget.problemhosts.edit.php new file mode 100755 index 00000000000..08e8611c74b --- /dev/null +++ b/ui/app/views/monitoring.widget.problemhosts.edit.php @@ -0,0 +1,30 @@ +show(); diff --git a/ui/app/views/monitoring.widget.problems.edit.php b/ui/app/views/monitoring.widget.problems.edit.php new file mode 100755 index 00000000000..08e8611c74b --- /dev/null +++ b/ui/app/views/monitoring.widget.problems.edit.php @@ -0,0 +1,30 @@ +show(); diff --git a/ui/app/views/monitoring.widget.problemsbysv.edit.php b/ui/app/views/monitoring.widget.problemsbysv.edit.php new file mode 100755 index 00000000000..08e8611c74b --- /dev/null +++ b/ui/app/views/monitoring.widget.problemsbysv.edit.php @@ -0,0 +1,30 @@ +show(); diff --git a/ui/app/views/monitoring.widget.slareport.edit.php b/ui/app/views/monitoring.widget.slareport.edit.php new file mode 100755 index 00000000000..08e8611c74b --- /dev/null +++ b/ui/app/views/monitoring.widget.slareport.edit.php @@ -0,0 +1,30 @@ +show(); diff --git a/ui/app/views/monitoring.widget.svggraph.edit.php b/ui/app/views/monitoring.widget.svggraph.edit.php new file mode 100755 index 00000000000..08e8611c74b --- /dev/null +++ b/ui/app/views/monitoring.widget.svggraph.edit.php @@ -0,0 +1,30 @@ +show(); diff --git a/ui/app/views/monitoring.widget.systeminfo.edit.php b/ui/app/views/monitoring.widget.systeminfo.edit.php new file mode 100755 index 00000000000..08e8611c74b --- /dev/null +++ b/ui/app/views/monitoring.widget.systeminfo.edit.php @@ -0,0 +1,30 @@ +show(); diff --git a/ui/app/views/monitoring.widget.tophosts.edit.php b/ui/app/views/monitoring.widget.tophosts.edit.php new file mode 100755 index 00000000000..08e8611c74b --- /dev/null +++ b/ui/app/views/monitoring.widget.tophosts.edit.php @@ -0,0 +1,30 @@ +show(); diff --git a/ui/app/views/monitoring.widget.trigover.edit.php b/ui/app/views/monitoring.widget.trigover.edit.php new file mode 100755 index 00000000000..08e8611c74b --- /dev/null +++ b/ui/app/views/monitoring.widget.trigover.edit.php @@ -0,0 +1,30 @@ +show(); diff --git a/ui/app/views/monitoring.widget.url.edit.php b/ui/app/views/monitoring.widget.url.edit.php new file mode 100755 index 00000000000..08e8611c74b --- /dev/null +++ b/ui/app/views/monitoring.widget.url.edit.php @@ -0,0 +1,30 @@ +show(); diff --git a/ui/app/views/monitoring.widget.web.edit.php b/ui/app/views/monitoring.widget.web.edit.php new file mode 100755 index 00000000000..08e8611c74b --- /dev/null +++ b/ui/app/views/monitoring.widget.web.edit.php @@ -0,0 +1,30 @@ +show(); diff --git a/ui/app/views/popup.massupdate.service.php b/ui/app/views/popup.massupdate.service.php index 6d11c9f98e2..89a127af34d 100644 --- a/ui/app/views/popup.massupdate.service.php +++ b/ui/app/views/popup.massupdate.service.php @@ -45,7 +45,7 @@ $tags_form_grid = (new CFormGrid()) renderTagTable([['tag' => '', 'value' => '']]) ->setHeader([_('Name'), _('Value'), _('Action')]) ->setId('tags-table'), - (new CScriptTemplate('tag-row-tmpl')) + (new CTemplateTag('tag-row-tmpl')) ->addItem(renderTagTableRow('#{rowNum}', '', '', ZBX_TAG_MANUAL, ['add_post_js' => false])) ])) ->setId('tags-div') diff --git a/ui/app/views/popup.service.edit.php b/ui/app/views/popup.service.edit.php index 6508f581369..99ccee64d13 100644 --- a/ui/app/views/popup.service.edit.php +++ b/ui/app/views/popup.service.edit.php @@ -73,7 +73,7 @@ $service_tab = (new CFormGrid()) ->addClass('element-table-add') )) ), - (new CScriptTemplate('problem-tag-row-tmpl')) + (new CTemplateTag('problem-tag-row-tmpl')) ->addItem( (new CRow([ (new CTextBox('problem_tags[#{rowNum}][tag]', '#{tag}', false, @@ -252,7 +252,7 @@ $tags_tab = (new CFormGrid()) renderTagTable($data['form']['tags']) ->setId('tags-table') ->setHeader((new CRowHeader([_('Name'), _('Value'), _('Action')]))->addClass(ZBX_STYLE_GREY)), - (new CScriptTemplate('tag-row-tmpl')) + (new CTemplateTag('tag-row-tmpl')) ->addItem(renderTagTableRow('#{rowNum}', '', '', ZBX_TAG_MANUAL, ['add_post_js' => false])) ]) ) diff --git a/ui/app/views/popup.sla.edit.php b/ui/app/views/popup.sla.edit.php index 555cb46cd37..e7c08919817 100644 --- a/ui/app/views/popup.sla.edit.php +++ b/ui/app/views/popup.sla.edit.php @@ -136,7 +136,7 @@ $sla_tab = (new CFormGrid()) ->addClass('element-table-add') )) ), - (new CScriptTemplate('service-tag-row-tmpl')) + (new CTemplateTag('service-tag-row-tmpl')) ->addItem( (new CRow([ (new CTextBox('service_tags[#{rowNum}][tag]', '#{tag}', false, diff --git a/ui/app/views/popup.tophosts.column.edit.php b/ui/app/views/popup.tophosts.column.edit.php index 10739a1f874..6431a2955d9 100644 --- a/ui/app/views/popup.tophosts.column.edit.php +++ b/ui/app/views/popup.tophosts.column.edit.php @@ -230,7 +230,7 @@ $thresholds = (new CDiv( ->setWidth(ZBX_TEXTAREA_STANDARD_WIDTH); $thresholds->addItem( - (new CScriptTemplate('thresholds-row-tmpl')) + (new CTemplateTag('thresholds-row-tmpl')) ->addItem((new CRow([ (new CColor('thresholds[#{rowNum}][color]', '#{color}'))->appendColorPickerJs(false), (new CTextBox('thresholds[#{rowNum}][threshold]', '#{threshold}', false)) diff --git a/ui/assets/styles/blue-theme.css b/ui/assets/styles/blue-theme.css index 35202f37088..38ffc192676 100644 --- a/ui/assets/styles/blue-theme.css +++ b/ui/assets/styles/blue-theme.css @@ -1541,27 +1541,21 @@ footer { .wrapper.layout-kioskmode .dashboard-navigation { display: none; } -form.dashboard-widget-clock .fields-group-date, -form.dashboard-widget-clock .fields-group-time, -form.dashboard-widget-clock .fields-group-tzone { +form.dashboard-widget-clock .fields-group.fields-group-date, form.dashboard-widget-clock .fields-group.fields-group-time, form.dashboard-widget-clock .fields-group.fields-group-tzone { display: grid; grid-template-columns: 60px 120px repeat(2, minmax(60px, max-content) auto); align-items: center; column-gap: 10px; row-gap: 5px; } - form.dashboard-widget-clock .fields-group-date label, - form.dashboard-widget-clock .fields-group-time label, - form.dashboard-widget-clock .fields-group-tzone label { + form.dashboard-widget-clock .fields-group.fields-group-date label, form.dashboard-widget-clock .fields-group.fields-group-time label, form.dashboard-widget-clock .fields-group.fields-group-tzone label { text-align: right; } - form.dashboard-widget-clock .fields-group-date .field-size input, - form.dashboard-widget-clock .fields-group-time .field-size input, - form.dashboard-widget-clock .fields-group-tzone .field-size input { + form.dashboard-widget-clock .fields-group.fields-group-date .field-size input, form.dashboard-widget-clock .fields-group.fields-group-time .field-size input, form.dashboard-widget-clock .fields-group.fields-group-tzone .field-size input { margin-right: 5px; } -form.dashboard-widget-clock .fields-group-time .field-format { +form.dashboard-widget-clock .fields-group.fields-group-time .field-format { grid-column: 4 / -1; } -form.dashboard-widget-clock .fields-group-tzone .field-format { +form.dashboard-widget-clock .fields-group.fields-group-tzone .field-format { grid-column: 2 / -1; } -form.dashboard-widget-clock .fields-group-tzone .field-timezone { +form.dashboard-widget-clock .fields-group.fields-group-tzone .field-timezone { grid-column: 2 / -1; } div.dashboard-widget-clock.clock-digital { diff --git a/ui/assets/styles/dark-theme.css b/ui/assets/styles/dark-theme.css index 527f30f9607..8577fb973ff 100644 --- a/ui/assets/styles/dark-theme.css +++ b/ui/assets/styles/dark-theme.css @@ -1554,27 +1554,21 @@ footer { .wrapper.layout-kioskmode .dashboard-navigation { display: none; } -form.dashboard-widget-clock .fields-group-date, -form.dashboard-widget-clock .fields-group-time, -form.dashboard-widget-clock .fields-group-tzone { +form.dashboard-widget-clock .fields-group.fields-group-date, form.dashboard-widget-clock .fields-group.fields-group-time, form.dashboard-widget-clock .fields-group.fields-group-tzone { display: grid; grid-template-columns: 60px 120px repeat(2, minmax(60px, max-content) auto); align-items: center; column-gap: 10px; row-gap: 5px; } - form.dashboard-widget-clock .fields-group-date label, - form.dashboard-widget-clock .fields-group-time label, - form.dashboard-widget-clock .fields-group-tzone label { + form.dashboard-widget-clock .fields-group.fields-group-date label, form.dashboard-widget-clock .fields-group.fields-group-time label, form.dashboard-widget-clock .fields-group.fields-group-tzone label { text-align: right; } - form.dashboard-widget-clock .fields-group-date .field-size input, - form.dashboard-widget-clock .fields-group-time .field-size input, - form.dashboard-widget-clock .fields-group-tzone .field-size input { + form.dashboard-widget-clock .fields-group.fields-group-date .field-size input, form.dashboard-widget-clock .fields-group.fields-group-time .field-size input, form.dashboard-widget-clock .fields-group.fields-group-tzone .field-size input { margin-right: 5px; } -form.dashboard-widget-clock .fields-group-time .field-format { +form.dashboard-widget-clock .fields-group.fields-group-time .field-format { grid-column: 4 / -1; } -form.dashboard-widget-clock .fields-group-tzone .field-format { +form.dashboard-widget-clock .fields-group.fields-group-tzone .field-format { grid-column: 2 / -1; } -form.dashboard-widget-clock .fields-group-tzone .field-timezone { +form.dashboard-widget-clock .fields-group.fields-group-tzone .field-timezone { grid-column: 2 / -1; } div.dashboard-widget-clock.clock-digital { diff --git a/ui/assets/styles/hc-dark.css b/ui/assets/styles/hc-dark.css index 6178fe5765c..b7d7b4a5d4d 100644 --- a/ui/assets/styles/hc-dark.css +++ b/ui/assets/styles/hc-dark.css @@ -1541,27 +1541,21 @@ footer { .wrapper.layout-kioskmode .dashboard-navigation { display: none; } -form.dashboard-widget-clock .fields-group-date, -form.dashboard-widget-clock .fields-group-time, -form.dashboard-widget-clock .fields-group-tzone { +form.dashboard-widget-clock .fields-group.fields-group-date, form.dashboard-widget-clock .fields-group.fields-group-time, form.dashboard-widget-clock .fields-group.fields-group-tzone { display: grid; grid-template-columns: 60px 120px repeat(2, minmax(60px, max-content) auto); align-items: center; column-gap: 10px; row-gap: 5px; } - form.dashboard-widget-clock .fields-group-date label, - form.dashboard-widget-clock .fields-group-time label, - form.dashboard-widget-clock .fields-group-tzone label { + form.dashboard-widget-clock .fields-group.fields-group-date label, form.dashboard-widget-clock .fields-group.fields-group-time label, form.dashboard-widget-clock .fields-group.fields-group-tzone label { text-align: right; } - form.dashboard-widget-clock .fields-group-date .field-size input, - form.dashboard-widget-clock .fields-group-time .field-size input, - form.dashboard-widget-clock .fields-group-tzone .field-size input { + form.dashboard-widget-clock .fields-group.fields-group-date .field-size input, form.dashboard-widget-clock .fields-group.fields-group-time .field-size input, form.dashboard-widget-clock .fields-group.fields-group-tzone .field-size input { margin-right: 5px; } -form.dashboard-widget-clock .fields-group-time .field-format { +form.dashboard-widget-clock .fields-group.fields-group-time .field-format { grid-column: 4 / -1; } -form.dashboard-widget-clock .fields-group-tzone .field-format { +form.dashboard-widget-clock .fields-group.fields-group-tzone .field-format { grid-column: 2 / -1; } -form.dashboard-widget-clock .fields-group-tzone .field-timezone { +form.dashboard-widget-clock .fields-group.fields-group-tzone .field-timezone { grid-column: 2 / -1; } div.dashboard-widget-clock.clock-digital { diff --git a/ui/assets/styles/hc-light.css b/ui/assets/styles/hc-light.css index 1d009e8e328..7a0fba21820 100644 --- a/ui/assets/styles/hc-light.css +++ b/ui/assets/styles/hc-light.css @@ -1541,27 +1541,21 @@ footer { .wrapper.layout-kioskmode .dashboard-navigation { display: none; } -form.dashboard-widget-clock .fields-group-date, -form.dashboard-widget-clock .fields-group-time, -form.dashboard-widget-clock .fields-group-tzone { +form.dashboard-widget-clock .fields-group.fields-group-date, form.dashboard-widget-clock .fields-group.fields-group-time, form.dashboard-widget-clock .fields-group.fields-group-tzone { display: grid; grid-template-columns: 60px 120px repeat(2, minmax(60px, max-content) auto); align-items: center; column-gap: 10px; row-gap: 5px; } - form.dashboard-widget-clock .fields-group-date label, - form.dashboard-widget-clock .fields-group-time label, - form.dashboard-widget-clock .fields-group-tzone label { + form.dashboard-widget-clock .fields-group.fields-group-date label, form.dashboard-widget-clock .fields-group.fields-group-time label, form.dashboard-widget-clock .fields-group.fields-group-tzone label { text-align: right; } - form.dashboard-widget-clock .fields-group-date .field-size input, - form.dashboard-widget-clock .fields-group-time .field-size input, - form.dashboard-widget-clock .fields-group-tzone .field-size input { + form.dashboard-widget-clock .fields-group.fields-group-date .field-size input, form.dashboard-widget-clock .fields-group.fields-group-time .field-size input, form.dashboard-widget-clock .fields-group.fields-group-tzone .field-size input { margin-right: 5px; } -form.dashboard-widget-clock .fields-group-time .field-format { +form.dashboard-widget-clock .fields-group.fields-group-time .field-format { grid-column: 4 / -1; } -form.dashboard-widget-clock .fields-group-tzone .field-format { +form.dashboard-widget-clock .fields-group.fields-group-tzone .field-format { grid-column: 2 / -1; } -form.dashboard-widget-clock .fields-group-tzone .field-timezone { +form.dashboard-widget-clock .fields-group.fields-group-tzone .field-timezone { grid-column: 2 / -1; } div.dashboard-widget-clock.clock-digital { diff --git a/ui/include/classes/api/services/CItem.php b/ui/include/classes/api/services/CItem.php index 1978de8374e..d9f238af5e5 100644 --- a/ui/include/classes/api/services/CItem.php +++ b/ui/include/classes/api/services/CItem.php @@ -986,11 +986,11 @@ class CItem extends CItemGeneral { $conflictedLink = reset($conflictedLink); // which of updated items populates this link? - $beingSavedItemName = ''; + $being_saved_item_name = ''; foreach ($items as $item) { if ($item['inventory_link'] == $conflictedLink) { if (isset($item['name'])) { - $beingSavedItemName = $item['name']; + $being_saved_item_name = $item['name']; } else { $thisItem = API::Item()->get([ @@ -998,14 +998,14 @@ class CItem extends CItemGeneral { 'filter' => ['itemid' => $item['itemid']], 'nopermissions' => true ]); - $beingSavedItemName = $thisItem[0]['name']; + $being_saved_item_name = $thisItem[0]['name']; } break; } } // name of the original item that already populates the field - $originalItem = API::Item()->get([ + $original_item = API::Item()->get([ 'output' => ['name'], 'filter' => [ 'hostid' => $hostId, @@ -1013,13 +1013,13 @@ class CItem extends CItemGeneral { ], 'nopermissions' => true ]); - $originalItemName = $originalItem[0]['name']; + $originalItemName = $original_item[0]['name']; self::exception( ZBX_API_ERROR_PARAMETERS, _s( 'Two items ("%1$s" and "%2$s") cannot populate one host inventory field "%3$s", this would lead to a conflict.', - $beingSavedItemName, + $being_saved_item_name, $originalItemName, $possibleHostInventories[$conflictedLink]['title'] ) diff --git a/ui/include/classes/core/ZBase.php b/ui/include/classes/core/ZBase.php index 5e7cb93d259..506fa2b6d90 100644 --- a/ui/include/classes/core/ZBase.php +++ b/ui/include/classes/core/ZBase.php @@ -335,7 +335,7 @@ class ZBase { $this->rootDir.'/include/classes/html', $this->rootDir.'/include/classes/html/pageheader', $this->rootDir.'/include/classes/html/svg', - $this->rootDir.'/include/classes/html/widget', + $this->rootDir.'/include/classes/html/widgets', $this->rootDir.'/include/classes/html/interfaces', $this->rootDir.'/include/classes/parsers', $this->rootDir.'/include/classes/parsers/results', diff --git a/ui/include/classes/helpers/CDashboardHelper.php b/ui/include/classes/helpers/CDashboardHelper.php index 59969e79e51..b3e898ee1c7 100644 --- a/ui/include/classes/helpers/CDashboardHelper.php +++ b/ui/include/classes/helpers/CDashboardHelper.php @@ -100,9 +100,9 @@ class CDashboardHelper { $fields_orig = self::convertWidgetFields($widget['fields']); // Transforms corrupted data to default values. - $widget_form = CWidgetConfig::getForm($widget['type'], json_encode($fields_orig), $templateid); + $widget_form = CWidgetConfig::getForm($widget['type'], $fields_orig, $templateid); $widget_form->validate(); - $fields = $widget_form->getFieldsData(); + $fields = $widget_form->getFieldsValues(); if ($with_rf_rate) { $rf_rate = (int) CProfile::get('web.dashboard.widget.rf_rate', -1, $widgetid); @@ -446,7 +446,7 @@ class CDashboardHelper { break 2; } - $widget_fields = array_key_exists('fields', $widget) ? $widget['fields'] : '{}'; + $widget_fields = array_key_exists('fields', $widget) ? $widget['fields'] : []; $widget['form'] = CWidgetConfig::getForm($widget['type'], $widget_fields, $templateid); unset($widget['fields']); diff --git a/ui/include/classes/helpers/CSvgGraphHelper.php b/ui/include/classes/helpers/CSvgGraphHelper.php index 3949305983e..f69d55c7bcc 100644 --- a/ui/include/classes/helpers/CSvgGraphHelper.php +++ b/ui/include/classes/helpers/CSvgGraphHelper.php @@ -740,7 +740,7 @@ class CSvgGraphHelper { * Find problems at given time period that matches specified problem options. */ private static function getProblems(array $metrics, array $problem_options, array $time_period): array { - if ($problem_options['show_problems'] != SVG_GRAPH_PROBLEMS_SHOW) { + if ($problem_options['show_problems'] == SVG_GRAPH_PROBLEMS_OFF) { return []; } diff --git a/ui/include/classes/html/CColor.php b/ui/include/classes/html/CColor.php index 178454953a7..f991288ffe7 100644 --- a/ui/include/classes/html/CColor.php +++ b/ui/include/classes/html/CColor.php @@ -64,11 +64,9 @@ class CColor extends CDiv { /** * Enable default color button. - - * @return CColor */ - public function enableUseDefault(): self { - $this->use_default = true; + public function enableUseDefault($use_default = true): self { + $this->use_default = $use_default; return $this; } diff --git a/ui/include/classes/html/CLabel.php b/ui/include/classes/html/CLabel.php index 513dfe94eb0..ab41f1493fc 100644 --- a/ui/include/classes/html/CLabel.php +++ b/ui/include/classes/html/CLabel.php @@ -21,12 +21,18 @@ class CLabel extends CTag { - public function __construct($label, $for = null) { + public function __construct($label, $id = null) { parent::__construct('label', true, $label); - if ($for !== null) { - $this->setAttribute('for', zbx_formatDomId($for)); + $this->setFor($id); + } + + public function setFor($id): self { + if ($id !== null) { + $this->setAttribute('for', zbx_formatDomId($id)); } + + return $this; } /** diff --git a/ui/include/classes/html/CRadioButtonList.php b/ui/include/classes/html/CRadioButtonList.php index 8ff7c4c8138..69f195c1982 100644 --- a/ui/include/classes/html/CRadioButtonList.php +++ b/ui/include/classes/html/CRadioButtonList.php @@ -100,7 +100,7 @@ class CRadioButtonList extends CList { return $this; } - public function setModern($modern) { + public function setModern($modern = true) { $this->modern = $modern; return $this; diff --git a/ui/include/classes/html/CScriptTemplate.php b/ui/include/classes/html/CScriptTemplate.php deleted file mode 100644 index 5d3f4212036..00000000000 --- a/ui/include/classes/html/CScriptTemplate.php +++ /dev/null @@ -1,52 +0,0 @@ - HTML template. - * - * @param string $id Template id - */ - public function __construct($id) { - parent::__construct('script', true); - $this->setAttribute('type', 'text/x-jquery-tmpl'); - $this->setId($id); - } - - public function addItem($value) { - if (is_array($value)) { - array_map([$this, 'addItem'], $value); - } - else { - $this->items[] = $value; - } - - return $this; - } - - protected function bodyToString(): string { - return implode("\n", $this->items); - } -} diff --git a/ui/include/classes/html/CTemplateTag.php b/ui/include/classes/html/CTemplateTag.php new file mode 100644 index 00000000000..f9c28087223 --- /dev/null +++ b/ui/include/classes/html/CTemplateTag.php @@ -0,0 +1,32 @@ +setId($id); + $this->addItem($value); + } +} diff --git a/ui/include/classes/html/widgets/CWidgetFieldCheckBoxListView.php b/ui/include/classes/html/widgets/CWidgetFieldCheckBoxListView.php new file mode 100755 index 00000000000..ef6524d42ec --- /dev/null +++ b/ui/include/classes/html/widgets/CWidgetFieldCheckBoxListView.php @@ -0,0 +1,57 @@ +field = $field; + } + + public function getView(): CList { + $checkbox_list = (new CList())->addClass(ZBX_STYLE_LIST_CHECK_RADIO); + + foreach ($this->classes as $class) { + $checkbox_list->addClass($class); + } + + foreach ($this->field->getValues() as $key => $label) { + $checkbox_list->addItem( + (new CCheckBox($this->field->getName().'[]', $key)) + ->setLabel($label) + ->setId($this->field->getName().'_'.$key) + ->setChecked(in_array($key, $this->field->getValue())) + ->setEnabled(!$this->isDisabled()) + ); + } + + return $checkbox_list; + } + + public function addClass(?string $class): self { + if ($class !== null) { + $this->classes[] = $class; + } + + return $this; + } +} diff --git a/ui/include/classes/html/widgets/CWidgetFieldCheckBoxView.php b/ui/include/classes/html/widgets/CWidgetFieldCheckBoxView.php new file mode 100755 index 00000000000..66543cbbf4c --- /dev/null +++ b/ui/include/classes/html/widgets/CWidgetFieldCheckBoxView.php @@ -0,0 +1,38 @@ +field = $field; + } + + public function getView(): array { + return [ + (new CVar($this->field->getName(), '0'))->removeId(), + (new CCheckBox($this->field->getName())) + ->setChecked((bool) $this->field->getValue()) + ->setEnabled(!$this->isDisabled()) + ->setLabel($this->field->getCaption()) + ->onChange($this->field->getAction()) + ]; + } +} diff --git a/ui/include/classes/html/widgets/CWidgetFieldColorView.php b/ui/include/classes/html/widgets/CWidgetFieldColorView.php new file mode 100755 index 00000000000..b08c09c1eda --- /dev/null +++ b/ui/include/classes/html/widgets/CWidgetFieldColorView.php @@ -0,0 +1,33 @@ +field = $field; + } + + public function getView(): CColor { + return (new CColor($this->field->getName(), $this->field->getValue())) + ->appendColorPickerJs(false) + ->enableUseDefault(!$this->field->hasAllowInherited()); + } +} diff --git a/ui/include/classes/html/widgets/CWidgetFieldIntegerBoxView.php b/ui/include/classes/html/widgets/CWidgetFieldIntegerBoxView.php new file mode 100755 index 00000000000..fa46f3ee08d --- /dev/null +++ b/ui/include/classes/html/widgets/CWidgetFieldIntegerBoxView.php @@ -0,0 +1,35 @@ +field = $field; + } + + public function getView(): CNumericBox { + return (new CNumericBox($this->field->getName(), $this->field->getValue(), $this->field->getMaxLength(), false, + !$this->isNotEmpty() + )) + ->setWidth(ZBX_TEXTAREA_NUMERIC_STANDARD_WIDTH) + ->setAriaRequired($this->isRequired()); + } +} diff --git a/ui/include/classes/html/widgets/CWidgetFieldMultiSelectHostView.php b/ui/include/classes/html/widgets/CWidgetFieldMultiSelectHostView.php new file mode 100755 index 00000000000..d862d36f20c --- /dev/null +++ b/ui/include/classes/html/widgets/CWidgetFieldMultiSelectHostView.php @@ -0,0 +1,38 @@ +field = $field; + $this->data = $data; + } + + public function getView(): CMultiSelect { + return $this->getMultiselect('hosts', [ + 'srctbl' => 'hosts', + 'srcfld1' => 'hostid' + ] + $this->field->getFilterParameters(), + [ + 'hostgroups' => 'groupids_' + ]); + } +} diff --git a/ui/include/classes/html/widgets/CWidgetFieldMultiSelectItemView.php b/ui/include/classes/html/widgets/CWidgetFieldMultiSelectItemView.php new file mode 100755 index 00000000000..919f97353cb --- /dev/null +++ b/ui/include/classes/html/widgets/CWidgetFieldMultiSelectItemView.php @@ -0,0 +1,35 @@ +field = $field; + $this->data = $data; + } + + public function getView(): CMultiSelect { + return $this->getMultiselect('items', [ + 'srctbl' => 'items', + 'srcfld1' => 'itemid' + ] + $this->field->getFilterParameters()); + } +} diff --git a/ui/include/classes/html/widgets/CWidgetFieldMultiSelectView.php b/ui/include/classes/html/widgets/CWidgetFieldMultiSelectView.php new file mode 100755 index 00000000000..d1a837f8f64 --- /dev/null +++ b/ui/include/classes/html/widgets/CWidgetFieldMultiSelectView.php @@ -0,0 +1,65 @@ +setForId($this->getForId()) + : null; + } + + public function getJavaScript(): string { + return $this->multiselect->getPostJS(); + } + + protected function getMultiselect($object_name, $popup_parameters, $filter_preselect_fields = []): CMultiSelect { + $options = [ + 'name' => $this->getForId(), + 'object_name' => $object_name, + 'multiple' => $this->field->isMultiple(), + 'data' => $this->data, + 'popup' => [ + 'parameters' => [ + 'dstfrm' => $this->form_name, + 'dstfld1' => zbx_formatDomId($this->getForId()) + ] + $popup_parameters + ] + $filter_preselect_fields, + 'add_post_js' => false + ]; + + $this->multiselect = (new CMultiSelect($options)) + ->setWidth(ZBX_TEXTAREA_STANDARD_WIDTH) + ->setAriaRequired($this->isRequired()); + + return $this->multiselect; + } + + private function getForId(): string { + return $this->field->getName().($this->field->isMultiple() ? '[]' : '').'_ms'; + } +} diff --git a/ui/include/classes/html/widgets/CWidgetFieldRadioButtonListView.php b/ui/include/classes/html/widgets/CWidgetFieldRadioButtonListView.php new file mode 100755 index 00000000000..c9d580b51a3 --- /dev/null +++ b/ui/include/classes/html/widgets/CWidgetFieldRadioButtonListView.php @@ -0,0 +1,41 @@ +field = $field; + } + + public function getView(): CRadioButtonList { + $radio_button_list = (new CRadioButtonList($this->field->getName(), $this->field->getValue())) + ->setModern() + ->setAriaRequired($this->isRequired()); + + foreach ($this->field->getValues() as $key => $value) { + $radio_button_list + ->addValue($value, $key, null, $this->field->getAction()) + ->setEnabled(!$this->isDisabled()); + } + + return $radio_button_list; + } +} diff --git a/ui/include/classes/html/widgets/CWidgetFieldSelectView.php b/ui/include/classes/html/widgets/CWidgetFieldSelectView.php new file mode 100755 index 00000000000..eebb900efa5 --- /dev/null +++ b/ui/include/classes/html/widgets/CWidgetFieldSelectView.php @@ -0,0 +1,37 @@ +field = $field; + } + + public function getView(): CSelect { + return (new CSelect($this->field->getName())) + ->setId($this->field->getName()) + ->setFocusableElementId('label-'.$this->field->getName()) + ->setValue($this->field->getValue()) + ->addOptions(CSelect::createOptionsFromArray($this->field->getValues())) + ->setDisabled($this->isDisabled()) + ->setAriaRequired($this->isRequired()); + } +} diff --git a/ui/include/classes/html/widgets/CWidgetFieldView.php b/ui/include/classes/html/widgets/CWidgetFieldView.php new file mode 100755 index 00000000000..b32d382ccfb --- /dev/null +++ b/ui/include/classes/html/widgets/CWidgetFieldView.php @@ -0,0 +1,65 @@ +form_name = $form_name; + + return $this; + } + + public function getLabel(): ?CLabel { + $label = $this->field->getLabel(); + + return $label !== null ? new CLabel($label) : null; + } + + /** + * @return null|array|CTag + */ + public function getView() { + return null; + } + + public function getJavaScript(): string { + return ''; + } + + public function getTemplates(): array { + return []; + } + + public function isNotEmpty(): bool { + return ($this->field->getFlags() & CWidgetField::FLAG_NOT_EMPTY) !== 0; + } + + public function isRequired(): bool { + return ($this->field->getFlags() & CWidgetField::FLAG_LABEL_ASTERISK) !== 0; + } + + public function isDisabled(): bool { + return ($this->field->getFlags() & CWidgetField::FLAG_DISABLED) !== 0; + } +} diff --git a/ui/include/classes/html/widgets/CWidgetFormView.php b/ui/include/classes/html/widgets/CWidgetFormView.php new file mode 100755 index 00000000000..4bb6a5a14f4 --- /dev/null +++ b/ui/include/classes/html/widgets/CWidgetFormView.php @@ -0,0 +1,226 @@ +data = $data; + $this->name = $name; + + $this + ->makeFormGrid() + ->includeJsFile('js/widget.form.view.js.php') + ->addJavaScript('widget_form.init();'); + } + + public function addFieldGroup(?string $label, array $field_views, string $row_class = null): self { + $items = []; + + foreach ($field_views as $field_view) { + $items[] = $this->makeField($field_view); + } + + $this->form_grid->addItem([ + $label !== null + ? (new CLabel($label)) + ->addClass(CFormGrid::ZBX_STYLE_FIELDS_GROUP_LABEL) + ->addClass($row_class) + : null, + (new CDiv($items)) + ->addClass(CFormGrid::ZBX_STYLE_FIELDS_GROUP) + ->addClass($row_class) + ]); + + return $this; + } + + public function addField(?CWidgetFieldView $field_view, string $row_class = null, bool $show_label = true): self { + if ($field_view !== null) { + $this->addItem($this->makeField($field_view, $row_class, $show_label)); + } + + return $this; + } + + public function addItem($value): self { + $this->form_grid->addItem($value); + + return $this; + } + + public function addTemplate(?CTemplateTag $template): self { + if ($template !== null) { + $this->templates[] = $template; + } + + return $this; + } + + public function addJavaScript(string $javascript): self { + $this->javascript[] = $javascript; + + return $this; + } + + public function includeJsFile(string $file_path): self { + ob_start(); + + if ((include CView::getLastDirectory().'/'.$file_path) === false) { + ob_end_clean(); + + throw new RuntimeException(sprintf('Cannot read file: "%s".', $file_path)); + } + + $this->javascript[] = ob_get_clean(); + + return $this; + } + + /** + * @throws JsonException + */ + public function show(): void { + $output = [ + 'header' => $this->data['unique_id'] !== null ? _('Edit widget') : _('Add widget'), + 'body' => implode('', [ + (new CForm()) + ->cleanItems() + ->setId('widget-dialogue-form') + ->setName($this->name) + ->addClass(ZBX_STYLE_DASHBOARD_WIDGET_FORM) + ->addClass('dashboard-widget-'.$this->data['type']) + ->addItem($this->form_grid) + // Submit button is needed to enable submit event on Enter on inputs. + ->addItem((new CInput('submit', 'dashboard_widget_config_submit'))->addStyle('display: none;')), + implode('', $this->templates), + $this->javascript ? new CScriptTag($this->javascript) : '' + ]), + 'buttons' => [ + [ + 'title' => $this->data['unique_id'] !== null ? _('Apply') : _('Add'), + 'class' => 'dialogue-widget-save', + 'keepOpen' => true, + 'isSubmit' => true, + 'action' => 'ZABBIX.Dashboard.applyWidgetProperties();' + ] + ], + 'doc_url' => CDocHelper::getUrl(CDocHelper::MONITORING_DASHBOARD_WIDGET_EDIT), + 'data' => [ + 'original_properties' => [ + 'type' => $this->data['type'], + 'unique_id' => $this->data['unique_id'], + 'dashboard_page_unique_id' => $this->data['dashboard_page_unique_id'] + ] + ] + ]; + + if ($error = get_and_clear_messages()) { + $output['error'] = [ + 'messages' => array_column($error, 'message') + ]; + } + + if ($this->data['user']['debug_mode'] == GROUP_DEBUG_MODE_ENABLED) { + CProfiler::getInstance()->stop(); + $output['debug'] = CProfiler::getInstance()->make()->toString(); + } + + echo json_encode($output, JSON_THROW_ON_ERROR); + } + + private function makeFormGrid(): self { + $types_select = (new CSelect('type')) + ->setFocusableElementId('label-type') + ->setId('type') + ->setValue($this->data['type']) + ->setAttribute('autofocus', 'autofocus') + ->addOptions(CSelect::createOptionsFromArray($this->data['known_types'])); + + if ($this->data['deprecated_types']) { + $types_select->addOptionGroup( + (new CSelectOptionGroup(_('Deprecated'))) + ->addOptions(CSelect::createOptionsFromArray($this->data['deprecated_types'])) + ); + } + + $this->form_grid = (new CFormGrid()) + ->addItem([ + new CLabel(_('Type'), 'label-type'), + new CFormField(array_key_exists($this->data['type'], $this->data['deprecated_types']) + ? [$types_select, ' ', makeWarningIcon(_('Widget is deprecated.'))] + : $types_select + ) + ]) + ->addItem( + (new CFormField( + (new CCheckBox('show_header')) + ->setLabel(_('Show header')) + ->setLabelPosition(CCheckBox::LABEL_POSITION_LEFT) + ->setId('show_header') + ->setChecked($this->data['view_mode'] == ZBX_WIDGET_VIEW_MODE_NORMAL) + ))->addClass('form-field-show-header') + ) + ->addItem([ + new CLabel(_('Name'), 'name'), + new CFormField( + (new CTextBox('name', $this->data['name'])) + ->setAttribute('placeholder', _('default')) + ->setWidth(ZBX_TEXTAREA_STANDARD_WIDTH) + ) + ]); + + if (array_key_exists('rf_rate', $this->data['fields'])) { + $this->addField(new CWidgetFieldSelectView($this->data['fields']['rf_rate'])); + } + + return $this; + } + + private function makeField(CWidgetFieldView $field_view, string $row_class = null, bool $show_label = true): array { + $field_view->setFormName($this->name); + + $label = $show_label ? $field_view->getLabel() : null; + + $this->addJavaScript($field_view->getJavaScript()); + + foreach ($field_view->getTemplates() as $template) { + $this->addTemplate($template); + } + + return [ + $label !== null + ? $label + ->addClass($row_class) + ->setAsteriskMark($field_view->isRequired()) + : null, + (new CFormField($field_view->getView())) + ->addClass($row_class) + ]; + } +} diff --git a/ui/include/classes/mvc/CRouter.php b/ui/include/classes/mvc/CRouter.php index b5b098c40fb..b19be08c8cf 100644 --- a/ui/include/classes/mvc/CRouter.php +++ b/ui/include/classes/mvc/CRouter.php @@ -22,38 +22,28 @@ class CRouter { /** * Layout used for view rendering. - * - * @var string */ - private $layout = null; + private ?string $layout = null; /** * Controller class for action handling. - * - * @var string */ - private $controller = null; + private ?string $controller = null; /** * View used to generate HTML, CSV, JSON and other content. - * - * @var string */ - private $view = null; + private ?string $view = null; /** * Unique action (request) identifier. - * - * @var string */ - private $action = null; + private ?string $action = null; /** * Mapping between action and corresponding controller, layout and view. - * - * @var array */ - private $routes = [ + private array $routes = [ // action controller layout view 'action.operation.get' => ['CControllerActionOperationGet', 'layout.json', null], 'action.operation.validate' => ['CControllerActionOperationValidate', 'layout.json', null], @@ -86,7 +76,6 @@ class CRouter { 'dashboard.view' => ['CControllerDashboardView', 'layout.htmlpage', 'monitoring.dashboard.view'], 'dashboard.widget.check' => ['CControllerDashboardWidgetCheck', 'layout.json', null], 'dashboard.widget.configure' => ['CControllerDashboardWidgetConfigure', 'layout.json', null], - 'dashboard.widget.edit' => ['CControllerDashboardWidgetEdit', 'layout.json', 'monitoring.dashboard.widget.edit'], 'dashboard.widget.rfrate' => ['CControllerDashboardWidgetRfRate', 'layout.json', null], 'dashboard.widgets.sanitize' => ['CControllerDashboardWidgetsSanitize', 'layout.json', null], 'discovery.create' => ['CControllerDiscoveryCreate', null, null], @@ -315,6 +304,8 @@ class CRouter { 'userrole.list' => ['CControllerUserroleList', 'layout.htmlpage', 'administration.userrole.list'], 'userrole.update' => ['CControllerUserroleUpdate', null, null], 'web.view' => ['CControllerWebView', 'layout.htmlpage', 'monitoring.web.view'], + + 'widget.actionlog.view' => ['CControllerWidgetActionLogView', 'layout.widget', 'monitoring.widget.actionlog.view'], 'widget.clock.view' => ['CControllerWidgetClockView', 'layout.widget', 'monitoring.widget.clock.view'], 'widget.dataover.view' => ['CControllerWidgetDataOverView', 'layout.widget', 'monitoring.widget.dataover.view'], @@ -327,8 +318,6 @@ class CRouter { 'widget.hostavail.view' => ['CControllerWidgetHostAvailView', 'layout.widget', 'monitoring.widget.hostavail.view'], 'widget.item.view' => ['CControllerWidgetItemView', 'layout.widget', 'monitoring.widget.item.view'], 'widget.map.view' => ['CControllerWidgetMapView', 'layout.widget', 'monitoring.widget.map.view'], - 'widget.navtree.item.edit' => ['CControllerWidgetNavTreeItemEdit', 'layout.json', 'monitoring.widget.navtreeitem.edit'], - 'widget.navtree.item.update' => ['CControllerWidgetNavTreeItemUpdate', 'layout.json', null], 'widget.navtree.view' => ['CControllerWidgetNavTreeView', 'layout.widget', 'monitoring.widget.navtree.view'], 'widget.plaintext.view' => ['CControllerWidgetPlainTextView', 'layout.widget', 'monitoring.widget.plaintext.view'], 'widget.problemhosts.view' => ['CControllerWidgetProblemHostsView', 'layout.widget', 'monitoring.widget.problemhosts.view'], @@ -342,6 +331,34 @@ class CRouter { 'widget.url.view' => ['CControllerWidgetUrlView', 'layout.widget', 'monitoring.widget.url.view'], 'widget.web.view' => ['CControllerWidgetWebView', 'layout.widget', 'monitoring.widget.web.view'], + 'widget.actionlog.edit' => ['CControllerDashboardWidgetEdit', 'layout.json', 'monitoring.widget.actionlog.edit'], + 'widget.clock.edit' => ['CControllerDashboardWidgetEdit', 'layout.json', 'monitoring.widget.clock.edit'], + 'widget.dataover.edit' => ['CControllerDashboardWidgetEdit', 'layout.json', 'monitoring.widget.dataover.edit'], + 'widget.discovery.edit' => ['CControllerDashboardWidgetEdit', 'layout.json', 'monitoring.widget.discovery.edit'], + 'widget.favgraphs.edit' => ['CControllerDashboardWidgetEdit', 'layout.json', 'monitoring.widget.favgraphs.edit'], + 'widget.favmaps.edit' => ['CControllerDashboardWidgetEdit', 'layout.json', 'monitoring.widget.favmaps.edit'], + 'widget.geomap.edit' => ['CControllerDashboardWidgetEdit', 'layout.json', 'monitoring.widget.geomap.edit'], + 'widget.graph.edit' => ['CControllerDashboardWidgetEdit', 'layout.json', 'monitoring.widget.graph.edit'], + 'widget.graphprototype.edit' => ['CControllerDashboardWidgetEdit', 'layout.json', 'monitoring.widget.graphprototype.edit'], + 'widget.hostavail.edit' => ['CControllerDashboardWidgetEdit', 'layout.json', 'monitoring.widget.hostavail.edit'], + 'widget.item.edit' => ['CControllerDashboardWidgetEdit', 'layout.json', 'monitoring.widget.item.edit'], + 'widget.map.edit' => ['CControllerDashboardWidgetEdit', 'layout.json', 'monitoring.widget.map.edit'], + 'widget.navtree.edit' => ['CControllerDashboardWidgetEdit', 'layout.json', 'monitoring.widget.navtree.edit'], + 'widget.plaintext.edit' => ['CControllerDashboardWidgetEdit', 'layout.json', 'monitoring.widget.plaintext.edit'], + 'widget.problemhosts.edit' => ['CControllerDashboardWidgetEdit', 'layout.json', 'monitoring.widget.problemhosts.edit'], + 'widget.problems.edit' => ['CControllerDashboardWidgetEdit', 'layout.json', 'monitoring.widget.problems.edit'], + 'widget.problemsbysv.edit' => ['CControllerDashboardWidgetEdit', 'layout.json', 'monitoring.widget.problemsbysv.edit'], + 'widget.slareport.edit' => ['CControllerDashboardWidgetEdit', 'layout.json', 'monitoring.widget.slareport.edit'], + 'widget.svggraph.edit' => ['CControllerDashboardWidgetEdit', 'layout.json', 'monitoring.widget.svggraph.edit'], + 'widget.systeminfo.edit' => ['CControllerDashboardWidgetEdit', 'layout.json', 'monitoring.widget.systeminfo.edit'], + 'widget.tophosts.edit' => ['CControllerDashboardWidgetEdit', 'layout.json', 'monitoring.widget.tophosts.edit'], + 'widget.trigover.edit' => ['CControllerDashboardWidgetEdit', 'layout.json', 'monitoring.widget.trigover.edit'], + 'widget.url.edit' => ['CControllerDashboardWidgetEdit', 'layout.json', 'monitoring.widget.url.edit'], + 'widget.web.edit' => ['CControllerDashboardWidgetEdit', 'layout.json', 'monitoring.widget.web.edit'], + + 'widget.navtree.item.edit' => ['CControllerWidgetNavTreeItemEdit', 'layout.json', 'monitoring.widget.navtreeitem.edit'], + 'widget.navtree.item.update' => ['CControllerWidgetNavTreeItemUpdate', 'layout.json', null], + // legacy actions 'actionconf.php' => ['CLegacyAction', null, null], 'auditacts.php' => ['CLegacyAction', null, null], @@ -422,8 +439,6 @@ class CRouter { /** * Returns layout name. - * - * @return string|null */ public function getLayout(): ?string { return $this->layout; @@ -431,8 +446,6 @@ class CRouter { /** * Returns controller name. - * - * @return string|null */ public function getController(): ?string { return $this->controller; @@ -440,8 +453,6 @@ class CRouter { /** * Returns view name. - * - * @return string|null */ public function getView(): ?string { return $this->view; @@ -449,8 +460,6 @@ class CRouter { /** * Returns action name. - * - * @return string|null */ public function getAction(): ?string { return $this->action; diff --git a/ui/include/classes/mvc/CView.php b/ui/include/classes/mvc/CView.php index 92f0a769c16..4dd6cce5df2 100644 --- a/ui/include/classes/mvc/CView.php +++ b/ui/include/classes/mvc/CView.php @@ -68,6 +68,8 @@ class CView { */ private $directory; + private static $last_directory; + /** * List of JavaScript files for inclusion into a HTML page using '; + } + + foreach ($this->js_files as $path) { + if (parse_url($path, PHP_URL_QUERY) === null) { + $path .= '?'.(int) filemtime($path); + } + + echo ''."\n"; + } + + echo ''."\n"; + + return $this; + } +} diff --git a/ui/include/classes/html/pageheader/CPageHeader.php b/ui/include/classes/html/pageheader/CPageHeader.php deleted file mode 100644 index e272f094998..00000000000 --- a/ui/include/classes/html/pageheader/CPageHeader.php +++ /dev/null @@ -1,190 +0,0 @@ -title = CHtml::encode($title); - $this->lang = $lang; - $this->sid = substr(CSessionHelper::getId(), 16, 16); - } - - /** - * Add path to css file to render in page head. - * - * @param string $path - */ - public function addCssFile($path) { - $this->cssFiles[$path] = $path; - return $this; - } - - /** - * Add css style to render in page head. - * - * @param string $style - */ - public function addStyle($style) { - $this->styles[] = $style; - return $this; - } - - /** - * Add path to js file to render in page head. - * - * @param string $path - */ - public function addJsFile($path) { - $this->jsFiles[$path] = $path; - return $this; - } - - /** - * Add js script to render in page head after js file includes are rendered. - * - * @param string $js - */ - public function addJs($js) { - $this->js[] = $js; - return $this; - } - - /** - * Add js script to render in page head before js file includes are rendered. - * - * @param string $js - */ - public function addJsBeforeScripts($js) { - $this->jsBefore[] = $js; - return $this; - } - - /** - * Display page head html. - */ - public function display() { - echo ''."\n"; - echo ''."\n"; - echo << - - - - - $this->title - - - - - - - - - - - -HTML; - - foreach ($this->cssFiles as $path) { - if (parse_url($path, PHP_URL_QUERY) === null) { - $path .= '?'.(int) filemtime($path); - } - - echo ''."\n"; - } - - if ($this->styles) { - echo ''; - } - - if ($this->jsBefore) { - echo ''; - } - - foreach ($this->jsFiles as $path) { - if (parse_url($path, PHP_URL_QUERY) === null) { - $path .= '?'.(int) filemtime($path); - } - - echo ''."\n"; - } - - if ($this->js) { - echo ''; - } - - echo ''."\n"; - return $this; - } -} diff --git a/ui/include/classes/mvc/CControllerResponse.php b/ui/include/classes/mvc/CControllerResponse.php index ddb418c6327..90559fed541 100644 --- a/ui/include/classes/mvc/CControllerResponse.php +++ b/ui/include/classes/mvc/CControllerResponse.php @@ -39,7 +39,7 @@ abstract class CControllerResponse { CMessageHelper::restoreScheduleMessages(); } - (new CPageHeader(_('Loading...'), CWebUser::getLang()))->display(); + (new CHtmlPageHeader(_('Loading...'), CWebUser::getLang()))->show(); echo ''; diff --git a/ui/include/classes/mvc/CView.php b/ui/include/classes/mvc/CView.php index 4dd6cce5df2..c47fcdaf40d 100644 --- a/ui/include/classes/mvc/CView.php +++ b/ui/include/classes/mvc/CView.php @@ -1,4 +1,4 @@ -. */ - private $directory; - - private static $last_directory; + private array $js_files = []; /** - * List of JavaScript files for inclusion into a HTML page using