mirror of
https://github.com/apache/cloudstack.git
synced 2025-10-26 08:42:29 +01:00
new UI - template page - implement delete action.
This commit is contained in:
parent
40db8f60e0
commit
b7d6ae6406
@ -29,12 +29,22 @@ $(document).ready(function() {
|
|||||||
clearLeftMenu();
|
clearLeftMenu();
|
||||||
clearMidMenu();
|
clearMidMenu();
|
||||||
|
|
||||||
$("#right_panel").load(rightPanelJSP, function(){
|
$("#right_panel").load(rightPanelJSP, function(){
|
||||||
|
|
||||||
$("#right_panel_content #tab_content_details #action_message_box #close_button").bind("click", function(event){
|
$("#right_panel_content #tab_content_details #action_message_box #close_button").bind("click", function(event){
|
||||||
$(this).parent().hide();
|
$(this).parent().hide();
|
||||||
return false;
|
return false;
|
||||||
});
|
});
|
||||||
|
|
||||||
|
var $actionLink = $("#right_panel_content #tab_content_details #action_link");
|
||||||
|
$actionLink.bind("mouseover", function(event) {
|
||||||
|
$(this).find("#action_menu").show();
|
||||||
|
return false;
|
||||||
|
});
|
||||||
|
$actionLink.bind("mouseout", function(event) {
|
||||||
|
$(this).find("#action_menu").hide();
|
||||||
|
return false;
|
||||||
|
});
|
||||||
|
|
||||||
afterLoadRightPanelJSP();
|
afterLoadRightPanelJSP();
|
||||||
|
|
||||||
$.ajax({
|
$.ajax({
|
||||||
|
|||||||
@ -515,15 +515,10 @@ var midmenuItemCount = 20;
|
|||||||
function setBooleanField(value, $field) {
|
function setBooleanField(value, $field) {
|
||||||
if(value == "true")
|
if(value == "true")
|
||||||
$field.find("#icon").removeClass("cross_icon").addClass("tick_icon").show();
|
$field.find("#icon").removeClass("cross_icon").addClass("tick_icon").show();
|
||||||
else // value == "false"
|
else if(value == "false")
|
||||||
$field.find("#icon").removeClass("tick_icon").addClass("cross_icon").show();
|
$field.find("#icon").removeClass("tick_icon").addClass("cross_icon").show();
|
||||||
}
|
else
|
||||||
|
$field.find("#icon").hide();
|
||||||
function getBooleanField($field) {
|
|
||||||
if($field.find("#icon").hasClass("tick_icon")==true)
|
|
||||||
return "true";
|
|
||||||
else // $field.find("#icon").hasClass("cross_icon")==true
|
|
||||||
return "false";
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function clearLeftMenu() {
|
function clearLeftMenu() {
|
||||||
|
|||||||
@ -183,7 +183,30 @@ function templateJsonToDetailsTab(jsonObj) {
|
|||||||
if(jsonObj.size != null)
|
if(jsonObj.size != null)
|
||||||
$detailsTab.find("#size").text(convertBytes(parseInt(jsonObj.size)));
|
$detailsTab.find("#size").text(convertBytes(parseInt(jsonObj.size)));
|
||||||
|
|
||||||
setDateField(jsonObj.created, $detailsTab.find("#created"));
|
setDateField(jsonObj.created, $detailsTab.find("#created"));
|
||||||
|
|
||||||
|
//actions ***
|
||||||
|
var $actionMenu = $("#right_panel_content #tab_content_details #action_link #action_menu");
|
||||||
|
$actionMenu.find("#action_list").empty();
|
||||||
|
|
||||||
|
// action Edit, Copy, Create VM
|
||||||
|
if ((isUser() && jsonObj.ispublic == "true" && !(jsonObj.domainid == g_domainid && jsonObj.account == g_account)) || jsonObj.id==DomRTemplateId || jsonObj.isready == "false") {
|
||||||
|
//template.find("#template_edit_container, #template_copy_container, #template_create_vm_container").hide();
|
||||||
|
$("edit_button").hide();
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
$("edit_button").show();
|
||||||
|
//buildActionLinkForDetailsTab("Copy Template", templateActionMap, $actionMenu, templateListAPIMap);
|
||||||
|
//buildActionLinkForDetailsTab("Create VM", templateActionMap, $actionMenu, templateListAPIMap);
|
||||||
|
}
|
||||||
|
|
||||||
|
// action Delete
|
||||||
|
if (((isUser() && jsonObj.ispublic == "true" && !(jsonObj.domainid == g_domainid && jsonObj.account == g_account)) || jsonObj.id==DomRTemplateId) || (jsonObj.isready == "false" && jsonObj.templatestatus != null && jsonObj.templatestatus.indexOf("% Downloaded") != -1)) {
|
||||||
|
//template.find("#template_delete_container").hide();
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
buildActionLinkForDetailsTab("Delete Template", templateActionMap, $actionMenu, templateListAPIMap);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//setIconByOsType() is shared by template page and ISO page
|
//setIconByOsType() is shared by template page and ISO page
|
||||||
@ -196,4 +219,60 @@ function setIconByOsType(osType, $field) {
|
|||||||
$field.attr("src", "images/midmenuicon_template_windows.png");
|
$field.attr("src", "images/midmenuicon_template_windows.png");
|
||||||
else
|
else
|
||||||
$field.attr("src", "images/midmenuicon_template_linux.png");
|
$field.attr("src", "images/midmenuicon_template_linux.png");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function templateClearRightPanel() {
|
||||||
|
var $detailsTab = $("#right_panel_content #tab_content_details");
|
||||||
|
$detailsTab.data("jsonObj", null);
|
||||||
|
$detailsTab.find("#id").text("");
|
||||||
|
$detailsTab.find("#zonename").text("");
|
||||||
|
|
||||||
|
$detailsTab.find("#name").text("");
|
||||||
|
$detailsTab.find("#name_edit").val("");
|
||||||
|
|
||||||
|
$detailsTab.find("#displaytext").text("");
|
||||||
|
$detailsTab.find("#displaytext_edit").val("");
|
||||||
|
|
||||||
|
$detailsTab.find("#status").text("");
|
||||||
|
|
||||||
|
setBooleanField(null, $detailsTab.find("#passwordenabled"));
|
||||||
|
$detailsTab.find("#passwordenabled_edit").val(null);
|
||||||
|
|
||||||
|
setBooleanField(null, $detailsTab.find("#ispublic"));
|
||||||
|
$detailsTab.find("#ispublic_edit").val(null);
|
||||||
|
|
||||||
|
setBooleanField(null, $detailsTab.find("#isfeatured"));
|
||||||
|
$detailsTab.find("#isfeatured_edit").val(null);
|
||||||
|
|
||||||
|
setBooleanField(null, $detailsTab.find("#crossZones"));
|
||||||
|
|
||||||
|
$detailsTab.find("#ostypename").text("");
|
||||||
|
$detailsTab.find("#ostypename_edit").val(null);
|
||||||
|
|
||||||
|
$detailsTab.find("#account").text("");
|
||||||
|
$detailsTab.find("#size").text("");
|
||||||
|
$detailsTab.find("#created").text("");
|
||||||
|
}
|
||||||
|
|
||||||
|
var templateActionMap = {
|
||||||
|
"Delete Template": {
|
||||||
|
api: "deleteTemplate",
|
||||||
|
isAsyncJob: true,
|
||||||
|
asyncJobResponse: "deletetemplateresponse",
|
||||||
|
inProcessText: "Deleting Template....",
|
||||||
|
afterActionSeccessFn: function(jsonObj) {
|
||||||
|
var $midmenuItem1 = $("#midmenuItem_"+jsonObj.id);
|
||||||
|
$midmenuItem1.remove();
|
||||||
|
clearRightPanel();
|
||||||
|
templateClearRightPanel();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
var templateListAPIMap = {
|
||||||
|
listAPI: "listTemplates&templatefilter=self",
|
||||||
|
listAPIResponse: "listtemplatesresponse",
|
||||||
|
listAPIResponseObj: "template"
|
||||||
|
};
|
||||||
|
|
||||||
|
var DomRTemplateId = 1;
|
||||||
@ -64,6 +64,7 @@ function volumeJsonToDetailsTab(jsonObj){
|
|||||||
|
|
||||||
setDateField(jsonObj.created, $detailsTab.find("#created"));
|
setDateField(jsonObj.created, $detailsTab.find("#created"));
|
||||||
|
|
||||||
|
/*
|
||||||
var $actionLink = $detailsTab.find("#action_link");
|
var $actionLink = $detailsTab.find("#action_link");
|
||||||
$actionLink.bind("mouseover", function(event) {
|
$actionLink.bind("mouseover", function(event) {
|
||||||
$(this).find("#action_menu").show();
|
$(this).find("#action_menu").show();
|
||||||
@ -72,9 +73,11 @@ function volumeJsonToDetailsTab(jsonObj){
|
|||||||
$actionLink.bind("mouseout", function(event) {
|
$actionLink.bind("mouseout", function(event) {
|
||||||
$(this).find("#action_menu").hide();
|
$(this).find("#action_menu").hide();
|
||||||
return false;
|
return false;
|
||||||
});
|
});
|
||||||
|
*/
|
||||||
var $actionMenu = $actionLink.find("#action_menu");
|
|
||||||
|
//actions ***
|
||||||
|
var $actionMenu = $("#right_panel_content #tab_content_details #action_link #action_menu");
|
||||||
$actionMenu.find("#action_list").empty();
|
$actionMenu.find("#action_list").empty();
|
||||||
if(jsonObj.type=="ROOT") { //"create template" is allowed(when stopped), "detach disk" is disallowed.
|
if(jsonObj.type=="ROOT") { //"create template" is allowed(when stopped), "detach disk" is disallowed.
|
||||||
if (jsonObj.vmstate == "Stopped")
|
if (jsonObj.vmstate == "Stopped")
|
||||||
@ -84,13 +87,7 @@ function volumeJsonToDetailsTab(jsonObj){
|
|||||||
buildActionLinkForDetailsTab("Detach Disk", volumeActionMap, $actionMenu, volumeListAPIMap);
|
buildActionLinkForDetailsTab("Detach Disk", volumeActionMap, $actionMenu, volumeListAPIMap);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
var volumeListAPIMap = {
|
|
||||||
listAPI: "listVolumes",
|
|
||||||
listAPIResponse: "listvolumesresponse",
|
|
||||||
listAPIResponseObj: "volume"
|
|
||||||
};
|
|
||||||
|
|
||||||
var volumeActionMap = {
|
var volumeActionMap = {
|
||||||
"Detach Disk": {
|
"Detach Disk": {
|
||||||
api: "detachVolume",
|
api: "detachVolume",
|
||||||
@ -108,14 +105,19 @@ var volumeActionMap = {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var volumeListAPIMap = {
|
||||||
|
listAPI: "listVolumes",
|
||||||
|
listAPIResponse: "listvolumesresponse",
|
||||||
|
listAPIResponseObj: "volume"
|
||||||
|
};
|
||||||
|
|
||||||
function doCreateTemplateFromVolume($actionLink, listAPIMap, $detailsTab) {
|
function doCreateTemplateFromVolume($actionLink, listAPIMap, $detailsTab) {
|
||||||
var jsonObj = $detailsTab.data("jsonObj");
|
var jsonObj = $detailsTab.data("jsonObj");
|
||||||
$("#dialog_create_template").find("#volume_name").text(jsonObj.name);
|
$("#dialog_create_template").find("#volume_name").text(jsonObj.name);
|
||||||
|
|
||||||
$("#dialog_create_template")
|
$("#dialog_create_template")
|
||||||
.dialog('option', 'buttons', {
|
.dialog('option', 'buttons', {
|
||||||
"Create": function() {
|
"Create": function() {
|
||||||
//debugger;
|
|
||||||
var thisDialog = $(this);
|
var thisDialog = $(this);
|
||||||
thisDialog.dialog("close");
|
thisDialog.dialog("close");
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user