Skip to content

Commit

Permalink
update Gauge control to optionally format metrics using thousands sep…
Browse files Browse the repository at this point in the history
…arators
  • Loading branch information
chillitom committed Aug 19, 2013
1 parent 7ff9183 commit 8e0776b
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions lib/riemann/dash/public/views/gauge.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
view.View.call(this, json);
this.query = json.query;
this.title = json.title;
this.commaSeperateThousands = json.commaSeperateThousands;
this.clickFocusable = true;
this.el.addClass('gauge');
this.el.append(
Expand All @@ -23,7 +24,7 @@
var value = this.el.find('.value');
this.sub = subs.subscribe(this.query, function(e) {
me.box.attr('class', 'box state ' + e.state);
value.text(format.float(e.metric));
value.text(format.float(e.metric, 2, me.commaSeperateThousands));
value.attr('title', e.description);

// The first time, do a full-height reflow.
Expand All @@ -45,15 +46,18 @@
return $.extend(view.View.prototype.json.call(this), {
type: 'Gauge',
title: this.title,
query: this.query
query: this.query,
commaSeperateThousands: this.commaSeperateThousands
});
}

var editTemplate = _.template(
"<label for='title'>Title</label>" +
"<input type='text' name='title' value='{{title}}' /><br />" +
"<label for='query'>Query</label>" +
'<textarea type="text" name="query" class="query">{{query}}</textarea>' );
'<textarea type="text" name="query" class="query">{{query}}</textarea>' +
"<label for='commaSeperateThousands'>Comma Seperate Thousands</label>" +
"<input type='checkbox' name='commaSeperateThousands' {% if(commaSeperateThousands) { %} checked='checked' {% } %} />" );

Gauge.prototype.editForm = function() {
return editTemplate(this);
Expand Down

0 comments on commit 8e0776b

Please sign in to comment.