application.js 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101
  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. var App = require('app');
  19. App.ApplicationController = Em.Controller.extend(App.UserPref, {
  20. name: 'applicationController',
  21. isPollerRunning: false,
  22. clusterName: function () {
  23. return (App.router.get('clusterController.clusterName') || 'My Cluster');
  24. }.property('App.router.clusterController.clusterName'),
  25. /**
  26. * set ambari server version from installerController or mainController, making sure version shown up all the time
  27. */
  28. ambariVersion: function () {
  29. return (App.router.get('installerController.ambariServerVersion') || App.router.get('mainController.ambariServerVersion') || Em.I18n.t('common.notAvailable'));
  30. }.property('App.router.installerController.ambariServerVersion', 'App.router.mainController.ambariServerVersion'),
  31. clusterDisplayName: function () {
  32. var name = this.get('clusterName');
  33. return name.length > 13 ? name.substr(0, 10) + "..." : name;
  34. }.property('clusterName'),
  35. isClusterDataLoaded: Em.computed.and('App.router.clusterController.isLoaded','App.router.loggedIn'),
  36. isExistingClusterDataLoaded: Em.computed.and('App.router.clusterInstallCompleted', 'isClusterDataLoaded'),
  37. enableLinks: function() {
  38. return this.get('isExistingClusterDataLoaded') && !App.get('isOnlyViewUser');
  39. }.property('isExistingClusterDataLoaded'),
  40. /**
  41. * Determines if "Exit" menu-item should be shown
  42. * It should if cluster isn't installed
  43. * If cluster is installer, <code>isClusterDataLoaded</code> is checked
  44. * @type {boolean}
  45. */
  46. showExitLink: function () {
  47. if (App.router.get('clusterInstallCompleted')) {
  48. return this.get('isClusterDataLoaded');
  49. }
  50. return true;
  51. }.property('App.router.clusterInstallCompleted', 'isClusterDataLoaded'),
  52. init: function(){
  53. this._super();
  54. },
  55. startKeepAlivePoller: function() {
  56. if (!this.get('isPollerRunning')) {
  57. this.set('isPollerRunning',true);
  58. App.updater.run(this, 'getStack', 'isPollerRunning', App.sessionKeepAliveInterval);
  59. }
  60. },
  61. getStack: function(callback) {
  62. App.ajax.send({
  63. name: 'router.login.clusters',
  64. sender: this,
  65. callback: callback
  66. });
  67. },
  68. goToAdminView: function () {
  69. App.router.route("adminView");
  70. },
  71. showAboutPopup: function() {
  72. var self = this;
  73. App.ModalPopup.show({
  74. header: Em.I18n.t('common.aboutAmbari'),
  75. secondary: false,
  76. bodyClass: Em.View.extend({
  77. templateName: require('templates/common/about'),
  78. ambariVersion: this.get('ambariVersion')
  79. })
  80. });
  81. }
  82. });