ambari-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From alexantone...@apache.org
Subject [1/3] ambari git commit: AMBARI-8469. Admin View: UI changes for new instance configuration properties (alexantonenko)
Date Fri, 28 Nov 2014 16:52:31 GMT
Repository: ambari
Updated Branches:
  refs/heads/trunk 9c3ed394c -> 0fc4e7f0e


AMBARI-8469. Admin View: UI changes for new instance configuration properties (alexantonenko)


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

Branch: refs/heads/trunk
Commit: ce7bfeb0abc70b47f1b826e8148557d228c18ac9
Parents: 9c3ed39
Author: Alex Antonenko <hiveww@gmail.com>
Authored: Thu Nov 27 20:26:05 2014 +0200
Committer: Alex Antonenko <hiveww@gmail.com>
Committed: Fri Nov 28 18:52:15 2014 +0200

----------------------------------------------------------------------
 .../ambariViews/CreateViewInstanceCtrl.js       |  8 ++++++-
 .../resources/ui/admin-web/app/styles/main.css  |  9 ++++++++
 .../admin-web/app/views/ambariViews/create.html | 15 ++++++++-----
 .../admin-web/app/views/ambariViews/edit.html   | 17 +++++++++------
 .../unit/controllers/CreateViewInstanceCtrl.js  | 22 +++++++++++++++++---
 5 files changed, 56 insertions(+), 15 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ambari/blob/ce7bfeb0/ambari-admin/src/main/resources/ui/admin-web/app/scripts/controllers/ambariViews/CreateViewInstanceCtrl.js
----------------------------------------------------------------------
diff --git a/ambari-admin/src/main/resources/ui/admin-web/app/scripts/controllers/ambariViews/CreateViewInstanceCtrl.js
b/ambari-admin/src/main/resources/ui/admin-web/app/scripts/controllers/ambariViews/CreateViewInstanceCtrl.js
index ac040ae..3c04775 100644
--- a/ambari-admin/src/main/resources/ui/admin-web/app/scripts/controllers/ambariViews/CreateViewInstanceCtrl.js
+++ b/ambari-admin/src/main/resources/ui/admin-web/app/scripts/controllers/ambariViews/CreateViewInstanceCtrl.js
@@ -27,6 +27,12 @@ angular.module('ambariAdminConsole')
       var viewVersion = data.data;
       $scope.view = viewVersion;
 
+      var parameters = viewVersion.ViewVersionInfo.parameters;
+
+      angular.forEach(parameters, function (item) {
+        item.value = item.default;
+      });
+
       $scope.instance = {
         view_name: viewVersion.ViewVersionInfo.view_name,
         version: viewVersion.ViewVersionInfo.version,
@@ -35,7 +41,7 @@ angular.module('ambariAdminConsole')
         visible: true,
         icon_path: '',
         icon64_path: '',
-        properties: viewVersion.ViewVersionInfo.parameters,
+        properties: parameters,
         description: ''
       };
     });

http://git-wip-us.apache.org/repos/asf/ambari/blob/ce7bfeb0/ambari-admin/src/main/resources/ui/admin-web/app/styles/main.css
----------------------------------------------------------------------
diff --git a/ambari-admin/src/main/resources/ui/admin-web/app/styles/main.css b/ambari-admin/src/main/resources/ui/admin-web/app/styles/main.css
index 36d934d..f395183 100644
--- a/ambari-admin/src/main/resources/ui/admin-web/app/styles/main.css
+++ b/ambari-admin/src/main/resources/ui/admin-web/app/styles/main.css
@@ -1269,4 +1269,13 @@ accordion .panel-group .panel{
 
 #stack-versions .table-bar .filtered-info {
   margin-top: 8px;
+}
+
+.checkbox input[type="checkbox"].viewproperty-input,
+.checkbox input[type="checkbox"].propertie-input {
+  margin-left: 0;
+}
+
+.popover-content {
+  word-wrap: break-word;
 }
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/ambari/blob/ce7bfeb0/ambari-admin/src/main/resources/ui/admin-web/app/views/ambariViews/create.html
----------------------------------------------------------------------
diff --git a/ambari-admin/src/main/resources/ui/admin-web/app/views/ambariViews/create.html
b/ambari-admin/src/main/resources/ui/admin-web/app/views/ambariViews/create.html
index 4186c85..e57c358 100644
--- a/ambari-admin/src/main/resources/ui/admin-web/app/views/ambariViews/create.html
+++ b/ambari-admin/src/main/resources/ui/admin-web/app/views/ambariViews/create.html
@@ -100,11 +100,16 @@
     <div class="panel-body property-form">
       <div class="form-group" ng-repeat="parameter in instance.properties"
         ng-class="{'has-error' : (form.instanceCreateForm[parameter.name].$error.required
