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),
))
try:
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
sinfo = await self.data.arcade.get_arcade(shop_id)
if not sinfo:
return Response(template.render(
title=f"{self.core_config.server.name} | Arcade",
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(
title=f"{self.core_config.server.name} | Arcade",
sesh=vars(usr_sesh),
arcade={
"name": sinfo['name'],
"id": sinfo['id'],
"cabs": []
"cabs": cablst
}
))

View File

@ -1,4 +1,19 @@
{% extends "core/templates/index.jinja" %}
{% block content %}
{% if arcade is defined %}
<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 %}

View File

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