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

More work on submission-notes

Started work on structuring the vuex store into modules
parent c0655699
No related branches found
No related tags found
2 merge requests!23Resolve "Logout of tutors after inactivity",!18WIP: Submission notes
Pipeline #
......@@ -17,7 +17,7 @@ module.exports = {
// Surge or Netlify already gzip all static assets for you.
// Before setting to `true`, make sure to:
// npm install --save-dev compression-webpack-plugin
productionGzip: false,
productionGzip: true,
productionGzipExtensions: ['js', 'css'],
// Run the build command with an extra argument to
// View the bundle analyzer report after build finishes:
......
<template>
<table>
<tr v-for="line in submission">
<tr v-for="(code, index) in submission" :key="index">
<td class="line-number-cell">
<v-tooltip left close-delay="20" color="transparent" content-class="comment-icon">
<v-btn block class="line-number-btn" slot="activator" @click="toggleEditorOnLine(line[1])">{{ line[1] }}</v-btn>
<v-btn block class="line-number-btn" slot="activator" @click="toggleEditorOnLine(index)">{{ index }}</v-btn>
<v-icon small color="indigo accent-3" class="comment-icon">fa-comment</v-icon>
</v-tooltip>
</td>
<td>
<pre class="prettyprint"><code class="lang-c"> {{ line[0] }}</code></pre>
<feedback-comment v-if="feedback[line[1]] && !showEditorOnLine[line[1]]" :feedback="feedback[line[1]]"></feedback-comment>
<comment-form v-if="showEditorOnLine[line[1]]" :feedback="feedback[line[1]]"></comment-form>
<pre class="prettyprint"><code class="lang-c"> {{ code }}</code></pre>
<feedback-comment v-if="feedback[index] && !showEditorOnLine[index]" :feedback="feedback[index]"></feedback-comment>
<comment-form v-if="showEditorOnLine[index]" :feedback="feedback[index]"></comment-form>
</td>
</tr>
</table>
......@@ -28,7 +28,10 @@
name: 'annotated-submission',
computed: {
submission () {
return this.source.split('\n').map((line, i) => { return [line, i + 1] })
return this.source.split('\n').reduce((acc, cur, index) => {
acc[index + 1] = cur
return acc
}, {})
}
},
data: function () {
......
const submission = {
state: {
submission: ''
}
}
export default submission
......@@ -11,10 +11,13 @@ const store = new Vuex.Store({
username: ''
},
mutations: {
'LOGIN': function (state, creds) {
state.token = creds.token
'SET_JWT_TOKEN': function (state, token) {
state.token = token
ax.defaults.headers.common['Authorization'] = 'JWT ' + state.token
},
'LOGIN': function (state, credentials) {
state.username = credentials.username
state.loggedIn = true
state.username = creds.username
},
'LOGOUT': function (state) {
state.token = ''
......@@ -22,16 +25,12 @@ const store = new Vuex.Store({
}
},
actions: {
async getToken (store, credentials) {
async getToken (context, credentials) {
const response = await ax.post('api-token-auth/', credentials)
store.commit('LOGIN', {
token: response.data.token,
context.commit('LOGIN', {
username: credentials.username
})
ax.defaults.headers.common['Authorization'] = 'JWT ' + response.data.token
},
logout (store) {
store.commit('LOGOUT')
context.commit('SET_JWT_TOKEN', response.data.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