supervisor_live.js 2.3 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. var App = require('app');
  19. App.SuperVisorUpView = App.TextDashboardWidgetView.extend(App.EditableWithLimitWidgetMixin, {
  20. title: Em.I18n.t('dashboard.widgets.SuperVisorUp'),
  21. id: '21',
  22. model_type: 'storm',
  23. hiddenInfo: function () {
  24. return [
  25. this.get('superVisorsLive') + ' ' + Em.I18n.t('dashboard.services.hdfs.nodes.live'),
  26. this.get('superVisorsDead') + ' ' + Em.I18n.t('dashboard.services.hdfs.nodes.dead')
  27. ];
  28. }.property('superVisorsLive', 'superVisorsDead'),
  29. hiddenInfoClass: "hidden-info-two-line",
  30. thresh1: 40,
  31. thresh2: 70,
  32. maxValue: 100,
  33. superVisorsLive: Em.computed.alias('model.superVisorsStarted'),
  34. superVisorsDead: Em.computed.alias('model.superVisorsInstalled'),
  35. superVisorsTotal: Em.computed.alias('model.superVisorsTotal'),
  36. data: function () {
  37. if ( !this.get('superVisorsTotal') || Em.isNone(this.get('superVisorsLive'))) {
  38. return -1;
  39. }
  40. return (this.get('superVisorsLive') / this.get('superVisorsTotal')).toFixed(2) * 100;
  41. }.property('superVisorsTotal', 'superVisorsLive'),
  42. content: function () {
  43. if (!Em.isNone(this.get('superVisorsTotal')) && !Em.isNone(this.get('superVisorsLive'))) {
  44. return this.get('superVisorsLive') + "/" + this.get('superVisorsTotal');
  45. }
  46. return Em.I18n.t('services.service.summary.notAvailable');
  47. }.property('superVisorsLive', 'superVisorsTotal'),
  48. hintInfo: function () {
  49. var maxTmp = parseFloat(parent.get('maxValue'));
  50. return Em.I18n.t('dashboard.widgets.hintInfo.hint1').format(maxTmp);
  51. }.property('maxValue')
  52. });