ambari-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From alexantone...@apache.org
Subject git commit: AMBARI-7037. Slider View: Create Slider app wizard should show configs in sections (alexantonenko)
Date Wed, 27 Aug 2014 14:41:04 GMT
Repository: ambari
Updated Branches:
  refs/heads/trunk c79fad250 -> eb08925ca


AMBARI-7037. Slider View: Create Slider app wizard should show configs in sections (alexantonenko)


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

Branch: refs/heads/trunk
Commit: eb08925ca4290ad26e90a5f353d97f1aed298422
Parents: c79fad2
Author: Alex Antonenko <hiveww@gmail.com>
Authored: Wed Aug 27 17:39:02 2014 +0300
Committer: Alex Antonenko <hiveww@gmail.com>
Committed: Wed Aug 27 17:39:02 2014 +0300

----------------------------------------------------------------------
 .../ui/app/components/configSection.js          | 48 ++++++++++++++++++++
 .../createAppWizard/step3_controller.js         | 45 ++++++++++++++----
 .../src/main/resources/ui/app/helpers/helper.js |  5 +-
 .../app/templates/components/configSection.hbs  | 30 ++++++++++++
 .../ui/app/templates/createAppWizard/step3.hbs  |  4 +-
 5 files changed, 122 insertions(+), 10 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ambari/blob/eb08925c/contrib/views/slider/src/main/resources/ui/app/components/configSection.js
----------------------------------------------------------------------
diff --git a/contrib/views/slider/src/main/resources/ui/app/components/configSection.js b/contrib/views/slider/src/main/resources/ui/app/components/configSection.js
new file mode 100644
index 0000000..7b2481d
--- /dev/null
+++ b/contrib/views/slider/src/main/resources/ui/app/components/configSection.js
@@ -0,0 +1,48 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+App.ConfigSectionComponent = Em.Component.extend({
+  layoutName:'components/configSection',
+  config:null,
+  section:'',
+
+  /**
+   * label for current section
+   * @return {String}
+   */
+  sectionLabel: function () {
+    return this.get('section').classify();
+  }.property(),
+
+  /**
+   * Return True is section name equals 'general'
+   * @type {Boolean}
+   */
+  isGeneral:Ember.computed.equal('section', 'general'),
+
+  /**
+   * Filtered configs for current section
+   */
+  sectionConfigs: Ember.computed.filter('config', function(item) {
+    if (this.get('isGeneral')) {
+      return !item.name.match('^site.');
+    } else {
+      return !!item.name.match('^site.'+this.get('section')) ;
+    }
+  })
+});

