jobset: Add a new "channels" tab.

It's very similar to "jobs" and the code is pretty much the same, except
that we don't do filtering on it. At least it doesn't waste space for a
filter option when there are usually WAY less channel jobs than ordinary
jobs.

Signed-off-by: aszlig <aszlig@redmoonstudios.org>
This commit is contained in:
aszlig 2015-04-14 08:58:55 +02:00
parent 19e7114f0e
commit 7b60aed5ed
No known key found for this signature in database
GPG key ID: D0EBD0EC8C2DC961
3 changed files with 77 additions and 0 deletions

View file

@ -145,6 +145,46 @@ sub jobs_tab : Chained('jobsetChain') PathPart('jobs-tab') Args(0) {
}
# XXX: Pretty much a rip-off of jobs-tab, make it DRY!
sub channels_tab : Chained('jobsetChain') PathPart('channels-tab') Args(0) {
my ($self, $c) = @_;
$c->stash->{template} = 'jobset-channels-tab.tt';
my @evals = $c->stash->{jobset}->jobsetevals->search(
{ hasnewbuilds => 1},
{ order_by => "id desc", rows => 20 }
);
my $evals = {};
my %channels;
foreach my $eval (@evals) {
my @builds = $eval->builds->search(
{ 'buildproducts.type' => 'file'
, 'buildproducts.subtype' => 'channel' },
{ join => ["buildproducts"]
, columns => ['id', 'job', 'finished', 'buildstatus'] }
);
foreach my $b (@builds) {
my $jobName = $b->get_column('job');
$evals->{$eval->id}->{timestamp} = $eval->timestamp;
$evals->{$eval->id}->{channels}->{$jobName} = {
id => $b->id,
finished => $b->finished,
buildstatus => $b->buildstatus
};
$channels{$jobName} = 1;
}
}
$c->stash->{evals} = $evals;
my @channels = sort (keys %channels);
$c->stash->{channels} = [@channels];
}
# Hydra::Base::Controller::ListBuilds needs this.
sub get_builds : Chained('jobsetChain') PathPart('') CaptureArgs(0) {
my ($self, $c) = @_;

View file

@ -0,0 +1,34 @@
[% PROCESS common.tt %]
[% IF channels.size == 0 %]
<div class="alert">There are no channels available.</div>
[% ELSE %]
[% evalIds = evals.keys.nsort.reverse %]
<table class="table table-striped table-condensed table-header-rotated">
<thead>
<tr>
<th style="width: 1em;">Channel</th>
[% FOREACH eval IN evalIds %]
<th class="rotate-45">
<div><span>
<a href="[% c.uri_for('/eval' eval) %]">[% INCLUDE renderRelativeDate timestamp=evals.$eval.timestamp %]</a>
</span></div></th>
[% END %]
</tr>
</thead>
<tbody>
[% FOREACH chan IN channels-%]
<tr>
<th><span>[% INCLUDE renderJobName project=project.name jobset=jobset.name job=chan %]</span></th>
[% FOREACH eval IN evalIds %]
<td>[% r = evals.$eval.channels.$chan; IF r.id %]<a href="[% c.uri_for('/build' r.id) %]">[% INCLUDE renderBuildStatusIcon size=16 build=r %]</a>[% END %]</td>
[% END %]
</tr>
[% END %]
</tbody>
</table>
[% END %]

View file

@ -64,6 +64,7 @@
<li><a href="#tabs-jobs" data-toggle="tab">Jobs</a></li>
<li><a href="#tabs-configuration" data-toggle="tab">Configuration</a></li>
<li><a href="#tabs-links" data-toggle="tab">Links</a></li>
<li><a href="#tabs-channels" data-toggle="tab">Channels</a></li>
</ul>
<div id="generic-tabs" class="tab-content">
@ -165,6 +166,8 @@
</ul>
</div>
[% INCLUDE makeLazyTab tabName="tabs-channels" uri=c.uri_for('/jobset' project.name jobset.name "channels-tab") %]
</div>
<script>