From 5b385d376e23d2ecd34428544d5de6ddd29d752e Mon Sep 17 00:00:00 2001 From: SimonGschnell Date: Tue, 14 Nov 2023 11:52:45 +0100 Subject: [PATCH] creating the controller/view/api base --- application/controllers/Cis/Profil.php | 67 +++++++++++++++++++++++ application/views/Cis/Profil.php | 18 ++++++ public/js/apps/Cis/ProfilApp.js | 24 ++++++++ public/js/apps/api/dummyapi.php | 13 +++++ public/js/apps/api/fhcapifactory.js | 4 +- public/js/apps/api/userdata.js | 13 +++++ public/js/components/Cis/Profil/Profil.js | 27 +++++++++ 7 files changed, 165 insertions(+), 1 deletion(-) create mode 100644 application/controllers/Cis/Profil.php create mode 100644 application/views/Cis/Profil.php create mode 100644 public/js/apps/Cis/ProfilApp.js create mode 100644 public/js/apps/api/dummyapi.php create mode 100644 public/js/apps/api/userdata.js create mode 100644 public/js/components/Cis/Profil/Profil.js diff --git a/application/controllers/Cis/Profil.php b/application/controllers/Cis/Profil.php new file mode 100644 index 000000000..f24216bfd --- /dev/null +++ b/application/controllers/Cis/Profil.php @@ -0,0 +1,67 @@ + ['student/anrechnung_beantragen:r','user:r'], // TODO(chris): permissions? + 'getUser' => ['student/anrechnung_beantragen:r','user:r'] + ]); + } + + // ----------------------------------------------------------------------------------------------------------------- + // Public methods + + /** + * @return void + */ + public function index() + { + //echo = getAuthUID(); + + $this->load->view('Cis/Profil', ["uid" => getAuthUID()]); + } + + public function getUser() + { + $myObj = new stdClass(); + $myObj->name = "John"; + $myObj->age = 30; + $myObj->city = "New York"; + echo json_encode($myObj); + } + + /* + public function _remap($param) + { + /$uid wird als global variable weiter gegeben + /get the data from the database with the uid + /give the data to the view + /put the queried data in global array and access properties needed in the specific view $profile_information = array() + /$this -> load->view('Cis/StudentProfile', ["uid" => $uid]) + + + if ($param === 'some_method') + { + echo "if"; + } + else + { + echo "else"; + } + }*/ + + + +} diff --git a/application/views/Cis/Profil.php b/application/views/Cis/Profil.php new file mode 100644 index 000000000..c8207f0c5 --- /dev/null +++ b/application/views/Cis/Profil.php @@ -0,0 +1,18 @@ + 'Stundenplan', + 'customJSModules' => ['public/js/apps/Cis/ProfilApp.js'], + 'customCSSs' => ['public/css/components/calendar.css'] +); + +$this->load->view('templates/CISHTML-Header', $includesArray); +?> + +
+

Profil

+
+

+ +
+ +load->view('templates/CISHTML-Footer', $includesArray); ?> diff --git a/public/js/apps/Cis/ProfilApp.js b/public/js/apps/Cis/ProfilApp.js new file mode 100644 index 000000000..b6c727e88 --- /dev/null +++ b/public/js/apps/Cis/ProfilApp.js @@ -0,0 +1,24 @@ +import Profil from "../../components/Cis/Profil/Profil.js"; + +import fhcapifactory from "../api/fhcapifactory.js"; + +Vue.$fhcapi = fhcapifactory; + +const app = Vue.createApp({ + components: { + Profil, + }, + data() { + return { + stunden: [], + events: null + } + }, + methods: { + testsearch: function() { + return Vue.$fhcapi.UserData.getUser(); + } + }, + +}); +app.mount('#content'); \ No newline at end of file diff --git a/public/js/apps/api/dummyapi.php b/public/js/apps/api/dummyapi.php new file mode 100644 index 000000000..515e72bcf --- /dev/null +++ b/public/js/apps/api/dummyapi.php @@ -0,0 +1,13 @@ + \ No newline at end of file diff --git a/public/js/apps/api/fhcapifactory.js b/public/js/apps/api/fhcapifactory.js index c1f1e0d5c..f75b03482 100644 --- a/public/js/apps/api/fhcapifactory.js +++ b/public/js/apps/api/fhcapifactory.js @@ -1,5 +1,7 @@ import Search from "./search.js"; +import UserData from "./userdata.js"; export default { - "Search": Search + "Search": Search, + "UserData": UserData }; diff --git a/public/js/apps/api/userdata.js b/public/js/apps/api/userdata.js new file mode 100644 index 000000000..d36628561 --- /dev/null +++ b/public/js/apps/api/userdata.js @@ -0,0 +1,13 @@ +export default { + + getUser: function() { + const url = FHC_JS_DATA_STORAGE_OBJECT.app_root + + 'Cis/Profil/getUser'; + return axios.get(url); + }, + getUserDumy: function(){ + const url = FHC_JS_DATA_STORAGE_OBJECT.app_root + + 'public/js/apps/api/dummyapi.php/getUser'; + return axios.get(url); + } +}; \ No newline at end of file diff --git a/public/js/components/Cis/Profil/Profil.js b/public/js/components/Cis/Profil/Profil.js new file mode 100644 index 000000000..546767c5c --- /dev/null +++ b/public/js/components/Cis/Profil/Profil.js @@ -0,0 +1,27 @@ + + +export default { + + data: function() { + return { + person: null, + } + }, + methods: { + testsearch: function() { + + } + }, + created(){ + this.$parent.testsearch().then((res) => { + this.person = res.data; + }); + }, + + template: ` +
+

test

+ {{JSON.stringify(person)}} +
+ `, +}; \ No newline at end of file