Add a dashboard

Currently the dashboard allows users to get a quick overview of the
status of jobs they're interested in, but more will be added,
e.g. viewing all your jobsets or all jobs of which you're a
maintainer.
This commit is contained in:
Eelco Dolstra
2013-10-14 20:07:26 +02:00
parent 09b5679ee7
commit 2127d133cd
16 changed files with 382 additions and 11 deletions

View File

@ -60,6 +60,12 @@ sub overview : Chained('job') PathPart('') Args(0) {
$c->stash->{aggregates} = $aggregates;
$c->stash->{constituentJobs} = [sort (keys %constituentJobs)];
$c->stash->{starred} = $c->user->starredjobs(
{ project => $c->stash->{project}->name
, jobset => $c->stash->{jobset}->name
, job => $c->stash->{job}->name
})->count == 1 if $c->user_exists;
}
@ -74,4 +80,22 @@ sub get_builds : Chained('job') PathPart('') CaptureArgs(0) {
}
sub star : Chained('job') PathPart('star') Args(0) {
my ($self, $c) = @_;
requirePost($c);
requireUser($c);
my $args =
{ project => $c->stash->{project}->name
, jobset => $c->stash->{jobset}->name
, job => $c->stash->{job}->name
};
if ($c->request->params->{star} eq "1") {
$c->user->starredjobs->update_or_create($args);
} else {
$c->user->starredjobs->find($args)->delete;
}
$c->stash->{resource}->{success} = 1;
}
1;

View File

@ -269,4 +269,19 @@ sub edit_POST {
}
sub dashboard :Chained('user') :Args(0) {
my ($self, $c) = @_;
$c->stash->{template} = 'dashboard.tt';
# Get the N most recent builds for each starred job.
$c->stash->{starredJobs} = [];
foreach my $j ($c->stash->{user}->starredjobs->search({}, { order_by => ['project', 'jobset', 'job'] })) {
my @builds = $j->job->builds->search(
{ },
{ rows => 20, order_by => "id desc" });
push $c->stash->{starredJobs}, { job => $j->job, builds => [@builds] };
}
}
1;