Bladeren bron

AMBARI-1857. Capacity Scheduler: field order for Add/Edit popup. (srimanth)

git-svn-id: https://svn.apache.org/repos/asf/incubator/ambari/trunk@1466282 13f79535-47bb-0310-9956-ffa450edef68
Srimanth 12 jaren geleden
bovenliggende
commit
dc23dd2aae

+ 2 - 0
CHANGES.txt

@@ -12,6 +12,8 @@ Trunk (unreleased changes):
 
  NEW FEATURES
 
+ AMBARI-1857. Capacity Scheduler: field order for Add/Edit popup. (srimanth)
+
  AMBARI-1855. Capacity Scheduler: when adding a new queue, populate 
  fields. (srimanth)
  

+ 20 - 10
ambari-web/app/data/custom_configs.js

@@ -32,7 +32,8 @@ module.exports =
       "category": "CapacityScheduler",
       "unit": "%",
       "isQueue": true,
-      "filename": 'capacity-scheduler.xml'
+      "filename": 'capacity-scheduler.xml',
+      "index": 1
     },
     {
       "id": "site property",
@@ -55,7 +56,8 @@ module.exports =
       "unit": "%",
       "valueRange": [0, 100],
       "isQueue": true,
-      "filename": 'capacity-scheduler.xml'
+      "filename": 'capacity-scheduler.xml',
+      "index": 2
     },
     {
       "id": "site property",
@@ -78,7 +80,8 @@ module.exports =
       "unit": "%",
       "valueRange": [1, 100],
       "isQueue": true,
-      "filename": 'capacity-scheduler.xml'
+      "filename": 'capacity-scheduler.xml',
+      "index": 9
     },
     {
       "id": "site property",
@@ -95,7 +98,8 @@ module.exports =
       "serviceName": "MAPREDUCE",
       "category": "CapacityScheduler",
       "isQueue": true,
-      "filename": 'capacity-scheduler.xml'
+      "filename": 'capacity-scheduler.xml',
+      "index": 8
     },
     {
       "id": "site property",
@@ -110,7 +114,8 @@ module.exports =
       "serviceName": "MAPREDUCE",
       "category": "CapacityScheduler",
       "isQueue": true,
-      "filename": 'capacity-scheduler.xml'
+      "filename": 'capacity-scheduler.xml',
+      "index": 7
     },
     {
       "id": "site property",
@@ -124,7 +129,8 @@ module.exports =
       "serviceName": "MAPREDUCE",
       "category": "CapacityScheduler",
       "isQueue": true,
-      "filename": 'mapred-queue-acls.xml'
+      "filename": 'mapred-queue-acls.xml',
+      "index": 13
     },
     {
       "id": "site property",
@@ -138,7 +144,8 @@ module.exports =
       "serviceName": "MAPREDUCE",
       "category": "CapacityScheduler",
       "isQueue": true,
-      "filename": 'mapred-queue-acls.xml'
+      "filename": 'mapred-queue-acls.xml',
+      "index": 14
     },
     {
       "id": "site property",
@@ -154,7 +161,8 @@ module.exports =
       "serviceName": "MAPREDUCE",
       "category": "CapacityScheduler",
       "isQueue": true,
-      "filename": 'capacity-scheduler.xml'
+      "filename": 'capacity-scheduler.xml',
+      "index": 10
     },
     {
       "id": "site property",
@@ -170,7 +178,8 @@ module.exports =
       "serviceName": "MAPREDUCE",
       "category": "CapacityScheduler",
       "isQueue": true,
-      "filename": 'capacity-scheduler.xml'
+      "filename": 'capacity-scheduler.xml',
+      "index": 11
     },
     {
       "id": "site property",
@@ -187,6 +196,7 @@ module.exports =
       "serviceName": "MAPREDUCE",
       "category": "CapacityScheduler",
       "isQueue": true,
-      "filename": 'capacity-scheduler.xml'
+      "filename": 'capacity-scheduler.xml',
+      "index": 12
     }
   ]

+ 1 - 1
ambari-web/app/utils/config.js

