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() {
var listView = $.extend(true, {}, cloudStack.sections.system.subsections.virtualRouters.listView, {
//???
actions: {
upgradeRouterToUseNewerTemplate: {
isHeader: true,
@ -7400,7 +7398,7 @@
label: 'Upgrade Router to Use Newer Template',
messages: {
notification: function(args) {
notification: function (args) {
return 'Upgrade Router to Use Newer Template';
}
},
@ -7410,18 +7408,24 @@
fields: {
zoneid: {
label: 'label.zone',
select: function(args) {
var items = [{ id: '', description: '' }];
select: function (args) {
var items = [{
id: '',
description: ''
}];
$.ajax({
url: createURL('listZones'),
data: {
listAll: true
},
success: function(json) {
success: function (json) {
var objs = json.listzonesresponse.zone;
if (objs != null) {
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({
@ -7435,7 +7439,10 @@
label: 'Pod',
dependsOn: 'zoneid',
select: function (args) {
var items = [{ id: '', description: '' }];
var items = [{
id: '',
description: ''
}];
if (args.zoneid.length > 0) {
$.ajax({
url: createURL('listPods'),
@ -7446,7 +7453,10 @@
var objs = json.listpodsresponse.pod;
if (objs != null) {
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({
@ -7464,19 +7474,25 @@
clusterid: {
label: 'label.cluster',
dependsOn: 'podid',
select: function(args) {
var items = [{ id: '', description: '' }];
select: function (args) {
var items = [{
id: '',
description: ''
}];
if (args.podid.length > 0) {
$.ajax({
url: createURL('listClusters'),
data: {
podid: args.podid
},
success: function(json) {
success: function (json) {
var objs = json.listclustersresponse.cluster;
if (objs != null) {
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({
@ -7494,7 +7510,7 @@
}
},
action: function(args) {
action: function (args) {
var data = {};
if (args.data.clusterid.length > 0) {
$.extend(data, {
@ -7509,14 +7525,14 @@
zoneid: args.data.zoneid
});
} 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;
}
$.ajax({
url: createURL('upgradeRouterTemplate'),
data: data,
success: function(json) {
success: function (json) {
//example
/*
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': {
label: 'label.destroy.router',
messages: {
@ -17491,6 +17540,8 @@
var jsonObj = args.context.item;
var allowedActions = [];
allowedActions.push('upgradeRouterToUseNewerTemplate');
if (jsonObj.state == 'Running') {
allowedActions.push("stop");