Commit 6e1cb5c96848910d65eac1a435e31c9b8dab92de
1 parent
be4bdd6416
Exists in
master
and in
2 other branches
added token
Showing
4 changed files
with
87 additions
and
36 deletions
Show diff stats
src/Services/http.js
1 | 1 | import axios from 'axios' |
2 | 2 | import store from '@/store/store' |
3 | +import Vue from 'vue' | |
4 | +import {vm1} from "@/main.js" | |
3 | 5 | |
4 | 6 | const baseDomain = "https://api-dashboard.intrack.in/v1"; |
5 | 7 | |
... | ... | @@ -13,12 +15,59 @@ const baseURL = `${baseDomain}`; |
13 | 15 | |
14 | 16 | // console.log("role",`${store.state.schoolRole}`); |
15 | 17 | // console.log("token",`${store.state.schoolToken}`); |
18 | + | |
16 | 19 | export default () => { |
17 | - return axios.create({ | |
18 | - // baseURL: 'http://192.168.2.221:3002/v1', | |
19 | - baseURL, | |
20 | + // return axios.create({ | |
21 | + // // baseURL: 'http://192.168.2.221:3002/v1', | |
22 | + // baseURL, | |
23 | + // headers: { | |
24 | + // Authorization: `Bearer ${store.state.token}` | |
25 | + // } | |
26 | + // }) | |
27 | + let instance = axios.create({ | |
28 | + // LIVE | |
29 | + //baseURL: 'https://annadata.patanjaliayurved.org/api', | |
30 | + // DEVELOPMENT | |
31 | + baseURL: baseURL, | |
32 | + | |
20 | 33 | headers: { |
21 | - Authorization: `Bearer ${store.state.token}` | |
34 | + Authorization: `Bearer ${store.state.token}`, | |
35 | + // 'Access-Control-Allow-Origin': '*' | |
36 | + | |
37 | + } | |
38 | + }) | |
39 | + | |
40 | + instance.interceptors.request.use((config) => { | |
41 | + // Do something before request is sent | |
42 | + | |
43 | + return config | |
44 | + }, error => { | |
45 | + return Promise.reject(error) | |
46 | + }) | |
47 | + instance.interceptors.response.use((response) => { | |
48 | + // do something with the response data | |
49 | + | |
50 | + | |
51 | + return response; | |
52 | + }, error => { | |
53 | + // handle the response error | |
54 | + console.log("error in interceptor - ",error.response.status) | |
55 | + var customError | |
56 | + const errorNo = error.response.status | |
57 | + | |
58 | + switch (errorNo) { | |
59 | + case 401: | |
60 | + customError = "Session expired" | |
61 | + console.log("what is this - ", vm1) | |
62 | + vm1.$store.dispatch("setToken", null); | |
63 | + vm1.$router.replace({ path: "/" }); | |
64 | + | |
65 | + vm1.$store.dispatch("Id", null); | |
66 | + | |
67 | + break; | |
22 | 68 | } |
23 | 69 | }) |
70 | + // response parse | |
71 | + | |
72 | + return instance; | |
24 | 73 | } |
25 | 74 | \ No newline at end of file | ... | ... |
src/main.js
src/pages/Dashboard/LiveOnlineClass.vue
... | ... | @@ -71,12 +71,7 @@ |
71 | 71 | <!-- JOIN OR END SESSION --> |
72 | 72 | <v-flex> |
73 | 73 | <div> |
74 | - <v-btn | |
75 | - round | |
76 | - class="open-dialog-button" | |
77 | - dark | |
78 | - @click="startChat()" | |
79 | - >Start Session</v-btn> | |
74 | + <v-btn round class="open-dialog-button" dark @click="startChat()">Start Session</v-btn> | |
80 | 75 | </div> |
81 | 76 | </v-flex> |
82 | 77 | <v-flex id="teacherClone"> |
... | ... | @@ -165,15 +160,20 @@ export default { |
165 | 160 | }; |
166 | 161 | }, |
167 | 162 | methods: { |
168 | - startChat() { | |
163 | + async startChat() { | |
169 | 164 | if (this.$store.state.role === "PARENT") { |
170 | - let div = document.getElementById("jitsi-container"); | |
171 | - var parent = div.parentNode; | |
172 | - var clone = div.cloneNode(true); | |
173 | - clone.id = "jitsi-container"; | |
174 | - parent.replaceChild(clone, div); | |
165 | + // let div = document.getElementById("jitsi-container"); | |
166 | + // var parent = div.parentNode; | |
167 | + // var clone = div.cloneNode(true); | |
168 | + // clone.id = "jitsi-container"; | |
169 | + // div.replaceWith(clone); | |
175 | 170 | // div.replaceWith(input.val('').clone(true)); |
176 | - this.studentClasses(); | |
171 | + if(this.counter == 0){ | |
172 | + this.counter +=1 | |
173 | + }else{ | |
174 | + await this.studentClasses(); | |
175 | + } | |
176 | + this.startConference(); | |
177 | 177 | } |
178 | 178 | if (this.$store.state.role === "TEACHER") { |
179 | 179 | let div = document.getElementById("jitsi-container"); |
... | ... | @@ -309,6 +309,14 @@ export default { |
309 | 309 | console.log("response getLiveClassesesList- ", response); |
310 | 310 | |
311 | 311 | /* CHECK RESPONSE TO ASSIGN MESSAGE INSIDE BUTTON */ |
312 | + if (response.data.data[0].sessionStatus == "ENDED") { | |
313 | + // this.startLiveSession = "Start Session"; | |
314 | + this.studentBtn = ""; | |
315 | + } | |
316 | + if (response.data.data[0].sessionStatus == "STARTED") { | |
317 | + // this.startLiveSession = "Join Session"; | |
318 | + this.studentBtn = "Join Session"; | |
319 | + } | |
312 | 320 | if (response.data.data.length == 0) { |
313 | 321 | this.startLiveSession = "Start Session"; |
314 | 322 | this.studentBtn = ""; |
... | ... | @@ -334,18 +342,9 @@ export default { |
334 | 342 | if (this_.room != null || this_.room != "") { |
335 | 343 | this.room = this.room; |
336 | 344 | } |
337 | - this.startConference(); | |
345 | + // this.startConference(); | |
338 | 346 | } |
339 | 347 | } |
340 | - | |
341 | - if (response.data.data[0].sessionStatus == "ENDED") { | |
342 | - // this.startLiveSession = "Start Session"; | |
343 | - this.studentBtn = ""; | |
344 | - } | |
345 | - if (response.data.data[0].sessionStatus == "STARTED") { | |
346 | - // this.startLiveSession = "Join Session"; | |
347 | - this.studentBtn = "Join Session"; | |
348 | - } | |
349 | 348 | } |
350 | 349 | }, |
351 | 350 | }, |
... | ... | @@ -355,7 +354,7 @@ export default { |
355 | 354 | }, |
356 | 355 | async created() { |
357 | 356 | if (this.$store.state.role === "PARENT") { |
358 | - this.studentClasses(); | |
357 | + await this.studentClasses(); | |
359 | 358 | } |
360 | 359 | |
361 | 360 | /* getStudentCourses - to get courseData - defined in GetApis.js*/ | ... | ... |
src/pages/Dashboard/dashboard.vue
... | ... | @@ -752,11 +752,11 @@ export default { |
752 | 752 | .catch(error => { |
753 | 753 | // console.log("err====>", err); |
754 | 754 | this.showLoader = false; |
755 | - if (error.response.status === 401) { | |
756 | - this.$router.replace({ path: "/" }); | |
757 | - this.$store.dispatch("setToken", null); | |
758 | - this.$store.dispatch("Id", null); | |
759 | - } | |
755 | + // if (error.response.status === 401) { | |
756 | + // this.$router.replace({ path: "/" }); | |
757 | + // this.$store.dispatch("setToken", null); | |
758 | + // this.$store.dispatch("Id", null); | |
759 | + // } | |
760 | 760 | }); |
761 | 761 | }, |
762 | 762 | getParents() { |
... | ... | @@ -1004,8 +1004,11 @@ export default { |
1004 | 1004 | async created() { |
1005 | 1005 | if (this.$store.state.role === "ADMIN") { |
1006 | 1006 | this.token = this.$store.state.token; |
1007 | + await this.getFeesAndCollectionsData(); | |
1008 | + await this.getExpensesData(); | |
1007 | 1009 | } else if (this.$store.state.schoolRole === "SUPERADMIN") { |
1008 | 1010 | this.token = this.$store.state.schoolToken; |
1011 | + await this.getFeesAndCollectionsData(); | |
1009 | 1012 | } else if (this.$store.state.role === "TEACHER") { |
1010 | 1013 | this.token = this.$store.state.token; |
1011 | 1014 | } else if (this.$store.state.role === "ACCOUNTANT") { |
... | ... | @@ -1025,8 +1028,8 @@ export default { |
1025 | 1028 | await this.getClasses(); |
1026 | 1029 | await this.getNoticeData(); |
1027 | 1030 | await this.getUserData(); |
1028 | - await this.getFeesAndCollectionsData(); | |
1029 | - await this.getExpensesData(); | |
1031 | + | |
1032 | + | |
1030 | 1033 | |
1031 | 1034 | /* get Latest events list for student login*/ |
1032 | 1035 | if (this.$store.state.role == "PARENT") { | ... | ... |