refactor(Dashboard Database data structure): changes how the data for the dashboard is structured in the database, instead of having a global widgets property, each section has its own widgets property where additional properties like description can be stored

This commit is contained in:
SimonGschnell
2025-04-22 09:52:07 +02:00
parent 19f169aca2
commit 8c00158d04
7 changed files with 28 additions and 27 deletions
+6 -6
View File
@@ -65,7 +65,7 @@ class Config extends Auth_Controller
$preset_decoded = json_decode($preset->preset, true);
$this->DashboardLib->addWidgetsToWidgets($preset_decoded['widgets'], $dashboard_kurzbz, $funktion_kurzbz, $input->widgets);
$this->DashboardLib->addWidgetsToWidgets($preset_decoded, $dashboard_kurzbz, $funktion_kurzbz, $input->widgets);
$preset->preset = json_encode($preset_decoded);
@@ -92,7 +92,7 @@ class Config extends Auth_Controller
}
$preset_decoded = json_decode($preset->preset, true);
if (!$this->DashboardLib->removeWidgetFromWidgets($preset_decoded['widgets'], $funktion_kurzbz, $widgetid))
if (!$this->DashboardLib->removeWidgetFromWidgets($preset_decoded, $funktion_kurzbz, $widgetid))
{
http_response_code(404);
$this->terminateWithJsonError('widgetid ' . $widgetid . ' not found');
@@ -119,7 +119,7 @@ class Config extends Auth_Controller
$override_decoded = json_decode($override->override, true);
$this->DashboardLib->addWidgetsToWidgets($override_decoded['widgets'], $dashboard_kurzbz, $funktion_kurzbz, $input->widgets);
$this->DashboardLib->addWidgetsToWidgets($override_decoded, $dashboard_kurzbz, $funktion_kurzbz, $input->widgets);
$override->override = json_encode($override_decoded);
@@ -148,7 +148,7 @@ class Config extends Auth_Controller
$override_decoded = json_decode($override->override, true);
if (!$this->DashboardLib->removeWidgetFromWidgets($override_decoded['widgets'], $funktion_kurzbz, $widgetid))
if (!$this->DashboardLib->removeWidgetFromWidgets($override_decoded, $funktion_kurzbz, $widgetid))
{
http_response_code(404);
$this->terminateWithJsonError('widgetid ' . $widgetid . ' not found');
@@ -202,10 +202,10 @@ class Config extends Auth_Controller
if ($conf)
{
$preset = json_decode($conf->preset, true);
if (!isset($preset['widgets']) || !isset($preset['widgets'][$funktion]))
if (!isset($preset[$funktion]) || !isset($preset[$funktion]['widgets']))
$result[$funktion] = [];
else
$result[$funktion] = $preset['widgets'][$funktion];
$result[$funktion] = $preset[$funktion]['widgets'];
}
else
$result[$funktion] = [];