CLOUDSTACK-4793: UI > Virtual Routers > add new action "Upgrade Router to Newer Template" in detailView.

This commit is contained in:
Jessica Wang 2013-11-19 16:14:47 -08:00
parent d6a38c238a
commit 829f1db6e8

View File

@ -7391,8 +7391,6 @@
}, },
virtualRouters: function() { virtualRouters: function() {
var listView = $.extend(true, {}, cloudStack.sections.system.subsections.virtualRouters.listView, { var listView = $.extend(true, {}, cloudStack.sections.system.subsections.virtualRouters.listView, {
//???
actions: { actions: {
upgradeRouterToUseNewerTemplate: { upgradeRouterToUseNewerTemplate: {
isHeader: true, isHeader: true,
@ -7400,7 +7398,7 @@
label: 'Upgrade Router to Use Newer Template', label: 'Upgrade Router to Use Newer Template',
messages: { messages: {
notification: function(args) { notification: function (args) {
return 'Upgrade Router to Use Newer Template'; return 'Upgrade Router to Use Newer Template';
} }
}, },
@ -7410,18 +7408,24 @@
fields: { fields: {
zoneid: { zoneid: {
label: 'label.zone', label: 'label.zone',
select: function(args) { select: function (args) {
var items = [{ id: '', description: '' }]; var items = [{
id: '',
description: ''
}];
$.ajax({ $.ajax({
url: createURL('listZones'), url: createURL('listZones'),
data: { data: {
listAll: true listAll: true
}, },
success: function(json) { success: function (json) {
var objs = json.listzonesresponse.zone; var objs = json.listzonesresponse.zone;
if (objs != null) { if (objs != null) {
for (var i = 0; i < objs.length; i++) { for (var i = 0; i < objs.length; i++) {
items.push({ id: objs[i].id, description: objs[i].name }); items.push({
id: objs[i].id,
description: objs[i].name
});
} }
} }
args.response.success({ args.response.success({
@ -7435,7 +7439,10 @@
label: 'Pod', label: 'Pod',
dependsOn: 'zoneid', dependsOn: 'zoneid',
select: function (args) { select: function (args) {
var items = [{ id: '', description: '' }]; var items = [{
id: '',
description: ''
}];
if (args.zoneid.length > 0) { if (args.zoneid.length > 0) {
$.ajax({ $.ajax({
url: createURL('listPods'), url: createURL('listPods'),
@ -7446,7 +7453,10 @@
var objs = json.listpodsresponse.pod; var objs = json.listpodsresponse.pod;
if (objs != null) { if (objs != null) {
for (var i = 0; i < objs.length; i++) { for (var i = 0; i < objs.length; i++) {
items.push({ id: objs[i].id, description: objs[i].name }); items.push({
id: objs[i].id,
description: objs[i].name
});
} }
} }
args.response.success({ args.response.success({
@ -7464,19 +7474,25 @@
clusterid: { clusterid: {
label: 'label.cluster', label: 'label.cluster',
dependsOn: 'podid', dependsOn: 'podid',
select: function(args) { select: function (args) {
var items = [{ id: '', description: '' }]; var items = [{
id: '',
description: ''
}];
if (args.podid.length > 0) { if (args.podid.length > 0) {
$.ajax({ $.ajax({
url: createURL('listClusters'), url: createURL('listClusters'),
data: { data: {
podid: args.podid podid: args.podid
}, },
success: function(json) { success: function (json) {
var objs = json.listclustersresponse.cluster; var objs = json.listclustersresponse.cluster;
if (objs != null) { if (objs != null) {
for (var i = 0; i < objs.length; i++) { for (var i = 0; i < objs.length; i++) {
items.push({ id: objs[i].id, description: objs[i].name }); items.push({
id: objs[i].id,
description: objs[i].name
});
} }
} }
args.response.success({ args.response.success({
@ -7494,7 +7510,7 @@
} }
}, },
action: function(args) { action: function (args) {
var data = {}; var data = {};
if (args.data.clusterid.length > 0) { if (args.data.clusterid.length > 0) {
$.extend(data, { $.extend(data, {
@ -7509,14 +7525,14 @@
zoneid: args.data.zoneid zoneid: args.data.zoneid
}); });
} else { } else {
args.response.error('Please specify a zone, a pod or a cluster.' ); args.response.error('Please specify a zone, a pod or a cluster.');
return; return;
} }
$.ajax({ $.ajax({
url: createURL('upgradeRouterTemplate'), url: createURL('upgradeRouterTemplate'),
data: data, data: data,
success: function(json) { success: function (json) {
//example //example
/* /*
json = { json = {
@ -8149,6 +8165,39 @@
} }
}, },
upgradeRouterToUseNewerTemplate: {
label: 'Upgrade Router to Use Newer Template',
messages: {
confirm: function(args) {
return 'Please confirm that you want to upgrade router to use newer template';
},
notification: function (args) {
return 'Upgrade Router to Use Newer Template';
}
},
action: function (args) {
$.ajax({
url: createURL('upgradeRouterTemplate'),
data: {
id: args.context.routers[0].id
},
success: function (json) {
var jobs = json.upgraderoutertemplateresponse.asyncjobs;
if (jobs != undefined) {
args.response.success({
_custom: {
jobId: jobs[0].jobid
}
});
}
}
});
},
notification: {
poll: pollAsyncJobResult
}
},
'remove': { 'remove': {
label: 'label.destroy.router', label: 'label.destroy.router',
messages: { messages: {
@ -17491,6 +17540,8 @@
var jsonObj = args.context.item; var jsonObj = args.context.item;
var allowedActions = []; var allowedActions = [];
allowedActions.push('upgradeRouterToUseNewerTemplate');
if (jsonObj.state == 'Running') { if (jsonObj.state == 'Running') {
allowedActions.push("stop"); allowedActions.push("stop");