2024-02-28 21:31:43 +01:00
{% extends "base.html" %}
{% block content %}
2024-03-04 14:46:45 +01:00
< center > < button class = "hidden-desktop" style = "background-color: white;border: 1px solid black; color: black;" id = "expand-button" > Expand Columns< / button > < / center >
< div class = "center-table" >
2024-03-04 15:24:13 +01:00
< table id = "data" class = "table" >
2024-02-28 21:31:43 +01:00
< thead >
< tr >
2024-03-04 13:45:58 +01:00
< th > < / th >
2024-03-04 14:46:45 +01:00
< th style = "text-align:center;margin:0px;" class = "fixed-width hidden-mobile" > ID< / th >
< th class = "fixed-width hidden-mobile" > Name< / th >
2024-03-04 13:45:58 +01:00
< th > Color< / th >
2024-03-04 14:46:45 +01:00
< th style = "text-align: center;" class = "fixed-width" > Qty< / th >
2024-02-29 15:28:30 +01:00
{% for i in json_file['unit'] %}
2024-03-04 14:46:45 +01:00
< th style = "text-align: center;" class = "fixed-width" > Missing ({{ loop.index }})< / th >
2024-02-29 15:28:30 +01:00
{% endfor %}
2024-02-28 21:31:43 +01:00
< / tr >
< / thead >
< tbody >
{% for brick in inventory_file.results %}
2024-03-02 09:02:37 +01:00
{% if brick.is_spare == False %}
2024-02-28 21:31:43 +01:00
< tr >
2024-03-03 12:43:35 +01:00
{% if brick.element_id == None %}
< td > < img src = "{{ '/static/none.jpg' }}" style = "height: 50px; width: auto;" > < / td >
{% else %}
2024-03-04 14:46:45 +01:00
< td > < img src = "{{ '/static/parts/' + brick.element_id + '.jpg' }}" class = "lightbox-trigger" style = "height: 50px; width: auto;" > < / td >
2024-03-03 12:43:35 +01:00
{% endif %}
2024-03-04 14:46:45 +01:00
< td style = "text-align:center;margin:0px;" class = "hidden-mobile" > {{ brick.part.part_num }}< / td >
< td class = "hidden-mobile" > {{ brick.part.name }}< / td >
2024-02-28 21:31:43 +01:00
< td > {{ brick.color.name }}< / td >
2024-03-04 14:46:45 +01:00
< td style = "text-align:center;" > {{ brick.quantity }}< / td >
2024-02-29 19:30:25 +01:00
{% for i in json_file['unit'] %}
2024-03-04 13:45:58 +01:00
< td class = "centered-cell" >
< div class = "inputContainer" >
2024-02-29 19:30:25 +01:00
{% set ns = namespace(count='') %}
2024-02-29 19:44:28 +01:00
< form action = "/{{ tmp }}/saveNumber" method = "post" >
2024-02-29 19:30:25 +01:00
< input type = "hidden" name = "brick.part.part_num" value = "{{ brick.part.part_num }}" >
< input type = "hidden" name = "count" value = "{{ i }}" >
< input type = "hidden" name = "index" value = "{{ loop.index0 }}" >
2024-03-02 09:02:37 +01:00
< input type = "hidden" name = "is_spare" value = "{{ brick.is_spare }}" >
2024-02-29 19:30:25 +01:00
< input type = "hidden" name = "brick.color.name" value = "{{ brick.color.name }}" >
{% for j in json_file['unit'][loop.index0]['bricks']['missing'] %}
{% if j['brick']['ID'] == brick.part.part_num and j['brick']['color_name'] == brick.color.name %}
2024-03-02 09:02:37 +01:00
{% if j['brick']['is_spare']|lower == brick.is_spare|lower %}
2024-02-29 19:30:25 +01:00
{% set ns.count = j['brick']['amount'] %}
2024-03-02 09:02:37 +01:00
{% endif %}
2024-02-29 19:30:25 +01:00
{% endif %}
{% endfor %}
2024-03-04 13:45:58 +01:00
< div class = 'inputField' >
< input type = "text" id = "numberInput" name = "numberInput" value = {{ ns . count } } >
< button class = "square-button" type = "submit" >
< img src = "/static/save.svg" alt = "Save Icon" >
< / button >
< / div >
2024-02-29 19:30:25 +01:00
< / form >
2024-03-04 13:45:58 +01:00
< / div >
2024-02-29 19:30:25 +01:00
< / td >
{% endfor %}
2024-02-28 21:31:43 +01:00
< / tr >
2024-03-02 09:02:37 +01:00
{% endif %}
2024-02-28 21:31:43 +01:00
{% endfor %}
< / tbody >
< / table >
2024-03-04 14:46:45 +01:00
< / div >
2024-02-29 19:30:25 +01:00
2024-03-02 09:02:37 +01:00
< h1 > Spares< / h1 >
< table id = "data" class = "table table-striped" >
< thead >
< tr >
< th > img< / th >
< th > element_id< / th >
< th > part_num< / th >
< th > name< / th >
< th > color< / th >
< th > qty< / th >
{% for i in json_file['unit'] %}
< th > Missing ({{ loop.index }})< / th >
{% endfor %}
< / tr >
< / thead >
< tbody >
{% for brick in inventory_file.results %}
{% if brick.is_spare == True %}
< tr >
2024-03-03 12:43:35 +01:00
{% if brick.element_id == None %}
< td > < img src = "{{ '/static/none.jpg' }}" style = "height: 50px; width: auto;" > < / td >
{% else %}
< td > < img src = "{{ '/static/parts/' + brick.element_id + '.jpg' }}" style = "height: 50px; width: auto;" > < / td >
{% endif %}
2024-03-02 09:02:37 +01:00
< td > {{ brick.element_id }}< / td >
< td > {{ brick.part.part_num }}< / td >
< td > {{ brick.part.name }}< / td >
< td > {{ brick.color.name }}< / td >
< td > {{ brick.quantity }}< / td >
{% for i in json_file['unit'] %}
< td >
{% set ns = namespace(count='') %}
< form action = "/{{ tmp }}/saveNumber" method = "post" >
< input type = "hidden" name = "brick.part.part_num" value = "{{ brick.part.part_num }}" >
< input type = "hidden" name = "count" value = "{{ i }}" >
< input type = "hidden" name = "index" value = "{{ loop.index0 }}" >
< input type = "hidden" name = "is_spare" value = "{{ brick.is_spare }}" >
< input type = "hidden" name = "brick.color.name" value = "{{ brick.color.name }}" >
{% for j in json_file['unit'][loop.index0]['bricks']['missing'] %}
{% if j['brick']['ID'] == brick.part.part_num and j['brick']['color_name'] == brick.color.name and j['brick']['is_spare']|lower == brick.is_spare|lower %}
{% set ns.count = j['brick']['amount'] %}
{% endif %}
{% endfor %}
< input type = "text" style = "height:auto;width:40px" id = "numberInput" name = "numberInput" value = {{ ns . count } } > < button type = "submit" > < i class = "fa fa-save" > < / i > < / button >
< / form >
< / td >
{% endfor %}
< / tr >
{% endif %}
2024-03-04 14:46:45 +01:00
2024-03-02 09:02:37 +01:00
{% endfor %}
< / tbody >
< / table >
2024-03-04 14:46:45 +01:00
< div id = "lightbox-modal" >
2024-03-04 15:24:13 +01:00
< div class = "lightbox-wrapper" >
< span class = "close" > × < / span >
< img class = "lightbox-content" id = "lightbox-image" >
< div class = "text-container" id = "lightbox-text" > < / div >
< / div >
2024-03-04 14:46:45 +01:00
< / div >
2024-03-04 15:24:13 +01:00
{% endblock %}
2024-03-04 14:46:45 +01:00
{% block scripts %}
< script >
2024-03-04 15:24:13 +01:00
function goToPage(url) {
window.location.href = url;
}
2024-03-04 14:46:45 +01:00
const expandButton = document.getElementById('expand-button');
const dataTable = document.getElementById('data');
let isExpanded = false;
expandButton.addEventListener('click', () => {
const hiddenColumns = dataTable.querySelectorAll('.hidden-mobile');
hiddenColumns.forEach(column => {
if (isExpanded) {
column.style.display = 'none';
expandButton.textContent = 'Expand Columns';
} else {
column.style.display = 'table-cell';
expandButton.textContent = 'Hide Columns';
}
});
isExpanded = !isExpanded;
});
document.addEventListener('DOMContentLoaded', function () {
const lightboxTrigger = document.querySelectorAll('.lightbox-trigger');
const lightboxModal = document.getElementById('lightbox-modal');
const lightboxImage = document.getElementById('lightbox-image');
2024-03-04 15:24:13 +01:00
const lightboxText = document.getElementById('lightbox-text');
2024-03-04 14:46:45 +01:00
const closeModal = document.querySelector('.close');
lightboxTrigger.forEach(function (element) {
element.addEventListener('click', function () {
const imgSrc = element.getAttribute('src');
2024-03-04 15:24:13 +01:00
const textContent = element.closest('tr').querySelector('td:nth-child(3)').textContent; // Adjust the index accordingly
2024-03-04 14:46:45 +01:00
lightboxImage.setAttribute('src', imgSrc);
2024-03-04 15:24:13 +01:00
lightboxText.textContent = textContent;
2024-03-04 14:46:45 +01:00
lightboxModal.style.display = 'block';
});
});
closeModal.addEventListener('click', function () {
lightboxModal.style.display = 'none';
});
lightboxModal.addEventListener('click', function (event) {
2024-03-04 15:24:13 +01:00
if (event.target === lightboxModal || event.target === lightboxImage || event.target === lightboxText) {
// Dismiss only if the clicked element is part of the content area
2024-03-04 14:46:45 +01:00
lightboxModal.style.display = 'none';
}
});
2024-03-04 15:24:13 +01:00
// Dismiss the lightbox when clicking outside the content area (i.e., the background)
lightboxModal.addEventListener('click', function (event) {
if (event.target != lightboxModal) {
lightboxModal.style.display = 'none';
}
});
});
2024-03-04 14:46:45 +01:00
< / script >
{% endblock %}