ambari-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ababiic...@apache.org
Subject git commit: AMBARI-7744 Admin View: include Views icon in header and link to /#/main/views in web. (Levgen Gorbachev via ababiichuk)
Date Sat, 11 Oct 2014 12:30:22 GMT
Repository: ambari
Updated Branches:
  refs/heads/trunk aa837da8e -> ffb8e3fa0


AMBARI-7744 Admin View: include Views icon in header and link to /#/main/views in web. (Levgen
Gorbachev via ababiichuk)


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

Branch: refs/heads/trunk
Commit: ffb8e3fa016601259fd9030ab92cd2265a39482e
Parents: aa837da
Author: ababiichuk <ababiichuk@hortonworks.com>
Authored: Sat Oct 11 14:54:30 2014 +0300
Committer: ababiichuk <ababiichuk@hortonworks.com>
Committed: Sat Oct 11 14:54:41 2014 +0300

----------------------------------------------------------------------
 .../main/resources/ui/admin-web/app/index.html  |  9 ++++
 .../app/scripts/controllers/mainCtrl.js         | 11 +++-
 .../ui/admin-web/app/scripts/services/View.js   | 25 +++++++++
 .../resources/ui/admin-web/app/styles/main.css  | 29 ++++++++++
 .../test/unit/controllers/mainCtrl_test.js      | 57 +++++++++++++++++++-
 5 files changed, 129 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ambari/blob/ffb8e3fa/ambari-admin/src/main/resources/ui/admin-web/app/index.html
----------------------------------------------------------------------
diff --git a/ambari-admin/src/main/resources/ui/admin-web/app/index.html b/ambari-admin/src/main/resources/ui/admin-web/app/index.html
index 1b517d5..f0f3f18 100644
--- a/ambari-admin/src/main/resources/ui/admin-web/app/index.html
+++ b/ambari-admin/src/main/resources/ui/admin-web/app/index.html
@@ -51,6 +51,15 @@
             <a href="#/" class="brand" title="Apache Ambari">Ambari</a>
             <ul class="nav navbar-nav navbar-right">
               <li>
+                <div class="btn-group navbar-views-dropdown" dropdown is-open="viewsdropdown.isopen"
ng-mouseover="viewsdropdown.isopen=true" ng-mouseout="viewsdropdown.isopen=false">
+                  <a href="/#/main/views" ng-click="gotoViewsDashboard()" class="dropdown-toggle"><i
class="fa fa-th"></i></a>
+                  <ul class="dropdown-menu" role="menu">
+                    <li ng-repeat="instance in viewInstances"><a href="/#/main{{instance.context_path}}"
ng-click="about()">{{instance.label}}</a></li>
+                    <li ng-show="!viewInstances.length" class="disabled"><a>No
Views</a></li>
+                  </ul>
+                </div>
+              </li>
+              <li>
                 <div class="btn-group" dropdown is-open="status.isopen">
                   <button type="button" class="btn btn-default dropdown-toggle navbar-btn"
ng-disabled="disabled">
                     <i class="fa fa-user"></i> {{currentUser}} <span class="caret"></span>

http://git-wip-us.apache.org/repos/asf/ambari/blob/ffb8e3fa/ambari-admin/src/main/resources/ui/admin-web/app/scripts/controllers/mainCtrl.js
----------------------------------------------------------------------
diff --git a/ambari-admin/src/main/resources/ui/admin-web/app/scripts/controllers/mainCtrl.js
b/ambari-admin/src/main/resources/ui/admin-web/app/scripts/controllers/mainCtrl.js
index 2a5c64b..eaed5f5 100644
--- a/ambari-admin/src/main/resources/ui/admin-web/app/scripts/controllers/mainCtrl.js
+++ b/ambari-admin/src/main/resources/ui/admin-web/app/scripts/controllers/mainCtrl.js
@@ -18,7 +18,7 @@
 'use strict';
 
 angular.module('ambariAdminConsole')
