Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/zabbix/zabbix.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGregory Chalenko <gregory.chalenko@zabbix.com>2020-08-21 12:16:58 +0300
committerGregory Chalenko <gregory.chalenko@zabbix.com>2020-08-21 12:16:58 +0300
commit56d9e4451ef8b5f838c4ebebd6e44c88ba963fd4 (patch)
treea5d35a634c24993831c3967072fb8238df6f313a /ui/app/controllers
parent6169a6457821219e059a6752c7af7103f1d2475a (diff)
..F....... [ZBXNEXT-710] draft changes
Diffstat (limited to 'ui/app/controllers')
-rw-r--r--ui/app/controllers/CControllerHost.php2
-rw-r--r--ui/app/controllers/CControllerHostView.php65
-rw-r--r--ui/app/controllers/CControllerHostViewRefresh.php64
-rw-r--r--ui/app/controllers/CControllerPopupTabFilterEdit.php38
4 files changed, 87 insertions, 82 deletions
diff --git a/ui/app/controllers/CControllerHost.php b/ui/app/controllers/CControllerHost.php
index f135594b070..e6bf596ac97 100644
--- a/ui/app/controllers/CControllerHost.php
+++ b/ui/app/controllers/CControllerHost.php
@@ -26,7 +26,7 @@
abstract class CControllerHost extends CController {
// Filter idx prefix.
- const FILTER_IDX = 'web.monitoringhosts';
+ const FILTER_IDX = 'web.monitoring.hosts';
// Filter fields default values.
const FILTER_FIELDS_DEFAULT = [
diff --git a/ui/app/controllers/CControllerHostView.php b/ui/app/controllers/CControllerHostView.php
index 451c2943235..92a6463a3be 100644
--- a/ui/app/controllers/CControllerHostView.php
+++ b/ui/app/controllers/CControllerHostView.php
@@ -20,10 +20,71 @@
**/
-class CControllerHostView extends CControllerHostViewRefresh {
+class CControllerHostView extends CControllerHost {
+
+ protected function init(): void {
+ $this->disableSIDValidation();
+ }
+
+ protected function checkInput(): bool {
+ $fields = [
+ 'name' => 'string',
+ 'groupids' => 'array_id',
+ 'ip' => 'string',
+ 'dns' => 'string',
+ 'port' => 'string',
+ 'status' => 'in -1,'.HOST_STATUS_MONITORED.','.HOST_STATUS_NOT_MONITORED,
+ 'evaltype' => 'in '.TAG_EVAL_TYPE_AND_OR.','.TAG_EVAL_TYPE_OR,
+ 'tags' => 'array',
+ 'severities' => 'array',
+ 'show_suppressed' => 'in '.ZBX_PROBLEM_SUPPRESSED_FALSE.','.ZBX_PROBLEM_SUPPRESSED_TRUE,
+ 'maintenance_status' => 'in '.HOST_MAINTENANCE_STATUS_OFF.','.HOST_MAINTENANCE_STATUS_ON,
+ 'sort' => 'in name,status',
+ 'sortorder' => 'in '.ZBX_SORT_UP.','.ZBX_SORT_DOWN,
+ 'page' => 'ge 1',
+ 'filter_name' => 'string',
+ 'filter_custom_time' => 'in 1,0',
+ 'filter_show_counter' => 'in 1,0',
+ 'filter_counters' => 'in 1'
+ ];
+
+ $ret = $this->validateInput($fields);
+
+ // Validate tags filter.
+ if ($ret && $this->hasInput('tags')) {
+ foreach ($this->getInput('tags') as $filter_tag) {
+ if (count($filter_tag) != 3
+ || !array_key_exists('tag', $filter_tag) || !is_string($filter_tag['tag'])
+ || !array_key_exists('value', $filter_tag) || !is_string($filter_tag['value'])
+ || !array_key_exists('operator', $filter_tag) || !is_string($filter_tag['operator'])) {
+ $ret = false;
+ break;
+ }
+ }
+ }
+
+ // Validate severity checkbox filter.
+ if ($ret && $this->hasInput('severities')) {
+ foreach ($this->getInput('severities') as $severity) {
+ if (!in_array($severity, range(TRIGGER_SEVERITY_NOT_CLASSIFIED, TRIGGER_SEVERITY_COUNT - 1))) {
+ $ret = false;
+ break;
+ }
+ }
+ }
+
+ if (!$ret) {
+ $this->setResponse(new CControllerResponseFatal());
+ }
+
+ return $ret;
+ }
+
+ protected function checkPermissions(): bool {
+ return ($this->getUserType() >= USER_TYPE_ZABBIX_USER);
+ }
protected function doAction(): void {
- $data['filter_defaults'] = static::FILTER_FIELDS_DEFAULT;
$profile = (new CTabFilterProfile(static::FILTER_IDX, static::FILTER_FIELDS_DEFAULT))
->read()
->setInput($this->getInputAll());
diff --git a/ui/app/controllers/CControllerHostViewRefresh.php b/ui/app/controllers/CControllerHostViewRefresh.php
index eaa95aa9204..5a3352fb692 100644
--- a/ui/app/controllers/CControllerHostViewRefresh.php
+++ b/ui/app/controllers/CControllerHostViewRefresh.php
@@ -23,69 +23,7 @@
/**
* Controller for the "Host->Monitoring" asynchronous refresh page.
*/
-class CControllerHostViewRefresh extends CControllerHost {
-
- protected function init(): void {
- $this->disableSIDValidation();
- }
-
- protected function checkInput(): bool {
- $fields = [
- 'name' => 'string',
- 'groupids' => 'array_id',
- 'ip' => 'string',
- 'dns' => 'string',
- 'port' => 'string',
- 'status' => 'in -1,'.HOST_STATUS_MONITORED.','.HOST_STATUS_NOT_MONITORED,
- 'evaltype' => 'in '.TAG_EVAL_TYPE_AND_OR.','.TAG_EVAL_TYPE_OR,
- 'tags' => 'array',
- 'severities' => 'array',
- 'show_suppressed' => 'in '.ZBX_PROBLEM_SUPPRESSED_FALSE.','.ZBX_PROBLEM_SUPPRESSED_TRUE,
- 'maintenance_status' => 'in '.HOST_MAINTENANCE_STATUS_OFF.','.HOST_MAINTENANCE_STATUS_ON,
- 'sort' => 'in name,status',
- 'sortorder' => 'in '.ZBX_SORT_UP.','.ZBX_SORT_DOWN,
- 'page' => 'ge 1',
- 'filter_name' => 'string',
- 'filter_custom_time' => 'in 1,0',
- 'filter_show_counter' => 'in 1,0',
- 'filter_counters' => 'in 1'
- ];
-
- $ret = $this->validateInput($fields);
-
- // Validate tags filter.
- if ($ret && $this->hasInput('tags')) {
- foreach ($this->getInput('tags') as $filter_tag) {
- if (count($filter_tag) != 3
- || !array_key_exists('tag', $filter_tag) || !is_string($filter_tag['tag'])
- || !array_key_exists('value', $filter_tag) || !is_string($filter_tag['value'])
- || !array_key_exists('operator', $filter_tag) || !is_string($filter_tag['operator'])) {
- $ret = false;
- break;
- }
- }
- }
-
- // Validate severity checkbox filter.
- if ($ret && $this->hasInput('severities')) {
- foreach ($this->getInput('severities') as $severity) {
- if (!in_array($severity, range(TRIGGER_SEVERITY_NOT_CLASSIFIED, TRIGGER_SEVERITY_COUNT - 1))) {
- $ret = false;
- break;
- }
- }
- }
-
- if (!$ret) {
- $this->setResponse(new CControllerResponseFatal());
- }
-
- return $ret;
- }
-
- protected function checkPermissions(): bool {
- return ($this->getUserType() >= USER_TYPE_ZABBIX_USER);
- }
+class CControllerHostViewRefresh extends CControllerHostView {
protected function doAction(): void {
$filter = static::FILTER_FIELDS_DEFAULT;
diff --git a/ui/app/controllers/CControllerPopupTabFilterEdit.php b/ui/app/controllers/CControllerPopupTabFilterEdit.php
index 58d83cec133..8a05f81f6a8 100644
--- a/ui/app/controllers/CControllerPopupTabFilterEdit.php
+++ b/ui/app/controllers/CControllerPopupTabFilterEdit.php
@@ -35,7 +35,8 @@ class CControllerPopupTabFilterEdit extends CController {
'filter_custom_time' => 'in 0,1',
'tabfilter_from' => 'string',
'tabfilter_to' => 'string',
- 'support_custom_time' => 'in 0,1'
+ 'support_custom_time' => 'in 0,1',
+ 'create' => 'in 0,1'
];
$ret = $this->validateInput($rules) && $this->customValidation();
@@ -91,7 +92,8 @@ class CControllerPopupTabFilterEdit extends CController {
'filter_custom_time' => 0,
'tabfilter_from' => '',
'tabfilter_to' => '',
- 'support_custom_time' => 0
+ 'support_custom_time' => 0,
+ 'create' => 0
];
$this->getInputs($data, array_keys($data));
@@ -131,23 +133,27 @@ class CControllerPopupTabFilterEdit extends CController {
*/
public function updateTab(array $data) {
$filter = (new CTabFilterProfile($data['idx'], []))->read();
+ $properties = [
+ 'filter_name' => $data['filter_name'],
+ 'filter_show_counter' => (int) $data['filter_show_counter'],
+ 'filter_custom_time' => (int) $data['filter_custom_time'],
+ 'from' => $data['tabfilter_from'],
+ 'to' => $data['tabfilter_to']
+ ];
- if (array_key_exists($data['idx2'], $filter->tabfilters)) {
- $properties = [
- 'filter_name' => $data['filter_name'],
- 'filter_show_counter' => (int) $data['filter_show_counter'],
- 'filter_custom_time' => (int) $data['filter_custom_time'],
- 'from' => $data['tabfilter_from'],
- 'to' => $data['tabfilter_to']
- ];
-
- if (!$properties['filter_custom_time']) {
- unset($properties['from'], $properties['to']);
- }
+ if (!$properties['filter_custom_time']) {
+ unset($properties['from'], $properties['to']);
+ }
- $filter->tabfilters[$data['idx2']] = $properties + $filter->tabfilters[$data['idx2']];
- $filter->update();
+ if (array_key_exists($data['idx2'], $filter->tabfilters)) {
+ $properties = $properties + $filter->tabfilters[$data['idx2']];
}
+ else {
+ $data['idx2'] = count($filter->tabfilters);
+ }
+
+ $filter->tabfilters[$data['idx2']] = $properties;
+ $filter->update();
$this->setResponse((new CControllerResponseData(['main_block' => json_encode($data)]))->disableView());
}