ambari-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From akovale...@apache.org
Subject git commit: AMBARI-3772. New config group dialog should have config-groups populated. (akovalenko)
Date Fri, 15 Nov 2013 14:15:59 GMT
Updated Branches:
  refs/heads/trunk 05be921e3 -> b8f96a2d6


AMBARI-3772. New config group dialog should have config-groups populated. (akovalenko)


Project: http://git-wip-us.apache.org/repos/asf/incubator-ambari/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-ambari/commit/b8f96a2d
Tree: http://git-wip-us.apache.org/repos/asf/incubator-ambari/tree/b8f96a2d
Diff: http://git-wip-us.apache.org/repos/asf/incubator-ambari/diff/b8f96a2d

Branch: refs/heads/trunk
Commit: b8f96a2d620546839090e934b1f4b156fe2072c7
Parents: 05be921
Author: Aleksandr Kovalenko <oleksandr.kovalenko@ukr.net>
Authored: Fri Nov 15 16:15:04 2013 +0200
Committer: Aleksandr Kovalenko <oleksandr.kovalenko@ukr.net>
Committed: Fri Nov 15 16:15:04 2013 +0200

----------------------------------------------------------------------
 .../controllers/main/service/info/configs.js    | 49 ++++++++--------
 ambari-web/app/messages.js                      |  1 +
 .../common/configs/selectCreateConfigGroup.hbs  | 53 +++++++++--------
 ambari-web/app/utils/config.js                  | 60 ++++++++++++--------
 .../app/views/common/configs/services_config.js |  4 +-
 ambari-web/app/views/main/service/item.js       |  2 +-
 6 files changed, 96 insertions(+), 73 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-ambari/blob/b8f96a2d/ambari-web/app/controllers/main/service/info/configs.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/controllers/main/service/info/configs.js b/ambari-web/app/controllers/main/service/info/configs.js
