diff --git a/parts/server.py b/parts/server.py index 03fe262..e3d0c4b 100644 --- a/parts/server.py +++ b/parts/server.py @@ -19,6 +19,15 @@ db_engine = {} db_metadata = {} parts = {} +def getContainers(): + query = "select id, name from containers order by UPPER(name);" + r = db_engine.execute(text(query)) + containers = [] + for row in r: + containers.append(dict(row)) + r.close() + return containers + def check_auth(username, password): admin_list = [] with open('edit_admin.json', 'r') as admin: @@ -47,13 +56,7 @@ def serveImage(img): @app.route('/parts') def index(): - query = "select id, name from containers order by UPPER(name);" - r = db_engine.execute(text(query)) - containers = [] - for row in r: - containers.append(dict(row)) - r.close() - return render_template('partsearch.html', containers=containers) + return render_template('partsearch.html', containers=getContainers()) @app.route('/parts/getlocationsInContainer/') def get_locations_in_container(containerID): @@ -77,15 +80,13 @@ def get_locationURL(locationID): @app.route('/parts/locationEditor') def locationEditor(): - query = 'select * from locations order by name;' + query = 'select c.name as container, l.name as name, l.id from locations as l inner join containers as c on l.container_id = c.id order by container, name;' r = db_engine.execute(text(query)) locations = [] for row in r: locations.append(dict(row)) r.close() - know_not_map_files = ['here.png', '404.png', '.DS_Store'] - mapfiles = [f for f in listdir('maps') if isfile(join('maps', f)) and f not in know_not_map_files] - return render_template('locationEditor.html', locations=locations, mapfiles=mapfiles, defaultMapfile="elab.png") + return render_template('locationEditor.html', locations=locations, containers=getContainers()) @app.route('/parts/alterLocation/', methods=['POST']) # @requires_auth diff --git a/parts/templates/locationEditor.html b/parts/templates/locationEditor.html index 973b1c4..fbdd1ed 100644 --- a/parts/templates/locationEditor.html +++ b/parts/templates/locationEditor.html @@ -18,15 +18,15 @@

Looking for a place to store your obsolete ICs discontinued years ago? Just toss them anywhere and mark that location here!

- + - + {% for location in locations %} - + - + {% endfor %}
IDContainer Location nameMap URLID
{{location['id']}}{{location['container']}} {{location['name']}}{{location['map']}}{{location['id']}}
@@ -41,8 +41,8 @@ MAP