Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
43006ce150 | ||
|
|
c3f1bba1d7 | ||
|
|
736cf7e065 | ||
|
|
68e10ec2ea | ||
|
|
b9142f71e0 | ||
|
|
8818b7d801 | ||
|
|
34d58dcfc9 | ||
|
|
0b77656e05 | ||
|
|
316c9323c2 | ||
|
|
1e6ac07e9e | ||
|
|
0c8ebeea3b | ||
|
|
c4da0395fa | ||
|
|
2d412372b1 | ||
|
|
c11c192d1c | ||
|
|
3c3f72b14f | ||
|
|
435e771e10 | ||
|
|
81409dc448 | ||
|
|
cd224a685b | ||
|
|
6998c7eff2 | ||
|
|
807c136143 | ||
|
|
51022e79bd | ||
|
|
b698ec446f | ||
|
|
4bceb35bd5 | ||
|
|
b3f8f890f4 | ||
|
|
fcf5f25c16 | ||
|
|
baed641f31 | ||
|
|
f57ac131ff | ||
|
|
961fb859f4 | ||
|
|
f331be7a89 | ||
|
|
a549c16548 | ||
|
|
8bb2a9d318 | ||
|
|
2be1d78d39 | ||
|
|
21e7356a99 | ||
|
|
ab663b1dec | ||
|
|
3cbff49168 | ||
|
|
6897d0f8ac | ||
|
|
feb1aea5c3 | ||
|
|
4f5df6c1fe | ||
|
|
1c8bdc69f6 | ||
|
|
a9ee37f96e | ||
|
|
3edd0542b8 | ||
|
|
3754174c7d | ||
|
|
6077dd4228 | ||
|
|
90b948a057 | ||
|
|
40f8263006 | ||
|
|
aebd74d185 | ||
|
|
d38013d00a | ||
|
|
2c14234e8d | ||
|
|
43ec84a3ca | ||
|
|
53db127b14 | ||
|
|
2f67fbf69a | ||
|
|
389409d814 | ||
|
|
c10a0258f6 | ||
|
|
fd8540d4e1 | ||
|
|
fd7c400bfe | ||
|
|
066c38db80 | ||
|
|
5c3aacfedf | ||
|
|
af3d1f3200 | ||
|
|
47c25847f0 | ||
|
|
c6168f5281 | ||
|
|
2de8a7bb99 | ||
|
|
f4fe883955 | ||
|
|
d7e9615453 | ||
|
|
f2ddbd6fdf | ||
|
|
d70c5dbde3 | ||
|
|
f1c32251f7 | ||
|
|
71ed8a60f4 | ||
|
|
ae96e7457c | ||
|
|
5da9712276 | ||
|
|
ff55c778ef | ||
|
|
bcbdc6b52a | ||
|
|
dac5d96f03 | ||
|
|
97a208f48c | ||
|
|
6e13be37e6 | ||
|
|
0789b3a0d8 | ||
|
|
4cf02f26c4 | ||
|
|
f4235556f7 | ||
|
|
dc880978ab | ||
|
|
582370a17d | ||
|
|
11b3ae1af5 | ||
|
|
82f1c364de | ||
|
|
38c22af31f | ||
|
|
112686b9c6 | ||
|
|
d64923ddad | ||
|
|
2a8b1f50f4 | ||
|
|
7e60da9362 | ||
|
|
227e725e95 | ||
|
|
a8496af806 | ||
|
|
cc6a1473cb | ||
|
|
b44d05aabd | ||
|
|
3cb81e9a79 | ||
|
|
b297462d3b | ||
|
|
40186ad08e | ||
|
|
a7751dc38b | ||
|
|
e2003e3562 | ||
|
|
7e1f59f781 | ||
|
|
4649723f87 | ||
|
|
0b64c50f36 | ||
|
|
597898885b | ||
|
|
55033f7295 | ||
|
|
8d1237011a | ||
|
|
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 | ||
|
|
9c80db4943 | ||
|
|
0fdcd100ff | ||
|
|
c4ca575ca1 | ||
|
|
3788060c78 | ||
|
|
d31799b3aa | ||
|
|
5df74f1276 | ||
|
|
7c1fd24cb0 | ||
|
|
329b076dec | ||
|
|
f072ffab4a | ||
|
|
e25d09aa5d | ||
|
|
a40748d0b2 | ||
|
|
9da62db5b8 | ||
|
|
6158439525 | ||
|
|
752b32cf7a | ||
|
|
1d5eefd87b | ||
|
|
e592f300bb | ||
|
|
706038bf09 | ||
|
|
161c866804 | ||
|
|
20db75a8d7 | ||
|
|
a0a090b5c0 | ||
|
|
839d2f87f5 | ||
|
|
56d2f9996c | ||
|
|
ca5d9e392d | ||
|
|
c1874759e2 | ||
|
|
2029ef5aeb | ||
|
|
fd4f29ca7d | ||
|
|
00a2d6f070 | ||
|
|
d131bcede6 | ||
|
|
3518c04c09 | ||
|
|
2d867f327c | ||
|
|
513cc34bdd | ||
|
|
1234bdfa14 | ||
|
|
2813481da4 | ||
|
|
f8301552c4 | ||
|
|
efc5af0b61 |
@@ -1,3 +1,5 @@
|
|||||||
admin.json
|
admin.json
|
||||||
edit_admin.json
|
edit_admin.json
|
||||||
*.scss
|
*.scss
|
||||||
|
|
||||||
|
.DS_Store
|
||||||
|
|||||||
@@ -0,0 +1,11 @@
|
|||||||
|
{
|
||||||
|
"port": 8084,
|
||||||
|
"repositories":
|
||||||
|
[{
|
||||||
|
"url": "https://git.elab.kth.se/davide/ELAB-partsearch",
|
||||||
|
"path": "/srv/ELAB-partsearch",
|
||||||
|
"deploy": "echo Deploying and restarting ELAB-partsearch && git reset --hard && git pull && sudo /usr/local/sbin/restart_partsearch.sh",
|
||||||
|
"secret-token": "etaeZee5eedie7sah8shaigo"
|
||||||
|
}]
|
||||||
|
}
|
||||||
|
|
||||||
@@ -0,0 +1,7 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
sudo cp restart_partsearch.sh /usr/local/sbin/
|
||||||
|
cd Git-Auto-Deploy
|
||||||
|
sudo python setup.py install
|
||||||
|
sudo cp /ELAB-partsearch/deploy/git-auto-deploy.service /etc/systemd/system
|
||||||
|
sudo systemctl enable git-auto-deploy.service
|
||||||
|
sudo systemctl start git-auto-deploy.service
|
||||||
@@ -0,0 +1,11 @@
|
|||||||
|
[Unit]
|
||||||
|
Description=GitAutoDeploy
|
||||||
|
|
||||||
|
[Service]
|
||||||
|
User=www-data
|
||||||
|
Group=www-data
|
||||||
|
WorkingDirectory=/srv/ELAB-partsearch/deploy/Git-Auto-Deploy/
|
||||||
|
ExecStart=/usr/bin/python -m /srv/ELAB-partsearch/deploy/Git-Auto-Deploy/gitautodeploy --daemon-mode --config /srv/ELAB-partsearch/deploy/GitAutoDeploy.config.json
|
||||||
|
|
||||||
|
[Install]
|
||||||
|
WantedBy=multi-user.target
|
||||||
@@ -0,0 +1,2 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
sudo supervisorctl restart partsearch
|
||||||
|
After Width: | Height: | Size: 42 KiB |
|
Before Width: | Height: | Size: 688 KiB After Width: | Height: | Size: 220 KiB |
|
Before Width: | Height: | Size: 165 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: 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 |
|
After Width: | Height: | Size: 15 KiB |
|
After Width: | Height: | Size: 15 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,83 +1,232 @@
|
|||||||
import os
|
import os
|
||||||
import re
|
import re
|
||||||
import json
|
import json
|
||||||
|
import requests
|
||||||
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, jsonify
|
||||||
from PIL import Image, ImageDraw
|
from PIL import Image, ImageDraw
|
||||||
from io import BytesIO
|
from io import BytesIO
|
||||||
|
from os import listdir
|
||||||
|
from os.path import isfile, join
|
||||||
from werkzeug.utils import secure_filename
|
from werkzeug.utils import secure_filename
|
||||||
|
import random
|
||||||
|
|
||||||
app = Flask(__name__)
|
app = Flask(__name__)
|
||||||
|
|
||||||
db_engine = {}
|
db_engine = {}
|
||||||
db_metadata = {}
|
db_metadata = {}
|
||||||
parts = {}
|
parts = {}
|
||||||
|
octopartURL =""
|
||||||
|
baseURL = "/parts"
|
||||||
|
|
||||||
|
taglines = []
|
||||||
|
with open('taglines.txt', 'r') as infile:
|
||||||
|
for line in infile:
|
||||||
|
taglines.append(line[:-1])
|
||||||
|
|
||||||
|
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()
|
||||||
|
with db_engine.connect() as conn:
|
||||||
|
r = conn.execute(text(query))
|
||||||
|
containers = r.mappings().all()
|
||||||
|
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) #SQLalchemy 1.x
|
||||||
admin_list = json.load(admin)
|
with db_engine.connect() as conn:
|
||||||
for user in admin_list:
|
r = conn.execute(text(query))
|
||||||
if username == user['username']:
|
results = r.mappings().all()
|
||||||
return password == user['password']
|
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()
|
||||||
img.save(img_io, 'PNG')
|
img.convert("RGB").save(img_io, 'PNG')
|
||||||
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(baseURL, strict_slashes=True)
|
||||||
def index():
|
def index():
|
||||||
return render_template('partsearch.html')
|
return render_template('partsearch.html', containers=getContainers(), baseURL=baseURL, tagline=random.choice(taglines))
|
||||||
|
|
||||||
@app.route('/parts/getlocations/')
|
@app.route(baseURL+'/getlocationsInContainer/<containerID>')
|
||||||
def get_locations():
|
def get_locations_in_container(containerID):
|
||||||
s = 'select id, name from locations order by name;'
|
s = 'select id, name from locations where container_id = :id order by name;'
|
||||||
r = db_engine.execute(text(s))
|
# r = db_engine.execute(text(s), id=containerID)
|
||||||
l = {}
|
# l={}
|
||||||
for row in r:
|
# for row in r:
|
||||||
l[row[0]]=row[1]
|
# l[str(row[0])]= row[1];
|
||||||
r.close()
|
# r.close()
|
||||||
return json.dumps(l)
|
# return json.dumps(l)
|
||||||
|
with db_engine.connect() as conn:
|
||||||
|
r = conn.execute(text(s), {"id": containerID})
|
||||||
|
l = {str(row.id): row.name for row in r}
|
||||||
|
|
||||||
@app.route('/parts/getlocationURL/<locationID>')
|
return jsonify(l)
|
||||||
|
@app.route(baseURL+'/getlocationURL/<locationID>')
|
||||||
def get_locationURL(locationID):
|
def get_locationURL(locationID):
|
||||||
s = 'select map from locations where id = :id;'
|
s = 'select map from locations where id = :id;'
|
||||||
r = db_engine.execute(text(s), id=locationID)
|
# r = db_engine.execute(text(s), id=locationID)
|
||||||
l=[];
|
# l=[];
|
||||||
for row in r:
|
# for row in r:
|
||||||
l.append(row);
|
# l.append(row);
|
||||||
r.close()
|
# r.close()
|
||||||
return l[0][0]
|
# return l[0][0]
|
||||||
|
with db_engine.connect() as conn:
|
||||||
|
result = conn.execute(text(s), {"id": locationID}).fetchone()
|
||||||
|
|
||||||
@app.route('/parts/getpartinfo/<partID>')
|
if result is None:
|
||||||
|
return ""
|
||||||
|
|
||||||
|
return result[0]
|
||||||
|
|
||||||
|
@app.route(baseURL+'/locationEditor')
|
||||||
|
def locationEditor():
|
||||||
|
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))
|
||||||
|
# locations = []
|
||||||
|
# for row in r:
|
||||||
|
# locations.append(dict(row))
|
||||||
|
# r.close()
|
||||||
|
# return render_template('locationEditor.html', locations=locations, containers=getContainers(),baseURL=baseURL)
|
||||||
|
|
||||||
|
with db_engine.connect() as conn:
|
||||||
|
result = conn.execute(text(query))
|
||||||
|
locations = [dict(row._mapping) for row in result]
|
||||||
|
|
||||||
|
return render_template(
|
||||||
|
'locationEditor.html',
|
||||||
|
locations=locations,
|
||||||
|
containers=getContainers(),
|
||||||
|
baseURL=baseURL
|
||||||
|
)
|
||||||
|
@app.route(baseURL+'/userEditor')
|
||||||
|
def userEditor():
|
||||||
|
query = 'select id, username from users;'
|
||||||
|
|
||||||
|
# r = db_engine.execute(text(query))
|
||||||
|
# users = []
|
||||||
|
# for row in r:
|
||||||
|
# users.append(dict(row))
|
||||||
|
# r.close()
|
||||||
|
with db_engine.connect() as conn:
|
||||||
|
result = conn.execute(text(query))
|
||||||
|
users = [dict(row._mapping) for row in result]
|
||||||
|
|
||||||
|
return render_template('userEditor.html', users=users, containers=getContainers(),baseURL=baseURL)
|
||||||
|
|
||||||
|
@app.route(baseURL + '/alterLocation/<locationID>', methods=['POST'])
|
||||||
|
@requires_auth
|
||||||
|
def alterLocation(locationID):
|
||||||
|
locationID = int(locationID)
|
||||||
|
|
||||||
|
if locationID < 0:
|
||||||
|
# New entry
|
||||||
|
query = text("""
|
||||||
|
insert into locations (name, container_id)
|
||||||
|
values (:name, :container)
|
||||||
|
""")
|
||||||
|
|
||||||
|
with db_engine.begin() as conn:
|
||||||
|
conn.execute(query, {
|
||||||
|
"name": request.form['name'],
|
||||||
|
"container": request.form['container']
|
||||||
|
})
|
||||||
|
|
||||||
|
return jsonify(status="ok")
|
||||||
|
|
||||||
|
else:
|
||||||
|
# Modify entry
|
||||||
|
query = text("""
|
||||||
|
update locations
|
||||||
|
set name=:name,
|
||||||
|
container_id=:container
|
||||||
|
where id=:locationID
|
||||||
|
""")
|
||||||
|
|
||||||
|
with db_engine.begin() as conn:
|
||||||
|
conn.execute(query, {
|
||||||
|
"name": request.form['name'],
|
||||||
|
"container": request.form['container'],
|
||||||
|
"locationID": locationID
|
||||||
|
})
|
||||||
|
|
||||||
|
return jsonify(status="ok")
|
||||||
|
|
||||||
|
@app.route(baseURL + '/alterUser/<userID>', methods=['POST'])
|
||||||
|
@requires_auth
|
||||||
|
def alterUser(userID):
|
||||||
|
userID = int(userID)
|
||||||
|
|
||||||
|
if userID < 0:
|
||||||
|
# New entry
|
||||||
|
query = text("""
|
||||||
|
insert into users (username, password)
|
||||||
|
values (:name, :password)
|
||||||
|
""")
|
||||||
|
|
||||||
|
with db_engine.begin() as conn:
|
||||||
|
conn.execute(query, {
|
||||||
|
"name": request.form['name'],
|
||||||
|
"password": request.form['password']
|
||||||
|
})
|
||||||
|
|
||||||
|
return jsonify(status="ok")
|
||||||
|
|
||||||
|
else:
|
||||||
|
# Modify entry
|
||||||
|
query = text("""
|
||||||
|
update users
|
||||||
|
set username=:name, password=:password
|
||||||
|
where id=:userID
|
||||||
|
""")
|
||||||
|
|
||||||
|
with db_engine.begin() as conn:
|
||||||
|
conn.execute(query, {
|
||||||
|
"name": request.form['name'],
|
||||||
|
"password": request.form['password'],
|
||||||
|
"userID": userID
|
||||||
|
})
|
||||||
|
|
||||||
|
return jsonify(status="ok")
|
||||||
|
@app.route(baseURL+'/getpartinfo/<partID>')
|
||||||
def get_part_info(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,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)
|
with db_engine.connect() as conn:
|
||||||
l = []
|
result = conn.execute(text(s), {"id": partID})
|
||||||
for row in r:
|
row = result.mappings().first()
|
||||||
l.append(dict(row))
|
|
||||||
r.close()
|
|
||||||
return json.dumps(l[0])
|
|
||||||
|
|
||||||
@app.route('/parts/query/<filter_dummy>/<query>') # TODO: maybe change AND to OR or maybe not
|
return jsonify(dict(row) if row else {})
|
||||||
|
@app.route(baseURL+'/query/<filter_dummy>/<query>') # TODO: maybe change AND to OR or maybe not
|
||||||
def query(filter_dummy, query):
|
def query(filter_dummy, query):
|
||||||
filter = request.args.to_dict()
|
filter = request.args.to_dict()
|
||||||
keywords = query.split() # Default splits with spaces
|
keywords = query.split() # Default splits with spaces
|
||||||
@@ -87,127 +236,218 @@ def query(filter_dummy, query):
|
|||||||
for i in range(len(keywords)):
|
for i in range(len(keywords)):
|
||||||
kw_dict["kw" + str(i)] = keywords[i]
|
kw_dict["kw" + str(i)] = keywords[i]
|
||||||
|
|
||||||
s = 'select p.id,partno,description,l.name as location_descriptor from parts as p inner join locations as l on p.location_id = l.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(c.name||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)
|
||||||
l = []
|
# l = []
|
||||||
for row in r:
|
# for row in r:
|
||||||
l.append(dict(row))
|
# l.append(dict(row))
|
||||||
r.close()
|
# r.close()
|
||||||
|
with db_engine.connect() as conn:
|
||||||
|
l = [dict(row) for row in conn.execute(text(s), kw_dict).mappings()]
|
||||||
return json.dumps(l)
|
return json.dumps(l)
|
||||||
|
|
||||||
@app.route('/parts/map/<mapurl>')
|
@app.route(baseURL+'/map/<containerID>')
|
||||||
def getMap(mapurl):
|
@app.route(baseURL+'/map/<containerID>/<annotate>')
|
||||||
|
def getMap(containerID, annotate=None):
|
||||||
|
s = 'select map, overlay from containers where id = :id;'
|
||||||
|
with db_engine.connect() as conn:
|
||||||
|
row = conn.execute(text(s), {"id": containerID}).mappings().first()
|
||||||
|
mapFile = row['map']
|
||||||
|
overlayFile = row['overlay']
|
||||||
try:
|
try:
|
||||||
mapimage = Image.open('maps/' + mapurl)
|
mapImage = Image.open('maps/' + mapFile).convert("RGBA")
|
||||||
|
overlayImage = Image.open('maps/overlays/' + overlayFile).convert("RGBA")
|
||||||
except FileNotFoundError:
|
except FileNotFoundError:
|
||||||
return serveImage(Image.open("maps/404.png"))
|
return serveImage(Image.open("maps/404.png"))
|
||||||
if request.args.get('x') is not None and request.args.get('y') is not None:
|
# if request.args.get('x') is not None and request.args.get('y') is not None:
|
||||||
x = int(request.args.get('x'))
|
# x = int(request.args.get('x'))
|
||||||
y = int(request.args.get('y'))
|
# y = int(request.args.get('y'))
|
||||||
pointer = Image.open('maps/here.png')
|
# pointer = Image.open('maps/here.png')
|
||||||
pointerLayer = Image.new("RGBA", mapimage.size)
|
# pointerLayer = Image.new("RGBA", mapimage.size)
|
||||||
width, height = pointer.size
|
# width, height = pointer.size
|
||||||
pointerLayer.paste(pointer, (x - int(width/2), y-int(height/2)))
|
# pointerLayer.paste(pointer, (x - int(width/2), y-int(height/2)))
|
||||||
mapimage = Image.alpha_composite(mapimage, pointerLayer)
|
mapimage = Image.alpha_composite(mapImage, overlayImage)
|
||||||
|
if annotate=='a':
|
||||||
|
try:
|
||||||
|
annotationName = mapFile.split('.')[0] + '-annotated.' + mapFile.split('.')[1]
|
||||||
|
annotationImage = Image.open('maps/' + annotationName).convert("RGBA")
|
||||||
|
mapimage = Image.alpha_composite(mapimage, annotationImage)
|
||||||
|
except FileNotFoundError:
|
||||||
|
pass
|
||||||
return serveImage(mapimage)
|
return serveImage(mapimage)
|
||||||
|
|
||||||
|
|
||||||
@app.route('/parts/getfile/<filename>')
|
@app.route(baseURL+'/getfile/<filename>')
|
||||||
def getfile(filename):
|
def getfile(filename):
|
||||||
if(re.match('^[\w\-_]+$', filename) == None):
|
# if(re.match('^[\w\-_]+.[p|P][d|D][f|F]$', filename) == None):
|
||||||
|
if(re.match(r'^[\w-]+\.pdf$', filename, re.IGNORECASE) == None):
|
||||||
return 'No injections pls.'
|
return 'No injections pls.'
|
||||||
|
|
||||||
return send_from_directory('/srv/datasheets/', filename + '.pdf')
|
return send_from_directory('/srv/datasheets/', filename)
|
||||||
|
|
||||||
@app.route('/parts/alter/<partID>', methods=['POST'])
|
@app.route(baseURL + '/alter/<partID>', methods=['POST'])
|
||||||
# @requires_auth
|
@requires_auth
|
||||||
def alter(partID):
|
def alter(partID):
|
||||||
partID = int(partID)
|
partID = int(partID)
|
||||||
s = ''
|
|
||||||
if partID < 0:
|
# -------------------------
|
||||||
# New entry
|
# HANDLE FILE UPLOAD
|
||||||
s = 'insert into parts (partno, description, datasheet, location_id) '
|
# -------------------------
|
||||||
s += 'values (:partno, :description, :datasheet, :location_id);'
|
if len(request.files) != 0:
|
||||||
s = text(s)
|
datasheet_file = request.files['datasheet-file']
|
||||||
if len(request.files) != 0:
|
datasheet_filename = secure_filename(datasheet_file.filename)
|
||||||
datasheet_file = request.files['datasheet-file']
|
|
||||||
datasheet_filename = secure_filename(datasheet_file.filename)
|
i = 1
|
||||||
i = 1
|
while os.path.isfile('/srv/datasheets/' + datasheet_filename):
|
||||||
while os.path.isfile('srv/datasheet/' + 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)
|
||||||
else:
|
datasheet_filename = 'http://elab.kth.se/parts/getfile/' + datasheet_filename
|
||||||
datasheet_filename = None
|
|
||||||
r = db_engine.execute(s, partno=request.form['partno'],
|
|
||||||
description=request.form['description'],
|
|
||||||
datasheet=datasheet_filename,
|
|
||||||
location_id=request.form['location_id'])
|
|
||||||
else:
|
else:
|
||||||
# Modify entry
|
try:
|
||||||
r = db_engine.execute(text('select * from parts where id=:id;'), id=partID)
|
datasheet_filename = request.form['datasheet-url']
|
||||||
l = []
|
except:
|
||||||
for row in r:
|
datasheet_filename = None
|
||||||
l.append(dict(row))
|
|
||||||
r.close()
|
|
||||||
s = 'update parts '
|
|
||||||
s += 'set partno=:partno, description=:description, datasheet=:datasheet, location_id=:location_id '
|
|
||||||
if len(request.files) != 0:
|
|
||||||
datasheet_file = request.files['datasheet-file']
|
|
||||||
datasheet_filename = secure_filename(datasheet_file.filename)
|
|
||||||
i = 1
|
|
||||||
while os.path.isfile('srv/datasheet/' + datasheet_filename):
|
|
||||||
datasheet_filename = datasheet_filename[:-4] + str(i) + '.pdf'
|
|
||||||
i += 1
|
|
||||||
datasheet_file.save('/srv/datasheets/' + datasheet_filename)
|
|
||||||
if l[0]['datasheet'] != None:
|
|
||||||
os.remove('/srv/datasheets/' + l[0]['datasheet'])
|
|
||||||
else:
|
|
||||||
datasheet_filename = l[0]['datasheet']
|
|
||||||
s += 'where id=:id;'
|
|
||||||
s = text(s)
|
|
||||||
r = db_engine.execute(s, partno=request.form['partno'],
|
|
||||||
description=request.form['description'],
|
|
||||||
datasheet=datasheet_filename,
|
|
||||||
location_id=request.form['location_id'])
|
|
||||||
|
|
||||||
|
# -------------------------
|
||||||
|
# INSERT
|
||||||
|
# -------------------------
|
||||||
|
if partID < 0:
|
||||||
|
query = text("""
|
||||||
|
insert into parts
|
||||||
|
(partno, description, datasheet, location_id, whoadded, notes)
|
||||||
|
values
|
||||||
|
(:partno, :description, :datasheet, :location_id, :user_id, :notes)
|
||||||
|
returning id
|
||||||
|
""")
|
||||||
|
|
||||||
return '{"status":"ok"}'
|
with db_engine.begin() as conn:
|
||||||
|
result = conn.execute(query, {
|
||||||
|
"partno": request.form['partno'],
|
||||||
|
"description": request.form['description'],
|
||||||
|
"datasheet": datasheet_filename,
|
||||||
|
"location_id": request.form['location_id'],
|
||||||
|
"notes": request.form['notes'],
|
||||||
|
"user_id": session['uid']
|
||||||
|
})
|
||||||
|
|
||||||
@app.route('/parts/delete/<partID>')
|
new_id = result.mappings().first()["id"]
|
||||||
|
|
||||||
|
return jsonify(status="ok", part_id=new_id)
|
||||||
|
|
||||||
|
# -------------------------
|
||||||
|
# UPDATE
|
||||||
|
# -------------------------
|
||||||
|
else:
|
||||||
|
query = text("""
|
||||||
|
update parts
|
||||||
|
set partno=:partno,
|
||||||
|
description=:description,
|
||||||
|
datasheet=:datasheet,
|
||||||
|
location_id=:location_id,
|
||||||
|
notes=:notes
|
||||||
|
where id=:id
|
||||||
|
returning id
|
||||||
|
""")
|
||||||
|
|
||||||
|
with db_engine.begin() as conn:
|
||||||
|
result = conn.execute(query, {
|
||||||
|
"partno": request.form['partno'],
|
||||||
|
"description": request.form['description'],
|
||||||
|
"datasheet": datasheet_filename,
|
||||||
|
"location_id": request.form['location_id'],
|
||||||
|
"notes": request.form['notes'],
|
||||||
|
"id": partID
|
||||||
|
})
|
||||||
|
|
||||||
|
new_id = result.mappings().first()["id"]
|
||||||
|
|
||||||
|
return jsonify(status="ok", part_id=new_id)
|
||||||
|
@app.route(baseURL + '/delete/<partID>')
|
||||||
@requires_auth
|
@requires_auth
|
||||||
def delete(partID):
|
def delete(partID):
|
||||||
|
partID = int(partID)
|
||||||
if partID < 0:
|
if partID < 0:
|
||||||
abort(400)
|
abort(400)
|
||||||
s = text('delete from parts where id=:id;')
|
|
||||||
r = db_engine.execute(s, id=partID)
|
query = text('delete from parts where id=:id')
|
||||||
return '{"status":"ok"}'
|
|
||||||
|
with db_engine.begin() as conn:
|
||||||
|
conn.execute(query, {"id": partID})
|
||||||
|
|
||||||
|
return jsonify(status="ok")
|
||||||
|
|
||||||
|
|
||||||
|
@app.route(baseURL + '/deleteLocation/<locationID>')
|
||||||
|
@requires_auth
|
||||||
|
def deleteLocation(locationID):
|
||||||
|
locationID = int(locationID)
|
||||||
|
if locationID < 0:
|
||||||
|
abort(400)
|
||||||
|
|
||||||
|
query = text('delete from locations where id=:id')
|
||||||
|
|
||||||
|
with db_engine.begin() as conn:
|
||||||
|
conn.execute(query, {"id": locationID})
|
||||||
|
|
||||||
|
return jsonify(status="ok")
|
||||||
|
|
||||||
|
|
||||||
|
@app.route(baseURL + '/deleteUser/<userID>')
|
||||||
|
@requires_auth
|
||||||
|
def deleteUser(userID):
|
||||||
|
userID = int(userID)
|
||||||
|
if userID < 0:
|
||||||
|
abort(400)
|
||||||
|
|
||||||
|
query = text('delete from users where id=:id')
|
||||||
|
|
||||||
|
with db_engine.begin() as conn:
|
||||||
|
conn.execute(query, {"id": userID})
|
||||||
|
|
||||||
|
return jsonify(status="ok")
|
||||||
|
|
||||||
|
@app.route(baseURL+'/fetchOctopartSnippet/<searchTerm>')
|
||||||
|
def fetchOctopartSnippet(searchTerm):
|
||||||
|
if octopartURL == '':
|
||||||
|
return '{"result":"octopart integration not enabled"}'
|
||||||
|
args = {
|
||||||
|
'q': searchTerm,
|
||||||
|
'start': '0',
|
||||||
|
'limit': 1
|
||||||
|
}
|
||||||
|
data = requests.get(octopartURL, params=args)
|
||||||
|
search_response = json.loads(data.text)
|
||||||
|
|
||||||
|
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'''
|
||||||
@@ -219,17 +459,31 @@ def connect(user, password, db, host='localhost', port=5432):
|
|||||||
con = sqlalchemy.create_engine(url, client_encoding='utf8')
|
con = sqlalchemy.create_engine(url, client_encoding='utf8')
|
||||||
|
|
||||||
# We then bind the connection to MetaData()
|
# We then bind the connection to MetaData()
|
||||||
meta = sqlalchemy.MetaData(bind=con, reflect=True)
|
meta = sqlalchemy.MetaData()
|
||||||
|
meta.reflect(con)
|
||||||
|
|
||||||
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_v3')
|
||||||
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'] != '':
|
||||||
|
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):
|
with db_engine.connect() as conn:
|
||||||
print row'''
|
r = conn.execute(text(query))
|
||||||
app.run('0.0.0.0')
|
'''
|
||||||
|
app.run(host='127.0.0.1', port='5000', debug=False)
|
||||||
|
|||||||
|
After Width: | Height: | Size: 14 KiB |
@@ -0,0 +1,18 @@
|
|||||||
|
var rootURL = '/parts/'
|
||||||
|
|
||||||
|
function overlay_in() {
|
||||||
|
$('.shadow').show();
|
||||||
|
$('.overlay').show();
|
||||||
|
$('.shadow').animate({'opacity' : 0.7});
|
||||||
|
$('.overlay').animate({'opacity' : 1.0, 'top' : '5%'});
|
||||||
|
}
|
||||||
|
|
||||||
|
function overlay_out() {
|
||||||
|
$('.shadow').animate({'opacity' : 0.0}, function () {
|
||||||
|
$('.shadow').hide();
|
||||||
|
});
|
||||||
|
$('.overlay').animate({'opacity' : 0.0, 'top' : '0'}, function () {
|
||||||
|
$('.overlay').hide();
|
||||||
|
});
|
||||||
|
end_edit();
|
||||||
|
}
|
||||||
@@ -0,0 +1,126 @@
|
|||||||
|
function new_location_entry() {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
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();
|
||||||
|
}
|
||||||
|
|
||||||
|
function update_map() {
|
||||||
|
var selected_map_file = $('#container-input').val();
|
||||||
|
$('#map').attr('src', 'map/' + selected_map_file);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
function saveLocation(locationID) {
|
||||||
|
var container_v = $('#container-input').val();
|
||||||
|
var name_v = $('#location-name-input').val();
|
||||||
|
|
||||||
|
if(name_v.length > 100) {
|
||||||
|
alert('Name too long (max 100 characters).')
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
var data = new FormData();
|
||||||
|
|
||||||
|
data.append('container', container_v);
|
||||||
|
data.append('name', name_v)
|
||||||
|
|
||||||
|
$.ajax({
|
||||||
|
url: rootURL + 'alterLocation/' + locationID,
|
||||||
|
type: 'POST',
|
||||||
|
data: data,
|
||||||
|
cache: false,
|
||||||
|
contentType: false,
|
||||||
|
processData: false,
|
||||||
|
success: function(data) {
|
||||||
|
alert("k.");
|
||||||
|
},
|
||||||
|
error: function() {
|
||||||
|
alert("Couldn't update the part information. Please retry.");
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
end_edit();
|
||||||
|
$('#edit-button').click(function() {
|
||||||
|
init_edit(partID);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
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){
|
||||||
|
//temporarily not used
|
||||||
|
var $img = $('#clickablemap');
|
||||||
|
var currentClickPosX = event.pageX - $img.offset().left;
|
||||||
|
var currentClickPosY = event.pageY - $img.offset().top;
|
||||||
|
|
||||||
|
var correctX = (($img.prop('naturalWidth') / $img.width()) * currentClickPosX).toFixed(0);
|
||||||
|
var correctY = (($img.prop('naturalHeight') / $img.height()) * currentClickPosY).toFixed(0);
|
||||||
|
|
||||||
|
// $("#mapURL").html("elab.png?x=" + correctX + "&y=" + correctY);
|
||||||
|
$("#clickablemap").attr("src", "map/" + $("#mapfile-input").val() + "?x=" + correctX + "&y=" + correctY);
|
||||||
|
}
|
||||||
@@ -1,129 +1,134 @@
|
|||||||
function overlay_in() {
|
var active_timer = 100;
|
||||||
$('.shadow').css({'display' : 'block'});
|
|
||||||
$('.overlay').css({'display' : 'block'});
|
|
||||||
$('.shadow').animate({'opacity' : 0.7});
|
|
||||||
$('.overlay').animate({'opacity' : 1.0, 'top' : '5%'});
|
|
||||||
}
|
|
||||||
|
|
||||||
function overlay_out() {
|
|
||||||
$('.shadow').animate({'opacity' : 0.0}, function () {
|
|
||||||
$('.overlay').css({'display' : 'none'});
|
|
||||||
});
|
|
||||||
$('.overlay').animate({'opacity' : 0.0, 'top' : '0'}, function () {
|
|
||||||
$('.shadow').css({'display' : 'none'});
|
|
||||||
});
|
|
||||||
end_edit();
|
|
||||||
}
|
|
||||||
|
|
||||||
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();
|
||||||
|
|
||||||
var datasheet_input = $('<input type="file" class="part-edit-file" id="datasheet-input" accept=".pdf">')
|
$('#duplicate-button').closest('div').hide();
|
||||||
$('#datasheet-info').replaceWith(datasheet_input);
|
$('#delete-button').closest('div').hide();
|
||||||
|
|
||||||
var newButton = '<div class="round-button-left"><a href="#" onclick="save(' + partID + ')"><i class="fa fa-check" aria-hidden="true"></i></a></div>';
|
$('tr#datasheet').show();
|
||||||
$('.round-button-left').replaceWith(newButton);
|
|
||||||
|
$('input[name=notes-input]').show();
|
||||||
|
$('table#details tr#notes td p').hide();
|
||||||
|
|
||||||
|
// make map have names of containers for this one click
|
||||||
|
if (!$('img#map').attr('src').endsWith('/a')){
|
||||||
|
$('img#map').attr('src', $('img#map').attr('src') + '/a')
|
||||||
|
}
|
||||||
|
|
||||||
|
// 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);
|
||||||
|
$('#edit-button').html('<i class="fa fa-check" aria-hidden="true"></i>');
|
||||||
|
$('#edit-button').off('click').on('click', function(){
|
||||||
|
save(partID);
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
function new_entry() {
|
function new_entry() {
|
||||||
$('table#details tr#location td p').text('');
|
$('table#details tr#location td p').text('');
|
||||||
$('table#details tr#partno td p').text('');
|
$('table#details tr#partno td p').text('');
|
||||||
$('table#details tr#description td p').text('');
|
$('table#details tr#description td p').text('');
|
||||||
// $('table#details tr#location select').text('');
|
$('table#details tr#partno td input').val('');
|
||||||
$('table#details tr#partno td input').text('');
|
$('table#details tr#description td input').val('');
|
||||||
$('table#details tr#description td input').text('');
|
$('input[name=datasheet-url-input]').val('');
|
||||||
init_edit(-1);
|
init_edit(-1);
|
||||||
overlay_in();
|
overlay_in();
|
||||||
|
container_onchange();
|
||||||
|
|
||||||
|
// make map have names of containers for this one click
|
||||||
|
if (!$('img#map').attr('src').endsWith('/a')){
|
||||||
|
$('img#map').attr('src', $('img#map').attr('src') + '/a')
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function end_edit() {
|
function end_edit() {
|
||||||
$('table#details tr#location td p').show();
|
|
||||||
$('table#details tr#location td select').hide();
|
|
||||||
|
|
||||||
|
$('table#details tr#location td p').text($('table#details tr#location td select option:checked').text());
|
||||||
|
$('table#details tr#location td p').show();
|
||||||
|
$('#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').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').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();
|
||||||
|
|
||||||
var newButton = '<div class="round-button-left"><a href="#" id="edit-button"><i class="fa fa-pencil" aria-hidden="true"></i></a></div>';
|
$('input[name=notes-input]').hide();
|
||||||
$('.round-button-left').replaceWith(newButton);
|
$('table#details tr#notes td p').show();
|
||||||
|
|
||||||
|
$('#duplicate-button').closest('div').show();
|
||||||
|
$('#delete-button').closest('div').show();
|
||||||
|
|
||||||
|
$('#edit-button').html('<i class="fa fa-pencil" aria-hidden="true"></i>');
|
||||||
|
// var newButton = '<div class="round-button-left"><a href="#" id="edit-button"><i class="fa fa-pencil" aria-hidden="true"></i></a></div>';
|
||||||
|
// $('.round-button-left').replaceWith(newButton);
|
||||||
}
|
}
|
||||||
|
|
||||||
function save(partID) {
|
function save(partID) {
|
||||||
// var block_v = $('#block-input').val();
|
if (!$('#location-dropdown').val() || $('#location-dropdown').val()== -1 ) {
|
||||||
// var type_v = $('#type-input').val();
|
alert('Please select a location.');
|
||||||
var location_id_v = $('table#details tr#location td select').val();
|
return;
|
||||||
var partno_v = $('table#details tr#partno td input').val();
|
}
|
||||||
var description_v = $('table#details tr#description td input').val();
|
var location_id_v = $('#location-dropdown').val();
|
||||||
// var quantity_v = $('#quantity-input').val();
|
var partno_v = $('input[name=partno-input]').val();
|
||||||
// var notes_v = $('#notes-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;
|
||||||
// if(! partno_v.match(/^([a-zA-Z0-9]{1,20}\s*){1,3}$/g)) {
|
var datasheet_url_v = $('input[name=datasheet-url-input]').val();
|
||||||
// alert('Invalid part number format. Accepted: <Part-number-line-1(max 20 chars)> <Part-number-line-2(max 20 chars)> <Part-number-line-3(max 20 chars)>');
|
var notes_v = $('input[name=notes-input]').val();
|
||||||
// return;
|
if(partno_v.length == 0){
|
||||||
// }
|
alert('Please enter a part number.');
|
||||||
// if(! block_v.match(/^[0-9]+$/g)) {
|
return;
|
||||||
// alert('Invalid location field. Only numbers accepted.');
|
}
|
||||||
// return;
|
if(description_v.length > 200) {
|
||||||
// }
|
alert('Description too long (max 200 characters).');
|
||||||
// if(type_v.length > 25) {
|
return;
|
||||||
// alert('Manufacturer name too long (max 25 characters).')
|
}
|
||||||
// return;
|
if(description_v.length == 0) {
|
||||||
// }
|
alert('Please enter a description.');
|
||||||
if(description_v.length > 200) {
|
|
||||||
alert('Description too long (max 200 characters).')
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
// if(quantity_v.length > 10) {
|
|
||||||
// alert('Quantity info too long (max 10 characters).')
|
|
||||||
// return;
|
|
||||||
// }
|
|
||||||
// if(notes_v.length > 200) {
|
|
||||||
// alert('Notes too long (max 200 characters).')
|
|
||||||
// return;
|
|
||||||
// }
|
|
||||||
|
|
||||||
// var partnos = partno_v.split(' ');
|
|
||||||
|
|
||||||
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]);
|
||||||
// data.append('block', block_v);
|
} else if (datasheet_url_v.length > 0) {
|
||||||
// data.append('type', type_v);
|
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);
|
||||||
// if (partnos.length > 1)
|
|
||||||
// data.append('partnoalt', partnos[1]);
|
|
||||||
// else
|
|
||||||
// data.append('partnoalt', '');
|
|
||||||
// if(partnos.length > 2)
|
|
||||||
// data.append('partnoalt2', partnos[2]);
|
|
||||||
// else
|
|
||||||
// data.append('partnoalt2', '');
|
|
||||||
data.append('description', description_v);
|
data.append('description', description_v);
|
||||||
// data.append('quantity', quantity_v);
|
data.append('notes', notes_v);
|
||||||
// data.append('notes', notes_v);
|
|
||||||
|
|
||||||
$.ajax({
|
$.ajax({
|
||||||
// Your server script to process the upload
|
// Your server script to process the upload
|
||||||
url: 'http://127.0.0.1:5000/parts/alter/' + partID,
|
url: rootURL + 'alter/' + partID,
|
||||||
type: 'POST',
|
type: 'POST',
|
||||||
|
|
||||||
data: data,
|
data: data,
|
||||||
@@ -135,7 +140,10 @@ function save(partID) {
|
|||||||
processData: false,
|
processData: false,
|
||||||
success: function(data) {
|
success: function(data) {
|
||||||
var datasheet_par = '<p id="datasheet-info"><i class="fa fa-check"></i></p>';
|
var datasheet_par = '<p id="datasheet-info"><i class="fa fa-check"></i></p>';
|
||||||
$('#datasheet-info').replaceWith(datasheet_par);
|
$('#datasheet-info').replaceWith(datasheet_par); // Fix addressing
|
||||||
|
$('#edit-button').click(function() {
|
||||||
|
init_edit(JSON.parse(data).part_id);
|
||||||
|
});
|
||||||
},
|
},
|
||||||
error: function() {
|
error: function() {
|
||||||
alert("Couldn't update the part information. Please retry.");
|
alert("Couldn't update the part information. Please retry.");
|
||||||
@@ -144,9 +152,7 @@ function save(partID) {
|
|||||||
});
|
});
|
||||||
|
|
||||||
end_edit();
|
end_edit();
|
||||||
$('#edit-button').click(function() {
|
perform_query();
|
||||||
init_edit(partID);
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function text_filter(string) {
|
function text_filter(string) {
|
||||||
@@ -162,7 +168,7 @@ function delete_entry(partID) {
|
|||||||
if (!confirm('Delete the selected entry?'))
|
if (!confirm('Delete the selected entry?'))
|
||||||
return;
|
return;
|
||||||
$.ajax({
|
$.ajax({
|
||||||
url: 'http://127.0.0.1:5000/parts/delete/' + partID,
|
url: rootURL + 'delete/' + partID,
|
||||||
type: 'GET',
|
type: 'GET',
|
||||||
cache: false,
|
cache: false,
|
||||||
contentType: false,
|
contentType: false,
|
||||||
@@ -178,42 +184,75 @@ function delete_entry(partID) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function show_part_info(partID) {
|
function show_part_info(partID) {
|
||||||
$.getJSON('http://127.0.0.1:5000/parts/getpartinfo/' + partID, function(data) {
|
$.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
|
$('#container-dropdown').val(data.container_id);
|
||||||
|
$('img#map').attr('src', 'parts/map/' + data.container_id);
|
||||||
|
$('#location-dropdown').empty();
|
||||||
|
$.getJSON('parts/getlocationsInContainer/' + data.container_id, function(json) {
|
||||||
|
$.each(json, function(loc_id, loc_name) {
|
||||||
|
$('#location-dropdown').append('<option value="' + loc_id + '">' + loc_name + '</option>');
|
||||||
|
});
|
||||||
|
$('#location-dropdown').val(data.location_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.map);
|
$('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="http://127.0.0.1:5000/parts/getfile/' + data.datasheet.substring(0, data.datasheet.length - 4) + '"><i class="fa fa-file-text" aria-hidden="true"></i></a></td>'));
|
// Resetting file input. Super dirty hack. Disgusting
|
||||||
else
|
var $el = $('#datasheet-finput');
|
||||||
|
$el.wrap('<form>').closest('form').get(0).reset();
|
||||||
|
$el.unwrap();
|
||||||
|
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 {
|
||||||
$('tr#datasheet-head td').text('DATASHEET: ');
|
$('tr#datasheet-head td').text('DATASHEET: ');
|
||||||
$('#edit-button').click(function() {
|
$('input[name=datasheet-url-input]').val('');
|
||||||
|
}
|
||||||
|
$('#edit-button').off('click').on('click', function() {
|
||||||
init_edit(partID);
|
init_edit(partID);
|
||||||
});
|
});
|
||||||
$('#delete-button').click(function() {
|
$('#delete-button').off('click').on('click', function() {
|
||||||
delete_entry(partID);
|
delete_entry(partID);
|
||||||
});
|
});
|
||||||
overlay_in();
|
overlay_in();
|
||||||
}).fail(function() {
|
}).fail(function() {
|
||||||
console.log( "Fetching part info failed" );
|
console.log( "Fetching part info failed" );
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// update URL and history
|
||||||
|
update_url(partID);
|
||||||
|
}
|
||||||
|
|
||||||
|
function update_url(partID){
|
||||||
|
params = {}
|
||||||
|
// If there is a seach bar, take its content
|
||||||
|
if($('.search-bar').length){
|
||||||
|
params['q'] = $('.search-bar').val();
|
||||||
|
}
|
||||||
|
if(partID != 0){
|
||||||
|
params['p'] = partID
|
||||||
|
}
|
||||||
|
window.history.pushState('searching', '', 'parts?' + jQuery.param(params));
|
||||||
}
|
}
|
||||||
|
|
||||||
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';
|
||||||
$.getJSON('http://127.0.0.1:5000/parts/query/' + filter + '/' + query, data, function(data) {
|
$("#results").find("tr:not(:first)").remove(); // Delete all table rows
|
||||||
$("#results").find("tr:not(:first)").remove(); // Delete all table rows
|
$.getJSON(rootURL + 'query/' + filter + '/' + query, data, function(data) {
|
||||||
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>');
|
||||||
|
|
||||||
@@ -223,61 +262,74 @@ 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" );
|
||||||
});
|
});
|
||||||
|
|
||||||
|
update_url(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
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(){
|
||||||
|
// $('#magic-autofill-button').attr('disabled', 'disabled');
|
||||||
|
// $.getJSON(rootURL + 'fetchOctopartSnippet/' + $('#partno-input').val()).done(function(json){
|
||||||
|
// $('#magic-autofill-button').removeAttr('disabled');
|
||||||
|
// if (json['result']=='ok'){
|
||||||
|
// $('#description-input').val(json['snippet']);
|
||||||
|
// }else{
|
||||||
|
// $('#description-input').val('');
|
||||||
|
// $('#description-input').attr('placeholder', json['result']);
|
||||||
|
// }
|
||||||
|
// }).fail(function() {
|
||||||
|
// $('#magic-autofill-button').removeAttr('disabled');
|
||||||
|
// });
|
||||||
|
// }
|
||||||
|
|
||||||
$(document).ready(function() {
|
$(document).ready(function() {
|
||||||
$.getJSON('parts/getlocations', function(data){
|
|
||||||
$.each(data, function(i, val) {
|
|
||||||
$('table#details tr#location td select').append('<option value="' + i + '">' + val + '</option>');
|
|
||||||
});
|
|
||||||
});
|
|
||||||
$.ajaxSetup({ cache: false });
|
$.ajaxSetup({ cache: false });
|
||||||
$('.search-bar').on('keyup', function() {
|
$('.search-bar').on('keyup', function() {
|
||||||
perform_query();
|
clearTimeout(active_timer);
|
||||||
|
active_timer = setTimeout(perform_query, 100);
|
||||||
});
|
});
|
||||||
$('.checkbox').change( function() {
|
$('.checkbox').change( 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();
|
||||||
});
|
});
|
||||||
});
|
|
||||||
|
//For linking to a search query or specific part
|
||||||
|
const search_params = new URLSearchParams(window.location.search);
|
||||||
|
if(search_params.has('q')){
|
||||||
|
$('.search-bar').val(search_params.get('q')); perform_query();
|
||||||
|
}
|
||||||
|
if(search_params.has('p')){
|
||||||
|
show_part_info(search_params.get('p'));
|
||||||
|
}
|
||||||
|
|
||||||
$(document).ready(function() {
|
// $('#partno-input').bind('blur',function() {
|
||||||
$("#clickablemap").on("click", function(event) {
|
// if($('#partno-input').val().length > 0){
|
||||||
var $img = $(this);
|
// octopartFetch();
|
||||||
var currentClickPosX = event.pageX - $img.offset().left;
|
// }
|
||||||
var currentClickPosY = event.pageY - $img.offset().top;
|
// });
|
||||||
|
|
||||||
var currentWidth = $img.width();
|
|
||||||
var currentHeight = $img.height();
|
|
||||||
|
|
||||||
var naturalWidth = this.naturalWidth;
|
|
||||||
var naturalHeight = this.naturalHeight;
|
|
||||||
|
|
||||||
var correctX = ((naturalWidth / currentWidth) * currentClickPosX).toFixed(0);
|
|
||||||
var correctY = ((naturalHeight / currentHeight) * currentClickPosY).toFixed(0);
|
|
||||||
|
|
||||||
$("#mapURL").html("elab.png?x=" + correctX + "&y=" + correctY);
|
|
||||||
$("#clickablemap").attr("src", "http://127.0.0.1:5000/parts/map/elab.png?x=" + correctX + "&y=" + correctY);
|
|
||||||
});
|
|
||||||
});
|
});
|
||||||
@@ -0,0 +1,223 @@
|
|||||||
|
html {
|
||||||
|
background-color: #D7E2E2;
|
||||||
|
color: #000F0F;
|
||||||
|
font-family: 'Roboto', sans-serif;
|
||||||
|
text-align: center;
|
||||||
|
}
|
||||||
|
|
||||||
|
body {
|
||||||
|
margin: 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
h1 {
|
||||||
|
padding: 16px;
|
||||||
|
margin: 0;
|
||||||
|
color: #D7E2E2;
|
||||||
|
background-color: #013A3A;
|
||||||
|
font-size: 150%;
|
||||||
|
}
|
||||||
|
|
||||||
|
h3 {
|
||||||
|
color: #5E9292;
|
||||||
|
text-align: center;
|
||||||
|
padding: 12pt;
|
||||||
|
font-size: x-large;
|
||||||
|
opacity: 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
p {
|
||||||
|
font-size: 0.6em;
|
||||||
|
}
|
||||||
|
|
||||||
|
input[type=text].search-bar {
|
||||||
|
color: #404040;
|
||||||
|
padding: 6px;
|
||||||
|
margin-top: 16px;
|
||||||
|
margin-bottom: 4px;
|
||||||
|
width: 90%;
|
||||||
|
font-size: 1.2em;
|
||||||
|
}
|
||||||
|
|
||||||
|
.filter-container p {
|
||||||
|
display: none;
|
||||||
|
}
|
||||||
|
|
||||||
|
.filter-container {
|
||||||
|
background-color: #226666;
|
||||||
|
width: 90%;
|
||||||
|
display: inline-block;
|
||||||
|
border: 1px #226666 solid;
|
||||||
|
}
|
||||||
|
|
||||||
|
.filter-container ul {
|
||||||
|
display: flex;
|
||||||
|
justify-content: stretch;
|
||||||
|
list-style: none;
|
||||||
|
margin: 0;
|
||||||
|
padding: 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
.filter-container li {
|
||||||
|
flex: 1;
|
||||||
|
font-size: 0.8em;
|
||||||
|
}
|
||||||
|
|
||||||
|
input[type=checkbox]{
|
||||||
|
display: none;
|
||||||
|
}
|
||||||
|
|
||||||
|
input[type=checkbox] + label.toggle-btn {
|
||||||
|
padding:6px 0 6px 0;
|
||||||
|
display: block;
|
||||||
|
color: rgba(94,146,146, 0.5);
|
||||||
|
background-color: #D7E2E2;
|
||||||
|
transition: 0.2s;
|
||||||
|
-webkit-transition: 0.2s;
|
||||||
|
}
|
||||||
|
|
||||||
|
input[type=checkbox]:checked + label.toggle-btn {
|
||||||
|
color: #D7E2E2;
|
||||||
|
background-color: #226666;
|
||||||
|
}
|
||||||
|
|
||||||
|
.round-floating-button {
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
justify-content: center;
|
||||||
|
position: fixed;
|
||||||
|
bottom: 20px;
|
||||||
|
right: 20px;
|
||||||
|
width: 56px;
|
||||||
|
height: 56px;
|
||||||
|
border-radius: 28px;
|
||||||
|
background-color: #5E9292;
|
||||||
|
font-size: 32px;
|
||||||
|
box-shadow: 2pt 1pt 8pt black;
|
||||||
|
}
|
||||||
|
|
||||||
|
.round-floating-button a{
|
||||||
|
color: #D7E2E2;
|
||||||
|
}
|
||||||
|
|
||||||
|
#results {
|
||||||
|
width:100%;
|
||||||
|
margin-top: 1em;
|
||||||
|
border-collapse: collapse;
|
||||||
|
/*table-layout: fixed;*/
|
||||||
|
}
|
||||||
|
|
||||||
|
#results th {
|
||||||
|
background-color: #226666;
|
||||||
|
color: #D7E2E2;
|
||||||
|
padding: 4px 0 4px 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
#results th#location {
|
||||||
|
width: 20%;
|
||||||
|
}
|
||||||
|
#results th#partno {
|
||||||
|
width: 30%;
|
||||||
|
}
|
||||||
|
|
||||||
|
#results td {
|
||||||
|
/*overflow: hidden;
|
||||||
|
white-space: nowrap;*/
|
||||||
|
padding: 5px 0 5px 0;
|
||||||
|
font-size: 0.7em;
|
||||||
|
text-align: left;
|
||||||
|
}
|
||||||
|
|
||||||
|
#results tr:nth-child(odd) {
|
||||||
|
background-color: #5E9292;
|
||||||
|
}
|
||||||
|
|
||||||
|
.shadow {
|
||||||
|
background-color: black;
|
||||||
|
display: none;
|
||||||
|
height: 100%;
|
||||||
|
left: 0;
|
||||||
|
opacity: 0.0;
|
||||||
|
position: fixed;
|
||||||
|
top: 0;
|
||||||
|
width: 100%;
|
||||||
|
z-index: 200;
|
||||||
|
}
|
||||||
|
|
||||||
|
.overlay {
|
||||||
|
opacity: 0.0;
|
||||||
|
display: none;
|
||||||
|
background-color: #226666;
|
||||||
|
color: #D7E2E2;
|
||||||
|
width: 90%;
|
||||||
|
position: absolute;
|
||||||
|
margin:auto;
|
||||||
|
left:0;
|
||||||
|
right:0;
|
||||||
|
top:0;
|
||||||
|
z-index: 201;
|
||||||
|
}
|
||||||
|
|
||||||
|
h2 {
|
||||||
|
background-color: #013A3A;
|
||||||
|
padding: 8px 0 8px 0;
|
||||||
|
margin-top: 0;
|
||||||
|
font-size: 1.2em;
|
||||||
|
}
|
||||||
|
|
||||||
|
#details {
|
||||||
|
width: 100%;
|
||||||
|
margin: 16px 0 16px 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
.details-header {
|
||||||
|
color: #013A3A;
|
||||||
|
}
|
||||||
|
|
||||||
|
.details-content td p{
|
||||||
|
font-size: 1em;
|
||||||
|
margin: 0 0 1em 0;
|
||||||
|
padding: 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
.button-container {
|
||||||
|
display: flex;
|
||||||
|
justify-content: space-evenly;
|
||||||
|
margin-bottom: 16px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.round-button {
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
justify-content: center;
|
||||||
|
width: 56px;
|
||||||
|
height: 56px;
|
||||||
|
border-radius: 28pt;
|
||||||
|
background-color: #5E9292;
|
||||||
|
font-size: 32px;
|
||||||
|
box-shadow: 2pt 1pt 8pt black;
|
||||||
|
}
|
||||||
|
|
||||||
|
.round-button a {
|
||||||
|
color: #D7E2E2;
|
||||||
|
}
|
||||||
|
|
||||||
|
#map {
|
||||||
|
width: 90%;
|
||||||
|
}
|
||||||
|
|
||||||
|
.small-square-button {
|
||||||
|
position: absolute;
|
||||||
|
top: 5px;
|
||||||
|
right: 10px;
|
||||||
|
font-size: 24px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.small-square-button a {
|
||||||
|
color: #D7E2E2;
|
||||||
|
}
|
||||||
|
|
||||||
|
.pinfo-input {
|
||||||
|
width: 90%;
|
||||||
|
padding: 4px;
|
||||||
|
display: none;
|
||||||
|
}
|
||||||
@@ -2,6 +2,8 @@ html {
|
|||||||
background-color: #D7E2E2;
|
background-color: #D7E2E2;
|
||||||
color: #000F0F;
|
color: #000F0F;
|
||||||
font-family: 'Roboto', sans-serif;
|
font-family: 'Roboto', sans-serif;
|
||||||
|
overflow-y: scroll;
|
||||||
|
text-align: center;
|
||||||
}
|
}
|
||||||
|
|
||||||
body {
|
body {
|
||||||
@@ -9,7 +11,7 @@ body {
|
|||||||
}
|
}
|
||||||
|
|
||||||
h1 {
|
h1 {
|
||||||
padding: 16pt;
|
padding: 16px;
|
||||||
margin: 0 0 20pt 0;
|
margin: 0 0 20pt 0;
|
||||||
text-align: center;
|
text-align: center;
|
||||||
color: #D7E2E2;
|
color: #D7E2E2;
|
||||||
@@ -26,7 +28,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,40 +42,40 @@ a {
|
|||||||
|
|
||||||
input[type=text].search-bar {
|
input[type=text].search-bar {
|
||||||
color: #404040;
|
color: #404040;
|
||||||
font-size: 20pt;
|
font-size: 1.6em;
|
||||||
padding: 5pt 8pt 5pt 8pt;
|
padding: 5pt 8pt 5pt 8pt;
|
||||||
margin-top: 8pt;
|
margin-top: 8pt;
|
||||||
margin-bottom: 8pt;
|
margin-bottom: 8pt;
|
||||||
margin-left: 20pt;
|
margin-left: 20pt;
|
||||||
width: 70%;
|
width: 70%;
|
||||||
border: 2pt solid grey;
|
border: 1px solid grey;
|
||||||
border-radius: 5pt;
|
|
||||||
}
|
|
||||||
|
|
||||||
.search-bar-container {
|
|
||||||
text-align: center;
|
|
||||||
}
|
|
||||||
|
|
||||||
.filter-container {
|
|
||||||
background-color: #226666;
|
|
||||||
padding: 10pt 15pt 10pt 15pt;
|
|
||||||
margin-top: 10pt;
|
|
||||||
margin-bottom: 10pt;
|
|
||||||
border-radius: 2pt;
|
|
||||||
display: inline-block;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
.filter-container p {
|
.filter-container p {
|
||||||
text-align: left;
|
text-align: left;
|
||||||
color: #D7E2E2;
|
font-size: 10px;
|
||||||
font-size: 10pt;
|
margin: 2px;
|
||||||
margin-top: 4pt;
|
|
||||||
margin-left: 16pt;
|
|
||||||
margin-bottom: 4pt;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
.filter-concontainertainer {
|
.filter-container {
|
||||||
text-align: center;
|
width: 30%;
|
||||||
|
display: inline-block;
|
||||||
|
border: 1px #226666 solid;
|
||||||
|
color: #D7E2E2;
|
||||||
|
background-color: #226666;
|
||||||
|
}
|
||||||
|
|
||||||
|
.filter-container ul {
|
||||||
|
display: flex;
|
||||||
|
justify-content: stretch;
|
||||||
|
list-style: none;
|
||||||
|
margin: 0;
|
||||||
|
padding: 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
.filter-container li {
|
||||||
|
flex: 1;
|
||||||
|
font-size: 0.8em;
|
||||||
}
|
}
|
||||||
|
|
||||||
input[type=checkbox]{
|
input[type=checkbox]{
|
||||||
@@ -81,69 +83,17 @@ input[type=checkbox]{
|
|||||||
}
|
}
|
||||||
|
|
||||||
input[type=checkbox] + label.toggle-btn {
|
input[type=checkbox] + label.toggle-btn {
|
||||||
border-radius: 3pt;
|
padding:10px 0 10px 0;
|
||||||
display: inline-block;
|
display: block;
|
||||||
padding: 5pt;
|
color: rgba(94,146,146, 0.5);
|
||||||
color: #D7E2E2;
|
background-color: #D7E2E2;
|
||||||
margin-top: 6pt;
|
|
||||||
margin-bottom: 6pt;
|
|
||||||
margin-left: 3pt;
|
|
||||||
margin-right: 3pt;
|
|
||||||
width: 100pt;
|
|
||||||
text-align: center;
|
|
||||||
border: 1pt solid #D7E2E2;
|
|
||||||
transition: 0.2s;
|
transition: 0.2s;
|
||||||
-webkit-transition: 0.2s;
|
-webkit-transition: 0.2s;
|
||||||
}
|
}
|
||||||
|
|
||||||
input[type=checkbox]:checked + label.toggle-btn {
|
input[type=checkbox]:checked + label.toggle-btn {
|
||||||
background-color: #D7E2E2;
|
color: #D7E2E2;
|
||||||
color: #000F0F;
|
background-color: #226666;
|
||||||
}
|
|
||||||
|
|
||||||
div label input {
|
|
||||||
margin-right:100px;
|
|
||||||
}
|
|
||||||
|
|
||||||
.tooltip {
|
|
||||||
position: relative;
|
|
||||||
display: inline-block;
|
|
||||||
}
|
|
||||||
|
|
||||||
.tooltip .tooltiptext {
|
|
||||||
font-size: 10pt;
|
|
||||||
visibility: hidden;
|
|
||||||
width: 120px;
|
|
||||||
background-color: black;
|
|
||||||
color: #fff;
|
|
||||||
text-align: center;
|
|
||||||
border-radius: 6px;
|
|
||||||
padding: 5px 0;
|
|
||||||
position: absolute;
|
|
||||||
z-index: 1;
|
|
||||||
top: -5px;
|
|
||||||
right: 105%;
|
|
||||||
margin-left: -60px;
|
|
||||||
|
|
||||||
/* Fade in tooltip - takes 1 second to go from 0% to 100% opac: */
|
|
||||||
opacity: 0;
|
|
||||||
transition: opacity 0.2s;
|
|
||||||
}
|
|
||||||
|
|
||||||
.tooltip:hover .tooltiptext {
|
|
||||||
visibility: visible;
|
|
||||||
opacity: 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
.tooltip .tooltiptext::after {
|
|
||||||
content: " ";
|
|
||||||
position: absolute;
|
|
||||||
top: 50%;
|
|
||||||
left: 100%; /* To the right of the tooltip */
|
|
||||||
margin-top: -5px;
|
|
||||||
border-width: 5px;
|
|
||||||
border-style: solid;
|
|
||||||
border-color: transparent transparent transparent black;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
.shadow {
|
.shadow {
|
||||||
@@ -152,7 +102,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,59 +113,28 @@ 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;
|
display: flex;
|
||||||
bottom: 15pt;
|
align-items: center;
|
||||||
left: calc(15% - 20pt);
|
justify-content: center;
|
||||||
width: 40pt;
|
width: 56px;
|
||||||
height: 32pt;
|
height: 56px;
|
||||||
border-radius: 20pt;
|
border-radius: 28px;
|
||||||
|
font-size: 32px;
|
||||||
background-color: #5E9292;
|
background-color: #5E9292;
|
||||||
font-size: 20pt;
|
|
||||||
padding-top: 8pt;
|
|
||||||
box-shadow: 2pt 1pt 8pt black;
|
|
||||||
}
|
|
||||||
|
|
||||||
.round-button-left {
|
|
||||||
position: absolute;
|
|
||||||
bottom: 15pt;
|
|
||||||
left: calc(30% - 20pt);
|
|
||||||
width: 40pt;
|
|
||||||
height: 32pt;
|
|
||||||
border-radius: 20pt;
|
|
||||||
background-color: #5E9292;
|
|
||||||
font-size: 20pt;
|
|
||||||
padding-top: 8pt;
|
|
||||||
box-shadow: 2pt 1pt 8pt black;
|
box-shadow: 2pt 1pt 8pt black;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -223,16 +142,11 @@ div label input {
|
|||||||
color: #D7E2E2;
|
color: #D7E2E2;
|
||||||
}
|
}
|
||||||
|
|
||||||
.round-button-left a{
|
|
||||||
color: #D7E2E2;
|
|
||||||
}
|
|
||||||
|
|
||||||
.small-square-button {
|
.small-square-button {
|
||||||
position: absolute;
|
position: absolute;
|
||||||
top: 5pt;
|
top: 5px;
|
||||||
right: 5pt;
|
right: 10px;
|
||||||
padding-right: 5pt;
|
font-size: 40px;
|
||||||
font-size: 16pt;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
.small-square-button a {
|
.small-square-button a {
|
||||||
@@ -240,17 +154,18 @@ div label input {
|
|||||||
}
|
}
|
||||||
|
|
||||||
.round-floating-button {
|
.round-floating-button {
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
justify-content: center;
|
||||||
position: fixed;
|
position: fixed;
|
||||||
bottom: 15pt;
|
bottom: 20px;
|
||||||
right: 15pt;
|
right: 20px;
|
||||||
width: 40pt;
|
width: 56px;
|
||||||
height: 32pt;
|
height: 56px;
|
||||||
border-radius: 20pt;
|
border-radius: 28px;
|
||||||
|
font-size: 32px;
|
||||||
background-color: #5E9292;
|
background-color: #5E9292;
|
||||||
font-size: 22pt;
|
|
||||||
padding-top: 8pt;
|
|
||||||
box-shadow: 2pt 1pt 8pt black;
|
box-shadow: 2pt 1pt 8pt black;
|
||||||
text-align: center;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
.round-floating-button a{
|
.round-floating-button a{
|
||||||
@@ -261,110 +176,78 @@ div label input {
|
|||||||
font-size: 12pt;
|
font-size: 12pt;
|
||||||
}
|
}
|
||||||
|
|
||||||
.bottom-spacer {
|
#results {
|
||||||
height: 80pt;
|
|
||||||
}
|
|
||||||
|
|
||||||
table#results {
|
|
||||||
width: 100%;
|
width: 100%;
|
||||||
|
max-width: 1280px;
|
||||||
|
margin-left: auto;
|
||||||
|
margin-right: auto;
|
||||||
border-collapse: collapse;
|
border-collapse: collapse;
|
||||||
|
margin-top: 1em;
|
||||||
}
|
}
|
||||||
|
|
||||||
table#results th {
|
#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;
|
||||||
}
|
}
|
||||||
|
|
||||||
table#results tr:nth-child(odd) {
|
#results tr:nth-child(odd) {
|
||||||
background-color: #5E9292;
|
background-color: #5E9292;
|
||||||
}
|
}
|
||||||
|
|
||||||
table#results td {
|
#results td {
|
||||||
padding: 4pt;
|
padding: 4pt;
|
||||||
cursor: pointer;
|
cursor: pointer;
|
||||||
|
text-align: left;
|
||||||
}
|
}
|
||||||
|
|
||||||
table#results #location {
|
#results #location {
|
||||||
width: 15%;
|
width: 18%;
|
||||||
}
|
}
|
||||||
|
|
||||||
table#results #partno {
|
#results #partno {
|
||||||
/*width: 20%;*/
|
/*width: 20%;*/
|
||||||
}
|
}
|
||||||
|
|
||||||
table#results #description {
|
#results #description {
|
||||||
width: 70%;
|
width: 70%;
|
||||||
}
|
}
|
||||||
|
|
||||||
table#results #docs {
|
#results #docs {
|
||||||
width: 5%;
|
width: 5%;
|
||||||
}
|
}
|
||||||
|
|
||||||
table#details {
|
#info-container {
|
||||||
position: absolute;
|
width: 35%;
|
||||||
left: 0;
|
height: 85%;
|
||||||
width: 45%;
|
display: flex;
|
||||||
margin-top: 4%;
|
flex-direction:column;
|
||||||
|
justify-content:space-between;
|
||||||
}
|
}
|
||||||
|
|
||||||
table#details #location-head {
|
#details {
|
||||||
height: 10%;
|
width: 100%;
|
||||||
|
}
|
||||||
|
|
||||||
|
#magical_autofill{
|
||||||
|
font-size: small;
|
||||||
|
}
|
||||||
|
|
||||||
|
a.small_link{
|
||||||
|
text-decoration: none;
|
||||||
|
color: #B0B0B0;
|
||||||
|
font-weight: 600;
|
||||||
|
}
|
||||||
|
|
||||||
|
.details-header {
|
||||||
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 {
|
||||||
@@ -372,15 +255,24 @@ td p {
|
|||||||
padding: 0;
|
padding: 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
.overlay img#map {
|
.button-container {
|
||||||
|
display: flex;
|
||||||
|
justify-content: space-evenly;
|
||||||
|
}
|
||||||
|
|
||||||
|
.map {
|
||||||
position: absolute;
|
position: absolute;
|
||||||
right: 5%;
|
right: 5%;
|
||||||
bottom: 5%;
|
/*margin-top: 4%;*/
|
||||||
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;
|
||||||
}
|
}
|
||||||
@@ -0,0 +1,118 @@
|
|||||||
|
function new_user_entry() {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
function init_User_edit(userID, name) {
|
||||||
|
$('#save-button').attr("onclick", "saveUser(" + userID + ")");
|
||||||
|
$('#delete-button').attr("onclick", "deleteUser(" + userID + ")");
|
||||||
|
$('#user-name-input').val(name);
|
||||||
|
$('#user-password-input').val('');
|
||||||
|
overlay_in();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
function saveUser(userID) {
|
||||||
|
var name_v = $('#user-name-input').val();
|
||||||
|
var password_v = $('#user-password-input').val();
|
||||||
|
|
||||||
|
if(name_v.length > 100) {
|
||||||
|
alert('Name too long (max 100 characters).')
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
var data = new FormData();
|
||||||
|
|
||||||
|
data.append('password', password_v);
|
||||||
|
data.append('name', name_v)
|
||||||
|
|
||||||
|
$.ajax({
|
||||||
|
url: rootURL + 'alterUser/' + userID,
|
||||||
|
type: 'POST',
|
||||||
|
data: data,
|
||||||
|
cache: false,
|
||||||
|
contentType: false,
|
||||||
|
processData: false,
|
||||||
|
success: function(data) {
|
||||||
|
alert("k.");
|
||||||
|
},
|
||||||
|
error: function() {
|
||||||
|
alert("Couldn't update the user information. Please retry.");
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
end_edit();
|
||||||
|
$('#edit-button').click(function() {
|
||||||
|
init_edit(userID);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
function deleteUser(userID) {
|
||||||
|
if (userID < 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 user? ')){
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
$.ajax({
|
||||||
|
url: rootURL + 'deleteUser/' + userID,
|
||||||
|
type: 'GET',
|
||||||
|
cache: false,
|
||||||
|
contentType: false,
|
||||||
|
processData: false,
|
||||||
|
success: function() {
|
||||||
|
alert("User removed.");
|
||||||
|
overlay_out();
|
||||||
|
location.reload();
|
||||||
|
},
|
||||||
|
fail: function() {
|
||||||
|
console.log('An error occurred while deleting the entry');
|
||||||
|
},
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
function end_edit(){
|
||||||
|
//intentionally left blank
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
function show_user_info(userID) {
|
||||||
|
$.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){
|
||||||
|
//temporarily not used
|
||||||
|
var $img = $('#clickablemap');
|
||||||
|
var currentClickPosX = event.pageX - $img.offset().left;
|
||||||
|
var currentClickPosY = event.pageY - $img.offset().top;
|
||||||
|
|
||||||
|
var correctX = (($img.prop('naturalWidth') / $img.width()) * currentClickPosX).toFixed(0);
|
||||||
|
var correctY = (($img.prop('naturalHeight') / $img.height()) * currentClickPosY).toFixed(0);
|
||||||
|
|
||||||
|
// $("#mapURL").html("elab.png?x=" + correctX + "&y=" + correctY);
|
||||||
|
$("#clickablemap").attr("src", "map/" + $("#mapfile-input").val() + "?x=" + correctX + "&y=" + correctY);
|
||||||
|
}
|
||||||
@@ -0,0 +1,32 @@
|
|||||||
|
Looking for obsolete ICs that were discontinued years ago? Just start typing!
|
||||||
|
Looking for obsolete ICs that were discontinued years ago? Just start typing!
|
||||||
|
Looking for obsolete ICs that were discontinued years ago? Just start typing!
|
||||||
|
Looking for obsolete ICs that were discontinued years ago? Just start typing!
|
||||||
|
Looking for obsolete ICs that were discontinued years ago? Just start typing!
|
||||||
|
Start typing to find your part
|
||||||
|
Start typing to find your part
|
||||||
|
Start typing to find your part
|
||||||
|
Start typing to find your part
|
||||||
|
Start typing to find your part
|
||||||
|
Try typing "mosfet"
|
||||||
|
Try typing "arduino"
|
||||||
|
Try typing "led driver"
|
||||||
|
Try typing "resistor"
|
||||||
|
Try typing "regulator"
|
||||||
|
Try typing "led"
|
||||||
|
Try typing "78L05"
|
||||||
|
Try typing "drv8833"
|
||||||
|
Try typing "stm32"
|
||||||
|
Try typing "logic analyzer"
|
||||||
|
Try typing "programmer"
|
||||||
|
Try typing "connector"
|
||||||
|
Try typing "motor"
|
||||||
|
Try typing "spring"
|
||||||
|
Try typing "usb"
|
||||||
|
Try typing "Flux capacitor". We don't have one, but you can try.
|
||||||
|
You can also search for tools
|
||||||
|
Now with emoji support!
|
||||||
|
I know it's here somwhere!
|
||||||
|
For every part you find, there is 1000 you won't!
|
||||||
|
'); DROP TABLE parts;--
|
||||||
|
Help! I'm trapped in a tagline randomiser!
|
||||||
@@ -0,0 +1,65 @@
|
|||||||
|
<!DOCTYPE html>
|
||||||
|
<html>
|
||||||
|
<head>
|
||||||
|
<meta charset="utf-8">
|
||||||
|
<title>ELAB Part Search Engine - Location editor</title>
|
||||||
|
<script
|
||||||
|
src="https://code.jquery.com/jquery-3.2.1.min.js"
|
||||||
|
integrity="sha256-hwg4gsxgFZhOsEEamdOYGBf13FyQuiTwlAQgxVSNgt4="
|
||||||
|
crossorigin="anonymous"></script>
|
||||||
|
<link href="https://fonts.googleapis.com/css?family=Roboto:300,400" rel="stylesheet">
|
||||||
|
<link rel="stylesheet" type="text/css" href="{{ baseURL }}/static/style.css">
|
||||||
|
<script src="https://use.fontawesome.com/2fef7be393.js"></script>
|
||||||
|
<script type="text/javascript" src="{{ baseURL }}/static/common.js"></script>
|
||||||
|
<script type="text/javascript" src="{{ baseURL }}/static/locationEditorScript.js"></script>
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<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! <a href=".">back to parts</a></p>
|
||||||
|
<table id="results" class="results-locations">
|
||||||
|
<tr>
|
||||||
|
<th>ID</th>
|
||||||
|
<th>c.ID</th>
|
||||||
|
<th>Container name</th>
|
||||||
|
<th>Location name</th>
|
||||||
|
</tr>
|
||||||
|
{% for location in locations %}
|
||||||
|
<tr onclick="init_Location_edit({{location['id']}}, '{{location['name']}}', {{location['container_id']}});">
|
||||||
|
<td>{{location['id']}}</td>
|
||||||
|
<td>{{location['container_id']}}</td>
|
||||||
|
<td>{{location['container']}}</td>
|
||||||
|
<td>{{location['name']}}</td>
|
||||||
|
</tr>
|
||||||
|
{% endfor %}
|
||||||
|
</table>
|
||||||
|
<div class="bottom-spacer"></div>
|
||||||
|
|
||||||
|
<div class="shadow" onclick="overlay_out()"></div>
|
||||||
|
<div class="overlay">
|
||||||
|
<h2>Part Details</h2>
|
||||||
|
<table id="details">
|
||||||
|
<tr><td>Adding a new LOCATION inside a given CONTAINER</td></tr>
|
||||||
|
<tr><td>
|
||||||
|
<select class="pinfo-input nothidden" onchange="update_map()" name="mapfile-input" id="container-input">
|
||||||
|
{% for container in containers %}
|
||||||
|
<option value="{{container['id']}}">{{container['name']}}</option>
|
||||||
|
{% endfor %}
|
||||||
|
</select>
|
||||||
|
</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>
|
||||||
|
<img src="map/{{containers[0]['id']}}" id="map" class="map"/>
|
||||||
|
<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="small-square-button"><a href="#" onclick="overlay_out()"><i class="fa fa-times" aria-hidden="true"></i></a></div>
|
||||||
|
</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>
|
||||||
|
</html>
|
||||||
@@ -2,31 +2,33 @@
|
|||||||
<html>
|
<html>
|
||||||
<head>
|
<head>
|
||||||
<meta charset="utf-8">
|
<meta charset="utf-8">
|
||||||
|
<meta name="viewport" content="width=device-width">
|
||||||
<title>ELAB Part Search Engine</title>
|
<title>ELAB Part Search Engine</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="
|
||||||
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="{{ baseURL }}/static/style.css" media="screen and (min-width:500px)">
|
||||||
|
<link rel="stylesheet" type="text/css" href="{{ baseURL }}/static/style-m.css" media="screen and (max-width:500px)">
|
||||||
|
<link rel="apple-touch-icon-precomposed" href="{{ baseURL }}/parts/static/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='script.js') }}"></script>
|
<script type="text/javascript" src="{{ baseURL }}/static/common.js"></script>
|
||||||
|
<script type="text/javascript" src="{{ baseURL }}/static/script.js"></script>
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
<h1>ELAB Part Search Engine</h1>
|
<h1>ELAB Part Search Engine</h1>
|
||||||
<p>Looking for obsolete ICs that were discontinued years ago? Just start typing!</p>
|
<p>{{ tagline }}</p>
|
||||||
<div class="search-bar-container">
|
|
||||||
<input type="text" name="search-bar" class="search-bar" placeholder="Search parts">
|
<input type="text" name="search-bar" class="search-bar" placeholder="Search parts">
|
||||||
</div>
|
|
||||||
<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>
|
<ul>
|
||||||
<input type="checkbox" class="checkbox" id="partno" checked></input><label class="toggle-btn" for="partno">Part Number</label>
|
<li><input type="checkbox" class="checkbox" id="location"><label class="toggle-btn" for="location">Locations<br><i class="fa fa-map" style="font-size:20pt"></i></label></li>
|
||||||
<input type="checkbox" class="checkbox" id="description" checked></input><label class="toggle-btn" for="description">Description</label>
|
<li><input type="checkbox" class="checkbox" id="partno" checked=""><label class="toggle-btn" for="partno">Part Number<br><i class="fa fa-hashtag" style="font-size:20pt"></i></label></li>
|
||||||
<input type="checkbox" class="checkbox" id="notes" checked></input><label class="toggle-btn" for="notes">Notes</label>
|
<li><input type="checkbox" class="checkbox" id="description" checked=""><label class="toggle-btn" for="description">Description<br><i class="fa fa-edit" style="font-size:20pt"></i></label></li>
|
||||||
|
</ul>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
|
||||||
<table id="results">
|
<table id="results">
|
||||||
<tr>
|
<tr>
|
||||||
<th id="location">Location</th>
|
<th id="location">Location</th>
|
||||||
@@ -35,25 +37,44 @@
|
|||||||
</tr>
|
</tr>
|
||||||
</table>
|
</table>
|
||||||
<h3 id="no-results">No results.</h3>
|
<h3 id="no-results">No results.</h3>
|
||||||
<div class="bottom-spacer"></div>
|
<div class="shadow" onclick="overlay_out();update_url(0);"></div>
|
||||||
|
|
||||||
<div class="shadow" onclick="overlay_out()"></div>
|
|
||||||
<div class="overlay">
|
<div class="overlay">
|
||||||
<h2>Part Details</h2>
|
<h2>Part Details</h2>
|
||||||
<table id="details">
|
<div id="info-container">
|
||||||
<tr id="location-head"><td>LOCATION</td></tr>
|
<img src="" id="map" class="map"/>
|
||||||
<tr id="location"><td><p></p><select class="pinfo-input" onchange="update_map()"></select></td></tr>
|
<table id="details">
|
||||||
<tr id="partno-head"><td>PART NUMBER</td></tr>
|
<tr id="location-head" class="details-header"><td>LOCATION</td></tr>
|
||||||
<tr id="partno"><td><p></p><input type="text" name="partno-input" placeholder="Part Number" class="pinfo-input"/></td></tr>
|
<tr id="location" class="details-content"><td><p></p>
|
||||||
<tr id="description-head"><td>DESCRIPTION</td></tr>
|
<select class="pinfo-input" id="container-dropdown" onchange="container_onchange()">
|
||||||
<tr id="description"><td><p></p><input type="text" name="description-input" placeholder="Description" class="pinfo-input"/></td></tr>
|
{% for container in containers %}
|
||||||
<tr id="datasheet-head"><td>DATASHEET: </td></tr>
|
<option value="{{container['id']}}">{{container['name']}}</option>
|
||||||
<tr id="datasheet"><td><input type="file" accept=".pdf" class="pinfo-input"></td></tr>
|
{% endfor %}
|
||||||
</table>
|
</select>
|
||||||
<img src="" id="map"/>
|
<select class="pinfo-input" id="location-dropdown">
|
||||||
<div class="round-button-left"><a href="#" id="edit-button"><i class="fa fa-pencil" aria-hidden="true"></i></a></div>
|
<option value="-1" selected="true">-- Select a container --</option>
|
||||||
<div class="round-button"><a href="#" id="delete-button"><i class="fa fa-trash" aria-hidden="true"></i></a></div>
|
</select>
|
||||||
<div class="small-square-button"><a href="#" onclick="overlay_out()"><i class="fa fa-times" aria-hidden="true"></i></a></div>
|
</td></tr>
|
||||||
|
<tr id="partno-head" class="details-header"><td>PART NUMBER</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" class="details-header"><td>DESCRIPTION</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="magical_autofill" style="display:none"><td><input type="button" id="magic-autofill-button" onclick="octopartFetch()" value="magical auto-fill" style="margin-bottom:6pt"/> powered by <a href="http://octopart.com" class="small_link">OctoPart™</a></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>
|
||||||
|
<tr id="missing" class="details-content"><td><p></p></td></tr>
|
||||||
|
</table>
|
||||||
|
<div class="button-container">
|
||||||
|
<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="edit-button"><i class="fa fa-pencil" aria-hidden="true"></i></a></div>
|
||||||
|
<div class="round-button"><a href="#" id="duplicate-button" onclick="init_edit(-1)"><i class="fa fa-copy" aria-hidden="true"></i></a></div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div>
|
||||||
|
<div class="small-square-button"><a href="#" onclick="overlay_out();update_url(0);"><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>
|
||||||
|
|||||||
@@ -0,0 +1,53 @@
|
|||||||
|
<!DOCTYPE html>
|
||||||
|
<html>
|
||||||
|
<head>
|
||||||
|
<meta charset="utf-8">
|
||||||
|
<title>ELAB Part Search Engine - User editor</title>
|
||||||
|
<script
|
||||||
|
src="https://code.jquery.com/jquery-3.2.1.min.js"
|
||||||
|
integrity="sha256-hwg4gsxgFZhOsEEamdOYGBf13FyQuiTwlAQgxVSNgt4="
|
||||||
|
crossorigin="anonymous"></script>
|
||||||
|
<link href="https://fonts.googleapis.com/css?family=Roboto:300,400" rel="stylesheet">
|
||||||
|
<link rel="stylesheet" type="text/css" href="{{ baseURL }}/static/style.css">
|
||||||
|
<script src="https://use.fontawesome.com/2fef7be393.js"></script>
|
||||||
|
<script type="text/javascript" src="{{ baseURL }}/static/common.js"></script>
|
||||||
|
<script type="text/javascript" src="{{ baseURL }}/static/userEditorScript.js"></script>
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<h1>USER EDITOR</h1>
|
||||||
|
<p>Get in! Get out! Get your fresh users here! <a href=".">back to parts</a></p>
|
||||||
|
<table id="results" class="results-locations">
|
||||||
|
<tr>
|
||||||
|
<th>ID</th>
|
||||||
|
<th>Username</th>
|
||||||
|
</tr>
|
||||||
|
{% for user in users %}
|
||||||
|
<tr onclick="init_User_edit({{user['id']}}, '{{user['username']}}');">
|
||||||
|
<td>{{user['id']}}</td>
|
||||||
|
<td>{{user['username']}}</td>
|
||||||
|
</tr>
|
||||||
|
{% endfor %}
|
||||||
|
</table>
|
||||||
|
<div class="bottom-spacer"></div>
|
||||||
|
|
||||||
|
<div class="shadow" onclick="overlay_out()"></div>
|
||||||
|
<div class="overlay">
|
||||||
|
<h2>User Details</h2>
|
||||||
|
<table id="details">
|
||||||
|
<tr><td>Adding a new user</td></tr>
|
||||||
|
|
||||||
|
<tr><td>Name and password for new user<br />Example: "noob"</td></tr>
|
||||||
|
<tr><td><p></p><input type="text" name="user-name-input" id="user-name-input" placeholder="Name" class="pinfo-input nothidden"/></td></tr>
|
||||||
|
<tr><td><p></p><input type="password" name="user-password-input" id="user-password-input" placeholder="Password" class="pinfo-input nothidden"/></td></tr>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
</table>
|
||||||
|
<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="small-square-button"><a href="#" onclick="overlay_out()"><i class="fa fa-times" aria-hidden="true"></i></a></div>
|
||||||
|
</div>
|
||||||
|
<div class="round-floating-button"><a href="#" onclick="init_User_edit(-1, '', 0)"><i class="fa fa-plus" aria-hidden="true"></i></a></div>
|
||||||
|
</body>
|
||||||
|
</html>
|
||||||
@@ -1,20 +0,0 @@
|
|||||||
<!DOCTYPE html>
|
|
||||||
<html>
|
|
||||||
<head>
|
|
||||||
<meta charset="utf-8">
|
|
||||||
<title>ELAB Part Search Engine</title>
|
|
||||||
<script
|
|
||||||
src="https://code.jquery.com/jquery-3.2.1.min.js"
|
|
||||||
integrity="sha256-hwg4gsxgFZhOsEEamdOYGBf13FyQuiTwlAQgxVSNgt4="
|
|
||||||
crossorigin="anonymous"></script>
|
|
||||||
<link href="https://fonts.googleapis.com/css?family=Roboto:300,400" rel="stylesheet">
|
|
||||||
<link rel="stylesheet" type="text/css" href="static/style.css">
|
|
||||||
<script src="https://use.fontawesome.com/2fef7be393.js"></script>
|
|
||||||
<script type="text/javascript" src="static/script.js"></script>
|
|
||||||
</head>
|
|
||||||
<body>
|
|
||||||
<div id="mapURL">unknown.png</div>
|
|
||||||
<br />
|
|
||||||
<img src="maps/elab.png" id="clickablemap" style="margin-top: 50px; margin-left: 3em; max-height: 830px;"/>
|
|
||||||
</body>
|
|
||||||
</html>
|
|
||||||
|
After Width: | Height: | Size: 49 KiB |
|
After Width: | Height: | Size: 210 KiB |
|
After Width: | Height: | Size: 204 KiB |
@@ -0,0 +1,63 @@
|
|||||||
|
# ELAB Part Search
|
||||||
|
ELABs custom inventory system for locating components.
|
||||||
|
|
||||||
|
## Design and use
|
||||||
|
The system allows searching for parts in ELAB by part name or a description text and returns the location of the part - a drawer or other compartment name and a map illustration. Finding obscure, outdated ICs was never this easy!
|
||||||
|
|
||||||
|
|
||||||
|
##Requirements (Debian-based systems)
|
||||||
|
|
||||||
|
|
||||||
|
$ sudo apt install python3 python3-pip libpq-dev postgresql-13 nginx git
|
||||||
|
|
||||||
|
Python packages:
|
||||||
|
|
||||||
|
* flask
|
||||||
|
* requests
|
||||||
|
* sqlalchemy
|
||||||
|
* werkzeug
|
||||||
|
* pillow
|
||||||
|
* psycopg2
|
||||||
|
|
||||||
|
## Adding a part
|
||||||
|
|
||||||
|
**PREREQUISITE** - In order to add a part to the database, you have to have access credentials.
|
||||||
|
|
||||||
|
### Procedure
|
||||||
|
|
||||||
|
To start adding a part, visit the Elab Part Search main page, then click the Add button.
|
||||||
|
|
||||||
|

|
||||||
|
|
||||||
|
A dialog will appear in which you can input all the relevant information about the part you are adding. The more information you can fill in, the easier will be for the next person to actually find what they are looking for!
|
||||||
|
|
||||||
|
Start by selecting the primary location of where the part will be stored. A map indicating where the selected place is located will appear in the empty space to the right.
|
||||||
|
|
||||||
|

|
||||||
|
|
||||||
|
The second drop-down menu will now be populated with all the sub-location contained in the primary location you have selected. You can now start filling in the rest of the information, following the general guidelines described in the next section.
|
||||||
|
|
||||||
|
When you are done, click the confirm button.
|
||||||
|
|
||||||
|

|
||||||
|
|
||||||
|
If you aren't already logged in, this action will spawn a login prompt. You should need to login only once.
|
||||||
|
|
||||||
|
AND DONE! Congratulations! You have added a part to the database! Only 563945679387340 to go.
|
||||||
|
|
||||||
|
### Part information guidelines
|
||||||
|
|
||||||
|
* The Part Number field should contain the part number (you don't say) of the component. If you don't have a part number, a short description is ok. Example 1: LM358AP. Example 2 (no part number): Rubber feet.
|
||||||
|
* The Description field is meant for a longer description (wow very helpful) for the part, which helps the future user to find this component even if they don't really know what part number they are looking for. It's good to include the part package, its main features, or in general some keyword-style information. Example 1: Op-amp, dual, 30V, 700kHz, 2mV input offset, 8-DIP. Example 2: Rubber feet PCB standoff with adhesive tape.
|
||||||
|
* The *magical auto-fill* button used to fetch a description from octopart.com so you don't have to come up with one. It has been broken since Octopart changed their API. Feel free to fix it! Trust me, it'll be fun!
|
||||||
|
* For the Datasheet, you have the option of either uploading a PDF that you have on your computer, or just pasting a link you found on the internet. If you upload a file, it will be stored on our servers, so that means we will have it even after it gets completely removed from the internet. Pasting a link is quicker, though, so I get it if you do that instead.
|
||||||
|
* The Notes field is for notes.
|
||||||
|
|
||||||
|
### Adding users
|
||||||
|
* go to https://elab.kth.se/parts/userEditor
|
||||||
|
* add the new user with the + thing in the bottom right
|
||||||
|
* Fun fact: any user can add more users. It's like the plague
|
||||||
|
* Fun fact 2: Don't add users manualy via the database pls and tank you.
|
||||||
|
|
||||||
|
## Work in progress
|
||||||
|
The system is currently being worked on. No touchy!
|
||||||