diff --git a/application/controllers/dashboard/Api.php b/application/controllers/dashboard/Api.php new file mode 100644 index 000000000..c6ac21463 --- /dev/null +++ b/application/controllers/dashboard/Api.php @@ -0,0 +1,78 @@ + 'dashboard/admin:rw', + 'getNews' => 'dashboard/admin:rw', + 'getAmpeln' => 'dashboard/admin:rw', + ) + ); + + $this->load->library('AuthLib', null, 'AuthLib'); + + $this->_setAuthUID(); + } + + public function index() + { + echo 'Dashboard API Controller'; + } + + /** + * Get News. + */ + public function getNews() + { + $limit = $this->input->get('limit'); + + $this->load->model('content/News_model', 'NewsModel'); + + $result = $this->NewsModel->getAll($limit); + + if(hasData($result)) + { + + $this->outputJson(getData($result), REST_Controller::HTTP_OK); + } + else + { + $this->terminateWithJsonError('fehler entdeckt'); + } + } + + + /** + * Get Ampeln. + */ + public function getAmpeln(){ + + $this->load->model('content/Ampel_model', 'AmpelModel'); + $result = $this->AmpelModel->getByUser($this->_uid); + + if(hasData($result)) + { + + $this->outputJson(getData($result), REST_Controller::HTTP_OK); + } + else + { + $this->terminateWithJsonError('fehler entdeckt'); + } + + } + + /** + * 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'); + } +} diff --git a/application/controllers/dashboard/DashboardDemo.php b/application/controllers/dashboard/DashboardDemo.php new file mode 100644 index 000000000..7088c44b9 --- /dev/null +++ b/application/controllers/dashboard/DashboardDemo.php @@ -0,0 +1,51 @@ + '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('dashboard/dashboard_demo.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'); + } + +} diff --git a/application/models/content/News_model.php b/application/models/content/News_model.php index 8d636d808..472eb2e56 100644 --- a/application/models/content/News_model.php +++ b/application/models/content/News_model.php @@ -11,4 +11,19 @@ class News_model extends DB_Model $this->dbTable = 'campus.tbl_news'; $this->pk = 'news_id'; } + + /** + * Get all News ordered by date. (most actual on top) + * @param null $limit Amount of news. + * @return array + */ + public function getAll($limit = null) + { + return $this->loadWhere(' + text IS NOT NULL + AND datum <= NOW() AND (datum_bis IS NULL OR datum_bis >= now()::date) + ORDER BY datum DESC + LIMIT '. $this->escape($limit) + ); + } } diff --git a/application/views/dashboard/dashboard_demo.php b/application/views/dashboard/dashboard_demo.php new file mode 100644 index 000000000..3518d769a --- /dev/null +++ b/application/views/dashboard/dashboard_demo.php @@ -0,0 +1,31 @@ +load->view('templates/FHC-Header', + array( + 'title' => 'FH-Complete', + 'bootstrap5' => true, + 'fontawesome6' => true, + 'axios027' => true, + 'restclient' => true, + 'vue3' => true, + 'customJSModules' => ['public/js/apps/Dashboard.js'], + 'customCSSs' => [ + 'public/css/components/dashboard.css' + ], + 'navigationcomponent' => true + ) +); +?> + +
+ + + +
+
+

Dashboard

+
+ +
+
+ +load->view('templates/FHC-Footer'); ?> diff --git a/public/js/apps/Dashboard.js b/public/js/apps/Dashboard.js new file mode 100644 index 000000000..54a73441c --- /dev/null +++ b/public/js/apps/Dashboard.js @@ -0,0 +1,16 @@ +import {CoreNavigationCmpt} from '../components/navigation/Navigation.js'; +import CoreDashboard from '../components/Dashboard/Dashboard.js'; + +Vue.createApp({ + data: () => ({ + appSideMenuEntries: {} + }), + components: { + CoreNavigationCmpt, + CoreDashboard + /*, + "CoreFilterCmpt": CoreFilterCmpt, + "verticalsplit": verticalsplit, + "searchbar": searchbar*/ + } +}).mount('#main'); diff --git a/public/js/components/Base/Modal.js b/public/js/components/Base/Modal.js new file mode 100644 index 000000000..ad3785e62 --- /dev/null +++ b/public/js/components/Base/Modal.js @@ -0,0 +1,38 @@ +export default { + name: "BaseModal", + props: [ + "id", + "cModalClass", // optional: add custom classes to modal class + "cModalDialogClass" // optional: add custom classes to modal-dialog class + ], + onMounted() + { + const modal = new bootstrap.Modal(this.$refs.modal, {}) + modal.show(); + }, + template: ` + ` +} diff --git a/public/js/components/Base/Offcanvas.js b/public/js/components/Base/Offcanvas.js new file mode 100644 index 000000000..4db2592a6 --- /dev/null +++ b/public/js/components/Base/Offcanvas.js @@ -0,0 +1,32 @@ +export default { + name: "BaseOffcanvas", + props: [ + "id", + "cOffcanvasClass", // optional: add custom classes to offcanvas class + "closeFunc" + ], + computed: { + OffcanvasClass() { + return this.cOffcanvasClass || 'offcanvas-end'; // default: slide in from right to left + } + }, + template: ` +
+
+
+ +
+ +
+
+
+ +
+
+
` +} diff --git a/public/js/components/Bootstrap/Modal.js b/public/js/components/Bootstrap/Modal.js index 0e5472477..a74e6daa0 100644 --- a/public/js/components/Bootstrap/Modal.js +++ b/public/js/components/Bootstrap/Modal.js @@ -92,7 +92,7 @@ export default { -