index 8d1bbb5..5e3e444 100644
--- a/ambari-web/app/controllers/main/service/info/configs.js
+++ b/ambari-web/app/controllers/main/service/info/configs.js
@@ -273,30 +273,33 @@ App.MainServiceInfoConfigsController = Em.Controller.extend({
       if (data.config_groups.length) {
         data.config_groups.forEach(function (item) {
           item = item.ConfigGroup;
-          var groupHosts = item.hosts.mapProperty('host_name');
-          var newConfigGroup = App.ConfigGroup.create({
-            name: item.group_name,
-            description: item.description,
-            isDefault: false,
-            parentConfigGroup: null,
-            service: App.Service.find().findProperty('serviceName', item.tag),
-            hosts: groupHosts,
-            configSiteTags: []
-          });
-          groupHosts.forEach(function (host) {
-            defaultConfigGroupHosts = defaultConfigGroupHosts.without(host);
-          }, this);
-          item.desired_configs.forEach(function (config) {
-            newConfigGroup.configSiteTags.push(App.ConfigSiteTag.create({
-              site: config.type,
-              tag: config.tag
-            }));
-          }, this);
-          // select default selected group for hosts page
-          if (!selectedConfigGroup && this.get('isHostsConfigsPage') && newConfigGroup.get('hosts').contains(this.get('host.hostName'))
&& this.get('content.serviceName') === item.tag) {
-            selectedConfigGroup = newConfigGroup;
+          if (item.tag === this.get('content.serviceName')) {
+            var groupHosts = item.hosts.mapProperty('host_name');
+            var newConfigGroup = App.ConfigGroup.create({
+              id: item.id,
+              name: item.group_name,
+              description: item.description,
+              isDefault: false,
+              parentConfigGroup: null,
+              service: App.Service.find().findProperty('serviceName', item.tag),
+              hosts: groupHosts,
+              configSiteTags: []
+            });
+            groupHosts.forEach(function (host) {
+              defaultConfigGroupHosts = defaultConfigGroupHosts.without(host);
+            }, this);
+            item.desired_configs.forEach(function (config) {
+              newConfigGroup.configSiteTags.push(App.ConfigSiteTag.create({
+                site: config.type,
+                tag: config.tag
+              }));
+            }, this);
+            // select default selected group for hosts page
+            if (!selectedConfigGroup && this.get('isHostsConfigsPage') &&
newConfigGroup.get('hosts').contains(this.get('host.hostName')) && this.get('content.serviceName')
=== item.tag) {
+              selectedConfigGroup = newConfigGroup;
+            }
+            configGroups.push(newConfigGroup);
           }
-          configGroups.push(newConfigGroup);
         }, this);
       }
       this.set('configGroups', configGroups);

http://git-wip-us.apache.org/repos/asf/incubator-ambari/blob/b8f96a2d/ambari-web/app/messages.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/messages.js b/ambari-web/app/messages.js
index 1e2f49d..ed23ef6 100644
--- a/ambari-web/app/messages.js
+++ b/ambari-web/app/messages.js
@@ -1692,6 +1692,7 @@ Em.I18n.translations = {
   'config.group.selection.dialog.option.create.msg': 'A new configuration group will be created
with the given name. Initially there will be no hosts in the group, with only the selected
property overridden.',
   'config.group.selection.dialog.err.name.exists': 'Configuration group with given name already
exists',
   'config.group.selection.dialog.err.create': 'Error creating new configuration group [{0}]',
+  'config.group.selection.dialog.no.groups': 'There are no existed Config Groups for this
Service',
 
   'utils.ajax.errorMessage': 'Error message'
 };

http://git-wip-us.apache.org/repos/asf/incubator-ambari/blob/b8f96a2d/ambari-web/app/templates/common/configs/selectCreateConfigGroup.hbs
----------------------------------------------------------------------
diff --git a/ambari-web/app/templates/common/configs/selectCreateConfigGroup.hbs b/ambari-web/app/templates/common/configs/selectCreateConfigGroup.hbs
index 9414cb0..27110db 100644
--- a/ambari-web/app/templates/common/configs/selectCreateConfigGroup.hbs
+++ b/ambari-web/app/templates/common/configs/selectCreateConfigGroup.hbs
@@ -22,31 +22,34 @@
   {{else}}
     &nbsp;
   {{/if}}
-  </div>
-  <label class="radio">
-    {{view view.selectConfigGroupRadioButton}} 
-    {{t config.group.selection.dialog.option.select}}
-  </label>
-  <div class="select-create-config-group-div">
-    <span class="btn-group">
-      <button class="btn" {{bindAttr disabled="view.parentView.optionCreateConfigGroup"}}>{{view.parentView.selectedConfigGroup.name}}</button>
-      <button class="btn dropdown-toggle" data-toggle="dropdown" {{bindAttr disabled="view.parentView.optionCreateConfigGroup"}}>
-        <span class="caret"></span>
-      </button>
-      <ul class="dropdown-menu">
-        <!-- available config group menu links -->
-        {{#each configGroup in view.parentView.availableConfigGroups}}
-           <li>
-             <a href="#" {{action "doSelectConfigGroup" configGroup target="view.parentView"}}>
-               {{configGroup.name}}
-             </a>
-           </li>
-        {{/each}}
-      </ul>
-    </span>
-    <div class="message">{{t config.group.selection.dialog.option.select.msg}}</div>
-  </div>
-
+    </div>
+    <label class="radio">
+      {{view view.selectConfigGroupRadioButton}}
+      {{t config.group.selection.dialog.option.select}}
+    </label>
+    {{#if view.parentView.availableConfigGroups.length}}
+    <div class="select-create-config-group-div">
+      <span class="btn-group">
+        <button class="btn" {{bindAttr disabled="view.parentView.optionCreateConfigGroup"}}>{{view.parentView.selectedConfigGroup.name}}</button>
+        <button class="btn dropdown-toggle" data-toggle="dropdown" {{bindAttr disabled="view.parentView.optionCreateConfigGroup"}}>
+          <span class="caret"></span>
+        </button>
+        <ul class="dropdown-menu">
+          <!-- available config group menu links -->
+          {{#each configGroup in view.parentView.availableConfigGroups}}
+             <li>
+               <a href="#" {{action "doSelectConfigGroup" configGroup target="view.parentView"}}>
+                 {{configGroup.name}}
+               </a>
+             </li>
+          {{/each}}
+        </ul>
+      </span>
+      <div class="message">{{t config.group.selection.dialog.option.select.msg}}</div>
+    </div>
+  {{else}}
+    <div class="alert alert-block">{{t config.group.selection.dialog.no.groups}}</div>
+  {{/if}}
   <label class="radio">
     {{view view.createConfigGroupRadioButton}}
     {{t config.group.selection.dialog.option.create}}

http://git-wip-us.apache.org/repos/asf/incubator-ambari/blob/b8f96a2d/ambari-web/app/utils/config.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/utils/config.js b/ambari-web/app/utils/config.js
index 7d35b77..a6859a5 100644
--- a/ambari-web/app/utils/config.js
+++ b/ambari-web/app/utils/config.js
@@ -983,8 +983,11 @@ App.config = Em.Object.create({
    * @param callback  Callback function which is invoked when dialog
    *  is closed, cancelled or OK is pressed.
    */
-  launchConfigGroupSelectionCreationDialog : function(serviceId, availableConfigGroups, callback)
{
+  launchConfigGroupSelectionCreationDialog : function(serviceId, configGroups, callback)
{
     var self = this;
+    var availableConfigGroups = configGroups.slice();
+    // delete Default Config Group
+    availableConfigGroups.pop();
     var selectedConfigGroup = availableConfigGroups && availableConfigGroups.length
> 0 ?
         availableConfigGroups[0] : null;
     App.ModalPopup.show({
@@ -1008,12 +1011,11 @@ App.config = Em.Object.create({
         } else {
           var newConfigGroupName = this.get('newConfigGroupName');
           var newConfigGroup = self.createNewConfigurationGroup(serviceId, newConfigGroupName);
-          if (newConfigGroup.configGroup!=null) {
+          if (newConfigGroup) {
+            var defaultConfigGroup = configGroups.popObject();
+            configGroups.pushObjects([newConfigGroup, defaultConfigGroup]);
             this.hide();
-            newConfigGroup.configGroup.name = newConfigGroupName;
-            callback(newConfigGroup.configGroup);
-          } else {
-            this.set('warningMessage', this.t('config.group.selection.dialog.err.create').format(newConfigGroup.error));
+            callback(newConfigGroup);
           }
         }
       },
@@ -1048,13 +1050,20 @@ App.config = Em.Object.create({
         controllerBinding: 'App.router.mainServiceInfoConfigsController',
         selectConfigGroupRadioButton: Ember.Checkbox.extend({
           tagName: 'input',
-          attributeBindings: ['type', 'checked'],
+          attributeBindings: ['type', 'checked', 'disabled'],
           checked: function () {
             return this.get('parentView.parentView.optionSelectConfigGroup');
           }.property('parentView.parentView.optionSelectConfigGroup'),
           type: 'radio',
+          disabled: false,
           click: function () {
             this.set('parentView.parentView.optionSelectConfigGroup', true);
+          },
+          didInsertElement: function () {
+            if (!this.get('parentView.parentView.availableConfigGroups').length) {
+              this.set('disabled', true);
+              this.set('parentView.parentView.optionSelectConfigGroup', false);
+            }
           }
         }),
         createConfigGroupRadioButton: Ember.Checkbox.extend({
@@ -1081,35 +1090,40 @@ App.config = Em.Object.create({
    *        { configGroup: {id:4}, error: {...}}
    */
   createNewConfigurationGroup: function (serviceId, configGroupName) {
-    var newConfigGroupData = {
-        configGroup: null,
-        error: null
-    };
+    var newConfigGroupData = null;
+    var description = "New configuration group created on " + new Date().toDateString();
     var sendData = {
       name: 'config_groups.create',
       data: {
         'group_name': configGroupName,
         'service_id': serviceId,
-        'description': "New configuration group created on " + new Date().toDateString()
+        'description': description
       },
       success: 'successFunction',
       error: 'errorFunction',
-      successFunction: function(response){
-        newConfigGroupData.configGroup = response.resources[0].ConfigGroup;
-        newConfigGroupData.error = null;
+      successFunction: function (response) {
+        newConfigGroupData = App.ConfigGroup.create({
+          id: response.resources[0].ConfigGroup.id,
+          name: null,
+          description: null,
+          isDefault: false,
+          parentConfigGroup: null,
+          service: null,
+          hosts: [],
+          configSiteTags: []
+        });
       },
-      errorFunction: function(request, ajaxOptions, error){
-        newConfigGroupData.configGroup = null;
-        try{
-          var errResponse = JSON.parse(request.responseText);
-          error = errResponse.message;
-        }catch(e){
-        }
-        newConfigGroupData.error = request.status + ": " + error;
+      errorFunction: function () {
+        console.error('Error in creating new Config Group');
       }
     };
     sendData.sender = sendData;
     App.ajax.send(sendData);
+    if (newConfigGroupData) {
+      newConfigGroupData.set('service', App.Service.find().filterProperty('serviceName',
serviceId));
+      newConfigGroupData.set('name', configGroupName);
+      newConfigGroupData.set('description', description);
+    }
     return newConfigGroupData;
   },
 

http://git-wip-us.apache.org/repos/asf/incubator-ambari/blob/b8f96a2d/ambari-web/app/views/common/configs/services_config.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/views/common/configs/services_config.js b/ambari-web/app/views/common/configs/services_config.js
index 5f2d22a..aecff2d 100644
--- a/ambari-web/app/views/common/configs/services_config.js
+++ b/ambari-web/app/views/common/configs/services_config.js
@@ -487,13 +487,15 @@ App.ServiceConfigsByCategoryView = Ember.View.extend({
   },
 
   createOverrideProperty: function (event) {
+    var serviceConfigController = this.get('controller');
     var serviceConfigProperty = event.contexts[0];
     // Launch dialog to pick/create Config-group
-    var serviceConfigGroups = [];
+    var serviceConfigGroups = serviceConfigController.get('configGroups');
     App.config.launchConfigGroupSelectionCreationDialog(this.get('service.serviceName'),

         serviceConfigGroups, function(selectedConfigGroup){
       console.log("launchConfigGroupSelectionCreationDialog(): Selected/Created:", selectedConfigGroup);
       if (selectedConfigGroup) {
+        serviceConfigController.set('selectedConfigGroup', selectedConfigGroup);
         // TODO - show configurations for this new config-group
 //        var overrides = serviceConfigProperty.get('overrides');
 //        if (!overrides) {

http://git-wip-us.apache.org/repos/asf/incubator-ambari/blob/b8f96a2d/ambari-web/app/views/main/service/item.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/views/main/service/item.js b/ambari-web/app/views/main/service/item.js
index f3c7d32..faa7e07 100644
--- a/ambari-web/app/views/main/service/item.js
+++ b/ambari-web/app/views/main/service/item.js
@@ -44,7 +44,7 @@ App.MainServiceItemView = Em.View.extend({
       default:
         options.push({action: 'runSmokeTest', 'label': Em.I18n.t('services.service.actions.run.smoke'),
disabled:disabled});
     }
-    if (App.supports.hostOverrides && service.get('serviceName') !== 'GANGLIA') {
+    if (App.supports.hostOverrides) {
       options.push({action: 'manageConfigurationGroups', 'label': Em.I18n.t('services.service.actions.manage_configuration_groups'),
disabled: false});
     }
     return options;


Mime
View raw message