123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254 |
- @extends('layouts.guest-meeting')
- @section('content')
- <div id="meetingComponent">
- <h5 class="bg-dark font-weight-bold text-white m-0 py-3 px-4 d-flex">
- <span>Meeting</span>
- <span class="ml-auto" v-if="!started">
- Connecting...
- </span>
- <span class="ml-auto" v-if="started">
- <i class="fa fa-clock mr-1 text-light"></i>
- @{{ timeDisplay() }}
- </span>
- </h5>
- <div class="d-flex align-items-stretch mt-4 justify-content-center flex-nowrap">
- <div class="tp-bar">
- <div v-for="(guest, index) of guests"
- class="tp-item mb-4"
- :class="activeParticipant && activeType === 'guest' && activeParticipant.id === guest.id ? 'active' : ''"
- v-on:click="setActiveView('guest', guest)">
- <img :src="guest.image" alt="" class="w-100">
- <p class="font-weight-bold text-center mt-1 mb-0">@{{ guest.name }}</p>
- </div>
- <div v-if="!guest" class="tp-item mb-4">
- <img src="/images/person/guest.png" alt="" class="w-100">
- <p class="font-weight-bold text-center mt-1">Invite Guest</p>
- </div>
- </div>
- <div class="main-view" style="width: 800px; min-height: 600px;">
- <div class="p-4 w-100 h-100 d-flex align-items-stretch justify-content-stretch flex-column">
- <img :src="activeParticipant.image" class="d-block mw-100 mh-100 mx-auto">
- <p class="font-weight-bold text-center text-white mt-2">Feed from @{{ activeParticipant.name }}</p>
- </div>
- </div>
- <div class="tp-bar">
- <div v-for="(pro, index) of pros"
- class="tp-item mb-4"
- :class="activeParticipant && activeType === 'pro' && activeParticipant.id === pro.id ? 'active' : ''"
- v-on:click="setActiveView('pro', pro)">
- <div v-if="pro.status === 'active'">
- <img :src="pro.image" alt="" class="w-100">
- <p class="font-weight-bold text-center mt-1 mb-0">@{{ pro.name }}</p>
- <p class="font-weight-normal text-center">@{{ pro.type }}</p>
- </div>
- <div v-if="pro.status === 'connecting'">
- <img src="/images/person/connecting.jpg" alt="" class="w-100">
- <p class="font-weight-normal text-center mt-1 d-flex align-items-center justify-content-center">
- <img src="/images/loading.gif" class="mr-1">
- Connecting
- </p>
- </div>
- </div>
- </div>
- </div>
- </div>
- <script>
- new Vue({
- el: '#meetingComponent',
- delimiters: ['@{{', '}}'],
- data: {
- meetingID: '<?= $meetingID ?>',
- participantID: '<?= $participantID ?>',
- socket: null,
- stompClient: null,
- time: 0,
- startTime: 0,
- started: false,
- guest: false,
- activeType: false,
- activeParticipant: false,
- guests: [
- {
- id: 1,
- name: 'You',
- image: '/images/person/you.jpg',
- status: 'connecting',
- },
- ],
- pros: [
- {
- id: 1,
- name: 'Nancy Drew',
- type: 'Receptionist',
- image: '/images/person/nancy.jpg',
- status: 'connecting',
- }
- ]
- },
- methods: {
- setActiveView: function(_type, _participant) {
- if(_participant.status === 'active') {
- this.activeType = _type;
- this.activeParticipant = _participant;
- }
- },
- timeDisplay: function() {
- // this.time = new Date().getTime() - this.startTime;
- var seconds = this.time / 1000,
- minutes = parseInt(seconds / 60, 10);
- seconds = parseInt(seconds % 60, 10);
- return minutes + " min, " + seconds + " sec";
- },
- connectToFirstPro: function() {
- console.log('Connecting to first pro ...');
- this.pros = [];
- this.addPro();
- $.post('/api/meeting/request-dial-pro', {
- meetingUid: this.meetingID,
- }, function(_data) {
- console.log('Response to /api/meeting/request-dial-pro');
- console.log(_data);
- }, 'json');
- },
- addPro: function() {
- this.pros.push({
- id: '0',
- name: 'Pro',
- type: 'Receptionist',
- image: '/images/person/nancy.jpg',
- status: 'connecting',
- });
- return this.pros[this.pros.length - 1];
- },
- onProJoined: function(_pID) {
- var found = false;
- // find pro with participant id
- var pro = this.pros.filter(function(_pro) {
- return _pro.id === _pID;
- });
- // no pro with id, find first one with id = 0
- if(!pro.length) {
- pro = this.pros.filter(function(_pro) {
- return _pro.id === "0";
- });
- }
- // no pro with id = 0, create one
- if(!pro.length) {
- pro = this.addPro();
- }
- else {
- pro = pro[0];
- }
- pro.id = _pID;
- pro.status = 'active';
- // TODO: init pro stream
- },
- playDemo: function() {
- this.activeType = 'guest';
- this.activeParticipant = this.guests[0];
- var self = this;
- // after 2 seconds, connect recep
- window.setTimeout(function() {
- self.pros[0].status = 'active';
- self.started = true;
- self.startTime = new Date().getTime();
- self.activeType = 'pro';
- self.activeParticipant = self.pros[0];
- window.setInterval(function() {
- self.time = new Date().getTime() - self.startTime;
- }, 1000);
- // after 1 second, add 2 docs in connecting state
- window.setTimeout(function() {
- self.pros.push({
- id: 2,
- name: 'Dr. Strange',
- type: 'Dietitian',
- image: '/images/person/strange.0.jpg',
- status: 'connecting',
- });
- self.pros.push({
- id: 3,
- name: 'Dr. Do Little',
- type: 'Cardiologist',
- image: '/images/person/dl.jpg',
- status: 'connecting',
- });
- // after a second, connect strange
- window.setTimeout(function() {
- self.pros[1].status = 'active';
- window.setTimeout(function() {
- self.pros[2].status = 'active';
- }, 1000);
- }, 1000);
- }, 1000);
- }, 2000);
- }
- },
- mounted: function() {
- this.pros = [];
- // this.playDemo();
- var self = this;
- // connect to WS
- self.socket = new SockJS('http://localhost:8080/ws');
- self.stompClient = Stomp.over(self.socket);
- self.stompClient.connect({}, function (frame) {
- console.log('Connected: ' + frame);
- // join self
- self.stompClient.send(
- "/app/meeting-participant-join-meeting",
- {},
- JSON.stringify({meetingParticipantUid: self.participantID})
- );
- // set self as active
- self.guests[0].id = '<?= $participantID ?>';
- self.guests[0].status = 'active';
- // TODO: init own stream
- // attempt to connect to first pro if "start"
- @if(request('start'))
- self.connectToFirstPro();
- @endif
- // subscribe to on pro joined WS event
- self.stompClient.subscribe("/topic/on-pro-join-meeting", function(message){
- console.log("on-pro-join-meeting:", message);
- message = JSON.parse(message.body);
- console.log(message.meetingParticipantUid);
- self.onProJoined(message.meetingParticipantUid);
- });
- });
- }
- });
- </script>
- @endsection
|