diff --git a/server.js b/server.js new file mode 100644 index 0000000..9ede5dd --- /dev/null +++ b/server.js @@ -0,0 +1,5 @@ +var express = require('express'); +var path = require('path'); +var serveStatic = require('serve-static');app = express(); +app.use(serveStatic(__dirname));var port = process.env.PORT || 5000; +app.listen(port);console.log('server started '+ port); diff --git a/src/App.vue b/src/App.vue index 371cfdb..9ad088f 100644 --- a/src/App.vue +++ b/src/App.vue @@ -19,7 +19,7 @@ Log Out - + @@ -27,6 +27,7 @@ import Vue from 'vue' import { StorageManagement } from "@sebgroup/frontend-tools"; import router from './router' +import axios from 'axios' export default Vue.extend({ data: function() { @@ -36,7 +37,8 @@ export default Vue.extend({ role: "DOCTOR", hideSidebar: false, loggedin: false, - token: "" + token: "", + locale: "" } }, methods: { @@ -56,14 +58,30 @@ export default Vue.extend({ }, - created(){ + async created(){ const localStorage = new StorageManagement("LOCAL"); if(localStorage.getItem("JWT") == null){ this.loggedin = false; router.push("/login"); return; } - this.loggedin = true; + try{ + const response = await axios.get('http://localhost:9090/profile',{ + headers : { + 'Authorization': `Bearer ${window.localStorage.getItem('JWT')}` + } + }) + console.log(response); + if(response.data.code == 200){ + this.locale = response.data.user.locale; + this.loggedin = true; + }else{ + this.loggedin = false; + } + }catch(err){ + console.log(err); + this.loggedin = false; + } this.token = localStorage.getItem("JWT"); } }) diff --git a/src/router/index.js b/src/router/index.js index 7be0cce..c7513ef 100644 --- a/src/router/index.js +++ b/src/router/index.js @@ -1,31 +1,29 @@ import Vue from 'vue' -import Calendar from '../views/Calendar.vue' -import Patients from '../views/Patients.vue' import VueRouter from 'vue-router' -import Login from '../views/Login.vue' Vue.use(VueRouter) const routes = [ { - path: '/calendar', + path: 'calendar', name: 'Calendar', - component: Calendar + component: () => import('../views/Calendar.vue'), + props: true }, { - path: '/patients', + path: 'patients', name: 'Patients', - component: Patients + component: () => import('../views/Patients.vue') }, { path: '/login', name: 'login', - component: Login + component: () => import('../views/Login.vue') }, ] const router = new VueRouter({ - mode: 'history', + mode: 'hash', base: process.env.BASE_URL, routes }) diff --git a/src/views/Calendar.vue b/src/views/Calendar.vue index 900a63e..7f8dd8a 100644 --- a/src/views/Calendar.vue +++ b/src/views/Calendar.vue @@ -182,7 +182,31 @@ export default { console.log("ERROR PLACEHOLDER"); failureCallback(err) }); - } + }, + updateAspectRatio: function(){ + var w = this.$refs.calendarContainer.clientWidth; + var h = this.$refs.calendarContainer.clientHeight; + if(w < 640){ + this.$refs.fullCalendar.getApi().changeView('timeGridDay') + this.$refs.fullCalendar.getApi().setOption('aspectRatio', w / h + 0.04) + return; + } + this.$refs.fullCalendar.getApi().setOption('aspectRatio', w / h + 0.15) + } + }, + watch: { + locale: function(newLocale, _){ // eslint-disable-line no-unused-vars + this.$refs.fullCalendar.getApi().setOption('locale', newLocale) + } + }, + created() { + window.addEventListener("resize", this.updateAspectRatio); + }, + destroyed() { + window.removeEventListener("resize", this.updateAspectRatio); + }, + mounted() { + this.updateAspectRatio() } }