diff --git a/src/Services/http.js b/src/Services/http.js index 730dcdb..0565e5a 100644 --- a/src/Services/http.js +++ b/src/Services/http.js @@ -1,5 +1,7 @@ import axios from 'axios' import store from '@/store/store' +import Vue from 'vue' +import {vm1} from "@/main.js" const baseDomain = "https://api-dashboard.intrack.in/v1"; @@ -13,12 +15,59 @@ const baseURL = `${baseDomain}`; // console.log("role",`${store.state.schoolRole}`); // console.log("token",`${store.state.schoolToken}`); + export default () => { - return axios.create({ - // baseURL: 'http://192.168.2.221:3002/v1', - baseURL, + // return axios.create({ + // // baseURL: 'http://192.168.2.221:3002/v1', + // baseURL, + // headers: { + // Authorization: `Bearer ${store.state.token}` + // } + // }) + let instance = axios.create({ + // LIVE + //baseURL: 'https://annadata.patanjaliayurved.org/api', + // DEVELOPMENT + baseURL: baseURL, + headers: { - Authorization: `Bearer ${store.state.token}` + Authorization: `Bearer ${store.state.token}`, + // 'Access-Control-Allow-Origin': '*' + + } + }) + + instance.interceptors.request.use((config) => { + // Do something before request is sent + + return config + }, error => { + return Promise.reject(error) + }) + instance.interceptors.response.use((response) => { + // do something with the response data + + + return response; + }, error => { + // handle the response error + console.log("error in interceptor - ",error.response.status) + var customError + const errorNo = error.response.status + + switch (errorNo) { + case 401: + customError = "Session expired" + console.log("what is this - ", vm1) + vm1.$store.dispatch("setToken", null); + vm1.$router.replace({ path: "/" }); + + vm1.$store.dispatch("Id", null); + + break; } }) + // response parse + + return instance; } \ No newline at end of file diff --git a/src/main.js b/src/main.js index ec54a96..39acd65 100644 --- a/src/main.js +++ b/src/main.js @@ -86,7 +86,7 @@ Vue.use(Vuetify, { /* eslint-disable no-new */ -new Vue({ +export var vm1 = new Vue({ el: '#app', router, store, diff --git a/src/pages/Dashboard/LiveOnlineClass.vue b/src/pages/Dashboard/LiveOnlineClass.vue index 54a1eeb..1f5bb0e 100644 --- a/src/pages/Dashboard/LiveOnlineClass.vue +++ b/src/pages/Dashboard/LiveOnlineClass.vue @@ -71,12 +71,7 @@ - Start Session + Start Session @@ -165,15 +160,20 @@ export default { }; }, methods: { - startChat() { + async startChat() { if (this.$store.state.role === "PARENT") { - let div = document.getElementById("jitsi-container"); - var parent = div.parentNode; - var clone = div.cloneNode(true); - clone.id = "jitsi-container"; - parent.replaceChild(clone, div); + // let div = document.getElementById("jitsi-container"); + // var parent = div.parentNode; + // var clone = div.cloneNode(true); + // clone.id = "jitsi-container"; + // div.replaceWith(clone); // div.replaceWith(input.val('').clone(true)); - this.studentClasses(); + if(this.counter == 0){ + this.counter +=1 + }else{ + await this.studentClasses(); + } + this.startConference(); } if (this.$store.state.role === "TEACHER") { let div = document.getElementById("jitsi-container"); @@ -309,6 +309,14 @@ export default { console.log("response getLiveClassesesList- ", response); /* CHECK RESPONSE TO ASSIGN MESSAGE INSIDE BUTTON */ + if (response.data.data[0].sessionStatus == "ENDED") { + // this.startLiveSession = "Start Session"; + this.studentBtn = ""; + } + if (response.data.data[0].sessionStatus == "STARTED") { + // this.startLiveSession = "Join Session"; + this.studentBtn = "Join Session"; + } if (response.data.data.length == 0) { this.startLiveSession = "Start Session"; this.studentBtn = ""; @@ -334,18 +342,9 @@ export default { if (this_.room != null || this_.room != "") { this.room = this.room; } - this.startConference(); + // this.startConference(); } } - - if (response.data.data[0].sessionStatus == "ENDED") { - // this.startLiveSession = "Start Session"; - this.studentBtn = ""; - } - if (response.data.data[0].sessionStatus == "STARTED") { - // this.startLiveSession = "Join Session"; - this.studentBtn = "Join Session"; - } } }, }, @@ -355,7 +354,7 @@ export default { }, async created() { if (this.$store.state.role === "PARENT") { - this.studentClasses(); + await this.studentClasses(); } /* getStudentCourses - to get courseData - defined in GetApis.js*/ diff --git a/src/pages/Dashboard/dashboard.vue b/src/pages/Dashboard/dashboard.vue index 20485e7..54bca6a 100644 --- a/src/pages/Dashboard/dashboard.vue +++ b/src/pages/Dashboard/dashboard.vue @@ -752,11 +752,11 @@ export default { .catch(error => { // console.log("err====>", err); this.showLoader = false; - if (error.response.status === 401) { - this.$router.replace({ path: "/" }); - this.$store.dispatch("setToken", null); - this.$store.dispatch("Id", null); - } + // if (error.response.status === 401) { + // this.$router.replace({ path: "/" }); + // this.$store.dispatch("setToken", null); + // this.$store.dispatch("Id", null); + // } }); }, getParents() { @@ -1004,8 +1004,11 @@ export default { async created() { if (this.$store.state.role === "ADMIN") { this.token = this.$store.state.token; + await this.getFeesAndCollectionsData(); + await this.getExpensesData(); } else if (this.$store.state.schoolRole === "SUPERADMIN") { this.token = this.$store.state.schoolToken; + await this.getFeesAndCollectionsData(); } else if (this.$store.state.role === "TEACHER") { this.token = this.$store.state.token; } else if (this.$store.state.role === "ACCOUNTANT") { @@ -1025,8 +1028,8 @@ export default { await this.getClasses(); await this.getNoticeData(); await this.getUserData(); - await this.getFeesAndCollectionsData(); - await this.getExpensesData(); + + /* get Latest events list for student login*/ if (this.$store.state.role == "PARENT") {