alteração da rota para o pusher e portas de comunicação
This commit is contained in:
parent
97b4d2c90e
commit
8280bb2ff6
|
|
@ -1,17 +1,19 @@
|
|||
<!DOCTYPE html>
|
||||
<html>
|
||||
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta http-equiv="Content-Security-Policy" content="
|
||||
default-src 'self';
|
||||
script-src 'self' 'unsafe-inline';
|
||||
style-src 'self' 'unsafe-inline';
|
||||
connect-src 'self' ws://autoatend.linco.work:6001 ws://localhost:6001;
|
||||
connect-src 'self' ws://autoatend.linco.work:6001 ws://localhost:6001 wss://aa.linco.work:443;
|
||||
">
|
||||
<title>Tela de Atendimento</title>
|
||||
<link rel="stylesheet" href="style.css">
|
||||
<script src="res/js/jquery/jquery.js"></script>
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<div id="list-view">
|
||||
<h1>Fila</h1>
|
||||
|
|
@ -47,4 +49,5 @@
|
|||
<script src="renderer.js"></script>
|
||||
|
||||
</body>
|
||||
|
||||
</html>
|
||||
80
main.js
80
main.js
|
|
@ -4,7 +4,7 @@ const path = require('path');
|
|||
const fs = require('fs');
|
||||
|
||||
const { autoUpdater, AppUpdater } = require('electron-updater');
|
||||
const pjson = require(path.join(__dirname,'','package.json'));
|
||||
const pjson = require(path.join(__dirname, '', 'package.json'));
|
||||
|
||||
let floatingWin;
|
||||
let mainWin;
|
||||
|
|
@ -16,7 +16,7 @@ const dataPath = path.join(__dirname, 'data.json'); // Caminho para o JSON (back
|
|||
const apiUrl = 'https://autoatend.linco.work/api/v1/';
|
||||
// const apiUrl = 'http://_lara10-autoatend.devel/api/v1/';
|
||||
|
||||
const pusherUrl = 'autoatend.linco.work';
|
||||
const pusherUrl = 'aa.linco.work';
|
||||
// const pusherUrl = 'localhost';
|
||||
|
||||
|
||||
|
|
@ -54,18 +54,18 @@ async function fetchDataFromAPI() {
|
|||
getFirstData();
|
||||
|
||||
//! as outras é o websockt que solicita a chamada de requisições em busca de alterações
|
||||
const updData = setInterval(()=>{
|
||||
const updData = setInterval(() => {
|
||||
getDataAndUpdateFloatingBtn();
|
||||
},3000);
|
||||
}, 3000);
|
||||
|
||||
const updVersion = setTimeout(()=>{
|
||||
if(pjson.isBuildNow){
|
||||
const updVersion = setTimeout(() => {
|
||||
if (pjson.isBuildNow) {
|
||||
autoUpdater.checkForUpdates();
|
||||
}
|
||||
},300000);
|
||||
}, 300000);
|
||||
}
|
||||
|
||||
async function getFirstData(){
|
||||
async function getFirstData() {
|
||||
|
||||
const token = await getAuthToken();
|
||||
const colabId = await floatingWin.webContents.executeJavaScript("localStorage.getItem('idOperator')")
|
||||
|
|
@ -117,7 +117,7 @@ async function getFirstData(){
|
|||
}
|
||||
|
||||
// Função para coletar a lista de atendimentos do servidor, vai ser chamada uma vez e a cada 30s
|
||||
async function getDataAndUpdateFloatingBtn (){
|
||||
async function getDataAndUpdateFloatingBtn() {
|
||||
|
||||
const proximos = JSON.parse(await floatingWin.webContents.executeJavaScript("localStorage.getItem('proximos')")) ?? [];
|
||||
let count = proximos.length;
|
||||
|
|
@ -256,7 +256,7 @@ function createFloatingWindow() {
|
|||
|
||||
floatingWin.loadFile('floating.html');
|
||||
|
||||
floatingWin.webContents.executeJavaScript('localStorage.setItem("version","'+app.getVersion()+'")');
|
||||
floatingWin.webContents.executeJavaScript('localStorage.setItem("version","' + app.getVersion() + '")');
|
||||
|
||||
// Envia a contagem inicial para a janela flutuante
|
||||
const data = readData();
|
||||
|
|
@ -307,24 +307,24 @@ function createMainWindow() {
|
|||
}
|
||||
|
||||
|
||||
if(pjson.isBuildNow){
|
||||
if (pjson.isBuildNow) {
|
||||
autoUpdater.on('update-available', () => {
|
||||
let pth = autoUpdater.downloadUpdate();
|
||||
updateWin.show(); updateWin.focus();
|
||||
updateWin.webContents.send('update_message',`Uma nova versão está dispinível.`);
|
||||
updateWin.webContents.send('update_percent',pth);
|
||||
updateWin.webContents.send('update_message', `Uma nova versão está dispinível.`);
|
||||
updateWin.webContents.send('update_percent', pth);
|
||||
})
|
||||
autoUpdater.on('download-progress',(obj) => {
|
||||
updateWin.webContents.send('update_message',`Estamos baixando uma nova atualização.`);
|
||||
autoUpdater.on('download-progress', (obj) => {
|
||||
updateWin.webContents.send('update_message', `Estamos baixando uma nova atualização.`);
|
||||
});
|
||||
autoUpdater.on('update-downloaded',(obj) => {
|
||||
updateWin.webContents.send('update_message',`Download concluído. Aguarde, vamos reiniciar para instalar!`);
|
||||
setTimeout(()=>{
|
||||
autoUpdater.on('update-downloaded', (obj) => {
|
||||
updateWin.webContents.send('update_message', `Download concluído. Aguarde, vamos reiniciar para instalar!`);
|
||||
setTimeout(() => {
|
||||
autoUpdater.quitAndInstall();
|
||||
},5000);
|
||||
}, 5000);
|
||||
});
|
||||
autoUpdater.on('error',err => {
|
||||
updateWin.webContents.send('update_message',err);
|
||||
autoUpdater.on('error', err => {
|
||||
updateWin.webContents.send('update_message', err);
|
||||
});
|
||||
}
|
||||
|
||||
|
|
@ -377,7 +377,7 @@ if (!gotTheLock) {
|
|||
}
|
||||
});
|
||||
|
||||
if(pjson.isBuildNow){
|
||||
if (pjson.isBuildNow) {
|
||||
autoUpdater.checkForUpdates();
|
||||
}
|
||||
|
||||
|
|
@ -436,11 +436,11 @@ ipcMain.handle('get-pusher-config', async () => {
|
|||
});
|
||||
|
||||
ipcMain.on('update_version', async (event, arg) => {
|
||||
if(updateWin){
|
||||
if(!updateWin.isVisible()){
|
||||
if (updateWin) {
|
||||
if (!updateWin.isVisible()) {
|
||||
updateWin.show();
|
||||
updateWin.focus();
|
||||
}else{
|
||||
} else {
|
||||
updateWin.focus();
|
||||
}
|
||||
} else {
|
||||
|
|
@ -484,14 +484,14 @@ ipcMain.on('chamar-fila', async () => {
|
|||
}
|
||||
}
|
||||
|
||||
const requestData = async () =>{
|
||||
const requestData = async () => {
|
||||
|
||||
|
||||
|
||||
|
||||
const colabId = await getSelectedOperatorId();
|
||||
const token = await getAuthToken('token');
|
||||
const url = apiUrl + 'chama-fila-app-colab/'+colabId; // URL de exemplo para enviar a solicitação
|
||||
const url = apiUrl + 'chama-fila-app-colab/' + colabId; // URL de exemplo para enviar a solicitação
|
||||
|
||||
const request = net.request({
|
||||
method: 'GET',
|
||||
|
|
@ -515,17 +515,17 @@ ipcMain.on('chamar-fila', async () => {
|
|||
if (response.statusCode === 200) {
|
||||
mainWin.webContents.send('select-atend-id', parsedData.data);
|
||||
if (parsedData.data && (parsedData.data.Status === 'Fila' || parsedData.data.Status === 'Chamado')) { showMainWindow(); } else
|
||||
if(parsedData.data && parsedData.data.Status === 'Atendendo'){
|
||||
if (parsedData.data && parsedData.data.Status === 'Atendendo') {
|
||||
let options2 = {
|
||||
'title': 'Precisa finalizar antes de chamar o próximo.',
|
||||
'message': 'Em andamento',
|
||||
'detail': 'Já possui um atendimento em andamento (Atendendo: '+ parsedData.data.clientName +'), continue e finalize por favor!',
|
||||
'detail': 'Já possui um atendimento em andamento (Atendendo: ' + parsedData.data.clientName + '), continue e finalize por favor!',
|
||||
'type': 'error',
|
||||
'noLink': true,
|
||||
'buttons': ['Depois','Continuar'],
|
||||
'buttons': ['Depois', 'Continuar'],
|
||||
};
|
||||
dialog.showMessageBox(floatingWin, options2).then(result => {
|
||||
if(result.response){
|
||||
if (result.response) {
|
||||
mainWin.webContents.send('show-observation');
|
||||
showMainWindow();
|
||||
} else {
|
||||
|
|
@ -567,13 +567,13 @@ ipcMain.on('chamar-fila', async () => {
|
|||
'message': 'Chamar um cliente da fila?',
|
||||
'type': 'warning',
|
||||
'noLink': true,
|
||||
'buttons': ['Não','Sim'],
|
||||
'buttons': ['Não', 'Sim'],
|
||||
};
|
||||
|
||||
|
||||
if(await countFila()){
|
||||
if (await countFila()) {
|
||||
dialog.showMessageBox(floatingWin, options).then(result => {
|
||||
if(result.response){
|
||||
if (result.response) {
|
||||
requestData();
|
||||
};
|
||||
});
|
||||
|
|
@ -583,7 +583,7 @@ ipcMain.on('chamar-fila', async () => {
|
|||
|
||||
});
|
||||
|
||||
ipcMain.on('select-atend-id',(itemId)=>{
|
||||
ipcMain.on('select-atend-id', (itemId) => {
|
||||
selectedItemId = itemId;
|
||||
console.log(selectedItemId);
|
||||
});
|
||||
|
|
@ -595,9 +595,9 @@ ipcMain.on('iniciar-atendimento', async (event, itemId) => {
|
|||
const colabId = await floatingWin.webContents.executeJavaScript("localStorage.getItem('idOperator')")
|
||||
//TODO inicia o atendimento o id do atendimento deve ser requisitado do backend
|
||||
|
||||
const url = apiUrl + 'iniciar-atendimento/'+itemId; // URL de exemplo para enviar a solicitação
|
||||
const url = apiUrl + 'iniciar-atendimento/' + itemId; // URL para enviar a solicitação
|
||||
|
||||
// Simula o envio de uma solicitação POST com o ID do item
|
||||
// envio de uma solicitação POST com o ID do item
|
||||
const request = net.request({
|
||||
method: 'GET',
|
||||
url: url,
|
||||
|
|
@ -643,7 +643,7 @@ ipcMain.on('save-observation', async (event, { itemId, observation }) => {
|
|||
const colabId = await floatingWin.webContents.executeJavaScript("localStorage.getItem('idOperator')")
|
||||
//TODO inicia o atendimento o id do atendimento deve ser requisitado do backend
|
||||
|
||||
const url = apiUrl + 'finalizar-atendimento/'+itemId; // URL de exemplo para enviar a solicitação
|
||||
const url = apiUrl + 'finalizar-atendimento/' + itemId; // URL de exemplo para enviar a solicitação
|
||||
|
||||
const fmData = JSON.stringify({
|
||||
"colabId": colabId,
|
||||
|
|
@ -699,7 +699,7 @@ ipcMain.on('drag-float-window', (event, { offsetX, offsetY }) => {
|
|||
*/
|
||||
|
||||
|
||||
ipcMain.on('logout', ()=>{
|
||||
ipcMain.on('logout', () => {
|
||||
mainWin.webContents.executeJavaScript(`
|
||||
localStorage.removeItem("idOperator");
|
||||
localStorage.removeItem("selectedOperator");
|
||||
|
|
@ -927,7 +927,7 @@ ipcMain.on('token-exists', async () => {
|
|||
});
|
||||
|
||||
|
||||
ipcMain.on('sair', ()=>{
|
||||
ipcMain.on('sair', () => {
|
||||
let exec = `
|
||||
localStorage.removeItem("idOperator");
|
||||
localStorage.removeItem("selectedOperator");
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
{
|
||||
"name": "autoatendcolab",
|
||||
"version": "1.1.2",
|
||||
"version": "1.1.3",
|
||||
"main": "main.js",
|
||||
"isBuildNow": true,
|
||||
"scripts": {
|
||||
|
|
|
|||
28
renderer.js
28
renderer.js
|
|
@ -18,7 +18,7 @@ let selectedItemName = '';
|
|||
|
||||
window.electronAPI.onLoadData((data) => {
|
||||
nextButton.disabled = true;
|
||||
if(!data){
|
||||
if (!data) {
|
||||
return;
|
||||
}
|
||||
// Reseta a view para a lista sempre que os dados são carregados
|
||||
|
|
@ -44,11 +44,11 @@ async function initializePusher() {
|
|||
|
||||
var pusher = new Pusher(PUSHER_APP_KEY, {
|
||||
wsHost: host,
|
||||
wsPort: 6001,
|
||||
wssPort: 6001,
|
||||
forceTLS: false,
|
||||
wsPort: 80,
|
||||
wssPort: 443,
|
||||
forceTLS: true,
|
||||
enableStats: false,
|
||||
enabledTransports: ['ws','wss'],
|
||||
enabledTransports: ['wss', 'ws'],
|
||||
cluster: 'mt1'
|
||||
});
|
||||
|
||||
|
|
@ -59,17 +59,17 @@ async function initializePusher() {
|
|||
|
||||
channel = pusher.subscribe('chat.' + channelLocal + '_' + colabId);
|
||||
|
||||
channel.bind('message-sent', function(r) {
|
||||
channel.bind('message-sent', function (r) {
|
||||
let data = r.data.fila.original;
|
||||
let count = data.length;
|
||||
console.log(data);
|
||||
localStorage.setItem('proximos',JSON.stringify(data));
|
||||
localStorage.setItem('proximos', JSON.stringify(data));
|
||||
|
||||
populateList(r.data.currentData.original);
|
||||
|
||||
});
|
||||
|
||||
pusher.connection.bind('error', function(err) {
|
||||
pusher.connection.bind('error', function (err) {
|
||||
console.error('Pusher connection error: ', err);
|
||||
});
|
||||
|
||||
|
|
@ -82,9 +82,9 @@ async function initializePusher() {
|
|||
initializePusher();
|
||||
|
||||
//chama o proximo da fila ao abrir a janela de atendimentos
|
||||
window.electronAPI.selectAtendID((data)=>{
|
||||
window.electronAPI.selectAtendID((data) => {
|
||||
nextButton.disabled = true;
|
||||
if(!data){
|
||||
if (!data) {
|
||||
queueNumber.innerHTML = 'Ninguem aguardando atendimento, fechando a janela em alguns segundos...';
|
||||
return;
|
||||
}
|
||||
|
|
@ -97,7 +97,7 @@ window.electronAPI.selectAtendID((data)=>{
|
|||
selectedItemNameSpan.innerHTML = data ? `<u> ${data.clientName.toUpperCase()} </u> <i style="float:right;">[ ${data.senhaGen} ]</i>` : 'Ninguem aguardando atendimento';
|
||||
});
|
||||
|
||||
window.electronAPI.showObservation(()=>{
|
||||
window.electronAPI.showObservation(() => {
|
||||
window.electronAPI.iniciaAtendimento(selectedItemId);
|
||||
showObservationView(); // Muda para a tela de observação
|
||||
});
|
||||
|
|
@ -110,9 +110,9 @@ function populateList(currentData) {
|
|||
const proximos = JSON.parse(datastorage);
|
||||
itemList.innerHTML = '';
|
||||
|
||||
setTimeout(()=>{
|
||||
setTimeout(() => {
|
||||
nextButton.disabled = !currentData;
|
||||
},5000);
|
||||
}, 5000);
|
||||
|
||||
// Seleciona o primeiro item por padrão (ou o próximo disponível)
|
||||
// Aqui, vamos apenas pegar o primeiro da lista atual
|
||||
|
|
@ -172,7 +172,7 @@ nextButton.addEventListener('click', () => {
|
|||
|
||||
|
||||
|
||||
logoutButton.addEventListener('click',()=>{
|
||||
logoutButton.addEventListener('click', () => {
|
||||
window.electronAPI.logoutApp();
|
||||
});
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue