mirror of
https://github.com/FH-Complete/FHC-Core.git
synced 2026-07-19 16:02:15 +00:00
uses the new fhcApi factory to make the roomInformation get request from the frontent/v1/stundenplan api and uses the CalendarDate class to get the first day of the week and the last day of the week to make the request for the room information over the whole week
This commit is contained in:
@@ -0,0 +1,90 @@
|
||||
<?php
|
||||
/**
|
||||
* Copyright (C) 2024 fhcomplete.org
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
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 Stundenplan extends FHCAPI_Controller
|
||||
{
|
||||
|
||||
/**
|
||||
* Object initialization
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
|
||||
parent::__construct([
|
||||
'roomInformation' => self::PERM_LOGGED,
|
||||
'Stunden' => self::PERM_LOGGED
|
||||
]);
|
||||
|
||||
// Load the library ...
|
||||
// $this->load->library('');
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------------------------------------------------
|
||||
// Public methods
|
||||
|
||||
/**
|
||||
* Gets a JSON body via HTTP POST and provides the parameters
|
||||
*/
|
||||
public function roomInformation()
|
||||
{
|
||||
// storing the get parameter in local variables
|
||||
$ort_kurzbz = $this->input->get('ort_kurzbz', TRUE);
|
||||
$start_date = $this->input->get('start_date', TRUE);
|
||||
$end_date = $this->input->get('end_date', TRUE);
|
||||
|
||||
$this->addMeta("ort",$ort_kurzbz);
|
||||
$this->addMeta("start date",$start_date);
|
||||
$this->addMeta("end date",$end_date);
|
||||
$this->addMeta("testKey","testValue");
|
||||
|
||||
$this->load->model('ressource/Stundenplan_model', 'StundenplanModel');
|
||||
|
||||
$result = $this->StundenplanModel->getRoomDataOnDay($ort_kurzbz,$start_date,$end_date);
|
||||
if(isError($result)){
|
||||
$this->terminateWithError(getError($result), self::ERROR_TYPE_GENERAL);
|
||||
}
|
||||
|
||||
$result = hasData($result) ? getData($result) : [];
|
||||
//echo($this->db->last_query());
|
||||
$this->terminateWithSuccess($result);
|
||||
|
||||
}
|
||||
|
||||
public function Stunden()
|
||||
{
|
||||
$this->load->model('ressource/Stunde_model', 'StundeModel');
|
||||
|
||||
$result = $this->StundeModel->load();
|
||||
|
||||
if (isError($result)){
|
||||
$this->terminateWithError(getError($result), self::ERROR_TYPE_GENERAL);
|
||||
}
|
||||
|
||||
$result = hasData($result)? getData($result) : [];
|
||||
|
||||
$this->terminateWithSuccess($result);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -69,9 +69,6 @@ class Stundenplan extends Auth_Controller
|
||||
public function RoomInformation()
|
||||
{
|
||||
$this->load->model('ressource/Stundenplan_model', 'StundenplanModel');
|
||||
|
||||
|
||||
|
||||
|
||||
$result = $this->StundenplanModel->getRoomDataOnDay('EDV_A2.06','2024-05-21');
|
||||
$result = hasData($result) ? getData($result) : [];
|
||||
|
||||
@@ -18,7 +18,7 @@ class Stundenplan_model extends DB_Model
|
||||
*
|
||||
* @return stdClass
|
||||
*/
|
||||
public function getRoomDataOnDay($ort_kurzbz,$date){
|
||||
public function getRoomDataOnDay($ort_kurzbz='EDV_A2.06',$start_date='2024-05-21',$end_date='2024-05-21'){
|
||||
|
||||
|
||||
$this->addSelect(['*',"CONCAT(UPPER(sp.stg_typ),UPPER(sp.stg_kurzbz),'-',COALESCE(CAST(sp.semester AS varchar),'/'),COALESCE(CAST(sp.verband AS varchar),'/')) as stg","lektor","CONCAT(lehrfach,'-',lehrform) as lv_info" ]);
|
||||
@@ -28,12 +28,13 @@ class Stundenplan_model extends DB_Model
|
||||
$res = $this->loadWhere(['ort_kurzbz'=>$ort_kurzbz,'datum'=>$date]);
|
||||
$res = hasData($res) ? getData($res): null;
|
||||
return $res; */
|
||||
$this->db->where('ort_kurzbz','EDV_A2.06',true);
|
||||
$this->db->where('datum >=','2024-05-21',true);
|
||||
$this->db->where('ort_kurzbz',$ort_kurzbz,true);
|
||||
$this->db->where('datum >=',$start_date,true);
|
||||
$this->db->where('datum <=',$end_date,true);
|
||||
|
||||
$query = $this->db->get_compiled_select('lehre.vw_stundenplan sp');
|
||||
|
||||
return $this->execQuery($query, [$ort_kurzbz, $date]);
|
||||
return $this->execQuery($query, [$ort_kurzbz, $start_date, $end_date]);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -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 stundenplan from "./studenplan.js";
|
||||
|
||||
export default {
|
||||
search,
|
||||
phrasen,
|
||||
navigation,
|
||||
filter,
|
||||
studstatus
|
||||
studstatus,
|
||||
stundenplan,
|
||||
};
|
||||
|
||||
@@ -0,0 +1,15 @@
|
||||
|
||||
export default {
|
||||
getRoomInfo(ort_kurzbz, start_date, end_date) {
|
||||
return this.$fhcApi.get(
|
||||
'/api/frontend/v1/Stundenplan/roomInformation',
|
||||
{ ort_kurzbz, start_date, end_date}
|
||||
);
|
||||
},
|
||||
getStunden() {
|
||||
return this.$fhcApi.get(
|
||||
'/api/frontend/v1/Stundenplan/Stunden',
|
||||
{}
|
||||
);
|
||||
},
|
||||
};
|
||||
@@ -1,4 +1,6 @@
|
||||
import FhcCalendar from "../../components/Calendar/Calendar.js";
|
||||
import CalendarDate from "../../composables/CalendarDate.js";
|
||||
import FhcApi from "../../plugin/FhcApi.js";
|
||||
|
||||
const app = Vue.createApp({
|
||||
components: {
|
||||
@@ -8,25 +10,26 @@ const app = Vue.createApp({
|
||||
return {
|
||||
stunden: [],
|
||||
events: null,
|
||||
testDate: new Date('2024-05-21'),
|
||||
}
|
||||
calendarWeek: new CalendarDate(new Date()),
|
||||
}
|
||||
},
|
||||
computed:{
|
||||
currentDate: function(){
|
||||
return new Date(this.calendarWeek.y, this.calendarWeek.m, this.calendarWeek.d);
|
||||
},
|
||||
},
|
||||
created() {
|
||||
axios.get(FHC_JS_DATA_STORAGE_OBJECT.app_root + FHC_JS_DATA_STORAGE_OBJECT.ci_router + '/components/Cis/Stundenplan/Stunden').then(res => {
|
||||
|
||||
|
||||
res.data.retval.forEach(std => {
|
||||
|
||||
this.$fhcApi.factory.stundenplan.getStunden().then(res =>{
|
||||
res.data.forEach(std => {
|
||||
this.stunden[std.stunde] = std; // TODO(chris): geht besser
|
||||
});
|
||||
console.log("this are the loaded stunden", this.stunden)
|
||||
|
||||
axios.get(FHC_JS_DATA_STORAGE_OBJECT.app_root + FHC_JS_DATA_STORAGE_OBJECT.ci_router + '/components/Cis/Stundenplan/RoomInformation').then(res => {
|
||||
this.$fhcApi.factory.stundenplan.getRoomInfo('EDV_A6.09', this.calendarWeek.firstDayOfWeek, this.calendarWeek.lastDayOfWeek).then(res =>{
|
||||
let events;
|
||||
console.log(" this is the res of the api call room information",res);
|
||||
if (res.data && res.data.forEach) {
|
||||
res.data.forEach((el, i) => {
|
||||
|
||||
console.log(el,"this is the element that gets changed")
|
||||
el.id = i;
|
||||
el.color = '#' + (el.farbe || 'CCCCCC');
|
||||
el.start = new Date(el.datum + ' ' + this.stunden[el.stunde].beginn);
|
||||
@@ -35,45 +38,16 @@ const app = Vue.createApp({
|
||||
if (el.lehrform)
|
||||
el.title += '-' + el.lehrform;
|
||||
});
|
||||
events = res.data;
|
||||
//console.log("this are the room events",events)
|
||||
this.events = events;
|
||||
|
||||
this.events = res.data;
|
||||
}
|
||||
}).catch((e)=>{console.log(e,"this is the exception")})
|
||||
});
|
||||
|
||||
/* axios.get(FHC_JS_DATA_STORAGE_OBJECT.app_root + FHC_JS_DATA_STORAGE_OBJECT.ci_router + '/components/Cis/Stundenplan').then(res => {
|
||||
|
||||
let events;
|
||||
console.log(" this is the res of the api call stundenplan",res);
|
||||
if (res.data.retval && res.data.retval.forEach) {
|
||||
res.data.retval.forEach((el, i) => {
|
||||
el.id = i;
|
||||
el.color = '#' + (el.farbe || 'CCCCCC');
|
||||
el.start = new Date(el.datum + ' ' + this.stunden[el.stunde].beginn);
|
||||
el.end = new Date(el.datum + ' ' + this.stunden[el.stunde].ende);
|
||||
el.title = el.lehrfach;
|
||||
if (el.lehrform)
|
||||
el.title += '-' + el.lehrform;
|
||||
});
|
||||
events = res.data.retval;
|
||||
console.log("this are the events of the stundenplan",events)
|
||||
}
|
||||
|
||||
// TODO(chris): do we need that
|
||||
|
||||
}).catch((e)=>{console.log(e,"this is the exception")})
|
||||
|
||||
|
||||
*/
|
||||
|
||||
|
||||
})
|
||||
});
|
||||
|
||||
},
|
||||
template: /*html*/`
|
||||
<div>
|
||||
<!--initialDate="2023-5-12"-->
|
||||
<fhc-calendar v-slot="{event}" :initialDate="testDate" :events="events" initial-mode="week" show-weeks>
|
||||
<fhc-calendar v-slot="{event}" :initialDate="currentDate" :events="events" initial-mode="week" show-weeks>
|
||||
<div class="d-flex flex-column align-items-center justify-content-evenly h-100">
|
||||
<span>{{event.orig.lv_info}}</span>
|
||||
<span>{{event.orig.stg}}</span>
|
||||
@@ -84,4 +58,5 @@ const app = Vue.createApp({
|
||||
`,
|
||||
});
|
||||
app.config.unwrapInjectedRef = true;
|
||||
app.use(FhcApi);
|
||||
app.mount('#content');
|
||||
@@ -41,7 +41,6 @@ export default {
|
||||
},
|
||||
eventsPerDayAndHour() {
|
||||
const res = {};
|
||||
console.log("this are the days",this.days)
|
||||
this.days.forEach(day => {
|
||||
let key = day.toDateString();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user