Permalink
Browse files

allow widgets with html embedded

  • Loading branch information...
1 parent 23970a7 commit bf4edff36ba4820a6887bd031d2f7436ba125ac7 @kunalmodi committed Apr 8, 2012
Showing with 55 additions and 1 deletion.
  1. +1 −0 lib/fnordmetric.rb
  2. +28 −0 lib/fnordmetric/html_widget.rb
  3. +26 −1 pub/fnordmetric.js
View
@@ -157,6 +157,7 @@ def self.embedded(opts={})
require "fnordmetric/bars_widget"
require "fnordmetric/toplist_widget"
require "fnordmetric/pie_widget"
+require "fnordmetric/html_widget"
require "fnordmetric/namespace"
require "fnordmetric/gauge_modifiers"
require "fnordmetric/gauge_calculations"
@@ -0,0 +1,28 @@
+class FnordMetric::HtmlWidget < FnordMetric::Widget
+ def data
+ super.merge(
+ :html => @opts[:html]
+ )
+ end
+
+ def add_gauges(gauges)
+ @gauges = []
+ @tick = 0
+
+ if !gauges.blank?
+ error! "initializing a html widget with gauges is void"
+ end
+ end
+
+ def data_gauges
+ {}
+ end
+
+ def default_range(now=Time.now)
+ 0..0
+ end
+
+ def has_tick?
+ false
+ end
+end
View
@@ -178,6 +178,31 @@ var FnordMetric = (function(){
};
+ var htmlWidget = function(){
+ function render(opts){
+
+ opts.elem.append(
+ $('<div class="headbar small"></div>').html(opts.title)
+ ).css({
+ 'marginBottom': 20,
+ 'overflow': 'hidden'
+ });
+
+ var container = $('<div></div>')
+ .addClass('html_container')
+ .html(opts.html);
+
+ opts.elem.append(container);
+ }
+
+ function updateValues(opts){}
+ function updatedisplay(opts, diff_factor){}
+
+ return {
+ render: render
+ };
+ }
+
var numbersWidget = function(){
@@ -604,7 +629,6 @@ var FnordMetric = (function(){
};
-
var pieWidget = function(){
function render(opts){
@@ -1078,6 +1102,7 @@ var FnordMetric = (function(){
if(widget.klass=='NumbersWidget'){ numbersWidget().render(widget); }
if(widget.klass=='ToplistWidget'){ toplistWidget().render(widget); }
if(widget.klass=='PieWidget'){ pieWidget().render(widget); }
+ if(widget.klass=="HtmlWidget") { htmlWidget().render(widget); }
};
function resizeWidget(wkey){

1 comment on commit bf4edff

rossta commented on bf4edff Apr 18, 2012

+1

Please sign in to comment.