Commit ac885aa8 authored by Paul Asmuth's avatar Paul Asmuth
Browse files

merged set_title & hide_active_users from mborromeo #23

parents b8dbc218 8298c2b7
Loading
Loading
Loading
Loading
+6 −0
Original line number Diff line number Diff line
@@ -177,6 +177,12 @@ require "fnordmetric"

FnordMetric.namespace :myapp do

  # Set a custom namespace title, if you want one
  # set_title "Emails sent"
  
  # Hide the "Active Users" tab, if you want
  # hide_active_users

  # numeric (delta) gauge, 1-hour tick
  gauge :messages_sent, 
    :tick => 1.hour.to_i, 
+10 −5
Original line number Diff line number Diff line
@@ -2,7 +2,7 @@
%html

  %head
    %title Fnordmetric Dashboard
    %title=current_namespace.title

    %script(type="text/javascript" src="#{path_prefix}/vendor/jquery-1.6.1.min.js")
    %script(type="text/javascript" src="#{path_prefix}/vendor/highcharts.js")
@@ -18,11 +18,12 @@
      %ul
        -namespaces.each do |key,namespace|
          %li{:class => namespace.token == current_namespace.token ? 'active' : nil}
            %a{:href=>"/#{namespace.token}"}=h namespace.token
            %a{:href=>"/#{namespace.token}"}=h namespace.title

    #wrap
      #tabs
        %ul
          - if current_namespace.active_users_available
            %li.active.sessions
              .picto.piechart
              Active Users
@@ -64,6 +65,10 @@
    resizeViewport();
    $(window).resize(resizeViewport);

    if(!#{current_namespace.active_users_available.to_s}) {
      $('#tabs li:first').trigger('click');
    }
    
    if(window.location.hash){
      $('#tabs li.dashboard[rel="'+window.location.hash.slice(1)+'"]').trigger('click');
    }
+21 −3
Original line number Diff line number Diff line
@@ -2,12 +2,14 @@ class FnordMetric::Namespace
  
  attr_reader :handlers, :gauges, :opts, :key, :dashboards

  @@opts = [:event, :gauge, :widget]
  @@opts = [:event, :gauge, :widget, :set_title, :active_users_available]

  def initialize(key, opts)    
    @gauges = Hash.new
    @dashboards = Hash.new
    @handlers = Hash.new
    @title = key
    @active_users_available = true
    @opts = opts
    @key = key      
  end
@@ -64,6 +66,14 @@ class FnordMetric::Namespace
    @key
  end
  
  def title
    @title
  end
  
  def active_users_available
    @active_users_available
  end
  
  def dashboards(name=nil)
    return @dashboards unless name
    dash = FnordMetric::Dashboard.new(:title => name)
@@ -85,6 +95,14 @@ class FnordMetric::Namespace
    send(:"opt_#{m}", *args, &block)
  end

  def hide_active_users
    @active_users_available = false
  end
  
  def set_title(key)
    @title = key
  end
  
  def opt_event(event_type, opts={}, &block)    
    opts.merge!(:redis => @redis, :gauges => @gauges)   
    FnordMetric::Context.new(opts, block).tap do |context|
+1 −1
Original line number Diff line number Diff line
@@ -4,7 +4,7 @@ body{ background:#3b3e45; color:#333; margin:0; padding:0; overflow-y:scroll; fo
.shown{ display: block; }
.hidden{ display: none; }

.topbar{ height:38px; background:#24272c; position:fixed; top:0px; width:100%; z-index: 1}
.topbar{ height:38px; background:#24272c; position:fixed; top:0px; width:100%; z-index: 1000;}
.topbar ul { list-style-type:none; margin:0; }
.topbar ul li { padding: 5px 10px 5px 10px; background-color:#3b3e45; display:inline; height:38px; line-height:38px; border-radius:3px; margin-right:5px;}
.topbar ul li a { color:#ccc; font-size:13px; text-decoration:none; }