Skip to content
Snippets Groups Projects
Commit af146891 authored by robinwilliam.hundt's avatar robinwilliam.hundt
Browse files

More work on student-page / minor Log & Layout refactor

parent dac1282a
No related branches found
No related tags found
1 merge request!23Resolve "Logout of tutors after inactivity"
...@@ -35,6 +35,7 @@ ...@@ -35,6 +35,7 @@
<script> <script>
import {mapActions} from 'vuex'
export default { export default {
name: 'grady-login', name: 'grady-login',
data () { data () {
...@@ -47,10 +48,17 @@ ...@@ -47,10 +48,17 @@
} }
}, },
methods: { methods: {
...mapActions([
'getJWTToken',
'getExamModule',
'getUserRole'
]),
submit () { submit () {
this.$store.dispatch('getJWTToken', this.credentials).then(response => { this.getJWTToken(this.credentials).then(() => {
this.$router.push('/student/') this.$router.push('/student/')
}).catch(_ => { this.getExamModule()
this.getUserRole()
}).catch(() => {
this.error = this.$store.state.error this.error = this.$store.state.error
}) })
} }
......
...@@ -4,26 +4,29 @@ ...@@ -4,26 +4,29 @@
fixed fixed
clipped clipped
app app
v-model="drawer" permanent
:mini-variant.sync="mini"
> >
<v-toolbar flat> <v-toolbar flat>
<v-list> <v-list>
<v-list-tile> <v-list-tile>
<v-list-tile-title class="title"> <v-list-tile-action v-if="mini">
<v-btn icon @click.native.stop="mini = !mini">
<v-icon>chevron_right</v-icon>
</v-btn>
</v-list-tile-action>
<v-list-tile-content class="title">
{{ examInstance }} {{ examInstance }}
</v-list-tile-title> </v-list-tile-content>
<v-list-tile-action>
<v-btn icon @click.native.stop="mini = !mini">
<v-icon>chevron_left</v-icon>
</v-btn>
</v-list-tile-action>
</v-list-tile> </v-list-tile>
</v-list> </v-list>
</v-toolbar> </v-toolbar>
<v-list dense> <slot name="navigation"></slot>
<v-list-tile exact v-for="(item, i) in navItems" :key="i" :to="item.route">
<v-list-tile-content>
<v-list-tile-title>
{{ item.name }}
</v-list-tile-title>
</v-list-tile-content>
</v-list-tile>
</v-list>
</v-navigation-drawer> </v-navigation-drawer>
<v-toolbar <v-toolbar
app app
...@@ -34,7 +37,6 @@ ...@@ -34,7 +37,6 @@
class="grady-toolbar" class="grady-toolbar"
> >
<v-toolbar-title> <v-toolbar-title>
<v-toolbar-side-icon @click.stop="drawer = !drawer"></v-toolbar-side-icon>
<v-avatar> <v-avatar>
<img src="../../assets/brand.png"> <img src="../../assets/brand.png">
</v-avatar> </v-avatar>
...@@ -57,10 +59,9 @@ ...@@ -57,10 +59,9 @@
name: 'base-layout', name: 'base-layout',
data () { data () {
return { return {
drawer: true mini: false
} }
}, },
props: ['navItems'],
computed: { computed: {
...mapGetters([ ...mapGetters([
'gradySpeak' 'gradySpeak'
...@@ -87,5 +88,4 @@ ...@@ -87,5 +88,4 @@
.grady-toolbar { .grady-toolbar {
font-weight: bold; font-weight: bold;
} }
</style> </style>
<template> <template>
<base-layout <base-layout>
:navItems="studentPageNavItems" <v-list dense slot="navigation">
> <v-list-tile exact v-for="(item, i) in generalNavItems" :key="i" :to="item.route">
<v-list-tile-action>
<v-icon>{{ item.icon }}</v-icon>
</v-list-tile-action>
<v-list-tile-content>
<v-list-tile-title>
{{ item.name }}
</v-list-tile-title>
</v-list-tile-content>
</v-list-tile>
<v-divider></v-divider>
<v-list-tile exact v-for="(item, i) in submissionNavItems" :key="i" :to="item.route">
<v-list-tile-action>
<v-icon>assignment</v-icon>
</v-list-tile-action>
<v-list-tile-content>
<v-list-tile-title>
{{ item.name }}
</v-list-tile-title>
</v-list-tile-content>
</v-list-tile>
</v-list>
<router-view></router-view> <router-view></router-view>
</base-layout> </base-layout>
</template> </template>
...@@ -16,10 +37,12 @@ ...@@ -16,10 +37,12 @@
generalNavItems: [ generalNavItems: [
{ {
name: 'Overview', name: 'Overview',
icon: 'home',
route: '/student/' route: '/student/'
}, },
{ {
name: 'Statistics', name: 'Statistics',
icon: 'show_chart',
route: '/student/' route: '/student/'
} }
] ]
...@@ -33,9 +56,6 @@ ...@@ -33,9 +56,6 @@
route: `/student/submission/${index}` route: `/student/submission/${index}`
} }
}) })
},
studentPageNavItems: function () {
return this.generalNavItems.concat(this.submissionNavItems)
} }
} }
} }
......
...@@ -16,10 +16,10 @@ const store = new Vuex.Store({ ...@@ -16,10 +16,10 @@ const store = new Vuex.Store({
state: { state: {
token: '', token: '',
loggedIn: false, loggedIn: false,
username: 'username', username: '',
userRole: 'Student', userRole: '',
error: '', error: '',
examInstance: 'B.Inf 1301 Kohorte 2' examInstance: ''
}, },
getters: { getters: {
gradySpeak: state => { gradySpeak: state => {
...@@ -40,6 +40,12 @@ const store = new Vuex.Store({ ...@@ -40,6 +40,12 @@ const store = new Vuex.Store({
}, },
'LOGOUT': function (state) { 'LOGOUT': function (state) {
state.loggedIn = false state.loggedIn = false
},
'SET_USER_ROLE': function (state, userRole) {
state.userRole = userRole
},
'SET_EXAM_INSTANCE': function (state, examInstance) {
state.examInstance = examInstance
} }
}, },
actions: { actions: {
...@@ -60,6 +66,12 @@ const store = new Vuex.Store({ ...@@ -60,6 +66,12 @@ const store = new Vuex.Store({
} }
} }
}, },
getUserRole (context) {
ax.get('api/user-role/').then(response => context.commit('SET_USER_ROLE', response.data.role))
},
getExamModule (context) {
ax.get('api/exam-module/').then(response => context.commit('SET_EXAM_INSTANCE', response.data.exam))
},
logout (store) { logout (store) {
store.commit('LOGOUT') store.commit('LOGOUT')
store.commit('SET_JWT_TOKEN', '') store.commit('SET_JWT_TOKEN', '')
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment