diff --git a/gestaoRaul/db.sqlite3 b/gestaoRaul/db.sqlite3 index a943193..60b004b 100644 Binary files a/gestaoRaul/db.sqlite3 and b/gestaoRaul/db.sqlite3 differ diff --git a/gestaoRaul/mesas/__pycache__/urls.cpython-313.pyc b/gestaoRaul/mesas/__pycache__/urls.cpython-313.pyc index c55ffd8..4f2711f 100644 Binary files a/gestaoRaul/mesas/__pycache__/urls.cpython-313.pyc and b/gestaoRaul/mesas/__pycache__/urls.cpython-313.pyc differ diff --git a/gestaoRaul/mesas/__pycache__/views.cpython-313.pyc b/gestaoRaul/mesas/__pycache__/views.cpython-313.pyc index 363a857..c5c2333 100644 Binary files a/gestaoRaul/mesas/__pycache__/views.cpython-313.pyc and b/gestaoRaul/mesas/__pycache__/views.cpython-313.pyc differ diff --git a/gestaoRaul/mesas/templates/mesas_map.html b/gestaoRaul/mesas/templates/mesas_map.html index ffcdae0..7b73e33 100644 --- a/gestaoRaul/mesas/templates/mesas_map.html +++ b/gestaoRaul/mesas/templates/mesas_map.html @@ -4,6 +4,8 @@ {% block 'head' %} + + {% endblock %} {% block 'title' %} @@ -12,84 +14,31 @@ RRB&C - Mapa de Mesas {% block 'body' %} - - - - - - - -
+
{% for eixo in eixosXY %}
+ top: {{eixo.x}}px;position: absolute"> +
{% endfor %} +
{% for mesa in mesas %} {% if mesa.active == True %} -
{{mesa.name}}
+
{{mesa.name}}
{% else %} -
{{mesa.name}}
+
{{mesa.name}}
{% endif %} {% endfor %} - - - {% endblock %} \ No newline at end of file diff --git a/gestaoRaul/mesas/urls.py b/gestaoRaul/mesas/urls.py index 25ffc3b..4367fef 100644 --- a/gestaoRaul/mesas/urls.py +++ b/gestaoRaul/mesas/urls.py @@ -5,6 +5,7 @@ from . import views urlpatterns = [ path('', views.mesas, name='mesas'), path('mapMesas/', views.mapMesas, name='mapMesas'), + path('locationMesa///', views.locationMesa, name='locationMesa'), diff --git a/gestaoRaul/mesas/views.py b/gestaoRaul/mesas/views.py index 9322ec0..3e61760 100644 --- a/gestaoRaul/mesas/views.py +++ b/gestaoRaul/mesas/views.py @@ -1,4 +1,6 @@ -from django.shortcuts import render,redirect +from django.shortcuts import render,redirect, HttpResponse +from django.http import JsonResponse + from mesas.models import Mesa @@ -19,6 +21,11 @@ def mapMesas(request): mesas = Mesa.objects.all() return render(request, 'mesas_map.html', {'mesas': mesas, 'eixosXY': eixosXY}) +def locationMesa(request, mesaId, location): + mesa = Mesa.objects.get(id=mesaId) + mesa.location = location + mesa.save() + return JsonResponse({'status': 'ok'}) # def onOffmesa(request): # id = request.POST.get('id-mesa') # mesa_id = int(id) diff --git a/gestaoRaul/templates/static/mesas/css/mesas.css b/gestaoRaul/templates/static/mesas/css/mesas.css index fa78942..fde5acc 100644 --- a/gestaoRaul/templates/static/mesas/css/mesas.css +++ b/gestaoRaul/templates/static/mesas/css/mesas.css @@ -27,7 +27,7 @@ box-shadow: 5px 5px 10px rgba(0, 0, 0, 0.2); text-align: center; line-height: 50px; /* Centraliza o texto verticalmente */ - font-size: 20px; + font-size: 10px; font-weight: bold; color: #333; /* position: absolute; */ @@ -54,4 +54,9 @@ .elemento { position: absolute; +} + +.espaco { + border: 0.3px solid #cccccc56; + padding: 0px; } \ No newline at end of file diff --git a/gestaoRaul/templates/static/mesas/js/mesas_map.js b/gestaoRaul/templates/static/mesas/js/mesas_map.js new file mode 100644 index 0000000..e56481b --- /dev/null +++ b/gestaoRaul/templates/static/mesas/js/mesas_map.js @@ -0,0 +1,70 @@ +document.addEventListener('dragstart', (e) => { + e.target.classList.add('dragging'); +}); + +document.addEventListener('dragover', (e) => { + e.preventDefault(); + const target = e.target; + if (target.classList.contains('column')) { + target.style.backgroundColor = ''; + } +}); + +document.addEventListener('dragend', (e) => { + e.target.classList.remove('dragging'); + document.querySelectorAll('.column').forEach(column => { + column.style.backgroundColor = ''; + }); +}); + +document.addEventListener('drop', (e) => { + e.preventDefault(); + const draggable = document.querySelector('.dragging'); + e.target.appendChild(draggable); +}); +function manipularCards() { + const cards = document.querySelectorAll('.m-card'); + + cards.forEach(card => { + const input = card.querySelector('input'); + const inputValue = input.value; + const targetElement = document.getElementById(inputValue); + + if (targetElement) { + targetElement.appendChild(card); + } else { + console.error(`Elemento com ID ${inputValue} não encontrado.`); + } + }); +} + +function saveLocal() { + const draggedElement = event.dataTransfer.getData('text/plain'); + +const mesaElement = event.target; +const targetElement = event.target.parentNode; +const mesaId = mesaElement.id + +const targetId = targetElement.id; +const url = `/mesas/locationMesa/${mesaId}/${targetId}/`; +var resposta = fetch(url, {method: 'GET', headers: {'Content-Type': 'application/json' + },}).then(response => response.json()) + .then(data => { + console.log(data); + if(data.status == 'ok'){ + alert('Mesa movida com sucesso!') + } + }) + .catch(error => { + console.error('Erro ao salvar local:', error); + }); + +} + +setTimeout(function() { + manipularCards();}, 1); + + setTimeout() + + +