Sha256: 9361698d071de28ad10a862b316fdc64c8437742bec1984852af698760a22588

Contents?: true

Size: 1.67 KB

Versions: 6

Compression:

Stored size: 1.67 KB

Contents

// Pane at the bottom of the dashboard for displaying events in context.

var eventPane = (function() {
  var el = $('#event-pane');
  var fixedFields = ['host', 'service', 'time', 'state', 'metric', 'ttl', 'description', 'tags'];
  var fixedTemplate =
    _.template(
      '<div class="host">{{-host}}</div>' +
      '<div class="service">{{-service}}</div>' +
      '<div class="state {{-state}}">{{-state}}</div>' +
      '<div class="metric">{{-metric}}</div>' +
      '<time class="absolute">{{-time}}</time>' +
      '<div class="ttl">{{-ttl}}</div>' +
      '<div class="tags">{{-tags}}</div>' +
      '<div class="description">{{-description}}</description>');

  var rowTemplate =
        _.template("<tr><td>{{-field}}</td><td>{{-value}}</td></tr>");

  // Hide the pane
  var hide = function() {
    if (el.hasClass("active")) {
      el.empty();
      el.removeClass("active");
    }
  };

  // Show an event in the pane
  var show = function(event) {
    hide();

    if (! el.hasClass("active")) {
      el.addClass("active");
    }

    el.append(
        fixedTemplate(
          _.defaults(
            util.merge(event, {time: new Date(event.time)}),
            {host: "nil",
             service: "nil",
             state: "nil",
             metric: "nil",
             ttl: "nil",
            tags: "nil",
            description: "nil"})));

    var table = el.append('<table></table>');

    // Remaining fields
    _.each(event, function(value, field) {
      if (! _.contains(fixedFields, field)) {
        table.append(rowTemplate({field: field, value: value}));
      }
    });
  };

  // Hide on escape.
  keys.bind(27, hide);

  return {show: show,
          hide: hide};
})();

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
riemann-dash-0.2.14 lib/riemann/dash/public/eventPane.js
riemann-dash-0.2.13 lib/riemann/dash/public/eventPane.js
riemann-dash-0.2.12 lib/riemann/dash/public/eventPane.js
riemann-dash-0.2.11 lib/riemann/dash/public/eventPane.js
riemann-dash-0.2.10 lib/riemann/dash/public/eventPane.js
riemann-dash-0.2.9 lib/riemann/dash/public/eventPane.js