&& form.instanceCreateForm.submitted)}" >
-        <label for="" class="col-sm-3 control-label" ng-class="{'not-required': !parameter.required}"
tooltip="{{parameter.description}}">{{parameter.name}}{{parameter.required ? '*' : ''}}</label>
-        <div class="col-sm-9">
-          <input type="{{parameter.masked ? 'password' : 'text'}}" class="form-control
viewproperty-input"  name="{{parameter.name}}" ng-required="parameter.required" ng-model="parameter.value"
autocomplete="off" tooltip="{{parameter.description}}">
-          <div class="alert alert-danger no-margin-bottom top-margin" ng-show='form.instanceCreateForm[parameter.name].$error.required
&& form.instanceCreateForm.submitted'>
-            This field is required.
+        <label for="" class="col-sm-3 control-label" ng-class="{'not-required': !parameter.required}">{{parameter.label
|| parameter.name}}{{parameter.required ? '*' : ''}}</label>
+        <div ng-switch="parameter.type">
+          <div class="col-sm-9 checkbox" ng-switch-when="boolean">
+            <input type="checkbox" class="viewproperty-input" name="{{parameter.name}}"
ng-required="parameter.required" ng-model="parameter.value" popover="{{parameter.description}}"
popover-title="{{parameter.name}}" popover-trigger="mouseenter">
+          </div>
+          <div class="col-sm-9" ng-switch-default>
+            <input type="{{parameter.masked ? 'password' : 'text'}}" class="form-control
viewproperty-input" name="{{parameter.name}}" ng-required="parameter.required" ng-model="parameter.value"
autocomplete="off" popover="{{parameter.description}}" popover-title="{{parameter.name}}"
popover-trigger="mouseenter" placeholder="{{parameter.placeholder}}">
+            <div class="alert alert-danger no-margin-bottom top-margin" ng-show='form.instanceCreateForm[parameter.name].$error.required
&& form.instanceCreateForm.submitted'>
+              This field is required.
+            </div>
           </div>
         </div>
       </div>

http://git-wip-us.apache.org/repos/asf/ambari/blob/ce7bfeb0/ambari-admin/src/main/resources/ui/admin-web/app/views/ambariViews/edit.html
----------------------------------------------------------------------
diff --git a/ambari-admin/src/main/resources/ui/admin-web/app/views/ambariViews/edit.html
b/ambari-admin/src/main/resources/ui/admin-web/app/views/ambariViews/edit.html
index d783cf4..339db7c 100644
--- a/ambari-admin/src/main/resources/ui/admin-web/app/views/ambariViews/edit.html
+++ b/ambari-admin/src/main/resources/ui/admin-web/app/views/ambariViews/edit.html
@@ -136,12 +136,17 @@
   <div class="panel-body">
     <form name="propertiesForm" class="form-horizontal property-form" ng-hide="isConfigurationEmpty"
novalidate>
       <fieldset>
