diff --git a/gestaoRaul/comandas/__pycache__/htmx_views.cpython-310.pyc b/gestaoRaul/comandas/__pycache__/htmx_views.cpython-310.pyc index 7dff6ed..5ae061b 100644 Binary files a/gestaoRaul/comandas/__pycache__/htmx_views.cpython-310.pyc and b/gestaoRaul/comandas/__pycache__/htmx_views.cpython-310.pyc differ diff --git a/gestaoRaul/comandas/htmx_views.py b/gestaoRaul/comandas/htmx_views.py index 9bd6182..742c4d4 100644 --- a/gestaoRaul/comandas/htmx_views.py +++ b/gestaoRaul/comandas/htmx_views.py @@ -1,3 +1,4 @@ +from datetime import date from decimal import Decimal from django.http import JsonResponse from django.shortcuts import render, redirect @@ -69,10 +70,10 @@ def addProduct(request, product_id, comanda_id): 'message': f"""

{product.name}

- +

{order.obs}

{comanda.name} - {comanda.mesa.name}

+

{order.queue.strftime("%d/%m/%Y - %H:%M")}

Atendente: {comanda.user.first_name}

-

{order.queue}

diff --git a/gestaoRaul/db.sqlite3 b/gestaoRaul/db.sqlite3 index f8a14ed..89a83ba 100644 Binary files a/gestaoRaul/db.sqlite3 and b/gestaoRaul/db.sqlite3 differ diff --git a/gestaoRaul/templates/static/base.js b/gestaoRaul/templates/static/base.js index 56f948c..6c5b43b 100644 --- a/gestaoRaul/templates/static/base.js +++ b/gestaoRaul/templates/static/base.js @@ -70,6 +70,7 @@ websocket.addEventListener('message', (event) => { case 'cozinha': if (document.getElementById('Fila') !== null && data.tipo === 'add'){ const novoElemento = document.createElement('div'); + // const novoElemento = document.getElementById('Fila'); novoElemento.innerHTML = data.message; var fila = document.getElementById('Fila').appendChild(novoElemento); let valorAtual = document.cookie.replace(/(?:(?:^|.*;\s*)notificacao\s*\=\s*([^;]*).*$)|^.*$/, "$1"); diff --git a/gestaoRaul/templates/static/comandas/js/comandas.js b/gestaoRaul/templates/static/comandas/js/comandas.js index 294887c..bff295a 100644 --- a/gestaoRaul/templates/static/comandas/js/comandas.js +++ b/gestaoRaul/templates/static/comandas/js/comandas.js @@ -1,7 +1,4 @@ -document.cookie = `pronto=0`; - - function openModal() { document.getElementById('Modal-create-comanda').style.display = 'block'; @@ -49,36 +46,3 @@ function mostrarNotificacao(titulo,corpo,grupo) { } } -function notificacao(){ - - var resposta = fetch(`/comandas/notificacao/`, {method: 'GET', - headers: {'Content-Type': 'application/json', - },}) - .then(response => response.json()) - .then(data => { - if (data['notificacao'] == 'true'){ - console.log('verdadeiro') - document.cookie = `pronto=${data['pronto']}`; - mostrarNotificacao(data['titulo'], data['corpo'],'Garçom') - texto = new SpeechSynthesisUtterance(data['corpo']+', para '+data['titulo']+' tá pronto.'); - window.speechSynthesis.speak(texto); - console.log(data['notificacao']) - - }else{ - document.cookie = `pronto=${data['pronto']}`; - console.log('falso') - console.log(data['notificacao']) - } - }) - .catch(error => { - alert('Erro verificar notificação:', error,data['notificacao']) - }); - - } - - -setInterval(()=> { - notificacao() -}, 10000) - - diff --git a/gestaoRaul/templates/static/comandas/js/viewcomanda.js b/gestaoRaul/templates/static/comandas/js/viewcomanda.js index e9efba5..6299819 100644 --- a/gestaoRaul/templates/static/comandas/js/viewcomanda.js +++ b/gestaoRaul/templates/static/comandas/js/viewcomanda.js @@ -187,7 +187,6 @@ function addOrder(){ headers: { 'Content-Type': 'application/json'} }) - .then(function(response) { if(response.status == 200){ closeModalObs() @@ -195,7 +194,6 @@ function addOrder(){ }else{ showToast('❌Ocorreu um erro!😢','error') } - }) } function showToastAdd(message, type ,duration = 3000) { @@ -208,10 +206,7 @@ function showToastAdd(message, type ,duration = 3000) { } else if (type === 'info') { toast.style.backgroundColor = '#ffc107'; } - - const toastMessage = document.getElementById('toast-message-add'); - toastMessage.textContent = message; toast.classList.add('show'); @@ -221,28 +216,20 @@ function showToastAdd(message, type ,duration = 3000) { } function addProductComanda(productId,comandaId, cuisine) { obs = document.getElementById('obs'); - // console.log(obs.value); - // console.log(cuisine); if(cuisine == 'ggg'){ var obs = openModalObs(); - }else{ - fetch(`/comandas/addProduct${productId}/${comandaId}`, { method: 'GET', headers: { 'Content-Type': 'application/json'} }) - .then(function(response) { return response.text(); }).then(function(text) { var listProductsBalcaoElement = document.getElementById("list-products-comanda"); listProductsBalcaoElement.innerHTML = text; }) - // websocket.send(JSON.stringify({ type: 'broadcast', message: '

Tapioca de ovo

sem ovo

Joao - mesa 07

Atendente: Lucas

25/02/2025 20:03

' - //})); - showToastAdd('Produto adicionado com sucesso!😁','success'); } @@ -267,15 +254,3 @@ function taxa(){ // event.preventDefault(); // }); - - - - -// Enviar uma mensagem (exemplo - broadcast): -// websocket.send(JSON.stringify({ type: 'broadcast', message: 'Olá do cliente!' })); - -//enviar uma mensagem (exemplo - echo): -// websocket.send(JSON.stringify({"type": "echo", "message": "Olá Mundo!"})) - -//enviar uma mensagem (exemplo - test): -// websocket.send(JSON.stringify({"type": "test"})) diff --git a/gestaoRaul/templates/static/orders/js/orders.js b/gestaoRaul/templates/static/orders/js/orders.js index 3971539..0923a7c 100644 --- a/gestaoRaul/templates/static/orders/js/orders.js +++ b/gestaoRaul/templates/static/orders/js/orders.js @@ -49,25 +49,25 @@ function openTab(evt, etapa) { displayBlock('Fila'); - function mostrarNotificacao(titulo,corpo,grupo) { - if (Notification.permission != 'granted') { - Notification.requestPermission().then(function(permission) { - if (permission == 'granted') { - var notification = new Notification(titulo, { - body: corpo, - icon: 'https://example.com/icon.png' - }); - } - }); - } else { - var notification = new Notification(titulo, { - body: corpo, - icon: 'https://imagecolorpicker.com/imagecolorpicker-preview_b.avif', - image: 'https://imagecolorpicker.com/imagecolorpicker-preview_b.avif', +// function mostrarNotificacao(titulo,corpo,grupo) { +// if (Notification.permission != 'granted') { +// Notification.requestPermission().then(function(permission) { +// if (permission == 'granted') { +// var notification = new Notification(titulo, { +// body: corpo, +// icon: 'https://example.com/icon.png' +// }); +// } +// }); +// } else { +// var notification = new Notification(titulo, { +// body: corpo, +// icon: 'https://imagecolorpicker.com/imagecolorpicker-preview_b.avif', +// image: 'https://imagecolorpicker.com/imagecolorpicker-preview_b.avif', - }); - } -} +// }); +// } +// } // function notificacao(){ @@ -95,17 +95,3 @@ function openTab(evt, etapa) { // } - -// setInterval(()=> { -// notificacao() -// }, 10000) - - - - -// setTimeout(function() { -// mostrarNotificacao();}, 2000); - - - // mostrarNotificacao() - // notificacao() \ No newline at end of file diff --git a/gestaoRaul/websocket/servidor.py b/gestaoRaul/websocket/servidor.py index 2a82c29..3678e09 100644 --- a/gestaoRaul/websocket/servidor.py +++ b/gestaoRaul/websocket/servidor.py @@ -56,7 +56,9 @@ async def process_message(data, websocket): async def broadcast_message(data): if connected_clients: logging.info(f"Enviando mensagem por broadcast: {data}") - await asyncio.wait([client.send(json.dumps(data)) for client in connected_clients]) + # await asyncio.wait([client.send(json.dumps(data)) for client in connected_clients]) + tasks = [asyncio.create_task(client.send(json.dumps(data))) for client in connected_clients] + await asyncio.wait(tasks) else: logging.info("Nenhum cliente conectado.")