Commit 30e7f843 authored by Mike Muzurakis's avatar Mike Muzurakis
Browse files

renaming function and button, Refs #307

parent 641136fc
......@@ -675,20 +675,19 @@ function start(serverIDs){
}
// rename action
function rename(serverIDs){
if (!serverIDs.length){
function rename(serverID, serverName){
if (!serverID.length){
//ajax_success('DEFAULT');
return false;
}
// ajax post rename call
var payload = {
"rename": {"type" : "PUT"}
"server": {"name" : serverName}
};
var serverID = serverIDs.pop()
$.ajax({
url: API_URL + '/servers/' + serverID + '/action',
type: "POST",
type: "PUT",
contentType: "application/json",
dataType: "json",
data: JSON.stringify(payload),
......@@ -703,8 +702,6 @@ function rename(serverIDs){
} catch(err) {}
// indicate that the action succeeded
display_success(serverID);
// continue with the rest of the servers
start(serverIDs);
} else {
ajax_error(jqXHR.status, serverID, 'Rename', jqXHR.responseText);
}
......
......@@ -73,7 +73,7 @@ $("a.show-metadata").live('click', function() {
return false;
});
//rename machine
//initiate machine renaming
$(".rename, h5.editable span.name").live('click', function() {
$(this).parent().find('.name').html("<input id=\"txtEdit\" type=\"text\" class=\"nametextbox\" value=\"" + $(this).parent().find('.name').text() + "\" / ><span class=\"oldValue\" style=\"display:none;\" >" + $(this).parent().find('.name').text() + "</span>");
$(this).parent().find('.rename').hide();
......@@ -82,9 +82,27 @@ $(".rename, h5.editable span.name").live('click', function() {
return false;
});
//rename machine
$(".editbuttons .save").live('click', function() {
serverID = $(this).parent().parent().parent().attr("id");
serverName = $(this).parent().parent().find('.name').find('.nametextbox').val();
var found = false;
$(this).parent().parent().find('.name').html($(this).parent().parent().find('.nametextbox').val());
$(this).parent().parent().find(".editbuttons").fadeOut("fast");
$(this).parent().parent().find(".rename").fadeIn("slow");
for (i=0;i<pending_actions.length;i++){ // if there is already a pending action for this server replace it
if (pending_actions[i][1]==serverID){
pending_actions[i][0] = rename;
found = true
}
}
if (!found) // no pending action for this server was found, so let's just add it to the list
pending_actions.push([rename, serverID, serverName])
return false;
});
//cancel renaming
$(".editbuttons .cancel").live('click', function() {
console.info($(this).parent().parent().find('.name').find('.oldValue').text());
$(this).parent().parent().find('.name').html($(this).parent().parent().find('.name').find('.oldValue').text());
$(this).parent().parent().find(".editbuttons").hide();
$(this).parent().parent().find(".rename").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