From d92ad0a6c6669055d03bcd586761da0f8b2e638d Mon Sep 17 00:00:00 2001 From: SimonGschnell Date: Fri, 14 Jun 2024 14:42:02 +0200 Subject: [PATCH] links the ort_kurzbz from the Stundenplan in the Dashboard to the Ort Information Content --- .../controllers/api/frontend/v1/Ort.php | 71 +++++++++++++++++++ application/models/ressource/Ort_model.php | 12 ++++ public/js/api/fhcapifactory.js | 4 +- public/js/api/ort.js | 10 +++ public/js/apps/Dashboard/Admin.js | 2 + public/js/apps/Dashboard/Fhc.js | 2 + .../components/DashboardWidget/Stundenplan.js | 21 +++++- 7 files changed, 119 insertions(+), 3 deletions(-) create mode 100644 application/controllers/api/frontend/v1/Ort.php create mode 100644 public/js/api/ort.js diff --git a/application/controllers/api/frontend/v1/Ort.php b/application/controllers/api/frontend/v1/Ort.php new file mode 100644 index 000000000..2bc0f945b --- /dev/null +++ b/application/controllers/api/frontend/v1/Ort.php @@ -0,0 +1,71 @@ +. + */ + +if (! defined('BASEPATH')) exit('No direct script access allowed'); + +/** + * This controller operates between (interface) the JS (GUI) and the SearchBarLib (back-end) + * Provides data to the ajax get calls about the searchbar component + * This controller works with JSON calls on the HTTP GET and the output is always JSON + */ +class Ort extends FHCAPI_Controller +{ + + /** + * Object initialization + */ + public function __construct() + { + // NOTE(chris): additional permission checks will be done in SearchBarLib + parent::__construct([ + 'ContentID' => self::PERM_LOGGED + ]); + + $this->load->model('ressource/Ort_model', 'OrtModel'); + + } + + //------------------------------------------------------------------------------------------------------------------ + // Public methods + + /** + * Gets a JSON body via HTTP POST and provides the parameters + */ + public function ContentID() + { + // if error + //$this->terminateWithError(SearchBarLib::ERROR_WRONG_JSON, self::ERROR_TYPE_GENERAL); + + $ort_kurzbz = $this->input->get('ort_kurzbz',TRUE); + + if(!$ort_kurzbz){ + $this->terminateWithError("missing ort_kurzbz parameter", self::ERROR_TYPE_GENERAL); + } + + $result = $this->OrtModel->getContentID($ort_kurzbz); + + if(isError($result)){ + $this->terminateWithError(getError($result), self::ERROR_TYPE_GENERAL); + } + + $result = hasData($result) ? current(getData($result)) : null; + + $this->terminateWithSuccess($result->content_id ?? NULL); + } +} + diff --git a/application/models/ressource/Ort_model.php b/application/models/ressource/Ort_model.php index 59b213a54..de0c8e331 100755 --- a/application/models/ressource/Ort_model.php +++ b/application/models/ressource/Ort_model.php @@ -20,4 +20,16 @@ class Ort_model extends DB_Model return $this->OrtModel->loadWhere(array("raumtyp_kurzbz" => $raumtyp_kurzbz)); } + + public function getContentID($ort_kurzbz) + { + + return $this->execReadOnlyQuery(" + SELECT content_id + FROM public.tbl_ort + WHERE ort_kurzbz = ?; + ",[$ort_kurzbz]); + + } + } \ No newline at end of file diff --git a/public/js/api/fhcapifactory.js b/public/js/api/fhcapifactory.js index 41c89ef50..a41730548 100644 --- a/public/js/api/fhcapifactory.js +++ b/public/js/api/fhcapifactory.js @@ -20,11 +20,13 @@ import phrasen from "./phrasen.js"; import navigation from "./navigation.js"; import filter from "./filter.js"; import studstatus from "./studstatus.js"; +import ort from "./ort.js"; export default { search, phrasen, navigation, filter, - studstatus + studstatus, + ort, }; diff --git a/public/js/api/ort.js b/public/js/api/ort.js new file mode 100644 index 000000000..32f114565 --- /dev/null +++ b/public/js/api/ort.js @@ -0,0 +1,10 @@ +export default { + getContentID($ort_kurbz) { + return this.$fhcApi.get( + FHC_JS_DATA_STORAGE_OBJECT.app_root + + FHC_JS_DATA_STORAGE_OBJECT.ci_router + + "/api/frontend/v1/Ort/ContentID", + { ort_kurzbz: $ort_kurbz } + ); + }, +} \ No newline at end of file diff --git a/public/js/apps/Dashboard/Admin.js b/public/js/apps/Dashboard/Admin.js index 426a2fce4..70254c955 100755 --- a/public/js/apps/Dashboard/Admin.js +++ b/public/js/apps/Dashboard/Admin.js @@ -1,5 +1,6 @@ import {CoreNavigationCmpt} from '../../components/navigation/Navigation.js'; import DashboardAdmin from '../../components/Dashboard/Admin.js'; +import FhcApi from '../../plugin/FhcApi.js'; const app = Vue.createApp({ data: () => ({ @@ -11,4 +12,5 @@ const app = Vue.createApp({ } }); app.config.unwrapInjectedRef = true; +app.use(FhcApi); app.mount('#main'); diff --git a/public/js/apps/Dashboard/Fhc.js b/public/js/apps/Dashboard/Fhc.js index ebcbb4b78..89d1e2c1e 100755 --- a/public/js/apps/Dashboard/Fhc.js +++ b/public/js/apps/Dashboard/Fhc.js @@ -1,4 +1,5 @@ import FhcDashboard from '../../components/Dashboard/Dashboard.js'; +import FhcApi from '../../plugin/FhcApi.js'; const app = Vue.createApp({ data: () => ({ @@ -9,4 +10,5 @@ const app = Vue.createApp({ } }); app.config.unwrapInjectedRef = true; +app.use(FhcApi); app.mount('#content'); diff --git a/public/js/components/DashboardWidget/Stundenplan.js b/public/js/components/DashboardWidget/Stundenplan.js index b74095b32..91b8d48cd 100755 --- a/public/js/components/DashboardWidget/Stundenplan.js +++ b/public/js/components/DashboardWidget/Stundenplan.js @@ -19,6 +19,7 @@ export default { } }, computed: { + currentEvents() { return (this.events || []).filter(evt => evt.end < this.dayAfterCurrentDay && evt.start >= this.currentDay); }, @@ -29,12 +30,28 @@ export default { } }, methods: { + printEntry: function(item){ + console.log(item); + }, selectDay(day) { this.currentDay = day; this.minimized = true; + }, + showRoomInfo: function($ort_kurzbz){ + + this.$fhcApi.factory.ort.getContentID($ort_kurzbz).then(res =>{ + + window.location.href = FHC_JS_DATA_STORAGE_OBJECT.app_root + + FHC_JS_DATA_STORAGE_OBJECT.ci_router + + "/CisHtml/Cms/content/" + res.data; + + }) } + }, created() { + + this.$emit('setConfig', false); axios .get(this.apiurl + '/components/Cis/Stundenplan/Stunden').then(res => { @@ -67,11 +84,11 @@ export default {
-
+
{{evt.title}}
- {{evt.ort_kurzbz}} + {{evt.ort_kurzbz}} {{evt.start.toLocaleTimeString(undefined, {hour:'numeric',minute:'numeric'})}}-{{evt.end.toLocaleTimeString(undefined, {hour:'numeric',minute:'numeric'})}}