From 31ebb9eec344686f097a9b7436a50fbc9537772b Mon Sep 17 00:00:00 2001
From: emreaydogdu <busra0112>
Date: Mon, 5 Oct 2020 00:30:10 +0200
Subject: [PATCH] expired message

---
 src/components/LogIn.vue     |  1 +
 src/components/SideMenu.vue  |  1 +
 src/components/Teachers.vue  | 44 +++++++++++++++++++++++++++---------
 src/main.js                  | 14 +++++++-----
 src/services/auth.service.js |  1 -
 5 files changed, 43 insertions(+), 18 deletions(-)

diff --git a/src/components/LogIn.vue b/src/components/LogIn.vue
index dc2cb75..646003d 100644
--- a/src/components/LogIn.vue
+++ b/src/components/LogIn.vue
@@ -113,6 +113,7 @@ export default {
         if (this.user.username && this.user.password) {
           this.$store.dispatch('auth/login', this.user).then(
               () => {
+                localStorage.setItem('cronJob', 0);
                 this.$router.push('/home');
                 this.$parent.update();
               }
diff --git a/src/components/SideMenu.vue b/src/components/SideMenu.vue
index 3e2d2b2..e8edeec 100644
--- a/src/components/SideMenu.vue
+++ b/src/components/SideMenu.vue
@@ -39,6 +39,7 @@ export default {
     logOut: function() {
       this.$store.dispatch('auth/logout').then(
           () => {
+            localStorage.setItem('cronJob', 0);
             this.$router.push('/login');
             this.$parent.update();
           },
diff --git a/src/components/Teachers.vue b/src/components/Teachers.vue
index 2a325c6..4a3c51a 100644
--- a/src/components/Teachers.vue
+++ b/src/components/Teachers.vue
@@ -1,5 +1,6 @@
 <template>
   <div class="content col-md-12">
+    <h1>{{counter}}</h1>
     <h1>{{data}}</h1>
   </div>
 </template>
@@ -9,25 +10,46 @@ export default {
   name: "Teachers",
   data(){
     return{
-      data: "Hello World"
+      data: "Placeholder",
+      counter: JSON.parse(localStorage.getItem('cronJob')),
+      cronJob: this.$crontab.addJob({
+        name: 'counter',
+        interval: {
+          seconds: '/1',
+        },
+        job: this.countUp
+      })
     }
   },
 
   created() {
-    this.get();
+    this.getData();
+    this.$crontab.execJob('counter');
   },
 
   methods:{
-      get(){
-        this.$store.dispatch('user/getHello').then(
-            () => {
-              this.data = this.$store.state.user.response;
-            },
-            error => {
-              this.message = (error.response && error.response.data) || error.message || error.toString();
-            }
-        );
+    countUp () {
+      this.counter += 1
+      if (this.counter >= 60){
+        this.$crontab.deleteJob('counter');
+        //alert("Geh nachhcause");
       }
+      localStorage.setItem('cronJob', this.counter);
+    },
+    getData () {
+      this.$store.dispatch('user/getHello').then(
+          () => {
+            this.data = this.$store.state.user.response;
+          },
+          error => {
+            this.message =
+                (error.response && error.response.data) ||
+                error.message ||
+                error.toString();
+            this.successful = false;
+          }
+      );
+    }
   }
 }
 </script>
diff --git a/src/main.js b/src/main.js
index 886ba9a..608442b 100644
--- a/src/main.js
+++ b/src/main.js
@@ -2,22 +2,24 @@ import Vue from 'vue'
 import App from './App.vue'
 
 import router from './router'
-import store from './store/index';
+import store from './store/index'
 
 import BootstrapVue from "bootstrap-vue"
 import "bootstrap/dist/css/bootstrap.min.css"
 import "bootstrap-vue/dist/bootstrap-vue.css"
+import VeeValidate from 'vee-validate'
+import VueCrontab  from 'vue-crontab'
 
-import VeeValidate from 'vee-validate';
-import { library } from '@fortawesome/fontawesome-svg-core';
-import { FontAwesomeIcon } from '@fortawesome/vue-fontawesome';
-import { faHome, faUser, faUserPlus, faSignInAlt, faSignOutAlt } from '@fortawesome/free-solid-svg-icons';
+import { library } from '@fortawesome/fontawesome-svg-core'
+import { FontAwesomeIcon } from '@fortawesome/vue-fontawesome'
+import { faHome, faUser, faUserPlus, faSignInAlt, faSignOutAlt } from '@fortawesome/free-solid-svg-icons'
 
 library.add(faHome, faUser, faUserPlus, faSignInAlt, faSignOutAlt);
 
 Vue.config.productionTip = false;
+Vue.use(VueCrontab)
 Vue.use(BootstrapVue)
-Vue.use(VeeValidate);
+Vue.use(VeeValidate)
 Vue.component('font-awesome-icon', FontAwesomeIcon);
 
 new Vue({
diff --git a/src/services/auth.service.js b/src/services/auth.service.js
index fe87078..bde9845 100644
--- a/src/services/auth.service.js
+++ b/src/services/auth.service.js
@@ -14,7 +14,6 @@ class AuthService {
             .then(response => {
                 if (response.data.idToken) {
                     localStorage.setItem('user', JSON.stringify(response.data));
-                    localStorage.setItem('cronJob', 0);
                 }
 
                 return response.data;
-- 
GitLab