Dashboard Admin Cleanup

- refactoring Api: FHC-API controller for Edit/Update, widgets and presets
- delete dashboard with Prompt
- phrases
This commit is contained in:
ma0068
2025-12-19 11:39:31 +01:00
parent 3485ee624c
commit 02153e469f
10 changed files with 664 additions and 122 deletions
@@ -0,0 +1,294 @@
<?php
/**
* Copyright (C) 2024 fhcomplete.org
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
if (! defined('BASEPATH')) exit('No direct script access allowed');
/**
* This controller operates between (interface) the JS (GUI) and the back-end
* Provides data to the ajax get calls about addresses
* This controller works with JSON calls on the HTTP GET or POST and the output is always JSON
*/
class DashboardAdmin extends FHCAPI_Controller
{
public function __construct()
{
parent::__construct([
'getAllDashboards' => 'dashboard/admin:r',
'createDashboard' => 'dashboard/admin:rw',
'updateDashboard' => 'dashboard/admin:rw',
'deleteDashboard' => 'dashboard/admin:rw',
'loadWidget' => ['dashboard/benutzer:r', 'dashboard/admin:r'],
'getAllWidgets' => 'dashboard/admin:r',
'getWidgetsForDashboard' => ['dashboard/benutzer:rw', 'dashboard/admin:r'],
'setWidgetAllowed' => 'dashboard/admin:rw',
'index' => 'dashboard/benutzer:r',
'dummy' => 'dashboard/benutzer:r',
'genWidgetId' => 'dashboard/benutzer:rw',
'addWidgetsToPreset' => 'dashboard/admin:rw',
'removeWidgetFromPreset' => 'dashboard/admin:rw',
'addWidgetsToUserOverride' => 'dashboard/benutzer:rw',
'removeWidgetFromUserOverride' => 'dashboard/benutzer:rw',
'funktionen' => 'dashboard/admin:r',
'preset' => 'dashboard/admin:r',
'presetBatch' => 'dashboard/admin:r'
]);
// Load language phrases
$this->loadPhrases([
'ui'
]);
$this->load->library('dashboard/DashboardLib', null, 'DashboardLib');
$this->load->model('dashboard/Dashboard_model', 'DashboardModel');
$this->load->model('dashboard/Widget_model', 'WidgetModel');
$this->load->model('dashboard/Dashboard_Widget_model', 'DashboardWidgetModel');
$this->load->model('ressource/Funktion_model', 'FunktionModel');
}
public function getAllDashboards()
{
$result = $this->DashboardModel->load();
if (isError($result))
{
return $this->terminateWithError($result, self::ERROR_TYPE_GENERAL);
}
$this->terminateWithSuccess($result);
}
public function createDashboard()
{
$dashboard_kurzbz = $this->input->post('dashboard_kurzbz');
$result = $this->DashboardModel->insert(
[
'dashboard_kurzbz' => $dashboard_kurzbz
]
);
if (isError($result))
{
$this->terminateWithError($result, self::ERROR_TYPE_GENERAL);
}
$this->terminateWithSuccess((getData($result) ?: []));
}
public function updateDashboard()
{
$dashboard_id = $this->input->post('dashboard_id');
$dashboard_kurzbz = $this->input->post('dashboard_kurzbz');
$beschreibung = $this->input->post('beschreibung');
if(!$dashboard_id)
{
$this->terminateWithError($this->p->t('ui', 'error_missingId', ['id'=> 'Dashboard ID']), self::ERROR_TYPE_GENERAL);
}
$result = $this->DashboardModel->update(
[
'dashboard_id' => $dashboard_id,
],
[
'dashboard_kurzbz' => $dashboard_kurzbz,
'beschreibung' => $beschreibung,
]
);
if (isError($result))
{
$this->terminateWithError($result, self::ERROR_TYPE_GENERAL);
}
$this->terminateWithSuccess($result);
}
public function deleteDashboard()
{
$dashboard_id = $this->input->post('dashboard_id');
if(!$dashboard_id)
{
return $this->terminateWithError($this->p->t('ui', 'error_missingId', ['id'=> 'Dashboard ID']), self::ERROR_TYPE_GENERAL);
}
//delete all presets
$this->load->model('dashboard/Dashboard_Preset_model', 'DashboardPresetModel');
$resultPresets = $this->DashboardPresetModel->delete(
array('dashboard_id' => $dashboard_id)
);
if ($resultPresets === false)
{
return $this->terminateWithError($resultPresets, self::ERROR_TYPE_GENERAL);
}
//delete all widgets
$this->load->model('dashboard/Dashboard_Widget_model', 'DashboardWidgetModel');
$resultWidgets = $this->DashboardWidgetModel->delete(
array('dashboard_id' => $dashboard_id)
);
if ($resultWidgets === false)
{
return $this->terminateWithError($resultWidgets, self::ERROR_TYPE_GENERAL);
}
$result = $this->DashboardModel->delete(
array('dashboard_id' => $dashboard_id)
);
if (isError($result))
{
return $this->terminateWithError($result, self::ERROR_TYPE_GENERAL);
}
$this->terminateWithSuccess($result);
}
public function getAllWidgets()
{
$dashboard_id = $this->input->get('dashboard_id');
if(!$dashboard_id)
{
return $this->terminateWithError($this->p->t('ui', 'error_missingId', ['id'=> 'Dashboard ID']), self::ERROR_TYPE_GENERAL);
}
//$this->terminateWithError($dashboard_id);
$result = $this->WidgetModel->getWithAllowedForDashboard($dashboard_id);
if (isError($result))
$this->terminateWithError($result, self::ERROR_TYPE_GENERAL);
$this->terminateWithSuccess(getData($result) ?: []);
}
public function setWidgetAllowed()
{
$dashboard_id = $this->input->post('dashboard_id');
$widget_id = $this->input->post('widget_id');
$action = $this->input->post('action');
if ($action == 'add')
{
$result = $this->DashboardWidgetModel->insert([
'dashboard_id' => $dashboard_id,
'widget_id' => $widget_id
]);
}
elseif ($action == 'delete')
{
$result = $this->DashboardWidgetModel->delete([
'dashboard_id' => $dashboard_id,
'widget_id' => $widget_id
]);
}
else
{
$this->terminateWithError("action value invalid", self::ERROR_TYPE_GENERAL);
}
if (isError($result))
$this->terminateWithError($result, self::ERROR_TYPE_GENERAL);
$this->terminateWithSuccess(getData($result) ?: []);
}
//Presets
public function funktionen()
{
$result = $this->FunktionModel->load();
if (isError($result))
$this->terminateWithError($result, self::ERROR_TYPE_GENERAL);
$this->terminateWithSuccess(getData($result) ?: []);
}
public function addWidgetsToPreset()
{
$raw = $this->input->raw_input_stream;
$json = json_decode($raw);
$dashboard_kurzbz = $json->db;
$funktion_kurzbz = $json->funktion_kurzbz;
$widgets = $json->widgets;
$preset = $this->DashboardLib->getPresetOrCreateEmptyPreset($dashboard_kurzbz, $funktion_kurzbz);
$preset_decoded = json_decode($preset->preset, true);
$this->DashboardLib->addWidgetsToWidgets($preset_decoded, $dashboard_kurzbz, $funktion_kurzbz, $widgets);
$preset->preset = json_encode($preset_decoded);
$result = $this->DashboardLib->insertOrUpdatePreset($preset);
if (isError($result))
$this->terminateWithError($this->p->t('dashboard', 'error_savePreset'), self::ERROR_TYPE_GENERAL);
$this->terminateWithSuccess($preset_decoded);
}
public function removeWidgetFromPreset()
{
$raw = $this->input->raw_input_stream;
$json = json_decode($raw);
$dashboard_kurzbz = $json->db;
$funktion_kurzbz = $json->funktion_kurzbz;
$widgetid = $json->widgetid;
$preset = $this->DashboardLib->getPreset($dashboard_kurzbz, $funktion_kurzbz);
if ($preset === null)
{
$this->terminateWithError($this->p->t('ui', 'error_presetAndFunctionNotFound', ['dashboard'=> $dashboard_kurzbz, 'funktion'=> $funktion_kurzbz]), self::ERROR_TYPE_GENERAL);
}
$preset_decoded = json_decode($preset->preset, true);
if (!$this->DashboardLib->removeWidgetFromWidgets($preset_decoded, $funktion_kurzbz, $widgetid))
{
$this->terminateWithError($this->p->t('ui', 'error_missingId', ['id'=> 'Widget ID']), self::ERROR_TYPE_GENERAL);
}
$preset->preset = json_encode($preset_decoded);
$result = $this->DashboardLib->insertOrUpdatePreset($preset);
if (isError($result))
{
$this->terminateWithError($this->p->t('dashboard', 'error_deleteWidget'), self::ERROR_TYPE_GENERAL);
}
$this->terminateWithSuccess(array('msg' => $this->p->t('dashboard', 'success_savePreset')));
}
public function presetBatch()
{
$db = $this->input->get('db');
$funktionen = $this->input->get('funktionen');
$result = [];
if($funktionen)
{
foreach ($funktionen as $funktion) {
$conf = $this->DashboardLib->getPreset($db, $funktion);
if ($conf) {
$preset = json_decode($conf->preset, true);
if (!isset($preset[$funktion]) || !isset($preset[$funktion]['widgets']))
$result[$funktion] = [];
else {
$result[$funktion] = $preset[$funktion]['widgets'];
}
} else
$result[$funktion] = [];
}
}
else
$result = [];
return $this->terminateWithSuccess($result);
}
}
@@ -8,9 +8,11 @@ $this->load->view(
'axios027' => true,
'restclient' => true,
'vue3' => true,
'customJSModules' => ['public/js/apps/DashboardAdmin.js'],
'primevue3' => true,
'customJSModules' => ['public/js/apps/Dashboard/Admin.js'],
'customCSSs' => [
'public/css/components/dashboard.css'
'public/css/components/dashboard.css',
'public/css/components/primevue.css',
],
'navigationcomponent' => true
)
@@ -0,0 +1,85 @@
/*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
export default {
addDashboard(params) {
return {
method: 'post',
url: 'api/frontend/v1/dashboard/DashboardAdmin/createDashboard',
params
};
},
updateDashboard(params) {
return {
method: 'post',
url: 'api/frontend/v1/dashboard/DashboardAdmin/updateDashboard',
params
};
},
deleteDashboard(dashboard_id) {
return {
method: 'post',
url: 'api/frontend/v1/dashboard/DashboardAdmin/deleteDashboard',
params: { dashboard_id }
};
},
getAllDashboards(){
return {
method: 'get',
url: 'api/frontend/v1/dashboard/DashboardAdmin/getAllDashboards'
};
},
getAllWidgets(dashboard_id){
return {
method: 'get',
url: 'api/frontend/v1/dashboard/DashboardAdmin/getAllWidgets',
params: {dashboard_id}
};
},
setWidgetAllowed(params){
return {
method: 'post',
url: 'api/frontend/v1/dashboard/DashboardAdmin/setWidgetAllowed',
params
};
},
loadFunktionen(){
return {
method: 'get',
url: 'api/frontend/v1/dashboard/DashboardAdmin/funktionen'
};
},
addWidgetsToPreset(params){
return {
method: 'post',
url: 'api/frontend/v1/dashboard/DashboardAdmin/addWidgetsToPreset',
params
};
},
removeWidgetFromPreset(params){
return {
method: 'post',
url: 'api/frontend/v1/dashboard/DashboardAdmin/removeWidgetFromPreset',
params
};
},
presetBatch(params){
return {
method: 'get',
url: 'api/frontend/v1/dashboard/DashboardAdmin/presetBatch',
params
};
},
}
+52 -31
View File
@@ -3,11 +3,14 @@ import DashboardAdminEdit from "./Admin/Edit.js";
import DashboardAdminWidgets from "./Admin/Widgets.js";
import DashboardAdminPresets from "./Admin/Presets.js";
import ApiDashboardAdmin from "../../api/factory/dashboard/dashboardAdmin.js";
export default {
name: 'DashboardAdmin',
components: {
DashboardAdminEdit,
DashboardAdminWidgets,
DashboardAdminPresets
DashboardAdminPresets,
},
provide() {
return {
@@ -22,9 +25,6 @@ export default {
};
},
computed: {
apiurl() {
return FHC_JS_DATA_STORAGE_OBJECT.app_root + FHC_JS_DATA_STORAGE_OBJECT.ci_router + '/dashboard';
},
dashboard() {
return this.dashboards.find(el => el.dashboard_id == this.current);
}
@@ -35,33 +35,49 @@ export default {
BsPrompt.popup('New Dashboard name').then(
name => {
_name = name;
return axios.post(this.apiurl + '/Dashboard/create', {
const params = {
dashboard_kurzbz: name
})
}
).then(res => {
let newDashboard = {
dashboard_id: res.data.retval,
dashboard_kurzbz: _name,
beschreibung: ''
};
this.dashboards.push(newDashboard);
this.current = newDashboard.dashboard_id;
}).catch(err => err !== undefined ? console.error('ERROR:', err) : 0);
};
return this.$api
.call(ApiDashboardAdmin.addDashboard(params))
.then(response =>{
this.$fhcAlert.alertSuccess(this.$p.t('ui', 'successSave')); //TODO(Manu) phrase here working
let newDashboard = {
dashboard_id: response.data,
dashboard_kurzbz: _name,
beschreibung: ''
};
this.dashboards.push(newDashboard);
this.current = newDashboard.dashboard_id;
})
.catch(this.$fhcAlert.handleSystemError);
});
},
dashboardUpdate(dashboard) {
// TODO(chris): Loading or message
axios.post(this.apiurl + '/Dashboard/update', dashboard).then(() => {
let old = this.dashboards.find(el => el.dashboard_id == dashboard.dashboard_id);
old.dashboard_kurzbz = dashboard.dashboard_kurzbz;
old.beschreibung = dashboard.beschreibung;
}).catch(err => console.error('ERROR:', err));
return this.$api
.call(ApiDashboardAdmin.updateDashboard(dashboard))
.then(response =>{
this.$fhcAlert.alertSuccess(this.$p.t('ui', 'successSave')); //TODO(Manu) phrase here working
let old = this.dashboards.find(el => el.dashboard_id == dashboard.dashboard_id);
old.dashboard_kurzbz = dashboard.dashboard_kurzbz;
old.beschreibung = dashboard.beschreibung;
})
.catch(this.$fhcAlert.handleSystemError);
},
dashboardDelete(dashboard_id) {
axios.post(this.apiurl + '/Dashboard/delete', {dashboard_id}).then(() => {
this.current = -1;
this.dashboards = this.dashboards.filter(el => el.dashboard_id != dashboard_id);
}).catch(err => console.error('ERROR:', err));
return this.$api
.call(ApiDashboardAdmin.deleteDashboard(dashboard_id))
.then(response => {
this.$fhcAlert.alertSuccess(this.$p.t('ui', 'successDelete')); //TODO(Manu) phrase here NOT always working
})
.catch(this.$fhcAlert.handleSystemError)
.finally(() => {
this.current = -1;
this.dashboards = this.dashboards.filter(el => el.dashboard_id != dashboard_id);
});
},
assignWidgets(widgets) {
this.widgets = widgets;
@@ -72,18 +88,23 @@ export default {
}
},
created() {
axios.get(this.apiurl + '/Dashboard').then(res => {
this.dashboards = res.data.retval;
}).catch(err => console.error('ERROR:', err));
this.$api
.call(ApiDashboardAdmin.getAllDashboards())
.then(result => {
this.dashboards = result.data.retval;
})
.catch(this.$fhcAlert.handleSystemError);
},
template: `<div class="dashboard-admin">
<div class="input-group">
<label for="dashbaord-select" class="input-group-text">Dashboard:</label>
<select id="dashbaord-select" class="form-select" v-model="current">
<label for="dashboard-select" class="input-group-text">Dashboard:</label>
<select id="dashboard-select" class="form-select" v-model="current">
<option v-for="dashboard in dashboards" :key="dashboard.dashboard_id" :value="dashboard.dashboard_id">{{dashboard.dashboard_kurzbz}}</option>
</select>
<button class="btn btn-outline-secondary" type="button" @click="dashboardAdd"><i class="fa-solid fa-plus"></i></button>
</div>
<div v-if="dashboard">
<ul class="nav nav-tabs mt-3" role="tablist">
<li class="nav-item" role="presentation">
+3 -1
View File
@@ -18,7 +18,9 @@ export default {
},
methods: {
sendDelete() {
BsConfirm.popup('Sure?').then(() => this.$emit('delete', this.dashboard_id)).catch();
//TODO(Manu) phrases here NOT always working
BsConfirm.popup(this.$p.t('alert', 'confirm_delete') + " " + this.$p.t('dashboard', 'deleteInfo'))
.then(() => this.$emit('delete', this.dashboard_id)).catch();
}
},
template: `<div class="dashboard-admin-edit px-3">
+86 -71
View File
@@ -1,6 +1,7 @@
import DashboardSection from "../Section.js";
import DashboardWidgetPicker from "../Widget/Picker.js";
import ObjectUtils from "../../../helpers/ObjectUtils.js";
import ApiDashboardAdmin from "../../../api/factory/dashboard/dashboardAdmin.js";
export default {
components: {
@@ -17,9 +18,6 @@ export default {
tmpLoading: ''
}),
computed: {
apiurl() {
return FHC_JS_DATA_STORAGE_OBJECT.app_root + FHC_JS_DATA_STORAGE_OBJECT.ci_router + '/dashboard';
},
pickerWidgets() {
return this.widgets.filter(widget => widget.allowed);
}
@@ -36,26 +34,29 @@ export default {
if (section.name == section_name)
section.widgets.push(loading);
});
axios.post(this.apiurl + '/Config/addWidgetsToPreset', {
const params = {
db: this.dashboard,
funktion_kurzbz: section_name,
widgets: [widget]
}).then(result => {
let newId = Object.keys(result.data.retval.data[section_name].widgets).pop();
widget.id = newId;
widget.custom = 1;
this.sections.forEach(section => {
if (section.name == section_name) {
section.widgets.splice(section.widgets.indexOf(loading),1);
section.widgets.push(widget);
}
});
}).catch(error => {
console.error('ERROR: ', error);
alert('ERROR: ' + error.response.data.retval);
});
}).catch(() => {});
};
return this.$api
.call(ApiDashboardAdmin.addWidgetsToPreset(params))
.then(result => {
let newId = Object.keys(result.data[section_name].widgets).pop();
widget.id = newId;
widget.custom = 1;
this.sections.forEach(section => {
if (section.name == section_name) {
section.widgets.splice(section.widgets.indexOf(loading),1);
section.widgets.push(widget);
}
});
})
.catch(this.$fhcAlert.handleSystemError);
})
.catch(() => {});
},
widgetUpdate(section_name, payload) {
payload = payload[section_name];
@@ -78,76 +79,90 @@ export default {
payload[k].widgetid = k;
delete payload[k].custom;
}
axios.post(this.apiurl + '/Config/addWidgetsToPreset', {
//TODO(manu) test
const params = {
db: this.dashboard,
funktion_kurzbz: section_name,
widgets: payload
}).then(() => {
this.sections.forEach(section => {
if (section.name == section_name) {
section.widgets.forEach((widget, i) => {
if (payload[widget.id]) {
payload[widget.id].id = widget.id;
payload[widget.id].index = widget.index;
section.widgets[i] = payload[widget.id];
section.widgets[i].custom = 1;
}
});
}
});
}).catch(error => {
// TODO(chris): revert placement on failure
console.error('ERROR: ', error);
alert('ERROR: ' + error.response.data.retval);
});
};
return this.$api
.call(ApiDashboardAdmin.addWidgetsToPreset(params))
.then(result => {
this.sections.forEach(section => {
if (section.name == section_name) {
section.widgets.forEach((widget, i) => {
if (payload[widget.id]) {
payload[widget.id].id = widget.id;
payload[widget.id].index = widget.index;
section.widgets[i] = payload[widget.id];
section.widgets[i].custom = 1;
}
});
}
});
})
.catch(this.$fhcAlert.handleSystemError);
},
widgetRemove(section_name, id) {
axios.post(this.apiurl + '/Config/removeWidgetFromPreset', {
const params = {
db: this.dashboard,
funktion_kurzbz: section_name,
widgetid: id
}).then(() => {
this.sections.forEach(section => {
if (section.name == section_name)
section.widgets = section.widgets.filter(widget => widget.id != id);
});
}).catch(error => {
console.error('ERROR: ', error);
alert('ERROR: ' + error.response.data.retval);
});
};
return this.$api
.call(ApiDashboardAdmin.removeWidgetFromPreset(params))
.then(result => {
this.sections.forEach(section => {
if (section.name == section_name)
section.widgets = section.widgets.filter(widget => widget.id != id);
});
})
.catch(this.$fhcAlert.handleSystemError);
},
loadSections(evt) {
let funktionen = Array.from(evt.target.querySelectorAll("option:checked"),e=>e.value);
this.sections = [];
this.tmpLoading = funktionen.join('###');
axios.get(this.apiurl + '/Config/presetBatch', {params: {
const params = {
db: this.dashboard,
funktionen
}}).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]) {
res.data.retval[section][wid].id = wid;
res.data.retval[section][wid].custom = 1;
widgets.push(res.data.retval[section][wid]);
};
return this.$api
.call(ApiDashboardAdmin.presetBatch(params))
.then(result => {
if (this.tmpLoading !== funktionen.join('###'))
return; // NOTE(chris): prevent race condition
for (var section in result.data) {
let widgets = [];
for (var wid in result.data[section]) {
result.data[section][wid].id = wid;
result.data[section][wid].custom = 1;
widgets.push(result.data[section][wid]);
}
this.sections.push({
name: section,
widgets
});
}
this.sections.push({
name: section,
widgets
});
}
}).catch(err => console.error('ERROR:', err));
})
.catch(this.$fhcAlert.handleSystemError);
}
},
created() {
axios.get(this.apiurl + '/Config/funktionen').then(res => {
this.funktionen = {general: 'GENERAL'};
res.data.retval.forEach(funktion => {
this.funktionen[funktion.funktion_kurzbz] = funktion.beschreibung;
});
}).catch(err => console.error('ERROR:', err));
this.$api
.call(ApiDashboardAdmin.loadFunktionen())
.then(result => {
//console.log(result);
result.data.forEach(funktion => {
this.funktionen[funktion.funktion_kurzbz] = funktion.beschreibung;
});
})
.catch(this.$fhcAlert.handleSystemError);
},
watch: {
dashboard() {
+18 -16
View File
@@ -1,3 +1,5 @@
import ApiDashboardAdmin from "../../../api/factory/dashboard/dashboardAdmin.js";
export default {
emits: [
"change",
@@ -7,34 +9,34 @@ export default {
dashboard_id: Number,
widgets: Array
},
computed: {
apiurl() {
return FHC_JS_DATA_STORAGE_OBJECT.app_root + FHC_JS_DATA_STORAGE_OBJECT.ci_router + '/dashboard';
}
},
methods: {
sendChange(widget_id) {
let allow = !this.widgets.find(el => el.widget_id == widget_id).allowed;
axios.post(this.apiurl + '/Widget/setAllowed', {
const params = {
dashboard_id: this.dashboard_id,
widget_id,
action: allow ? 'add' : 'delete'
}).catch(err => console.error('ERROR: ' + err));
};
this.$api
.call(ApiDashboardAdmin.setWidgetAllowed(params))
.catch(this.$fhcAlert.handleSystemError);
}
},
created() {
axios.get(this.apiurl + '/Widget/getAll', {
params:{
dashboard_id: this.dashboard_id
}
}).then(
result => {
this.$emit('assignWidgets', result.data.retval.map(el => ({
this.$api
.call(ApiDashboardAdmin.getAllWidgets(this.dashboard_id))
.then(result => {
/* console.log(result.data.map(el => ({
...el,
...{setup:JSON.parse(el.setup),arguments:JSON.parse(el.arguments),allowed:!!el.allowed}
})));*/
this.$emit('assignWidgets', result.data.map(el => ({
...el,
...{setup:JSON.parse(el.setup),arguments:JSON.parse(el.arguments),allowed:!!el.allowed}
})));
}
).catch(err => console.error('ERROR:', err));
})
.catch(this.$fhcAlert.handleSystemError);
},
template: `
<div class="dashboard-admin-widgets">
+1 -1
View File
@@ -151,7 +151,7 @@ export default {
},
removeWidget(item, revert) {
if (item.custom) {
BsConfirm.popup('Are you sure you want to delete this widget?').then(() => this.$emit('widgetRemove', this.name, item.id));
BsConfirm.popup(this.$p.t('dashboard', 'alert_deleteWidget')).then(() => this.$emit('widgetRemove', this.name, item.id));
} else {
let update = {};
update[item.id] = { hidden: !revert };
+121
View File
@@ -52612,6 +52612,127 @@ I have been informed that I am under no obligation to consent to the transmissio
)
),
// ### Refactor Messages END
// ### Phrases Dashboard Admin START
array(
'app' => 'core',
'category' => 'dashboard',
'phrase' => 'deleteInfo',
'insertvon' => 'system',
'phrases' => array(
array(
'sprache' => 'German',
'text' => 'Mit dieser Aktion werden auch alle Voreinstellungen der verbundenen Widgets gelöscht.',
'description' => '',
'insertvon' => 'system'
),
array(
'sprache' => 'English',
'text' => 'This action will also delete all presets of the connected widgets.',
'description' => '',
'insertvon' => 'system'
)
)
),
array(
'app' => 'core',
'category' => 'dashboard',
'phrase' => 'error_savePreset',
'insertvon' => 'system',
'phrases' => array(
array(
'sprache' => 'German',
'text' => 'Voreinstellung konnten nicht gespeichert werden.',
'description' => '',
'insertvon' => 'system'
),
array(
'sprache' => 'English',
'text' => 'Preset could not be saved.',
'description' => '',
'insertvon' => 'system'
)
)
),
array(
'app' => 'core',
'category' => 'dashboard',
'phrase' => 'error_presetAndFunctionNotFound',
'insertvon' => 'system',
'phrases' => array(
array(
'sprache' => 'German',
'text' => 'Voreinstellung für Dashboard {dashboard} und Funktion {funktion} nicht gefunden.',
'description' => '',
'insertvon' => 'system'
),
array(
'sprache' => 'English',
'text' => 'Preset for dashboard {dashboard} and function {funktion} not found.',
'description' => '',
'insertvon' => 'system'
)
)
),
array(
'app' => 'core',
'category' => 'dashboard',
'phrase' => 'error_deleteWidget',
'insertvon' => 'system',
'phrases' => array(
array(
'sprache' => 'German',
'text' => 'Widget konnte nicht entfernt werden',
'description' => '',
'insertvon' => 'system'
),
array(
'sprache' => 'English',
'text' => 'failed to remove widget',
'description' => '',
'insertvon' => 'system'
)
)
),
array(
'app' => 'core',
'category' => 'dashboard',
'phrase' => 'success_savePreset',
'insertvon' => 'system',
'phrases' => array(
array(
'sprache' => 'German',
'text' => 'Voreinstellung erfolgreich aktualisiert',
'description' => '',
'insertvon' => 'system'
),
array(
'sprache' => 'English',
'text' => 'Preset successfully updated',
'description' => '',
'insertvon' => 'system'
)
)
), array(
'app' => 'core',
'category' => 'dashboard',
'phrase' => 'alert_deleteWidget',
'insertvon' => 'system',
'phrases' => array(
array(
'sprache' => 'German',
'text' => 'Sind Sie sicher, dass Sie dieses Widget löschen möchten?',
'description' => '',
'insertvon' => 'system'
),
array(
'sprache' => 'English',
'text' => 'Are you sure you want to delete this widget?',
'description' => '',
'insertvon' => 'system'
)
)
),
// ### Phrases Dashboard Admin END
);