Added delete entry function

pull/3/head
Davide Bongiovanni 7 years ago
parent 5bf02c4892
commit 43c88980f3

@ -117,6 +117,12 @@ def alter(partID):
return '{"status":"ok"}'
@app.route('/parts/delete/<partID>')
def delete(partID):
s = text('delete from parts where id=:id;')
r = db_engine.execute(s, id=partID)
return '{"status":"ok"}'
def connect(user, password, db, host='localhost', port=5432):
'''Returns a connection and a metadata object'''
# We connect with the help of the PostgreSQL URL

@ -173,6 +173,25 @@ function text_filter(string) {
return '';
}
function delete_entry(partID) {
if (!confirm('Delete the selected entry?'))
return;
$.ajax({
url: 'https://www.elab.kth.se/parts/delete/' + partID,
type: 'GET',
cache: false,
contentType: false,
processData: false,
success: function() {
overlay_out();
perform_query();
},
fail: function() {
console.log('An error occurred while deleting the entry');
},
});
}
function show_part_info(partID) {
$.getJSON('https://www.elab.kth.se/parts/getpartinfo/' + partID, function(data) {
$('#block-info').text(text_filter(data.block));
@ -188,6 +207,9 @@ function show_part_info(partID) {
$('#edit-button').click(function() {
init_edit(partID);
});
$('#edit-button').click(function() {
delete_entry(partID);
});
overlay_in();
}).fail(function() {
console.log( "Fetching part info failed" );

@ -273,6 +273,19 @@ div label input {
box-shadow: 2pt 1pt 8pt black;
}
.round-button-left {
position: absolute;
bottom: 15pt;
left: 15pt;
width: 40pt;
height: 32pt;
border-radius: 20pt;
background-color: #5E9292;
font-size: 20pt;
padding-top: 8pt;
box-shadow: 2pt 1pt 8pt black;
}
.round-button a{
color: #D7E2E2;
}

@ -77,6 +77,7 @@
</div>
<div class="round-button"><a href="#" id="edit-button"><i class="fa fa-pencil" aria-hidden="true"></i></a></div>
<div class="round-button-left"><a href="#" id="delete-button"><i class="fa fa-trash" aria-hidden="true"></i></a></div>
<div class="small-square-button"><a href="#" onclick="overlay_out()"><i class="fa fa-times" aria-hidden="true"></i></a></div>
<!--<h2 class="card-id"></h2>
<input type="text" name="name" placeholder="Name" id="name"><br><br>

Loading…
Cancel
Save