From d376cfdf5cc8df1b13b8913f59c7feead00919f8 Mon Sep 17 00:00:00 2001 From: Franco Fichtner Date: Sat, 2 Jul 2016 09:44:57 +0200 Subject: [PATCH] dashboard: default to empty, allow empy save; closes #1048 We do have a config.xml default, and we don't need a second default that pops up every time the old layout is cleared. On top of that the old layout could never be cleared again, so it only dealt with an empty config.xml scenario which we don't have. --- src/www/index.php | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) diff --git a/src/www/index.php b/src/www/index.php index 64d2f23a2..f708ee304 100644 --- a/src/www/index.php +++ b/src/www/index.php @@ -44,11 +44,8 @@ if (empty($config['widgets']) || !is_array($config['widgets'])) { if ($_SERVER['REQUEST_METHOD'] === 'GET') { $pconfig = $config['widgets']; - if (empty($pconfig['sequence'])) { - // set default dashboard view - $pconfig['sequence'] = 'system_information-container:col1:show,interface_list-container:col1:show,traffic_graphs-container:col1:show'; - } - // default 2 column grid layout + // set default dashboard view + $pconfig['sequence'] = !empty($pconfig['sequence']) ? $pconfig['sequence'] : ''; $pconfig['column_count'] = !empty($pconfig['column_count']) ? $pconfig['column_count'] : 2; // build list of widgets $widgetCollection = array(); @@ -77,12 +74,16 @@ if ($_SERVER['REQUEST_METHOD'] === 'GET') { } elseif ($_SERVER['REQUEST_METHOD'] === 'POST') { if (!empty($_POST['sequence'])) { $config['widgets']['sequence'] = $_POST['sequence']; - if (!empty($_POST['column_count'])) { - $config['widgets']['column_count'] = $_POST['column_count']; - } - write_config(gettext("Widget configuration has been changed.")); + } else { + unset($config['widgets']['sequence']); } - header("Location: index.php"); + if (!empty($_POST['column_count'])) { + $config['widgets']['column_count'] = $_POST['column_count']; + } else { + unset($config['widgets']['column_count']); + } + write_config(gettext('Widget configuration has been changed.')); + header('Location: index.php'); exit; }