Skip to content
This repository has been archived by the owner on Sep 23, 2020. It is now read-only.

Commit

Permalink
Add Terminate and Replace buttons underneath VM details
Browse files Browse the repository at this point in the history
  • Loading branch information
oldpatricka committed Jan 26, 2013
1 parent b35385d commit 95ffd00
Show file tree
Hide file tree
Showing 3 changed files with 47 additions and 2 deletions.
4 changes: 4 additions & 0 deletions phantomweb/static/css/phantom_domain.css
Expand Up @@ -16,6 +16,10 @@
display: none;
}

#phantom_details_button_div {
display: none;
}

#phantom_domain_loading_image {
display: none;
}
Expand Down
36 changes: 34 additions & 2 deletions phantomweb/static/js/phantom_domain.js
Expand Up @@ -94,6 +94,30 @@ $(document).ready(function() {
return false;
});

$("#details_button_replace_vm").click(function() {
var instance_id = get_selected_instance_id();
var instance = get_instance(instance_id);
if (instance === null) {
return;
}
console.log(instance_id);
console.log(instance);
phantom_domain_instance_replace_click(instance.instance_id, instance.cloud);

return false;
});

$("#details_button_terminate_vm").click(function() {
var instance_id = get_selected_instance_id();
var instance = get_instance(instance_id);
if (instance === null) {
return;
}
phantom_domain_instance_terminate_click(instance.instance_id, instance.cloud);

return false;
});

});


Expand Down Expand Up @@ -508,6 +532,7 @@ function phantom_domain_select_domain(domain, load_details) {
function phantom_domain_deselect_domain() {
$("#phantom_domain_main_combined_pane_inner").show();
$("#phantom_domain_instance_details").empty();
$("#phantom_details_button_div").hide();
$("#details_table_body").empty();
$("#instance_table_body").empty();
$("#phantom_domain_main_combined_pane_inner").hide();
Expand Down Expand Up @@ -588,6 +613,11 @@ function human_lifecycle_state(state) {
}
}

function get_selected_instance_id() {
var instance_id = $("#details_table tr.info td.instance_id").text();
return instance_id;
}

function get_instance(instance_id) {

var instance = null;
Expand Down Expand Up @@ -626,6 +656,8 @@ function show_instance_details(instance_id) {
return;
}

$("#phantom_details_button_div").show();

g_selected_instance = instance_id;

var data = make_row("Instance ID", instance.instance_id) +
Expand Down Expand Up @@ -777,7 +809,7 @@ function phantom_domain_instance_terminate_click(instanceid, cloudname) {

var obj = $("#phantom_domain_instance_context_menu");
var msg = "Do you want to kill the VM instance ".concat(instanceid).concat("?");
var answer = confirm (msg);
var answer = confirm(msg);

if (!answer) {
return;
Expand All @@ -803,7 +835,7 @@ function phantom_domain_instance_replace_click(instanceid, cloudname) {

var obj = $("#phantom_domain_instance_context_menu");
var msg = "Do you want to kill and replace the VM instance ".concat(instanceid).concat("?");
var answer = confirm (msg);
var answer = confirm(msg);

if (!answer) {
return;
Expand Down
9 changes: 9 additions & 0 deletions phantomweb/templates/phantom_domain.html
Expand Up @@ -178,6 +178,15 @@ <h5 class="phantom_area_header magic-underline">Configuration for <span id="phan
<tbody id="instance_table_body">
</tbody>
</table>

<div id="phantom_details_button_div" class="control-group pull-right">
<input type="button" id="details_button_replace_vm" class="btn btn-mini" value="Replace"/>
<input type="button" id="details_button_terminate_vm" class="btn btn-mini btn-danger" value="Terminate"/>
</div>
<div style="clear: both"></div>
<!-- Hack that I don't understand, but is standard practice? Makes parent div inherit height of
contained elements
-->
</div>
</div>
</div>
Expand Down

0 comments on commit 95ffd00

Please sign in to comment.