Explorar o código

AMBARI-5868. Provide 'Create App' Wizard Step3 functionallity. (akovalenko)

Aleksandr Kovalenko %!s(int64=11) %!d(string=hai) anos
pai
achega
4461d6b1d2

+ 4 - 4
contrib/views/slider/src/main/resources/ui/app/controllers/createAppWizard/step2_controller.js

@@ -55,9 +55,9 @@ App.CreateAppWizardStep2Controller = Ember.ArrayController.extend({
       allTypeComponents.forEach(function (typeComponent) {
         content.push(Ember.Object.create({
           name: typeComponent.get('displayName'),
-          numInstances: typeComponent.get('defaultNumInstances'),
-          yarnMemory: typeComponent.get('defaultYARNMemory'),
-          yarnCPU: typeComponent.get('defaultYARNCPU')
+          numInstances: typeComponent.get('defaultNumInstances').toString(),
+          yarnMemory: typeComponent.get('defaultYARNMemory').toString(),
+          yarnCPU: typeComponent.get('defaultYARNCPU').toString()
         }));
       });
       this.set('content', content);
@@ -84,7 +84,7 @@ App.CreateAppWizardStep2Controller = Ember.ArrayController.extend({
    * @return {Boolean}
    */
   isNotInteger: function (value) {
-    return !value || !(value % 1 == 0);
+    return !(value.trim().length && (value % 1 == 0));
   },
 
   /**

+ 93 - 0
contrib/views/slider/src/main/resources/ui/app/controllers/createAppWizard/step3_controller.js

@@ -0,0 +1,93 @@
+/**
+ * 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.CreateAppWizardStep3Controller = Ember.ObjectController.extend({
+
+  needs: "createAppWizard",
+
+  appWizardController: Ember.computed.alias("controllers.createAppWizard"),
+
+  /**
+   * Configs entered in TextArea
+   * @type {String}
+   */
+  configs: '',
+
+  /**
+   * Defines if <code>configs</code> are properly key-value formatted
+   * @type {Boolean}
+   */
+  isError: false,
+
+  /**
+   * Config object converted from <code>configs</code>
+   * @type {Object}
+   */
+  configsObject: {},
+
+  /**
+   * Load all data required for step
+   */
+  loadStep: function () {
+    this.clearStep();
+  },
+
+  /**
+   * Clear all initial data
+   */
+  clearStep: function () {
+    this.set('isError', false);
+  },
+
+  /**
+   * Validate <code>configs</code> to be key-value formatted amd convert it to object
+   * @return {Boolean}
+   */
+  validateConfigs: function () {
+    var self = this;
+    var result = true;
+    var configs = this.get('configs');
+    try {
+      var configsObject = JSON.parse('{' + configs + '}');
+      self.set('configsObject', configsObject);
+    } catch (e) {
+      self.set('isError', true);
+      result = false;
+    }
+    return result;
+  },
+
+  /**
+   * Save converted configs to new App configs
+   */
+  saveConfigs: function () {
+    this.set('appWizardController.newApp.configs', this.get('configsObject'));
+  },
+
+  actions: {
+    /**
+     * If <code>configs</code> is valid, than save it and proceed to the next step
+     */
+    submit: function () {
+      if (this.validateConfigs()) {
+        this.saveConfigs();
+        this.get('appWizardController').nextStep();
+      }
+    }
+  }
+});

+ 1 - 1
contrib/views/slider/src/main/resources/ui/app/styles/application.less

@@ -338,7 +338,7 @@ a {
     margin-left: 10px;
   }
   #configs-text-area {
-    width: 98%;
+    margin-bottom: 10px;
     height: 225px;
   }
   #step4 {

+ 9 - 4
contrib/views/slider/src/main/resources/ui/app/templates/createAppWizard/step3.hbs

@@ -17,8 +17,13 @@
 }}
 
 <p>
-  Provide configuration details for HBase application
+  {{t wizard.step3.header}}
 </p>
-{{view Ember.TextArea id="configs-text-area"}}
-<button class="btn btn-success pull-right next-btn" {{action nextStep}}>Next</button>
-<button class="btn pull-right" {{action prevStep}}>Back</button>
+<div {{bind-attr class="controller.isError:has-error :form-group"}}>
+  {{view Ember.TextArea id="configs-text-area" valueBinding="controller.configs" classNames="form-control"}}
+  {{#if controller.isError}}
+    <div class="alert alert-danger">{{t wizard.step3.error}}</div>
+  {{/if}}
+</div>
+<button class="btn btn-success pull-right next-btn" {{action submit}}>{{t common.next}}</button>
+<button class="btn pull-right" {{action prevStep}}>{{t common.back}}</button>

+ 4 - 2
contrib/views/slider/src/main/resources/ui/app/translations.js

@@ -65,8 +65,10 @@ Em.I18n.translations = {
   'wizard.step2.header': 'HBase application requires resources to be allocated on the cluster. Provide resource allocation requests for each component of the application below.',
   'wizard.step2.table.instances': 'Number of Instances',
   'wizard.step2.table.memory': 'YARN Memory (MB)',
-  'wizard.step2.table.cpu': 'Number of Instances',
-    'wizard.step2.error.numbers': 'All fields should be filled. Only integer numbers allowed.',
+  'wizard.step2.table.cpu': 'YARN	CPU	Cores',
+  'wizard.step2.error.numbers': 'All fields should be filled. Only integer numbers allowed.',
   'wizard.step3.name': 'Configuration',
+  'wizard.step3.header': 'Provide	configuration	details	for	HBase	application',
+  'wizard.step3.error': 'Only \"key\":\"value\" format allowed.',
   'wizard.step4.name': 'Deploy'
 };

+ 24 - 0
contrib/views/slider/src/main/resources/ui/app/views/createAppWizard/step3_view.js

@@ -0,0 +1,24 @@
+/**
+ * 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.CreateAppWizardStep3View = Ember.View.extend({
+
+  didInsertElement: function () {
+    this.get('controller').loadStep();
+  }
+});