Commit b2065c64 authored by Mike Muzurakis's avatar Mike Muzurakis
Browse files

initial ui work on server renaming, Refs #307

parent 3393cc71
......@@ -1427,7 +1427,21 @@ div#user a.current_lang {
}
.machine .settings {
margin-top: 22px;
margin-top: 13px;
}
.editbuttons {
float:none !important;
margin: 0px !important;
}
.namecontainer {
line-height: 22px;
}
.nametextbox {
height: 13px;
font-size: 95%;
}
#spinner {
......
......@@ -674,6 +674,46 @@ function start(serverIDs){
return false;
}
// rename action
function rename(serverIDs){
if (!serverIDs.length){
//ajax_success('DEFAULT');
return false;
}
// ajax post rename call
var payload = {
"rename": {"type" : "PUT"}
};
var serverID = serverIDs.pop()
$.ajax({
url: API_URL + '/servers/' + serverID + '/action',
type: "POST",
contentType: "application/json",
dataType: "json",
data: JSON.stringify(payload),
timeout: TIMEOUT,
error: function(jqXHR, textStatus, errorThrown) {
display_failure(jqXHR.status, serverID, 'Rename', jqXHR.responseText)
},
success: function(data, textStatus, jqXHR) {
if ( jqXHR.status == '202') {
try {
console.info('renamed ' + serverID);
} 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);
}
}
});
return false;
}
// get server metadata
function get_metadata(serverID) {
$.ajax({
......
......@@ -21,7 +21,11 @@
</div>
<img class="logo" src="" />
<a href="#" class="name">
<h5>{% trans "Name: " %}<span class="name">node.name</span><span class="rename"></span></h5>
<h5 class="namecontainer">
{% trans "Name: " %}<span class="name">node.name</span><span class="rename"></span>
<img class="editbuttons save" style="display:none" src="/static/save.png" />
<img class="editbuttons cancel" style="display:none" src="/static/cancel.png" />
</h5>
</a>
<a href="#" class="ip">
<h5>{% trans "IP: " %}<span class="public">node.public_ip</span></h5>
......@@ -67,6 +71,21 @@ $("a.show-metadata").live('click', function() {
return false;
});
//rename machine
$(".rename").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).fadeOut("fast");
$(this).parent().find(".editbuttons").fadeIn("slow");
});
//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").fadeOut("fast");
$(this).parent().parent().find(".rename").fadeIn("slow");
});
// intercept reboot click
$("div.actions a.action-reboot").live('click', function(){
var serverID = $(this).parent().parent().attr("id");
......
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