Bläddra i källkod

Revert "AMBARI-10533. Admin View About says 2.0.0 (and links to Admin View are hardcoded to 2.0.0) (alexantonenko)"

This reverts commit ecaf2d15f3657ca53625434bbfcce2c36fbaf4b4.
Alex Antonenko 10 år sedan
förälder
incheckning
affca503f2

+ 0 - 7
ambari-admin/src/main/resources/ui/admin-web/app/assets/data/cluster/ambariServerInfo.json

@@ -1,7 +0,0 @@
-{
-  "RootServiceComponents" : {
-    "component_name" : "AMBARI_SERVER",
-    "component_version" : "2.0.0",
-    "service_name" : "AMBARI"
-  }
-}

+ 0 - 1
ambari-admin/src/main/resources/ui/admin-web/app/index.html

@@ -146,7 +146,6 @@
     <script src="scripts/services/User.js"></script>
     <script src="scripts/services/Group.js"></script>
     <script src="scripts/services/View.js"></script>
-    <script src="scripts/services/Component.js"></script>
     <script src="scripts/services/Cluster.js"></script>
     <script src="scripts/services/Alert.js"></script>
     <script src="scripts/services/PermissionLoader.js"></script>

+ 9 - 14
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', 'Component', 'View', function($scope, $window, Auth, Alert, $modal, Cluster, Component, View) {
+.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;
@@ -31,19 +31,14 @@ angular.module('ambariAdminConsole')
   };
 
   $scope.about = function() {
-    Component.getAmbariServer().then(function(component) {
-      var modalInstance = $modal.open({
-        templateUrl:'views/modals/AboutModal.html',
-        controller: ['$scope', function($scope) {
-          $scope.component = component;
-          $scope.ok = function() {
-            modalInstance.close();
-          };
-        }]
-      });
-    }).catch(function() {
-      Alert.error('Cannot load component status');
-    });
+  	var modalInstance = $modal.open({
+  		templateUrl:'views/modals/AboutModal.html',
+  		controller: ['$scope', function($scope) {
+  			$scope.ok = function() {
+  				modalInstance.close();
+  			};
+  		}]
+  	});
   };
 
   $scope.currentUser = Auth.getCurrentUser();

+ 0 - 30
ambari-admin/src/main/resources/ui/admin-web/app/scripts/services/Component.js

@@ -1,30 +0,0 @@
-/**
- * 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.
- */
-'use strict';
-
-angular.module('ambariAdminConsole')
-  .factory('Component', ['$http', '$q', 'Settings', function($http, $q, Settings) {
-    return {
-      getAmbariServer: function() {
-        return $http.get(Settings.baseUrl + '/services/AMBARI/components/AMBARI_SERVER?fields=RootServiceComponents/component_version&minimal_response=true')
-          .then(function(response) {
-            return response.data;
-          });
-      }
-    };
-  }]);

+ 2 - 2
ambari-admin/src/main/resources/ui/admin-web/app/views/modals/AboutModal.html

@@ -28,7 +28,7 @@
       <div class="project">Apache Ambari</div>
       <br>
       <span id="i18n-33">Version</span>
-      <span>{{component.RootServiceComponents.component_version}}</span>
+      <script id="metamorph-199-start" type="text/x-placeholder"></script>2.0.0<script id="metamorph-199-end" type="text/x-placeholder"></script>
       <br>
       <br>
       <a href="http://ambari.apache.org/" target="_blank"><span id="i18n-34">Get involved!</span></a>
@@ -39,4 +39,4 @@
 </div>
 <div class="modal-footer">
     <button class="btn btn-success" ng-click="ok()">OK</button>
-</div>
+</div>

+ 0 - 56
ambari-admin/src/main/resources/ui/admin-web/test/unit/services/Component_test.js

@@ -1,56 +0,0 @@
-/**
- * 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('#Component', function () {
-  var componentService,
-    httpBackend,
-    Settings;
-
-  beforeEach(function() {
-    module('ambariAdminConsole');
-
-    inject(function(_Component_, $httpBackend, _Settings_) {
-      componentService = _Component_;
-      httpBackend = $httpBackend;
-      Settings = _Settings_;
-    });
-  });
-
-  afterEach(function() {
-    httpBackend.verifyNoOutstandingExpectation();
-    httpBackend.verifyNoOutstandingRequest();
-  });
-
-  var returnData = {
-    RootServiceComponents: {
-      'component_name': "AMBARI_SERVER",
-      'component_version': "2.0.0",
-      'service_name': "AMBARI"
-    }
-  };
-  it('should get the information of the Ambari server', function() {
-    httpBackend.whenGET(/\/api\/v1\/services\/AMBARI\/components\/AMBARI_SERVER\?.*/).respond(returnData);
-
-    componentService.getAmbariServer().then(function(response) {
-      expect(response).toEqual(returnData);
-      expect(response.RootServiceComponents.component_version).toEqual('2.0.0');
-    });
-
-    httpBackend.flush();
-  });
-});

+ 6 - 22
ambari-web/app/router.js

