diff options
author | Andrejs Verza <andrejs.verza@zabbix.com> | 2021-02-23 12:27:20 +0300 |
---|---|---|
committer | Andrejs Verza <andrejs.verza@zabbix.com> | 2021-02-23 12:27:20 +0300 |
commit | 2d51908146265602cb022c0f906a8ebac66a9db7 (patch) | |
tree | be0027c997fd4d10b3983a208a0c9493ab5bb31f /ui/app/controllers | |
parent | dcffae6ae69f05d140bff1f25b17a60c23a6141c (diff) |
..F....... [ZBXNEXT-6309] updated dashboard properties form, added Add button to the template dashboards
Diffstat (limited to 'ui/app/controllers')
-rw-r--r-- | ui/app/controllers/CControllerTemplateDashboardEdit.php | 4 | ||||
-rw-r--r-- | ui/app/controllers/CControllerTemplateDashboardUpdate.php | 33 |
2 files changed, 36 insertions, 1 deletions
diff --git a/ui/app/controllers/CControllerTemplateDashboardEdit.php b/ui/app/controllers/CControllerTemplateDashboardEdit.php index 3f05c083b82..94d8db856a2 100644 --- a/ui/app/controllers/CControllerTemplateDashboardEdit.php +++ b/ui/app/controllers/CControllerTemplateDashboardEdit.php @@ -51,7 +51,7 @@ class CControllerTemplateDashboardEdit extends CController { if ($this->hasInput('dashboardid')) { $dashboards = API::TemplateDashboard()->get([ - 'output' => ['dashboardid', 'name', 'templateid'], + 'output' => ['dashboardid', 'name', 'templateid', 'display_period', 'auto_start'], 'selectPages' => ['dashboard_pageid', 'name', 'display_period', 'widgets'], 'dashboardids' => [$this->getInput('dashboardid')], 'editable' => true @@ -78,6 +78,8 @@ class CControllerTemplateDashboardEdit extends CController { 'dashboardid' => null, 'templateid' => $this->getInput('templateid'), 'name' => _('New dashboard'), + 'display_period' => DB::getDefault('dashboard', 'display_period'), + 'auto_start' => DB::getDefault('dashboard', 'auto_start'), 'pages' => [ [ 'dashboard_pageid' => null, diff --git a/ui/app/controllers/CControllerTemplateDashboardUpdate.php b/ui/app/controllers/CControllerTemplateDashboardUpdate.php index b0409411f89..8498741042e 100644 --- a/ui/app/controllers/CControllerTemplateDashboardUpdate.php +++ b/ui/app/controllers/CControllerTemplateDashboardUpdate.php @@ -28,6 +28,8 @@ class CControllerTemplateDashboardUpdate extends CController { 'templateid' => 'required|db dashboard.templateid', 'dashboardid' => 'db dashboard.dashboardid', 'name' => 'required|db dashboard.name|not_empty', + 'display_period' => 'required|db dashboard.display_period|in '.implode(',', DASHBOARD_DISPLAY_PERIODS), + 'auto_start' => 'required|db dashboard.auto_start|in 0,1', 'widgets' => 'array' ]; @@ -78,6 +80,8 @@ class CControllerTemplateDashboardUpdate extends CController { $dashboard = [ 'name' => $this->getInput('name'), + 'display_period' => $this->getInput('display_period'), + 'auto_start' => $this->getInput('auto_start'), 'widgets' => [] ]; @@ -108,11 +112,40 @@ class CControllerTemplateDashboardUpdate extends CController { } if ($this->hasInput('dashboardid')) { + // TODO: fix temporary solution. + $ds = API::TemplateDashboard()->get([ + 'output' => ['dashboardid'], + 'selectPages' => ['dashboard_pageid'], + 'dashboardids' => [$dashboard['dashboardid']], +// 'preservekeys' => true + ]); + + $dashboard_pageid = $ds[0]['pages'][0]['dashboard_pageid']; + $dashboard['pages'] = [ + [ + 'dashboard_pageid' => $dashboard_pageid, + 'widgets' => $dashboard['widgets'], + ], + ]; + unset($dashboard['widgets']); + // ============================= + + $result = API::TemplateDashboard()->update($dashboard); $message = _('Dashboard updated'); $error_msg = _('Failed to update dashboard'); } else { + // TODO: fix temporary solution. + $dashboard['pages'] = [ + [ + 'widgets' => $dashboard['widgets'], + ], + ]; + unset($dashboard['widgets']); + // ============================= + + $result = API::TemplateDashboard()->create($dashboard); $message = _('Dashboard created'); $error_msg = _('Failed to create dashboard'); |