Add timezones charts to SCM and MLS pages

These new charts show the activity of commits and messages
per timezone. Note that one of the SCM charts was resized to fit
on the new layout.

Change-Id: I4b6896ee4055d7500313906f6333d6f7a0c7957b
This commit is contained in:
Santiago Dueñas 2015-02-16 17:38:40 +01:00
parent c58d58f2b0
commit db4a858de8
7 changed files with 166 additions and 39 deletions

103
browser/lib/timezones.js Normal file
View File

@ -0,0 +1,103 @@
/*
* Copyright (C) 2012-2015 Bitergia
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*
* This file is a part of the VizGrimoireJS-lib package
*
* Authors:
* Alvaro del Castillo San Felix <acs@bitergia.com>
* Luis Cañas-Díaz <lcanas@bitergia.com>
*
*/
var Timezones = {};
(function() {
var data_tz = false;
Timezones.widget = function(){
var divs = $(".TimezonesBlock");
if (divs.length > 0){
$.each(divs, function(id, div) {
ds_name = $(this).data('data-source');
metric_name = $(this).data('metric');
/* this is a typical check, should be moved to a generic funct*/
DS = Report.getDataSourceByName(ds_name);
if (DS === null) return;
if (DS.getData().length === 0) return; /* no data for data source*/
loadTimeZonesData(ds_name,
function(){
displayTimeZones(div, ds_name, metric_name);
});
});
}
};
function loadTimeZonesData (ds_name, cb) {
suffix = ds_name.toLowerCase();
var json_file = "data/json/" + suffix + "-timezone.json";
$.when($.getJSON(json_file)
).done(function(json_data) {
data_tz = json_data;
cb();
}).fail(function() {
console.log("Time zone widget disabled. Missing " + json_file);
});
}
function displayTimeZones (div, ds_name, metric_name) {
var data;
// we get the HTML with bootstrap
var html = HTMLTimezones(ds_name, metric_name);
if (!div.id) div.id = "Parsed" + getRandomId();
$("#"+div.id).append(html);
//we call the Viz method to plot the chart
var mark = "TimeZones";
var divs = $("."+mark);
if (divs.length > 0) {
var unique = 0;
$.each(divs, function(id, div) {
div.id = mark + (unique++);
var ds = $(this).data('data-source');
if (ds === undefined) return;
var metric = $(this).data('metric');
labels = data_tz.tz;
data = data_tz[metric];
Viz.displayTimeZone(div.id, labels, data, metric);
});
}
}
function HTMLTimezones (ds_name, metric_name){
var html = '<div class="row">';
html += '<div class="col-md-12"><div class="well">';
html +='<div class="TimeZones" style="height: 150px"';
html += 'data-metric="'+metric_name+'" data-data-source="'+ds_name+'"></div>';
html += '</div></div></div>';
return html;
}
function getRandomId() {
return Math.floor(Math.random()*1000+1);
}
})();
Loader.data_ready(function() {
Timezones.widget();
});

File diff suppressed because one or more lines are too long

View File

@ -60,6 +60,11 @@
</div>
<!-- end senders -->
<!-- timezones -->
<div class="TimezonesBlock" data-data-source="mls"
data-metric="messages"></div>
<!-- end timezones -->
</div>
<!-- end left column -->
@ -140,11 +145,12 @@
<script src="./lib/bootstrap-3.1.1.min.js"></script>
<script src="./lib/jasny-bootstrap-3.1.3.min.js"></script>
<script src="./lib/vizgrimoire.min.js"></script>
<script src="./lib/timezones.js"></script>
<!-- Piwik code will be included here-->
<!-- Piwik -->
<!-- End Piwik Code -->
<!-- End of Piwik code -->
</body>
</html>

View File

