|
|
@ -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>');
|
|
|
|
newRow.append($('<td id="location"></td>').text(text_filter(data[i].location_descriptor)));
|
|
|
|
var newClicker = $('<a href="#" onclick="show_part_info(' + data[i].id + ')"></a>');
|
|
|
|
newRow.append($('<td id="partno"></td>').text(text_filter(data[i].partno)));
|
|
|
|
|
|
|
|
newRow.append($('<td id="description"></td>').text(text_filter(data[i].description)));
|
|
|
|
newClicker.append($('<div class="results-block"></div>').text(text_filter(data[i].block)));
|
|
|
|
newRow.append($('<td id="docs"></td>').text(text_filter(data[i].docs)));
|
|
|
|
newClicker.append($('<div class="results-type"></div>').text(text_filter(data[i].type)));
|
|
|
|
$('#results').append(newRow);
|
|
|
|
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);
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
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>';
|
|
|
|