1
0
Fork 0
mirror of https://github.com/mperham/sidekiq.git synced 2022-11-09 13:52:34 -05:00

Merge pull request #1728 from mperham/graph-labels-locale

Use locale labels for dashboard graphs
This commit is contained in:
Mike Perham 2014-05-21 16:20:05 -07:00
commit c0d05b3cf1
2 changed files with 15 additions and 8 deletions

View file

@ -22,14 +22,16 @@ var poller;
var realtimeGraph = function(updatePath) {
var timeInterval = parseInt(localStorage.timeInterval || '2000');
var graphElement = document.getElementById("realtime");
var graph = new Rickshaw.Graph( {
element: document.getElementById("realtime"),
element: graphElement,
width: responsiveWidth(),
height: 200,
renderer: 'line',
interpolation: 'linear',
series: new Rickshaw.Series.FixedDuration([{ name: 'Failed', color: '#B1003E' }, { name: 'Processed', color: '#006f68' }], undefined, {
series: new Rickshaw.Series.FixedDuration([{ name: graphElement.dataset.failedLabel, color: '#B1003E' }, { name: graphElement.dataset.processedLabel, color: '#006f68' }], undefined, {
timeInterval: timeInterval,
maxDataPoints: 100,
})
@ -93,7 +95,11 @@ var realtimeGraph = function(updatePath) {
var failed = data.sidekiq.failed - Sidekiq.failed;
}
graph.series.addData({ Failed: failed, Processed: processed });
dataPoint = {};
dataPoint[graphElement.dataset.failedLabel] = failed;
dataPoint[graphElement.dataset.processedLabel] = processed;
graph.series.addData(dataPoint);
graph.render();
Sidekiq.processed = data.sidekiq.processed;
@ -111,8 +117,9 @@ var historyGraph = function() {
processed = createSeries($("#history").data("processed"))
failed = createSeries($("#history").data("failed"))
var graphElement = document.getElementById("history");
var graph = new Rickshaw.Graph( {
element: document.getElementById("history"),
element: graphElement,
width: responsiveWidth(),
height: 200,
renderer: 'line',
@ -121,11 +128,11 @@ var historyGraph = function() {
{
color: "#B1003E",
data: failed,
name: 'Failed'
name: graphElement.dataset.failedLabel
}, {
color: "#006f68",
data: processed,
name: 'Processed'
name: graphElement.dataset.processedLabel
}
]
} );

View file

@ -15,7 +15,7 @@
</div>
</div>
<div id="realtime"></div>
<div id="realtime" data-processed-label="<%= t('Processed') %>" data-failed-label="<%= t('Failed') %>"></div>
<div id="realtime-legend"></div>
<h5>
@ -25,7 +25,7 @@
<a href="<%= root_path %>?days=90" class="history-graph <%= "active" if params[:days] == "90" %>"><%= t('ThreeMonths') %></a>
<a href="<%= root_path %>?days=180" class="history-graph <%= "active" if params[:days] == "180" %>"><%= t('SixMonths') %></a>
</h5>
<div id="history" data-processed="<%= h Sidekiq.dump_json(@processed_history) %>" data-failed="<%= h Sidekiq.dump_json(@failed_history) %>" data-update-url="<%= root_path %>dashboard/stats"></div>
<div id="history" data-processed-label="<%= t('Processed') %>" data-failed-label="<%= t('Failed') %>" data-processed="<%= h Sidekiq.dump_json(@processed_history) %>" data-failed="<%= h Sidekiq.dump_json(@failed_history) %>" data-update-url="<%= root_path %>dashboard/stats"></div>
<div id="history-legend"></div>
<br/>