mirror of
https://github.com/apache/cloudstack.git
synced 2025-10-26 08:42:29 +01:00
VM snapshot: Make multi-select action
This commit is contained in:
parent
f930ccda99
commit
0db10ad55c
@ -16,10 +16,90 @@
|
|||||||
// under the License.
|
// under the License.
|
||||||
(function($, cloudStack) {
|
(function($, cloudStack) {
|
||||||
var vmMigrationHostObjs;
|
var vmMigrationHostObjs;
|
||||||
|
|
||||||
|
var vmSnapshotAction = function(args) {
|
||||||
|
var action = {
|
||||||
|
messages: {
|
||||||
|
notification: function(args) {
|
||||||
|
return 'label.action.vmsnapshot.create';
|
||||||
|
}
|
||||||
|
},
|
||||||
|
label: 'label.action.vmsnapshot.create',
|
||||||
|
addRow: 'false',
|
||||||
|
createForm: {
|
||||||
|
title: 'label.action.vmsnapshot.create',
|
||||||
|
fields: {
|
||||||
|
name: {
|
||||||
|
label: 'label.name',
|
||||||
|
isInput: true
|
||||||
|
},
|
||||||
|
description: {
|
||||||
|
label: 'label.description',
|
||||||
|
isTextarea: true
|
||||||
|
},
|
||||||
|
snapshotMemory: {
|
||||||
|
label: 'label.vmsnapshot.memory',
|
||||||
|
isBoolean: true,
|
||||||
|
isChecked: false
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
action: function(args) {
|
||||||
|
var instances = args.context.instances;
|
||||||
|
|
||||||
|
$(instances).map(function(index, instance) {
|
||||||
|
var array1 = [];
|
||||||
|
array1.push("&snapshotmemory=" + (args.data.snapshotMemory == "on"));
|
||||||
|
var displayname = args.data.name;
|
||||||
|
if (displayname != null && displayname.length > 0) {
|
||||||
|
array1.push("&name=" + todb(displayname));
|
||||||
|
}
|
||||||
|
var description = args.data.description;
|
||||||
|
if (description != null && description.length > 0) {
|
||||||
|
array1.push("&description=" + todb(description));
|
||||||
|
}
|
||||||
|
$.ajax({
|
||||||
|
url: createURL("createVMSnapshot&virtualmachineid=" + instance.id + array1.join("")),
|
||||||
|
dataType: "json",
|
||||||
|
async: true,
|
||||||
|
success: function(json) {
|
||||||
|
var jid = json.createvmsnapshotresponse.jobid;
|
||||||
|
args.response.success({
|
||||||
|
_custom: {
|
||||||
|
jobId: jid,
|
||||||
|
getUpdatedItem: function(json) {
|
||||||
|
return json.queryasyncjobresultresponse.jobresult.virtualmachine;
|
||||||
|
},
|
||||||
|
getActionFilter: function() {
|
||||||
|
return vmActionfilter;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
},
|
||||||
|
notification: {
|
||||||
|
poll: pollAsyncJobResult
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
if (args && args.listView) {
|
||||||
|
$.extend(action, {
|
||||||
|
isHeader: true,
|
||||||
|
isMultiSelectAction: true
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
return action;
|
||||||
|
};
|
||||||
|
|
||||||
cloudStack.sections.instances = {
|
cloudStack.sections.instances = {
|
||||||
title: 'label.instances',
|
title: 'label.instances',
|
||||||
id: 'instances',
|
id: 'instances',
|
||||||
listView: {
|
listView: {
|
||||||
|
multiSelect: true,
|
||||||
section: 'instances',
|
section: 'instances',
|
||||||
filters: {
|
filters: {
|
||||||
all: {
|
all: {
|
||||||
@ -181,7 +261,8 @@
|
|||||||
notification: {
|
notification: {
|
||||||
poll: pollAsyncJobResult
|
poll: pollAsyncJobResult
|
||||||
}
|
}
|
||||||
}
|
},
|
||||||
|
snapshot: vmSnapshotAction({ listView: true })
|
||||||
},
|
},
|
||||||
|
|
||||||
dataProvider: function(args) {
|
dataProvider: function(args) {
|
||||||
@ -246,7 +327,6 @@
|
|||||||
success: function(json) {
|
success: function(json) {
|
||||||
var items = json.listvirtualmachinesresponse.virtualmachine;
|
var items = json.listvirtualmachinesresponse.virtualmachine;
|
||||||
args.response.success({
|
args.response.success({
|
||||||
actionFilter: vmActionfilter,
|
|
||||||
data: items
|
data: items
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@ -470,68 +550,7 @@
|
|||||||
poll: pollAsyncJobResult
|
poll: pollAsyncJobResult
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
snapshot: {
|
snapshot: vmSnapshotAction(),
|
||||||
messages: {
|
|
||||||
notification: function(args) {
|
|
||||||
return 'label.action.vmsnapshot.create';
|
|
||||||
}
|
|
||||||
},
|
|
||||||
label: 'label.action.vmsnapshot.create',
|
|
||||||
addRow: 'false',
|
|
||||||
createForm: {
|
|
||||||
title: 'label.action.vmsnapshot.create',
|
|
||||||
fields: {
|
|
||||||
name: {
|
|
||||||
label: 'label.name',
|
|
||||||
isInput: true
|
|
||||||
},
|
|
||||||
description: {
|
|
||||||
label: 'label.description',
|
|
||||||
isTextarea: true
|
|
||||||
},
|
|
||||||
snapshotMemory: {
|
|
||||||
label: 'label.vmsnapshot.memory',
|
|
||||||
isBoolean: true,
|
|
||||||
isChecked: false
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
action: function(args) {
|
|
||||||
var array1 = [];
|
|
||||||
array1.push("&snapshotmemory=" + (args.data.snapshotMemory == "on"));
|
|
||||||
var displayname = args.data.name;
|
|
||||||
if (displayname != null && displayname.length > 0) {
|
|
||||||
array1.push("&name=" + todb(displayname));
|
|
||||||
}
|
|
||||||
var description = args.data.description;
|
|
||||||
if (description != null && description.length > 0) {
|
|
||||||
array1.push("&description=" + todb(description));
|
|
||||||
}
|
|
||||||
$.ajax({
|
|
||||||
url: createURL("createVMSnapshot&virtualmachineid=" + args.context.instances[0].id + array1.join("")),
|
|
||||||
dataType: "json",
|
|
||||||
async: true,
|
|
||||||
success: function(json) {
|
|
||||||
var jid = json.createvmsnapshotresponse.jobid;
|
|
||||||
args.response.success({
|
|
||||||
_custom: {
|
|
||||||
jobId: jid,
|
|
||||||
getUpdatedItem: function(json) {
|
|
||||||
return json.queryasyncjobresultresponse.jobresult.virtualmachine;
|
|
||||||
},
|
|
||||||
getActionFilter: function() {
|
|
||||||
return vmActionfilter;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
},
|
|
||||||
notification: {
|
|
||||||
poll: pollAsyncJobResult
|
|
||||||
}
|
|
||||||
},
|
|
||||||
destroy: {
|
destroy: {
|
||||||
label: 'label.action.destroy.instance',
|
label: 'label.action.destroy.instance',
|
||||||
compactLabel: 'label.destroy',
|
compactLabel: 'label.destroy',
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user