Bugfix: External spool

Improvement: Use fragments in templates
Features: Manual fill of empty tray
Bump version to 0.1.3
This commit is contained in:
Filip Bednárik
2024-12-22 23:32:58 +01:00
parent 5dd026479f
commit 96a85271c0
10 changed files with 203 additions and 252 deletions

View File

@ -3,70 +3,5 @@
{% block content %}
<!-- Page Title -->
<h1 class="mb-4 text-center">Assign NFC Tag to Spool</h1>
<!-- Empty State -->
{% if spools|length == 0 or not spools %}
<div class="alert alert-info text-center" role="alert">
No spools available to tag at the moment.
</div>
{% else %}
<!-- Spool List -->
<div class="list-group">
{% for spool in spools %}
{% if not spool.extra.get("tag") or spool.extra.get("tag") == "\"\"" %}
<!-- Individual Spool Item -->
<a href="{{ url_for('write_tag', spool_id=spool.id) }}"
class="list-group-item list-group-item-action d-flex justify-content-between align-items-center">
<!-- Left: Filament Color Badge -->
<div class="me-3">
<span class="badge d-inline-block"
style="background-color: #{{ spool.filament.color_hex }}; width: 20px; height: 50px;">
</span>
</div>
<!-- Middle: Filament Details -->
<div class="flex-grow-1">
<!-- Vendor Name and Material (Row 1) -->
<h6 class="mb-0">{{ spool.filament.vendor.name }} - {{ spool.filament.material }}</h6>
<!-- Filament Name (Row 2) -->
<small class="text-muted">{{ spool.filament.name }}</small>
</div>
<!-- Action Icon -->
<span class="badge bg-primary rounded-pill">
<i class="bi bi-plus-circle"></i> Assign
</span>
</a>
{% endif %}
{% endfor %}
{% for spool in spools %}
{% if spool.extra.get("tag") and spool.extra.get("tag") != "\"\"" %}
<!-- Individual Spool Item -->
<a href="{{ url_for('write_tag', spool_id=spool.id) }}"
class="list-group-item list-group-item-action d-flex justify-content-between align-items-center">
<!-- Left: Filament Color Badge -->
<div class="me-3">
<span class="badge d-inline-block"
style="background-color: #{{ spool.filament.color_hex }}; width: 20px; height: 50px;">
</span>
</div>
<!-- Middle: Filament Details -->
<div class="flex-grow-1">
<!-- Vendor Name and Material (Row 1) -->
<h6 class="mb-0">{{ spool.filament.vendor.name }} - {{ spool.filament.material }}</h6>
<!-- Filament Name (Row 2) -->
<small class="text-muted">{{ spool.filament.name }}</small>
</div>
<!-- Action Icon -->
<span class="badge bg-secondary rounded-pill">
<i class="bi bi-plus-circle"></i> Reassign
</span>
</a>
{% endif %}
{% endfor %}
</div>
{% endif %}
{% with action_assign=True %}{% include 'fragments/list_spools.html' %}{% endwith %}
{% endblock %}

7
templates/fill.html Normal file
View File

@ -0,0 +1,7 @@
{% extends 'base.html' %}
{% block content %}
<h1>Fill slot</h1>
<h2>AMS: {{ ams_id }}, Tray: {{ tray_id }}</h2>
{% with action_fill=True %}{% include 'fragments/list_spools.html' %}{% endwith %}
{% endblock %}

View File

@ -0,0 +1,51 @@
<!-- Empty State -->
{% if spools|length == 0 or not spools %}
<div class="alert alert-info text-center" role="alert">
No spools available to tag at the moment.
</div>
{% else %}
<!-- Spool List -->
<div class="list-group">
{% for spool in spools %}
<!-- Individual Spool Item -->
{% if action_fill %}<a href="{{ url_for('fill', spool_id=spool.id, ams=ams_id, tray=tray_id) }}"
class="list-group-item list-group-item-action d-flex justify-content-between align-items-center">{% endif %}
{% if action_assign %}<a href="{{ url_for('write_tag', spool_id=spool.id) }}"
class="list-group-item list-group-item-action d-flex justify-content-between align-items-center">{% endif %}
<!-- Left: Filament Color Badge -->
<div class="me-3">
<span class="badge d-inline-block"
style="background-color: #{{ spool.filament.color_hex }}; width: 20px; height: 50px;">
</span>
</div>
<!-- Middle: Filament Details -->
<div class="flex-grow-1">
<!-- Vendor Name and Material (Row 1) -->
<h6 class="mb-0">{{ spool.filament.vendor.name }} - {{ spool.filament.material }}</h6>
<!-- Filament Name (Row 2) -->
<small class="text-muted">{{ spool.filament.name }}</small>
</div>
{% if action_fill %}
<span class="badge bg-primary rounded-pill">
<i class="bi bi-plus-circle"></i> Fill
</span>
{% endif %}
{% if action_assign %}
<!-- Action Icon -->
{% if spool.extra.get("tag") or spool.extra.get("tag") == "\"\"" %}
<span class="badge bg-secondary rounded-pill">
<i class="bi bi-plus-circle"></i> Reassign
</span>
{% else %}
<span class="badge bg-primary rounded-pill">
<i class="bi bi-plus-circle"></i> Assign
</span>
{% endif %}
{% endif %}
{% if action_fill or action_assign %}</a>{% endif %}
{% endfor %}
</div>
{% endif %}

View File

@ -0,0 +1,57 @@
<div class="card">
<!-- Tray ID -->
<div class="card-header d-flex justify-content-between align-items-center">
{% if tray_data.issue %}
<i class="bi bi-exclamation-circle text-danger me-2"></i>
{% endif %}
{% if not tray_data.tray_type %}
Empty
{% endif %}
Tray {{ tray_data.id }}
</div>
<div class="card-body">
<!-- Tray Sub-Brand and Type -->
<div class="small text-muted mb-2">
{{ tray_data.tray_type }}
{% if tray_data.tray_sub_brands %}
<br/>
{{ tray_data.tray_sub_brands }}
{% endif %}
</div>
<!-- Badge with Dynamic Colors -->
<span class="badge d-inline-block p-2"
style="background-color: #{{ tray_data.tray_color }};
color: {% if color_is_dark(tray_data.tray_color) %}#FFFFFF{% else %}#000000{% endif %}">
#{{ tray_data.tray_color | upper }}
</span>
<!-- Remaining Percentage -->
<div class="mt-2">
Remaining:
{% if AUTO_SPEND and tray_data.matched %}
<span class="fw-bold">{{ tray_data.remaining_weight|round }}g</span>
{% else %}
<span class="fw-bold">{{ tray_data.remain }}%</span>
{% endif %}
</div>
</div>
<div class="card-footer">
{% if pick_tray %}
<a class="btn btn-primary"
href="{{ url_for('tray_load', spool_id=current_spool['id'], tag_id=tag_id, ams=ams_id, tray=tray_id) }}">Pick
this tray</a>
{% endif %}
{% if tray_data.issue %}
<a class="btn btn-primary"
href="{{ url_for('issue', ams=ams_id, tray=tray_id) }}">Fix
this tray</a>
{% endif %}
{% if not pick_tray and not tray_data.tray_type %}
<a class="btn btn-primary"
href="{{ url_for('fill', ams=ams_id, tray=tray_id) }}">Fill
this tray</a>
{% endif %}
</div>
</div>

View File

@ -9,7 +9,7 @@
</div>
<div class="card-body">
<h5 class="card-title">There is a mismatch between printer and SpoolMan</h5>
<p class="card-text">TODO: To fix the issue click on the tray with the red exclamation mark <i class="bi bi-exclamation-circle text-danger me-2"></i></p>
<p class="card-text">Fix issue by clicking "Fix this tray" on tray with <i class="bi bi-exclamation-circle text-danger me-2"></i></p>
</div>
</div>
{% endif %}
@ -22,42 +22,7 @@
<h5 class="mb-0">External Spool</h5>
</div>
<div class="card-body text-center">
<!-- Tray ID -->
<h6 class="text-uppercase mb-1">
{% if vt_tray_data.issue %}
<i class="bi bi-exclamation-circle text-danger me-2"></i>
{% endif %}
{% if not vt_tray_data.tray_type %}
Empty
{% endif %}
Tray {{ vt_tray_data.id }}
</h6>
<!-- Tray Sub-Brand and Type -->
<div class="small text-muted mb-2">
{{ vt_tray_data.tray_type }}
{% if vt_tray_data.tray_sub_brands %}
<br/>
{{ vt_tray_data.tray_sub_brands }}
{% endif %}
</div>
<!-- Badge with Dynamic Colors -->
<span class="badge d-inline-block p-2"
style="background-color: #{{ vt_tray_data.tray_color }};
color: {% if color_is_dark(vt_tray_data.tray_color) %}#FFFFFF{% else %}#000000{% endif %}">
#{{ vt_tray_data.tray_color | upper }}
</span>
<!-- Remaining Percentage -->
<div class="mt-2">
Remaining:
{% if AUTO_SPEND and vt_tray_data.matched %}
<span class="fw-bold">{{ vt_tray_data.remaining_weight|round }}g</span>
{% else %}
<span class="fw-bold">{{ vt_tray_data.remain }}%</span>
{% endif %}
</div>
{% with tray_data=vt_tray_data, ams_id=EXTERNAL_SPOOL_AMS_ID, pick_tray=False, tray_id=vt_tray_data.id %} {% include 'fragments/tray.html' %} {% endwith %}
</div>
</div>
</div>
@ -72,46 +37,7 @@
<div class="row">
{% for tray in ams.tray %}
<div class="col-6 mb-3">
<div class="border rounded p-2 text-center">
<!-- Tray ID -->
<h6 class="text-uppercase mb-1">
{% if tray.issue %}
<i class="bi bi-exclamation-circle text-danger me-2"></i>
{% endif %}
{% if not tray.tray_type %}
Empty
{% endif %}
Tray {{ tray.id }}
</h6>
<!-- Tray Sub-Brand and Type -->
<div class="small text-muted mb-2">
{{ tray.tray_type }}
{% if tray.tray_sub_brands %}
<br/>
{{ tray.tray_sub_brands }}
{% endif %}
</div>
{% if tray.tray_color %}
<!-- Badge with Dynamic Colors -->
<span class="badge d-inline-block p-2"
style="background-color: #{{ tray.tray_color }};
color: {% if color_is_dark(tray.tray_color) %}#FFFFFF{% else %}#000000{% endif %}">
#{{ tray.tray_color | upper }}
</span>
{% endif %}
<!-- Remaining Percentage -->
<div class="mt-2">
Remaining:
{% if AUTO_SPEND and tray.matched %}
<span class="fw-bold">{{ tray.remaining_weight|round }}g</span>
{% else %}
<span class="fw-bold">{{ tray.remain }}%</span>
{% endif %}
</div>
</div>
{% with tray_data=tray, ams_id=ams.id, pick_tray=False, tray_id=tray.id %} {% include 'fragments/tray.html' %} {% endwith %}
</div>
{% endfor %}
</div>

