Compare commits
5
Commits
846b7297ce
...
c886f2e860
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
c886f2e860 | ||
|
|
501491ac9a | ||
|
|
257a8d9754 | ||
|
|
005ea98f59 | ||
|
|
e9b670bea8 |
+8
-9
@@ -132,31 +132,30 @@ def query(filter_dummy, query):
|
|||||||
kw_dict["kw" + str(i)] = keywords[i]
|
kw_dict["kw" + str(i)] = keywords[i]
|
||||||
|
|
||||||
s = 'select p.id,partno,description, c.name || l.name as location_descriptor from parts as p inner join locations as l on p.location_id = l.id inner join containers as c on l.container_id = c.id where '
|
s = 'select p.id,partno,description, c.name || l.name as location_descriptor from parts as p inner join locations as l on p.location_id = l.id inner join containers as c on l.container_id = c.id where '
|
||||||
if filter['l']:
|
|
||||||
|
if filter['l'] == 'true':
|
||||||
s += '('
|
s += '('
|
||||||
for i in range(len(keywords)):
|
for i in range(len(keywords)):
|
||||||
s += 'LOWER(l.name) like LOWER(:kw'+ str(i) +') AND '
|
s += 'LOWER(l.name) like LOWER(:kw'+ str(i) +') AND '
|
||||||
s = s[:-5]
|
s = s[:-5]
|
||||||
s += ') OR '
|
s += ') OR '
|
||||||
if filter['p']:
|
if filter['p'] == 'true':
|
||||||
s += '('
|
s += '('
|
||||||
for i in range(len(keywords)):
|
for i in range(len(keywords)):
|
||||||
s += 'LOWER(partno) like LOWER(:kw'+ str(i) +') AND '
|
s += 'LOWER(partno) like LOWER(:kw'+ str(i) +') AND '
|
||||||
s = s[:-5]
|
s = s[:-5]
|
||||||
s += ') OR '
|
s += ') OR '
|
||||||
if filter['d']:
|
if filter['d'] == 'true':
|
||||||
s += '('
|
s += '('
|
||||||
for i in range(len(keywords)):
|
for i in range(len(keywords)):
|
||||||
s += 'LOWER(description) like LOWER(:kw'+ str(i) +') AND '
|
s += 'LOWER(description) like LOWER(:kw'+ str(i) +') AND '
|
||||||
s = s[:-5]
|
s = s[:-5]
|
||||||
s += ') OR '
|
s += ') OR '
|
||||||
if filter['n']:
|
if filter['n'] == 'true':
|
||||||
s += '('
|
s = s[:-4]
|
||||||
for i in range(len(keywords)):
|
s += "AND (datasheet='' IS NOT FALSE) IS FALSE OR "
|
||||||
s += 'LOWER(notes) like LOWER(:kw'+ str(i) +') AND '
|
|
||||||
s = s[:-5]
|
|
||||||
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 = []
|
||||||
|
|||||||
+16
-12
@@ -56,8 +56,8 @@ function end_edit() {
|
|||||||
|
|
||||||
function save(partID) {
|
function save(partID) {
|
||||||
var location_id_v = $('#location-dropdown').val();
|
var location_id_v = $('#location-dropdown').val();
|
||||||
var partno_v = $('table#details tr#partno td input').val();
|
var partno_v = $('input[name=partno-input]').val();
|
||||||
var description_v = $('table#details tr#description td 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.length == 0){
|
if(partno_v.length == 0){
|
||||||
alert('Please enter a part number.');
|
alert('Please enter a part number.');
|
||||||
@@ -73,12 +73,17 @@ function save(partID) {
|
|||||||
}
|
}
|
||||||
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('partno', partno_v);
|
data.append('partno', partno_v);
|
||||||
data.append('location_id', location_id_v)
|
data.append('location_id', location_id_v)
|
||||||
data.append('description', description_v);
|
data.append('description', description_v);
|
||||||
@@ -151,7 +156,8 @@ function show_part_info(partID) {
|
|||||||
$('table#details tr#description td input').val(text_filter(data.description));
|
$('table#details tr#description td input').val(text_filter(data.description));
|
||||||
container_onchange();
|
container_onchange();
|
||||||
if (data.datasheet != null) {
|
if (data.datasheet != null) {
|
||||||
$('tr#datasheet-head').html($('<td>DATASHEET: <a href=""><i class="fa fa-file-text" aria-hidden="true"></i></a></td>'));
|
$('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
|
else
|
||||||
$('tr#datasheet-head td').text('DATASHEET: ');
|
$('tr#datasheet-head td').text('DATASHEET: ');
|
||||||
@@ -168,17 +174,18 @@ function show_part_info(partID) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function perform_query() {
|
function perform_query() {
|
||||||
|
$('#no-results').stop();
|
||||||
$('#no-results').css("opacity", 0);
|
$('#no-results').css("opacity", 0);
|
||||||
var query = $('.search-bar').val();
|
var query = $('.search-bar').val();
|
||||||
var data = {
|
var data = {
|
||||||
l:$('#type').is(':checked'),
|
l:$('#type').is(':checked'),
|
||||||
p:$('#partno').is(':checked'),
|
p:$('#partno').is(':checked'),
|
||||||
d:$('#description').is(':checked'),
|
d:$('#description').is(':checked'),
|
||||||
n:$('#notes').is(':checked')
|
n:$('#has-docs').is(':checked')
|
||||||
};
|
};
|
||||||
filter = '0';
|
filter = '0';
|
||||||
|
$("#results").find("tr:not(:first)").remove(); // Delete all table rows
|
||||||
$.getJSON(rootURL + 'query/' + filter + '/' + query, data, function(data) {
|
$.getJSON(rootURL + 'query/' + filter + '/' + query, data, function(data) {
|
||||||
$("#results").find("tr:not(:first)").remove(); // Delete all table rows
|
|
||||||
for(var i = 0; i < data.length; i++) {
|
for(var i = 0; i < data.length; i++) {
|
||||||
var newRow = $('<tr onclick="show_part_info(' + data[i].id + ')"></tr>');
|
var newRow = $('<tr onclick="show_part_info(' + data[i].id + ')"></tr>');
|
||||||
|
|
||||||
@@ -191,10 +198,7 @@ function perform_query() {
|
|||||||
$('#no-results').animate({opacity:1},2000);
|
$('#no-results').animate({opacity:1},2000);
|
||||||
}
|
}
|
||||||
}).fail(function() {
|
}).fail(function() {
|
||||||
var newResults = '<div class="results">';
|
$('#no-results').animate({opacity:1},2000);
|
||||||
newResults += '<h3>No results.</h3>';
|
|
||||||
newResults += '</div>';
|
|
||||||
$('.results').replaceWith(newResults);
|
|
||||||
console.log( "Query failed" );
|
console.log( "Query failed" );
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@@ -206,7 +210,7 @@ function container_onchange() {
|
|||||||
$('#location-dropdown').empty();
|
$('#location-dropdown').empty();
|
||||||
$.getJSON('parts/getlocationsInContainer/' + selected_container_id, function(data) {
|
$.getJSON('parts/getlocationsInContainer/' + selected_container_id, function(data) {
|
||||||
$.each(data, function(location_id, location_name) {
|
$.each(data, function(location_id, location_name) {
|
||||||
$('#location-dropdown').append('<option value="' + location_id + '">' + location_name + '</option>');
|
$('#location-dropdown').append('<option val="' + location_id + '">' + location_name + '</option>');
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@@ -221,7 +225,7 @@ $(document).ready(function() {
|
|||||||
if ( !$('#location').is(':checked')
|
if ( !$('#location').is(':checked')
|
||||||
&& !$('#partno').is(':checked')
|
&& !$('#partno').is(':checked')
|
||||||
&& !$('#description').is(':checked')
|
&& !$('#description').is(':checked')
|
||||||
&& !$('#notes').is(':checked'))
|
&& !$('#has-docs').is(':checked'))
|
||||||
$(this).prop('checked', true);
|
$(this).prop('checked', true);
|
||||||
else
|
else
|
||||||
perform_query();
|
perform_query();
|
||||||
|
|||||||
@@ -59,7 +59,6 @@ input[type=text].search-bar {
|
|||||||
padding: 10pt 15pt 10pt 15pt;
|
padding: 10pt 15pt 10pt 15pt;
|
||||||
margin-top: 10pt;
|
margin-top: 10pt;
|
||||||
margin-bottom: 10pt;
|
margin-bottom: 10pt;
|
||||||
border-radius: 2pt;
|
|
||||||
display: inline-block;
|
display: inline-block;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -81,7 +80,6 @@ input[type=checkbox]{
|
|||||||
}
|
}
|
||||||
|
|
||||||
input[type=checkbox] + label.toggle-btn {
|
input[type=checkbox] + label.toggle-btn {
|
||||||
border-radius: 3pt;
|
|
||||||
display: inline-block;
|
display: inline-block;
|
||||||
padding: 5pt;
|
padding: 5pt;
|
||||||
color: #D7E2E2;
|
color: #D7E2E2;
|
||||||
@@ -89,7 +87,8 @@ input[type=checkbox] + label.toggle-btn {
|
|||||||
margin-bottom: 6pt;
|
margin-bottom: 6pt;
|
||||||
margin-left: 3pt;
|
margin-left: 3pt;
|
||||||
margin-right: 3pt;
|
margin-right: 3pt;
|
||||||
width: 100pt;
|
width: 80pt;
|
||||||
|
line-height: 300%;
|
||||||
text-align: center;
|
text-align: center;
|
||||||
border: 1pt solid #D7E2E2;
|
border: 1pt solid #D7E2E2;
|
||||||
transition: 0.2s;
|
transition: 0.2s;
|
||||||
|
|||||||
@@ -22,10 +22,10 @@
|
|||||||
<div class="filter-concontainertainer">
|
<div class="filter-concontainertainer">
|
||||||
<div class="filter-container">
|
<div class="filter-container">
|
||||||
<p>Search in:</p>
|
<p>Search in:</p>
|
||||||
<input type="checkbox" class="checkbox" id="location"></input><label class="toggle-btn" for="location">Locations</label>
|
<input type="checkbox" class="checkbox" id="location"></input><label class="toggle-btn" for="location">Locations<br/><i class="fa fa-map" style="font-size:28pt"></i></label>
|
||||||
<input type="checkbox" class="checkbox" id="partno" checked></input><label class="toggle-btn" for="partno">Part Number</label>
|
<input type="checkbox" class="checkbox" id="partno" checked></input><label class="toggle-btn" for="partno">Part Number<br/><i class="fa fa-hashtag" style="font-size:28pt"></i></label>
|
||||||
<input type="checkbox" class="checkbox" id="description" checked></input><label class="toggle-btn" for="description">Description</label>
|
<input type="checkbox" class="checkbox" id="description" checked></input><label class="toggle-btn" for="description">Description<br/><i class="fa fa-edit" style="font-size:28pt"></i></label>
|
||||||
<input type="checkbox" class="checkbox" id="notes" checked></input><label class="toggle-btn" for="notes">Notes</label>
|
<input type="checkbox" class="checkbox" id="has-docs"></input><label class="toggle-btn" for="has-docs">Has docs<br/><i class="fa fa-paperclip" style="font-size:28pt"></i></label>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<table id="results">
|
<table id="results">
|
||||||
|
|||||||
Reference in New Issue
Block a user