Updated Parts

This commit is contained in:
FrederikBaerentsen 2024-11-21 13:23:32 +01:00
parent 69198ee0a2
commit f8b4e89d84
2 changed files with 44 additions and 89 deletions

14
app.py
View File

@ -457,21 +457,21 @@ def missing():
def parts(): def parts():
conn = sqlite3.connect('app.db') conn = sqlite3.connect('app.db')
cursor = conn.cursor() cursor = conn.cursor()
cursor.execute('SELECT id, part_num, color_id, element_id, part_img_url_id, SUM(quantity) AS total_quantity FROM inventory GROUP BY id, part_num, part_img_url_id, color_id, element_id;') cursor.execute('SELECT id, part_num, color_id, color_name, element_id, part_img_url_id, SUM(quantity) AS total_quantity, name FROM inventory GROUP BY id, part_num, part_img_url_id, color_id, color_name, element_id, name;')
results = cursor.fetchall() results = cursor.fetchall()
missing_list = [list(i) for i in results] missing_list = [list(i) for i in results]
cursor.close() cursor.close()
conn.close() conn.close()
color_file = np.loadtxt("colors.csv",delimiter=",",dtype="str") #color_file = np.loadtxt("colors.csv",delimiter=",",dtype="str")
color_dict = {str(code): name for code, name, _, _ in color_file} #color_dict = {str(code): name for code, name, _, _ in color_file}
for item in missing_list: #for item in missing_list:
color_code = str(item[2]) # color_code = str(item[2])
if color_code in color_dict: # if color_code in color_dict:
item[2] = color_dict[color_code] # item[2] = color_dict[color_code]
return render_template('parts.html',missing_list=missing_list) return render_template('parts.html',missing_list=missing_list)

View File

@ -24,22 +24,27 @@ table.sortable tbody tr:nth-child(2n+1) td {
background: #ecf0f1; background: #ecf0f1;
} }
table { @media only screen and (max-width: 480px) {
width: 100%; /* Ensure the table takes full width of its container */ /* horizontal scrollbar for tables if mobile screen */
img {
margin:0;
padding: 0;
min-width: 50px;
min-height: 50px;
display: block !important;
width: 50px;
height: 50px;
}
} }
td { @media only screen and (min-width: 600px) {
overflow: hidden; img {
text-overflow: ellipsis; margin:0;
word-wrap: break-word; padding: 0;
} width: 50px;
height: 50px;
}
.name-class {
max-width: 300px;
overflow: hidden;
white-space: nowrap;
text-overflow: ellipsis;
} }
@media only screen and (min-width: 600px) { @media only screen and (min-width: 600px) {
@ -59,70 +64,18 @@ td {
} }
.name-class {
max-width: 200px;
overflow: hidden;
white-space: nowrap;
/* Chrome, Safari, Edge, Opera */ text-overflow: ellipsis;
input::-webkit-outer-spin-button,
input::-webkit-inner-spin-button {
-webkit-appearance: none;
margin: 0;
}
/* Firefox */
input[type=number] {
-moz-appearance: textfield;
}
.header {
width:100%;
text-align:center;
z-index: 99;
background-color: white;
}
.content {
padding: 16px;
} }
.inputContainer {
display: inline-block; /* Display as an inline block */
vertical-align: middle; /* Center vertically within the cell */
width: 120px;
}
.inputContainer form {
margin: 5% auto 5% auto;
}
.inputField {
display: flex;
align-items: center; /* Align items vertically */
width: 100%; /* Ensure inputField fills out inputContainer */
height: 100%; /* Ensure inputField fills out inputContainer */
}
.inputField input {
flex: 1;
width: 70%;
padding: 0px;
margin: auto 2.5px auto 2.5px;
}
.inputField button {
width: 30%;
padding: 0px;
margin: 0 2.5px 0 2.5px;
}
.square-button {
background-color: white;
border: 1px solid #d1d1d1;
}
/* Modal Styles */ /* Modal Styles */
#lightbox-modal { #lightbox-modal {
display: none; display: none;
position: fixed; position: fixed;
z-index: 1000; z-index: 1000;
@ -144,6 +97,8 @@ background-color: white;
.lightbox-content { .lightbox-content {
max-width: 90%; max-width: 90%;
max-height: 90%; max-height: 90%;
height: auto;
width: auto;
position: absolute; position: absolute;
top: 50%; top: 50%;
left: 50%; left: 50%;
@ -213,13 +168,13 @@ background-color: white;
</nav> </nav>
<center> <center>
<div class="center-table" > <div class="center-table" >
<table id="data" class="table sortable"> <table id="data" class="table tablemobile sortable">
<thead> <thead>
<tr> <tr>
<th class="sorttable_nosort"></th> <th class="sorttable_nosort"></th>
<th >id</th> <th >Part Num</th>
<th >part_num</th> <th >Color</th>
<th >color_id</th> <th class="name-class" >Name</th>
<th >element_id</th> <th >element_id</th>
<th >total_quantity</th> <th >total_quantity</th>
</tr> </tr>
@ -228,15 +183,15 @@ background-color: white;
{% 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="id: {{ brick[0] }}, color: {{ brick[2] }}, qty: {{ brick[5] }}" 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="id: {{ brick[0] }}, color: {{ brick[3] }}, qty: {{ brick[6] }}" loading="lazy"></td>
{% else %} {% else %}
<td><img src="{{ '/static/parts/' + brick[4] + '.jpg' }}" alt="id: {{ brick[0] }}, color: {{ brick[2] }}, qty: {{ brick[5] }}" 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[5] + '.jpg' }}" alt="id: {{ brick[0] }}, color: {{ brick[3] }}, qty: {{ brick[6] }}" class="lightbox-trigger" loading="lazy"></td>
{% endif %} {% endif %}
<td>{{ brick[0] }}</td> <td><a target="_blank" href="https://www.bricklink.com/v2/catalog/catalogitem.page?P={{ brick[1] }}">{{ brick[1] }}</a></td>
<td>{{ brick[1] }}</td> <td class="name-class">{{ brick[3] }}</td>
<td>{{ brick[2] }}</td> <td>{{ brick[7] }}</td>
<td>{{ brick[3] }}</td> <td><a target="_blank" href="https://www.rebrickable.com/elements/{{ brick[4] }}">{{ brick[4] }}</a></td>
<td>{{ brick[5] }}</td> <td>{{ brick[6] }}</td>
</tr> </tr>
{% endfor %} {% endfor %}
</tbody> </tbody>