Browse Source

Github created

production
Yiğit Çolakoğlu 4 years ago
parent
commit
d96f011d14
4 changed files with 59 additions and 14 deletions
  1. +5
    -0
      server.js
  2. +22
    -4
      src/App.vue
  3. +7
    -9
      src/router/index.js
  4. +25
    -1
      src/views/Calendar.vue

+ 5
- 0
server.js View File

@ -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);

+ 22
- 4
src/App.vue View File

@ -19,7 +19,7 @@
<a :class="{'bg-transparent dark-mode:bg-transparent': selected != 'logout', 'bg-gray-200 dark-mode:text-white dark-mode:bg-gray-600': selected=='logout'}" class="block px-4 py-2 mt-2 text-sm font-semibold text-gray-900 rounded-lg dark-mode:hover:bg-gray-600 dark-mode:hover:text-white dark-mode:text-gray-200 hover:text-gray-900 focus:text-gray-900 hover:bg-gray-200 focus:outline-none focus:shadow-outline" @click="selectPage('logout')">Log Out</a>
</nav>
</div>
<router-view class="flex-1 w-5/6"></router-view>
<router-view :locale="locale" class="flex-1 w-5/6"></router-view>
</div>
</template>
@ -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");
}
})


+ 7
- 9
src/router/index.js View File

@ -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
})


+ 25
- 1
src/views/Calendar.vue View File

@ -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()
}
}


Loading…
Cancel
Save