Skip to content

Instantly share code, notes, and snippets.

@elvishuges
Last active February 13, 2020 19:38
Show Gist options
  • Save elvishuges/acf873288c7195bb79b5226aacb7dcfd to your computer and use it in GitHub Desktop.
Save elvishuges/acf873288c7195bb79b5226aacb7dcfd to your computer and use it in GitHub Desktop.
<template>
<v-app id="inspire">
<v-content>
<v-layout class="pt-2 pb-0" row>
<v-flex xs10>
<img src="../assets/rect51522.png" width="350" class="left" />
</v-flex>
<v-flex class="right mt-2" xs2>
<h1>
<p v-text="currentTime"></p>
</h1>
</v-flex>
<v-flex xs1>
<v-btn
title="Logout"
@click="logout()"
flat
large
icon
color="primary"
class="right mt-2"
>
<v-icon title="Logout">logout</v-icon>
</v-btn>
</v-flex>
</v-layout>
<noscript>
<strong>
We're sorry but gestaofila doesn't work properly without JavaScript enabled. Please enable it to
continue.
</strong>
</noscript>
<!-- {{listaChamadas}} -->
<v-layout row justify-center>
<v-dialog v-model="aguardandoConexao" persistent width="300">
<v-card color="primary" dark>
<v-card-text>
Aguardando conexão...
<v-progress-linear indeterminate color="white" class="mb-0"></v-progress-linear>
</v-card-text>
</v-card>
</v-dialog>
</v-layout>
<div>
<div class="text-xs-center"></div>
<v-alert color="#A5D6A7" :value="notificacao" type="success" transition="scale-transition">
<h2
class="display-1"
>Dr. {{mensagemNomeMedicoNotificacao}} já se encontra pronto para atendimento no {{mensagemNomeLocalNotificacao}}</h2>
</v-alert>
</div>
<div id="player"></div>
<!-- tela para guiche -->
<div v-show="mostrarChamadas">
<v-layout>
<v-layout row>
<v-flex
class
v-if="listaChamadas.length > 0 && !listaChamadas[0].nomeConsultorio
"
xs12
>
<!-- <v-card class="rounded-card mx-auto" style=" border-radius: 20px;" color="#26A69A" dark max-width="1100"> -->
<v-card class="rounded-card mx-auto" color="#26A69A" dark>
<v-layout row>
<v-flex md6>
<v-card-title class="pt-0">
<div v-if="listaChamadas.length > 0" class="display-3 center">
<p
:class="brilhar ? 'teal--text': ''"
v-if="listaChamadas[0].prioridade == 1 || listaChamadas[0].prioridade == 3 "
>Prioridade</p>
<p v-else :class="brilhar ? 'teal--text': ''">Convencional</p>
</div>
</v-card-title>
<v-card-text pa-0 class="headline font-weight-bold">
<div
v-if="listaChamadas.length > 0"
class="pl-2 display-4 font-weight-bold left"
>
<h1
v-if="listaChamadas[0].prioridade === 0"
:class="brilhar ? 'teal--text': ''"
>C{{listaChamadas[0].codigo}}</h1>
<h1
v-if="listaChamadas[0].prioridade === 1"
:class="brilhar ? 'teal--text': ''"
>P{{listaChamadas[0].codigo}}</h1>
<h1
v-if="listaChamadas[0].prioridade === 2"
:class="brilhar ? 'teal--text': ''"
>B{{listaChamadas[0].codigo}}</h1>
<h1
v-if="listaChamadas[0].prioridade === 3"
:class="brilhar ? 'teal--text': ''"
>A{{listaChamadas[0].codigo}}</h1>
</div>
</v-card-text>
</v-flex>
<v-flex md6>
<v-card-title class="pt-0">
<div class="display-3 center">
<p v-if="!!Number(listaChamadas[0].guiche) || listaChamadas[0].guiche == 0" :class="brilhar ? 'teal--text': ''">Guichê</p>
<p v-else :class="brilhar ? 'teal--text': ''">Local</p>
</div>
</v-card-title>
<v-card-text class="headline font-weight-bold">
<div v-if="!Number(listaChamadas[0].guiche) && listaChamadas[0].guiche != 0"
class="display-3 pt-2 font-weight-bold left">
<h1
:class="brilhar ? 'teal--text mt-5 mb-5 ': ' mt-5 mb-5 yellow--text text--accent-3'"
>
{{listaChamadas[0].guiche}}</h1>
</div>
<div v-else class="display-4 font-weight-bold center">
<h1
:class="brilhar ? 'teal--text': 'yellow--text text--accent-3'"
>{{listaChamadas[0].guiche}}</h1>
</div>
</v-card-text>
</v-flex>
</v-layout>
</v-card>
</v-flex>
</v-layout>
</v-layout>
<!-- tela para paciente -->
<v-layout class v-if="listaChamadas.length > 0 && listaChamadas[0].nomeConsultorio
">
<v-layout row>
<v-flex xs12 class>
<v-card class="rounded-card mx-auto" color="primary" dark>
<v-layout row>
<v-flex md6 class="pb-0 pt-0 left">
<v-card-title>
<v-flex class="display-1 center" xs12>
<v-img :src="require('../assets/userIcon2.png')" height="200px" contain></v-img>
<br />
<p
:class="brilhar ? 'teal--text': ''"
class="display-3 text-truncate"
>{{nomeFormatado(listaChamadas[0].nomePaciente)}}</p>
<br />
</v-flex>
</v-card-title>
</v-flex>
<v-flex md6>
<v-card-text class="headline font-weight-bold">
<div class="display-1 center">
<p :class="brilhar ? 'teal--text display-2': 'withe--text display-2'">Local</p>
<p
:class="brilhar ? 'teal--text pb-0 display-3': 'yellow--text pb-0 display-3'"
>{{listaChamadas[0].nomeConsultorio}}</p>
<p
:class="brilhar ? 'teal--text pb-0 display-3': 'yellow--text pb-0 display-3'"
>{{listaChamadas[0].nomeLocal}}</p>
<div :class="brilhar ? 'teal--text': 'withe--text'">
Atendimento
<br />
Dr.
{{listaChamadas[0].nomeMedico}}
</div>
</div>
</v-card-text>
</v-flex>
</v-layout>
</v-card>
</v-flex>
<br />
</v-layout>
</v-layout>
<v-layout xs7 row class="pa-1 pl-3">
<v-flex xs12>
<div
class="left greyPrimary--text text-truncate display-1 font-weight-bold"
>Chamadas Anteriores</div>
</v-flex>
</v-layout>
<v-divider></v-divider>
<v-layout row>
<v-flex xs3>
<div v-if="listaChamadas.length > 2">
<div class="greyPrimary--text text-truncate display-1 font-weight-bold"></div>
<div
v-if="listaChamadas[1].prioridade === 0"
class="greyDark--text text-truncate display-4"
>
<h6>C{{listaChamadas[1].codigo}}</h6>
</div>
<div
v-if="listaChamadas[1].prioridade === 1"
class="greyDark--text text-truncate display-4"
>
<h6>P{{listaChamadas[1].codigo}}</h6>
</div>
<div
v-if="listaChamadas[1].prioridade === 2"
class="greyDark--text text-truncate display-4"
>
<h6>B{{listaChamadas[1].codigo}}</h6>
</div>
<div
v-if="listaChamadas[1].prioridade === 3"
class="greyDark--text text-truncate display-4"
>
<h6>A{{listaChamadas[1].codigo}}</h6>
</div>
<div
v-if="listaChamadas[1].nomeConsultorio
!= null "
class="greyDark--text text-truncate display-2 font-weight-bold"
>
Local
<br />
<div class="greyDark--text text-truncate display-2 font-weight-bold">
{{listaChamadas[1].nomeConsultorio
}}
<br />
<div class="red--text">{{listaChamadas[1].nomeLocal}}</div>
</div>
</div>
<div v-else class="greyDark--text text-truncate display-2 font-weight-bold">
<div v-if="!!Number(listaChamadas[1].guiche) || listaChamadas[1].guiche == 0">Guichê</div>
<div v-else>Local</div>
<h3 v-if="!!!Number(listaChamadas[1].guiche)" class="text-truncate">{{listaChamadas[1].guiche}}</h3>
<h2 v-else class="text-truncate">{{listaChamadas[1].guiche}}</h2>
</div>
</div>
</v-flex>
<v-flex xs3>
<div v-if="listaChamadas.length > 2">
<div class="greyPrimary--text text-truncate display-1"></div>
<div
v-if="listaChamadas[2].prioridade === 0"
class="greyDark--text text-truncate display-4"
>
<h6>C{{listaChamadas[2].codigo}}</h6>
</div>
<div
v-if="listaChamadas[2].prioridade === 1"
class="greyDark--text text-truncate display-4"
>
<h6>P{{listaChamadas[2].codigo}}</h6>
</div>
<div
v-if="listaChamadas[2].prioridade === 2"
class="greyDark--text text-truncate display-4"
>
<h6>B{{listaChamadas[2].codigo}}</h6>
</div>
<div
v-if="listaChamadas[2].prioridade === 3"
class="greyDark--text text-truncate display-4"
>
<h6>A{{listaChamadas[2].codigo}}</h6>
</div>
<div
v-if="listaChamadas[2].nomeConsultorio
!= null "
class="greyDark--text text-truncate display-2 font-weight-bold"
>
Local
<br />
<div class="greyDark--text text-truncate display-2 font-weight-bold">
{{listaChamadas[2].nomeConsultorio}}
<br />
<div class="red--text">{{listaChamadas[2].nomeLocal}}</div>
</div>
</div>
<div v-else class="greyDark--text text-truncate display-2 font-weight-bold">
<div v-if="!!Number(listaChamadas[2].guiche) || listaChamadas[2].guiche == 0">Guichê</div>
<div v-else>Local</div>
<h3 v-if="!!!Number(listaChamadas[2].guiche)" class="text-truncate">{{listaChamadas[2].guiche}}</h3>
<h2 v-else class="text-truncate">{{listaChamadas[2].guiche}}</h2>
</div>
</div>
</v-flex>
<v-flex xs3>
<div v-if="listaChamadas.length > 3">
<div class="greyPrimary--text text-truncate display-1 font-weight-bold"></div>
<div
v-if="listaChamadas[3].prioridade === 0"
class="greyDark--text text-truncate display-4 font-weight-bold"
>
<h6>C{{listaChamadas[3].codigo}}</h6>
</div>
<div
v-if="listaChamadas[3].prioridade === 1"
class="greyDark--text text-truncate display-4 font-weight-bold"
>
<h6>P{{listaChamadas[3].codigo}}</h6>
</div>
<div
v-if="listaChamadas[3].prioridade === 2"
class="greyDark--text text-truncate display-4 font-weight-bold"
>
<h6>B{{listaChamadas[3].codigo}}</h6>
</div>
<div
v-if="listaChamadas[3].prioridade === 3"
class="greyDark--text text-truncate display-4 font-weight-bold"
>
<h6>A{{listaChamadas[3].codigo}}</h6>
</div>
<div
v-if="listaChamadas[3].nomeConsultorio
!= null"
class="greyDark--text text-truncate display-2 font-weight-bold"
>
Local
<br />
<div class="greyDark--text text-truncate display-2 font-weight-bold">
{{listaChamadas[3].nomeConsultorio}}
<br />
<div class="red--text">{{listaChamadas[3].nomeLocal}}</div>
</div>
</div>
<div v-else class="greyDark--text text-truncate display-2 font-weight-bold">
<div v-if="!!Number(listaChamadas[3].guiche) || listaChamadas[3].guiche == 0">Guichê</div>
<div v-else>Local</div>
<h3 v-if="!!!Number(listaChamadas[3].guiche)" class="text-truncate">{{listaChamadas[3].guiche}}</h3>
<h2 v-else class="text-truncate">{{listaChamadas[3].guiche}}</h2>
</div>
</div>
</v-flex>
<v-flex xs3>
<div v-if="listaChamadas.length > 4">
<div class="greyPrimary--text text-truncate display-1 font-weight-bold"></div>
<div
v-if="listaChamadas[4].prioridade === 0"
class="greyDark--text text-truncate display-4 font-weight-bold"
>
<h6>C{{listaChamadas[4].codigo}}</h6>
</div>
<div
v-if="listaChamadas[4].prioridade === 1"
class="greyDark--text text-truncate display-4 font-weight-bold"
>
<h6>P{{listaChamadas[4].codigo}}</h6>
</div>
<div
v-if="listaChamadas[4].prioridade === 2"
class="greyDark--text text-truncate display-4 font-weight-bold"
>
<h6>B{{listaChamadas[4].codigo}}</h6>
</div>
<div
v-if="listaChamadas[4].prioridade === 3"
class="greyDark--text text-truncate display-4 font-weight-bold"
>
<h6>A{{listaChamadas[4].codigo}}</h6>
</div>
<div
v-if="listaChamadas[4].nomeConsultorio
!= null "
class="greyDark--text text-truncate display-2 font-weight-bold"
>
Local
<br />
<div class="greyDark--text">
{{listaChamadas[4].nomeConsultorio}}
<br />
<div class="red--text">{{listaChamadas[4].nomeLocal}}</div>
</div>
</div>
<div v-else class="greyDark--text text-truncate display-2 font-weight-bold">
<div v-if="!!Number(listaChamadas[4].guiche) || listaChamadas[4].guiche == 0">Guichê</div>
<div v-else>Local</div>
<h3 v-if="!!!Number(listaChamadas[4].guiche)" class="text-truncate">{{listaChamadas[4].guiche}}</h3>
<h2 v-else class="text-truncate">{{listaChamadas[4].guiche}}</h2>
</div>
</div>
</v-flex>
</v-layout>
</div>
</v-content>
</v-app>
</template>
<script>
import Cookies from "js-cookie";
import { getToken, setToken } from "../store/auth";
import visorService from "../services/visor.service";
import socketService from "../services/socket.service";
import speech from "speech-synth";
// import HelloWorld from '@/components/HelloWorld.vue'
export default {
name: "Painel",
created() {
var i1 = setInterval(() => this.iniciarContador(), 1000);
var i2 = setInterval(this.addMensagensVisorDelay, 200);
var i3 = setInterval(this.refreshToken, 21600000);
var i4 = setInterval(() => this.atualizarPainel(), 20 * 1000);
this.intervalos.push(i1);
this.intervalos.push(i2);
this.intervalos.push(i3);
this.intervalos.push(i4);
},
data() {
return {
selectedVoice: "", // 15 provavelmente é o valor para indioma brasileiro,
synth: window.speechSynthesis,
voiceList: [],
greetingSpeech: new window.SpeechSynthesisUtterance(),
URL_AUDIO:
"http://soundbible.com/mp3/Air Plane Ding-SoundBible.com-496729130.mp3",
executandoAudio: true,
usuario: {},
visorGuiche: false,
dialogAudio: false,
videoPlayer:'',
mostrarChamadas:true,
isTelevisao: 0,
player:'',
executandoAudioTimeout:false,
valid: false,
brilhar: false,
horario: "0:0",
socket: "",
intervalos: [],
currentTime: null,
mensagemNotificacaoSocket: "default",
mensagemNomeMedicoNotificacao: "",
mensagemNomeLocalNotificacao: "",
aguardandoConexao: false,
entrouEmAguardandoConexao: false,
exibindoMensagensVisor: false,
fila1MensagensVisor: [],
fila2MensagensVisor: [],
filaMensagemMedicoOnline: [],
notificacao: false,
IframeAPIReady:false,
listaChamadas: [],
date: new Date().getHours() + ":" + new Date().getMinutes(),
listaChamadasAux: [
{
codigo: "000",
prioridade: 0,
guiche: "0",
},
{
codigo: "000",
prioridade: 0,
guiche: "0"
},
{
codigo: "000",
prioridade: 0,
guiche: "0"
},
{
codigo: "000",
prioridade: 0,
guiche: "0"
},
{
codigo: "000",
prioridade: 0,
guiche: "0"
},
{
codigo: "000",
prioridade: 0,
guiche: "0"
}
]
};
},
beforeDestroy: function() {
console.log("em beforeDestroy...");
//this.socket.close()
this.limparIntervalos();
},
mounted() {
this.user = this.$store.getters.usuario;
this.isTelevisao == null ? this.isTelevisao = 0 : this.isTelevisao = this.user.isTelevisao
if(this.isTelevisao == 1){
this.mostrarChamadas = false
}
console.log("dados usuario", this.user);
console.log("is telev", this.isTelevisao);
if (this.user.tipo != 6) {
this.$router.push("/login");
return;
}
this.socket = io.connect(socketService.SOCKET_URL, {
query: {
token: getToken()
}
});
//this.dialogAudio = true;
this.voiceList = this.synth.getVoices();
if (this.voiceList.length) {
this.executandoAudio = false;
}
//const ut = new SpeechSynthesisUtterance('Bom dia Pessoal do Centro médico');
//speechSynthesis.speak(ut);
this.synth.onvoiceschanged = () => {
this.voiceList = this.synth.getVoices();
setTimeout(() => {
this.executandoAudio = false;
}, 800);
};
this.listenForSpeechEvents();
this.chamarSocket();
this.retornarChamadas();
var tag = document.createElement('script');
tag.src = "https://www.youtube.com/iframe_api";
var firstScriptTag = document.getElementsByTagName('script')[0];
firstScriptTag.parentNode.insertBefore(tag, firstScriptTag);
window.onYouTubeIframeAPIReady = function() {
this.IframeAPIReady = true
}.bind(this),
window.onPlayerReady = function(event) {
event.target.setVolume(0.5);
event.target.playVideo();
},
window.onPlayerStateChange = function(event) {
if (event.data == player.PlayerState.PLAYING && !done) {
setTimeout(stopVideo, 6000);
done = true;
}
}
let espera = setInterval(isLoaded, 200);
const _this = this
function isLoaded() {
if(_this.IframeAPIReady){
clearInterval(espera)
_this.criarVideo()
}
}
},
methods: {
buscaVozPortugues() {
return this.voiceList.filter(voz => voz.lang === "pt-BR");
},
criarVideo(){
console.log('videooooooooooooooooooooo');
var player
player = new YT.Player('player', {
videoId: 'hshcfVKHL40',
top:0,
bottom:0,
right:0,
left:0,
playerVars: {
playsinline:1,
muted:0,
},
events: {
'onReady': onPlayerReady,
'onStateChange': onPlayerStateChange
}
});
},
IniciarVideo(){
// 2. This code loads the IFrame Player API code asynchronously.
// 3. This function creates an <iframe> (and YouTube player)
// after the API code downloads.
var player;
// 4. The API will call this function when the video player is ready.
function onPlayerReady(event) {
event.target.playVideo();
}
// 5. The API calls this function when the player's state changes.
// The function indicates that when playing a video (state=1),
// the player should play for six seconds and then stop.
var done = false;
function onPlayerStateChange(event) {
if (event.data == YT.PlayerState.PLAYING && !done) {
setTimeout(stopVideo, 6000);
done = true;
}
}
function stopVideo() {
player.stopVideo();
}
},
onPlayerStateChange(event) {
if (event.data == this.player.PlayerState.PLAYING && !done) {
setTimeout(stopVideo, 6000);
done = true;
}
},
onPlayerReady(event) {
event.target.playVideo();
},
executandoAudioTimeoutMethod(){
this.executandoAudioTimeout = true
// Re-enable after 6 seconds
setTimeout(() => {
this.executandoAudioTimeout = false
}, 6000);
},
tempoExibirTelaChamada(){
this.mostrarChamadas = true
// Re-enable after 6 seconds
setTimeout(() => {
this.mostrarChamadas = false
}, 10000);
},
brilharMensagemVisor() {
for (let i = 0; i < 10; i++) {
setTimeout(
function() {
if (i % 2 == 0) {
this.brilhar = true;
} else {
this.brilhar = false;
}
}.bind(this),
i * 500
);
}
},
refreshToken() {
visorService.visor
.refreshToken(getToken())
.then(rsp => {
if (rsp.status == 200) {
setToken(rsp.data.token);
this.socket.close();
this.socket = io.connect(socketService.SOCKET_URL, {
query: {
token: getToken()
}
});
this.chamarSocket();
} else {
this.logout();
}
})
.catch(err => {
// handle your error here
console.log(err);
});
},
limparIntervalos() {
console.log("limpar intervalos");
this.intervalos.forEach(clearInterval);
},
iniciarAudio() {
this.playSound();
const context = new (window.AudioContext || window.webkitAudioContext)();
if (context.state !== "running") {
context.resume().then(() => (this.display = false));
} else {
this.display = false;
}
console.log(context.state);
this.dialogAudio = false;
},
chamarModalConexao() {
console.log("em chamarModalConexao..");
if (this.mensagemNotificacaoSocket == "aguardando conexao") {
console.log("em if aguard conex");
this.aguardandoConexao = true;
this.entrouEmAguardandoConexao = true;
}
if (this.mensagemNotificacaoSocket == "conectado") {
this.aguardandoConexao = false;
if (this.entrouEmAguardandoConexao) {
this.retornarChamadas();
this.entrouEmAguardandoConexao = false;
}
} else if (this.mensagemNotificacaoSocket == "desconectado") {
this.aguardandoConexao = true;
}
},
converteStringNome(str) {
var arr = str.split(" ");
if (arr.length > 1) {
var keep = arr[1][0].toUpperCase() != arr[1][0];
return arr.slice(0, keep ? 3 : 2).join(" ");
} else {
return str;
}
},
nomeFormatado(str) {
var arr = str.split(' ');
if(arr[1] != null){
var preposicao = arr[1].toLowerCase()
if (preposicao == 'de' || preposicao == 'da' || preposicao == 'das' || preposicao == 'do' || preposicao == 'dos') {
preposicao = true
} else{
preposicao = false
}
}
return arr.slice(0, preposicao ? 3 : 2).join(' ');
},
retornarChamadas(){
console.log("em retornar chamadas...");
visorService.visor
.retornarChamadas()
.then(rsp => {
console.log("retorno:", rsp.data);
this.listaChamadas = rsp.data;
this.carregarMensagens();
})
.catch(err => {
// handle your error here
console.log(err);
});
},
carregarMensagens() {
this.listaChamadasAux.forEach(element => {
this.listaChamadas.push(element);
});
},
playSound(sound) {
if (sound) {
var audio = new Audio(
require("../assets/Air Plane Ding-SoundBible.com-496729130.mp3")
);
audio.play();
}
},
greet(index) {
console.log("em greet executar som...");
this.playSound(
"http://soundbible.com/mp3/Air Plane Ding-SoundBible.com-496729130.mp3"
);
this.executandoAudioTimeoutMethod();
this.brilharMensagemVisor();
if (index == 1) {
var text = ". comparecer ao guichê"
if(!!!Number(this.listaChamadas[0].guiche)){
text = ". comparecer a"
}
if (this.listaChamadas[0].prioridade == 0) {
this.greetingSpeech.text = `senha ,C ${" , "} ${
this.listaChamadas[0].codigo
} ${text} ${this.listaChamadas[0].guiche}.`;
} else if (this.listaChamadas[0].prioridade == 1) {
this.greetingSpeech.text = `senha ,P ${" , "} ${
this.listaChamadas[0].codigo
} ${text} ${this.listaChamadas[0].guiche}.`;
} else if (this.listaChamadas[0].prioridade == 2) {
this.greetingSpeech.text = `senha ,B ${" , "} ${
this.listaChamadas[0].codigo
} ${text} ${this.listaChamadas[0].guiche}.`;
} else if (this.listaChamadas[0].prioridade == 3) {
this.greetingSpeech.text = `senha ,A ${" , "} ${
this.listaChamadas[0].codigo
} ${text} ${this.listaChamadas[0].guiche}.`;
}
} else if (index == 2) {
this.greetingSpeech.text = `paciente ${this.listaChamadas[0].nomePaciente}.
comparecer ao ${this.listaChamadas[0].nomeConsultorio} ${this.listaChamadas[0].nomeLocal}`;
}
this.greetingSpeech.voice = this.buscaVozPortugues()[0];
this.greetingSpeech.rate = 0.7;
this.greetingSpeech.pitch = 1;
this.synth.speak(this.greetingSpeech);
console.log("idioma encontrado", this.buscaVozPortugues()[0]);
},
atualizarPainel() {
var date = new Date(); // Create a Date object to find out what time it is
if (date.getHours() === 2 && date.getMinutes() === 0) {
// Check o harario para atualizar
console.log("atualizaou painel");
this.retornarChamadas();
}
},
iniciarContador() {
var today = new Date();
var h = today.getHours();
var m = today.getMinutes();
var s = today.getSeconds();
m = this.checkTime(m);
s = this.checkTime(s);
this.currentTime = h + ":" + m + ":" + s;
},
checkTime(i) {
if (i < 10) {
i = "0" + i;
} // add zero in front of numbers < 10
return i;
},
chamarSocket() {
console.log("em chamar socket...");
this.socket.on(
"medicoOnline",
function(mensagem) {
console.log("skt medicoOnline");
console.log(mensagem);
this.filaMensagemMedicoOnline.push(mensagem);
this.mensagemNomeMedicoNotificacao = mensagem.nomeMedico;
this.mensagemNomeLocalNotificacao = mensagem.nomeLocal;
this.notificacao = true;
setTimeout(() => {
this.escondeNotificacaoMedico();
}, 8000);
}.bind(this)
);
this.socket.on(
"chamando",
function(mensagem) {
console.log("skt chamando", mensagem);
if(this.isTelevisao == 1){
this.tempoExibirTelaChamada()
}
if (!this.executandoAudioTimeout &&
this.listaChamadas[0].codigo == mensagem.codigo &&
this.listaChamadas[0].guiche == mensagem.guiche) {
this.greet(1);
return;
} else if (!this.executandoAudioTimeout) {
this.listaChamadas.length = 7; // adicionado ...
this.listaChamadas.unshift(mensagem);
this.greet(1);
return;
} else {
this.fila1MensagensVisor.push(mensagem);
}
if (this.listaChamadas.length >= 7) {
// removido...
}
}.bind(this)
);
this.socket.on(
"chamandoPaciente",
function(mensagem) {
console.log("skt chamandoPaciente", mensagem);
if (
!this.executandoAudioTimeout &&
this.listaChamadas[0].codigo == mensagem.codigo &&
this.listaChamadas[0].nomePaciente == mensagem.nomePaciente &&
this.listaChamadas[0].nomeMedico == mensagem.nomeMedico &&
this.listaChamadas[0].local == mensagem.local
) {
this.greet(2);
return;
} else {
this.fila2MensagensVisor.push(mensagem);
}
}.bind(this)
);
// informações sobre a conexão de dados usando socket
this.socket.on(
"connect",
function(mensagem) {
this.mensagemNotificacaoSocket = "conectado";
this.chamarModalConexao();
}.bind(this)
);
this.socket.on("connect_error", () => {
this.mensagemNotificacaoSocket = "aguardando conexao";
this.chamarModalConexao();
});
this.socket.on(
"disconnect",
function() {
this.mensagemNotificacaoSocket = "desconectado";
this.chamarModalConexao();
}.bind(this)
);
},
escondeNotificacaoMedico() {
console.log("em esconde Notificacao Medico..");
this.notificacao = false;
},
// delay
addMensagensVisorDelay() {
// chmar essa funcao a cada 5 segundos
//console.log('em add mensagem visor..');
if (!this.executandoAudioTimeout) {
if (this.fila1MensagensVisor.length) {
this.fila1MensagensVisor.forEach((element, index) => {
setTimeout(() => {
console.log("delay");
this.listaChamadas.unshift(element);
this.greet(1);
}, 1000);
});
this.fila1MensagensVisor = [];
} else {
if (this.fila2MensagensVisor.length) {
this.fila2MensagensVisor.forEach((element, index) => {
setTimeout(() => {
console.log("delay");
this.listaChamadas.unshift(element);
this.greet(2);
}, 1000);
});
this.fila2MensagensVisor = [];
}
}
}
},
testarIteracao() {
this.playSound();
var compSequence = new Array("red", "blue", "yellow");
compSequence.forEach((element, index) => {
setTimeout(() => {
this.playSound();
}, 3000 * index);
});
},
addMensagemMedicoOnlineDelay() {
this.filaMensagemMedicoOnline.forEach(element => {
this.exibindoMensagensVisor = true;
setTimeout(
function() {
console.log("delay");
}.bind(this),
7000
);
});
},
listenForSpeechEvents() {
this.greetingSpeech.onstart = () => {
this.executandoAudio = true;
};
this.greetingSpeech.onend = () => {
this.executandoAudio = false;
};
},
logout() {
console.log("em logout..");
//this.$router.push("/login");
this.$store
.dispatch("FedLogOut")
.then(rsp => {
console.log("11111111");
this.limparIntervalos();
if (this.socket) {
this.socket.close();
this.socket.disconnect();
}
this.$router.push("/login");
if (r) {
}
})
.catch(error => {
// this.progress = false;
// this.alert = true;
// this.msg = error;
});
}
}
};
</script>
<style scoped>
.underline {
text-decoration: underline;
}
.fullscream{
position: fixed;
right: 0;
bottom: 0;
min-width: 100%;
min-height: 90%;
}
</style>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment