|
|
|
@ -358,12 +358,13 @@ function recorderVoice () {
|
|
|
|
|
* @returns
|
|
|
|
|
*/ |
|
|
|
|
const buildNotification = (data = {}) => { |
|
|
|
|
if(data.length == 'undefined'){ |
|
|
|
|
if(data.length == 'undefined' || (data.media == undefined && data.media == undefined) ){ |
|
|
|
|
return |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
const datesend = converdata(data.datetime) |
|
|
|
|
const status = data.status == 0 ? 'opacity-3' : '' |
|
|
|
|
|
|
|
|
|
return `<div class="chat ${status}" id="${data.uniqueid}" onclick="selectNotification(this.id)">
|
|
|
|
|
<div class="chat-left"> |
|
|
|
|
<img src="${path}/images/${data.media}.png"/> |
|
|
|
@ -460,8 +461,13 @@ const notifications = (obj = {}) => {
|
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
notification.data.sort((a, b) => b.status - a.status) |
|
|
|
|
notification.data.forEach(e => { |
|
|
|
|
|
|
|
|
|
let chat = notification.data.filter(function (a) { |
|
|
|
|
return !this[JSON.stringify(a.uniqueid)] && (this[JSON.stringify(a.uniqueid)] = true); |
|
|
|
|
}, Object.create(null)) |
|
|
|
|
|
|
|
|
|
chat.sort((a, b) => b.status - a.status) |
|
|
|
|
chat.forEach(e => { |
|
|
|
|
chatList += buildNotification({
|
|
|
|
|
uniqueid: e.uniqueid,
|
|
|
|
|
number: e.cliente_id,
|
|
|
|
@ -479,11 +485,11 @@ const notifications = (obj = {}) => {
|
|
|
|
|
|
|
|
|
|
const monitorPausaAgente = () => { |
|
|
|
|
statusAgente(localStorage.getItem('id_empresa'), localStorage.getItem('my_uniqueid')).then((agente) => { |
|
|
|
|
let statusagent = agente.data[0].status |
|
|
|
|
let statusagent = agente.data[0]?.status |
|
|
|
|
|
|
|
|
|
const status = [ |
|
|
|
|
{ status: "LIVRE", class: "status-connect", html: `id="entrePause" src="${path}/images/pause.svg" title="Atribuir uma pausa"`, descricao: statusagent }, |
|
|
|
|
{ status: "PAUSA", class: "status-desconnect", html: `id="exitPause" src="${path}/images/play.svg" title="Remover a pausa"`, descricao: `${statusagent} - ${agente.data[0].motivo_pausa}` }, |
|
|
|
|
{ status: "PAUSA", class: "status-desconnect", html: `id="exitPause" src="${path}/images/play.svg" title="Remover a pausa"`, descricao: `${statusagent} - ${agente.data[0]?.motivo_pausa}` }, |
|
|
|
|
{ status: "OCUPADO", class: "status-reconnect", html: `id="entrePause" src="${path}/images/pause.svg" title="Atribuir uma pausa"`, descricao: statusagent }, |
|
|
|
|
{ status: "INDISPONIVEL", class: "status-reconnect", html: `id="exitPause" src="${path}/images/play.svg" title="Remover a pausa"`, descricao: statusagent }, |
|
|
|
|
] |
|
|
|
@ -531,7 +537,7 @@ const connect = (wsserver) => {
|
|
|
|
|
|
|
|
|
|
ws.onerror = function(err) { |
|
|
|
|
alertModal( |
|
|
|
|
`<h2>CONECTANDO NO SISTEMA! POR FAVOR AGUARDE.</h2>`, |
|
|
|
|
`<h3>CONECTANDO NO SISTEMA! POR FAVOR AGUARDE.</h3>`, |
|
|
|
|
`<img id="imgReconnect" width="20px" src="${path}/images/loading.gif">` |
|
|
|
|
) |
|
|
|
|
$("#status_agent").addClass("status-desconnect").text('DESCONECTADO'); |
|
|
|
@ -541,6 +547,7 @@ const connect = (wsserver) => {
|
|
|
|
|
ws.onopen = function wsconnect() { |
|
|
|
|
$("#status_agent").addClass("status-reconnect").text('RECONECTANDO ...'); |
|
|
|
|
entrar(localStorage.getItem('my_uniqueid'), localStorage.getItem('obj_queue')).then((login) => { |
|
|
|
|
console.log(login) |
|
|
|
|
if(login.status == 'success' || login.message.indexOf('autenticado') >= 0){ |
|
|
|
|
$('#modalselect').css({display: 'none'}) |
|
|
|
|
monitorPausaAgente()
|
|
|
|
@ -548,7 +555,7 @@ const connect = (wsserver) => {
|
|
|
|
|
notifications() |
|
|
|
|
} else if(login.status == 'error'){ |
|
|
|
|
alertModal( |
|
|
|
|
`<h2>OPSS!! ${login.message}  </h2>`, |
|
|
|
|
`<h3>OPSS!! ${login.message}  </h3>`, |
|
|
|
|
`<img width="20px" src="${path}/images/alerta.png">` |
|
|
|
|
) |
|
|
|
|
$("#status_agent").addClass("status-desconnect").text('OFF'); |
|
|
|
@ -559,9 +566,8 @@ const connect = (wsserver) => {
|
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
ws.addEventListener("open", () => { |
|
|
|
|
const storage = ['my_uniqueid', 'keep_msg', 'obj_contact', 'session_uniqueid', 'session_window'] |
|
|
|
|
|
|
|
|
|
ws.addEventListener("message", e => { |
|
|
|
|
|
|
|
|
|
/** att: atualizacao do websocket */ |
|
|
|
|
if(e.data != 'att'){
|
|
|
|
|
const data = JSON.parse(e?.data) |
|
|
|
|