Commit 939809d9 authored by Paul Asmuth's avatar Paul Asmuth
Browse files

sidebar integration

parent 719ceb15
Loading
Loading
Loading
Loading
+8 −8
Original line number Diff line number Diff line
@@ -11,14 +11,6 @@ FnordMetric.namespace :ulm do
  gauge :messages_read, :tick => 1.day.to_i, :title => "Messages (read)"
  gauge :winks_sent, :tick => 1.day.to_i, :title => "Winks sent"

  widget 'Overview', {
    :title => "User-Activity",
    :type => :timeline,
    :width => 67,
    :autoupdate => 30,
    :gauges => [:skip_votes, :yes_votes, :maybe_votes]
  }

  widget 'Overview', {
    :title => "Yes/No/Skip-Votes",
    :type => :timeline,
@@ -44,6 +36,14 @@ FnordMetric.namespace :ulm do
    :gauges => [:messages_sent, :messages_read, :winks_sent]
  }
  
  widget 'Overview', {
    :title => "User-Activity",
    :type => :timeline,
    :width => 67,
    :autoupdate => 30,
    :gauges => [:skip_votes, :yes_votes, :maybe_votes]
  }

end

FnordMetric.options = {
+2 −1
Original line number Diff line number Diff line
@@ -114,7 +114,8 @@ class FnordMetric::Namespace

  def opt_gauge(gauge_key, opts={})
    opts.merge!(:key => gauge_key, :key_prefix => key_prefix)
    @gauges[gauge_key] ||= FnordMetric::Gauge.new(opts)  
    klass = "FnordMetric::#{(opts[:type] || "").camelize}Gauge".constantize
    @gauges[gauge_key] ||= klass.new(opts)
  end

  def opt_multigauge(gauge_type, gauge_key, opts={})
+21 −4
Original line number Diff line number Diff line
@@ -4,10 +4,27 @@ class FnordMetric::Reactor
    @namespaces = FnordMetric.namespaces
  end

  def execute(event)
  	return false unless event["type"] == "widget_request"
  	return false unless @namespaces.keys.include?(event["namespace"].to_sym)
  	"FnordMetric::#{event["klass"]}".constantize.execute(@namespaces[event["namespace"].to_sym], event) # FIXPAUL
  def execute(socket, event, messages = [])
    return false unless event["namespace"]
    return false unless ns = @namespaces[event["namespace"].to_sym]
    messages << discover(ns) if event["type"] == "discover_request"
    messages << widget(ns, event) if event["type"] == "widget_request"
    messages.flatten.each{ |m| socket.send(m.to_json) }
  end

private

  def widget(namespace, event)
    "FnordMetric::#{event["klass"]}".constantize.execute(namespace, event) # FIXPAUL
  end

  def discover(namespace)
    [namespace.dashboards.map do |dash_key, gauge|
      { "type" => "discover_response", "gauge_key" => dash_key, "view" => "dashboard" }
    end,
    namespace.gauges.map do |gauge_key, gauge|
      { "type" => "discover_response", "gauge_key" => gauge_key, "view" => "gauge" }
    end]
  end

end
 No newline at end of file
+1 −3
Original line number Diff line number Diff line
@@ -34,9 +34,7 @@ private
          else
            message["_eid"] ||= get_uuid
            message["_sender"] = @uuid
            if msg = @reactor.execute(message) # FIXPAUL
              socket.send(msg.to_json)
            end
            msg = @reactor.execute(socket, message) # FIXPAUL
          end
        end

+1 −1
Original line number Diff line number Diff line
@@ -45,7 +45,7 @@ class FnordMetric::NumbersWidget < FnordMetric::Widget
    super.merge(
      :series => gauges.map(&:name),
      :offsets => (@opts[:offsets] || [0, 1, "s30"]),
      :autoupdate => (@opts[:autoupdate] || 1)
      :autoupdate => (@opts[:autoupdate] || 10)
    )
  end

Loading