diff options
author | Vladimirs Maksimovs <vladimirs.maksimovs@zabbix.com> | 2020-09-11 15:57:05 +0300 |
---|---|---|
committer | Vladimirs Maksimovs <vladimirs.maksimovs@zabbix.com> | 2020-09-11 15:58:46 +0300 |
commit | 774d3481b0e07e6558cbef5143d5653da6c7d372 (patch) | |
tree | 6c93b3e1ff7b8d2d4f0977f6b68dabb0ab23210a /ui/app | |
parent | bfa1ae96b53cdedbebd8f97a82cc957546586c26 (diff) |
A.F....... [ZBXNEXT-6141] implemented frontend changes for new trigger functions for long term analytics; added new property event_name to Trigger and Trigger prototype API objects
Diffstat (limited to 'ui/app')
-rw-r--r-- | ui/app/controllers/CControllerPopupTriggerExpr.php | 74 | ||||
-rw-r--r-- | ui/app/controllers/CControllerPopupTriggerWizard.php | 10 | ||||
-rw-r--r-- | ui/app/views/popup.triggerexpr.php | 7 | ||||
-rw-r--r-- | ui/app/views/popup.triggerwizard.php | 4 |
4 files changed, 94 insertions, 1 deletions
diff --git a/ui/app/controllers/CControllerPopupTriggerExpr.php b/ui/app/controllers/CControllerPopupTriggerExpr.php index 65de11fcc28..3eb84d98442 100644 --- a/ui/app/controllers/CControllerPopupTriggerExpr.php +++ b/ui/app/controllers/CControllerPopupTriggerExpr.php @@ -22,11 +22,13 @@ class CControllerPopupTriggerExpr extends CController { private $metrics = []; private $param1SecCount = []; + private $param1Period = []; private $param1Sec = []; private $param1Str = []; private $param2SecCount = []; private $param2SecMode = []; private $param3SecVal = []; + private $param3SecPeriod = []; private $param3SecPercent = []; private $paramSecIntCount = []; private $paramForecast = []; @@ -67,6 +69,19 @@ class CControllerPopupTriggerExpr extends CController { ] ]; + $this->param1Period = [ + 'last' => [ + 'C' => _('Last of').' (T)', + 'T' => T_ZBX_INT, + 'A' => true + ], + 'period_shift' => [ + 'C' => _('Period shift'), + 'T' => T_ZBX_INT, + 'A' => true + ] + ]; + $this->param1Sec = [ 'last' => [ 'C' => _('Last of').' (T)', @@ -134,6 +149,29 @@ class CControllerPopupTriggerExpr extends CController { ] ]; + $this->param3SecPeriod = [ + 'last' => [ + 'C' => _('Last of').' (T)', + 'T' => T_ZBX_INT, + 'A' => true + ], + 'v' => [ + 'C' => 'V', + 'T' => T_ZBX_STR, + 'A' => false + ], + 'o' => [ + 'C' => 'O', + 'T' => T_ZBX_STR, + 'A' => false + ], + 'period_shift' => [ + 'C' => _('Period shift'), + 'T' => T_ZBX_INT, + 'A' => true + ] + ]; + $this->param3SecPercent = [ 'last' => [ 'C' => _('Last of').' (T)', @@ -416,6 +454,42 @@ class CControllerPopupTriggerExpr extends CController { 'params' => $this->paramTimeleft, 'allowed_types' => $this->allowedTypesNumeric, 'operators' => ['=', '<>', '>', '<', '>=', '<='] + ], + 'trendavg' => [ + 'description' => _('trendavg() - Average value of a period T with exact period shift'), + 'params' => $this->param1Period, + 'allowed_types' => $this->allowedTypesNumeric, + 'operators' => ['=', '<>', '>', '<', '>=', '<='] + ], + 'trendcount' => [ + 'description' => _('trendcount() - Number of successfully retrieved values V (which fulfill operator O) for period T with exact period shift'), + 'params' => $this->param3SecPeriod, + 'allowed_types' => $this->allowedTypesAny, + 'operators' => ['=', '<>', '>', '<', '>=', '<='] + ], + 'trenddelta' => [ + 'description' => _('trenddelta() - Difference between MAX and MIN value of a period T with exact period shift'), + 'params' => $this->param1Period, + 'allowed_types' => $this->allowedTypesNumeric, + 'operators' => ['=', '<>', '>', '<', '>=', '<='] + ], + 'trendmax' => [ + 'description' => _('trendmax() - Maximum value for period T with exact period shift'), + 'params' => $this->param1Period, + 'allowed_types' => $this->allowedTypesNumeric, + 'operators' => ['=', '<>', '>', '<', '>=', '<='] + ], + 'trendmin' => [ + 'description' => _('trendmin() - Minimum value for period T with exact period shift'), + 'params' => $this->param1Period, + 'allowed_types' => $this->allowedTypesNumeric, + 'operators' => ['=', '<>', '>', '<', '>=', '<='] + ], + 'trendsum' => [ + 'description' => _('trendsum() - Sum of values of a period T with exact period shift'), + 'params' => $this->param1Period, + 'allowed_types' => $this->allowedTypesNumeric, + 'operators' => ['=', '<>', '>', '<', '>=', '<='] ] ]; diff --git a/ui/app/controllers/CControllerPopupTriggerWizard.php b/ui/app/controllers/CControllerPopupTriggerWizard.php index b9634a1a110..67473d03365 100644 --- a/ui/app/controllers/CControllerPopupTriggerWizard.php +++ b/ui/app/controllers/CControllerPopupTriggerWizard.php @@ -29,6 +29,7 @@ class CControllerPopupTriggerWizard extends CController { protected function checkInput() { $fields = [ 'description' => 'string', + 'event_name' => 'db triggers.event_name', 'itemid' => 'required|db items.itemid', 'triggerid' => 'db triggers.triggerid', 'type' => 'in 0,1', @@ -89,6 +90,7 @@ class CControllerPopupTriggerWizard extends CController { protected function doAction() { $page_options = [ 'description' => $this->getInput('description', ''), + 'event_name' => $this->getInput('event_name', ''), 'opdata' => $this->getInput('opdata', ''), 'itemid' => $this->getInput('itemid', 0), 'type' => $this->getInput('type', 0), @@ -145,6 +147,7 @@ class CControllerPopupTriggerWizard extends CController { if (array_key_exists('triggerid', $page_options)) { $triggerid = $page_options['triggerid']; $description = $page_options['description']; + $event_name = $page_options['event_name']; $opdata = $page_options['opdata']; $db_triggers = API::Trigger()->get([ @@ -156,6 +159,7 @@ class CControllerPopupTriggerWizard extends CController { $db_triggers = CMacrosResolverHelper::resolveTriggerExpressions($db_triggers); $description = $db_triggers[0]['description']; + $event_name = $db_triggers[0]['event_name']; $opdata = $db_triggers[0]['opdata']; $expression = $db_triggers[0]['expression']; } @@ -164,6 +168,7 @@ class CControllerPopupTriggerWizard extends CController { 'triggerid' => $triggerid, 'expression' => $expression, 'description' => $description, + 'event_name' => $event_name, 'opdata' => $opdata, 'type' => TRIGGER_MULT_EVENT_ENABLED, 'priority' => $page_options['priority'], @@ -176,6 +181,7 @@ class CControllerPopupTriggerWizard extends CController { $trigger = [ 'expression' => $expression, 'description' => $page_options['description'], + 'event_name' => $page_options['event_name'], 'opdata' => $page_options['opdata'], 'type' => TRIGGER_MULT_EVENT_ENABLED, 'priority' => $page_options['priority'], @@ -245,7 +251,8 @@ class CControllerPopupTriggerWizard extends CController { // Select requested trigger. if (array_key_exists('triggerid', $page_options)) { $result = DBselect( - 'SELECT t.expression,t.description,t.priority,t.comments,t.url,t.status,t.type,t.opdata'. + 'SELECT t.expression,t.description,t.priority,t.comments,t.url,t.status,t.type,t.opdata,'. + 't.event_name'. ' FROM triggers t'. ' WHERE t.triggerid='.zbx_dbstr($page_options['triggerid']). ' AND EXISTS ('. @@ -262,6 +269,7 @@ class CControllerPopupTriggerWizard extends CController { if ($row = DBfetch($result)) { $expression = CMacrosResolverHelper::resolveTriggerExpression($row['expression']); $page_options['description'] = $row['description']; + $page_options['event_name'] = $row['event_name']; $page_options['opdata'] = $row['opdata']; $page_options['type'] = $row['type']; $page_options['priority'] = $row['priority']; diff --git a/ui/app/views/popup.triggerexpr.php b/ui/app/views/popup.triggerexpr.php index 674e952eaae..91f445070ef 100644 --- a/ui/app/views/popup.triggerexpr.php +++ b/ui/app/views/popup.triggerexpr.php @@ -139,9 +139,16 @@ if (array_key_exists('params', $data['functions'][$data['selectedFunction']])) { elseif (in_array($param_name, ['shift'])) { $param_type_element = _('Time'); } + elseif (in_array($param_name, ['period_shift'])) { + $param_type_element = _('Period'); + } $param_field = (new CTextBox('params['.$param_name.']', $param_value))->setWidth(ZBX_TEXTAREA_SMALL_WIDTH); + if ($param_name === 'period_shift') { + $param_field->setAttribute('placeholder', 'now/h'); + } + $expression_form_list->addRow($label, [ $param_field, (new CDiv())->addClass(ZBX_STYLE_FORM_INPUT_MARGIN), diff --git a/ui/app/views/popup.triggerwizard.php b/ui/app/views/popup.triggerwizard.php index abcd67251db..762e076315e 100644 --- a/ui/app/views/popup.triggerwizard.php +++ b/ui/app/views/popup.triggerwizard.php @@ -83,6 +83,10 @@ $form->addItem( ->setAriaRequired() ->setWidth(ZBX_TEXTAREA_STANDARD_WIDTH) ) + ->addRow( + new CLabel(_('Event name'), 'event_name'), + (new CTextBox('event_name', $options['event_name']))->setWidth(ZBX_TEXTAREA_STANDARD_WIDTH) + ) ->addRow((new CLabel(_('Item'), 'itemid'))->setAsteriskMark(), $ms_itemid) ->addRow(_('Severity'), new CSeverity([ 'name' => 'priority', |