Commit 3563393e authored by Markos Gogoulos's avatar Markos Gogoulos
Browse files

add server metadata forms

Refs #375
parent db259cbc
......@@ -725,6 +725,37 @@ function delete_server_metadata(serverID, meta_key) {
}
// add server metadata action
function add_server_metadata(serverID, meta_key, meta_value) {
var payload = {
"meta": {
}
};
payload["meta"][meta_key] = meta_value;
$.ajax({
url: API_URL + '/servers/' + serverID + '/meta/' + meta_key,
type: "PUT",
contentType: "application/json",
dataType: "json",
data: JSON.stringify(payload),
timeout: TIMEOUT,
error: function(jqXHR, textStatus, errorThrown) {
try {
ajax_error(jqXHR.status, undefined, 'add metadata', jqXHR.responseText);
} catch (err) {
ajax_error(err);
}
},
success: function(data, textStatus, jqXHR) {
get_metadata(serverID);
}
});
return false;
}
// show the welcome screen
function showWelcome() {
$("#view-select").fadeOut("fast");
......
......@@ -648,12 +648,12 @@ $('#editor-2.meta-modal button.cancel').click( function(){
});
// intercept click on save button in metadata add dialog
$('#editor-2.meta-modal button.save').click( function(){
// ajax call to save metadata
//TODO
// go from add meatata to edit metadata
$('a#meta-editor-2').data('overlay').close();
editMetadata();
$('#editor-2.meta-modal button.save').live('click', function() {
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);
return false;
});
// update metadata in edit dialog
......
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