mainCtrl.js 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. /**
  2. * Licensed to the Apache Software Foundation (ASF) under one
  3. * or more contributor license agreements. See the NOTICE file
  4. * distributed with this work for additional information
  5. * regarding copyright ownership. The ASF licenses this file
  6. * to you under the Apache License, Version 2.0 (the
  7. * "License"); you may not use this file except in compliance
  8. * with the License. You may obtain a copy of the License at
  9. *
  10. * http://www.apache.org/licenses/LICENSE-2.0
  11. *
  12. * Unless required by applicable law or agreed to in writing, software
  13. * distributed under the License is distributed on an "AS IS" BASIS,
  14. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  15. * See the License for the specific language governing permissions and
  16. * limitations under the License.
  17. */
  18. 'use strict';
  19. angular.module('ambariAdminConsole')
  20. .controller('MainCtrl',['$scope', '$window','Auth', 'Alert', '$modal', 'Cluster', 'View', function($scope, $window, Auth, Alert, $modal, Cluster, View) {
  21. $scope.signOut = function() {
  22. var data = JSON.parse(localStorage.ambari);
  23. delete data.app.authenticated;
  24. delete data.app.loginName;
  25. delete data.app.user;
  26. localStorage.ambari = JSON.stringify(data);
  27. $window.location.pathname = '';
  28. $scope.hello = "hello";
  29. Auth.signout();
  30. };
  31. $scope.about = function() {
  32. var modalInstance = $modal.open({
  33. templateUrl:'views/modals/AboutModal.html',
  34. controller: ['$scope', function($scope) {
  35. $scope.ok = function() {
  36. modalInstance.close();
  37. };
  38. }]
  39. });
  40. };
  41. $scope.currentUser = Auth.getCurrentUser();
  42. $scope.cluster = null;
  43. $scope.isLoaded = null;
  44. Cluster.getStatus().then(function(cluster) {
  45. $scope.cluster = cluster;
  46. $scope.isLoaded = true;
  47. }).catch(function(data) {
  48. Alert.error('Check cluster status error', data.data.message);
  49. });
  50. $scope.viewInstances = [];
  51. View.getAllVisibleInstance().then(function(instances) {
  52. $scope.viewInstances = instances;
  53. });
  54. $scope.gotoViewsDashboard =function() {
  55. window.location = '/#/main/views';
  56. };
  57. }]);