node_managers_live.js 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  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.NodeManagersLiveView = App.TextDashboardWidgetView.extend(App.EditableWithLimitWidgetMixin, {
  20. title: Em.I18n.t('dashboard.widgets.NodeManagersLive'),
  21. id: '19',
  22. model_type: 'yarn',
  23. hiddenInfo: function () {
  24. var nmActive = this.get('model.nodeManagersCountActive') == null ? Em.I18n.t('services.service.summary.notAvailable') : this.get('model.nodeManagersCountActive');
  25. var nmLost = this.get('model.nodeManagersCountLost') == null ? Em.I18n.t('services.service.summary.notAvailable') : this.get('model.nodeManagersCountLost');
  26. var nmUnhealthy = this.get('model.nodeManagersCountUnhealthy') == null ? Em.I18n.t('services.service.summary.notAvailable') : this.get('model.nodeManagersCountUnhealthy');
  27. var nmRebooted = this.get('model.nodeManagersCountRebooted') == null ? Em.I18n.t('services.service.summary.notAvailable'): this.get('model.nodeManagersCountRebooted');
  28. var nmDecom = this.get('model.nodeManagersCountDecommissioned') == null ? Em.I18n.t('services.service.summary.notAvailable') : this.get('model.nodeManagersCountDecommissioned');
  29. return [
  30. nmActive + " active",
  31. nmLost + " lost",
  32. nmUnhealthy + " unhealthy",
  33. nmRebooted + " rebooted",
  34. nmDecom + " decommissioned"
  35. ];
  36. }.property('model.nodeManagersCountActive', 'model.nodeManagersCountLost',
  37. 'model.nodeManagersCountUnhealthy', 'model.nodeManagersCountRebooted', 'model.nodeManagersCountDecommissioned'),
  38. hiddenInfoClass: "hidden-info-five-line",
  39. thresh1: 40,
  40. thresh2: 70,
  41. maxValue: 100,
  42. isDataAvailable: Em.computed.and('!model.metricsNotAvailable', 'App.router.clusterController.isComponentsStateLoaded'),
  43. nodeManagersLive: Em.computed.alias('model.nodeManagersCountActive'),
  44. data: function () {
  45. var nodeManagers = this.get('model.nodeManagersTotal');
  46. var nodeManagersLive = this.get('nodeManagersLive');
  47. if (!nodeManagersLive || !nodeManagers) {
  48. return null;
  49. }
  50. return (nodeManagersLive / nodeManagers).toFixed(2) * 100;
  51. }.property('model.nodeManagersTotal', 'nodeManagersLive'),
  52. content: function () {
  53. return !this.get('nodeManagersLive') || !this.get('model.nodeManagersTotal') ? Em.I18n.t('services.service.summary.notAvailable') : this.get('nodeManagersLive') + '/' + this.get('model.nodeManagersTotal');
  54. }.property('model.nodeManagersTotal', 'nodeManagersLive'),
  55. hintInfo: function () {
  56. var maxTmp = parseFloat(this.get('maxValue'));
  57. return Em.I18n.t('dashboard.widgets.hintInfo.hint1').format(maxTmp);
  58. }.property('maxValue')
  59. });