Compare commits
5
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
81409dc448 | ||
|
|
cd224a685b | ||
|
|
6998c7eff2 | ||
|
|
807c136143 | ||
|
|
51022e79bd |
+2
-17
@@ -149,7 +149,7 @@ def alterUser(userID):
|
||||
s = 'insert into users (username, password) '
|
||||
s += 'values (:name, :password);'
|
||||
s = text(s)
|
||||
r = db_engine.execute(s,username=request.form['name'],password=request.form['password']);
|
||||
r = db_engine.execute(s,name=request.form['name'],password=request.form['password']);
|
||||
r.close()
|
||||
return '{"status":"ok"}'
|
||||
else:
|
||||
@@ -164,7 +164,7 @@ def alterUser(userID):
|
||||
|
||||
@app.route(baseURL+'/getpartinfo/<partID>')
|
||||
def get_part_info(partID):
|
||||
s = 'select p.id,partno,description,notes,EXTRACT(EPOCH from now()-reported_missing) as missing_for, c.name || l.name as location_descriptor, location_id, container_id, datasheet from parts as p inner join locations as l on p.location_id = l.id inner join containers as c on l.container_id = c.id where p.id = :id;'
|
||||
s = 'select p.id,partno,description,notes, c.name || l.name as location_descriptor, location_id, container_id, datasheet from parts as p inner join locations as l on p.location_id = l.id inner join containers as c on l.container_id = c.id where p.id = :id;'
|
||||
r = db_engine.execute(text(s), id=partID)
|
||||
l = []
|
||||
for row in r:
|
||||
@@ -316,21 +316,6 @@ def alter(partID):
|
||||
r.close()
|
||||
return '{"status":"ok", "part_id" : ' + str(new_id) + '}'
|
||||
|
||||
@app.route(baseURL+'/report_missing', methods=['POST'])
|
||||
def report_missing():
|
||||
if 'partID' not in request.form:
|
||||
return '{"status":"fail"}'
|
||||
partID = request.form['partID']
|
||||
missing = True if request.form['missing']=='missing' else False #must be "missing" or "found"
|
||||
if missing:
|
||||
r = db_engine.execute(text('update parts set reported_missing = now() where id=:id;'), id=partID)
|
||||
r.close()
|
||||
return '{"status":"ok"}'
|
||||
else:
|
||||
r = db_engine.execute(text('update parts set reported_missing = NULL where id=:id;'), id=partID)
|
||||
r.close()
|
||||
return '{"status":"ok"}'
|
||||
|
||||
@app.route(baseURL+'/delete/<partID>')
|
||||
@requires_auth
|
||||
def delete(partID):
|
||||
|
||||
+14
-30
@@ -145,32 +145,6 @@ function save(partID) {
|
||||
perform_query();
|
||||
}
|
||||
|
||||
function report_missing(partID, missing){
|
||||
var data = new FormData();
|
||||
data.append('partID', partID);
|
||||
if(missing){
|
||||
missing = 'missing'
|
||||
}else{
|
||||
missing = 'found'
|
||||
}
|
||||
data.append('missing', missing)
|
||||
$.ajax({
|
||||
url: rootURL + 'report_missing',
|
||||
type: 'POST',
|
||||
data: data,
|
||||
cache: false,
|
||||
contentType: false,
|
||||
processData: false,
|
||||
success: function(data) {
|
||||
alert("Thank you for reporting part as " + missing + ".");
|
||||
},
|
||||
error: function() {
|
||||
alert("Couldn't update the part information. Please retry.");
|
||||
}
|
||||
|
||||
});
|
||||
}
|
||||
|
||||
function text_filter(string) {
|
||||
if (string != null)
|
||||
return string;
|
||||
@@ -241,8 +215,19 @@ function show_part_info(partID) {
|
||||
});
|
||||
|
||||
// update URL and history
|
||||
var query = $('.search-bar').val();
|
||||
window.history.pushState('searching', '', 'parts?q=' + query + '&p=' + partID)
|
||||
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() {
|
||||
@@ -276,8 +261,7 @@ function perform_query() {
|
||||
console.log( "Query failed" );
|
||||
});
|
||||
|
||||
// update URL and history
|
||||
window.history.pushState('searching', '', 'parts?q=' + query)
|
||||
update_url(0);
|
||||
}
|
||||
|
||||
function container_onchange() {
|
||||
|
||||
@@ -37,7 +37,7 @@
|
||||
</tr>
|
||||
</table>
|
||||
<h3 id="no-results">No results.</h3>
|
||||
<div class="shadow" onclick="overlay_out()"></div>
|
||||
<div class="shadow" onclick="overlay_out();update_url(0);"></div>
|
||||
<div class="overlay">
|
||||
<h2>Part Details</h2>
|
||||
<div id="info-container">
|
||||
@@ -73,7 +73,7 @@
|
||||
</div>
|
||||
</div>
|
||||
<div>
|
||||
<div class="small-square-button"><a href="#" onclick="overlay_out()"><i class="fa fa-times" aria-hidden="true"></i></a></div>
|
||||
<div class="small-square-button"><a href="#" onclick="overlay_out();update_url(0);"><i class="fa fa-times" aria-hidden="true"></i></a></div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="round-floating-button"><a href="#" onclick="new_entry()"><i class="fa fa-plus" aria-hidden="true"></i></a></div>
|
||||
|
||||
Reference in New Issue
Block a user