You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cloudstack.apache.org by se...@apache.org on 2013/07/18 18:35:12 UTC
[37/39] Format JS
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/ad69bc8d/ui/scripts/affinity.js
----------------------------------------------------------------------
diff --git a/ui/scripts/affinity.js b/ui/scripts/affinity.js
index a9c6695..8a88694 100644
--- a/ui/scripts/affinity.js
+++ b/ui/scripts/affinity.js
@@ -15,169 +15,193 @@
// specific language governing permissions and limitations
// under the License.
(function(cloudStack) {
- cloudStack.sections.affinityGroups = {
- title: 'label.affinity.groups',
- listView: {
- id: 'affinityGroups',
- fields: {
- name: { label: 'label.name' },
- type: { label: 'label.type' }
- },
- dataProvider: function(args) {
- var data = {};
- if (args.context != null) {
- if ("instances" in args.context) {
- $.extend(data, {
- virtualmachineid: args.context.instances[0].id
- });
- }
- }
- $.ajax({
- url: createURL('listAffinityGroups'),
- data: data,
- success: function(json) {
- var items = json.listaffinitygroupsresponse.affinitygroup;
- args.response.success({data: items});
- }
- });
- },
- actions: {
- add: {
- label: 'label.add.affinity.group',
-
- messages: {
- notification: function(args) {
- return 'label.add.affinity.group';
- }
- },
-
- createForm: {
- title: 'label.add.affinity.group',
+ cloudStack.sections.affinityGroups = {
+ title: 'label.affinity.groups',
+ listView: {
+ id: 'affinityGroups',
fields: {
- name: {
- label: 'label.name',
- validation: { required: true }
- },
- description: {
- label: 'label.description'
- },
- type: {
- label: 'label.type',
- select: function(args) {
- $.ajax({
- url: createURL('listAffinityGroupTypes'),
- success: function(json) {
- var types = [];
- var items = json.listaffinitygrouptypesresponse.affinityGroupType;
- if(items != null) {
- for(var i = 0; i < items.length; i++) {
- types.push({id: items[i].type, description: items[i].type});
- }
- }
- args.response.success({data: types})
- }
- });
+ name: {
+ label: 'label.name'
+ },
+ type: {
+ label: 'label.type'
}
- }
- }
- },
+ },
+ dataProvider: function(args) {
+ var data = {};
+ if (args.context != null) {
+ if ("instances" in args.context) {
+ $.extend(data, {
+ virtualmachineid: args.context.instances[0].id
+ });
+ }
+ }
+ $.ajax({
+ url: createURL('listAffinityGroups'),
+ data: data,
+ success: function(json) {
+ var items = json.listaffinitygroupsresponse.affinitygroup;
+ args.response.success({
+ data: items
+ });
+ }
+ });
+ },
+ actions: {
+ add: {
+ label: 'label.add.affinity.group',
- action: function(args) {
- var data = {
- name: args.data.name,
- type: args.data.type
- };
- if(args.data.description != null && args.data.description.length > 0)
- $.extend(data, {description: args.data.description});
-
- $.ajax({
- url: createURL('createAffinityGroup'),
- data: data,
- success: function(json) {
- var jid = json.createaffinitygroupresponse.jobid;
- args.response.success(
- {_custom:
- {jobId: jid,
- getUpdatedItem: function(json) {
- return json.queryasyncjobresultresponse.jobresult.affinitygroup;
- }
- }
- }
- );
- }
- });
- },
+ messages: {
+ notification: function(args) {
+ return 'label.add.affinity.group';
+ }
+ },
- notification: {
- poll: pollAsyncJobResult
- }
- }
- },
- detailView: {
- actions: {
- remove: {
- label: 'label.delete.affinity.group',
- messages: {
- confirm: function(args) {
- return 'message.delete.affinity.group';
- },
- notification: function(args) {
- return 'label.delete.affinity.group';
- }
- },
- action: function(args) {
- $.ajax({
- url: createURL('deleteAffinityGroup'),
- data: {
- id: args.context.affinityGroups[0].id
- },
- success: function(json) {
- var jid = json.deleteaffinitygroupresponse.jobid;
- args.response.success({
- _custom:{
- jobId: jid
- }
- });
- }
- });
+ createForm: {
+ title: 'label.add.affinity.group',
+ fields: {
+ name: {
+ label: 'label.name',
+ validation: {
+ required: true
+ }
+ },
+ description: {
+ label: 'label.description'
+ },
+ type: {
+ label: 'label.type',
+ select: function(args) {
+ $.ajax({
+ url: createURL('listAffinityGroupTypes'),
+ success: function(json) {
+ var types = [];
+ var items = json.listaffinitygrouptypesresponse.affinityGroupType;
+ if (items != null) {
+ for (var i = 0; i < items.length; i++) {
+ types.push({
+ id: items[i].type,
+ description: items[i].type
+ });
+ }
+ }
+ args.response.success({
+ data: types
+ })
+ }
+ });
+ }
+ }
+ }
+ },
+
+ action: function(args) {
+ var data = {
+ name: args.data.name,
+ type: args.data.type
+ };
+ if (args.data.description != null && args.data.description.length > 0)
+ $.extend(data, {
+ description: args.data.description
+ });
+
+ $.ajax({
+ url: createURL('createAffinityGroup'),
+ data: data,
+ success: function(json) {
+ var jid = json.createaffinitygroupresponse.jobid;
+ args.response.success({
+ _custom: {
+ jobId: jid,
+ getUpdatedItem: function(json) {
+ return json.queryasyncjobresultresponse.jobresult.affinitygroup;
+ }
+ }
+ });
+ }
+ });
+ },
+
+ notification: {
+ poll: pollAsyncJobResult
+ }
+ }
},
- notification: {
- poll: pollAsyncJobResult
- }
- }
- },
+ detailView: {
+ actions: {
+ remove: {
+ label: 'label.delete.affinity.group',
+ messages: {
+ confirm: function(args) {
+ return 'message.delete.affinity.group';
+ },
+ notification: function(args) {
+ return 'label.delete.affinity.group';
+ }
+ },
+ action: function(args) {
+ $.ajax({
+ url: createURL('deleteAffinityGroup'),
+ data: {
+ id: args.context.affinityGroups[0].id
+ },
+ success: function(json) {
+ var jid = json.deleteaffinitygroupresponse.jobid;
+ args.response.success({
+ _custom: {
+ jobId: jid
+ }
+ });
+ }
+ });
+ },
+ notification: {
+ poll: pollAsyncJobResult
+ }
+ }
+ },
- viewAll: { path: 'instances', label: 'label.instances' },
-
- tabs: {
- details: {
- title: 'label.details',
- fields: [
- {
- name: { label: 'label.name' }
- },
- {
- description: { label: 'label.description' },
- type: { label: 'label.type' },
- id: { label: 'label.id' }
- }
- ],
+ viewAll: {
+ path: 'instances',
+ label: 'label.instances'
+ },
- dataProvider: function(args) {
- $.ajax({
- url: createURL('listAffinityGroups'),
- data: {
- id: args.context.affinityGroups[0].id
- },
- success: function(json) {
- var item = json.listaffinitygroupsresponse.affinitygroup[0];
- args.response.success({data: item});
- }
- });
+ tabs: {
+ details: {
+ title: 'label.details',
+ fields: [{
+ name: {
+ label: 'label.name'
+ }
+ }, {
+ description: {
+ label: 'label.description'
+ },
+ type: {
+ label: 'label.type'
+ },
+ id: {
+ label: 'label.id'
+ }
+ }],
+
+ dataProvider: function(args) {
+ $.ajax({
+ url: createURL('listAffinityGroups'),
+ data: {
+ id: args.context.affinityGroups[0].id
+ },
+ success: function(json) {
+ var item = json.listaffinitygroupsresponse.affinitygroup[0];
+ args.response.success({
+ data: item
+ });
+ }
+ });
+ }
+ }
+ }
}
- }
}
- }
- }
- };
+ };
})(cloudStack);