Commit 4a27a543 authored by Marco Borromeo's avatar Marco Borromeo
Browse files

Let the user customize a namespace Title. It will appear as HTML title tag, and as topbar link text

parent 12dac710
Loading
Loading
Loading
Loading
+2 −2
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,7 +18,7 @@
      %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
+12 −3
Original line number Diff line number Diff line
@@ -2,12 +2,13 @@ class FnordMetric::Namespace
  
  attr_reader :handlers, :gauges, :opts, :key, :dashboards

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

  def initialize(key, opts)    
    @gauges = Hash.new
    @dashboards = Hash.new
    @handlers = Hash.new
    @title = key
    @opts = opts
    @key = key      
  end
@@ -64,6 +65,10 @@ class FnordMetric::Namespace
    @key
  end
  
  def title
    @title
  end
  
  def dashboards(name=nil)
    return @dashboards unless name
    dash = FnordMetric::Dashboard.new(:title => name)
@@ -84,6 +89,10 @@ class FnordMetric::Namespace
    send(:"opt_#{m}", *args, &block)
  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|