From a0fb34420e7e2d20446f69ba0cabc01ccf759b55 Mon Sep 17 00:00:00 2001 From: SimonGschnell Date: Tue, 27 May 2025 14:30:34 +0200 Subject: [PATCH 01/12] fix(Stundenplan API):corrects little bug with if statement check --- application/controllers/api/frontend/v1/Stundenplan.php | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/application/controllers/api/frontend/v1/Stundenplan.php b/application/controllers/api/frontend/v1/Stundenplan.php index 61a9e8f54..35b7ccc56 100644 --- a/application/controllers/api/frontend/v1/Stundenplan.php +++ b/application/controllers/api/frontend/v1/Stundenplan.php @@ -81,14 +81,11 @@ class Stundenplan extends FHCAPI_Controller $lv_id = $this->input->get('lv_id', TRUE); $stundenplan_events = $this->stundenplanlib->getStundenplan($start_date,$end_date,$lv_id); + $stundenplan_events = $this->getDataOrTerminateWithError($stundenplan_events); if( is_null($stundenplan_events) || isEmptyArray($stundenplan_events) ) { $stundenplan_events = array(); } - else - { - $stundenplan_events = $this->getDataOrTerminateWithError($stundenplan_events); - } // fetching moodle events $moodle_events = []; From a5bb72baf6fe2337614453761f2561620ff2eb9b Mon Sep 17 00:00:00 2001 From: SimonGschnell Date: Wed, 28 May 2025 12:30:38 +0200 Subject: [PATCH 02/12] feature(Stundenplan Moodle Events Dependency Injection): injects moodle components dependency to the Stundenplan --- .../api/frontend/v1/RendererLoader.php | 72 +++++++++++++++ public/css/components/calendar.css | 75 ++++++++++++++++ public/js/api/factory/renderers.js | 12 +++ public/js/apps/Dashboard/Fhc.js | 16 +++- .../EventTypes/lehreinheitEvent.js | 30 +++++++ .../components/Cis/Stundenplan/Stundenplan.js | 89 +++++-------------- public/js/helpers/moodleSVG.js | 5 -- 7 files changed, 226 insertions(+), 73 deletions(-) create mode 100644 application/controllers/api/frontend/v1/RendererLoader.php create mode 100644 public/js/api/factory/renderers.js create mode 100644 public/js/components/Cis/Stundenplan/EventTypes/lehreinheitEvent.js delete mode 100644 public/js/helpers/moodleSVG.js diff --git a/application/controllers/api/frontend/v1/RendererLoader.php b/application/controllers/api/frontend/v1/RendererLoader.php new file mode 100644 index 000000000..dc16bb3fc --- /dev/null +++ b/application/controllers/api/frontend/v1/RendererLoader.php @@ -0,0 +1,72 @@ +. + */ + +if (! defined('BASEPATH')) exit('No direct script access allowed'); + +use CI3_Events as Events; + +class RendererLoader extends FHCAPI_Controller +{ + + /** + * Object initialization + */ + public function __construct() + { + + parent::__construct([ + 'GetRenderers' => self::PERM_LOGGED, + + ]); + + $this->load->library('LogLib'); + $this->loglib->setConfigs(array( + 'classIndex' => 5, + 'functionIndex' => 5, + 'lineIndex' => 4, + 'dbLogType' => 'API', // required + 'dbExecuteUser' => 'RESTful API' + )); + + + } + + //------------------------------------------------------------------------------------------------------------------ + // Public methods + + /** + * fetches Stundenplan and Moodle events together + * @access public + * + */ + public function GetRenderers(){ + $renderer_paths = []; + Events::trigger( + 'loadRenderers', + function & () use (&$renderer_paths) + { + return $renderer_paths; + } + ); + $this->terminateWithSuccess($renderer_paths); + } + + + + +} diff --git a/public/css/components/calendar.css b/public/css/components/calendar.css index 1de5e575b..202768d90 100644 --- a/public/css/components/calendar.css +++ b/public/css/components/calendar.css @@ -320,4 +320,79 @@ .selectedEvent { background-color: #00649c !important; color: white; +} + + +.dayPageContainer, .weekPageContainer{ + container-type: inline-size; +} + +.dayPageContainer .lehreinheitEventContent, +.weekPageContainer .lehreinheitEventContent { + display: flex; + flex-direction: column; +} + +.dayPageContainer .moodleEventContent, +.weekPageContainer .moodleEventContent{ + display: flex; + flex-direction: row; +} + +.dayPageContainer .lehreinheitEventContent{ + flex-grow:1; + align-items: center; + font-size: 0.875rem; + font-weight: 400; + line-height:1.25; +} + +.dayPageContainer .lehreinheitEventHeader { + display: flex; + flex-direction: column; + padding: 1rem; + border-right: 1px solid gray; +} + +.dayPageContainer .moodleEventContent { + align-items: center; + font-size: 0.875rem; + font-weight: 400; + line-height: 1.25; + width:100%; +} + +.weekPageContainer .moodleEventContent { + align-items: center; + font-size: 0.875rem; + font-weight: 400; + line-height: 1.25; + width: 100%; +} + +.weekPageContainer .lehreinheitEventHeader { + display: flex; + flex-direction: column; + padding: 1rem; + border-right: 1px solid gray; +} + +.weekPageContainer .lehreinheitEventContent { + flex-grow: 1; + align-items: center; + font-size: 0.875rem; + font-weight: 400; + line-height: 1.25; +} + + +@container( min-width: 500px){ + .dayPageContainer .lehreinheitEventContent, + .weekPageContainer .lehreinheitEventContent { + flex-direction: row; + } + + .dayPageContainer .lehreinheitEventContent{ + justify-content: space-evenly; + } } \ No newline at end of file diff --git a/public/js/api/factory/renderers.js b/public/js/api/factory/renderers.js new file mode 100644 index 000000000..fee81e4df --- /dev/null +++ b/public/js/api/factory/renderers.js @@ -0,0 +1,12 @@ + +export default { + + loadRenderers() { + return { + method: 'get', + url: '/api/frontend/v1/RendererLoader/GetRenderers', + params: { + } + }; + }, +} \ No newline at end of file diff --git a/public/js/apps/Dashboard/Fhc.js b/public/js/apps/Dashboard/Fhc.js index fc25fbdfe..cdd69362c 100644 --- a/public/js/apps/Dashboard/Fhc.js +++ b/public/js/apps/Dashboard/Fhc.js @@ -15,6 +15,8 @@ import AbgabetoolMitarbeiter from "../../components/Cis/Abgabetool/AbgabetoolMit import DeadlineOverview from "../../components/Cis/Abgabetool/DeadlineOverview.js"; import Studium from "../../components/Cis/Studium/Studium.js"; +import ApiRenderers from '../../api/factory/renderers.js'; + const ciPath = FHC_JS_DATA_STORAGE_OBJECT.app_root.replace(/(https:|)(^|\/\/)(.*?\/)/g, '') + FHC_JS_DATA_STORAGE_OBJECT.ci_router; const router = VueRouter.createRouter({ @@ -234,7 +236,8 @@ const router = VueRouter.createRouter({ const app = Vue.createApp({ name: 'FhcApp', data: () => ({ - appSideMenuEntries: {} + appSideMenuEntries: {}, + renderers: {}, }), components: {}, computed: { @@ -244,7 +247,8 @@ const app = Vue.createApp({ }, provide() { return { // provide injectable & watchable language property - language: Vue.computed(() => this.$p.user_language) + language: Vue.computed(() => this.$p.user_language), + renderers: Vue.computed(() => this.renderers), } }, methods: { @@ -282,6 +286,14 @@ const app = Vue.createApp({ } } }, + async created(){ + await this.$api + .call(ApiRenderers.loadRenderers()) + .then(res => res.data) + .then(data => { + this.renderers = data; + }); + }, mounted() { document.addEventListener('click', this.handleClick); }, diff --git a/public/js/components/Cis/Stundenplan/EventTypes/lehreinheitEvent.js b/public/js/components/Cis/Stundenplan/EventTypes/lehreinheitEvent.js new file mode 100644 index 000000000..088fb42f9 --- /dev/null +++ b/public/js/components/Cis/Stundenplan/EventTypes/lehreinheitEvent.js @@ -0,0 +1,30 @@ +export default { + methods:{ + convertTime: function ([hour, minute]) { + let date = new Date(); + date.setHours(hour); + date.setMinutes(minute); + // returns date string as hh:mm + return date.toLocaleTimeString(this.$p.user_locale, { hour: '2-digit', minute: '2-digit', hour12: false }); + + }, + }, + props:{ + event: { + type:Object, + required:true, + }, + }, + template: ` +
+ {{convertTime(event.beginn.split(":"))}} + {{convertTime(event.ende.split(":"))}} +
+
+ {{event.topic}} + {{lektor.kurzbz}} + {{event.ort_kurzbz}} +
+ + `, +} diff --git a/public/js/components/Cis/Stundenplan/Stundenplan.js b/public/js/components/Cis/Stundenplan/Stundenplan.js index efb8c06ea..5b42d54f8 100644 --- a/public/js/components/Cis/Stundenplan/Stundenplan.js +++ b/public/js/components/Cis/Stundenplan/Stundenplan.js @@ -3,11 +3,12 @@ import CalendarDate from "../../../composables/CalendarDate.js"; import LvModal from "../Mylv/LvModal.js"; import LvInfo from "../Mylv/LvInfo.js" import LvMenu from "../Mylv/LvMenu.js" -import moodleSvg from "../../../helpers/moodleSVG.js" +import lehreinheitEvent from "./EventTypes/lehreinheitEvent.js" import ApiStundenplan from '../../../api/factory/stundenplan.js'; import ApiAuthinfo from '../../../api/factory/authinfo.js'; + export const DEFAULT_MODE_STUNDENPLAN = 'Week' const Stundenplan = { @@ -46,6 +47,7 @@ const Stundenplan = { eventMaxHeight: this.eventMaxHeight } }, + inject:["renderers"], watch: { weekFirstDay: { handler: async function (newValue) { @@ -69,7 +71,7 @@ const Stundenplan = { } }, components: { - FhcCalendar, LvModal, LvMenu, LvInfo, moodleSvg + FhcCalendar, LvModal, LvMenu, LvInfo, lehreinheitEvent, }, computed:{ downloadLinks: function(){ @@ -105,17 +107,16 @@ const Stundenplan = { }, }, methods:{ + renderComponent(name){ + switch(name){ + case 'lehreinheitEvent': return lehreinheitEvent; + default: return !this.renderers? null : Vue.defineAsyncComponent(() => import(this.renderers[name])) + } + }, fetchStudiensemesterDetails: async function (date) { return this.$api.call(ApiStundenplan.studiensemesterDateInterval(date)); }, - convertTime: function([hour,minute]){ - let date = new Date(); - date.setHours(hour); - date.setMinutes(minute); - // returns date string as hh:mm - return date.toLocaleTimeString(this.$p.user_locale, { hour: '2-digit', minute: '2-digit', hour12:false}); - - }, + setSelectedEvent: function (event) { this.currentlySelectedEvent = event; }, @@ -248,6 +249,7 @@ const Stundenplan = { .then(data => { this.uid = data.uid; }); + // this.loadEvents(); }, beforeUnmount() { @@ -285,68 +287,23 @@ const Stundenplan = { - +