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();
|
||||
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){
|
||||
$(this).parent().hide();
|
||||
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();
|
||||
|
||||
$.ajax({
|
||||
|
||||
@ -515,15 +515,10 @@ var midmenuItemCount = 20;
|
||||
function setBooleanField(value, $field) {
|
||||
if(value == "true")
|
||||
$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();
|
||||
}
|
||||
|
||||
function getBooleanField($field) {
|
||||
if($field.find("#icon").hasClass("tick_icon")==true)
|
||||
return "true";
|
||||
else // $field.find("#icon").hasClass("cross_icon")==true
|
||||
return "false";
|
||||
else
|
||||
$field.find("#icon").hide();
|
||||
}
|
||||
|
||||
function clearLeftMenu() {
|
||||
|
||||
@ -183,7 +183,30 @@ function templateJsonToDetailsTab(jsonObj) {
|
||||
if(jsonObj.size != null)
|
||||
$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
|
||||
@ -196,4 +219,60 @@ function setIconByOsType(osType, $field) {
|
||||
$field.attr("src", "images/midmenuicon_template_windows.png");
|
||||
else
|
||||
$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"));
|
||||
|
||||
/*
|
||||
var $actionLink = $detailsTab.find("#action_link");
|
||||
$actionLink.bind("mouseover", function(event) {
|
||||
$(this).find("#action_menu").show();
|
||||
@ -72,9 +73,11 @@ function volumeJsonToDetailsTab(jsonObj){
|
||||
$actionLink.bind("mouseout", function(event) {
|
||||
$(this).find("#action_menu").hide();
|
||||
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();
|
||||
if(jsonObj.type=="ROOT") { //"create template" is allowed(when stopped), "detach disk" is disallowed.
|
||||
if (jsonObj.vmstate == "Stopped")
|
||||
@ -84,13 +87,7 @@ function volumeJsonToDetailsTab(jsonObj){
|
||||
buildActionLinkForDetailsTab("Detach Disk", volumeActionMap, $actionMenu, volumeListAPIMap);
|
||||
}
|
||||
}
|
||||
|
||||
var volumeListAPIMap = {
|
||||
listAPI: "listVolumes",
|
||||
listAPIResponse: "listvolumesresponse",
|
||||
listAPIResponseObj: "volume"
|
||||
};
|
||||
|
||||
|
||||
var volumeActionMap = {
|
||||
"Detach Disk": {
|
||||
api: "detachVolume",
|
||||
@ -108,14 +105,19 @@ var volumeActionMap = {
|
||||
}
|
||||
}
|
||||
|
||||
var volumeListAPIMap = {
|
||||
listAPI: "listVolumes",
|
||||
listAPIResponse: "listvolumesresponse",
|
||||
listAPIResponseObj: "volume"
|
||||
};
|
||||
|
||||
function doCreateTemplateFromVolume($actionLink, listAPIMap, $detailsTab) {
|
||||
var jsonObj = $detailsTab.data("jsonObj");
|
||||
$("#dialog_create_template").find("#volume_name").text(jsonObj.name);
|
||||
|
||||
$("#dialog_create_template")
|
||||
.dialog('option', 'buttons', {
|
||||
"Create": function() {
|
||||
//debugger;
|
||||
"Create": function() {
|
||||
var thisDialog = $(this);
|
||||
thisDialog.dialog("close");
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user