@@ -552,7 +552,7 @@ App.config = Em.Object.create({
               var dpv = desiredConfigs[property];
               var apv = actualConfigs[property];
               if (dpv !== apv && globalPropertyToServicesMap[property] != null) {
-                effected = globalPropertyToServicesMap[property].indexOf(serviceName) > -1;
+                effected = globalPropertyToServicesMap[property].indexOf(service) > -1;
                 this.differentGlobalTagsCache.push(service+"/"+desiredTag+"/"+actualTag);
               }
             }

+ 42 - 9
ambari-web/app/views/common/configs/services_config.js

@@ -602,6 +602,7 @@ App.ServiceConfigCapacityScheduler = App.ServiceConfigsByCategoryView.extend({
           config.set('displayType', customConfig.displayType);
           config.set('valueRange', customConfig.valueRange);
           config.set('isVisible', customConfig.isVisible);
+          config.set('index', customConfig.index);
         }
         queue.push(config);
       }
@@ -872,9 +873,22 @@ App.ServiceConfigCapacityScheduler = App.ServiceConfigsByCategoryView.extend({
         }
         this.hide();
       },
+      /**
+       * Queue properties order:
+       * 1. Queue Name
+       * 2. Capacity
+       * 3. Max Capacity
+       * 4. Users
+       * 5. Groups
+       * 6. Admin Users
+       * 7. Admin Groups
+       * 8. Support Priority
+       * ...
+       */
       content: function(){
         var content = (queueName) ? self.get('queues').findProperty('name', queueName) : self.get('emptyQueue');
         var configs = [];
+        var tableContent = self.get('tableContent');
         // copy of queue configs
         content.configs.forEach(function (config, index) {
           if (config.name == 'mapred.capacity-scheduler.queue.' + content.name + '.capacity') {
@@ -884,13 +898,13 @@ App.ServiceConfigCapacityScheduler = App.ServiceConfigsByCategoryView.extend({
                 var isError = false;
                 var capacities = [];
                 var capacitySum = 0;
-                if(self.get('tableContent')){
-                  capacities = self.get('tableContent').mapProperty('capacity');
+                if(tableContent){
+                  capacities = tableContent.mapProperty('capacity');
                   for (var i = 0, l = capacities.length; i < l; i++) {
                     capacitySum += parseInt(capacities[i]);
                   }
                   if (content.name != '<queue-name>') {
-                    capacitySum = capacitySum - parseInt(self.get('tableContent').findProperty('name', content.name).capacity);
+                    capacitySum = capacitySum - parseInt(tableContent.findProperty('name', content.name).capacity);
                   }
                 }
                 if (value == '') {
@@ -932,7 +946,9 @@ App.ServiceConfigCapacityScheduler = App.ServiceConfigsByCategoryView.extend({
           name: content.name,
           configs: configs
         };
-        return this.insertExtraConfigs(content);
+        content = this.insertExtraConfigs(content);
+        content.configs = this.sortQueueProperties(content.configs);
+        return content;
       }.property(),
       footerClass: Ember.View.extend({
         classNames: ['modal-footer', 'host-checks-update'],
@@ -1023,7 +1039,8 @@ App.ServiceConfigCapacityScheduler = App.ServiceConfigsByCategoryView.extend({
             }
           }.observes('value'),
           isRequired: true,
-          isVisible: true
+          isVisible: true,
+          index: 0
         });
         newField.validate();
         content.configs.unshift(newField);
@@ -1035,7 +1052,8 @@ App.ServiceConfigCapacityScheduler = App.ServiceConfigsByCategoryView.extend({
           isRequired: true,
           isVisible: true,
           type: 'USERS',
-          "displayType": "UNIXList"
+          displayType: "UNIXList",
+          index: 3
         });
         newField.validate();
         content.configs.push(newField);
@@ -1047,7 +1065,8 @@ App.ServiceConfigCapacityScheduler = App.ServiceConfigsByCategoryView.extend({
           isRequired: true,
           isVisible: true,
           type: 'USERS',
-          "displayType": "UNIXList"
+          displayType: "UNIXList",
+          index: 5
         });
         newField.validate();
         content.configs.push(newField);
@@ -1059,7 +1078,8 @@ App.ServiceConfigCapacityScheduler = App.ServiceConfigsByCategoryView.extend({
           isRequired: true,
           isVisible: true,
           "displayType": "UNIXList",
-          type: 'GROUPS'
+          type: 'GROUPS',
+          index: 4
         });
         newField.validate();
         content.configs.push(newField);
@@ -1071,11 +1091,24 @@ App.ServiceConfigCapacityScheduler = App.ServiceConfigsByCategoryView.extend({
           isRequired: true,
           isVisible: true,
           "displayType": "UNIXList",
-          type: 'GROUPS'
+          type: 'GROUPS',
+          index: 6
         });
         newField.validate();
         content.configs.push(newField);
         return content;
+      },
+      sortQueueProperties: function(configs){
+        var sortedConfigs = [];
+        var skippedConfigs = [];
+        configs.forEach(function(_config){
+          if(isFinite(_config.index)){
+            sortedConfigs[_config.index] = _config;
+          } else {
+            skippedConfigs.push(_config);
+          }
+        });
+        return sortedConfigs.concat(skippedConfigs);
       }
     })
   }