@@ -271,9 +271,12 @@ App.Router = Em.Router.extend({
     } else {
       controller.postLogin(false, false, null);
     }
+
   },
 
   loginGetClustersSuccessCallback: function (clustersData, opt, params) {
+    var adminViewUrl = '/views/ADMIN_VIEW/2.0.0/INSTANCE/#/';
+    //TODO: Replace hard coded value with query. Same in templates/application.hbs
     var loginController = this.get('loginController');
     var loginData = params.loginData;
     var privileges = loginData.privileges || [];
@@ -287,12 +290,8 @@ App.Router = Em.Router.extend({
           router.setClusterInstalled(clustersData);
           transitionToApp = true;
         } else {
-          App.ajax.send({
-            name: 'ambari.service.load_server_version',
-            sender: this,
-            success: 'adminViewInfoSuccessCallback',
-            error: 'adminViewInfoErrorCallback'
-          });
+          window.location = adminViewUrl;
+          return;
         }
       } else {
         if (clustersData.items.length) {
@@ -328,16 +327,6 @@ App.Router = Em.Router.extend({
       }
   },
 
-  adminViewInfoSuccessCallback: function(data) {
-    if (data && data.RootServiceComponents && data.RootServiceComponents.component_version) {
-      window.location.replace('/views/ADMIN_VIEW/'+data.RootServiceComponents.component_version+'/INSTANCE/#/');
-    }
-  },
-
-  adminViewInfoErrorCallback: function (req) {
-    console.log("Get admin view version error: " + req.statusCode);
-  },
-
   loginGetClustersErrorCallback: function (req) {
     console.log("Get clusters error: " + req.statusCode);
   },
@@ -516,12 +505,7 @@ App.Router = Em.Router.extend({
             router.transitionTo('login');
           });
         } else {
-          App.ajax.send({
-            name: 'ambari.service.load_server_version',
-            sender: router,
-            success: 'adminViewInfoSuccessCallback',
-            error: 'adminViewInfoErrorCallback'
-          });
+            window.location.replace('/views/ADMIN_VIEW/2.0.0/INSTANCE/#/');
         }
       }
     }),

+ 1 - 6
ambari-web/app/views/main/admin/stack_upgrade/versions_view.js

@@ -168,12 +168,7 @@ App.MainAdminStackVersionsView = Em.View.extend({
    */
   goToVersions: function () {
     return App.showConfirmationPopup(function () {
-        App.ajax.send({
-          name: 'ambari.service.load_server_version',
-          sender: this
-        }).then(function(data) {
-          window.location.replace('/views/ADMIN_VIEW/'+data.RootServiceComponents.component_version+'/INSTANCE/#/stackVersions');
-        });
+      window.location.replace('/views/ADMIN_VIEW/2.0.0/INSTANCE/#/stackVersions');
     },
     Em.I18n.t('admin.stackVersions.manageVersions.popup.body'),
     null,

+ 0 - 38
ambari-web/test/router_test.js

@@ -108,42 +108,4 @@ describe('App.Router', function () {
 
   });
 
-  describe('#adminViewInfoSuccessCallback', function() {
-    beforeEach(function() {
-      sinon.stub(window.location, 'replace', Em.K);
-    });
-
-    afterEach(function() {
-      window.location.replace.restore();
-    });
-
-    it('should redirect to the latest version of admin view', function() {
-      var tests = [
-        {
-          mockData: {
-            RootServiceComponents: {
-              component_version: '2.0.0'
-            }
-          },
-          expected: '/views/ADMIN_VIEW/2.0.0/INSTANCE/#/'
-        },
-        {
-          mockData: {
-            RootServiceComponents: {
-              component_version: '2.1.0'
-            }
-          },
-          expected: '/views/ADMIN_VIEW/2.1.0/INSTANCE/#/'
-        }
-      ];
-
-      tests.forEach(function(data) {
-        router.adminViewInfoSuccessCallback(data.mockData);
-        expect(window.location.replace.calledWith(data.expected)).to.be.true;
-      });
-
-    });
-
-  });
-
 });

+ 2 - 12
ambari-web/test/views/main/admin/stack_upgrade/version_view_test.js

@@ -281,26 +281,16 @@ describe('App.mainAdminStackVersionsView', function () {
     before(function () {
       sinon.spy(App, 'showConfirmationPopup', Em.K);
       sinon.stub(window.location, 'replace', Em.K);
-      var data = {
-        RootServiceComponents: {
-          component_version: '2.1.0'
-        }
-      };
-      sinon.stub(App.ajax, 'send').returns({then: function(callback) { callback(data); }});
     });
-
     after(function () {
       App.showConfirmationPopup.restore();
       window.location.replace.restore();
-      App.ajax.send.restore();
     });
-
-    it("should go to link using the version retrieved by query", function() {
+    it("", function() {
       var popup = view.goToVersions();
       expect(App.showConfirmationPopup.calledOnce).to.be.true;
       popup.onPrimary();
-      expect(App.ajax.send.calledOnce).to.be.true;
-      expect(window.location.replace.calledWith('/views/ADMIN_VIEW/2.1.0/INSTANCE/#/stackVersions')).to.be.true;
+      expect(window.location.replace.calledWith('/views/ADMIN_VIEW/2.0.0/INSTANCE/#/stackVersions')).to.be.true;
     });
   });