Un-retardeded the filters. Results are now a table
This commit is contained in:
+1
-2
@@ -52,7 +52,7 @@ def get_part_info(partID):
|
|||||||
r.close()
|
r.close()
|
||||||
return json.dumps(l[0])
|
return json.dumps(l[0])
|
||||||
|
|
||||||
@app.route('/parts/query/<filter_dummy>/<query>')
|
@app.route('/parts/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
|
||||||
@@ -88,7 +88,6 @@ def query(filter_dummy, query):
|
|||||||
s = s[:-5]
|
s = s[:-5]
|
||||||
s += ') OR '
|
s += ') OR '
|
||||||
s = s[:-4] + ';'
|
s = s[:-4] + ';'
|
||||||
print(s)
|
|
||||||
s = text(s)
|
s = text(s)
|
||||||
r = db_engine.execute(s, kw_dict)
|
r = db_engine.execute(s, kw_dict)
|
||||||
l = []
|
l = []
|
||||||
|
|||||||
+22
-44
@@ -144,7 +144,7 @@ function save(partID) {
|
|||||||
|
|
||||||
$.ajax({
|
$.ajax({
|
||||||
// Your server script to process the upload
|
// Your server script to process the upload
|
||||||
url: 'https://www.elab.kth.se/parts/alter/' + partID,
|
url: 'http://127.0.0.1:5000/parts/alter/' + partID,
|
||||||
type: 'POST',
|
type: 'POST',
|
||||||
|
|
||||||
data: data,
|
data: data,
|
||||||
@@ -183,7 +183,7 @@ function delete_entry(partID) {
|
|||||||
if (!confirm('Delete the selected entry?'))
|
if (!confirm('Delete the selected entry?'))
|
||||||
return;
|
return;
|
||||||
$.ajax({
|
$.ajax({
|
||||||
url: 'https://www.elab.kth.se/parts/delete/' + partID,
|
url: 'http://127.0.0.1:5000/parts/delete/' + partID,
|
||||||
type: 'GET',
|
type: 'GET',
|
||||||
cache: false,
|
cache: false,
|
||||||
contentType: false,
|
contentType: false,
|
||||||
@@ -199,7 +199,7 @@ function delete_entry(partID) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function show_part_info(partID) {
|
function show_part_info(partID) {
|
||||||
$.getJSON('https://www.elab.kth.se/parts/getpartinfo/' + partID, function(data) {
|
$.getJSON('http://127.0.0.1:5000/parts/getpartinfo/' + partID, function(data) {
|
||||||
$('#block-info').text(text_filter(data.block));
|
$('#block-info').text(text_filter(data.block));
|
||||||
$('#type-info').text(text_filter(data.type));
|
$('#type-info').text(text_filter(data.type));
|
||||||
$('#partno-info').text(text_filter(data.partno) + ' ' + text_filter(data.partnoalt) + ' ' + text_filter(data.partnoalt2));
|
$('#partno-info').text(text_filter(data.partno) + ' ' + text_filter(data.partnoalt) + ' ' + text_filter(data.partnoalt2));
|
||||||
@@ -207,7 +207,7 @@ function show_part_info(partID) {
|
|||||||
$('#quantity-info').text(text_filter(data.quantity));
|
$('#quantity-info').text(text_filter(data.quantity));
|
||||||
$('#notes-info').text(text_filter(data.notes));
|
$('#notes-info').text(text_filter(data.notes));
|
||||||
if (data.datasheet != null)
|
if (data.datasheet != null)
|
||||||
$('#datasheet-info').html($('<a href="https://www.elab.kth.se/parts/getfile/' + data.datasheet.substring(0, data.datasheet.length - 4) + '"><i class="fa fa-file-text" aria-hidden="true"></i></a>'));
|
$('#datasheet-info').html($('<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>'));
|
||||||
else
|
else
|
||||||
$('#datasheet-info').text(' ');
|
$('#datasheet-info').text(' ');
|
||||||
$('#edit-button').click(function() {
|
$('#edit-button').click(function() {
|
||||||
@@ -223,51 +223,29 @@ function show_part_info(partID) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function perform_query() {
|
function perform_query() {
|
||||||
|
$('#no-results').css("opacity", 0);
|
||||||
var query = $('.search-bar').val();
|
var query = $('.search-bar').val();
|
||||||
var filter = 0;
|
var data = {
|
||||||
if($('#type').is(':checked'))
|
l:$('#type').is(':checked'),
|
||||||
filter += 1;
|
p:$('#partno').is(':checked'),
|
||||||
if($('#partno').is(':checked'))
|
d:$('#description').is(':checked'),
|
||||||
filter += 2 + 4 + 8;
|
n:$('#notes').is(':checked')
|
||||||
if($('#description').is(':checked'))
|
};
|
||||||
filter += 16;
|
filter = '0';
|
||||||
if($('#notes').is(':checked'))
|
$.getJSON('http://127.0.0.1:5000/parts/query/' + filter + '/' + query, data, function(data) {
|
||||||
filter += 32;
|
$("#results").find("tr:not(:first)").remove(); // Delete all table rows
|
||||||
$.getJSON('https://www.elab.kth.se/parts/query/' + filter + '/' + query, function(data) {
|
for(var i = 0; i < data.length; i++) {
|
||||||
var newResults = $('<div class="results"></div>');
|
var newRow = $('<tr onclick="show_part_info(' + data[i].id + ')"></tr>');
|
||||||
for(var i = 0; i < data.length; i++) { // Create new view for results
|
|
||||||
var newRow = $('<div class="results-row"></div>');
|
|
||||||
var newClicker = $('<a href="#" onclick="show_part_info(' + data[i].id + ')"></a>');
|
|
||||||
|
|
||||||
newClicker.append($('<div class="results-block"></div>').text(text_filter(data[i].block)));
|
newRow.append($('<td id="location"></td>').text(text_filter(data[i].location_descriptor)));
|
||||||
newClicker.append($('<div class="results-type"></div>').text(text_filter(data[i].type)));
|
newRow.append($('<td id="partno"></td>').text(text_filter(data[i].partno)));
|
||||||
newClicker.append($('<div class="results-partno"></div>').text(text_filter(data[i].partno)));
|
newRow.append($('<td id="description"></td>').text(text_filter(data[i].description)));
|
||||||
newClicker.append($('<div class="results-description"></div>').text(text_filter(data[i].description)));
|
newRow.append($('<td id="docs"></td>').text(text_filter(data[i].docs)));
|
||||||
var notes = $('<div class="results-notes"></div>');
|
$('#results').append(newRow);
|
||||||
if (data[i].notes != null && data[i].notes.length > 0) {
|
|
||||||
var icon = $('<i class="fa fa-sticky-note"></i>');
|
|
||||||
var tooltipText = $('<div class="tooltiptext"></div>').text(data[i].notes);
|
|
||||||
var tooltip = $('<div class="tooltip"></div>');
|
|
||||||
tooltip.append(icon, tooltipText);
|
|
||||||
notes.append(tooltip);
|
|
||||||
}
|
|
||||||
newClicker.append(notes);
|
|
||||||
var datasheet = $('<div class="results-datasheet"></div>');
|
|
||||||
if (data[i].datasheet != null)
|
|
||||||
datasheet.html('<a href="https://www.elab.kth.se/parts/getfile/'
|
|
||||||
+ data[i].datasheet.substring(0, data[i].datasheet.length - 4)
|
|
||||||
+ '"><i class="fa fa-file-text" aria-hidden="true"></i></a>');
|
|
||||||
newClicker.append(datasheet);
|
|
||||||
|
|
||||||
newRow.append(newClicker);
|
|
||||||
newResults.append(newRow);
|
|
||||||
}
|
}
|
||||||
if(data.length == 0) {
|
if(data.length == 0) {
|
||||||
newResults = '<div class="results">';
|
$('#no-results').animate({opacity:1},2000);
|
||||||
newResults += '<h3>No results.</h3>';
|
|
||||||
newResults += '</div>';
|
|
||||||
}
|
}
|
||||||
$('.results').replaceWith(newResults);
|
|
||||||
}).fail(function() {
|
}).fail(function() {
|
||||||
var newResults = '<div class="results">';
|
var newResults = '<div class="results">';
|
||||||
newResults += '<h3>No results.</h3>';
|
newResults += '<h3>No results.</h3>';
|
||||||
|
|||||||
@@ -27,6 +27,7 @@ h3 {
|
|||||||
text-align: center;
|
text-align: center;
|
||||||
padding: 12pt;
|
padding: 12pt;
|
||||||
font-size: 20pt;
|
font-size: 20pt;
|
||||||
|
opacity: 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
p {
|
p {
|
||||||
@@ -338,3 +339,41 @@ div label input {
|
|||||||
.bottom-spacer {
|
.bottom-spacer {
|
||||||
height: 80pt;
|
height: 80pt;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
table#results {
|
||||||
|
width: 100%;
|
||||||
|
border-collapse: collapse;
|
||||||
|
}
|
||||||
|
|
||||||
|
table#results th {
|
||||||
|
background-color: #226666;
|
||||||
|
color: #D7E2E2;
|
||||||
|
padding: 4pt;
|
||||||
|
border-right: 2px solid #D7E2E2;
|
||||||
|
border-left: 2px solid #D7E2E2;
|
||||||
|
}
|
||||||
|
|
||||||
|
table#results tr:nth-child(odd) {
|
||||||
|
background-color: #5E9292;
|
||||||
|
}
|
||||||
|
|
||||||
|
table#results td {
|
||||||
|
padding: 4pt;
|
||||||
|
cursor: pointer;
|
||||||
|
}
|
||||||
|
|
||||||
|
#location {
|
||||||
|
width: 15%;
|
||||||
|
}
|
||||||
|
|
||||||
|
#partno {
|
||||||
|
/*width: 20%;*/
|
||||||
|
}
|
||||||
|
|
||||||
|
#description {
|
||||||
|
width: 65%;
|
||||||
|
}
|
||||||
|
|
||||||
|
#docs {
|
||||||
|
width: 5%;
|
||||||
|
}
|
||||||
@@ -8,9 +8,9 @@
|
|||||||
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('parts/static', filename='style.css') }}">
|
<link rel="stylesheet" type="text/css" href="{{ url_for('static', filename='style.css') }}">
|
||||||
<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('parts/static', filename='script.js') }}"></script>
|
<script type="text/javascript" src="{{ url_for('static', filename='script.js') }}"></script>
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
<h1>ELAB Part Search Engine</h1>
|
<h1>ELAB Part Search Engine</h1>
|
||||||
@@ -21,20 +21,21 @@
|
|||||||
<div class="filter-concontainertainer">
|
<div class="filter-concontainertainer">
|
||||||
<div class="filter-container">
|
<div class="filter-container">
|
||||||
<p>Search in:</p>
|
<p>Search in:</p>
|
||||||
<input type="checkbox" class="checkbox" id="type" checked></input><label class="toggle-btn" for="type">Manufacturer</label>
|
<input type="checkbox" class="checkbox" id="location"></input><label class="toggle-btn" for="type">Locations</label>
|
||||||
<input type="checkbox" class="checkbox" id="partno" checked></input><label class="toggle-btn" for="partno">Part Number</label>
|
<input type="checkbox" class="checkbox" id="partno" checked></input><label class="toggle-btn" for="partno">Part Number</label>
|
||||||
<input type="checkbox" class="checkbox" id="description" checked></input><label class="toggle-btn" for="description">Description</label>
|
<input type="checkbox" class="checkbox" id="description" checked></input><label class="toggle-btn" for="description">Description</label>
|
||||||
<input type="checkbox" class="checkbox" id="notes" checked></input><label class="toggle-btn" for="notes">Notes</label>
|
<input type="checkbox" class="checkbox" id="notes" checked></input><label class="toggle-btn" for="notes">Notes</label>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="res-header-small">Block</div>
|
<table id="results">
|
||||||
<div class="res-header">Manufacturer</div>
|
<tr>
|
||||||
<div class="res-header">Part Number</div>
|
<th id="location">Location</th>
|
||||||
<div class="res-header-3">Description</div>
|
<th id="partno">Part Number</th>
|
||||||
<div class="res-header-small">Notes</div>
|
<th id="description">Description</th>
|
||||||
<div class="res-header-small">Docs</div>
|
<th id="docs">Docs</th>
|
||||||
<div class="results">
|
</tr>
|
||||||
</div>
|
</table>
|
||||||
|
<h3 id="no-results">No results.</h3>
|
||||||
<div class="bottom-spacer"></div>
|
<div class="bottom-spacer"></div>
|
||||||
|
|
||||||
<div class="shadow" onclick="overlay_out()"></div>
|
<div class="shadow" onclick="overlay_out()"></div>
|
||||||
|
|||||||
Reference in New Issue
Block a user