heatmap_host.js 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  1. /**
  2. * Licensed to the Apache Software Foundation (ASF) under one or more
  3. * contributor license agreements. See the NOTICE file distributed with this
  4. * work for additional information regarding copyright ownership. The ASF
  5. * licenses this file to you under the Apache License, Version 2.0 (the
  6. * "License"); you may not use this file except in compliance with the License.
  7. * You may obtain a copy of the License at
  8. *
  9. * http://www.apache.org/licenses/LICENSE-2.0
  10. *
  11. * Unless required by applicable law or agreed to in writing, software
  12. * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
  13. * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
  14. * License for the specific language governing permissions and limitations under
  15. * the License.
  16. */
  17. var App = require('app');
  18. App.MainChartsHeatmapHostView = Em.View.extend({
  19. templateName: require('templates/main/charts/heatmap/heatmap_host'),
  20. /** @private */
  21. hostClass: 'hostBlock',
  22. /**
  23. * show Host details block and move it near the cursor
  24. *
  25. * @param {Object}
  26. * e
  27. * @this App.MainChartsHeatmapHostView
  28. */
  29. mouseEnter: function (e) {
  30. var host = this.get('content');
  31. var view = App.MainChartsHeatmapHostDetailView.create();
  32. $.each(view.get('details'), function (i) {
  33. view.set('details.' + i, host.get(i));
  34. });
  35. var selectedMetric = this.get('controller.selectedMetric');
  36. if (selectedMetric) {
  37. var metricName = selectedMetric.get('name');
  38. var h2vMap = selectedMetric.get('hostToValueMap');
  39. if (h2vMap && metricName) {
  40. var value = h2vMap[host.get('hostName')];
  41. if (value == undefined || value == null) {
  42. value = this.t('charts.heatmap.unknown');
  43. } else {
  44. value = value + selectedMetric.get('units')
  45. }
  46. view.set('details.metricName', metricName);
  47. view.set('details.metricValue', value);
  48. }
  49. }
  50. var detailsBlock = $("#heatmapDetailsBlock");
  51. detailsBlock.css('top', e.pageY + 10);
  52. detailsBlock.css('left', e.pageX + 10);
  53. detailsBlock.show();
  54. },
  55. /**
  56. * hide Host details block
  57. *
  58. * @param {Object}
  59. * e
  60. * @this App.MainChartsHeatmapHostView
  61. */
  62. mouseLeave: function (e) {
  63. $("#heatmapDetailsBlock").hide();
  64. },
  65. hostTemperatureStyle: function () {
  66. var controller = this.get('controller');
  67. var h2sMap = controller.get('hostToSlotMap');
  68. if (h2sMap) {
  69. var hostname = this.get('content.hostName');
  70. if (hostname) {
  71. var slot = h2sMap[hostname];
  72. if (slot > -1) {
  73. var slotDefs = controller.get('selectedMetric.slotDefinitions');
  74. if (slotDefs && slotDefs.length > slot) {
  75. return slotDefs[slot].get('cssStyle');
  76. }
  77. }
  78. }
  79. }
  80. return '';
  81. }.property('controller.hostToSlotMap')
  82. });