Skip to content

Commit

Permalink
Merge branch 'feature/elapsed_time_graph'
Browse files Browse the repository at this point in the history
  • Loading branch information
moznion committed Apr 15, 2014
2 parents f51074e + 776ae99 commit 5e83645
Show file tree
Hide file tree
Showing 9 changed files with 228 additions and 43 deletions.
1 change: 1 addition & 0 deletions share/static/css/jquery.powertip-light.min.css

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

46 changes: 46 additions & 0 deletions share/static/js/Chart.min.js

Large diffs are not rendered by default.

44 changes: 44 additions & 0 deletions share/static/js/elapsed-time-chart.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
function drawElapsedTimeGraph($drawArea, elapsedTimes, spot) {
var gap = elapsedTimes.length - spot.length;
for (var i = 0; i < gap; i++) {
spot.unshift(undefined);
}

var excludeHyphenValue = function (arr) {
return $.grep(arr, function (n, i) {
return n !== '-';
});
};
elapsedTimes = excludeHyphenValue(elapsedTimes);
spot = excludeHyphenValue(spot);

spot.splice(0, spot.length - elapsedTimes.length);

var data = {
labels: $.map(elapsedTimes, function () {
return "";
}),
datasets: [
{
fillColor: "rgba(151,187,205,0.5)",
strokeColor: "rgba(151,187,205,1)",
pointColor: "rgba(151,187,205,1)",
pointStrokeColor: "#fff",
data: elapsedTimes
},
{
pointColor: "rgba(220,122,109,1)",
pointStrokeColor: "#fff",
data: spot
}
]
};

var ctx = $drawArea.get(0).getContext("2d");
var myNewChart = new Chart(ctx).Line(data, {
pointDotRadius: 2.5,
pointDotStrokeWidth: 0.5,
animation: false
});
}

4 changes: 4 additions & 0 deletions share/static/js/jquery-1.11.0.min.js

Large diffs are not rendered by default.

4 changes: 0 additions & 4 deletions share/static/js/jquery-1.6.3.min.js

This file was deleted.

