Repository: ambari
Updated Branches:
  refs/heads/trunk f38162a8b -> 57bded5f2


AMBARI-7730. Slider View: Provide more detailed tooltips for view parameters. 
(Max Shepel via akovalenko)


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

Branch: refs/heads/trunk
Commit: 57bded5f23ef526cc92b94e6d8019670d797faf6
Parents: f38162a
Author: Aleksandr Kovalenko <[email protected]>
Authored: Fri Oct 10 18:36:56 2014 +0300
Committer: Aleksandr Kovalenko <[email protected]>
Committed: Fri Oct 10 18:36:56 2014 +0300

----------------------------------------------------------------------
 .../ambariViews/CreateViewInstanceCtrl.js       | 10 ++-
 .../resources/ui/admin-web/app/styles/main.css  |  1 +
 .../ambariViews/CreateViewInstanceCtrl_test.js  | 77 ++++++++++++++++++++
 .../views/slider/src/main/resources/view.xml    | 12 +--
 4 files changed, 94 insertions(+), 6 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ambari/blob/57bded5f/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 40a90c8..bfabd59 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
@@ -18,12 +18,20 @@
 'use strict';
 
 angular.module('ambariAdminConsole')
-.controller('CreateViewInstanceCtrl',['$scope', 'View', 'Alert', 
'$routeParams', '$location', function($scope, View, Alert, $routeParams, 
$location) {
+.controller('CreateViewInstanceCtrl',['$scope', 'View', 'Alert', 'Auth', 
'$routeParams', '$location', function($scope, View, Alert, Auth, $routeParams, 
$location) {
   $scope.form = {};
 
   function loadMeta(){
     View.getMeta($routeParams.viewId, $scope.version).then(function(data) {
       var viewVersion = data.data;
+      var pattern = /{username}/;
+      viewVersion.ViewVersionInfo.parameters = 
viewVersion.ViewVersionInfo.parameters.map(function (item) {
+        var parameter = item;
+        if (pattern.test(item.description)) {
+          parameter.description = item.description.replace(pattern, 
Auth.getCurrentUser());
+        }
+        return parameter;
+      });
       $scope.view = viewVersion;
 
       $scope.instance = {

http://git-wip-us.apache.org/repos/asf/ambari/blob/57bded5f/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 bd2a18a..b6189f8 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
@@ -202,6 +202,7 @@
 
 .tooltip-inner{
   word-wrap: break-word;
+    text-align: left;
 }
 
  .instances-table{

http://git-wip-us.apache.org/repos/asf/ambari/blob/57bded5f/ambari-web/ambari-admin/src/main/resources/ui/admin-web/test/unit/controllers/ambariViews/CreateViewInstanceCtrl_test.js
----------------------------------------------------------------------
diff --git 
a/ambari-web/ambari-admin/src/main/resources/ui/admin-web/test/unit/controllers/ambariViews/CreateViewInstanceCtrl_test.js
 
b/ambari-web/ambari-admin/src/main/resources/ui/admin-web/test/unit/controllers/ambariViews/CreateViewInstanceCtrl_test.js
new file mode 100644
index 0000000..4deaf52
--- /dev/null
+++ 
b/ambari-web/ambari-admin/src/main/resources/ui/admin-web/test/unit/controllers/ambariViews/CreateViewInstanceCtrl_test.js
@@ -0,0 +1,77 @@
+/**
+ * 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.
+ */
+
+describe('#CreateViewInstanceCtrl', function () {
+
+  describe('loadMeta', function () {
+
+    var scope, ctrl, $window, $q, deferred;
+
+    beforeEach(module('ambariAdminConsole', function ($provide) {
+      $provide.value('$window', {
+        location: {
+          pathname: 
'http://c6401.ambari.apache.org:8080/views/ADMIN_VIEW/1.0.0/INSTANCE/#/'
+        }
+      });
+      $provide.value('Auth', {
+        getCurrentUser: function () {
+          return 'admin';
+        }
+      });
+      $provide.value('View', {
+        getMeta: function () {
+          return deferred.promise;
+        },
+        getVersions: function () {
+          var dfd = $q.defer();
+          return dfd.promise;
+        }
+      });
+      $provide.value('$routeParams', {
+        viewId: 'ADMIN_VIEW'
+      });
+    }));
+
+    beforeEach(inject(function ($rootScope, $controller, _$window_, _$q_) {
+      $q = _$q_;
+      $window = _$window_;
+      scope = $rootScope.$new();
+      deferred = $q.defer();
+      ctrl = $controller('CreateViewInstanceCtrl', {
+        $scope: scope
+      });
+    }));
+
+    it('should parse {username}', function () {
+      deferred.resolve({
+        data: {
+          ViewVersionInfo: {
+            parameters: [{
+              description: '{username}'
+            }]
+          }
+        }
+      });
+      scope.version = '1.0.0';
+      scope.$digest();
+      
chai.expect(scope.view.ViewVersionInfo.parameters[0].description).to.equal('admin');
+    });
+
+  });
+
+});

http://git-wip-us.apache.org/repos/asf/ambari/blob/57bded5f/contrib/views/slider/src/main/resources/view.xml
----------------------------------------------------------------------
diff --git a/contrib/views/slider/src/main/resources/view.xml 
b/contrib/views/slider/src/main/resources/view.xml
index cf86d6a..5dcc397 100644
--- a/contrib/views/slider/src/main/resources/view.xml
+++ b/contrib/views/slider/src/main/resources/view.xml
@@ -38,20 +38,22 @@ limitations under the License. Kerberos, LDAP, Custom. 
Binary/Htt
        </parameter>
        <parameter>
                <name>slider.user</name>
-               <description>Slider user</description>
+               <description>User this view instance should run as. Specifying 
an empty value runs view as YARN service user (for example 'yarn'). Specifying 
'{username}' runs the view as the currently logged in user. Specifying any 
other value runs the view as that user.
+                       Administrators should check that the HDFS home folder 
for that user is created and accessible.
+        </description>
                <required>false</required>
        </parameter>
        <parameter>
                <name>view.kerberos.principal</name>
-               <description>Kerberos principal associated with this view. For
-                       example: ambari/[email protected]
+               <description>Kerberos principal associated with this view. For 
example: ambari/[email protected].
+                       Administrators should make sure that HDFS service has 
the 'hadoop.proxyuser.[user].groups' and 'hadoop.proxyuser.[user].hosts' 
configs populated in 'core-site.xml'.
                </description>
                <required>false</required>
        </parameter>
        <parameter>
                <name>view.kerberos.principal.keytab</name>
-               <description>Path to the Kerberos principal keytab used for 
view's
-                       user. For example: 
/etc/security/keytabs/ambari.headless.keytab
+               <description>Path to the Kerberos principal keytab used for 
view's user. For example: /etc/security/keytabs/ambari.headless.keytab
+                       Administrators should make sure that HDFS service has 
the 'hadoop.proxyuser.[user].groups' and 'hadoop.proxyuser.[user].hosts' 
configs populated in 'core-site.xml'.
                </description>
                <required>false</required>
        </parameter>

Reply via email to