From 3830bdf5a07faea476d503711b8099eeb32e2c97 Mon Sep 17 00:00:00 2001 From: Tony Murray Date: Mon, 17 Dec 2018 09:35:09 -0600 Subject: [PATCH] Fix incorrectly marking the settings on aggregate graphs as invalid --- app/Http/Controllers/Widgets/GraphController.php | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/app/Http/Controllers/Widgets/GraphController.php b/app/Http/Controllers/Widgets/GraphController.php index 22e9d95caf..f6ed9f95a2 100644 --- a/app/Http/Controllers/Widgets/GraphController.php +++ b/app/Http/Controllers/Widgets/GraphController.php @@ -154,14 +154,12 @@ class GraphController extends WidgetController { $settings = $this->getSettings(); - // get type - $type = $this->getGraphType(); - // force settings if not initialized - if (is_null($type) || empty($settings['graph_' . $this->getGraphType(false)])) { + if ($this->hasInvalidSettings()) { return $this->getSettingsView($request); } + $type = $this->getGraphType(); $param = ''; if ($type == 'device') { @@ -224,6 +222,16 @@ class GraphController extends WidgetController return $type; } + private function hasInvalidSettings() + { + $raw_type = $this->getGraphType(false); + if ($raw_type == 'custom' || $this->getGraphType() != 'aggregate') { + return empty($this->getSettings()['graph_' . $raw_type]); + } + + return false; // non-custom aggregate types require no additional settings + } + public function getSettings() { if (is_null($this->settings)) {