diff --git a/application/controllers/dashboard/Config.php b/application/controllers/dashboard/Config.php
index 2c0cf5fca..f6db9509f 100644
--- a/application/controllers/dashboard/Config.php
+++ b/application/controllers/dashboard/Config.php
@@ -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] = [];
diff --git a/application/libraries/dashboard/DashboardLib.php b/application/libraries/dashboard/DashboardLib.php
index d411bfcfc..7aab6b949 100644
--- a/application/libraries/dashboard/DashboardLib.php
+++ b/application/libraries/dashboard/DashboardLib.php
@@ -53,6 +53,7 @@ class DashboardLib
$userconfig = $this->getUserConfig($dashboard_id, $uid);
$mergedconfig = array_replace_recursive($defaultconfig, $userconfig);
+
return $mergedconfig;
}
@@ -106,7 +107,7 @@ class DashboardLib
$emptyoverride = new stdClass();
$emptyoverride->dashboard_id = $dashboard->dashboard_id;
$emptyoverride->uid = $uid;
- $emptyoverride->override = '{"widgets": {"' . self::USEROVERRIDE_SECTION . '": {}}}';
+ $emptyoverride->override = '{"' . self::USEROVERRIDE_SECTION . '": {"widgets":{}}}}';
return $emptyoverride;
}
@@ -126,7 +127,7 @@ class DashboardLib
$emptypreset->dashboard_id = $dashboard->dashboard_id;
$emptypreset->funktion_kurzbz = $funktion_kurzbz;
$section = ($funktion_kurzbz !== null) ? $funktion_kurzbz : self::SECTION_IF_FUNKTION_KURZBZ_IS_NULL;
- $emptypreset->preset = '{"widgets": {"' . $section . '": {}}}';
+ $emptypreset->preset = '{"' . $section . '": { "widgets" : {}},"custom": { "widgets" : {}}}';
return $emptypreset;
}
@@ -205,7 +206,7 @@ class DashboardLib
public function addWidgetToWidgets(&$widgets, $section, $widget, $widgetid)
{
$section = ($section !== null) ? $section : self::SECTION_IF_FUNKTION_KURZBZ_IS_NULL;
- if (!isset($widgets[$section]) || !is_array($widgets[$section]))
+ if (!isset($widgets[$section]) || !isset($widgets[$section]["widgets"]) || !is_array($widgets[$section]))
{
$widgets[$section] = array();
$widgets[$section]["widgets"] = array();
@@ -217,7 +218,7 @@ class DashboardLib
public function removeWidgetFromWidgets(&$widgets, $section, $widgetid)
{
$section = ($section !== null) ? $section : self::SECTION_IF_FUNKTION_KURZBZ_IS_NULL;
- if (isset($widgets[$section]["widgets"]) && isset($widgets[$section]["widgets"][$widgetid]))
+ if (isset($widgets[$section]) && isset($widgets[$section]["widgets"][$widgetid]))
{
unset($widgets[$section]["widgets"][$widgetid]);
if(empty($widgets[$section]["widgets"]) && $section !== self::USEROVERRIDE_SECTION) {
diff --git a/public/js/apps/DashboardAdmin.js b/public/js/apps/DashboardAdmin.js
index 1f3e831c8..05b438798 100644
--- a/public/js/apps/DashboardAdmin.js
+++ b/public/js/apps/DashboardAdmin.js
@@ -1,5 +1,6 @@
import {CoreNavigationCmpt} from '../components/navigation/Navigation.js';
import DashboardAdmin from '../components/Dashboard/Admin.js';
+import Phrases from "../plugin/Phrasen.js"
Vue.createApp({
name: 'DashboardAdminApp',
@@ -12,4 +13,4 @@ Vue.createApp({
},
mounted() {
}
-}).mount('#main');
\ No newline at end of file
+}).use(Phrases).mount('#main');
\ No newline at end of file
diff --git a/public/js/components/Dashboard/Admin/Presets.js b/public/js/components/Dashboard/Admin/Presets.js
index fa8f65970..8d6a07803 100644
--- a/public/js/components/Dashboard/Admin/Presets.js
+++ b/public/js/components/Dashboard/Admin/Presets.js
@@ -42,7 +42,7 @@ export default {
funktion_kurzbz: section_name,
widgets: [widget]
}).then(result => {
- let newId = Object.keys(result.data.retval.data.widgets[section_name]).pop();
+ let newId = Object.keys(result.data.retval.data[section_name].widgets).pop();
widget.id = newId;
widget.custom = 1;
this.sections.forEach(section => {
@@ -126,7 +126,6 @@ export default {
}}).then(res => {
if (this.tmpLoading !== funktionen.join('###'))
return; // NOTE(chris): prevent race condition
-
for (var section in res.data.retval) {
let widgets = [];
for (var wid in res.data.retval[section]) {
diff --git a/public/js/components/Dashboard/Dashboard.js b/public/js/components/Dashboard/Dashboard.js
index c682d78c6..005551570 100644
--- a/public/js/components/Dashboard/Dashboard.js
+++ b/public/js/components/Dashboard/Dashboard.js
@@ -70,7 +70,7 @@ export default {
funktion_kurzbz: section_name,
widgets: [widget]
}).then(result => {
- let newId = Object.keys(result.data.retval.data.widgets[section_name]).pop();
+ let newId = Object.keys(result.data.retval.data[section_name].widgets).pop();
widget.id = newId;
this.sections.forEach(section => {
if (section.name == section_name) {
@@ -143,7 +143,7 @@ export default {
}
},
created() {
-
+ this.$p.loadCategory('dashboard');
axios.get(this.apiurl + '/Widget/getWidgetsForDashboard', {
params: {
db: this.dashboard
@@ -159,23 +159,23 @@ export default {
axios.get(this.apiurl + '/Config', {params:{
db: this.dashboard
}}).then(res => {
- for (var name in res.data.retval.widgets) {
+ for (var name in res.data.retval) {
let widgets = [];
let remove = [];
- for (var wid in res.data.retval.widgets[name].widgets) {
- res.data.retval.widgets[name].widgets[wid].id = wid;
- if (res.data.retval.widgets[name].widgets[wid].custom || res.data.retval.widgets[name].widgets[wid].preset)
- widgets.push(res.data.retval.widgets[name].widgets[wid]);
+ for (var wid in res.data.retval[name].widgets) {
+ res.data.retval[name].widgets[wid].id = wid;
+ if (res.data.retval[name].widgets[wid].custom || res.data.retval[name].widgets[wid].preset)
+ widgets.push(res.data.retval[name].widgets[wid]);
else
remove.push(wid);
}
this.sections.push({
name: name,
- description:res.data.retval.widgets[name].description,
widgets: widgets
});
remove.forEach(wid => this.widgetRemove(name, wid));
}
+ this.sections = this.sections.sort((section1, section2) => section2.widgets.length - section1.widgets.length);
}).catch(err => console.error('ERROR:', err));
},
async beforeMount() {
@@ -190,7 +190,7 @@ export default {
{{ $p.t('global/personalGreeting', [ viewDataInternal?.name ]) }}
-