|
|
|
@ -144,7 +144,7 @@ function save(partID) {
|
|
|
|
|
|
|
|
|
|
$.ajax({
|
|
|
|
|
// 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',
|
|
|
|
|
|
|
|
|
|
data: data,
|
|
|
|
@ -183,7 +183,7 @@ function delete_entry(partID) {
|
|
|
|
|
if (!confirm('Delete the selected entry?'))
|
|
|
|
|
return;
|
|
|
|
|
$.ajax({
|
|
|
|
|
url: 'https://www.elab.kth.se/parts/delete/' + partID,
|
|
|
|
|
url: 'http://127.0.0.1:5000/parts/delete/' + partID,
|
|
|
|
|
type: 'GET',
|
|
|
|
|
cache: false,
|
|
|
|
|
contentType: false,
|
|
|
|
@ -199,7 +199,7 @@ function delete_entry(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));
|
|
|
|
|
$('#type-info').text(text_filter(data.type));
|
|
|
|
|
$('#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));
|
|
|
|
|
$('#notes-info').text(text_filter(data.notes));
|
|
|
|
|
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
|
|
|
|
|
$('#datasheet-info').text(' ');
|
|
|
|
|
$('#edit-button').click(function() {
|
|
|
|
@ -223,51 +223,29 @@ function show_part_info(partID) {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function perform_query() {
|
|
|
|
|
$('#no-results').css("opacity", 0);
|
|
|
|
|
var query = $('.search-bar').val();
|
|
|
|
|
var filter = 0;
|
|
|
|
|
if($('#type').is(':checked'))
|
|
|
|
|
filter += 1;
|
|
|
|
|
if($('#partno').is(':checked'))
|
|
|
|
|
filter += 2 + 4 + 8;
|
|
|
|
|
if($('#description').is(':checked'))
|
|
|
|
|
filter += 16;
|
|
|
|
|
if($('#notes').is(':checked'))
|
|
|
|
|
filter += 32;
|
|
|
|
|
$.getJSON('https://www.elab.kth.se/parts/query/' + filter + '/' + query, function(data) {
|
|
|
|
|
var newResults = $('<div class="results"></div>');
|
|
|
|
|
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)));
|
|
|
|
|
newClicker.append($('<div class="results-type"></div>').text(text_filter(data[i].type)));
|
|
|
|
|
newClicker.append($('<div class="results-partno"></div>').text(text_filter(data[i].partno)));
|
|
|
|
|
newClicker.append($('<div class="results-description"></div>').text(text_filter(data[i].description)));
|
|
|
|
|
var notes = $('<div class="results-notes"></div>');
|
|
|
|
|
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);
|
|
|
|
|
var data = {
|
|
|
|
|
l:$('#type').is(':checked'),
|
|
|
|
|
p:$('#partno').is(':checked'),
|
|
|
|
|
d:$('#description').is(':checked'),
|
|
|
|
|
n:$('#notes').is(':checked')
|
|
|
|
|
};
|
|
|
|
|
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
|
|
|
|
|
for(var i = 0; i < data.length; i++) {
|
|
|
|
|
var newRow = $('<tr onclick="show_part_info(' + data[i].id + ')"></tr>');
|
|
|
|
|
|
|
|
|
|
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) {
|
|
|
|
|
newResults = '<div class="results">';
|
|
|
|
|
newResults += '<h3>No results.</h3>';
|
|
|
|
|
newResults += '</div>';
|
|
|
|
|
$('#no-results').animate({opacity:1},2000);
|
|
|
|
|
}
|
|
|
|
|
$('.results').replaceWith(newResults);
|
|
|
|
|
}).fail(function() {
|
|
|
|
|
var newResults = '<div class="results">';
|
|
|
|
|
newResults += '<h3>No results.</h3>';
|
|
|
|
|