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

@ -459,4 +459,9 @@ BLOCK menuItem %]
</li>
[% END;
BLOCK makeStar %]
<span class="star" data-post="[% starUri %]">[% IF starred; "★"; ELSE; "☆"; END %]</span>
[% END;
%]

42
src/root/dashboard.tt Normal file
View File

@ -0,0 +1,42 @@
[% WRAPPER layout.tt title="Dashboard" %]
[% PROCESS common.tt %]
<ul class="nav nav-tabs">
<li class="active"><a href="#tabs-starred-jobs" data-toggle="tab">Starred jobs</a></li>
</ul>
<div id="generic-tabs" class="tab-content">
<div id="tabs-starred-jobs" class="tab-pane active">
[% IF starredJobs.size > 0 %]
<p>Below are the 20 most recent builds of your starred jobs.</p>
<table class="table table-striped table-condensed">
<thead>
<tr><th>Job</th></tr>
</thead>
<tdata>
[% FOREACH j IN starredJobs %]
<tr>
<td>[% INCLUDE renderFullJobName project=j.job.get_column('project') jobset=j.job.get_column('jobset') job=j.job.name %]</td>
[% FOREACH b IN j.builds %]
<td><a href="[% c.uri_for('/build' b.id) %]">[% INCLUDE renderBuildStatusIcon size=16 build=b %]</a></td>
[% END %]
</tr>
[% END %]
</tdata>
</table>
[% ELSE %]
<div class="alert alert-warning">You have no starred jobs. You can add them by visiting a job page and clicking on the ☆ icon.</div>
[% END %]
</div>
</div>
[% END %]

View File

@ -1,4 +1,7 @@
[% WRAPPER layout.tt title="Job $project.name:$jobset.name:$job.name" %]
[% WRAPPER layout.tt
title="Job $project.name:$jobset.name:$job.name"
starUri=c.uri_for(c.controller('Job').action_for('star'), c.req.captures)
%]
[% PROCESS common.tt %]
[% hideProjectName=1 hideJobsetName=1 hideJobName=1 %]

View File

@ -82,7 +82,7 @@
[% IF !hideHeader %]
<div class="page-header">
<h1><small>[% HTML.escape(title) %]</small></h1>
<h1><small>[% IF c.user_exists && starUri; INCLUDE makeStar; " "; END; HTML.escape(title) %]</small></h1>
</div>
[% ELSE %]
<br />

View File

@ -97,5 +97,14 @@ td.nowrap {
}
.actions {
font-weight:bold;
font-weight: bold;
}
.star {
color: black;
font-size: 110%;
}
.star:hover {
cursor: pointer;
}

View File

@ -80,6 +80,23 @@ $(document).ready(function() {
$('div[data-toggle="buttons-radio"] .btn').click(function(){
$('input', $(this).parent()).val($(this).val());
});
$(".star").click(function(event) {
var star = $(this);
var active = star.text() != '★';
requestJSON({
url: star.attr("data-post"),
data: active ? "star=1" : "star=0",
type: 'POST',
success: function(res) {
if (active) {
star.text('★');
} else {
star.text('☆');
}
}
});
});
});
var tabsLoaded = {};

View File

@ -9,6 +9,10 @@
<ul class="nav pull-left">
[% IF c.user_exists %]
[% INCLUDE menuItem uri = c.uri_for(c.controller('User').action_for('dashboard'), [c.user.username]) title = "Dashboard" %]
[% END %]
[% WRAPPER makeSubMenu title="Status" %]
[% INCLUDE menuItem
uri = c.uri_for(c.controller('Root').action_for('queue'))