-        <div class="form-group" ng-repeat="property in configurationMeta" ng-class="{'has-error'
: property.required && propertiesForm[property.name].$error.required && !editConfigurationDisabled}"
tooltip="{{property.description}}">
-          <label for="" class="control-label col-sm-3" ng-class="{'not-required': !property.required}">{{property.name}}{{property.required
? '*' : ''}}</label>
-          <div class="col-sm-9">
-            <input type="{{property.masked ? 'password' : 'text'}}" class="form-control
propertie-input" ng-required="property.required"  ng-disabled="editConfigurationDisabled"
name="{{property.name}}" ng-model="configuration[property.name]">
-            <div class="alert alert-danger no-margin-bottom top-margin" ng-show='property.required
&& propertiesForm[property.name].$error.required && !editConfigurationDisabled'>
-              This field is required.
+        <div class="form-group" ng-repeat="property in configurationMeta" ng-class="{'has-error'
: property.required && propertiesForm[property.name].$error.required && !editConfigurationDisabled}">
+          <label for="" class="control-label col-sm-3" ng-class="{'not-required': !property.required}">{{property.label
|| property.name}}{{property.required ? '*' : ''}}</label>
+          <div ng-switch="property.type">
+            <div class="col-sm-9 checkbox" ng-switch-when="boolean">
+              <input type="checkbox" class="propertie-input" ng-disabled="editConfigurationDisabled"
name="{{property.name}}" ng-model="configuration[property.name]" ng-true-value="true" ng-false-value="false"
popover="{{property.description}}" popover-title="{{property.name}}" popover-trigger="mouseenter">
+            </div>
+            <div class="col-sm-9" ng-switch-default>
+              <input type="{{property.masked ? 'password' : 'text'}}" class="form-control
propertie-input" ng-required="property.required"  ng-disabled="editConfigurationDisabled"
name="{{property.name}}" ng-model="configuration[property.name]" popover="{{property.description}}"
popover-title="{{property.name}}" popover-trigger="mouseenter" placeholder="{{property.placeholder}}">
+              <div class="alert alert-danger no-margin-bottom top-margin" ng-show='property.required
&& propertiesForm[property.name].$error.required && !editConfigurationDisabled'>
+                This field is required.
+              </div>
             </div>
           </div>
         </div>

http://git-wip-us.apache.org/repos/asf/ambari/blob/ce7bfeb0/ambari-admin/src/main/resources/ui/admin-web/test/unit/controllers/CreateViewInstanceCtrl.js
----------------------------------------------------------------------
diff --git a/ambari-admin/src/main/resources/ui/admin-web/test/unit/controllers/CreateViewInstanceCtrl.js
b/ambari-admin/src/main/resources/ui/admin-web/test/unit/controllers/CreateViewInstanceCtrl.js
index 69ebf66..ff54b19 100644
--- a/ambari-admin/src/main/resources/ui/admin-web/test/unit/controllers/CreateViewInstanceCtrl.js
+++ b/ambari-admin/src/main/resources/ui/admin-web/test/unit/controllers/CreateViewInstanceCtrl.js
@@ -18,7 +18,7 @@
 
 describe('#CreateViewInstanceCtrl', function () {
   var scope, ctrl, $httpBackend, View;
-  
+
   beforeEach(module('ambariAdminConsole', function($provide){
     $provide.value('$routeParams', {viewId: 'TestView'});
   }));
@@ -37,8 +37,10 @@ describe('#CreateViewInstanceCtrl', function () {
       "versions": [{"ViewVersionInfo": {}}]
     });
     $httpBackend.whenGET(/\/api\/v1\/views\/TestView\/versions\/1\.0\.0/).respond(200, {
-      "ViewVersionInfo": {}
+      "ViewVersionInfo": {"parameters": [{"name": "n", "default": "d"}]}
     });
+    $httpBackend.whenGET('template/modal/backdrop.html').respond(200, '<div></div>');
+    $httpBackend.whenGET('template/modal/window.html').respond(200, '<div></div>');
     scope = $rootScope.$new();
     ctrl = $controller('CreateViewInstanceCtrl', {$scope: scope});
   }));
@@ -53,5 +55,19 @@ describe('#CreateViewInstanceCtrl', function () {
     $httpBackend.flush();
     scope.save();
     expect(View.createInstance).toHaveBeenCalled();
-  });  
+  });
+
+  it('should set default property value before creating view instance', function () {
+    scope.form = {
+      instanceCreateForm: {
+        $dirty: true
+      }
+    };
+    scope.version = '1.0.0';
+    $httpBackend.expectGET('template/modal/backdrop.html');
+    $httpBackend.expectGET('template/modal/window.html');
+    scope.$digest();
+    $httpBackend.flush();
+    chai.expect(scope.view.ViewVersionInfo.parameters[0].value).to.equal('d');
+  });
 });
\ No newline at end of file


Mime
View raw message