-.controller('MainCtrl',['$scope', '$window','Auth', 'Alert', '$modal', 'Cluster', function($scope,
$window, Auth, Alert, $modal, Cluster) {
+.controller('MainCtrl',['$scope', '$window','Auth', 'Alert', '$modal', 'Cluster', 'View',
function($scope, $window, Auth, Alert, $modal, Cluster, View) {
   $scope.signOut = function() {
     var data = JSON.parse(localStorage.ambari);
     delete data.app.authenticated;
@@ -53,4 +53,13 @@ angular.module('ambariAdminConsole')
     Alert.error('Check cluster status error', data.data.message);
   });
 
+  $scope.viewInstances = [];
+  View.getAllVisibleInstance().then(function(instances) {
+    $scope.viewInstances = instances;
+  });
+
+  $scope.gotoViewsDashboard =function() {
+    window.location = '/#/main/views';
+  };
+
 }]);

http://git-wip-us.apache.org/repos/asf/ambari/blob/ffb8e3fa/ambari-admin/src/main/resources/ui/admin-web/app/scripts/services/View.js
----------------------------------------------------------------------
diff --git a/ambari-admin/src/main/resources/ui/admin-web/app/scripts/services/View.js b/ambari-admin/src/main/resources/ui/admin-web/app/scripts/services/View.js
index 20fe59f..65c5c38 100644
--- a/ambari-admin/src/main/resources/ui/admin-web/app/scripts/services/View.js
+++ b/ambari-admin/src/main/resources/ui/admin-web/app/scripts/services/View.js
@@ -251,6 +251,31 @@ angular.module('ambariAdminConsole')
     return deferred;
   };
 
+  View.getAllVisibleInstance = function() {
+    var deferred = $q.defer();
+    $http({
+      method: 'GET',
+      url: Settings.baseUrl + '/views',
+      params:{
+        'fields': 'versions/instances/ViewInstanceInfo',
+        'versions/ViewVersionInfo/system': false,
+        'versions/instances/ViewInstanceInfo/visible': true
+      }
+    }).then(function(data) {
+      var instances = [];
+      data.data.items.forEach(function(view) {
+        view.versions.forEach(function(version) {
+          version.instances.forEach(function(instance) {
+            instances.push(instance.ViewInstanceInfo);
+          });
+        })
+      });
+      deferred.resolve(instances);
+    });
+
+    return deferred.promise;
+  };
+
   View.all = function() {
     var deferred = $q.defer();
     var fields = [

http://git-wip-us.apache.org/repos/asf/ambari/blob/ffb8e3fa/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 b6189f8..789af82 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
@@ -395,6 +395,35 @@ a.gotoinstance{
 /*
   Style topnav menu
 */
+.navbar-views-dropdown > a{
+  color: #c3c3c3;
+  font-size: 1.3em;
+  padding: 10px 25px 18px;
+  display: block;
+  box-shadow: none!important;
+  background: none!important;
+  text-decoration: none;
+}
+.navbar-views-dropdown > a:hover{
+  color: #fff;
+}
+.navbar-views-dropdown > a > i{
+  display: block;
+  margin-top: 1px;
+  margin-bottom: -12px;
+}
+.navbar-views-dropdown .dropdown-menu{
+  margin-top: -2px;
+}
+
+.navbar-views-dropdown .dropdown-menu a:hover{
+  background: #666;
+  color: #fff;
+}
+.navbar-views-dropdown .dropdown-menu .disabled a:hover{
+  background: none;
+  color: #999;
+}
 #top-nav .navbar.navbar-static-top{
   min-height: 40px;
 }

http://git-wip-us.apache.org/repos/asf/ambari/blob/ffb8e3fa/ambari-admin/src/main/resources/ui/admin-web/test/unit/controllers/mainCtrl_test.js
----------------------------------------------------------------------
diff --git a/ambari-admin/src/main/resources/ui/admin-web/test/unit/controllers/mainCtrl_test.js
b/ambari-admin/src/main/resources/ui/admin-web/test/unit/controllers/mainCtrl_test.js
index c66d96e..23afcb6 100644
--- a/ambari-admin/src/main/resources/ui/admin-web/test/unit/controllers/mainCtrl_test.js
+++ b/ambari-admin/src/main/resources/ui/admin-web/test/unit/controllers/mainCtrl_test.js
@@ -36,6 +36,54 @@ describe('#Auth', function () {
       $window = _$window_;
       $httpBackend = _$httpBackend_;
       $httpBackend.whenGET('/api/v1/logout').respond(200,{message: "successfully logged out"});
+      $httpBackend.whenGET('/api/v1/views?fields=versions%2Finstances%2FViewInstanceInfo&versions%2FViewVersionInfo%2Fsystem=false&versions%2Finstances%2FViewInstanceInfo%2Fvisible=true')
+        .respond(200,{
+          "href": "http://c6401.ambari.apache.org:8080/api/v1/views?fields=versions/instances/ViewInstanceInfo&versions/ViewVersionInfo/system=false&versions/instances/ViewInstanceInfo/visible=true",
+          "items": [
+            {
+              "ViewInfo": {
+                "view_name": "SLIDER"
+              },
+              "href": "http://c6401.ambari.apache.org:8080/api/v1/views/SLIDER",
+              "versions": [
+                {
+                  "ViewVersionInfo": {
+                    "system": false,
+                    "version": "1.0.0",
+                    "view_name": "SLIDER"
+                  },
+                  "href": "http://c6401.ambari.apache.org:8080/api/v1/views/SLIDER/versions/1.0.0",
+                  "instances": [
+                    {
+                      "ViewInstanceInfo": {
+                        "context_path": "/views/SLIDER/1.0.0/VisibleInstance",
+                        "description": "VisibleInstance",
+                        "icon64_path": null,
+                        "icon_path": null,
+                        "instance_data": {},
+                        "instance_name": "VisibleInstance",
+                        "label": "VisibleInstance",
+                        "properties": {
+                          "ambari.server.password": "123",
+                          "ambari.server.url": "123",
+                          "ambari.server.username": "123",
+                          "slider.user": null,
+                          "view.kerberos.principal": null,
+                          "view.kerberos.principal.keytab": null
+                        },
+                        "static": false,
+                        "version": "1.0.0",
+                        "view_name": "SLIDER",
+                        "visible": true
+                      },
+                      "href": "http://c6401.ambari.apache.org:8080/api/v1/views/SLIDER/versions/1.0.0/instances/VisibleInstance"
+                    }
+                  ]
+                }
+              ]
+            }
+          ]
+        });
       scope = $rootScope.$new();
       scope.$apply();
       ctrl = $controller('MainCtrl', {$scope: scope});
@@ -43,12 +91,19 @@ describe('#Auth', function () {
 
     it('should reset window.location and ambari localstorage', function () {
       scope.signOut();
-      $httpBackend.flush();
       chai.expect($window.location.pathname).to.be.empty;
       var data = JSON.parse(localStorage.ambari);
       chai.expect(data.app.authenticated).to.equal(undefined);
       chai.expect(data.app.loginName).to.equal(undefined);
       chai.expect(data.app.user).to.equal(undefined);
+      $httpBackend.flush();
+    });
+
+    it('should get visible view instances and show them in top nav menu', function() {
+      $httpBackend.flush();
+
+      chai.expect(scope.viewInstances.length).to.equal(1);
+      chai.expect(scope.viewInstances[0].instance_name).to.equal('VisibleInstance');
     });
   });
 });
\ No newline at end of file


Mime
View raw message