Skip to content

Commit 98af560

Browse files
author
Jessica Wang
committed
CLOUDSTACK-4796: UI > Instances > detailView > add new action "Assign Instance to Another Account".
1 parent b63270f commit 98af560

1 file changed

Lines changed: 77 additions & 4 deletions

File tree

‎ui/scripts/instances.js‎

Lines changed: 77 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1336,8 +1336,6 @@
13361336
});
13371337
}
13381338
}
1339-
1340-
13411339
}
13421340
},
13431341

@@ -1378,9 +1376,79 @@
13781376
notification: {
13791377
poll: pollAsyncJobResult
13801378
}
1381-
13821379
},
1383-
1380+
1381+
assignVmToAnotherAccount: {
1382+
label: 'Assign Instance to Another Account',
1383+
createForm: {
1384+
title: 'Assign Instance to Another Account',
1385+
fields: {
1386+
domainid: {
1387+
label: 'label.domain',
1388+
validation: {
1389+
required: true
1390+
},
1391+
select: function(args) {
1392+
$.ajax({
1393+
url: createURL('listDomains'),
1394+
data: {
1395+
listAll: true,
1396+
details: 'min'
1397+
},
1398+
success: function(json) {
1399+
var array1 = [];
1400+
var domains = json.listdomainsresponse.domain;
1401+
if (domains != null && domains.length > 0) {
1402+
for (var i = 0; i < domains.length; i++) {
1403+
array1.push({
1404+
id: domains[i].id,
1405+
description: domains[i].path
1406+
});
1407+
}
1408+
}
1409+
args.response.success({
1410+
data: array1
1411+
});
1412+
}
1413+
});
1414+
}
1415+
},
1416+
account: {
1417+
label: 'label.account',
1418+
validation: {
1419+
required: true
1420+
}
1421+
}
1422+
}
1423+
},
1424+
action: function(args) {
1425+
$.ajax({
1426+
url: createURL('assignVirtualMachine&virtualmachine'),
1427+
data: {
1428+
virtualmachineid: args.context.instances[0].id,
1429+
domainid: args.data.domainid,
1430+
account: args.data.account
1431+
},
1432+
success: function(json) {
1433+
var item = json.virtualmachine.virtualmachine;
1434+
args.response.success({
1435+
data: item
1436+
});
1437+
}
1438+
});
1439+
},
1440+
messages: {
1441+
notification: function(args) {
1442+
return 'Assign Instance to Another Account';
1443+
}
1444+
},
1445+
notification: {
1446+
poll: function(args) {
1447+
args.complete();
1448+
}
1449+
}
1450+
},
1451+
13841452
viewConsole: {
13851453
label: 'label.view.console',
13861454
action: {
@@ -1936,6 +2004,11 @@
19362004
if (jsonObj.hypervisor == "BareMetal") {
19372005
allowedActions.push("createTemplate");
19382006
}
2007+
2008+
if (isAdmin() || isDomainAdmin()) {
2009+
allowedActions.push("assignVmToAnotherAccount");
2010+
}
2011+
19392012
} else if (jsonObj.state == 'Starting') {
19402013
// allowedActions.push("stop");
19412014
} else if (jsonObj.state == 'Error') {

0 commit comments

Comments
 (0)