application.js 3.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697
  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. /**
  38. * Determines if "Exit" menu-item should be shown
  39. * It should if cluster isn't installed
  40. * If cluster is installer, <code>isClusterDataLoaded</code> is checked
  41. * @type {boolean}
  42. */
  43. showExitLink: function () {
  44. if (App.router.get('clusterInstallCompleted')) {
  45. return this.get('isClusterDataLoaded');
  46. }
  47. return true;
  48. }.property('App.router.clusterInstallCompleted', 'isClusterDataLoaded'),
  49. init: function(){
  50. this._super();
  51. },
  52. startKeepAlivePoller: function() {
  53. if (!this.get('isPollerRunning')) {
  54. this.set('isPollerRunning',true);
  55. App.updater.run(this, 'getStack', 'isPollerRunning', App.sessionKeepAliveInterval);
  56. }
  57. },
  58. getStack: function(callback) {
  59. App.ajax.send({
  60. name: 'router.login.clusters',
  61. sender: this,
  62. callback: callback
  63. });
  64. },
  65. goToAdminView: function () {
  66. App.router.route("adminView");
  67. },
  68. showAboutPopup: function() {
  69. var self = this;
  70. App.ModalPopup.show({
  71. header: Em.I18n.t('common.aboutAmbari'),
  72. secondary: false,
  73. bodyClass: Em.View.extend({
  74. templateName: require('templates/common/about'),
  75. ambariVersion: this.get('ambariVersion')
  76. })
  77. });
  78. }
  79. });