Commit a73a0fde authored by Christodoulos Psaltis's avatar Christodoulos Psaltis
Browse files

Minor metadata dialog fixes.

This includes:

* renaming ajax funtions
* save button click gets you back to basic edit form
* more comments

Refs #375
parent 3563393e
......@@ -696,14 +696,15 @@ function get_metadata(serverID) {
}
},
success: function(data, textStatus, jqXHR) {
// to list the new results in the edit dialog
list_metadata(data);
}
});
return false;
}
// delete server metadata action
function delete_server_metadata(serverID, meta_key) {
// delete metadata key-value pair
function delete_metadata(serverID, meta_key) {
$.ajax({
url: API_URL + '/servers/' + serverID + '/meta/' + meta_key,
type: "DELETE",
......@@ -718,6 +719,7 @@ function delete_server_metadata(serverID, meta_key) {
}
},
success: function(data, textStatus, jqXHR) {
// to GET new results and list them in the edit dialog
get_metadata(serverID);
}
});
......@@ -725,8 +727,8 @@ function delete_server_metadata(serverID, meta_key) {
}
// add server metadata action
function add_server_metadata(serverID, meta_key, meta_value) {
// add metadata key-value pair
function add_metadata(serverID, meta_key, meta_value) {
var payload = {
"meta": {
......@@ -749,6 +751,7 @@ function add_server_metadata(serverID, meta_key, meta_value) {
}
},
success: function(data, textStatus, jqXHR) {
// to GET new results and list them in the edit dialog
get_metadata(serverID);
}
});
......
......@@ -619,21 +619,23 @@ function addMetadata() {
// intercept click on create button in metadata edit dialog
$('#editor-1.meta-modal button.create').click( function(){
// go from edit metadata to add metadata
// close edit metadata and open add metadata dialog
$('a#meta-editor-1').data('overlay').close();
addMetadata();
});
// intercept click on remove button in metadata edit dialog
$('#editor-1.meta-modal button.remove').live('click', function() {
$('#editor-1.meta-modal button.remove').live('click', function() {
// get the server id and meta key needed for the ajax call
var serverID = $(this).parent().parent().parent().parent().children("h3").attr('id');
var meta_key = $(this).parent().find("label").text();
delete_server_metadata(serverID, meta_key);
// make the ajax call and list the new GET results
delete_metadata(serverID, meta_key);
return false;
});
// intercept click on edit button in metadata edit dialog
$('#editor-1.meta-modal button.create').click( function(){
$('#editor-1.meta-modal button.edit').click( function(){
// inline editing of selected key-value pair
// on submission ajax call from updating
// on success update the overlay
......@@ -642,17 +644,22 @@ $('#editor-1.meta-modal button.create').click( function(){
// intercept click on cancel button in metadata add dialog
$('#editor-2.meta-modal button.cancel').click( function(){
// go from add meatata to edit metadata
// close add metadata and open edit metadata dialog
$('a#meta-editor-2').data('overlay').close();
editMetadata();
});
// intercept click on save button in metadata add dialog
$('#editor-2.meta-modal button.save').live('click', function() {
$('#editor-2.meta-modal button.save').live('click', function() {
// get the server id, meta key and meta value needed for the ajax call
var serverID = $(this).parent().children("h3").attr('id');
var meta_key = $(this).parent().find(".content input.key").attr('value');
var meta_value = $(this).parent().find(".content input.value").attr('value');
add_server_metadata(serverID, meta_key, meta_value);
// make the ajax call and list the new GET results
add_metadata(serverID, meta_key, meta_value);
// close add metadata and open edit metadata dialog
$('a#meta-editor-2').data('overlay').close();
editMetadata();
return false;
});
......@@ -667,7 +674,7 @@ function list_metadata(data) {
pair = $("ul.meta-template li").clone();
pair.find("label").text(key);
pair.find("p").text(meta[key]);
pair.appendTo("#editor-1 div.content ul.meta-list");
pair.appendTo("#editor-1 div.content ul.meta-list").fadeIn();
}
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment