Commit 1e660d8a authored by Leo Iannacone's avatar Leo Iannacone

Merge remote-tracking branch 'github/master' into portable

parents fce74f58 4727c50e
...@@ -37,7 +37,7 @@ function Page_History() { ...@@ -37,7 +37,7 @@ function Page_History() {
var distribution_url = Utils.get_url_to_package({ var distribution_url = Utils.get_url_to_package({
'distribution': p.distribution 'distribution': p.distribution
}); });
var row = '<tr id="' + _get_id(package_status) + '">'; var row = '<tr class="package" id="' + _get_id(package_status) + '">';
var package_url = Utils.get_url_to_package(p); var package_url = Utils.get_url_to_package(p);
row += '<td><a href="' + distribution_url + '">' + p.distribution + '</a></td>'; row += '<td><a href="' + distribution_url + '">' + p.distribution + '</a></td>';
row += '<td><a href="' + package_url + '">' + p.package + '</td>'; row += '<td><a href="' + package_url + '">' + p.package + '</td>';
...@@ -143,6 +143,49 @@ function Page_History() { ...@@ -143,6 +143,49 @@ function Page_History() {
Chartist.Line('#days-chart', days_data); Chartist.Line('#days-chart', days_data);
} }
function _exportTableToCSV($table, filename) {
// code from http://jsfiddle.net/terryyounghk/KPEGU/
var $rows = $table.find('tr.package:visible:has(td)'),
// Temporary delimiter characters unlikely to be typed by keyboard
// This is to avoid accidentally splitting the actual contents
tmpColDelim = String.fromCharCode(11), // vertical tab character
tmpRowDelim = String.fromCharCode(0), // null character
// actual delimiter characters for CSV format
colDelim = '","',
rowDelim = '"\r\n"',
// Grab text from table into CSV formatted string
csv = '"' + $rows.map(function (i, row) {
var $row = $(row),
$cols = $row.find('td');
return $cols.map(function (j, col) {
var $col = $(col),
text = $col.text();
return text.replace('"', '""'); // escape double quotes
}).get().join(tmpColDelim);
}).get().join(tmpRowDelim)
.split(tmpRowDelim).join(rowDelim)
.split(tmpColDelim).join(colDelim) + '"',
// Data URI
csvData = 'data:application/csv;charset=utf-8,' + encodeURIComponent(csv);
$(this)
.attr({
'download': filename,
'href': csvData,
'target': '_blank'
});
}
this.start = function (socket) { this.start = function (socket) {
socket.on(config.events.broadcast.status_update, function (socket_data) { socket.on(config.events.broadcast.status_update, function (socket_data) {
// TODO - implements _update_table // TODO - implements _update_table
...@@ -162,4 +205,8 @@ function Page_History() { ...@@ -162,4 +205,8 @@ function Page_History() {
_sort_table(); _sort_table();
_create_graph_distributions(); _create_graph_distributions();
_create_graph_days(); _create_graph_days();
$('#download').on('click', function () {
_exportTableToCSV.apply(this, [$('#history'), 'history.csv']);
});
} }
...@@ -258,6 +258,8 @@ footer .info { ...@@ -258,6 +258,8 @@ footer .info {
cursor: pointer; cursor: pointer;
} }
/* History page */
.ct-chart { .ct-chart {
height: 180px; height: 180px;
width: 50%; width: 50%;
...@@ -265,11 +267,51 @@ footer .info { ...@@ -265,11 +267,51 @@ footer .info {
margin-bottom: 30px; margin-bottom: 30px;
} }
.ct-chart .ct-label {
font-size: 0.85em;
}
#distributions-chart.ct-chart { #distributions-chart.ct-chart {
height: 200px; height: 200px;
margin-top: -20px; margin-top: -20px;
} }
.ct-chart .ct-label { #history {
font-size: 0.85em; margin-top: 15px;
}
/* add more colors to graphs */
.ct-series-e .ct-bar,
.ct-chart .ct-series.ct-series-e .ct-line,
.ct-chart .ct-series.ct-series-e .ct-point,
.ct-chart .ct-series.ct-series-e .ct-slice.ct-donut {
stroke: #E6E3BB;
}
.ct-chart .ct-series.ct-series-f .ct-bar,
.ct-chart .ct-series.ct-series-f .ct-line,
.ct-chart .ct-series.ct-series-f .ct-point,
.ct-chart .ct-series.ct-series-f .ct-slice.ct-donut {
stroke: #D3741C;
}
.ct-chart .ct-series.ct-series-g .ct-bar,
.ct-chart .ct-series.ct-series-g .ct-line,
.ct-chart .ct-series.ct-series-g .ct-point,
.ct-chart .ct-series.ct-series-g .ct-slice.ct-donut {
stroke: #C6491A;
}
.ct-chart .ct-series.ct-series-h .ct-bar,
.ct-chart .ct-series.ct-series-h .ct-line,
.ct-chart .ct-series.ct-series-h .ct-point,
.ct-chart .ct-series.ct-series-h .ct-slice.ct-donut {
stroke: #8E4423;
}
.ct-chart .ct-series.ct-series-i .ct-bar,
.ct-chart .ct-series.ct-series-i .ct-line,
.ct-chart .ct-series.ct-series-i .ct-point,
.ct-chart .ct-series.ct-series-i .ct-slice.ct-donut {
stroke: #242729;
} }
...@@ -10,6 +10,7 @@ ...@@ -10,6 +10,7 @@
<div id="days-chart" class="ct-chart"></div> <div id="days-chart" class="ct-chart"></div>
<div id="distributions-chart" class="ct-chart"></div> <div id="distributions-chart" class="ct-chart"></div>
</div> </div>
<a id="download" class="btn btn-primary btn-lg">Download current view</a>
<table id="history" class="tablesorter"> <table id="history" class="tablesorter">
<thead> <thead>
<tr> <tr>
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment