Added link on missing page to the set that's missing the piece. Fixed formatting on missing page

This commit is contained in:
FrederikBaerentsen 2024-12-29 13:40:53 +01:00
parent a495ad3b3b
commit 971a3ef7d3
2 changed files with 36 additions and 12 deletions

4
app.py
View File

@ -493,7 +493,9 @@ def config():
def missing(): def missing():
conn = sqlite3.connect('app.db') conn = sqlite3.connect('app.db')
cursor = conn.cursor() cursor = conn.cursor()
cursor.execute("SELECT part_num, color_id, element_id, part_img_url_id, SUM(quantity) AS total_quantity, GROUP_CONCAT(set_num, ', ') AS set_number FROM missing GROUP BY part_num, color_id, element_id;") #cursor.execute("SELECT part_num, color_id, element_id, part_img_url_id, SUM(quantity) AS total_quantity, GROUP_CONCAT(set_num, ', ') AS set_number FROM missing GROUP BY part_num, color_id, element_id;")
cursor.execute("SELECT part_num, color_id, element_id, part_img_url_id, SUM(quantity) AS total_quantity, GROUP_CONCAT(set_num || ',' || u_id, ',') AS set_number FROM missing GROUP BY part_num, color_id, element_id, part_img_url_id ORDER BY part_num;")
results = cursor.fetchall() results = cursor.fetchall()
missing_list = [list(i) for i in results] missing_list = [list(i) for i in results]

View File

@ -25,6 +25,17 @@ table.sortable tbody tr:nth-child(2n+1) td {
background: #ecf0f1; background: #ecf0f1;
} }
table {
width: 100%; /* Ensure the table takes full width of its container */
}
td {
overflow: hidden;
text-overflow: ellipsis;
word-wrap: break-word;
}
@media only screen and (max-width: 480px) { @media only screen and (max-width: 480px) {
/* horizontal scrollbar for tables if mobile screen */ /* horizontal scrollbar for tables if mobile screen */
@ -73,6 +84,9 @@ table.sortable tbody tr:nth-child(2n+1) td {
text-overflow: ellipsis; text-overflow: ellipsis;
} }
.fixed-width {
max-width:100px;
}
/* Modal Styles */ /* Modal Styles */
@ -164,38 +178,46 @@ table.sortable tbody tr:nth-child(2n+1) td {
</div> </div>
</div> </div>
</nav> </nav>
<div class="container">
<center> <center>
<div class="center-table" > <h1 class="title is-2 mt-4">Missing Pieces</h1>
<table id="data" class="table sortable tablemobile"> <div style="overflow-x:auto;border-radius: 10px;border: 1px #ccc solid; box-shadow:0 0.5em 1em -0.125em hsla(221deg,14%,4%,0.1),0 0px 0 1px hsla(221deg,14%,4%,0.02);" >
<table id="data" class="table sortable tablemobile">
<thead> <thead>
<tr> <tr>
<th class="sorttable_nosort"></th> <th style="width:65px;" class="fixed-width sorttable_nosort"></th>
<th >Part Num</th> <th class="fixed-width" >Part Num</th>
<th >Color</th> <th class="fixed-width" >Color</th>
<th >Element ID</th> <th class="fixed-width" >Element ID</th>
<th >Qty</th> <th class="fixed-width" >Qty</th>
<th class="sorttable_nosort">Sets</th> <th class="fixed-width sorttable_nosort">Sets</th>
</tr> </tr>
</thead> </thead>
<tbody> <tbody>
{% for brick in missing_list %} {% for brick in missing_list %}
<tr> <tr>
{% if brick[4] == 'nil' %} {% if brick[4] == 'nil' %}
<td><img src="{{ '/static/none.jpg' }}" class="lightbox-trigger" alt="{{ brick[3] }}" style="height: 50px; width: 50px;margin:0;padding: 0;" loading="lazy"></td> <td style="background-color: #ffffff;"><img src="{{ '/static/none.jpg' }}" class="lightbox-trigger" alt="{{ brick[3] }}" style="height: 50px; width: 50px;margin:0;padding: 0;" loading="lazy"></td>
{% else %} {% else %}
<td><img src="{{ '/static/parts/' + brick[3] + '.jpg' }}" alt="{{ brick[3] }}" class="lightbox-trigger" style="height: 50px; width: 50px;margin:0;padding: 0;" loading="lazy"></td> <td style="background-color: #ffffff;"><img src="{{ '/static/parts/' + brick[3] + '.jpg' }}" alt="{{ brick[3] }}" class="lightbox-trigger" style="height: 50px; width: 50px;margin:0;padding: 0;" loading="lazy"></td>
{% endif %} {% endif %}
<td><a target="_blank" href="https://www.bricklink.com/v2/catalog/catalogitem.page?P={{ brick[0] }}">{{ brick[0] }}</a></td> <td><a target="_blank" href="https://www.bricklink.com/v2/catalog/catalogitem.page?P={{ brick[0] }}">{{ brick[0] }}</a></td>
<td>{{ brick[1] }}</td> <td>{{ brick[1] }}</td>
<td><a target="_blank" href="https://www.rebrickable.com/elements/{{ brick[2] }}">{{ brick[2] }}</a></td> <td><a target="_blank" href="https://www.rebrickable.com/elements/{{ brick[2] }}">{{ brick[2] }}</a></td>
<td>{{ brick[4] }}</td> <td>{{ brick[4] }}</td>
<td>{{ brick[5] }}</td> <td>
{% set set_numbers = brick[5].split(',') %}
{% for i in range(0, set_numbers|length, 2) %}
<a href="{{ set_numbers[i] }}/{{ set_numbers[i+1] }}">{{ set_numbers[i] }}</a>{% if i != set_numbers|length - 2 %},{% endif %}
{% endfor %}
</td>
</tr> </tr>
{% endfor %} {% endfor %}
</tbody> </tbody>
</table> </table>
</div> </div>
</center> </center>
</div>
<div id="lightbox-modal"> <div id="lightbox-modal">