123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276 |
- /**
- * 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.
- */
- var App = require('app');
- var uiEffects = require('utils/ui_effects');
- App.HostComponentView = Em.View.extend({
- templateName: require('templates/main/host/details/host_component'),
- /**
- * @type {App.HostComponent}
- */
- content: null,
- /**
- * @type {App.HostComponent}
- */
- hostComponent: function () {
- var hostComponent = null;
- var serviceComponent = this.get('content');
- var host = App.router.get('mainHostDetailsController.content');
- if (host) {
- hostComponent = host.get('hostComponents').findProperty('componentName', serviceComponent.get('componentName'));
- }
- return hostComponent;
- }.property('content', 'App.router.mainHostDetailsController.content'),
- /**
- * @type {String}
- */
- workStatus: function () {
- var workStatus = this.get('content.workStatus');
- var hostComponent = this.get('hostComponent');
- if (hostComponent) {
- workStatus = hostComponent.get('workStatus');
- }
- return workStatus;
- }.property('content.workStatus', 'hostComponent.workStatus'),
- /**
- * Return host component text status
- * @type {String}
- */
- componentTextStatus: function () {
- var componentTextStatus = this.get('content.componentTextStatus');
- var hostComponent = this.get('hostComponent');
- if (hostComponent) {
- componentTextStatus = hostComponent.get('componentTextStatus');
- }
- return componentTextStatus;
- }.property('content.passiveState','workStatus'),
- /**
- * CSS-class for host component status
- * @type {String}
- */
- statusClass: function () {
- //Class when install failed
- if (this.get('workStatus') === App.HostComponentStatus.install_failed) {
- return 'health-status-color-red icon-cog';
- }
- //Class when installing
- if (this.get('workStatus') === App.HostComponentStatus.installing) {
- return 'health-status-color-blue icon-cog';
- }
- //For all other cases
- return 'health-status-' + App.HostComponentStatus.getKeyName(this.get('workStatus'));
- }.property('workStatus'),
- /**
- * CSS-icon-class for host component status
- * @type {String}
- */
- statusIconClass: function () {
- return Em.getWithDefault({
- 'health-status-started': App.healthIconClassGreen,
- 'health-status-starting': App.healthIconClassGreen,
- 'health-status-installed': App.healthIconClassRed,
- 'health-status-stopping': App.healthIconClassRed,
- 'health-status-unknown': App.healthIconClassYellow,
- 'health-status-DEAD-ORANGE': App.healthIconClassOrange
- }, this.get('statusClass'), '');
- }.property('statusClass'),
- /**
- * CSS-class for disabling drop-down menu with list of host component actions
- * Disabled if host's <code>healthClass</code> is health-status-DEAD-YELLOW (lost heartbeat)
- * @type {String}
- */
- disabled: function () {
- return (this.get('parentView.content.healthClass') === "health-status-DEAD-YELLOW") ? 'disabled' : '';
- }.property('parentView.content.healthClass'),
- /**
- * For Upgrade failed state
- * @type {bool}
- */
- isUpgradeFailed: function () {
- return App.HostComponentStatus.getKeyName(this.get('workStatus')) === "upgrade_failed";
- }.property("workStatus"),
- /**
- * For Install failed state
- * @type {bool}
- */
- isInstallFailed: function () {
- return App.HostComponentStatus.getKeyName(this.get('workStatus')) === "install_failed";
- }.property("workStatus"),
- /**
- * For Started and Starting states
- * @type {bool}
- */
- isStart: function () {
- return [App.HostComponentStatus.started, App.HostComponentStatus.starting].contains(this.get('workStatus'));
- }.property('workStatus'),
- /**
- * For Installed state
- * @type {bool}
- */
- isStop: function () {
- return (this.get('workStatus') == App.HostComponentStatus.stopped);
- }.property('workStatus'),
- /**
- * For Installing state
- * @type {bool}
- */
- isInstalling: function () {
- return (this.get('workStatus') == App.HostComponentStatus.installing);
- }.property('workStatus'),
- /**
- * For Init state
- * @type {bool}
- */
- isInit: function() {
- return this.get('workStatus') == App.HostComponentStatus.init;
- }.property('workStatus'),
- /**
- * No action available while component is starting/stopping/unknown
- * @type {String}
- */
- noActionAvailable: function () {
- var workStatus = this.get('workStatus');
- return [App.HostComponentStatus.starting, App.HostComponentStatus.stopping,
- App.HostComponentStatus.unknown, App.HostComponentStatus.disabled].contains(workStatus) ? "hidden" : '';
- }.property('workStatus'),
- /**
- * For Stopping or Starting states
- * @type {bool}
- */
- isInProgress: function () {
- return (this.get('workStatus') === App.HostComponentStatus.stopping ||
- this.get('workStatus') === App.HostComponentStatus.starting);
- }.property('workStatus'),
- /**
- * For OFF <code>passiveState</code> of host component
- * @type {bool}
- */
- isActive: function () {
- return (this.get('content.passiveState') == "OFF");
- }.property('content.passiveState'),
- /**
- * For PASSIVE <code>passiveState</code> of host or service
- * @type {bool}
- */
- isImplied: function() {
- return (this.get('parentView.content.passiveState') === 'ON' || this.get('content.service.passiveState') === 'ON');
- }.property('parentView.content.passiveState', 'content.service.passiveState'),
- /**
- * Shows whether we need to show Delete button
- * @type {bool}
- */
- isDeletableComponent: function () {
- return App.get('components.deletable').contains(this.get('content.componentName'));
- }.property('content'),
- /**
- * Host component with some <code>workStatus</code> can't be deleted (so, disable such action in the dropdown list)
- * @type {bool}
- */
- isDeleteComponentDisabled: function () {
- return !(this.get('isComponentRecommissionAvailable') || [App.HostComponentStatus.stopped, App.HostComponentStatus.unknown, App.HostComponentStatus.install_failed, App.HostComponentStatus.upgrade_failed, App.HostComponentStatus.init].contains(this.get('workStatus')));
- }.property('workStatus','isComponentRecommissionAvailable'),
- /**
- * Check if component may be reassinged to another host
- * @type {bool}
- */
- isReassignable: function () {
- return App.supports.reassignMaster && App.get('components.reassignable').contains(this.get('content.componentName')) && App.Host.find().content.length > 1;
- }.property('content.componentName'),
- /**
- * Check if component is restartable
- * @type {bool}
- */
- isRestartableComponent: function() {
- return App.get('components.restartable').contains(this.get('content.componentName'));
- }.property('content'),
- /**
- * Host component with some <code>workStatus</code> can't be restarted (so, disable such action in the dropdown list)
- * @type {bool}
- */
- isRestartComponentDisabled: function() {
- return ![App.HostComponentStatus.started].contains(this.get('workStatus'));
- }.property('workStatus'),
- /**
- * Check if component configs can be refreshed
- * @type {bool}
- */
- isRefreshConfigsAllowed: function() {
- return App.get('components.refreshConfigsAllowed').contains(this.get('content.componentName'));
- }.property('content'),
- didInsertElement: function () {
- App.tooltip($('[rel=componentHealthTooltip]'));
- App.tooltip($('[rel=passiveTooltip]'));
- if (this.get('isInProgress')) {
- this.doBlinking();
- }
- },
- /**
- * Do blinking for 1 minute
- */
- doBlinking: function () {
- var workStatus = this.get('workStatus');
- var self = this;
- var pulsate = [ App.HostComponentStatus.starting, App.HostComponentStatus.stopping, App.HostComponentStatus.installing].contains(workStatus);
- if (pulsate && !self.get('isBlinking')) {
- self.set('isBlinking', true);
- uiEffects.pulsate(self.$('.components-health'), 1000, function () {
- self.set('isBlinking', false);
- self.doBlinking();
- });
- }
- },
- /**
- * Start blinking when host component is starting/stopping
- */
- startBlinking: function () {
- this.$('.components-health').stop(true, true);
- this.$('.components-health').css({opacity: 1.0});
- this.doBlinking();
- }.observes('workStatus')
- });
|