Blame view
src/pages/Dashboard/LiveOnlineClass.vue
16.3 KB
ac24ec07a
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 |
<template> <div class="body-color"> <!-- LOADER --> <div class="loader" v-if="showLoader"> <v-progress-circular indeterminate color="white"></v-progress-circular> </div> <!-- SNACKBAR --> <v-snackbar :timeout="timeout" :top="y === 'top'" :right="x === 'right'" :vertical="mode === 'vertical'" v-model="snackbar" :color="snackbarColor" > {{ text }} <v-spacer></v-spacer> <v-btn flat text @click="snackbar = false">X</v-btn> </v-snackbar> |
ac24ec07a
|
21 22 |
<v-container grid-list-xl class="pt-0"> <v-layout row wrap class="mt-1"> |
e91641fe5
|
23 |
<!-- if logged in user is parent --> |
30e404e65
|
24 25 26 27 |
<v-flex xs12 sm12 md9 v-if=" $store.state.role === 'PARENT' "> <v-layout column> <!-- HEADING --> <v-flex> |
e91641fe5
|
28 29 30 |
<div class="title side-bar-color font-weight-bold" >Live Online Classes - {{$route.query.chapterName}}</div> |
9a4a64725
|
31 |
<!-- <div class="subheading grey--text lighten-1">{{liveLink}}</div> --> |
edfe025fa
|
32 |
<!-- <div |
30e404e65
|
33 |
class="subheading grey--text lighten-1" |
852713654
|
34 |
>The session started at 1:00 there is 1 moderator</div>--> |
30e404e65
|
35 36 37 |
</v-flex> <!-- JOIN OR END SESSION --> |
46997790d
|
38 |
<v-flex v-if="showJoinSessionButton"> |
30e404e65
|
39 |
<div> |
edfe025fa
|
40 41 42 43 44 |
<v-btn round class="open-dialog-button" dark v-if="studentBtn" |
d23a27a41
|
45 |
@click="showLoader = true;startChat();" |
edfe025fa
|
46 |
>{{studentBtn}}</v-btn> |
e659e774f
|
47 |
<span class="subheading grey--twxt lighten-1" v-else>Session hasn't started yet</span> |
30e404e65
|
48 49 |
</div> </v-flex> |
375b62cd1
|
50 |
<v-flex id="studentClone"> |
edfe025fa
|
51 52 |
<div id="jitsi-container"></div> </v-flex> |
30e404e65
|
53 54 |
</v-layout> </v-flex> |
e91641fe5
|
55 56 |
<!-- if logged in user is teacher --> |
30e404e65
|
57 |
<v-flex xs12 sm12 md12 v-else> |
ac24ec07a
|
58 59 60 |
<v-layout column> <!-- HEADING --> <v-flex> |
cf2d498a8
|
61 62 63 |
<div class="title side-bar-color font-weight-bold" >Live Online Classes - {{$route.query.chapterName}}</div> |
852713654
|
64 65 |
<!-- <div class="subheading grey--text lighten-1"></div> --> <!-- <div |
ac24ec07a
|
66 |
class="subheading grey--text lighten-1" |
852713654
|
67 |
>The session started at 1:00 there is 1 moderator</div>--> |
ac24ec07a
|
68 69 70 |
</v-flex> <!-- JOIN OR END SESSION --> |
92c6232a6
|
71 |
<v-flex v-if="showStartSessionButton"> |
ac24ec07a
|
72 |
<div> |
860da881d
|
73 74 75 76 77 78 |
<v-btn round class="open-dialog-button" dark @click="showLoader = true;startChat()" >Start Session</v-btn> |
ac24ec07a
|
79 80 |
</div> </v-flex> |
375b62cd1
|
81 |
<v-flex id="teacherClone"> |
e91641fe5
|
82 |
<div id="jitsi-container"></div> |
ac24ec07a
|
83 84 85 86 87 |
</v-flex> </v-layout> </v-flex> <v-spacer></v-spacer> |
e91641fe5
|
88 |
<!-- COURSES SIDE BAR- positioned to the right of the page --> |
de958fcfc
|
89 |
<!-- <v-flex xs3> |
ac24ec07a
|
90 |
<v-card class="elevation-0 card-border" height="100%"> |
e91641fe5
|
91 |
<CoursesSideBar></CoursesSideBar> |
ac24ec07a
|
92 |
</v-card> |
de958fcfc
|
93 |
</v-flex>--> |
ac24ec07a
|
94 95 96 97 98 99 100 101 |
</v-layout> </v-container> </div> </template> <script> import AllApiCalls from "@/Services/AllApiCalls.js"; import http from "@/Services/http.js"; import moment from "moment"; |
e91641fe5
|
102 103 |
import Meet from "@/pages/Meet/meet.vue"; import CoursesSideBar from "@/pages/Common/CoursesSideBar.vue"; |
ac24ec07a
|
104 105 |
export default { mixins: [AllApiCalls], |
e91641fe5
|
106 |
components: { |
375b62cd1
|
107 |
CoursesSideBar, |
e91641fe5
|
108 |
}, |
ac24ec07a
|
109 110 |
data() { return { |
e91641fe5
|
111 |
startLiveSession: "", |
852713654
|
112 |
studentBtn: "", |
ac24ec07a
|
113 114 115 116 |
// DATA TABLE search: "", pagination: { |
375b62cd1
|
117 |
rowsPerPage: 10, |
ac24ec07a
|
118 119 120 121 122 123 |
}, liveOnlineHeaders: [ { text: "Playback", value: "attachementUrl", sortable: false, |
375b62cd1
|
124 |
align: "center", |
ac24ec07a
|
125 126 127 128 129 |
}, { text: "Meeting", align: "center", sortable: false, |
375b62cd1
|
130 |
value: "", |
ac24ec07a
|
131 132 133 134 135 |
}, { text: "Recording", value: "", sortable: false, |
375b62cd1
|
136 |
align: "center", |
ac24ec07a
|
137 138 139 140 141 |
}, { text: "Description Preview", value: "", sortable: false, |
375b62cd1
|
142 |
align: "center", |
ac24ec07a
|
143 144 145 |
}, { text: "Date", value: "", sortable: false, align: "center" }, { text: "Duration", value: "", sortable: false, align: "center" }, |
375b62cd1
|
146 |
{ text: "Toolbar", value: "", sortable: false, align: "center" }, |
ac24ec07a
|
147 148 |
], liveOnlineItems: [], |
e91641fe5
|
149 |
// JITSI CONTAINER |
edfe025fa
|
150 |
liveLink: "", |
e91641fe5
|
151 152 |
token: "", selectStudents: {}, |
375b62cd1
|
153 154 |
classRules: [(v) => !!v || " Class Name is required"], sectionRules: [(v) => !!v || " Section Name is required"], |
e91641fe5
|
155 156 157 158 159 |
addclass: [], addSection: [], loading: false, room: "", username: "", |
375b62cd1
|
160 |
roomPassword: "", |
e659e774f
|
161 |
// counter: 0, |
b6e4f6eaa
|
162 |
appLink: "", |
92c6232a6
|
163 |
showStartSessionButton: true, |
46997790d
|
164 |
showJoinSessionButton: true, |
275b17e4f
|
165 |
courseAttendanceId: {}, |
ac24ec07a
|
166 167 168 |
}; }, methods: { |
6e1cb5c96
|
169 |
async startChat() { |
375b62cd1
|
170 |
if (this.$store.state.role === "PARENT") { |
d32525d71
|
171 172 173 174 175 176 177 178 |
// if (this.counter == 0) { // console.log("enter start chat"); const isMobile = /iPhone|iPad|iPod|Android/i.test(navigator.userAgent); if (isMobile) { window.open(this.appLink); this.showLoader = false; } else { this.startConference(); |
c301facad
|
179 |
this.createAttendence(); |
d32525d71
|
180 181 |
// this.counter += 1; this.showJoinSessionButton = false; |
6e1cb5c96
|
182 |
} |
d32525d71
|
183 |
// } |
375b62cd1
|
184 185 |
} if (this.$store.state.role === "TEACHER") { |
d32525d71
|
186 187 188 189 |
// if (this.counter == 0) { this.createRoom(); // this.counter += 1; // } |
375b62cd1
|
190 191 |
} }, |
e91641fe5
|
192 193 |
// JITSI CONTAINER startConference() { |
860da881d
|
194 |
// console.log("yes session started"); |
e91641fe5
|
195 196 |
var _this = this; try { |
01a388dfe
|
197 |
const domain = "meet.intrack.in"; |
e91641fe5
|
198 199 200 201 |
const options = { audioInput: "<deviceLabel>", audioOutput: "<deviceLabel>", videoInput: "<deviceLabel>", |
edfe025fa
|
202 |
prejoinPageEnabled: false, |
e91641fe5
|
203 204 205 206 207 |
roomName: this.room, height: 500, parentNode: document.getElementById("jitsi-container"), interfaceConfigOverwrite: { filmStripOnly: false, |
9a4a64725
|
208 209 |
SHOW_PROMOTIONAL_CLOSE_PAGE: false, SHOW_POWERED_BY: false, |
e91641fe5
|
210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 |
SHOW_JITSI_WATERMARK: false, TOOLBAR_BUTTONS: [ "microphone", "camera", "closedcaptions", "desktop", "fullscreen", "fodeviceselection", "hangup", "profile", "info", "chat", "recording", "livestreaming", "etherpad", "sharedvideo", "settings", "raisehand", "videoquality", "filmstrip", "invite", "feedback", "stats", "shortcuts", |
375b62cd1
|
234 235 |
"tileview", ], |
e91641fe5
|
236 237 |
}, configOverwrite: { |
375b62cd1
|
238 |
disableSimulcast: false, |
e91641fe5
|
239 240 |
}, teacherName: "", |
e05668b28
|
241 |
room: "", |
e91641fe5
|
242 |
}; |
a690a86fb
|
243 |
_this.api = new JitsiMeetExternalAPI(domain, options); |
860da881d
|
244 |
// console.log("this.api ", this.api); |
a690a86fb
|
245 |
_this.api.addEventListener("videoConferenceJoined", () => { |
90bec8782
|
246 |
this.showLoader = false; |
e05668b28
|
247 248 249 250 |
setTimeout(() => { _this.api.executeCommand("displayName", _this.username); _this.api.executeCommand("password", _this.roomPassword); }, 1000); |
ac24ec07a
|
251 |
}); |
860da881d
|
252 |
|
32eff55c5
|
253 254 255 |
_this.api.on("passwordRequired", () => { _this.api.executeCommand("password", _this.roomPassword); }); |
a690a86fb
|
256 |
_this.api.on("readyToClose", () => { |
92c6232a6
|
257 258 259 260 |
// this.$router.push({ name: "Refresh" }); let jitsi = document.getElementById("jitsi-container"); jitsi.innerHTML = ""; this.showStartSessionButton = true; |
46997790d
|
261 |
this.showJoinSessionButton = true; |
e659e774f
|
262 263 264 |
if (this.$store.state.role === "TEACHER") { this.updateLiveClass(); } |
9a4a64725
|
265 |
}); |
e91641fe5
|
266 |
} catch (error) { |
860da881d
|
267 |
// console.error("Failed to load Jitsi API", error); |
ac24ec07a
|
268 269 |
} }, |
e91641fe5
|
270 271 272 273 274 275 276 277 278 279 280 |
openRoom() { // verify the JitsiMeetExternalAPI constructor is added to the global.. // if (this.teacherName != "" || this.room != "") { // if (window.JitsiMeetExternalAPI) { // // var person = prompt("Please enter your name:", "Rabie"); // if (person != null || person != "") this.username = this.teacherName; // var room = prompt("Please enter your room:", "Test Room"); // if (room != null || room != "") this.room = this.room; // this.startConference(); // } else alert("Jitsi Meet API script not loaded"); // } |
ac24ec07a
|
281 |
}, |
e91641fe5
|
282 |
createRoom(classId) { |
8b7976c3a
|
283 |
// this.showLoader = true; |
e91641fe5
|
284 |
var classId = { |
375b62cd1
|
285 |
classId: classId, |
ac24ec07a
|
286 287 |
}; http() |
e91641fe5
|
288 289 290 |
.post("/createLiveClasses", { classId: this.$route.query.classId, courseId: this.$route.query.courseId, |
375b62cd1
|
291 |
chapterId: this.$route.query.chapterId, |
ac24ec07a
|
292 |
}) |
375b62cd1
|
293 |
.then((response) => { |
e91641fe5
|
294 |
// this.addSection = response.data.data; |
860da881d
|
295 |
// console.log("CREATE___ROOOM", response.data); |
a690a86fb
|
296 |
var room = response.data.data.roomName; |
860da881d
|
297 |
var username = localStorage.getItem("teacherName"); |
a690a86fb
|
298 |
var roomPassword = response.data.data.password; |
b6e4f6eaa
|
299 |
this.appLink = response.data.data.appLink; |
e659e774f
|
300 |
this.liveClassId = response.data.data._id; |
860da881d
|
301 302 303 304 305 306 307 308 |
// console.log( // "room", // room, // "username", // username, // "roomPassword", // roomPassword // ); |
e91641fe5
|
309 |
var this_ = this; |
a690a86fb
|
310 |
if (username != "" || room != "") { |
b6e4f6eaa
|
311 312 313 314 315 316 |
const isMobile = /iPhone|iPad|iPod|Android/i.test( navigator.userAgent ); if (isMobile) { // console.log("==TEACHER=appLink==", this.appLink); window.open(this.appLink); |
92c6232a6
|
317 318 |
this.showLoader = false; this.showStartSessionButton = false; |
b6e4f6eaa
|
319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 |
} else { if (window.JitsiMeetExternalAPI) { // var person = prompt("Please enter your name:", "Rabie"); if (username != null || username != "") { this_.username = username; } // var room = prompt("Please enter your room:", "Test Room"); if (room != null || room != "") { this_.room = room; } if (roomPassword != null || roomPassword != "") { this_.roomPassword = roomPassword; } } else alert("Jitsi Meet API script not loaded"); this_.startConference(); |
92c6232a6
|
334 |
this.showStartSessionButton = false; |
b6e4f6eaa
|
335 |
} |
e91641fe5
|
336 |
} |
ac24ec07a
|
337 |
}) |
375b62cd1
|
338 |
.catch((err) => { |
ac24ec07a
|
339 340 |
this.showLoader = false; }); |
375b62cd1
|
341 |
}, |
c301facad
|
342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 |
formatAMPM(date) { var hours = date.getHours(); var minutes = date.getMinutes(); var ampm = hours >= 12 ? "pm" : "am"; hours = hours % 12; hours = hours ? hours : 12; // the hour '0' should be '12' minutes = minutes < 10 ? "0" + minutes : minutes; var strTime = hours + ":" + minutes + " " + ampm; return strTime; }, createAttendence() { let studentId = localStorage.getItem("parentStudentId"); let todayDate = new Date(); var attendenceData = { classId: this.$route.query.classId, studentId: studentId, date: new Date().toISOString().substr(0, 10), studentAttendance: [ { courseId: this.$route.query.courseId, chapterId: this.$route.query.chapterId, liveClassId: this.attendenceLiveClassId, startTime: this.formatAMPM(new Date()), }, ], }; this.loading = true; http() .post("/createCourseAttendance", attendenceData) .then((response) => { |
275b17e4f
|
372 373 |
this.courseAttendanceId = response.data.data._id; this.updateCourseAttendance(); |
c301facad
|
374 375 376 377 378 379 380 381 382 383 |
this.loading = false; // this.snackbar = true; // this.color = "green"; }) .catch((err) => { this.loading = false; this.snackbar = true; this.color = "error"; }); }, |
e659e774f
|
384 385 386 387 388 389 390 391 392 393 394 395 396 397 |
updateLiveClass() { this.showLoader = true; var payloadData = { liveClassesId: this.liveClassId, }; http() .put("/updateLiveClasses", payloadData) .then((response) => { this.showLoader = false; }) .catch((error) => { this.showLoader = false; }); }, |
275b17e4f
|
398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 |
updateCourseAttendance() { this.showLoader = true; var payloadData = { courseAttendanceId: this.courseAttendanceId, liveClassId: this.attendenceLiveClassId, endTime: this.formatAMPM(new Date()), }; http() .put("/updateCourseAttendance", payloadData) .then((response) => { this.showLoader = false; }) .catch((error) => { this.showLoader = false; }); }, |
375b62cd1
|
414 |
async studentClasses() { |
fa975e45a
|
415 416 417 418 |
this.liveLink = ""; this.room = ""; this.username = ""; this.roomPassword = ""; |
375b62cd1
|
419 420 421 422 423 424 |
/* getLiveClassesesList - To up date line under heading*/ let response = await this.getLiveClassesesList({ classId: this.$route.query.classId, courseId: this.$route.query.courseId, chapterId: this.$route.query.chapterId, }); |
860da881d
|
425 |
// console.log("response getLiveClassesesList- ", response); |
c301facad
|
426 |
this.attendenceLiveClassId = response.data.data[0]._id; |
852713654
|
427 |
|
375b62cd1
|
428 |
/* CHECK RESPONSE TO ASSIGN MESSAGE INSIDE BUTTON */ |
6e1cb5c96
|
429 430 431 432 433 434 435 436 |
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"; } |
375b62cd1
|
437 438 439 440 441 |
if (response.data.data.length == 0) { this.startLiveSession = "Start Session"; this.studentBtn = ""; } else { this.liveLink = response.data.data[0].link; |
b6e4f6eaa
|
442 |
this.appLink = response.data.data[0].appLink; |
fa975e45a
|
443 |
var room = response.data.data[0].roomName; |
a690a86fb
|
444 445 |
var username = this.currentUser; var roomPassword = response.data.data[0].password; |
375b62cd1
|
446 |
var this_ = this; |
a690a86fb
|
447 |
// console.log(this.room, this.roomPassword, this.username); |
edfe025fa
|
448 |
|
fa975e45a
|
449 |
if (username != "" || room != "") { |
375b62cd1
|
450 451 |
if (window.JitsiMeetExternalAPI) { // var person = prompt("Please enter your name:", "Rabie"); |
fa975e45a
|
452 |
if (username != null || username != "") { |
a690a86fb
|
453 454 455 456 |
this_.username = username; } if (roomPassword != null || roomPassword != "") { this_.roomPassword = roomPassword; |
375b62cd1
|
457 458 |
} // var room = prompt("Please enter your room:", "Test Room"); |
fa975e45a
|
459 |
if (room != null || room != "") { |
a690a86fb
|
460 |
this_.room = room; |
375b62cd1
|
461 |
} |
6e1cb5c96
|
462 |
// this.startConference(); |
edfe025fa
|
463 |
} |
edfe025fa
|
464 |
} |
852713654
|
465 |
} |
375b62cd1
|
466 467 |
}, }, |
375b62cd1
|
468 |
async created() { |
860da881d
|
469 470 471 472 |
// console.log( // "this.$store.state.studentsData", // this.$store.state.studentsData[0].name // ); |
a690a86fb
|
473 |
this.currentUser = localStorage.getItem("studentName"); |
fa975e45a
|
474 |
this.token = this.$store.state.token; |
375b62cd1
|
475 |
if (this.$store.state.role === "PARENT") { |
6e1cb5c96
|
476 |
await this.studentClasses(); |
e91641fe5
|
477 478 479 480 481 482 |
} /* getStudentCourses - to get courseData - defined in GetApis.js*/ if (this.$store.state.role === "PARENT") { await this.getStudentCourses({ classId: localStorage.getItem("parentClassId"), |
375b62cd1
|
483 |
studentId: localStorage.getItem("parentStudentId"), |
e91641fe5
|
484 485 |
}); } |
375b62cd1
|
486 |
}, |
ac24ec07a
|
487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 |
}; </script> <style scoped> .side-bar-color { color: #827bfa !important; /* border-top-right-radius: 74px !important; */ } .card-border { border: 1px #bdbdbd solid; border-radius: 3px; } .reply-desc { border: 1px solid #f2f2f2; } .open-dialog-button { background: #827bfa !important; border-color: #827bfa !important; text-transform: none !important; } .reply-btn { background: #feb83c !important; border-color: #feb83c !important; text-transform: none !important; -webkit-box-shadow: none !important; box-shadow: none !important; } |
e91641fe5
|
514 515 516 |
#jitsi-container { height: 100vh; } |
ac24ec07a
|
517 |
</style> |