<commit_before>
namespace "Bixby.view.monitoring", (exports, top) ->

  class exports.Layout extends Stark.View
    el: "#content"
    template: "monitoring/layout"


  class exports.ResourceList extends Stark.View
    el: "div.monitoring_content"
    template: "monitoring/resource_list"
    events: {
      "click .add_resource_link": (e) ->
        @transition "mon_hosts_resources_new", { host: @host }
    }

    render: ->
      super()

      # display graphs
      @resources.each (res) ->
        metrics = res.get("metrics");
        _.each metrics, (metric, key) ->
          s = ".resource[resource_id=" + res.id + "] .metric[metric='" + key + "']"
          el = $(s + " .graph")[0]

          vals = _.map metric.vals, (v) ->
            [ new Date(v.x * 1000), v.y ]

          opts = {
            labels: [ "Date/Time", "v" ]
            strokeWidth: 2
          }

          if metric.unit == "%"
            # set range if known
            opts.valueRange = [ 0, 100 ]

          # draw
          g = new Dygraph(el, vals, opts)

          unit = ""
          if metric.unit?
            if metric.unit != "%"
              unit = " " + metric.unit
            else
              unit = "%"

          $(s + " .footer").text(sprintf("Last Value: %0.2f%s", metric.vals[metric.vals.length-1].y, unit))

    render_with_rickshaw: ->
      render()

      # display graphs
      @resources.each (res) ->
        metrics = res.get("metrics");
        _.each metrics, (val, key) -><commit_msg>move hightlight detail into footer<commit_after>
namespace "Bixby.view.monitoring", (exports, top) ->

  class exports.Layout extends Stark.View
    el: "#content"
    template: "monitoring/layout"


  class exports.ResourceList extends Stark.View
    el: "div.monitoring_content"
    template: "monitoring/resource_list"
    events: {
      "click .add_resource_link": (e) ->
        @transition "mon_hosts_resources_new", { host: @host }
    }

    render: ->
      super()

      # display graphs
      @resources.each (res) ->
        metrics = res.get("metrics");

        _.each metrics, (metric, key) ->
          s = ".resource[resource_id=" + res.id + "] .metric[metric='" + key + "']"
          el = $(s + " .graph")[0]

          # draw footer
          footer = $(s + " .footer")
          unit = ""
          if metric.unit?
            if metric.unit != "%"
              unit = " " + metric.unit
            else
              unit = "%"
          footer_text = sprintf("Last Value: %0.2f%s", metric.vals[metric.vals.length-1].y, unit)
          footer.text(footer_text)

          vals = _.map metric.vals, (v) ->
            [ new Date(v.x * 1000), v.y ]

          opts = {
            labels: [ "Date/Time", "v" ]
            strokeWidth: 2
            showLabelsOnHighlight: false
            legend: "never"
          }

          if metric.unit == "%"
            # set range if known
            opts.valueRange = [ 0, 100 ]

          # draw
          g = new Dygraph(el, vals, opts)

          # set callbacks
          xOptView = g.optionsViewForAxis_('x');
          xvf = xOptView('valueFormatter');
          opts = {
            highlightCallback: (e, x, pts, row) ->
              date = xvf(x, xOptView, "", g) + ", " + sprintf("val = %0.2f%s", pts[0].yval, unit)
              footer.text(date)

            unhighlightCallback: (e) ->
              footer.text(footer_text)
          }
          g.updateOptions(opts);

    render_with_rickshaw: ->
      render()

      # display graphs
      @resources.each (res) ->
        metrics = res.get("metrics");
        _.each metrics, (val, key) ->
{'fraction_non_alphanumeric': 0.1466299862448418, 'fraction_numerical': 0.00797799174690509, 'mean_word_length': 1.6578947368421053, 'pattern_counts': {'":': 2, '<': 3, '<?xml version=': 0, '>': 23, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2561902', 'n_tokens_mistral': 1157, 'n_tokens_neox': 1094, 'n_words': 249}