8 changes: 8 additions & 0 deletions share/static/js/jquery.powertip.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion share/tmpl/include/layout.tx
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
<link rel="alternate" type="application/rss+xml" title="RSS" href="<: uri_for('/rss.xml') :>" />
<link rel="shortcut icon" type="image/vnd.microsoft.icon" href="<: uri_for('/static/img/favicon.ico') :>" />
<link href="<: uri_for('/static/less/bootstrap/bootstrap.less') :>" rel="stylesheet/less" media="screen" />
<script src="<: uri_for('/static/js/jquery-1.6.3.min.js') :>"></script>
<script src="<: uri_for('/static/js/jquery-1.11.0.min.js') :>"></script>
<link href="<: uri_for('/static/css/main.less') :>" rel="stylesheet/less" media="screen" />
<script src="<: uri_for('/static/js/less-1.1.3.min.js') :>"></script>
<!--[if lt IE 9]>
Expand Down
104 changes: 66 additions & 38 deletions share/tmpl/report_list.tx
Original file line number Diff line number Diff line change
@@ -1,49 +1,77 @@
: cascade include::layout
: override content -> {

<link rel="stylesheet" href="<: uri_for('/static/css/jquery.powertip-light.min.css') :>" type="text/css">
<script src="<: uri_for('/static/js/jquery.powertip.min.js') :>"></script>
<script src="<: uri_for('/static/js/Chart.min.js') :>"></script>
<script src="<: uri_for('/static/js/elapsed-time-chart.js') :>"></script>

<script>
var elapsedTimes = [];
</script>

<hr class="space">

<section>
<div class="row">
<div class="span16">
<h1><: l('Reports for') :> <a href="<: uri_for('/', {project => $project}) :>"><: $project :></a> [<: $branch :>]</h1>

<table>
<tr>
<th>ID</th>
<th><: l('Revision') :></th>
<th><: l('Status') :></th>
<th><: l('Date') :></th>
<th><: l('Elapsed Time') :></th>
</tr>
: for $reports -> $v {
<tr>
<td><a href="<: uri_for('/report/' ~ $v.report_id) :>"><: $v.report_id :></a></td>
<td><: $v.revision || '-' :></td>
<td style="color: <: $v.status | status_color :>"><: $v.status | status_str :> </td>
<td><: ago($now-$v.ctime, 1) :></td>
<td><: duration($v.elapsed_time_sec) :></td>
</tr>
: }
</table>

<div class="pager">
: if $pager.prev_page {
<a href="<: uri_with({page => $pager.prev_page}) :>">←</a>
: } else {
: }
|<: $pager.current_page :>|
: if $pager.next_page {
<a href="<: uri_with({page => $pager.next_page}) :>">→</a>
: } else {
: }
</div>

<a href="<: uri_for('/branch/delete', { branch_id => $branch_id }) :>"><: l('Delete test data for this branch') :></a>
<div class="span16">
<h1><: l('Reports for') :> <a href="<: uri_for('/', {project => $project}) :>"><: $project :></a> [<: $branch :>]</h1>

<table>
<tr>
<th>ID</th>
<th><: l('Revision') :></th>
<th><: l('Status') :></th>
<th><: l('Date') :></th>
<th><: l('Elapsed Time') :></th>
</tr>
: for $reports -> $v {
<tr>
<td><a href="<: uri_for('/report/' ~ $v.report_id) :>"><: $v.report_id :></a></td>
<td><: $v.revision || '-' :></td>
<td style="color: <: $v.status | status_color :>"><: $v.status | status_str :> </td>
<td><: ago($now-$v.ctime, 1) :></td>
<td id="elapsed_time_<: $v.report_id :>">
<: duration($v.elapsed_time_sec) :>
<script>
: if defined $v.elapsed_time_sec {
elapsedTimes.unshift(<: $v.elapsed_time_sec :>);
(function () {
var spot = $.map(elapsedTimes, function () {return '-'});
spot[0] = elapsedTimes[0];
$("#elapsed_time_<: $v.report_id :>").powerTip({smartPlacement: true});
$("#elapsed_time_<: $v.report_id :>").data('powertip', function () {
var tooltip = $('<canvas width="300" height="200"></canvas>');
drawElapsedTimeGraph(tooltip, elapsedTimes, spot);
return tooltip;
});
})();
: } else {
elapsedTimes.unshift("-");
: }
</script>
</td>
</tr>
: }
</table>

<div class="pager">
: if $pager.prev_page {
<a href="<: uri_with({page => $pager.prev_page}) :>">←</a>
: } else {
: }
|<: $pager.current_page :>|
: if $pager.next_page {
<a href="<: uri_with({page => $pager.next_page}) :>">→</a>
: } else {
: }
</div>

<a href="<: uri_for('/branch/delete', { branch_id => $branch_id }) :>"><: l('Delete test data for this branch') :></a>
</div>
</div>
</section>

: }

58 changes: 58 additions & 0 deletions t/jshint.t
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
use strict;
use warnings;
use Test::More;
use Test::Requires 'Text::SimpleTable';
use File::Basename;

plan skip_all => 'this test requires "jshint" command'
if system("jshint --version") != 0;

my @files = (<share/static/*/*.js>);

my %WHITE_LIST = map { $_ => 1 } qw(
lang-apollo.js
lang-clj.js
lang-css.js
lang-go.js
lang-hs.js
lang-lisp.js
lang-lua.js
lang-ml.js
lang-n.js
lang-proto.js
lang-scala.js
lang-sql.js
lang-tex.js
lang-vb.js
lang-vhdl.js
lang-wiki.js
lang-xq.js
lang-yaml.js
prettify.js
Chart.min.js
jquery.powertip.min.js
less-1.1.3.min.js
);

my $table = Text::SimpleTable->new( 25, 5 );

for my $file (@files) {
next if $WHITE_LIST{basename($file)};
next if basename($file) =~ /jquery-[0-9.]+.min.js$/;

my $out = `jshint $file`;
my $err = 0;
if ( $out =~ /(\d+) errors?/ ) {
( $err ) = ( $1 );
is($err, 0, $file)
or note $out;
}
else {
ok(1);
}
$table->row( basename($file), $err );
}

note $table->draw;

done_testing;

0 comments on commit 5e83645

Please sign in to comment.