location editor lists the new style of locations. Actual adding/editing locations coming soon.

master
Marek Baczynski 6 years ago
parent 777942aeaa
commit 846b7297ce

@ -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/<containerID>')
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/<locationID>', methods=['POST'])
# @requires_auth

@ -18,15 +18,15 @@
<p>Looking for a place to store your obsolete ICs discontinued years ago? Just toss them anywhere and mark that location here!</p>
<table id="results">
<tr>
<th id="id">ID</th>
<th id="id">Container</th>
<th id="location">Location name</th>
<th id="mapURL">Map URL</th>
<th id="mapURL">ID</th>
</tr>
{% for location in locations %}
<tr>
<td>{{location['id']}}</td>
<td>{{location['container']}}</td>
<td>{{location['name']}}</td>
<td>{{location['map']}}</td>
<td>{{location['id']}}</td>
</tr>
{% endfor %}
</table>
@ -41,8 +41,8 @@
<tr><td>MAP</td></tr>
<tr><td>
<select class="pinfo-input" onchange="update_clickable_map()" name="mapfile-input" id="mapfile-input">
{% for mapfile in mapfiles %}
<option value="{{mapfile}}" {% if mapfile==defaultMapfile %}selected="true"{% endif %}>{{mapfile}}</option>
{% for container in containers %}
<option value="{{container['id']}}">{{container['name']}}</option>
{% endfor %}
</select>
</td></tr>

Loading…
Cancel
Save