Merge branch 'master' of https://git.elab.kth.se/davide/ELAB-partsearch
This commit is contained in:
+1
-1
@@ -49,7 +49,7 @@ def index():
|
||||
|
||||
@app.route('/parts/getlocations/')
|
||||
def get_locations():
|
||||
s = 'select id, map from locations'
|
||||
s = 'select id, name from locations'
|
||||
r = db_engine.execute(text(s))
|
||||
l = {}
|
||||
for row in r:
|
||||
|
||||
+75
-48
@@ -2,86 +2,107 @@ function overlay_in() {
|
||||
$('.shadow').css({'display' : 'block'});
|
||||
$('.overlay').css({'display' : 'block'});
|
||||
$('.shadow').animate({'opacity' : 0.7});
|
||||
$('.overlay').animate({'opacity' : 1.0, 'top' : '10%'});
|
||||
$('.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' : '5%'}, function () {
|
||||
$('.overlay').animate({'opacity' : 0.0, 'top' : '0'}, function () {
|
||||
$('.shadow').css({'display' : 'none'});
|
||||
});
|
||||
end_edit();
|
||||
}
|
||||
|
||||
function init_edit(partID) {
|
||||
var block_input = $('<input type="text" class="part-edit-input" id="block-input" placeholder="Location">')
|
||||
block_input.val($('#block-info').text());
|
||||
$('#block-info').replaceWith(block_input);
|
||||
// var block_input = $('<input type="text" class="part-edit-input" id="block-input" placeholder="Location">')
|
||||
// block_input.val($('#block-info').text());
|
||||
// $('#block-info').replaceWith(block_input);
|
||||
|
||||
var type_input = $('<input type="text" class="part-edit-input" id="type-input" placeholder="Manufacturer">')
|
||||
type_input.val($('#type-info').text());
|
||||
$('#type-info').replaceWith(type_input);
|
||||
// var type_input = $('<input type="text" class="part-edit-input" id="type-input" placeholder="Manufacturer">')
|
||||
// type_input.val($('#type-info').text());
|
||||
// $('#type-info').replaceWith(type_input);
|
||||
|
||||
var partno_input = $('<input type="text" class="part-edit-input" id="partno-input" placeholder="Part number">')
|
||||
partno_input.val($('#partno-info').text());
|
||||
$('#partno-info').replaceWith(partno_input);
|
||||
$('table#details tr#location td p').hide();
|
||||
$('table#details tr#location td select').show();
|
||||
|
||||
var description_input = $('<input type="text" class="part-edit-input" id="description-input" placeholder="Description">')
|
||||
description_input.val($('#description-info').text());
|
||||
$('#description-info').replaceWith(description_input);
|
||||
$('table#details tr#partno td p').hide()
|
||||
$('table#details tr#partno td input').show()
|
||||
|
||||
var quantity_input = $('<input type="text" class="part-edit-input" id="quantity-input" placeholder="Quantity">')
|
||||
quantity_input.val($('#quantity-info').text());
|
||||
$('#quantity-info').replaceWith(quantity_input);
|
||||
$('table#details tr#description td p').hide()
|
||||
$('table#details tr#description td input').show()
|
||||
|
||||
var notes_input = $('<input type="text" class="part-edit-input" id="notes-input" placeholder="Notes">')
|
||||
notes_input.val($('#notes-info').text());
|
||||
$('#notes-info').replaceWith(notes_input);
|
||||
// var partno_input = $('<input type="text" class="part-edit-input" id="partno-input" placeholder="Part number">')
|
||||
// partno_input.val($('#partno-info').text());
|
||||
// $('table#details tr#partno td').replaceWith(partno_input);
|
||||
|
||||
// var description_input = $('<input type="text" class="part-edit-input" id="description-input" placeholder="Description">')
|
||||
// description_input.val($('#description-info').text());
|
||||
// $('#description-info').replaceWith(description_input);
|
||||
|
||||
// var quantity_input = $('<input type="text" class="part-edit-input" id="quantity-input" placeholder="Quantity">')
|
||||
// quantity_input.val($('#quantity-info').text());
|
||||
// $('#quantity-info').replaceWith(quantity_input);
|
||||
|
||||
// var notes_input = $('<input type="text" class="part-edit-input" id="notes-input" placeholder="Notes">')
|
||||
// notes_input.val($('#notes-info').text());
|
||||
// $('#notes-info').replaceWith(notes_input);
|
||||
|
||||
var datasheet_input = $('<input type="file" class="part-edit-file" id="datasheet-input" accept=".pdf">')
|
||||
$('#datasheet-info').replaceWith(datasheet_input);
|
||||
|
||||
var newButton = '<div class="round-button"><a href="#" onclick="save(' + partID + ')"><i class="fa fa-check" aria-hidden="true"></i></a></div>';
|
||||
$('.round-button').replaceWith(newButton);
|
||||
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);
|
||||
}
|
||||
|
||||
function new_entry() {
|
||||
$('#block-info').text('');
|
||||
$('#type-info').text('');
|
||||
$('#partno-info').text('');
|
||||
$('#description-info').text('');
|
||||
$('#quantity-info').text('');
|
||||
$('#notes-info').text('');
|
||||
$('table#details tr#location td').text('');
|
||||
$('table#details tr#partno td').text('');
|
||||
$('table#details tr#description td').text('');
|
||||
// $('#block-info').text('');
|
||||
// $('#type-info').text('');
|
||||
// $('#partno-info').text('');
|
||||
// $('#description-info').text('');
|
||||
// $('#quantity-info').text('');
|
||||
// $('#notes-info').text('');
|
||||
init_edit(-1);
|
||||
overlay_in();
|
||||
}
|
||||
|
||||
function end_edit() {
|
||||
var block_par = '<p id="block-info">' + $('#block-input').val() + '</p>';
|
||||
$('#block-input').replaceWith(block_par);
|
||||
$('table#details tr#location td p').show();
|
||||
$('table#details tr#location td select').hide();
|
||||
|
||||
var type_par = '<p id="type-info">' + $('#type-input').val() + '</p>';
|
||||
$('#type-input').replaceWith(type_par);
|
||||
$('table#details tr#partno td p').show()
|
||||
$('table#details tr#partno td input').hide()
|
||||
|
||||
var partno_par = '<p id="partno-info">' + $('#partno-input').val() + '</p>';
|
||||
$('#partno-input').replaceWith(partno_par);
|
||||
$('table#details tr#description td p').show()
|
||||
$('table#details tr#description td input').hide()
|
||||
|
||||
var description_par = '<p id="description-info">' + $('#description-input').val() + '</p>';
|
||||
$('#description-input').replaceWith(description_par);
|
||||
// var block_par = '<p id="block-info">' + $('#block-input').val() + '</p>';
|
||||
// $('#block-input').replaceWith(block_par);
|
||||
|
||||
var quantity_par = '<p id="quantity-info">' + $('#quantity-input').val() + '</p>';
|
||||
$('#quantity-input').replaceWith(quantity_par);
|
||||
// var type_par = '<p id="type-info">' + $('#type-input').val() + '</p>';
|
||||
// $('#type-input').replaceWith(type_par);
|
||||
|
||||
var notes_par = '<p id="notes-info">' + $('#notes-input').val() + '</p>';
|
||||
$('#notes-input').replaceWith(notes_par);
|
||||
// var partno_par = '<p id="partno-info">' + $('#partno-input').val() + '</p>';
|
||||
// $('#partno-input').replaceWith(partno_par);
|
||||
|
||||
var datasheet_par = '<p id="datasheet-info"><i class="fa fa-circle-o-notch fa-spin fa-fw"></i></p>';
|
||||
$('#datasheet-input').replaceWith(datasheet_par);
|
||||
// var description_par = '<p id="description-info">' + $('#description-input').val() + '</p>';
|
||||
// $('#description-input').replaceWith(description_par);
|
||||
|
||||
var newButton = '<div class="round-button"><a href="#" id="edit-button"><i class="fa fa-pencil" aria-hidden="true"></i></a></div>';
|
||||
$('.round-button').replaceWith(newButton);
|
||||
// var quantity_par = '<p id="quantity-info">' + $('#quantity-input').val() + '</p>';
|
||||
// $('#quantity-input').replaceWith(quantity_par);
|
||||
|
||||
// var notes_par = '<p id="notes-info">' + $('#notes-input').val() + '</p>';
|
||||
// $('#notes-input').replaceWith(notes_par);
|
||||
|
||||
// var datasheet_par = '<p id="datasheet-info"><i class="fa fa-circle-o-notch fa-spin fa-fw"></i></p>';
|
||||
// $('#datasheet-input').replaceWith(datasheet_par);
|
||||
|
||||
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) {
|
||||
@@ -200,9 +221,11 @@ function delete_entry(partID) {
|
||||
|
||||
function show_part_info(partID) {
|
||||
$.getJSON('http://127.0.0.1:5000/parts/getpartinfo/' + partID, function(data) {
|
||||
$('table#details tr#location td').text(text_filter(data.name)); // name is the location friendly name
|
||||
$('table#details tr#partno td').text(text_filter(data.partno));
|
||||
$('table#details tr#description td').text(text_filter(data.description));
|
||||
$('table#details tr#location td p').text(text_filter(data.name)); // name is the location friendly name
|
||||
$('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));
|
||||
$('img#map').attr('src', 'parts/map/' + data.map);
|
||||
if (data.datasheet != null)
|
||||
$('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>'));
|
||||
@@ -238,7 +261,6 @@ function perform_query() {
|
||||
newRow.append($('<td id="location"></td>').text(text_filter(data[i].location_descriptor)));
|
||||
newRow.append($('<td id="partno"></td>').text(text_filter(data[i].partno)));
|
||||
newRow.append($('<td id="description"></td>').text(text_filter(data[i].description)));
|
||||
newRow.append($('<td id="docs"></td>').text(text_filter(data[i].docs)));
|
||||
$('#results').append(newRow);
|
||||
}
|
||||
if(data.length == 0) {
|
||||
@@ -254,6 +276,11 @@ function perform_query() {
|
||||
}
|
||||
|
||||
$(document).ready(function() {
|
||||
$.getJSON('http://127.0.0.1:5000/parts/getlocations', function(data){
|
||||
$.each(data, function(i, val) {
|
||||
$('table#details tr#location td select').append('<option value="' + i + '">' + val + '</option>');
|
||||
});
|
||||
});
|
||||
$.ajaxSetup({ cache: false });
|
||||
$('.search-bar').on('keyup', function() {
|
||||
perform_query();
|
||||
|
||||
+12
-2
@@ -166,7 +166,7 @@ div label input {
|
||||
left: 20%;
|
||||
padding: 0;
|
||||
position: fixed;
|
||||
top:5% !important;
|
||||
top:0;
|
||||
width: 60%;
|
||||
z-index: 201;
|
||||
border-radius: 2pt;
|
||||
@@ -296,7 +296,7 @@ table#results #partno {
|
||||
}
|
||||
|
||||
table#results #description {
|
||||
width: 65%;
|
||||
width: 70%;
|
||||
}
|
||||
|
||||
table#results #docs {
|
||||
@@ -367,10 +367,20 @@ table#details #datasheet-head td {
|
||||
padding-top: 16pt;
|
||||
}
|
||||
|
||||
td p {
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
}
|
||||
|
||||
.overlay img#map {
|
||||
position: absolute;
|
||||
right: 5%;
|
||||
bottom: 5%;
|
||||
height: calc(90% - 42pt);
|
||||
max-width: 50%;
|
||||
}
|
||||
|
||||
.pinfo-input {
|
||||
display: none;
|
||||
width: 90%;
|
||||
}
|
||||
@@ -32,7 +32,6 @@
|
||||
<th id="location">Location</th>
|
||||
<th id="partno">Part Number</th>
|
||||
<th id="description">Description</th>
|
||||
<th id="docs">Docs</th>
|
||||
</tr>
|
||||
</table>
|
||||
<h3 id="no-results">No results.</h3>
|
||||
@@ -43,12 +42,13 @@
|
||||
<h2>Part Details</h2>
|
||||
<table id="details">
|
||||
<tr id="location-head"><td>LOCATION</td></tr>
|
||||
<tr id="location"><td></td></tr>
|
||||
<tr id="location"><td><p></p><select class="pinfo-input"></select></td></tr>
|
||||
<tr id="partno-head"><td>PART NUMBER</td></tr>
|
||||
<tr id="partno"><td></td></tr>
|
||||
<tr id="partno"><td><p></p><input type="text" name="partno-input" placeholder="Part Number" class="pinfo-input"/></td></tr>
|
||||
<tr id="description-head"><td>DESCRIPTION</td></tr>
|
||||
<tr id="description"><td></td></tr>
|
||||
<tr id="description"><td><p></p><input type="text" name="description-input" placeholder="Description" class="pinfo-input"/></td></tr>
|
||||
<tr id="datasheet-head"><td>DATASHEET: </td></tr>
|
||||
<tr id="datasheet"><td></td></tr>
|
||||
</table>
|
||||
<img src="" id="map"/>
|
||||
<div class="round-button-left"><a href="#" id="edit-button"><i class="fa fa-pencil" aria-hidden="true"></i></a></div>
|
||||
|
||||
Reference in New Issue
Block a user