Funktionen fett schreiben, die schon presets hinterlegt haben, demo aus views und Controller namen entfernen, preview hinzufuegen

This commit is contained in:
Harald Bamberger
2026-03-18 15:48:57 +01:00
parent a4f2502fe6
commit 14a8e2f001
7 changed files with 114 additions and 32 deletions
@@ -205,18 +205,63 @@ class DashboardAdmin extends FHCAPI_Controller
//Presets
public function funktionen()
{
$this->FunktionModel->addSelect('funktion_kurzbz, beschreibung');
$this->FunktionModel->addOrder('beschreibung', 'ASC');
$result = $this->FunktionModel->loadWhere(array('aktiv' => true));
$dashboard_kurzbz = $this->input->get('db');
if(!$dashboard_kurzbz)
{
$this->terminateWithError('missing query parameter db');
}
$sql = <<<EOSQL
with
dashboard_presets as (
select
*
from
dashboard.tbl_dashboard_preset dp
join
dashboard.tbl_dashboard d on d.dashboard_id = dp.dashboard_id
where
d.dashboard_kurzbz = {$this->db->escape($dashboard_kurzbz)}
),
general as (
select
'general' as funktion_kurzbz,
'Allgemein' as beschreibung
)
(
select
f.funktion_kurzbz,
f.beschreibung,
count(p.preset_id) as has_preset
from
general f
left join
dashboard_presets p on p.funktion_kurzbz is null
group by
f.funktion_kurzbz, f.beschreibung
)
union ALL
(
select
f.funktion_kurzbz,
f.beschreibung,
count(p.preset_id) as has_preset
from
public.tbl_funktion f
left join
dashboard_presets p on p.funktion_kurzbz = f.funktion_kurzbz
group by
f.funktion_kurzbz, f.beschreibung
order by
f.beschreibung asc
)
EOSQL;
$result = $this->FunktionModel->execReadOnlyQuery($sql);
if (isError($result))
$this->terminateWithError($result, self::ERROR_TYPE_GENERAL);
$funktionen = getData($result) ?: [];
array_unshift($funktionen, (object) array(
'funktion_kurzbz' => 'general',
'beschreibung' => 'Allgemein'
));
$this->terminateWithSuccess($funktionen);
}
@@ -4,7 +4,7 @@ if (! defined('BASEPATH')) exit('No direct script access allowed');
/**
*/
class DashboardDemo extends Auth_Controller
class DashboardAdmin extends Auth_Controller
{
private $_uid; // uid of the logged user
@@ -16,8 +16,8 @@ class DashboardDemo extends Auth_Controller
// Set required permissions
parent::__construct(
array(
'index' => 'dashboard/benutzer:r',
'admin' => 'dashboard/admin:rw'
'index' => 'dashboard/admin:rw',
'preview' => 'dashboard/admin:r',
)
);
@@ -33,15 +33,14 @@ class DashboardDemo extends Auth_Controller
// Public methods
public function index()
{
$this->load->view('dashboard/dashboard_demo.php', []);
$this->load->view('dashboard/dashboard_admin.php', []);
}
// -----------------------------------------------------------------------------------------------------------------
// Public methods
public function admin()
{
$this->load->view('dashboard/dashboard_demo_admin.php', []);
}
public function preview()
{
$dashboard_kurzbz = $this->input->get('db') ?? 'CIS';
$this->load->view('dashboard/dashboard_preview.php', ['dashboard_kurzbz' => $dashboard_kurzbz]);
}
// -----------------------------------------------------------------------------------------------------------------
// Private methods
@@ -9,6 +9,10 @@ $this->load->view(
'restclient' => true,
'vue3' => true,
'primevue3' => true,
'vuedatepicker11' => true,
'customJSs' => [
'vendor/moment/luxonjs/luxon.min.js'
],
'customJSModules' => ['public/js/apps/Dashboard/Admin.js'],
'customCSSs' => [
'public/css/components/dashboard.css',
@@ -8,7 +8,12 @@ $this->load->view(
'axios027' => true,
'restclient' => true,
'vue3' => true,
'customJSModules' => ['public/js/apps/Dashboard.js'],
'vuedatepicker11' => true,
'primevue3' => true,
'customJSs' => [
'vendor/moment/luxonjs/luxon.min.js'
],
'customJSModules' => ['public/js/apps/Dashboard/Preview.js'],
'customCSSs' => [
'public/css/components/dashboard.css'
],
@@ -23,9 +28,9 @@ $this->load->view(
<div id="content">
<div class="d-flex justify-content-between flex-wrap flex-md-nowrap align-items-center pt-3 pb-2 mb-3 border-bottom">
<h1 class="h2">Dashboard</h1>
<h1 class="h2">Dashboard <?= $dashboard_kurzbz ?></h1>
</div>
<core-dashboard dashboard="CIS" apiurl="<?= site_url('dashboard'); ?>"></core-dashboard>
<core-dashboard dashboard="<?= $dashboard_kurzbz ?>"></core-dashboard>
</div>
</div>
@@ -55,10 +55,11 @@ export default {
params
};
},
loadFunktionen(){
loadFunktionen(dashboard_kurzbz){
return {
method: 'get',
url: 'api/frontend/v1/dashboard/DashboardAdmin/funktionen'
url: 'api/frontend/v1/dashboard/DashboardAdmin/funktionen?db='
+ encodeURIComponent(dashboard_kurzbz)
};
},
addWidgetsToPreset(params){
+17
View File
@@ -0,0 +1,17 @@
import {CoreNavigationCmpt} from '../../components/navigation/Navigation.js';
import CoreDashboard from '../../components/Dashboard/Dashboard.js';
import PluginsPhrasen from '../../plugins/Phrasen.js';
const app = Vue.createApp({
name: 'DashboardPreviewApp',
data: () => ({
appSideMenuEntries: {}
}),
components: {
CoreNavigationCmpt,
CoreDashboard
}
});
app.use(PluginsPhrasen);
app.directive('tooltip', primevue.tooltip);
app.mount('#main');
+21 -10
View File
@@ -53,6 +53,11 @@ export default {
section.widgets.push(widget);
}
});
this.funktionen.forEach(funktion => {
if(funktion.funktion_kurzbz === section_name && funktion.has_preset < 1) {
funktion.has_preset = 1;
}
});
})
.catch(this.$fhcAlert.handleSystemError);
})
@@ -151,30 +156,36 @@ export default {
})
.catch(this.$fhcAlert.handleSystemError);
},
loadFunktionen() {
this.$api
.call(ApiDashboardAdmin.loadFunktionen(this.dashboard))
.then(result => {
this.funktionen = result.data;
})
.catch(this.$fhcAlert.handleSystemError);
}
},
created() {
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);
this.loadFunktionen();
},
watch: {
dashboard() {
// TODO(chris): this should be done without a watcher
this.loadSections({target:this.$refs.funktionenList});
this.loadFunktionen();
}
},
template: `<div class="dashboard-admin-presets">
<div class="row">
<div class="col-3">
<select ref="funktionenList" style="height:30em" class="form-control" multiple @input="loadSections">
<option v-for="name,id in funktionen" :key="id" :value="id">{{ name }}</option>
<option
v-for="funktion in funktionen"
:key="funktion.funktion_kurzbz"
:value="funktion.funktion_kurzbz"
:class="(funktion.has_preset > 0) ? 'fw-bold' : ''"
>{{ funktion.beschreibung }}</option>
</select>
</div>
<div class="col-9">