mirror of https://github.com/apache/cloudstack.git
new UI - snapshots page - implement create template from snapshot action.
This commit is contained in:
parent
e8a16e052c
commit
ea5d33315d
|
|
@ -141,3 +141,36 @@
|
|||
</div>
|
||||
</div>
|
||||
<!-- Add Volume Dialog from Snapshot (end) -->
|
||||
|
||||
<!-- Create template from snapshot (begin) -->
|
||||
<div id="dialog_create_template_from_snapshot" title="Create Template from Snapshot" style="display:none">
|
||||
<div class="dialog_formcontent">
|
||||
<form action="#" method="post" id="form6">
|
||||
<ol>
|
||||
<li>
|
||||
<label>Name:</label>
|
||||
<input class="text" type="text" id="name" style="width:250px"/>
|
||||
<div id="name_errormsg" class="dialog_formcontent_errormsg" style="display:none;"></div>
|
||||
</li>
|
||||
<li>
|
||||
<label>Display Text:</label>
|
||||
<input class="text" type="text" id="display_text" style="width:250px"/>
|
||||
<div id="display_text_errormsg" class="dialog_formcontent_errormsg" style="display:none;"></div>
|
||||
</li>
|
||||
<li>
|
||||
<label>OS Type:</label>
|
||||
<select class="select" id="os_type">
|
||||
</select>
|
||||
</li>
|
||||
<li>
|
||||
<label>Password Enabled?:</label>
|
||||
<select class="select" id="password">
|
||||
<option value="false">No</option>
|
||||
<option value="true">Yes</option>
|
||||
</select>
|
||||
</li>
|
||||
</ol>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
<!-- Create template from snapshot (end) -->
|
||||
|
|
|
|||
|
|
@ -1,9 +1,32 @@
|
|||
function afterLoadSnapshotJSP() {
|
||||
//initialize dialog
|
||||
activateDialog($("#dialog_add_volume_from_snapshot").dialog({
|
||||
autoOpen: false,
|
||||
modal: true,
|
||||
zIndex: 2000
|
||||
}));
|
||||
}));
|
||||
activateDialog($("#dialog_create_template_from_snapshot").dialog({
|
||||
width: 400,
|
||||
autoOpen: false,
|
||||
modal: true,
|
||||
zIndex: 2000
|
||||
}));
|
||||
|
||||
//populate dropdown
|
||||
$.ajax({
|
||||
data: createURL("command=listOsTypes"),
|
||||
dataType: "json",
|
||||
success: function(json) {
|
||||
types = json.listostypesresponse.ostype;
|
||||
if (types != null && types.length > 0) {
|
||||
var osTypeField = $("#dialog_create_template_from_snapshot").find("#os_type").empty();
|
||||
for (var i = 0; i < types.length; i++) {
|
||||
var html = "<option value='" + types[i].id + "'>" + types[i].description + "</option>";
|
||||
osTypeField.append(html);
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
function snapshotToMidmenu(jsonObj, $midmenuItem1) {
|
||||
|
|
@ -37,7 +60,8 @@ function snapshotJsonToDetailsTab(jsonObj) {
|
|||
var $actionMenu = $("#right_panel_content #tab_content_details #action_link #action_menu");
|
||||
$actionMenu.find("#action_list").empty();
|
||||
buildActionLinkForDetailsTab("Create Volume", snapshotActionMap, $actionMenu, snapshotListAPIMap);
|
||||
buildActionLinkForDetailsTab("Delete snapshot", snapshotActionMap, $actionMenu, snapshotListAPIMap);
|
||||
buildActionLinkForDetailsTab("Delete Snapshot", snapshotActionMap, $actionMenu, snapshotListAPIMap);
|
||||
buildActionLinkForDetailsTab("Create Template", snapshotActionMap, $actionMenu, snapshotListAPIMap);
|
||||
}
|
||||
|
||||
function snapshotClearRightPanel() {
|
||||
|
|
@ -60,7 +84,7 @@ var snapshotActionMap = {
|
|||
afterActionSeccessFn: function(jsonObj) {}
|
||||
}
|
||||
,
|
||||
"Delete snapshot": {
|
||||
"Delete Snapshot": {
|
||||
api: "deleteSnapshot",
|
||||
isAsyncJob: true,
|
||||
asyncJobResponse: "deletesnapshotresponse",
|
||||
|
|
@ -72,6 +96,14 @@ var snapshotActionMap = {
|
|||
snapshotClearRightPanel();
|
||||
}
|
||||
}
|
||||
,
|
||||
"Create Template": {
|
||||
isAsyncJob: true,
|
||||
asyncJobResponse: "createtemplateresponse",
|
||||
dialogBeforeActionFn : doCreateTemplateFromSnapshotInSnapshotPage,
|
||||
inProcessText: "Creating Template....",
|
||||
afterActionSeccessFn: function(jsonObj) {}
|
||||
}
|
||||
}
|
||||
|
||||
var snapshotListAPIMap = {
|
||||
|
|
@ -104,4 +136,33 @@ function doCreateVolumeFromSnapshotInSnapshotPage($actionLink, listAPIMap, $deta
|
|||
$(this).dialog("close");
|
||||
}
|
||||
}).dialog("open");
|
||||
}
|
||||
|
||||
function doCreateTemplateFromSnapshotInSnapshotPage($actionLink, listAPIMap, $detailsTab) {
|
||||
var jsonObj = $detailsTab.data("jsonObj");
|
||||
|
||||
$("#dialog_create_template_from_snapshot")
|
||||
.dialog("option", "buttons", {
|
||||
"Add": function() {
|
||||
var thisDialog = $(this);
|
||||
var isValid = true;
|
||||
isValid &= validateString("Name", thisDialog.find("#name"), thisDialog.find("#name_errormsg"), false);
|
||||
isValid &= validateString("Display Text", thisDialog.find("#display_text"), thisDialog.find("#display_text_errormsg"), false);
|
||||
if (!isValid) return;
|
||||
|
||||
thisDialog.dialog("close");
|
||||
|
||||
var name = thisDialog.find("#name").val();
|
||||
var displayText = thisDialog.find("#display_text").val();
|
||||
var osTypeId = thisDialog.find("#os_type").val();
|
||||
var password = thisDialog.find("#password").val();
|
||||
|
||||
var id = jsonObj.id;
|
||||
var apiCommand = "command=createTemplate&snapshotid="+id+"&name="+name+"&displaytext="+displayText+"&ostypeid="+osTypeId+"&passwordEnabled="+password;
|
||||
doActionToDetailsTab(id, $actionLink, apiCommand, listAPIMap);
|
||||
},
|
||||
"Cancel": function() {
|
||||
$(this).dialog("close");
|
||||
}
|
||||
}).dialog("open");
|
||||
}
|
||||
Loading…
Reference in New Issue