http://git-wip-us.apache.org/repos/asf/ambari/blob/eb08925c/contrib/views/slider/src/main/resources/ui/app/controllers/createAppWizard/step3_controller.js
----------------------------------------------------------------------
diff --git a/contrib/views/slider/src/main/resources/ui/app/controllers/createAppWizard/step3_controller.js
b/contrib/views/slider/src/main/resources/ui/app/controllers/createAppWizard/step3_controller.js
index 2c34592..b98afb4 100644
--- a/contrib/views/slider/src/main/resources/ui/app/controllers/createAppWizard/step3_controller.js
+++ b/contrib/views/slider/src/main/resources/ui/app/controllers/createAppWizard/step3_controller.js
@@ -22,11 +22,30 @@ App.CreateAppWizardStep3Controller = Ember.ObjectController.extend({
 
   appWizardController: Ember.computed.alias("controllers.createAppWizard"),
 
+  newAppConfigs: Ember.computed.alias("appWizardController.newApp.configs"),
+
   /**
-   * Configs entered in TextArea
-   * @type {String}
+   * Configs entered in TextFields
+   * @type Array
    */
-  configs: '',
+  configs: Em.A(),
+
+  /**
+   * Convert configs to array of uniq section names
+   * @return {Array}
+   */
+  sectionKeys:function () {
+    var configs = this.get('newAppConfigs') || {},
+        k = ["general"];
+
+    Object.keys(configs).forEach(function (key) {
+      if (key.split('.')[0] == "site") {
+        k.push(key.split('.')[1])
+      }
+    });
+
+    return k.uniq();
+  }.property('newAppConfigs'),
 
   /**
    * Defines if <code>configs</code> are properly key-value formatted
@@ -54,10 +73,16 @@ App.CreateAppWizardStep3Controller = Ember.ObjectController.extend({
    * @method initConfigs
    */
   initConfigs: function() {
-    var c = JSON.stringify(this.get('appWizardController.newApp.configs')).replace(/",/g,
'",\n');
-    c = c.substr(1, c.length - 2);
+    var configs = this.get('newAppConfigs') || {},
+        c = Em.A();
+
+    Object.keys(configs).forEach(function (key) {
+      var label = (!!key.match('^site.'))?key.substr(5):key;
+      c.push({name:key,value:configs[key],label:label})
+    });
+
     this.set('configs', c);
-  },
+  }.observes('newAppConfigs'),
 
   /**
    * Clear all initial data
@@ -76,8 +101,12 @@ App.CreateAppWizardStep3Controller = Ember.ObjectController.extend({
     var self = this;
     var result = true;
     var configs = this.get('configs');
+    var configsObject = {};
+
     try {
-      var configsObject = JSON.parse('{' + configs + '}');
+      configs.forEach(function (item) {
+        configsObject[item.name] = item.value;
+      })
       self.set('configsObject', configsObject);
     } catch (e) {
       self.set('isError', true);
@@ -91,7 +120,7 @@ App.CreateAppWizardStep3Controller = Ember.ObjectController.extend({
    * @method saveConfigs
    */
   saveConfigs: function () {
-    this.set('appWizardController.newApp.configs', this.get('configsObject'));
+    this.set('newAppConfigs', this.get('configsObject'));
   },
 
   actions: {

http://git-wip-us.apache.org/repos/asf/ambari/blob/eb08925c/contrib/views/slider/src/main/resources/ui/app/helpers/helper.js
----------------------------------------------------------------------
diff --git a/contrib/views/slider/src/main/resources/ui/app/helpers/helper.js b/contrib/views/slider/src/main/resources/ui/app/helpers/helper.js
index bfa0a68..664328c 100644
--- a/contrib/views/slider/src/main/resources/ui/app/helpers/helper.js
+++ b/contrib/views/slider/src/main/resources/ui/app/helpers/helper.js
@@ -58,11 +58,14 @@ App.registerBoundHelper = function(name, view) {
 App.registerBoundHelper('formatWordBreak', Em.View.extend({
   tagName: 'span',
   template: Ember.Handlebars.compile('{{{view.result}}}'),
+  devider:'/',
 
   /**
    * @type {string}
    */
   result: function() {
-    return this.get('content') && this.get('content').replace(/\//g, '/<wbr />');
+    var d = this.get('devider');
+    var r = new RegExp('\\'+d,"g");
+    return this.get('content') && this.get('content').replace(r, d+'<wbr />');
   }.property('content')
 }));
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/ambari/blob/eb08925c/contrib/views/slider/src/main/resources/ui/app/templates/components/configSection.hbs
----------------------------------------------------------------------
diff --git a/contrib/views/slider/src/main/resources/ui/app/templates/components/configSection.hbs
b/contrib/views/slider/src/main/resources/ui/app/templates/components/configSection.hbs
new file mode 100644
index 0000000..9b47650
--- /dev/null
+++ b/contrib/views/slider/src/main/resources/ui/app/templates/components/configSection.hbs
@@ -0,0 +1,30 @@
+{{!
+* Licensed to the Apache Software Foundation (ASF) under one
+* or more contributor license agreements.  See the NOTICE file
+* distributed with this work for additional information
+* regarding copyright ownership.  The ASF licenses this file
+* to you under the Apache License, Version 2.0 (the
+* "License"); you may not use this file except in compliance
+* with the License.  You may obtain a copy of the License at
+*
+*     http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+}}
+
+{{#bs-panel heading=sectionLabel collapsible=true dismiss=false open=isGeneral }}
+  <form class="form-horizontal" role="form">
+    {{#each sectionConfigs}}
+    <div class="form-group">
+      <label class="col-sm-4 control-label">{{formatWordBreak label devider='.'}}</label>
+      <div class="col-sm-6">
+        {{input value=value class="form-control"}}
+      </div>
+    </div>
+    {{/each}}
+  </form>
+{{/bs-panel}}

http://git-wip-us.apache.org/repos/asf/ambari/blob/eb08925c/contrib/views/slider/src/main/resources/ui/app/templates/createAppWizard/step3.hbs
----------------------------------------------------------------------
diff --git a/contrib/views/slider/src/main/resources/ui/app/templates/createAppWizard/step3.hbs
b/contrib/views/slider/src/main/resources/ui/app/templates/createAppWizard/step3.hbs
index 6b81a1e..181e93e 100644
--- a/contrib/views/slider/src/main/resources/ui/app/templates/createAppWizard/step3.hbs
+++ b/contrib/views/slider/src/main/resources/ui/app/templates/createAppWizard/step3.hbs
@@ -20,7 +20,9 @@
   {{t wizard.step3.header}}
 </p>
 <div {{bind-attr class="controller.isError:has-error :form-group"}}>
-  {{view Ember.TextArea id="configs-text-area" valueBinding="controller.configs" classNames="form-control"}}
+  {{#each controller.sectionKeys}}
+    {{config-section section=this config=controller.configs}}
+  {{/each}}
   {{#if controller.isError}}
     <div class="alert alert-danger">{{t wizard.step3.error}}</div>
   {{/if}}


Mime
View raw message