frontend: fix cab list on arcade page

This commit is contained in:
Hay1tsme 2024-01-09 20:08:10 -05:00
parent d672edb266
commit 0a56207e90
3 changed files with 27 additions and 7 deletions

View File

@ -677,24 +677,30 @@ class FE_Arcade(FE_Base):
sesh=vars(usr_sesh), sesh=vars(usr_sesh),
)) ))
try: sinfo = await self.data.arcade.get_arcade(shop_id)
sinfo = await self.data.arcade.get_arcade(shop_id)
except Exception as e:
self.logger.error(f"Failed to fetch shop info for shop {shop_id} in render_GET - {e}")
sinfo = None
if not sinfo: if not sinfo:
return Response(template.render( return Response(template.render(
title=f"{self.core_config.server.name} | Arcade", title=f"{self.core_config.server.name} | Arcade",
sesh=vars(usr_sesh), sesh=vars(usr_sesh),
)) ))
cabs = await self.data.arcade.get_arcade_machines(shop_id)
cablst = []
if cabs:
for x in cabs:
cablst.append({
"id": x['id'],
"serial": x['serial'],
"game": x['game'],
})
return Response(template.render( return Response(template.render(
title=f"{self.core_config.server.name} | Arcade", title=f"{self.core_config.server.name} | Arcade",
sesh=vars(usr_sesh), sesh=vars(usr_sesh),
arcade={ arcade={
"name": sinfo['name'], "name": sinfo['name'],
"id": sinfo['id'], "id": sinfo['id'],
"cabs": [] "cabs": cablst
} }
)) ))

View File

@ -1,4 +1,19 @@
{% extends "core/templates/index.jinja" %} {% extends "core/templates/index.jinja" %}
{% block content %} {% block content %}
{% if arcade is defined %}
<h1>{{ arcade.name }}</h1> <h1>{{ arcade.name }}</h1>
<h2>PCBs assigned to this arcade <button class="btn btn-success" id="btn_add_cab" onclick="toggle_add_cab_form()">Add</button></h2>
{% if success is defined and success == 3 %}
<div style="background-color: #00AA00; padding: 20px; margin-bottom: 10px; width: 15%;">
Cab added successfully
</div>
{% endif %}
<ul style="font-size: 20px;">
{% for c in arcade.cabs %}
<li><a href="/cab/{{ c.id }}">{{ c.serial }} ({{ c.game }})</a>&nbsp;<button class="btn btn-secondary" onclick="prep_edit_form()">Edit</button>&nbsp;<button class="btn-danger btn">Delete</button></li>
{% endfor %}
</ul>
{% else %}
<h3>Arcade Not Found</h3>
{% endif %}
{% endblock content %} {% endblock content %}

View File

@ -1,5 +1,4 @@
{% extends "core/templates/index.jinja" %} {% extends "core/templates/index.jinja" %}
{% block content %} {% block content %}
{% include "core/templates/widgets/err_banner.jinja" %}
<h1>Machine Management</h1> <h1>Machine Management</h1>
{% endblock content %} {% endblock content %}