Fetching containers instead of locations. Fixed query and relative script for get_part_info

pull/3/head
Davide Bongiovanni 6 years ago
parent d31799b3aa
commit 3788060c78

@ -47,13 +47,13 @@ def serveImage(img):
@app.route('/parts')
def index():
query = "select id, name from locations order by UPPER(name);"
query = "select id, name from containers order by UPPER(name);"
r = db_engine.execute(text(query))
locations = []
containers = []
for row in r:
locations.append(dict(row))
containers.append(dict(row))
r.close()
return render_template('partsearch.html', locations=locations)
return render_template('partsearch.html', containers=containers)
@app.route('/parts/getlocationsInContainer/<containerID>')
def get_locations_in_container(containerID):
@ -112,7 +112,7 @@ def alterLocation(locationID):
@app.route('/parts/getpartinfo/<partID>')
def get_part_info(partID):
s = 'select * from parts as p inner join locations as l on p.location_id=l.id where p.id = :id;'
s = 'select p.id,partno,description, c.name || l.name as location_descriptor, location_id, container_id datasheet from parts as p inner join locations as l on p.location_id = l.id inner join containers as c on l.container_id = c.id where p.id = :id;'
r = db_engine.execute(text(s), id=partID)
l = []
for row in r:

@ -131,13 +131,13 @@ function delete_entry(partID) {
function show_part_info(partID) {
$.getJSON(rootURL + 'getpartinfo/' + partID, function(data) {
$('table#details tr#location td p').text(text_filter(data.name)); // name is the location friendly name
$('table#details tr#location td p').text(text_filter(data.location_descriptor)); // name is the location friendly name
$('table#details tr#location td select').val(data.location_id); // name is the location friendly name
$('table#details tr#partno td p').text(text_filter(data.partno));
$('table#details tr#partno td input').val(text_filter(data.partno));
$('table#details tr#description td p').text(text_filter(data.description));
$('table#details tr#description td input').val(text_filter(data.description));
$('img#map').attr('src', 'parts/map/' + data.map);
$('img#map').attr('src', 'parts/map/' + data.container_id);
if (data.datasheet != null)
$('tr#datasheet-head').html($('<td>DATASHEET: <a href="' + rootURL + 'getfile/' + data.datasheet.substring(0, data.datasheet.length - 4) + '"><i class="fa fa-file-text" aria-hidden="true"></i></a></td>'));
else

@ -45,8 +45,8 @@
<tr id="location-head"><td>LOCATION</td></tr>
<tr id="location"><td><p></p>
<select class="pinfo-input" onchange="update_map()">
{% for location in locations %}
<option value="{{location['id']}}">{{location['name']}}</option>
{% for container in containers %}
<option value="{{container['id']}}">{{container['name']}}</option>
{% endfor %}
</select>
</td></tr>

Loading…
Cancel
Save