@ -62,6 +62,11 @@
</div>
<!-- end authors -->
<!-- timezones -->
<div class="TimezonesBlock" data-data-source="scm"
data-metric="commits"></div>
<!-- end timezones -->
<!-- files -->
<div class="row">
<div class="col-md-12">
@ -74,6 +79,19 @@
</div>
<!-- end files -->
<!-- files, lines -->
<div class="row">
<div class="col-md-12">
<div class="well">
<div class="MetricsEvol" data-data-source="scm"
data-metrics="scm_added_lines,scm_removed_lines" data-min="true"
data-legend="true" style="height: 120px;"></div>
<div class="MicrodashText" data-metric="scm_added_lines" data-name="true"></div>
<div class="MicrodashText" data-metric="scm_removed_lines" data-name="true"></div>
</div>
</div>
</div>
<!-- end files, lines -->
</div>
<!-- end left column -->
@ -133,16 +151,6 @@
</div>
<!-- end commits, authors, stats, top authors -->
<div class="col-md-12">
<div class="well">
<div class="MetricsEvol" data-data-source="scm"
data-metrics="scm_added_lines,scm_removed_lines" data-min="true"
data-legend="true" style="height: 120px;"></div>
<div class="MicrodashText" data-metric="scm_added_lines" data-name="true"></div>
<div class="MicrodashText" data-metric="scm_removed_lines" data-name="true"></div>
</div>
</div>
<!-- end files, lines -->
</div>
<!-- END SECTION HTML-->
@ -159,11 +167,12 @@
<script src="./lib/bootstrap-3.1.1.min.js"></script>
<script src="./lib/jasny-bootstrap-3.1.3.min.js"></script>
<script src="./lib/vizgrimoire.min.js"></script>
<script src="./lib/timezones.js"></script>
<!-- Piwik code will be included here-->
<!-- Piwik -->
<!-- End Piwik Code -->
<!-- End of Piwik code -->
</body>
</html>

View File

@ -44,6 +44,7 @@
<script src="./lib/bootstrap-3.1.1.min.js"></script>
<script src="./lib/jasny-bootstrap-3.1.3.min.js"></script>
<script src="./lib/vizgrimoire.min.js"></script>
<script src="./lib/timezones.js"></script>
<!-- Piwik code will be included here-->
REPLACE_WEBSTATS
<!-- End of Piwik code -->

View File

@ -29,6 +29,11 @@
</div>
<!-- end senders -->
<!-- timezones -->
<div class="TimezonesBlock" data-data-source="mls"
data-metric="messages"></div>
<!-- end timezones -->
</div>
<!-- end left column -->

View File

@ -31,6 +31,11 @@
</div>
<!-- end authors -->
<!-- timezones -->
<div class="TimezonesBlock" data-data-source="scm"
data-metric="commits"></div>
<!-- end timezones -->
<!-- files -->
<div class="row">
<div class="col-md-12">
@ -43,6 +48,19 @@
</div>
<!-- end files -->
<!-- files, lines -->
<div class="row">
<div class="col-md-12">
<div class="well">
<div class="MetricsEvol" data-data-source="scm"
data-metrics="scm_added_lines,scm_removed_lines" data-min="true"
data-legend="true" style="height: 120px;"></div>
<div class="MicrodashText" data-metric="scm_added_lines" data-name="true"></div>
<div class="MicrodashText" data-metric="scm_removed_lines" data-name="true"></div>
</div>
</div>
</div>
<!-- end files, lines -->
</div>
<!-- end left column -->
@ -102,14 +120,4 @@
</div>
<!-- end commits, authors, stats, top authors -->
<div class="col-md-12">
<div class="well">
<div class="MetricsEvol" data-data-source="scm"
data-metrics="scm_added_lines,scm_removed_lines" data-min="true"
data-legend="true" style="height: 120px;"></div>
<div class="MicrodashText" data-metric="scm_added_lines" data-name="true"></div>
<div class="MicrodashText" data-metric="scm_removed_lines" data-name="true"></div>
</div>
</div>
<!-- end files, lines -->
</div>