From 200750722241590cff650161b4d23728a856c00a Mon Sep 17 00:00:00 2001
From: "robinwilliam.hundt" <robinwilliam.hundt@stud.uni-goettingen.de>
Date: Sun, 5 Aug 2018 21:35:44 +0200
Subject: [PATCH] Started typing js files

---
 frontend/@types/v-clipboard/index.d.ts |  1 +
 frontend/src/main.ts                   |  4 ++--
 frontend/src/router/index.ts           | 18 ++++++++++--------
 frontend/src/store/getters.js          |  2 +-
 frontend/tsconfig.json                 |  8 ++------
 5 files changed, 16 insertions(+), 17 deletions(-)
 create mode 100644 frontend/@types/v-clipboard/index.d.ts

diff --git a/frontend/@types/v-clipboard/index.d.ts b/frontend/@types/v-clipboard/index.d.ts
new file mode 100644
index 00000000..f2dd4459
--- /dev/null
+++ b/frontend/@types/v-clipboard/index.d.ts
@@ -0,0 +1 @@
+declare module 'v-clipboard';
\ No newline at end of file
diff --git a/frontend/src/main.ts b/frontend/src/main.ts
index 5576736f..ad81436e 100644
--- a/frontend/src/main.ts
+++ b/frontend/src/main.ts
@@ -4,13 +4,13 @@ import router from './router/index'
 import store from './store/store'
 import Vuetify from 'vuetify'
 import Notifications from 'vue-notification'
-import Cliboard from 'v-clipboard'
+import Clipboard from 'v-clipboard'
 
 import 'vuetify/dist/vuetify.min.css'
 import 'highlight.js/styles/atom-one-light.css'
 
 Vue.use(Vuetify)
-Vue.use(Cliboard)
+Vue.use(Clipboard)
 Vue.use(Notifications)
 
 Vue.config.productionTip = false
diff --git a/frontend/src/router/index.ts b/frontend/src/router/index.ts
index e780522f..25b1aeee 100644
--- a/frontend/src/router/index.ts
+++ b/frontend/src/router/index.ts
@@ -1,5 +1,5 @@
 import Vue from 'vue'
-import Router from 'vue-router'
+import Router, {RawLocation, Route, NavigationGuard} from 'vue-router'
 import Login from '@/pages/Login.vue'
 import StudentSubmissionPage from '@/pages/student/StudentSubmissionPage.vue'
 import StudentOverviewPage from '@/pages/reviewer/StudentOverviewPage.vue'
@@ -19,7 +19,9 @@ import store from '@/store/store'
 
 Vue.use(Router)
 
-function denyAccess (next, redirect) {
+type rerouteFunc = (to?: RawLocation | false | ((vm: Vue) => any) | void) => void
+
+function denyAccess (next: rerouteFunc, redirect: Route) {
   next(redirect.path)
   VueInstance.$notify({
     title: 'Access denied',
@@ -28,23 +30,23 @@ function denyAccess (next, redirect) {
   })
 }
 
-function tutorOrReviewerOnly (to, from, next) {
+let tutorOrReviewerOnly: NavigationGuard = function (to, from, next) {
   if (store.getters.isTutorOrReviewer) {
     next()
   } else {
-    denyAccess(next, from.path)
+    denyAccess(next, from)
   }
 }
 
-function reviewerOnly (to, from, next) {
+let reviewerOnly: NavigationGuard = function (to, from, next) {
   if (store.getters.isReviewer) {
     next()
   } else {
-    denyAccess(next, from.path)
+    denyAccess(next, from)
   }
 }
 
-function studentOnly (to, from, next) {
+let studentOnly: NavigationGuard = function (to, from, next) {
   if (store.getters.isStudent) {
     next()
   } else {
@@ -52,7 +54,7 @@ function studentOnly (to, from, next) {
   }
 }
 
-function checkLoggedIn (to, from, next) {
+let checkLoggedIn: NavigationGuard = function (to, from, next) {
   if (store.getters.isLoggedIn) {
     next()
   } else {
diff --git a/frontend/src/store/getters.js b/frontend/src/store/getters.js
index 5663746c..3cdc0cbe 100644
--- a/frontend/src/store/getters.js
+++ b/frontend/src/store/getters.js
@@ -1,7 +1,7 @@
 const getters = {
   corrected (state) {
     return state.statistics.submission_type_progress.every(progress => {
-      return progress.percentage === 100
+      return progress.feedback_final === progress.submission_count
     })
   },
   getSubmission: state => pk => {
diff --git a/frontend/tsconfig.json b/frontend/tsconfig.json
index c1700466..c19146b1 100644
--- a/frontend/tsconfig.json
+++ b/frontend/tsconfig.json
@@ -2,7 +2,7 @@
   "compilerOptions": {
     "target": "esnext",
     "module": "esnext",
-    "strict": false,
+    "strict": true,
     "jsx": "preserve",
     "importHelpers": true,
     "moduleResolution": "node",
@@ -10,11 +10,6 @@
     "esModuleInterop": true,
     "sourceMap": true,
     "baseUrl": ".",
-    "types": [
-      "node",
-      "mocha",
-      "chai"
-    ],
     "paths": {
       "@/*": [
         "src/*"
@@ -28,6 +23,7 @@
     ]
   },
   "include": [
+    "@types/",
     "src/**/*.ts",
     "src/**/*.tsx",
     "src/**/*.vue",
-- 
GitLab