Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
70401139f9 | ||
|
|
4429a2a4f6 | ||
|
|
725d2b0cdd | ||
|
|
3793f4a865 | ||
|
|
e3f25e76f2 | ||
|
|
d6f0421b9f | ||
|
|
e5f6341d4e | ||
|
|
c29d0af836 | ||
|
|
383bf4d220 | ||
|
|
1e8576af1c | ||
|
|
c0f0fd732f | ||
|
|
b871e98cbb | ||
|
|
db55a5769e | ||
|
|
0e949dff50 | ||
|
|
ad643464cb | ||
|
|
4541fab34e | ||
|
|
50e4903a30 | ||
|
|
d65de687d8 | ||
|
|
afecca7172 | ||
|
|
623770091b | ||
|
|
7098d19225 | ||
|
|
08b8646374 | ||
|
|
590701fe22 | ||
|
|
da5339a473 | ||
|
|
caf1efce0c | ||
|
|
a222906fe2 | ||
|
|
c568635f60 | ||
|
|
b3aad9a1ca | ||
|
|
db19e86f73 | ||
|
|
4f1e51e7bd | ||
|
|
6120420f56 | ||
|
|
d1bd2aa0ec | ||
|
|
954b449757 | ||
|
|
a99a356985 | ||
|
|
44adb43466 | ||
|
|
c886f2e860 | ||
|
|
501491ac9a | ||
|
|
257a8d9754 | ||
|
|
005ea98f59 | ||
|
|
e9b670bea8 | ||
|
|
846b7297ce | ||
|
|
777942aeaa | ||
|
|
2ce132868c | ||
|
|
694310a733 | ||
|
|
42fb09f89b | ||
|
|
4c78533976 | ||
|
|
240293cf01 | ||
|
|
95fe77ce16 | ||
|
|
90079c70cd | ||
|
|
6670487ac0 | ||
|
|
2efb06ef3c | ||
|
|
863ce49e98 |
|
Before Width: | Height: | Size: 70 KiB After Width: | Height: | Size: 44 KiB |
|
After Width: | Height: | Size: 15 KiB |
|
After Width: | Height: | Size: 15 KiB |
|
After Width: | Height: | Size: 15 KiB |
|
After Width: | Height: | Size: 15 KiB |
|
After Width: | Height: | Size: 15 KiB |
|
After Width: | Height: | Size: 14 KiB |
|
After Width: | Height: | Size: 14 KiB |
|
After Width: | Height: | Size: 15 KiB |
|
After Width: | Height: | Size: 15 KiB |
|
After Width: | Height: | Size: 15 KiB |
|
After Width: | Height: | Size: 14 KiB |
|
After Width: | Height: | Size: 15 KiB |
|
After Width: | Height: | Size: 15 KiB |
|
After Width: | Height: | Size: 15 KiB |
|
After Width: | Height: | Size: 15 KiB |
|
After Width: | Height: | Size: 15 KiB |
|
After Width: | Height: | Size: 15 KiB |
|
After Width: | Height: | Size: 15 KiB |
|
After Width: | Height: | Size: 15 KiB |
|
After Width: | Height: | Size: 15 KiB |
|
After Width: | Height: | Size: 15 KiB |
|
After Width: | Height: | Size: 15 KiB |
|
After Width: | Height: | Size: 15 KiB |
|
After Width: | Height: | Size: 16 KiB |
|
After Width: | Height: | Size: 15 KiB |
|
After Width: | Height: | Size: 15 KiB |
|
After Width: | Height: | Size: 15 KiB |
|
After Width: | Height: | Size: 15 KiB |
|
After Width: | Height: | Size: 15 KiB |
|
After Width: | Height: | Size: 15 KiB |
|
After Width: | Height: | Size: 15 KiB |
|
After Width: | Height: | Size: 15 KiB |
|
After Width: | Height: | Size: 15 KiB |
|
After Width: | Height: | Size: 15 KiB |
|
After Width: | Height: | Size: 15 KiB |
|
After Width: | Height: | Size: 15 KiB |
|
After Width: | Height: | Size: 15 KiB |
|
After Width: | Height: | Size: 15 KiB |
|
After Width: | Height: | Size: 15 KiB |
|
After Width: | Height: | Size: 15 KiB |
|
After Width: | Height: | Size: 15 KiB |
|
After Width: | Height: | Size: 15 KiB |
|
After Width: | Height: | Size: 15 KiB |
|
After Width: | Height: | Size: 15 KiB |
|
After Width: | Height: | Size: 15 KiB |
|
After Width: | Height: | Size: 15 KiB |
|
After Width: | Height: | Size: 15 KiB |
|
Before Width: | Height: | Size: 83 KiB |
|
After Width: | Height: | Size: 212 KiB |
|
After Width: | Height: | Size: 213 KiB |
|
After Width: | Height: | Size: 213 KiB |
|
After Width: | Height: | Size: 213 KiB |
|
After Width: | Height: | Size: 213 KiB |
|
After Width: | Height: | Size: 213 KiB |
|
After Width: | Height: | Size: 213 KiB |
|
After Width: | Height: | Size: 213 KiB |
@@ -1,12 +1,12 @@
|
|||||||
import os
|
import os
|
||||||
import re
|
import re
|
||||||
import json
|
import json, urllib.parse, urllib.request
|
||||||
import sqlalchemy
|
import sqlalchemy
|
||||||
from functools import wraps
|
from functools import wraps
|
||||||
from sqlalchemy.sql import select
|
from sqlalchemy.sql import select
|
||||||
from sqlalchemy.sql import text
|
from sqlalchemy.sql import text
|
||||||
from flask import Flask
|
from flask import Flask
|
||||||
from flask import render_template, send_from_directory, request, Response, send_file
|
from flask import render_template, send_from_directory, request, Response, send_file, session
|
||||||
from PIL import Image, ImageDraw
|
from PIL import Image, ImageDraw
|
||||||
from io import BytesIO
|
from io import BytesIO
|
||||||
from os import listdir
|
from os import listdir
|
||||||
@@ -18,26 +18,45 @@ app = Flask(__name__)
|
|||||||
db_engine = {}
|
db_engine = {}
|
||||||
db_metadata = {}
|
db_metadata = {}
|
||||||
parts = {}
|
parts = {}
|
||||||
|
octopartURL =""
|
||||||
|
|
||||||
|
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):
|
def check_auth(username, password):
|
||||||
admin_list = []
|
query = "select id, password from users where username=:usrnm;"
|
||||||
with open('edit_admin.json', 'r') as admin:
|
r = db_engine.execute(text(query), usrnm=username)
|
||||||
admin_list = json.load(admin)
|
results = []
|
||||||
for user in admin_list:
|
for row in r:
|
||||||
if username == user['username']:
|
results.append(dict(row))
|
||||||
return password == user['password']
|
r.close()
|
||||||
|
if len(results)!=1:
|
||||||
|
return False;
|
||||||
|
|
||||||
|
if results[0]['password']==password:
|
||||||
|
session['uid'] = results[0]['id']
|
||||||
|
print (session['uid'])
|
||||||
|
return True
|
||||||
|
else:
|
||||||
|
return False
|
||||||
|
|
||||||
def authenticate():
|
def authenticate():
|
||||||
return Response('Could not verify access level. Please retry', 401, {'WWW-Authenticate' : 'Basic realm="Login Required"'})
|
return Response('Could not verify access level. Please retry', 401, {'WWW-Authenticate' : 'Basic realm="Login Required"'})
|
||||||
|
|
||||||
def requires_auth(f):
|
def requires_auth(f):
|
||||||
@wraps(f)
|
@wraps(f)
|
||||||
def decorated(*args, **kwargs):
|
def decorated(*args, **kwargs):
|
||||||
auth = request.authorization
|
auth = request.authorization
|
||||||
if not auth or not check_auth(auth.username, auth.password):
|
if not auth or not check_auth(auth.username, auth.password):
|
||||||
return authenticate()
|
return authenticate()
|
||||||
return f(*args, **kwargs)
|
return f(*args, **kwargs)
|
||||||
return decorated
|
return decorated
|
||||||
|
|
||||||
def serveImage(img):
|
def serveImage(img):
|
||||||
img_io = BytesIO()
|
img_io = BytesIO()
|
||||||
@@ -45,15 +64,9 @@ def serveImage(img):
|
|||||||
img_io.seek(0)
|
img_io.seek(0)
|
||||||
return send_file(img_io, mimetype='image/png')
|
return send_file(img_io, mimetype='image/png')
|
||||||
|
|
||||||
@app.route('/parts')
|
@app.route('/parts', strict_slashes=False)
|
||||||
def index():
|
def index():
|
||||||
query = "select id, name from containers order by UPPER(name);"
|
return render_template('partsearch.html', containers=getContainers())
|
||||||
r = db_engine.execute(text(query))
|
|
||||||
containers = []
|
|
||||||
for row in r:
|
|
||||||
containers.append(dict(row))
|
|
||||||
r.close()
|
|
||||||
return render_template('partsearch.html', containers=containers)
|
|
||||||
|
|
||||||
@app.route('/parts/getlocationsInContainer/<containerID>')
|
@app.route('/parts/getlocationsInContainer/<containerID>')
|
||||||
def get_locations_in_container(containerID):
|
def get_locations_in_container(containerID):
|
||||||
@@ -77,42 +90,40 @@ def get_locationURL(locationID):
|
|||||||
|
|
||||||
@app.route('/parts/locationEditor')
|
@app.route('/parts/locationEditor')
|
||||||
def locationEditor():
|
def locationEditor():
|
||||||
query = 'select * from locations order by name;'
|
query = 'select c.name as container, l.name as name, l.id, c.id as container_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))
|
r = db_engine.execute(text(query))
|
||||||
locations = []
|
locations = []
|
||||||
for row in r:
|
for row in r:
|
||||||
locations.append(dict(row))
|
locations.append(dict(row))
|
||||||
r.close()
|
r.close()
|
||||||
know_not_map_files = ['here.png', '404.png', '.DS_Store']
|
return render_template('locationEditor.html', locations=locations, containers=getContainers())
|
||||||
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")
|
|
||||||
|
|
||||||
@app.route('/parts/alterLocation/<locationID>', methods=['POST'])
|
@app.route('/parts/alterLocation/<locationID>', methods=['POST'])
|
||||||
# @requires_auth
|
@requires_auth
|
||||||
def alterLocation(locationID):
|
def alterLocation(locationID):
|
||||||
locationID = int(locationID)
|
locationID = int(locationID)
|
||||||
s = ''
|
s = ''
|
||||||
if locationID < 0:
|
if locationID < 0:
|
||||||
# New entry
|
# New entry
|
||||||
s = 'insert into locations (name, map) '
|
s = 'insert into locations (name, container_id) '
|
||||||
s += 'values (:name, :map);'
|
s += 'values (:name, :container, :userid);'
|
||||||
s = text(s)
|
s = text(s)
|
||||||
r = db_engine.execute(s,name=request.form['name'],map=request.form['map']);
|
r = db_engine.execute(s,name=request.form['name'],container=request.form['container']);
|
||||||
r.close()
|
r.close()
|
||||||
return '{"status":"ok"}'
|
return '{"status":"ok"}'
|
||||||
else:
|
else:
|
||||||
# Modify entry
|
# Modify entry
|
||||||
s = 'update locations '
|
s = 'update locations '
|
||||||
s += 'set name=:name, map=:map, '
|
s += 'set name=:name, container_id=:container '
|
||||||
s += 'where id=:locationID;'
|
s += 'where id=:locationID;'
|
||||||
s = text(s)
|
s = text(s)
|
||||||
r = db_engine.execute(s, name=request.form['name'],map=request.form['map'],locationID=locationID);
|
r = db_engine.execute(s, name=request.form['name'],container=request.form['container'],locationID=locationID);
|
||||||
r.close()
|
r.close()
|
||||||
return '{"status":"ok"}'
|
return '{"status":"ok"}'
|
||||||
|
|
||||||
@app.route('/parts/getpartinfo/<partID>')
|
@app.route('/parts/getpartinfo/<partID>')
|
||||||
def get_part_info(partID):
|
def get_part_info(partID):
|
||||||
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;'
|
s = 'select p.id,partno,description,notes, 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)
|
r = db_engine.execute(text(s), id=partID)
|
||||||
l = []
|
l = []
|
||||||
for row in r:
|
for row in r:
|
||||||
@@ -131,30 +142,25 @@ def query(filter_dummy, query):
|
|||||||
kw_dict["kw" + str(i)] = keywords[i]
|
kw_dict["kw" + str(i)] = keywords[i]
|
||||||
|
|
||||||
s = 'select p.id,partno,description, c.name || l.name as location_descriptor 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 '
|
s = 'select p.id,partno,description, c.name || l.name as location_descriptor 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 '
|
||||||
if filter['l']:
|
|
||||||
|
if filter['l'] == 'true':
|
||||||
s += '('
|
s += '('
|
||||||
for i in range(len(keywords)):
|
for i in range(len(keywords)):
|
||||||
s += 'LOWER(l.name) like LOWER(:kw'+ str(i) +') AND '
|
s += 'LOWER(l.name) like LOWER(:kw'+ str(i) +') AND '
|
||||||
s = s[:-5]
|
s = s[:-5]
|
||||||
s += ') OR '
|
s += ') OR '
|
||||||
if filter['p']:
|
if filter['p'] == 'true':
|
||||||
s += '('
|
s += '('
|
||||||
for i in range(len(keywords)):
|
for i in range(len(keywords)):
|
||||||
s += 'LOWER(partno) like LOWER(:kw'+ str(i) +') AND '
|
s += 'LOWER(partno) like LOWER(:kw'+ str(i) +') AND '
|
||||||
s = s[:-5]
|
s = s[:-5]
|
||||||
s += ') OR '
|
s += ') OR '
|
||||||
if filter['d']:
|
if filter['d'] == 'true':
|
||||||
s += '('
|
s += '('
|
||||||
for i in range(len(keywords)):
|
for i in range(len(keywords)):
|
||||||
s += 'LOWER(description) like LOWER(:kw'+ str(i) +') AND '
|
s += 'LOWER(description) like LOWER(:kw'+ str(i) +') AND '
|
||||||
s = s[:-5]
|
s = s[:-5]
|
||||||
s += ') OR '
|
s += ') OR '
|
||||||
if filter['n']:
|
|
||||||
s += '('
|
|
||||||
for i in range(len(keywords)):
|
|
||||||
s += 'LOWER(notes) like LOWER(:kw'+ str(i) +') AND '
|
|
||||||
s = s[:-5]
|
|
||||||
s += ') OR '
|
|
||||||
s = s[:-4] + ';'
|
s = s[:-4] + ';'
|
||||||
s = text(s)
|
s = text(s)
|
||||||
r = db_engine.execute(s, kw_dict)
|
r = db_engine.execute(s, kw_dict)
|
||||||
@@ -197,30 +203,38 @@ def getfile(filename):
|
|||||||
return send_from_directory('/srv/datasheets/', filename + '.pdf')
|
return send_from_directory('/srv/datasheets/', filename + '.pdf')
|
||||||
|
|
||||||
@app.route('/parts/alter/<partID>', methods=['POST'])
|
@app.route('/parts/alter/<partID>', methods=['POST'])
|
||||||
# @requires_auth
|
@requires_auth
|
||||||
def alter(partID):
|
def alter(partID):
|
||||||
partID = int(partID)
|
partID = int(partID)
|
||||||
s = ''
|
s = ''
|
||||||
r = {}
|
r = {}
|
||||||
if partID < 0:
|
if partID < 0:
|
||||||
# New entry
|
# New entry
|
||||||
s = 'insert into parts (partno, description, datasheet, location_id) '
|
s = 'insert into parts (partno, description, datasheet, location_id, whoadded, notes) '
|
||||||
s += 'values (:partno, :description, :datasheet, :location_id) returning id;'
|
s += 'values (:partno, :description, :datasheet, :location_id, :user_id, :notes) returning id;'
|
||||||
s = text(s)
|
s = text(s)
|
||||||
if len(request.files) != 0:
|
if len(request.files) != 0:
|
||||||
datasheet_file = request.files['datasheet-file']
|
datasheet_file = request.files['datasheet-file']
|
||||||
datasheet_filename = secure_filename(datasheet_file.filename)
|
datasheet_filename = secure_filename(datasheet_file.filename)
|
||||||
i = 1
|
i = 1
|
||||||
while os.path.isfile('srv/datasheet/' + datasheet_filename):
|
while os.path.isfile('srv/datasheets/' + datasheet_filename):
|
||||||
datasheet_filename = datasheet_filename[:-4] + str(i) + '.pdf'
|
datasheet_filename = datasheet_filename[:-4] + str(i) + '.pdf'
|
||||||
i += 1
|
i += 1
|
||||||
datasheet_file.save('/srv/datasheets/' + datasheet_filename)
|
datasheet_file.save('/srv/datasheets/' + datasheet_filename)
|
||||||
|
datasheet_filename = 'http://elab.kth.se/parts/getfile/' + datasheet_filename
|
||||||
|
# elif request.form.has_key('datasheet-url'):
|
||||||
|
# datasheet_filename = request.form['datasheet-url']
|
||||||
else:
|
else:
|
||||||
datasheet_filename = None
|
try:
|
||||||
|
datasheet_filename = request.form['datasheet-url']
|
||||||
|
except:
|
||||||
|
datasheet_filename = None
|
||||||
r = db_engine.execute(s, partno=request.form['partno'],
|
r = db_engine.execute(s, partno=request.form['partno'],
|
||||||
description=request.form['description'],
|
description=request.form['description'],
|
||||||
datasheet=datasheet_filename,
|
datasheet=datasheet_filename,
|
||||||
location_id=request.form['location_id'])
|
location_id=request.form['location_id'],
|
||||||
|
notes=request.form['notes'],
|
||||||
|
user_id=session['uid'])
|
||||||
else:
|
else:
|
||||||
# Modify entry
|
# Modify entry
|
||||||
r = db_engine.execute(text('select * from parts where id=:id;'), id=partID)
|
r = db_engine.execute(text('select * from parts where id=:id;'), id=partID)
|
||||||
@@ -229,26 +243,33 @@ def alter(partID):
|
|||||||
l.append(dict(row))
|
l.append(dict(row))
|
||||||
r.close()
|
r.close()
|
||||||
s = 'update parts '
|
s = 'update parts '
|
||||||
s += 'set partno=:partno, description=:description, datasheet=:datasheet, location_id=:location_id '
|
s += 'set partno=:partno, description=:description, datasheet=:datasheet, location_id=:location_id, notes=:notes '
|
||||||
if len(request.files) != 0:
|
if len(request.files) != 0:
|
||||||
datasheet_file = request.files['datasheet-file']
|
datasheet_file = request.files['datasheet-file']
|
||||||
datasheet_filename = secure_filename(datasheet_file.filename)
|
datasheet_filename = secure_filename(datasheet_file.filename)
|
||||||
i = 1
|
i = 1
|
||||||
while os.path.isfile('srv/datasheet/' + datasheet_filename):
|
while os.path.isfile('srv/datasheets/' + datasheet_filename):
|
||||||
datasheet_filename = datasheet_filename[:-4] + str(i) + '.pdf'
|
datasheet_filename = datasheet_filename[:-4] + str(i) + '.pdf'
|
||||||
i += 1
|
i += 1
|
||||||
datasheet_file.save('/srv/datasheets/' + datasheet_filename)
|
datasheet_file.save('/srv/datasheets/' + datasheet_filename)
|
||||||
|
datasheet_filename = 'http://elab.kth.se/parts/getfile/' + datasheet_filename
|
||||||
if l[0]['datasheet'] != None:
|
if l[0]['datasheet'] != None:
|
||||||
os.remove('/srv/datasheets/' + l[0]['datasheet'])
|
os.remove('/srv/datasheets/' + l[0]['datasheet'])
|
||||||
|
# elif request.form.has_key('datasheet-url'):
|
||||||
|
# datasheet_filename = request.form['datasheet-url']
|
||||||
else:
|
else:
|
||||||
datasheet_filename = l[0]['datasheet']
|
try:
|
||||||
|
datasheet_filename = request.form['datasheet-url']
|
||||||
|
except:
|
||||||
|
datasheet_filename = l[0]['datasheet']
|
||||||
s += 'where id=:id returning id;'
|
s += 'where id=:id returning id;'
|
||||||
s = text(s)
|
s = text(s)
|
||||||
r = db_engine.execute(s, partno=request.form['partno'],
|
r = db_engine.execute(s, partno=request.form['partno'],
|
||||||
description=request.form['description'],
|
description=request.form['description'],
|
||||||
datasheet=datasheet_filename,
|
datasheet=datasheet_filename,
|
||||||
location_id=request.form['location_id'],
|
location_id=request.form['location_id'],
|
||||||
id=partID)
|
id=partID,
|
||||||
|
notes=request.form['notes'])
|
||||||
|
|
||||||
new_id = r.fetchone()[0]
|
new_id = r.fetchone()[0]
|
||||||
r.close()
|
r.close()
|
||||||
@@ -263,6 +284,35 @@ def delete(partID):
|
|||||||
r = db_engine.execute(s, id=partID)
|
r = db_engine.execute(s, id=partID)
|
||||||
return '{"status":"ok"}'
|
return '{"status":"ok"}'
|
||||||
|
|
||||||
|
@app.route('/parts/deleteLocation/<locationID>')
|
||||||
|
# @requires_auth
|
||||||
|
def deleteLocation(locationID):
|
||||||
|
if int(locationID) < 0:
|
||||||
|
abort(400)
|
||||||
|
s = text('delete from locations where id=:id;')
|
||||||
|
r = db_engine.execute(s, id=locationID)
|
||||||
|
return '{"status":"ok"}'
|
||||||
|
|
||||||
|
@app.route('/parts/fetchOctopartSnippet/<searchTerm>')
|
||||||
|
def fetchOctopartSnippet(searchTerm):
|
||||||
|
if octopartURL == '':
|
||||||
|
return '{"result":"octopart integration not enabled"}'
|
||||||
|
args = [
|
||||||
|
('q', searchTerm),
|
||||||
|
('start', 0),
|
||||||
|
('limit', 1)
|
||||||
|
]
|
||||||
|
data = urllib.request.urlopen(octopartURL + '&' + urllib.parse.urlencode(args)).read()
|
||||||
|
search_response = json.loads(data)
|
||||||
|
|
||||||
|
result = '{"result":"no results. sorry :(("}'
|
||||||
|
if search_response['hits']>0:
|
||||||
|
try:
|
||||||
|
result = '{"result":"ok", "snippet":"' + (search_response['results'][0]['snippet']) + '"}';
|
||||||
|
except TypeError:
|
||||||
|
result = '{"result":"no results?"}'
|
||||||
|
return result
|
||||||
|
|
||||||
def connect(user, password, db, host='localhost', port=5432):
|
def connect(user, password, db, host='localhost', port=5432):
|
||||||
'''Returns a connection and a metadata object'''
|
'''Returns a connection and a metadata object'''
|
||||||
# We connect with the help of the PostgreSQL URL
|
# We connect with the help of the PostgreSQL URL
|
||||||
@@ -278,10 +328,22 @@ def connect(user, password, db, host='localhost', port=5432):
|
|||||||
return con, meta
|
return con, meta
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
|
app.secret_key = 'asuiygdiahsdo[ainsfl]asfkjnb;asklnj'
|
||||||
|
app.config['SESSION_TYPE'] = 'memcached'
|
||||||
with open('admin.json') as f:
|
with open('admin.json') as f:
|
||||||
postgres_credentials = json.load(f)
|
postgres_credentials = json.load(f)
|
||||||
db_engine, db_metadata = connect(postgres_credentials['username'], postgres_credentials['password'], 'parts_v2')
|
db_engine, db_metadata = connect(postgres_credentials['username'], postgres_credentials['password'], 'parts_v2')
|
||||||
parts = sqlalchemy.Table('parts', db_metadata)
|
parts = sqlalchemy.Table('parts', db_metadata)
|
||||||
|
try:
|
||||||
|
with open('octopartAPIkey.json') as f:
|
||||||
|
j = json.load(f);
|
||||||
|
if j['key'] is not '':
|
||||||
|
octopartURL = j['URL'] + j['key']
|
||||||
|
print ("Octopart credentials loaded.")
|
||||||
|
else:
|
||||||
|
raise FileNotFoundError
|
||||||
|
except FileNotFoundError:
|
||||||
|
print ("NO OCTOPART KEY FOUND. ABANDONING THAT PART")
|
||||||
# Example query
|
# Example query
|
||||||
'''s = select([parts]).where(parts.c.notes != '')
|
'''s = select([parts]).where(parts.c.notes != '')
|
||||||
for row in db_engine.execute(s):
|
for row in db_engine.execute(s):
|
||||||
|
|||||||
|
After Width: | Height: | Size: 14 KiB |
@@ -1,18 +1,18 @@
|
|||||||
var rootURL = '/parts/'
|
var rootURL = '/parts/'
|
||||||
|
|
||||||
function overlay_in() {
|
function overlay_in() {
|
||||||
$('.shadow').css({'display' : 'block'});
|
$('.shadow').show();
|
||||||
$('.overlay').css({'display' : 'block'});
|
$('.overlay').show();
|
||||||
$('.shadow').animate({'opacity' : 0.7});
|
$('.shadow').animate({'opacity' : 0.7});
|
||||||
$('.overlay').animate({'opacity' : 1.0, 'top' : '5%'});
|
$('.overlay').animate({'opacity' : 1.0, 'top' : '5%'});
|
||||||
}
|
}
|
||||||
|
|
||||||
function overlay_out() {
|
function overlay_out() {
|
||||||
$('.shadow').animate({'opacity' : 0.0}, function () {
|
$('.shadow').animate({'opacity' : 0.0}, function () {
|
||||||
$('.overlay').css({'display' : 'none'});
|
$('.shadow').hide();
|
||||||
});
|
});
|
||||||
$('.overlay').animate({'opacity' : 0.0, 'top' : '0'}, function () {
|
$('.overlay').animate({'opacity' : 0.0, 'top' : '0'}, function () {
|
||||||
$('.shadow').css({'display' : 'none'});
|
$('.overlay').hide();
|
||||||
});
|
});
|
||||||
end_edit();
|
end_edit();
|
||||||
}
|
}
|
||||||
@@ -1,27 +1,26 @@
|
|||||||
function new_location_entry() {
|
function new_location_entry() {
|
||||||
$('#location-name-input').text('');
|
|
||||||
$('#location-name-input').show();
|
}
|
||||||
$('#mapfile-input').show();
|
|
||||||
init_Location_edit(-1);
|
function init_Location_edit(locationID, name, containerID) {
|
||||||
|
$('#save-button').attr("onclick", "saveLocation(" + locationID + ")");
|
||||||
|
$('#delete-button').attr("onclick", "deleteLocation(" + locationID + ")");
|
||||||
|
$('#location-name-input').val(name);
|
||||||
|
if(containerID > 0){
|
||||||
|
$("#container-input").val(containerID);
|
||||||
|
update_map();
|
||||||
|
}
|
||||||
overlay_in();
|
overlay_in();
|
||||||
}
|
}
|
||||||
|
|
||||||
function init_Location_edit(locationID) {
|
function update_map() {
|
||||||
|
var selected_map_file = $('#container-input').val();
|
||||||
$('table#details tr#datasheet td input').show();
|
$('#map').attr('src', 'map/' + selected_map_file);
|
||||||
|
|
||||||
var newButton = '<div class="round-button-left"><a href="#" onclick="saveLocation(' + locationID + ')"><i class="fa fa-check" aria-hidden="true"></i></a></div>';
|
|
||||||
$('.round-button-left').replaceWith(newButton);
|
|
||||||
}
|
|
||||||
|
|
||||||
function update_clickable_map() {
|
|
||||||
var selected_map_file = $('#mapfile-input').val();
|
|
||||||
$('#clickablemap').attr('src', 'map/' + selected_map_file);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
function saveLocation(locationID) {
|
function saveLocation(locationID) {
|
||||||
var map_v = $('#clickablemap').attr('src').substring(4);
|
var container_v = $('#container-input').val();
|
||||||
var name_v = $('#location-name-input').val();
|
var name_v = $('#location-name-input').val();
|
||||||
|
|
||||||
if(name_v.length > 100) {
|
if(name_v.length > 100) {
|
||||||
@@ -30,7 +29,7 @@ function saveLocation(locationID) {
|
|||||||
}
|
}
|
||||||
var data = new FormData();
|
var data = new FormData();
|
||||||
|
|
||||||
data.append('map', map_v);
|
data.append('container', container_v);
|
||||||
data.append('name', name_v)
|
data.append('name', name_v)
|
||||||
|
|
||||||
$.ajax({
|
$.ajax({
|
||||||
@@ -54,7 +53,65 @@ function saveLocation(locationID) {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
function deleteLocation(locationID) {
|
||||||
|
if (locationID < 0)
|
||||||
|
alert('Congratulations! You found the secret UI bug easter egg! This button should not be here, yet I left it specifically because I wanted an easter egg and not because of any other reasons! Good for you!')
|
||||||
|
return;
|
||||||
|
if (!confirm('Delete the selected location? If there are parts there, this will leave a mess in the database and Marek will be very sad.'))
|
||||||
|
return;
|
||||||
|
$.ajax({
|
||||||
|
url: rootURL + 'deleteLocation/' + locationID,
|
||||||
|
type: 'GET',
|
||||||
|
cache: false,
|
||||||
|
contentType: false,
|
||||||
|
processData: false,
|
||||||
|
success: function() {
|
||||||
|
alert("location removed.");
|
||||||
|
overlay_out();
|
||||||
|
location.reload();
|
||||||
|
},
|
||||||
|
fail: function() {
|
||||||
|
console.log('An error occurred while deleting the entry');
|
||||||
|
},
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
function end_edit(){
|
||||||
|
//intentionally left blank
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
function show_location_info(locationID) {
|
||||||
|
$.getJSON(rootURL + 'getpartinfo/' + partID, function(data) {
|
||||||
|
$('table#details tr#location td p').text(text_filter(data.location_descriptor)); // name is the location friendly name
|
||||||
|
$('#location-dropdown').val(data.location_id);
|
||||||
|
$('#container-dropdown').val(data.container_id);
|
||||||
|
$('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));
|
||||||
|
container_onchange();
|
||||||
|
if (data.datasheet != null) {
|
||||||
|
$('tr#datasheet-head').html($('<td>DATASHEET: <a href="parts/getfile/' + data.datasheet + '"><i class="fa fa-file-text" aria-hidden="true"></i></a></td>'));
|
||||||
|
$('#datasheet-input').val(data.datasheet);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
$('tr#datasheet-head td').text('DATASHEET: ');
|
||||||
|
$('#edit-button').click(function() {
|
||||||
|
init_edit(partID);
|
||||||
|
});
|
||||||
|
$('#delete-button').click(function() {
|
||||||
|
delete_entry(partID);
|
||||||
|
});
|
||||||
|
overlay_in();
|
||||||
|
}).fail(function() {
|
||||||
|
console.log( "Fetching part info failed" );
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
function placeMarker(locationID){
|
function placeMarker(locationID){
|
||||||
|
//temporarily not used
|
||||||
var $img = $('#clickablemap');
|
var $img = $('#clickablemap');
|
||||||
var currentClickPosX = event.pageX - $img.offset().left;
|
var currentClickPosX = event.pageX - $img.offset().left;
|
||||||
var currentClickPosY = event.pageY - $img.offset().top;
|
var currentClickPosY = event.pageY - $img.offset().top;
|
||||||
|
|||||||
@@ -1,19 +1,24 @@
|
|||||||
function init_edit(partID) {
|
function init_edit(partID) {
|
||||||
$('table#details tr#location td p').hide();
|
$('table#details tr#location td p').hide();
|
||||||
$('table#details tr#location td select').show();
|
$('#location-dropdown').show();
|
||||||
|
$('#container-dropdown').show();
|
||||||
|
|
||||||
$('table#details tr#partno td p').hide();
|
$('table#details tr#partno td p').hide();
|
||||||
$('table#details tr#partno td input').show();
|
$('input[name=partno-input]').show();
|
||||||
|
$('#magical_autofill').show();
|
||||||
|
|
||||||
$('table#details tr#description td p').hide();
|
$('table#details tr#description td p').hide();
|
||||||
$('table#details tr#description td input').show();
|
$('input[name=description-input]').show();
|
||||||
|
|
||||||
|
$('table#details tr#datasheet td input').closest().show();
|
||||||
$('table#details tr#datasheet td input').show();
|
$('table#details tr#datasheet td input').show();
|
||||||
|
|
||||||
$('#duplicate-button').closest('div').hide();
|
$('#duplicate-button').closest('div').hide();
|
||||||
|
|
||||||
var datasheet_input = $('<input type="file" class="part-edit-file" id="datasheet-input" accept=".pdf">')
|
$('tr#datasheet').show();
|
||||||
$('#datasheet-info').replaceWith(datasheet_input);
|
|
||||||
|
$('input[name=notes-input]').show();
|
||||||
|
$('table#details tr#notes td p').hide();
|
||||||
|
|
||||||
var newButton = '<div class="round-button-left"><a href="#" onclick="save(' + partID + ')"><i class="fa fa-check" aria-hidden="true"></i></a></div>';
|
var newButton = '<div class="round-button-left"><a href="#" onclick="save(' + partID + ')"><i class="fa fa-check" aria-hidden="true"></i></a></div>';
|
||||||
$('.round-button-left').replaceWith(newButton);
|
$('.round-button-left').replaceWith(newButton);
|
||||||
@@ -25,6 +30,8 @@ function new_entry() {
|
|||||||
$('table#details tr#description td p').text('');
|
$('table#details tr#description td p').text('');
|
||||||
$('table#details tr#partno td input').val('');
|
$('table#details tr#partno td input').val('');
|
||||||
$('table#details tr#description td input').val('');
|
$('table#details tr#description td input').val('');
|
||||||
|
$('input[name=datasheet-url-input]').val('');
|
||||||
|
container_onchange();
|
||||||
init_edit(-1);
|
init_edit(-1);
|
||||||
overlay_in();
|
overlay_in();
|
||||||
}
|
}
|
||||||
@@ -33,17 +40,23 @@ function end_edit() {
|
|||||||
|
|
||||||
$('table#details tr#location td p').text($('table#details tr#location td select option:checked').text());
|
$('table#details tr#location td p').text($('table#details tr#location td select option:checked').text());
|
||||||
$('table#details tr#location td p').show();
|
$('table#details tr#location td p').show();
|
||||||
$('table#details tr#location td select').hide();
|
$('#location-dropdown').hide();
|
||||||
|
$('#container-dropdown').hide();
|
||||||
|
|
||||||
$('table#details tr#partno td p').text($('table#details tr#partno td input').val());
|
$('table#details tr#partno td p').text($('table#details tr#partno td input').val());
|
||||||
$('table#details tr#partno td p').show();
|
$('table#details tr#partno td p').show();
|
||||||
$('table#details tr#partno td input').hide();
|
$('table#details tr#partno td input').hide();
|
||||||
|
|
||||||
|
$('#magical_autofill').hide();
|
||||||
|
|
||||||
$('table#details tr#description td p').text($('table#details tr#description td input').val());
|
$('table#details tr#description td p').text($('table#details tr#description td input').val());
|
||||||
$('table#details tr#description td p').show();
|
$('table#details tr#description td p').show();
|
||||||
$('table#details tr#description td input').hide();
|
$('table#details tr#description td input').hide();
|
||||||
|
|
||||||
$('table#details tr#datasheet td input').hide();
|
$('tr#datasheet').hide();
|
||||||
|
|
||||||
|
$('input[name=notes-input]').hide();
|
||||||
|
$('table#details tr#notes td p').show();
|
||||||
|
|
||||||
$('#duplicate-button').closest('div').show();
|
$('#duplicate-button').closest('div').show();
|
||||||
|
|
||||||
@@ -52,25 +65,47 @@ function end_edit() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function save(partID) {
|
function save(partID) {
|
||||||
var location_id_v = $('table#details tr#location td select').val();
|
if (!$('#location-dropdown').val()) {
|
||||||
var partno_v = $('table#details tr#partno td input').val();
|
alert('Please select a location.');
|
||||||
var description_v = $('table#details tr#description td input').val();
|
return;
|
||||||
|
}
|
||||||
|
var location_id_v = $('#location-dropdown').val();
|
||||||
|
var partno_v = $('input[name=partno-input]').val();
|
||||||
|
var description_v = $('input[name=description-input]').val();
|
||||||
var datasheet = $('table#details tr#datasheet td input')[0].files;
|
var datasheet = $('table#details tr#datasheet td input')[0].files;
|
||||||
|
var datasheet_url_v = $('input[name=datasheet-url-input]').val();
|
||||||
|
var notes_v = $('input[name=notes-input]').val();
|
||||||
|
if(partno_v.length == 0){
|
||||||
|
alert('Please enter a part number.');
|
||||||
|
return;
|
||||||
|
}
|
||||||
if(description_v.length > 200) {
|
if(description_v.length > 200) {
|
||||||
alert('Description too long (max 200 characters).')
|
alert('Description too long (max 200 characters).');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if(description_v.length == 0) {
|
||||||
|
alert('Please enter a description.');
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
var data = new FormData();
|
var data = new FormData();
|
||||||
|
|
||||||
if (datasheet.length == 1)
|
if (datasheet.length == 1) {
|
||||||
if(! datasheet[0]['name'].match(/^[\w\-]+\.pdf$/g)) {
|
if(! datasheet[0]['name'].match(/^[\w\-]+\.pdf$/g)) {
|
||||||
alert('Invalid filename. Please match /^[\w\-]+\.pdf$/g');
|
alert('Invalid filename. Please match /^[\w\-]+\.pdf$/g');
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
if (datasheet[0]['size'] > 20 * 1000000) {
|
||||||
|
alert('File too large. Must be < 20MB.');
|
||||||
|
return;
|
||||||
|
}
|
||||||
data.append('datasheet-file', datasheet[0]);
|
data.append('datasheet-file', datasheet[0]);
|
||||||
|
} else if (datasheet_url_v.length > 0) {
|
||||||
|
data.append('datasheet-url', datasheet_url_v);
|
||||||
|
}
|
||||||
data.append('partno', partno_v);
|
data.append('partno', partno_v);
|
||||||
data.append('location_id', location_id_v)
|
data.append('location_id', location_id_v);
|
||||||
data.append('description', description_v);
|
data.append('description', description_v);
|
||||||
|
data.append('notes', notes_v);
|
||||||
|
|
||||||
$.ajax({
|
$.ajax({
|
||||||
// Your server script to process the upload
|
// Your server script to process the upload
|
||||||
@@ -132,14 +167,19 @@ function delete_entry(partID) {
|
|||||||
function show_part_info(partID) {
|
function show_part_info(partID) {
|
||||||
$.getJSON(rootURL + 'getpartinfo/' + partID, function(data) {
|
$.getJSON(rootURL + 'getpartinfo/' + partID, function(data) {
|
||||||
$('table#details tr#location td p').text(text_filter(data.location_descriptor)); // 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
|
$('#location-dropdown').val(data.location_id);
|
||||||
|
$('#container-dropdown').val(data.container_id);
|
||||||
$('table#details tr#partno td p').text(text_filter(data.partno));
|
$('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#partno td input').val(text_filter(data.partno));
|
||||||
$('table#details tr#description td p').text(text_filter(data.description));
|
$('table#details tr#description td p').text(text_filter(data.description));
|
||||||
$('table#details tr#description td input').val(text_filter(data.description));
|
$('table#details tr#description td input').val(text_filter(data.description));
|
||||||
$('img#map').attr('src', 'parts/map/' + data.container_id);
|
$('table#details tr#notes td p').text(text_filter(data.notes));
|
||||||
if (data.datasheet != null)
|
$('input[name=notes-input]').val(text_filter(data.notes));
|
||||||
$('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>'));
|
container_onchange();
|
||||||
|
if (data.datasheet != null) {
|
||||||
|
$('tr#datasheet-head').html($('<td>DATASHEET: <a href="' + data.datasheet + '" target="_blank"><i class="fa fa-file-text" aria-hidden="true"></i></a></td>'));
|
||||||
|
$('input[name=datasheet-url-input]').val(data.datasheet);
|
||||||
|
}
|
||||||
else
|
else
|
||||||
$('tr#datasheet-head td').text('DATASHEET: ');
|
$('tr#datasheet-head td').text('DATASHEET: ');
|
||||||
$('#edit-button').click(function() {
|
$('#edit-button').click(function() {
|
||||||
@@ -155,17 +195,18 @@ function show_part_info(partID) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function perform_query() {
|
function perform_query() {
|
||||||
|
$('#no-results').stop();
|
||||||
$('#no-results').css("opacity", 0);
|
$('#no-results').css("opacity", 0);
|
||||||
|
$('#no-results').hide();
|
||||||
var query = $('.search-bar').val();
|
var query = $('.search-bar').val();
|
||||||
var data = {
|
var data = {
|
||||||
l:$('#type').is(':checked'),
|
l:$('#location').is(':checked'),
|
||||||
p:$('#partno').is(':checked'),
|
p:$('#partno').is(':checked'),
|
||||||
d:$('#description').is(':checked'),
|
d:$('#description').is(':checked')
|
||||||
n:$('#notes').is(':checked')
|
|
||||||
};
|
};
|
||||||
filter = '0';
|
filter = '0';
|
||||||
|
$("#results").find("tr:not(:first)").remove(); // Delete all table rows
|
||||||
$.getJSON(rootURL + 'query/' + filter + '/' + query, data, function(data) {
|
$.getJSON(rootURL + 'query/' + filter + '/' + query, data, function(data) {
|
||||||
$("#results").find("tr:not(:first)").remove(); // Delete all table rows
|
|
||||||
for(var i = 0; i < data.length; i++) {
|
for(var i = 0; i < data.length; i++) {
|
||||||
var newRow = $('<tr onclick="show_part_info(' + data[i].id + ')"></tr>');
|
var newRow = $('<tr onclick="show_part_info(' + data[i].id + ')"></tr>');
|
||||||
|
|
||||||
@@ -175,22 +216,39 @@ function perform_query() {
|
|||||||
$('#results').append(newRow);
|
$('#results').append(newRow);
|
||||||
}
|
}
|
||||||
if(data.length == 0) {
|
if(data.length == 0) {
|
||||||
$('#no-results').animate({opacity:1},2000);
|
$('#no-results').show();
|
||||||
|
$('#no-results').animate({opacity:1},2000);
|
||||||
}
|
}
|
||||||
}).fail(function() {
|
}).fail(function() {
|
||||||
var newResults = '<div class="results">';
|
$('#no-results').show();
|
||||||
newResults += '<h3>No results.</h3>';
|
$('#no-results').animate({opacity:1},2000);
|
||||||
newResults += '</div>';
|
|
||||||
$('.results').replaceWith(newResults);
|
|
||||||
console.log( "Query failed" );
|
console.log( "Query failed" );
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
function update_map() {
|
function container_onchange() {
|
||||||
var selected_id = $('table#details tr#location td select').val();
|
var selected_container_id = $('#container-dropdown').val();
|
||||||
$.ajax('parts/getlocationURL/' + selected_id).done( function(data) {
|
if (selected_container_id > 0) {
|
||||||
$('img#map').attr('src', 'parts/map/' + data);
|
$('img#map').attr('src', 'parts/map/' + selected_container_id);
|
||||||
});
|
$('#location-dropdown').empty();
|
||||||
|
$.getJSON('parts/getlocationsInContainer/' + selected_container_id, function(data) {
|
||||||
|
$.each(data, function(location_id, location_name) {
|
||||||
|
$('#location-dropdown').append('<option value="' + location_id + '">' + location_name + '</option>');
|
||||||
|
});
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
function octopartFetch(){
|
||||||
|
$.getJSON(rootURL + 'fetchOctopartSnippet/' + $('#partno-input').val()).done(function(json){
|
||||||
|
if (json['result']=='ok'){
|
||||||
|
$('#description-input').val(json['snippet']);
|
||||||
|
}else{
|
||||||
|
$('#description-input').val('');
|
||||||
|
$('#description-input').attr('placeholder', json['result']);
|
||||||
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
$(document).ready(function() {
|
$(document).ready(function() {
|
||||||
@@ -202,7 +260,7 @@ $(document).ready(function() {
|
|||||||
if ( !$('#location').is(':checked')
|
if ( !$('#location').is(':checked')
|
||||||
&& !$('#partno').is(':checked')
|
&& !$('#partno').is(':checked')
|
||||||
&& !$('#description').is(':checked')
|
&& !$('#description').is(':checked')
|
||||||
&& !$('#notes').is(':checked'))
|
&& !$('#has-docs').is(':checked'))
|
||||||
$(this).prop('checked', true);
|
$(this).prop('checked', true);
|
||||||
else
|
else
|
||||||
perform_query();
|
perform_query();
|
||||||
|
|||||||
@@ -2,6 +2,7 @@ html {
|
|||||||
background-color: #D7E2E2;
|
background-color: #D7E2E2;
|
||||||
color: #000F0F;
|
color: #000F0F;
|
||||||
font-family: 'Roboto', sans-serif;
|
font-family: 'Roboto', sans-serif;
|
||||||
|
font-size:large;
|
||||||
}
|
}
|
||||||
|
|
||||||
body {
|
body {
|
||||||
@@ -26,7 +27,7 @@ h3 {
|
|||||||
color: #5E9292;
|
color: #5E9292;
|
||||||
text-align: center;
|
text-align: center;
|
||||||
padding: 12pt;
|
padding: 12pt;
|
||||||
font-size: 20pt;
|
font-size: x-large;
|
||||||
opacity: 0;
|
opacity: 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -40,7 +41,7 @@ a {
|
|||||||
|
|
||||||
input[type=text].search-bar {
|
input[type=text].search-bar {
|
||||||
color: #404040;
|
color: #404040;
|
||||||
font-size: 20pt;
|
font-size: x-large;
|
||||||
padding: 5pt 8pt 5pt 8pt;
|
padding: 5pt 8pt 5pt 8pt;
|
||||||
margin-top: 8pt;
|
margin-top: 8pt;
|
||||||
margin-bottom: 8pt;
|
margin-bottom: 8pt;
|
||||||
@@ -59,7 +60,6 @@ input[type=text].search-bar {
|
|||||||
padding: 10pt 15pt 10pt 15pt;
|
padding: 10pt 15pt 10pt 15pt;
|
||||||
margin-top: 10pt;
|
margin-top: 10pt;
|
||||||
margin-bottom: 10pt;
|
margin-bottom: 10pt;
|
||||||
border-radius: 2pt;
|
|
||||||
display: inline-block;
|
display: inline-block;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -68,7 +68,7 @@ input[type=text].search-bar {
|
|||||||
color: #D7E2E2;
|
color: #D7E2E2;
|
||||||
font-size: 10pt;
|
font-size: 10pt;
|
||||||
margin-top: 4pt;
|
margin-top: 4pt;
|
||||||
margin-left: 16pt;
|
margin-left: 3pt;
|
||||||
margin-bottom: 4pt;
|
margin-bottom: 4pt;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -81,7 +81,6 @@ input[type=checkbox]{
|
|||||||
}
|
}
|
||||||
|
|
||||||
input[type=checkbox] + label.toggle-btn {
|
input[type=checkbox] + label.toggle-btn {
|
||||||
border-radius: 3pt;
|
|
||||||
display: inline-block;
|
display: inline-block;
|
||||||
padding: 5pt;
|
padding: 5pt;
|
||||||
color: #D7E2E2;
|
color: #D7E2E2;
|
||||||
@@ -89,7 +88,8 @@ input[type=checkbox] + label.toggle-btn {
|
|||||||
margin-bottom: 6pt;
|
margin-bottom: 6pt;
|
||||||
margin-left: 3pt;
|
margin-left: 3pt;
|
||||||
margin-right: 3pt;
|
margin-right: 3pt;
|
||||||
width: 100pt;
|
width: 80pt;
|
||||||
|
line-height: 300%;
|
||||||
text-align: center;
|
text-align: center;
|
||||||
border: 1pt solid #D7E2E2;
|
border: 1pt solid #D7E2E2;
|
||||||
transition: 0.2s;
|
transition: 0.2s;
|
||||||
@@ -152,7 +152,7 @@ div label input {
|
|||||||
height: 100%;
|
height: 100%;
|
||||||
left: 0;
|
left: 0;
|
||||||
opacity: 0.0;
|
opacity: 0.0;
|
||||||
position: absolute;
|
position: fixed;
|
||||||
top: 0;
|
top: 0;
|
||||||
width: 100%;
|
width: 100%;
|
||||||
z-index: 200;
|
z-index: 200;
|
||||||
@@ -163,36 +163,19 @@ div label input {
|
|||||||
color: #D7E2E2;
|
color: #D7E2E2;
|
||||||
display: none;
|
display: none;
|
||||||
height: 90%;
|
height: 90%;
|
||||||
left: 20%;
|
|
||||||
padding: 0;
|
padding: 0;
|
||||||
position: fixed;
|
position: fixed;
|
||||||
|
margin:auto;
|
||||||
|
left:0;
|
||||||
|
right:0;
|
||||||
top:0;
|
top:0;
|
||||||
width: 60%;
|
min-width: 60%;
|
||||||
|
width:900px;
|
||||||
z-index: 201;
|
z-index: 201;
|
||||||
border-radius: 2pt;
|
|
||||||
text-align: center;
|
text-align: center;
|
||||||
opacity: 0.0;
|
opacity: 0.0;
|
||||||
}
|
}
|
||||||
|
|
||||||
.details-item {
|
|
||||||
display: inline-block;
|
|
||||||
width: 25%;
|
|
||||||
padding: 12pt 10pt 12pt 0;
|
|
||||||
text-align: right;
|
|
||||||
text-transform: uppercase;
|
|
||||||
}
|
|
||||||
|
|
||||||
.details-content {
|
|
||||||
display: inline-block;
|
|
||||||
width: 65%;
|
|
||||||
padding-left: 20pt;
|
|
||||||
text-align: left;
|
|
||||||
}
|
|
||||||
|
|
||||||
.details-content p {
|
|
||||||
text-align: left;
|
|
||||||
}
|
|
||||||
|
|
||||||
.round-button {
|
.round-button {
|
||||||
position: absolute;
|
position: absolute;
|
||||||
bottom: 15pt;
|
bottom: 15pt;
|
||||||
@@ -284,13 +267,16 @@ div label input {
|
|||||||
|
|
||||||
table#results {
|
table#results {
|
||||||
width: 100%;
|
width: 100%;
|
||||||
|
max-width: 1280px;
|
||||||
|
margin-left: auto;
|
||||||
|
margin-right: auto;
|
||||||
border-collapse: collapse;
|
border-collapse: collapse;
|
||||||
}
|
}
|
||||||
|
|
||||||
table#results th {
|
table#results th {
|
||||||
background-color: #226666;
|
background-color: #226666;
|
||||||
color: #D7E2E2;
|
color: #D7E2E2;
|
||||||
padding: 4pt;
|
padding: 5pt;
|
||||||
border-right: 2px solid #D7E2E2;
|
border-right: 2px solid #D7E2E2;
|
||||||
border-left: 2px solid #D7E2E2;
|
border-left: 2px solid #D7E2E2;
|
||||||
}
|
}
|
||||||
@@ -305,7 +291,7 @@ table#results td {
|
|||||||
}
|
}
|
||||||
|
|
||||||
table#results #location {
|
table#results #location {
|
||||||
width: 15%;
|
width: 18%;
|
||||||
}
|
}
|
||||||
|
|
||||||
table#results #partno {
|
table#results #partno {
|
||||||
@@ -323,65 +309,17 @@ table#results #docs {
|
|||||||
table#details {
|
table#details {
|
||||||
position: absolute;
|
position: absolute;
|
||||||
left: 0;
|
left: 0;
|
||||||
width: 45%;
|
width: 35%;
|
||||||
margin-top: 4%;
|
margin-top: 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
table#details #location-head {
|
.details-header {
|
||||||
height: 10%;
|
|
||||||
color: #013A3A;
|
color: #013A3A;
|
||||||
}
|
}
|
||||||
|
|
||||||
table#details #location {
|
.details-content td{
|
||||||
height: 10%;
|
padding-top:6pt;
|
||||||
}
|
padding-bottom:16pt;
|
||||||
|
|
||||||
table#details #location td{
|
|
||||||
height: 10%;
|
|
||||||
}
|
|
||||||
|
|
||||||
table#details #partno-head {
|
|
||||||
height: 10%;
|
|
||||||
color: #013A3A;
|
|
||||||
}
|
|
||||||
|
|
||||||
table#details #partno-head td{
|
|
||||||
padding-top: 16pt;
|
|
||||||
}
|
|
||||||
|
|
||||||
table#details #partno{
|
|
||||||
height: 10%;
|
|
||||||
}
|
|
||||||
|
|
||||||
table#details #partno td{
|
|
||||||
height: 10%;
|
|
||||||
}
|
|
||||||
|
|
||||||
table#details #description-head {
|
|
||||||
height: 10%;
|
|
||||||
color: #013A3A;
|
|
||||||
}
|
|
||||||
|
|
||||||
table#details #description-head td {
|
|
||||||
padding-top: 16pt;
|
|
||||||
}
|
|
||||||
|
|
||||||
table#details #description {
|
|
||||||
height: 20%;
|
|
||||||
}
|
|
||||||
|
|
||||||
table#details #description td {
|
|
||||||
padding-left: 5%;
|
|
||||||
padding-right: 5%;
|
|
||||||
}
|
|
||||||
|
|
||||||
table#details #datasheet-head {
|
|
||||||
height: 10%;
|
|
||||||
color: #013A3A;
|
|
||||||
}
|
|
||||||
|
|
||||||
table#details #datasheet-head td {
|
|
||||||
padding-top: 16pt;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
td p {
|
td p {
|
||||||
@@ -392,12 +330,20 @@ td p {
|
|||||||
.map {
|
.map {
|
||||||
position: absolute;
|
position: absolute;
|
||||||
right: 5%;
|
right: 5%;
|
||||||
margin-top: 4%;
|
/*margin-top: 4%;*/
|
||||||
max-height: calc(90% - 42pt);
|
max-height: calc(90% - 42pt);
|
||||||
max-width: 50%;
|
max-width: 60%;
|
||||||
}
|
}
|
||||||
|
|
||||||
.pinfo-input {
|
.pinfo-input {
|
||||||
display: none;
|
display: none;
|
||||||
width: 90%;
|
width: 90%;
|
||||||
|
}
|
||||||
|
|
||||||
|
.nothidden{
|
||||||
|
display: initial !important;
|
||||||
|
}
|
||||||
|
|
||||||
|
.results-locations{
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -2,7 +2,7 @@
|
|||||||
<html>
|
<html>
|
||||||
<head>
|
<head>
|
||||||
<meta charset="utf-8">
|
<meta charset="utf-8">
|
||||||
<title>ELAB Part Search Engine</title>
|
<title>ELAB Part Search Engine - Location editor</title>
|
||||||
<script
|
<script
|
||||||
src="https://code.jquery.com/jquery-3.2.1.min.js"
|
src="https://code.jquery.com/jquery-3.2.1.min.js"
|
||||||
integrity="sha256-hwg4gsxgFZhOsEEamdOYGBf13FyQuiTwlAQgxVSNgt4="
|
integrity="sha256-hwg4gsxgFZhOsEEamdOYGBf13FyQuiTwlAQgxVSNgt4="
|
||||||
@@ -14,19 +14,21 @@
|
|||||||
<script type="text/javascript" src="{{ url_for('static', filename='locationEditorScript.js') }}"></script>
|
<script type="text/javascript" src="{{ url_for('static', filename='locationEditorScript.js') }}"></script>
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
<h1>ELAB Part Search Engine - LOCATION EDITOR</h1>
|
<h1>LOCATION EDITOR</h1>
|
||||||
<p>Looking for a place to store your obsolete ICs discontinued years ago? Just toss them anywhere and mark that location here!</p>
|
<p>Looking for a place to store your obsolete ICs discontinued years ago? Just toss them anywhere and mark that location here! <a href=".">back to parts</a></p>
|
||||||
<table id="results">
|
<table id="results" class="results-locations">
|
||||||
<tr>
|
<tr>
|
||||||
<th id="id">ID</th>
|
<th>ID</th>
|
||||||
<th id="location">Location name</th>
|
<th>c.ID</th>
|
||||||
<th id="mapURL">Map URL</th>
|
<th>Container name</th>
|
||||||
|
<th>Location name</th>
|
||||||
</tr>
|
</tr>
|
||||||
{% for location in locations %}
|
{% for location in locations %}
|
||||||
<tr>
|
<tr onclick="init_Location_edit({{location['id']}}, '{{location['name']}}', {{location['container_id']}});">
|
||||||
<td>{{location['id']}}</td>
|
<td>{{location['id']}}</td>
|
||||||
|
<td>{{location['container_id']}}</td>
|
||||||
|
<td>{{location['container']}}</td>
|
||||||
<td>{{location['name']}}</td>
|
<td>{{location['name']}}</td>
|
||||||
<td>{{location['map']}}</td>
|
|
||||||
</tr>
|
</tr>
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
</table>
|
</table>
|
||||||
@@ -35,26 +37,28 @@
|
|||||||
<div class="overlay">
|
<div class="overlay">
|
||||||
<h2>Part Details</h2>
|
<h2>Part Details</h2>
|
||||||
<table id="details">
|
<table id="details">
|
||||||
<tr><td>Name</td></tr>
|
<tr><td>Adding a new LOCATION inside a given CONTAINER</td></tr>
|
||||||
<tr><td><p></p><input type="text" name="location-name-input" id="location-name-input" placeholder="Location name" class="pinfo-input"/></td></tr>
|
|
||||||
|
|
||||||
<tr><td>MAP</td></tr>
|
|
||||||
<tr><td>
|
<tr><td>
|
||||||
<select class="pinfo-input" onchange="update_clickable_map()" name="mapfile-input" id="mapfile-input">
|
<select class="pinfo-input nothidden" onchange="update_map()" name="mapfile-input" id="container-input">
|
||||||
{% for mapfile in mapfiles %}
|
{% for container in containers %}
|
||||||
<option value="{{mapfile}}" {% if mapfile==defaultMapfile %}selected="true"{% endif %}>{{mapfile}}</option>
|
<option value="{{container['id']}}">{{container['name']}}</option>
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
</select>
|
</select>
|
||||||
</td></tr>
|
</td></tr>
|
||||||
|
|
||||||
<tr><td>And click on the map to place the marker</td></tr>
|
<tr><td>Location name (obs! If a drawer has an identification sticker, start the name with it.<br />Example: ".2 - Power resistors"</td></tr>
|
||||||
|
<tr><td><p></p><input type="text" name="location-name-input" id="location-name-input" placeholder="Location name" class="pinfo-input nothidden"/></td></tr>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
<tr><td>Note: adding custom "containers" is currently insupported and unpossible.</td></tr>
|
||||||
|
|
||||||
</table>
|
</table>
|
||||||
<img src="map/{{defaultMapfile}}" id="clickablemap" class="map" onclick="placeMarker()"/>
|
<img src="map/{{containers[0]['id']}}" id="map" class="map"/>
|
||||||
<div class="round-button-left"><a href="#" id="edit-button"><i class="fa fa-pencil" aria-hidden="true"></i></a></div>
|
<div class="round-button-left"><a href="#" id="save-button"><i class="fa fa-check" aria-hidden="true"></i></a></div>
|
||||||
<div class="round-button"><a href="#" id="delete-button"><i class="fa fa-trash" aria-hidden="true"></i></a></div>
|
<div class="round-button"><a href="#" id="delete-button"><i class="fa fa-trash" aria-hidden="true"></i></a></div>
|
||||||
<div class="small-square-button"><a href="#" onclick="overlay_out()"><i class="fa fa-times" aria-hidden="true"></i></a></div>
|
<div class="small-square-button"><a href="#" onclick="overlay_out()"><i class="fa fa-times" aria-hidden="true"></i></a></div>
|
||||||
</div>
|
</div>
|
||||||
<div class="round-floating-button"><a href="#" onclick="new_location_entry()"><i class="fa fa-plus" aria-hidden="true"></i></a></div>
|
<div class="round-floating-button"><a href="#" onclick="init_Location_edit(-1, '', 0)"><i class="fa fa-plus" aria-hidden="true"></i></a></div>
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
|
|||||||
@@ -9,6 +9,8 @@
|
|||||||
crossorigin="anonymous"></script>
|
crossorigin="anonymous"></script>
|
||||||
<link href="https://fonts.googleapis.com/css?family=Roboto:300,400" rel="stylesheet">
|
<link href="https://fonts.googleapis.com/css?family=Roboto:300,400" rel="stylesheet">
|
||||||
<link rel="stylesheet" type="text/css" href="{{ url_for('static', filename='style.css') }}">
|
<link rel="stylesheet" type="text/css" href="{{ url_for('static', filename='style.css') }}">
|
||||||
|
<link rel="apple-touch-icon-precomposed" href="{{ url_for('static', filename='apple-touch-icon.png') }}">
|
||||||
|
|
||||||
<script src="https://use.fontawesome.com/2fef7be393.js"></script>
|
<script src="https://use.fontawesome.com/2fef7be393.js"></script>
|
||||||
<script type="text/javascript" src="{{ url_for('static', filename='common.js') }}"></script>
|
<script type="text/javascript" src="{{ url_for('static', filename='common.js') }}"></script>
|
||||||
<script type="text/javascript" src="{{ url_for('static', filename='script.js') }}"></script>
|
<script type="text/javascript" src="{{ url_for('static', filename='script.js') }}"></script>
|
||||||
@@ -21,11 +23,10 @@
|
|||||||
</div>
|
</div>
|
||||||
<div class="filter-concontainertainer">
|
<div class="filter-concontainertainer">
|
||||||
<div class="filter-container">
|
<div class="filter-container">
|
||||||
<p>Search in:</p>
|
<p>SEARCH IN</p>
|
||||||
<input type="checkbox" class="checkbox" id="location"></input><label class="toggle-btn" for="location">Locations</label>
|
<input type="checkbox" class="checkbox" id="location"></input><label class="toggle-btn" for="location">Locations<br/><i class="fa fa-map" style="font-size:28pt"></i></label>
|
||||||
<input type="checkbox" class="checkbox" id="partno" checked></input><label class="toggle-btn" for="partno">Part Number</label>
|
<input type="checkbox" class="checkbox" id="partno" checked></input><label class="toggle-btn" for="partno">Part Number<br/><i class="fa fa-hashtag" style="font-size:28pt"></i></label>
|
||||||
<input type="checkbox" class="checkbox" id="description" checked></input><label class="toggle-btn" for="description">Description</label>
|
<input type="checkbox" class="checkbox" id="description" checked></input><label class="toggle-btn" for="description">Description<br/><i class="fa fa-edit" style="font-size:28pt"></i></label>
|
||||||
<input type="checkbox" class="checkbox" id="notes" checked></input><label class="toggle-btn" for="notes">Notes</label>
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<table id="results">
|
<table id="results">
|
||||||
@@ -41,27 +42,38 @@
|
|||||||
<div class="shadow" onclick="overlay_out()"></div>
|
<div class="shadow" onclick="overlay_out()"></div>
|
||||||
<div class="overlay">
|
<div class="overlay">
|
||||||
<h2>Part Details</h2>
|
<h2>Part Details</h2>
|
||||||
|
<div>
|
||||||
<table id="details">
|
<table id="details">
|
||||||
<tr id="location-head"><td>LOCATION</td></tr>
|
<tr id="location-head" class="details-header"><td>LOCATION</td></tr>
|
||||||
<tr id="location"><td><p></p>
|
<tr id="location" class="details-content"><td><p></p>
|
||||||
<select class="pinfo-input" onchange="update_map()">
|
<select class="pinfo-input" id="container-dropdown" onchange="container_onchange()">
|
||||||
{% for container in containers %}
|
{% for container in containers %}
|
||||||
<option value="{{container['id']}}">{{container['name']}}</option>
|
<option value="{{container['id']}}">{{container['name']}}</option>
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
</select>
|
</select>
|
||||||
|
<select class="pinfo-input" id="location-dropdown">
|
||||||
|
<option value="-1" selected="true">-- Select a container --</option>
|
||||||
|
</select>
|
||||||
</td></tr>
|
</td></tr>
|
||||||
<tr id="partno-head"><td>PART NUMBER</td></tr>
|
<tr id="partno-head" class="details-header"><td>PART NUMBER</td></tr>
|
||||||
<tr id="partno"><td><p></p><input type="text" name="partno-input" placeholder="Part Number" class="pinfo-input"/></td></tr>
|
<tr id="partno" class="details-content"><td><p></p><input type="text" name="partno-input" placeholder="Part Number" class="pinfo-input" id="partno-input"/></td></tr>
|
||||||
<tr id="description-head"><td>DESCRIPTION</td></tr>
|
<tr id="description-head" class="details-header"><td>DESCRIPTION</td></tr>
|
||||||
<tr id="description"><td><p></p><input type="text" name="description-input" placeholder="Description" class="pinfo-input"/></td></tr>
|
<tr id="description" class="details-content"><td><p></p><input type="text" name="description-input" placeholder="Description" class="pinfo-input" id="description-input"/></td></tr>
|
||||||
<tr id="datasheet-head"><td>DATASHEET: </td></tr>
|
<tr id="magical_autofill" style="display:none"><td><input type="button" id="magic-autofill-button" onclick="octopartFetch()" value="magical auto-fill" style="margin-bottom:6pt"/></td></tr>
|
||||||
<tr id="datasheet"><td><input type="file" accept=".pdf" class="pinfo-input"></td></tr>
|
<tr id="datasheet-head" class="details-header"><td>DATASHEET: </td></tr>
|
||||||
|
<tr id="datasheet" style="display: none"><td><input type="file" accept=".pdf" class="pinfo-input" id="datasheet-finput"></td></tr>
|
||||||
|
<tr id="datasheet" style="display: none"><td>OR: <input type="text" class="pinfo-input" name="datasheet-url-input" style="width:80%; margin-bottom: 6pt;" placeholder="Datasheet URL"></td></tr>
|
||||||
|
<tr id="notes-head" class="details-header"><td>NOTES</td></tr>
|
||||||
|
<tr id="notes" class="details-content"><td><p></p><input type="text" name="notes-input" class="pinfo-input" placeholder="Notes"></td></tr>
|
||||||
</table>
|
</table>
|
||||||
<img src="" id="map" class="map"/>
|
<img src="" id="map" class="map"/>
|
||||||
|
</div>
|
||||||
|
<div>
|
||||||
<div class="round-button-left"><a href="#" id="edit-button"><i class="fa fa-pencil" aria-hidden="true"></i></a></div>
|
<div class="round-button-left"><a href="#" id="edit-button"><i class="fa fa-pencil" aria-hidden="true"></i></a></div>
|
||||||
<div class="round-button"><a href="#" id="delete-button"><i class="fa fa-trash" aria-hidden="true"></i></a></div>
|
<div class="round-button"><a href="#" id="delete-button"><i class="fa fa-trash" aria-hidden="true"></i></a></div>
|
||||||
<div class="round-button-right"><a href="#" id="duplicate-button" onclick="init_edit(-1)"><i class="fa fa-copy" aria-hidden="true"></i></a></div>
|
<div class="round-button-right"><a href="#" id="duplicate-button" onclick="init_edit(-1)"><i class="fa fa-copy" aria-hidden="true"></i></a></div>
|
||||||
<div class="small-square-button"><a href="#" onclick="overlay_out()"><i class="fa fa-times" aria-hidden="true"></i></a></div>
|
<div class="small-square-button"><a href="#" onclick="overlay_out()"><i class="fa fa-times" aria-hidden="true"></i></a></div>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="round-floating-button"><a href="#" onclick="new_entry()"><i class="fa fa-plus" aria-hidden="true"></i></a></div>
|
<div class="round-floating-button"><a href="#" onclick="new_entry()"><i class="fa fa-plus" aria-hidden="true"></i></a></div>
|
||||||
</body>
|
</body>
|
||||||
|
|||||||