6
templates/issue.html Normal file
View File

@ -0,0 +1,6 @@
{% extends 'base.html' %}
{% block content %}
<h1>Solve issue</h1>
<h2>TBD</h2>
{% endblock %}

View File

@ -46,42 +46,7 @@
<h5 class="mb-0">External Spool</h5>
</div>
<div class="card-body text-center">
<div class="card">
<!-- Tray ID -->
<div class="card-header d-flex justify-content-between align-items-center">
{% if vt_tray_data.issue %}
<i class="bi bi-exclamation-circle text-danger me-2"></i>
{% endif %}
{% if not vt_tray_data.tray_type %}
Empty
{% endif %}
Tray {{ vt_tray_data.id }}
</div>
<div class="card-body">
<!-- Tray Sub-Brand and Type -->
<div class="small text-muted mb-2">
{{ vt_tray_data.tray_type }}
{% if vt_tray_data.tray_sub_brands %}
<br/>
{{ vt_tray_data.tray_sub_brands }}
{% endif %}
</div>
<!-- Badge with Dynamic Colors -->
<span class="badge d-inline-block p-2"
style="background-color: #{{ vt_tray_data.tray_color }};
color: {% if color_is_dark(vt_tray_data.tray_color) %}#FFFFFF{% else %}#000000{% endif %}">
#{{ vt_tray_data.tray_color | upper }}
</span>
</div>
<div class="card-footer">
<a class="btn btn-primary"
href="{{ url_for('tray_load', spool_id=current_spool['id'], tag_id=tag_id,ams=vt_tray_data['id'], tray='255') }}">Pick
this tray</a>
</div>
</div>
{% with tray_data=vt_tray_data, ams_id=EXTERNAL_SPOOL_AMS_ID, pick_tray=True, tray_id=vt_tray_data.id %} {% include 'fragments/tray.html' %} {% endwith %}
</div>
</div>
</div>
@ -96,43 +61,7 @@
<div class="row">
{% for tray in ams.tray %}
<div class="col-6 mb-3">
<div class="card">
<!-- Tray ID -->
<div class="card-header d-flex justify-content-between align-items-center">
{% if tray.issue %}
<i class="bi bi-exclamation-circle text-danger me-2"></i>
{% endif %}
{% if not tray.tray_type %}
Empty
{% endif %}
Tray {{ tray.id }}
</div>
<div class="card-body">
<!-- Tray Sub-Brand and Type -->
<div class="small text-muted mb-2">
{{ tray.tray_type }}
{% if tray.tray_sub_brands %}
<br/>
{{ tray.tray_sub_brands }}
{% endif %}
</div>
{% if tray.tray_color %}
<!-- Badge with Dynamic Colors -->
<span class="badge d-inline-block p-2"
style="background-color: #{{ tray.tray_color }};
color: {% if color_is_dark(tray.tray_color) %}#FFFFFF{% else %}#000000{% endif %}">
#{{ tray.tray_color | upper }}
</span>
{% endif %}
</div>
<div class="card-footer">
<a class="btn btn-primary"
href="{{ url_for('tray_load', spool_id=current_spool['id'], tag_id=tag_id,ams=ams['id'], tray=tray['id']) }}">Pick
this tray</a>
</div>
</div>
{% with tray_data=tray, ams_id=ams.id, pick_tray=True, tray_id=tray.id %} {% include 'fragments/tray.html' %} {% endwith %}
</div>
{% endfor %}
</div>