diff --git a/frontend/config/index.js b/frontend/config/index.js index 2c458f66802f5f8d206f4f136a0b5d52b59b4c21..91cda89ee4dffe53254ba613294b6df8b9d1bc4b 100644 --- a/frontend/config/index.js +++ b/frontend/config/index.js @@ -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: diff --git a/frontend/src/components/submission_notes/AnnotatedSubmission.vue b/frontend/src/components/submission_notes/AnnotatedSubmission.vue index e0af89e5f7c04dea88d1c3ef3ccf8a5b15f80246..5ecb1262ff79b556198cd85e4464c788a1c6c2a5 100644 --- a/frontend/src/components/submission_notes/AnnotatedSubmission.vue +++ b/frontend/src/components/submission_notes/AnnotatedSubmission.vue @@ -1,16 +1,16 @@ <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 () { diff --git a/frontend/src/store/modules/submission_notes.js b/frontend/src/store/modules/submission_notes.js index e69de29bb2d1d6434b8b29ae775ad8c2e48c5391..3212a56ab804f3134fe078dd2ebfb0ed549244de 100644 --- a/frontend/src/store/modules/submission_notes.js +++ b/frontend/src/store/modules/submission_notes.js @@ -0,0 +1,7 @@ +const submission = { + state: { + submission: '' + } +} + +export default submission diff --git a/frontend/src/store/store.js b/frontend/src/store/store.js index 150521a07241ce031fa1bd5454e3ba7a9e9f963f..d2119b940ede05f02f5841ea73901155acff6ef3 100644 --- a/frontend/src/store/store.js +++ b/frontend/src/store/store.js @@ -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) } } })