From d37fac0ff74b91c9351818c07694c6b7e5af99bd Mon Sep 17 00:00:00 2001 From: chfhtw Date: Wed, 25 Mar 2026 16:12:17 +0100 Subject: [PATCH] cleanup api calls to dashboard board --- .../api/frontend/v1/dashboard/Board.php | 17 ++++++++++--- public/js/components/Dashboard/Admin.js | 25 +++++-------------- 2 files changed, 20 insertions(+), 22 deletions(-) diff --git a/application/controllers/api/frontend/v1/dashboard/Board.php b/application/controllers/api/frontend/v1/dashboard/Board.php index c50fec128..2c8c72107 100644 --- a/application/controllers/api/frontend/v1/dashboard/Board.php +++ b/application/controllers/api/frontend/v1/dashboard/Board.php @@ -40,11 +40,22 @@ class Board extends FHCAPI_Controller public function list() { + $this->DashboardModel->addSelect('dashboard_id'); + $this->DashboardModel->addSelect('dashboard_kurzbz'); + $this->DashboardModel->addSelect('tbl_dashboard.beschreibung'); + $this->DashboardModel->addSelect("( + SELECT json_agg(w.*) + FROM dashboard.tbl_widget w + JOIN dashboard.tbl_dashboard_widget dw + USING(widget_id) + WHERE dw.dashboard_id=tbl_dashboard.dashboard_id + ) AS \"widgetSetup\""); + $result = $this->DashboardModel->load(); $data = $this->getDataOrTerminateWithError($result); - $this->terminateWithSuccess($result); + $this->terminateWithSuccess($data); } public function create() @@ -82,7 +93,7 @@ class Board extends FHCAPI_Controller $data = $this->getDataOrTerminateWithError($result); - $this->terminateWithSuccess($result); + $this->terminateWithSuccess($data); } public function delete() @@ -116,6 +127,6 @@ class Board extends FHCAPI_Controller $data = $this->getDataOrTerminateWithError($result); - $this->terminateWithSuccess($result); + $this->terminateWithSuccess($data); } } diff --git a/public/js/components/Dashboard/Admin.js b/public/js/components/Dashboard/Admin.js index ff117a956..5222b9673 100644 --- a/public/js/components/Dashboard/Admin.js +++ b/public/js/components/Dashboard/Admin.js @@ -4,7 +4,6 @@ import DashboardAdminWidgets from "./Admin/Widgets.js"; import DashboardAdminPresets from "./Admin/Presets.js"; import ApiDashboardBoard from "../../api/factory/dashboard/board.js"; -import ApiDashboardWidget from "../../api/factory/dashboard/widget.js"; export default { name: 'DashboardAdmin', @@ -16,7 +15,7 @@ export default { provide() { return { adminMode: true, - widgetsSetup: Vue.computed(() => this.dashboards[this.current] ? this.dashboards[this.current].widgetSetup : null) + widgetsSetup: Vue.computed(() => this.dashboard ? this.dashboard.widgetSetup : null) }; }, data() { @@ -59,7 +58,7 @@ export default { dashboardUpdate(dashboard) { return this.$api .call(ApiDashboardBoard.update(dashboard)) - .then(response =>{ + .then(response => { this.$fhcAlert.alertSuccess(this.$p.t('ui', 'successSave')); @@ -74,34 +73,22 @@ export default { .call(ApiDashboardBoard.delete(dashboard_id)) .then(response => { this.$fhcAlert.alertSuccess(this.$p.t('ui', 'successDelete')); - - }) - .catch(this.$fhcAlert.handleSystemError) - .finally(() => { this.current = -1; this.dashboards = this.dashboards.filter(el => el.dashboard_id != dashboard_id); - }); + }) + .catch(this.$fhcAlert.handleSystemError); }, assignWidgets(widgets) { this.widgets = widgets; - /*while (this.widgets.length) - this.widgets.pop(); - for (var i in widgets) - this.widgets.push(widgets[i]);*/ } }, created() { this.$api .call(ApiDashboardBoard.list()) .then(result => { - this.dashboards = result.data.retval; + this.dashboards = result.data; for (const dashboard of this.dashboards) { - this.$api - .call(ApiDashboardWidget.list(dashboard.dashboard_id)) - .then(res => { - dashboard.widgetSetup = res.data; - }) - .catch(this.$fhcAlert.handleSystemError); + dashboard.widgetSetup = JSON.parse(dashboard.widgetSetup); } }) .catch(this.$fhcAlert.handleSystemError);