templateName: require()

in ambari-web/app/views/main/charts/heatmap/heatmap_host.js [23:93]


  templateName: require('templates/main/charts/heatmap/heatmap_host'),
  /** @private */
  hostClass: 'hostBlock',

  /**
   * show Host details block and move it near the cursor
   * 
   * @param {Object}
   *          e
   * @this App.MainChartsHeatmapHostView
   */
  mouseEnter: function (e) {
    var host = this.get('content');
    var view = App.MainChartsHeatmapHostDetailView.create();
    $.each(view.get('details'), function(i){
      var val = host.get(i);
      if (i == 'diskUsage') {
        if (val == undefined || isNaN(val) || val == Infinity || val == -Infinity) {
          val = null;
        } else {
          val = val.toFixed(1);
        }
      } else if (i == 'cpuUsage') {
        if (val == undefined || isNaN(val)) {
          val = null;
        } else {
          val = val.toFixed(1);
        }
      } else if (i == 'memoryUsage') {
        if (val == undefined || isNaN(val) || val == Infinity || val == -Infinity) {
          val = null;
        } else {
          val = val.toFixed(1);
        }
      } else if (i == 'hostComponents') {
        if (val == undefined) {
          val = null;
        } else {
          val = val.filterProperty('isMaster').concat(val.filterProperty('isSlave')).mapProperty('displayName').join(', ');
        }
      }
      view.set('details.' + i, val);
    });
    var selectedMetric = this.get('controller.selectedMetric');
    if (selectedMetric) {
      var metricName = selectedMetric.get('name');
      var h2vMap = selectedMetric.get('hostToValueMap');
      if (h2vMap && metricName) {
        var value = h2vMap[host.get('hostName')];
        if (value == undefined || value == null) {
          value = this.t('charts.heatmap.unknown');
        } else {
          if (metricName == 'Garbage Collection Time') {
            value = date.timingFormat(parseInt(value));
          } else {
            if (isNaN(value)) {
              value = this.t('charts.heatmap.unknown');
            } else {
              value = value + selectedMetric.get('units');
            }
          }
        }
        view.set('details.metricName', metricName);
        view.set('details.metricValue', value);
      }
    }
    var detailsBlock = $("#heatmapDetailsBlock");
    detailsBlock.css('top', e.pageY + 10);
    detailsBlock.css('left', e.pageX + 10);
    detailsBlock.show();
  },