mirror of
https://github.com/FH-Complete/FHC-Core.git
synced 2026-07-21 08:52:21 +00:00
Dashboard Test V1
This commit is contained in:
@@ -0,0 +1,51 @@
|
||||
<?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' => 'user:r',
|
||||
)
|
||||
);
|
||||
|
||||
$this->load->library('AuthLib');
|
||||
$this->load->library('WidgetLib');
|
||||
|
||||
$this->_setAuthUID(); // sets property uid
|
||||
|
||||
$this->setControllerId(); // sets the controller id
|
||||
}
|
||||
|
||||
// -----------------------------------------------------------------------------------------------------------------
|
||||
// Public methods
|
||||
public function index()
|
||||
{
|
||||
$this->load->view('test/Test.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');
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,54 @@
|
||||
<?php
|
||||
/**
|
||||
* FH-Complete
|
||||
*
|
||||
* @package FHC-API
|
||||
* @author FHC-Team
|
||||
* @copyright Copyright (c) 2016, fhcomplete.org
|
||||
* @license GPLv3
|
||||
* @link http://fhcomplete.org
|
||||
* @since Version 1.0
|
||||
* @filesource
|
||||
*/
|
||||
// ------------------------------------------------------------------------
|
||||
|
||||
if (!defined('BASEPATH')) exit('No direct script access allowed');
|
||||
|
||||
class Dashboard extends API_Controller
|
||||
{
|
||||
/**
|
||||
* Appdaten API constructor.
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct([
|
||||
'Widgets' => 'user:r'
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return void
|
||||
*/
|
||||
public function getWidgets()
|
||||
{
|
||||
$this->load->model('dashboard/Dashboard_model', 'DashboardModel');
|
||||
$result = $this->DashboardModel->loadWhere(['name'=>$this->get('dashboard')]);
|
||||
if (isError($result))
|
||||
return $this->response($result, REST_Controller::HTTP_INTERNAL_SERVER_ERROR);
|
||||
if (!hasData($result))
|
||||
return $this->response('No Dashboard with the name "' . $this->get('dashboard') . '" found.', REST_Controller::HTTP_INTERNAL_SERVER_ERROR);
|
||||
$dashboard_id = current(getData($result))->dashboard_id;
|
||||
|
||||
$this->load->model('dashboard/Dashboardwidget_model', 'DashboardwidgetModel');
|
||||
$result = $this->DashboardwidgetModel->loadWidgets($dashboard_id);
|
||||
if (isError($result))
|
||||
return $this->response($result, REST_Controller::HTTP_INTERNAL_SERVER_ERROR);
|
||||
if (!hasData($result))
|
||||
return $this->response('No Widgets for Dashboard "' . $this->get('dashboard') . '" found.', REST_Controller::HTTP_INTERNAL_SERVER_ERROR);
|
||||
|
||||
$this->response(getData($result), REST_Controller::HTTP_OK);
|
||||
}
|
||||
|
||||
protected function _check_whitelist_auth() {}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,89 @@
|
||||
<?php
|
||||
/**
|
||||
* FH-Complete
|
||||
*
|
||||
* @package FHC-API
|
||||
* @author FHC-Team
|
||||
* @copyright Copyright (c) 2016, fhcomplete.org
|
||||
* @license GPLv3
|
||||
* @link http://fhcomplete.org
|
||||
* @since Version 1.0
|
||||
* @filesource
|
||||
*/
|
||||
// ------------------------------------------------------------------------
|
||||
|
||||
if (!defined('BASEPATH')) exit('No direct script access allowed');
|
||||
|
||||
class User extends API_Controller
|
||||
{
|
||||
/**
|
||||
* Appdaten API constructor.
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct([
|
||||
'AuthObj' => 'user:r',
|
||||
'Widget' => 'user:r',
|
||||
'Widgets' => 'user:r'
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return void
|
||||
*/
|
||||
public function getAuthObj()
|
||||
{
|
||||
$result = $this->authlib->getAuthObj();
|
||||
|
||||
$this->response($result, REST_Controller::HTTP_OK);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return void
|
||||
*/
|
||||
public function getWidget()
|
||||
{
|
||||
$this->load->model('dashboard/Widget_model', 'WidgetModel');
|
||||
$result = $this->WidgetModel->load($this->get('widget_id'));
|
||||
if (isError($result))
|
||||
return $this->response($result, REST_Controller::HTTP_INTERNAL_SERVER_ERROR);
|
||||
if (!hasData($result))
|
||||
return $this->response('No Widget with the id "' . $this->get('widget_id') . '" found.', REST_Controller::HTTP_INTERNAL_SERVER_ERROR);
|
||||
$result = current(getData($result));
|
||||
|
||||
$this->response($result, REST_Controller::HTTP_OK);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return void
|
||||
*/
|
||||
public function getWidgets()
|
||||
{
|
||||
$this->load->model('dashboard/Dashboard_model', 'DashboardModel');
|
||||
$result = $this->DashboardModel->loadWhere(['name'=>$this->get('dashboard')]);
|
||||
if (isError($result))
|
||||
return $this->response($result, REST_Controller::HTTP_INTERNAL_SERVER_ERROR);
|
||||
if (!hasData($result))
|
||||
return $this->response('No Dashboard with the name "' . $this->get('dashboard') . '" found.', REST_Controller::HTTP_INTERNAL_SERVER_ERROR);
|
||||
$dashboard_id = current(getData($result))->dashboard_id;
|
||||
|
||||
$authObj = $this->authlib->getAuthObj();
|
||||
|
||||
$this->load->model('dashboard/Dashboardpreset_model', 'DashboardpresetModel');
|
||||
$result = $this->DashboardpresetModel->loadForUser($dashboard_id, $authObj->username);
|
||||
if (isError($result))
|
||||
return $this->response($result, REST_Controller::HTTP_INTERNAL_SERVER_ERROR);
|
||||
if (!hasData($result))
|
||||
return $this->response('No Dashboard for user "' . $authObj->username . '" found.', REST_Controller::HTTP_INTERNAL_SERVER_ERROR);
|
||||
|
||||
$result = (current(getData($result))->config);
|
||||
$result = json_decode($result);
|
||||
if ($result === null)
|
||||
return $this->response(json_last_error_msg(), REST_Controller::HTTP_INTERNAL_SERVER_ERROR);
|
||||
|
||||
$this->response($result, REST_Controller::HTTP_OK);
|
||||
}
|
||||
|
||||
protected function _check_whitelist_auth() {}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
<?php
|
||||
class Dashboard_model extends DB_Model
|
||||
{
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
$this->dbTable = "( WITH vals (dashboard_id, name) AS (VALUES
|
||||
(0,'CIS'),
|
||||
(1,'PV21')
|
||||
) SELECT * FROM vals ) AS tbl_dashboard";
|
||||
$this->pk = 'dashboard_id';
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,28 @@
|
||||
<?php
|
||||
class Dashboardpreset_model extends DB_Model
|
||||
{
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
$this->dbTable = "( WITH vals (dashboard_preset_id, config) AS (VALUES
|
||||
(0,CONCAT('[[0',',','0',',','0',',','0',',','[]]',',','[1',',','2',',','2',',','2',',','{\"display\":2}]]')),
|
||||
(1,CONCAT('[[0',',','1',',','0',',','1',',','{}]',',','[1',',','0',',','1',',','0',',','{\"display\":1}]]'))
|
||||
) SELECT * FROM vals ) AS tbl_dashboard_preset";
|
||||
$this->pk = 'dashboard_preset_id';
|
||||
}
|
||||
|
||||
public function loadForUser($dashboard_id, $uid)
|
||||
{
|
||||
$this->addJoin("( WITH vals (dashboard_preset_user_id, uid, dashboard_id, dashboard_preset_id) AS (VALUES
|
||||
(0,'ma0168', 0, 0)
|
||||
) SELECT * FROM vals ) AS tbl_dashboard_preset_user", 'dashboard_preset_id');
|
||||
return $this->loadWhere(['uid' => $uid, 'dashboard_id' => $dashboard_id]);
|
||||
|
||||
return success();
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,29 @@
|
||||
<?php
|
||||
class Dashboardwidget_model extends DB_Model
|
||||
{
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
$this->dbTable = "( WITH vals (dashboard_widget_id, dashboard_id, widget_id) AS (VALUES
|
||||
(0,0,0),
|
||||
(1,0,1),
|
||||
(2,1,0)
|
||||
) SELECT * FROM vals ) AS tbl_dashboard_widget";
|
||||
$this->pk = 'dashboard_widget_id';
|
||||
}
|
||||
|
||||
public function loadWidgets($dashboard_id)
|
||||
{
|
||||
$this->addJoin("( WITH vals (widget_id, name, component_name, component_path, arguments) AS (VALUES
|
||||
(0,'KPI Single','DbwKpi','./DBW/KPI.js',CONCAT('{\"data\":[1]',',','\"display\":0}')),
|
||||
(1,'KPI Multi','DbwKpi','./DBW/KPI.js',CONCAT('{\"data\":[1,2,3]}'))
|
||||
) SELECT * FROM vals ) AS tbl_widget", 'widget_id');
|
||||
|
||||
return $this->loadWhere(['dashboard_id' => $dashboard_id]);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
<?php
|
||||
class Widget_model extends DB_Model
|
||||
{
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
$this->dbTable = "( WITH vals (widget_id, name, component_name, component_path, arguments) AS (VALUES
|
||||
(0,'KPI Single','DbwKpi','./DBW/KPI.js',CONCAT('{\"data\":[1]',',','\"display\":0}')),
|
||||
(1,'KPI Multi','DbwKpi','./DBW/KPI.js',CONCAT('{\"data\":[1,2,3]}'))
|
||||
) SELECT * FROM vals ) AS tbl_widget";
|
||||
$this->pk = 'widget_id';
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,63 @@
|
||||
<?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'],
|
||||
'navigationcomponent' => true
|
||||
)
|
||||
);
|
||||
?>
|
||||
|
||||
<style type="text/css">
|
||||
.fixed-h {
|
||||
padding-bottom: 100%;
|
||||
position: relative;
|
||||
height: 0;
|
||||
}
|
||||
.fixed-h > * {
|
||||
position: absolute;
|
||||
top: 0;
|
||||
left: 0;
|
||||
width: 100%;
|
||||
}
|
||||
.fixed-h-1 > * {
|
||||
height: 100%;
|
||||
}
|
||||
.fixed-h-2 > * {
|
||||
height: calc(200% + var(--bs-gutter-y));
|
||||
}
|
||||
|
||||
.core-dashboard .row {
|
||||
--bs-gutter-y: 1.5rem;
|
||||
}
|
||||
|
||||
.draganddropcontainer {
|
||||
grid-template-columns:repeat(4,1fr);
|
||||
}
|
||||
@media(max-width: 700px) {
|
||||
.draganddropcontainer {
|
||||
grid-template-columns:repeat(2,1fr);
|
||||
}
|
||||
}
|
||||
</style>
|
||||
|
||||
<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="CIS"></core-dashboard>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<?php $this->load->view('templates/FHC-Footer'); ?>
|
||||
Reference in New Issue
Block a user