Merge branch 'feature-24647/Konfigurierbare_Dashboards' into feature-25999/C4

This commit is contained in:
cgfhtw
2023-02-09 16:12:36 +01:00
10 changed files with 231 additions and 28 deletions
+63
View File
@@ -0,0 +1,63 @@
<?php
if (! defined('BASEPATH')) exit('No direct script access allowed');
/**
*/
class Test extends Auth_Controller
{
private $_uid; // uid of the logged user
/**
* Constructor
*/
public function __construct()
{
// Set required permissions
parent::__construct(
array(
'index' => 'dashboard/benutzer:r',
'db' => 'dashboard/benutzer:r',
'admin' => 'dashboard/admin:r',
)
);
$this->load->library('AuthLib');
$this->_setAuthUID(); // sets property uid
$this->setControllerId(); // sets the controller id
}
// -----------------------------------------------------------------------------------------------------------------
// Public methods
public function index()
{
$this->load->view('test/Test.php', ['dashboard' => 'CIS']);
}
// Public methods
public function db($dashboard)
{
$this->load->view('test/Test.php', ['dashboard' => $dashboard]);
}
public function admin()
{
$this->load->view('test/Admin.php', []);
}
// -----------------------------------------------------------------------------------------------------------------
// Private methods
/**
* Retrieve the UID of the logged user and checks if it is valid
*/
private function _setAuthUID()
{
$this->_uid = getAuthUID();
if (!$this->_uid) show_error('User authentification failed');
}
}
+7 -1
View File
@@ -207,7 +207,13 @@ class Config extends Auth_Controller
foreach ($funktionen as $funktion) {
$conf = $this->DashboardLib->getPreset($db, $funktion);
if ($conf)
$result[$funktion] = json_decode($conf->preset, true)['widgets'][$funktion];
{
$preset = json_decode($conf->preset, true);
if (!isset($preset['widgets']) || !isset($preset['widgets'][$funktion]))
$result[$funktion] = [];
else
$result[$funktion] = $preset['widgets'][$funktion];
}
else
$result[$funktion] = [];
}
+2 -2
View File
@@ -11,9 +11,9 @@ class Widget extends Auth_Controller
{
parent::__construct(
array(
'index' => 'dashboard/benutzer:r',
'index' => ['dashboard/benutzer:r', 'dashboard/admin:r'],
'getAll' => 'dashboard/admin:r',
'getWidgetsForDashboard' => 'dashboard/benutzer:rw',
'getWidgetsForDashboard' => ['dashboard/benutzer:rw', 'dashboard/admin:r'],
'setAllowed' => 'dashboard/admin:rw'
)
);
@@ -15,8 +15,8 @@ class Widget_model extends DB_Model
public function getWithAllowedForDashboard($dashboard_id)
{
$this->addSelect($this->dbTable . '.*');
$this->addSelect('CASE WHEN dashboard_id = ? THEN 1 ELSE 0 END AS allowed', false);
$this->addJoin('dashboard.tbl_dashboard_widget', 'widget_id', 'LEFT');
$this->addSelect('CASE WHEN dashboard_id IS NULL THEN 0 ELSE 1 END AS allowed', false);
$this->db->join('dashboard.tbl_dashboard_widget dw', $this->dbTable . '.widget_id=dw.widget_id AND dashboard_id = ?', 'LEFT', false);
return $this->execQuery($this->db->get_compiled_select($this->dbTable), [$dashboard_id]);
}
+32
View File
@@ -0,0 +1,32 @@
<?php
$this->load->view('templates/FHC-Header',
array(
'title' => 'FH-Complete',
'bootstrap5' => true,
'fontawesome6' => true,
'axios027' => true,
'restclient' => true,
'vue3' => true,
'customJSModules' => ['public/js/apps/Test.js'],
'customCSSs' => [
'public/css/components/dashboard.css'
],
'navigationcomponent' => true
)
);
?>
<div id="main">
<core-navigation-cmpt :add-side-menu-entries="appSideMenuEntries"></core-navigation-cmpt>
<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>
</div>
<dashboard-admin/>
</div>
</div>
<?php $this->load->view('templates/FHC-Footer'); ?>
+32
View File
@@ -0,0 +1,32 @@
<?php
$this->load->view('templates/FHC-Header',
array(
'title' => 'FH-Complete',
'bootstrap5' => true,
'fontawesome6' => true,
'axios027' => true,
'restclient' => true,
'vue3' => true,
'customJSModules' => ['public/js/apps/Test.js'],
'customCSSs' => [
'public/css/components/dashboard.css'
],
'navigationcomponent' => true
)
);
?>
<div id="main">
<core-navigation-cmpt :add-side-menu-entries="appSideMenuEntries"></core-navigation-cmpt>
<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>
</div>
<core-dashboard dashboard="<?= $dashboard; ?>"/>
</div>
</div>
<?php $this->load->view('templates/FHC-Footer'); ?>