* Improved the navigation bar: don't include all projects (since that

doesn't scale), and include links for jobset/job specific pages.
  The main page now lists the projects.
* Overview pages for jobsets and jobs.
* Links to the channels.
* Jobsets are now defined and edited in a separate action.
This commit is contained in:
Eelco Dolstra 2009-04-02 16:15:57 +00:00
parent db4ce0df06
commit 753e56b6eb
18 changed files with 762 additions and 470 deletions

View file

@ -17,7 +17,16 @@ sub job : Chained('/') PathPart('job') CaptureArgs(3) {
}
sub index : Chained('job') PathPart('') Args(0) {
sub overview : Chained('job') PathPart('') Args(0) {
my ($self, $c) = @_;
$c->stash->{template} = 'job.tt';
getBuildStats($c, scalar $c->stash->{job}->builds);
}
sub all : Chained('job') PathPart Args(0) {
my ($self, $c) = @_;
$c->go($self->action_for("all"));
}

View file

@ -22,7 +22,13 @@ sub jobset : Chained('/') PathPart('jobset') CaptureArgs(2) {
sub index : Chained('jobset') PathPart('') Args(0) {
my ($self, $c) = @_;
$c->go($self->action_for("all"));
$c->stash->{template} = 'jobset.tt';
getBuildStats($c, scalar $c->stash->{jobset}->builds);
$c->stash->{activeJobs} = [$c->stash->{jobset}->jobs->search({active => 1})];
$c->stash->{inactiveJobs} = [$c->stash->{jobset}->jobs->search({active => 0})];
}
@ -36,4 +42,120 @@ sub get_builds : Chained('jobset') PathPart('') CaptureArgs(0) {
}
sub edit : Chained('jobset') PathPart Args(0) {
my ($self, $c) = @_;
requireProjectOwner($c, $c->stash->{project});
$c->stash->{template} = 'jobset.tt';
$c->stash->{edit} = 1;
}
sub submit : Chained('jobset') PathPart Args(0) {
my ($self, $c) = @_;
requireProjectOwner($c, $c->stash->{project});
requirePost($c);
$c->model('DB')->schema->txn_do(sub {
updateJobset($c, $c->stash->{jobset});
});
$c->res->redirect($c->uri_for($self->action_for("index"),
[$c->stash->{project}->name, $c->stash->{jobset}->name]));
}
sub delete : Chained('jobset') PathPart Args(0) {
my ($self, $c) = @_;
requireProjectOwner($c, $c->stash->{project});
requirePost($c);
$c->model('DB')->schema->txn_do(sub {
$c->stash->{jobset}->delete;
});
$c->res->redirect($c->uri_for($c->controller('Project')->action_for("view"),
[$c->stash->{project}->name]));
}
sub updateJobset {
my ($c, $jobset) = @_;
my $jobsetName = trim $c->request->params->{"name"};
error($c, "Invalid jobset name: $jobsetName") unless $jobsetName =~ /^[[:alpha:]][\w\-]*$/;
# The Nix expression path must be relative and can't contain ".." elements.
my $nixExprPath = trim $c->request->params->{"nixexprpath"};
error($c, "Invalid Nix expression path: $nixExprPath") if $nixExprPath !~ /^$relPathRE$/;
my $nixExprInput = trim $c->request->params->{"nixexprinput"};
error($c, "Invalid Nix expression input name: $nixExprInput") unless $nixExprInput =~ /^\w+$/;
$jobset->update(
{ name => $jobsetName
, description => trim($c->request->params->{"description"})
, nixexprpath => $nixExprPath
, nixexprinput => $nixExprInput
});
my %inputNames;
# Process the inputs of this jobset.
foreach my $param (keys %{$c->request->params}) {
next unless $param =~ /^input-(\w+)-name$/;
my $baseName2 = $1;
next if $baseName2 eq "template";
print STDERR "GOT INPUT: $baseName2\n";
my $inputName = trim $c->request->params->{"input-$baseName2-name"};
error($c, "Invalid input name: $inputName") unless $inputName =~ /^[[:alpha:]]\w*$/;
my $inputType = trim $c->request->params->{"input-$baseName2-type"};
error($c, "Invalid input type: $inputType") unless
$inputType eq "svn" || $inputType eq "cvs" || $inputType eq "tarball" ||
$inputType eq "string" || $inputType eq "path" || $inputType eq "boolean" ||
$inputType eq "build";
$inputNames{$inputName} = 1;
my $input;
if ($baseName2 =~ /^\d+$/) { # numeric base name is auto-generated, i.e. a new entry
$input = $jobset->jobsetinputs->create(
{ name => $inputName
, type => $inputType
});
} else { # it's an existing input
$input = ($jobset->jobsetinputs->search({name => $baseName2}))[0];
die unless defined $input;
$input->update({name => $inputName, type => $inputType});
}
# Update the values for this input. Just delete all the
# current ones, then create the new values.
$input->jobsetinputalts->delete_all;
my $values = $c->request->params->{"input-$baseName2-values"};
$values = [] unless defined $values;
$values = [$values] unless ref($values) eq 'ARRAY';
my $altnr = 0;
foreach my $value (@{$values}) {
print STDERR "VALUE: $value\n";
my $value = trim $value;
error($c, "Invalid Boolean value: $value") if
$inputType eq "boolean" && !($value eq "true" || $value eq "false");
$input->jobsetinputalts->create({altnr => $altnr++, value => $value});
}
}
# Get rid of deleted inputs.
my @inputs = $jobset->jobsetinputs->all;
foreach my $input (@inputs) {
$input->delete unless defined $inputNames{$input->name};
}
}
1;

View file

@ -23,6 +23,8 @@ sub view : Chained('project') PathPart('') Args(0) {
$c->stash->{template} = 'project.tt';
getBuildStats($c, scalar $c->stash->{project}->builds);
$c->stash->{releaseSets} = [$c->stash->{project}->releasesets->all];
}
@ -40,14 +42,13 @@ sub submit : Chained('project') PathPart Args(0) {
my ($self, $c) = @_;
requireProjectOwner($c, $c->stash->{project});
error($c, "Request must be POSTed.") if $c->request->method ne "POST";
requirePost($c);
$c->model('DB')->schema->txn_do(sub {
updateProject($c, $c->stash->{project});
});
$c->res->redirect($c->uri_for($self->action_for("view"), $c->req->captures));
$c->res->redirect($c->uri_for($self->action_for("view"), [$c->stash->{project}->name]));
}
@ -55,8 +56,7 @@ sub delete : Chained('project') PathPart Args(0) {
my ($self, $c) = @_;
requireProjectOwner($c, $c->stash->{project});
error($c, "Request must be POSTed.") if $c->request->method ne "POST";
requirePost($c);
$c->model('DB')->schema->txn_do(sub {
$c->stash->{project}->delete;
@ -109,6 +109,37 @@ sub create_submit : Path('/create-project/submit') {
}
sub create_jobset : Chained('project') PathPart('create-jobset') Args(0) {
my ($self, $c) = @_;
requireProjectOwner($c, $c->stash->{project});
$c->stash->{template} = 'jobset.tt';
$c->stash->{create} = 1;
$c->stash->{edit} = 1;
}
sub create_jobset_submit : Chained('project') PathPart('create-jobset/submit') Args(0) {
my ($self, $c) = @_;
requireProjectOwner($c, $c->stash->{project});
my $jobsetName = trim $c->request->params->{name};
$c->model('DB')->schema->txn_do(sub {
# Note: $jobsetName is validated in updateProject, which will
# abort the transaction if the name isn't valid.
my $jobset = $c->stash->{project}->jobsets->create(
{name => $jobsetName, nixexprinput => "", nixexprpath => ""});
Hydra::Controller::Jobset::updateJobset($c, $jobset);
});
$c->res->redirect($c->uri_for($c->controller('Jobset')->action_for("index"),
[$c->stash->{project}->name, $jobsetName]));
}
sub updateProject {
my ($c, $project) = @_;
my $projectName = trim $c->request->params->{name};
@ -116,120 +147,22 @@ sub updateProject {
my $displayName = trim $c->request->params->{displayname};
error($c, "Invalid display name: $displayName") if $displayName eq "";
$project->name($projectName);
$project->displayname($displayName);
$project->description(trim $c->request->params->{description});
$project->homepage(trim $c->request->params->{homepage});
$project->enabled(trim($c->request->params->{enabled}) eq "1" ? 1 : 0);
my $owner = $project->owner;
if ($c->check_user_roles('admin')) {
my $owner = trim $c->request->params->{owner};
$owner = trim $c->request->params->{owner};
error($c, "Invalid owner: $owner")
unless defined $c->model('DB::Users')->find({username => $owner});
$project->owner($owner);
}
$project->update;
my %jobsetNames;
foreach my $param (keys %{$c->request->params}) {
next unless $param =~ /^jobset-(\w+)-name$/;
my $baseName = $1;
next if $baseName eq "template";
my $jobsetName = trim $c->request->params->{"jobset-$baseName-name"};
error($c, "Invalid jobset name: $jobsetName") unless $jobsetName =~ /^[[:alpha:]][\w\-]*$/;
# The Nix expression path must be relative and can't contain ".." elements.
my $nixExprPath = trim $c->request->params->{"jobset-$baseName-nixexprpath"};
error($c, "Invalid Nix expression path: $nixExprPath") if $nixExprPath !~ /^$relPathRE$/;
my $nixExprInput = trim $c->request->params->{"jobset-$baseName-nixexprinput"};
error($c, "Invalid Nix expression input name: $nixExprInput") unless $nixExprInput =~ /^\w+$/;
$jobsetNames{$jobsetName} = 1;
my $jobset;
my $description = trim $c->request->params->{"jobset-$baseName-description"};
if ($baseName =~ /^\d+$/) { # numeric base name is auto-generated, i.e. a new entry
$jobset = $project->jobsets->create(
{ name => $jobsetName
, description => $description
, nixexprpath => $nixExprPath
, nixexprinput => $nixExprInput
});
} else { # it's an existing jobset
my $oldName = trim $c->request->params->{"jobset-$baseName-oldName"};
$jobset = ($project->jobsets->search({name => $oldName}))[0] or die;
$jobset->update(
{ name => $jobsetName, description => $description
, nixexprpath => $nixExprPath, nixexprinput => $nixExprInput });
}
my %inputNames;
# Process the inputs of this jobset.
foreach my $param (keys %{$c->request->params}) {
next unless $param =~ /^jobset-$baseName-input-(\w+)-name$/;
my $baseName2 = $1;
next if $baseName2 eq "template";
print STDERR "GOT INPUT: $baseName2\n";
my $inputName = trim $c->request->params->{"jobset-$baseName-input-$baseName2-name"};
error($c, "Invalid input name: $inputName") unless $inputName =~ /^[[:alpha:]]\w*$/;
my $inputType = trim $c->request->params->{"jobset-$baseName-input-$baseName2-type"};
error($c, "Invalid input type: $inputType") unless
$inputType eq "svn" || $inputType eq "cvs" || $inputType eq "tarball" ||
$inputType eq "string" || $inputType eq "path" || $inputType eq "boolean" ||
$inputType eq "build";
$inputNames{$inputName} = 1;
my $input;
if ($baseName2 =~ /^\d+$/) { # numeric base name is auto-generated, i.e. a new entry
$input = $jobset->jobsetinputs->create(
{ name => $inputName
, type => $inputType
});
} else { # it's an existing jobset
$input = ($jobset->jobsetinputs->search({name => $baseName2}))[0];
die unless defined $input;
$input->update({name => $inputName, type => $inputType});
}
# Update the values for this input. Just delete all the
# current ones, then create the new values.
$input->jobsetinputalts->delete_all;
my $values = $c->request->params->{"jobset-$baseName-input-$baseName2-values"};
$values = [] unless defined $values;
$values = [$values] unless ref($values) eq 'ARRAY';
my $altnr = 0;
foreach my $value (@{$values}) {
print STDERR "VALUE: $value\n";
my $value = trim $value;
error($c, "Invalid Boolean value: $value") if
$inputType eq "boolean" && !($value eq "true" || $value eq "false");
$input->jobsetinputalts->create({altnr => $altnr++, value => $value});
}
}
# Get rid of deleted inputs.
my @inputs = $jobset->jobsetinputs->all;
foreach my $input (@inputs) {
$input->delete unless defined $inputNames{$input->name};
}
}
# Get rid of deleted jobsets, i.e., ones that are no longer submitted in the parameters.
my @jobsets = $project->jobsets->all;
foreach my $jobset (@jobsets) {
$jobset->delete unless defined $jobsetNames{$jobset->name};
}
$project->update(
{ name => $projectName
, displayname => $displayName
, description => trim($c->request->params->{description})
, homepage => trim($c->request->params->{homepage})
, enabled => trim($c->request->params->{enabled}) eq "1" ? 1 : 0
, owner => $owner
});
}

View file

@ -13,7 +13,6 @@ __PACKAGE__->config->{namespace} = '';
sub begin :Private {
my ($self, $c) = @_;
$c->stash->{projects} = [$c->model('DB::Projects')->search({}, {order_by => 'displayname'})];
$c->stash->{curUri} = $c->request->uri;
$c->stash->{version} = $ENV{"HYDRA_RELEASE"} || "<devel>";
}
@ -21,8 +20,8 @@ sub begin :Private {
sub index :Path :Args(0) {
my ($self, $c) = @_;
$c->stash->{template} = 'index.tt';
$c->stash->{template} = 'overview.tt';
$c->stash->{projects} = [$c->model('DB::Projects')->search({}, {order_by => 'displayname'})];
getBuildStats($c, $c->model('DB::Builds'));
}
@ -63,18 +62,6 @@ sub queue :Local {
}
sub releasesets :Local {
my ($self, $c, $projectName) = @_;
$c->stash->{template} = 'releasesets.tt';
my $project = $c->model('DB::Projects')->find($projectName);
notFound($c, "Project $projectName doesn't exist.") if !defined $project;
$c->stash->{project} = $project;
$c->stash->{releaseSets} = [$project->releasesets->all];
}
sub getReleaseSet {
my ($c, $projectName, $releaseSetName) = @_;

View file

@ -9,7 +9,7 @@ our @ISA = qw(Exporter);
our @EXPORT = qw(
getBuild getBuildStats getLatestBuilds getChannelData
error notFound
requireLogin requireProjectOwner requireAdmin
requireLogin requireProjectOwner requireAdmin requirePost
trim
$pathCompRE $relPathRE
);
@ -126,6 +126,12 @@ sub requireAdmin {
}
sub requirePost {
my ($c) = @_;
error($c, "Request must be POSTed.") if $c->request->method ne "POST";
}
sub trim {
my $s = shift;
$s =~ s/^\s+|\s+$//g;

View file

@ -3,12 +3,12 @@
[% PROCESS "product-list.tt" %]
[% USE HTML %]
[% project = build.get_column('project') %]
[% jobset = build.get_column('jobset') %]
[% job = build.get_column('job') %]
[% project = build.project %]
[% jobset = build.jobset %]
[% job = build.job %]
<h1>
Job <tt>[% project %]:[% jobset %]:[% job %]</tt> build [% id %]
Job <tt>[% project.name %]:[% jobset.name %]:[% job.name %]</tt> build [% id %]
[% IF !build.finished %]
[% IF build.schedulingInfo.busy %]
(currently building)
@ -77,15 +77,15 @@
</tr>
<tr>
<th>Project:</th>
<td>[% INCLUDE renderProjectName %]</td>
<td>[% INCLUDE renderProjectName project=project.name %]</td>
</tr>
<tr>
<th>Jobset:</th>
<td>[% INCLUDE renderJobsetName %]</td>
<td>[% INCLUDE renderJobsetName project=project.name jobset=jobset.name %]</td>
</tr>
<tr>
<th>Job name:</th>
<td>[% INCLUDE renderJobName %]</td>
<td>[% INCLUDE renderJobName project=project.name jobset=jobset.name job=job.name %]</td>
</tr>
<tr>
<th>Nix name:</th>

View file

@ -1,4 +1,5 @@
[% USE date %]
[% USE HTML %]
[% inputTypes =
@ -140,3 +141,30 @@
[% BLOCK renderReleaseJobName -%]
[% IF job.description; HTML.escape(job.description); ELSE %]<tt>[% job.job %]</tt> ([% job.attrs %])[% END -%]
[% END -%]
[% BLOCK maybeLink -%]
[% IF uri %]<a [% HTML.attributes(href => uri) %]>[% content %]</a>[% ELSE; content; END -%]
[% END -%]
[% BLOCK renderSelection %]
[% IF edit %]
<select [% HTML.attributes(id => param, name => param) %]>
[% FOREACH name IN options.keys.sort %]
<option [% HTML.attributes(value => name) %] [% IF name == curValue; "selected='selected'"; END %]>[% options.$name %]</option>
[% END %]
</select>
[% ELSE %]
[% options.$curValue %]
[% END %]
[% END %]
[% BLOCK maybeEditString;
IF edit -%]
<input type="text" class="string [% extraClass %]" [% HTML.attributes(id => param, name => param, value => value) %] />
[% ELSE;
HTML.escape(value);
END -%]
[% END -%]

View file

@ -1,13 +0,0 @@
[% WRAPPER layout.tt title="Overview" %]
[% PROCESS common.tt %]
<h1>Hydra Overview</h1>
<h2>Statistics</h2>
[% INCLUDE showBuildStats %]
[% END %]

31
src/root/job.tt Normal file
View file

@ -0,0 +1,31 @@
[% WRAPPER layout.tt title="Job $project.name:$jobset.name:$job.name" %]
[% PROCESS common.tt %]
<h1>Job <tt>[% project.name %]:[% jobset.name %]:[% job.name %]</tt></h1>
<h2>Channels</h2>
<p>This job provides the following Nix channels:</p>
<ul>
<li>
<a href="[% c.uri_for('/job' project.name jobset.name job.name
'channel' 'latest') %]"><tt>latest</tt></a> — contains the latest
successful build for each platform.
</li>
<li>
<a href="[% c.uri_for('/job' project.name jobset.name job.name
'channel' 'all') %]"><tt>all</tt></a> — contains every successful
build of this job.
</li>
</ul>
<h2>Statistics</h2>
[% INCLUDE showBuildStats %]
[% END %]

212
src/root/jobset.tt Normal file
View file

@ -0,0 +1,212 @@
[% WRAPPER layout.tt title=(edit ? (create ? "New Jobset in Project $project.name" : "Editing Jobset $project.name:$jobset.name") : "Jobset $project.name:$jobset.name") %]
[% PROCESS common.tt %]
[% IF edit %]
<form action="[% IF create %][% c.uri_for('/project' project.name 'create-jobset/submit') %][% ELSE %][% c.uri_for('/jobset' project.name jobset.name 'submit') %][% END %]" method="post">
[% END %]
[% IF create %]
<h1>New Jobset in Project <tt>[% project.name %]</tt></h1>
[% ELSE %]
<h1>Jobset <tt>[% project.name %]:[% jobset.name %]</tt></h1>
[% END %]
[% BLOCK renderInputAlt %]
[% IF edit %]
<button type="button" onclick='$(this).parents(".inputalt").remove()'><img src="/static/images/failure.gif" alt="Delete value" /></button>
[% INCLUDE maybeEditString param=param value=alt.value %]
<br />
[% ELSE %]
[% INCLUDE maybeEditString param=param value=alt.value %]
[% END %]
[% END %]
[% BLOCK renderInput %]
<tr class="input [% extraClass %]" [% IF id %]id="[% id %]"[% END %]>
<td>
[% IF edit %]<button type="button" onclick='$(this).parents(".input").remove()'><img src="/static/images/failure.gif" alt="Delete input" /></button>[% END -%]
<tt>[% INCLUDE maybeEditString param="$baseName-name" value=input.name extraClass="shortString" %]</tt>
</td>
<td>
[% INCLUDE renderSelection curValue=input.type param="$baseName-type" options=inputTypes %]
</td>
<td class="inputalts" id="[% baseName %]">
[% FOREACH alt IN input.jobsetinputalts -%]
<tt class="inputalt">
[% IF input.type == "string" && !edit %]
"[% HTML.escape(alt.value) %]"
[% ELSE %]
[% INCLUDE renderInputAlt alt=alt param="$baseName-values" %]
[% END %]
</tt>
[% END %]
[% IF edit %]<button type="button" onclick='return false' class="add-inputalt">+</button>[% END %]
</td>
</tr>
[% END %]
<h2>Information[% IF !edit %] <a class="smallLink" href="[% c.uri_for('/jobset' project.name jobset.name 'edit') %]">[Edit]</a>[% END %]</h2>
<table class="layoutTable">
[% IF edit %]
<tr>
<th>Identifier:</th>
<td>[% INCLUDE maybeEditString param="name" value=jobset.name %]</td>
</tr>
[% END %]
<tr>
<th>Description:</th>
<td>[% INCLUDE maybeEditString param="description" value=jobset.description %]</td>
</tr>
<tr>
<th>Nix expression:</th>
<td>
<tt>[% INCLUDE maybeEditString param="nixexprpath" value=jobset.nixexprpath extraClass="shortString" %]</tt> in input
<tt>[% INCLUDE maybeEditString param="nixexprinput" value=jobset.nixexprinput extraClass="shortString" %]</tt>
</td>
</tr>
[% IF !edit %]
<tr>
<th>Last checked:</th>
<td>
[% IF jobset.lastcheckedtime %]
[% INCLUDE renderDateTime timestamp = jobset.lastcheckedtime -%][% IF jobset.errormsg -%]<em>, evaluation error</em>:
<pre class="multiLineMsg error">[% HTML.escape(jobset.errormsg) %]</pre>
[% ELSE %], <em>no errors</em>
[% END %]
[% ELSE %]
<em>never</em>
[% END %]
</td>
</tr>
[% END %]
</table>
<h3>Inputs</h3>
<table class="tablesorter">
<thead>
<tr><th>Input name</th><th>Type</th><th>Values</th></tr>
</thead>
<tbody class="inputs">
[% FOREACH input IN jobset.jobsetinputs -%]
[% INCLUDE renderInput input=input baseName="input-$input.name" %]
[% END %]
[% IF edit %]
<tr>
<td colspan="3"><button type="button" class="add-input">Add a new input</button></td>
</tr>
[% END %]
</tbody>
</table>
[% IF !edit %]
<h2>Jobs</h2>
<p>This jobset currently contains the following [% activeJobs.size %] jobs:
<blockquote>
[% IF activeJobs.size == 0 %]<em>(none)</em>[% END %]
[% FOREACH j IN activeJobs %] [% INCLUDE renderJobName project=project.name jobset=jobset.name job=j.name %] [% END %]
</blockquote>
</p>
<p>This jobset used to contain the following [% inactiveJobs.size %] jobs:
<blockquote>
[% IF inactiveJobs.size == 0 %]<em>(none)</em>[% END %]
[% FOREACH j IN inactiveJobs %] [% INCLUDE renderJobName project=project.name jobset=jobset.name job=j.name %] [% END %]
</blockquote>
</p>
<h2>Channels</h2>
<p>This jobset provides the following Nix channels:</p>
<ul>
<li>
<a href="[% c.uri_for('/jobset' project.name jobset.name 'channel'
'latest') %]"><tt>latest</tt></a> — contains the latest successful
build of every job in this jobset.
</li>
<li>
<a href="[% c.uri_for('/jobset' project.name jobset.name 'channel'
'all') %]"><tt>all</tt></a> — contains every successful,
non-garbage-collected build of every job in this project.
</li>
</ul>
<h2>Statistics</h2>
[% INCLUDE showBuildStats %]
[% END %]
[% IF edit %]
<table class="template"> <!-- dummy wrapper needed because “hidden” trs are visible anyway -->
[% INCLUDE renderInput input="" extraClass="template" id="input-template" baseName="input-template" %]
</table>
<tt class="inputalt template" id="inputalt-template">
[% INCLUDE renderInputAlt alt=alt %]
</tt>
<script type="text/javascript">
$(document).ready(function() {
var id = 0;
$(".add-input").click(function() {
var newid = "input-" + id++;
var x = $("#input-template").clone(true).attr("id", "").insertBefore($(this).parents("tr")).show();
$("#input-template-name", x).attr("name", newid + "-name");
$("#input-template-type", x).attr("name", newid + "-type");
$("#input-template", x).attr("id", newid);
return false;
});
$(".add-inputalt").click(function() {
var x = $("#inputalt-template").clone(true).insertBefore($(this)).attr("id", "").show();
$("input", x).attr("name", x.parents(".inputalts").attr("id") + "-values");
});
});
</script>
<p><button type="submit"><img src="/static/images/success.gif" />[%IF create %]Create[% ELSE %]Apply changes[% END %]</button></p>
</form>
[% IF !create %]
<form action="[% c.uri_for('/jobset' project.name jobset.name 'delete') %]" method="post">
<p><button id="delete-jobset" type="submit"><img src="/static/images/failure.gif" />Delete this jobset</button></p>
</form>
<script type="text/javascript">
$("#delete-jobset").click(function() {
return confirm("Are you sure you want to delete this jobset?");
});
</script>
[% END %]
[% END %]
[% END %]

View file

@ -4,17 +4,6 @@
[% PROCESS common.tt %]
[% BLOCK makeLinkWrapped %]
<li [% IF curUri == uri %]class="active"[% END %]>
<div class="title"><a href="[% uri %]">[% title %]</a></div>
[% content %]
</li>
[% END %]
[% BLOCK makeLink -%]
[% INCLUDE makeLinkWrapped content="" -%]
[% END %]
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
@ -83,63 +72,8 @@
<div id="container">
<div id="leftnavbar">
<div id="logo"><img src="/static/images/hydra.png" alt="Hydra" /></div>
<ul class="menu">
<li>
<div class="title">Hydra</div>
<ul class="submenu">
[% INCLUDE makeLink uri = c.uri_for('/') title = "Overview" %]
[% INCLUDE makeLink uri = c.uri_for('/queue') title = "Queue" %]
[% INCLUDE makeLink uri = c.uri_for('/jobstatus') title = "Job status" %]
[% INCLUDE makeLink uri = c.uri_for('/all') title = "All builds" %]
</ul>
</li>
<li>
<div class="title">Projects</div>
<ul class="submenu">
[% FOREACH project_ IN projects %]
<li [% IF curUri == c.uri_for('/project' project_.name) %]class="active"[% END %]>
<div class="title"><a href="[% c.uri_for('/project' project_.name) %]">[% HTML.escape(project_.displayname) %]</a></div>
[% IF project.name == project_.name %]
<ul class="subsubmenu">
[% INCLUDE makeLink uri = c.uri_for('/project' project.name 'jobstatus') title = "Job status" %]
[% INCLUDE makeLink uri = c.uri_for('/project' project.name 'all') title = "All builds" %]
[% WRAPPER makeLinkWrapped uri = c.uri_for('/releasesets' project.name) title = "Releases" %]
[% IF project.releasesets && project.releasesets.size > 0 %]
<ul class="subsubsubmenu">
[% FOREACH releaseset IN project.releasesets %]
[% myUri = c.uri_for('/releases' project.name releaseset.name) %]
<li [% IF curUri == myUri %]class="active"[% END %]>
<div class="title"><a href="[% myUri %]">
[% HTML.escape(releaseset.description ? releaseset.description : releaseset.name) %]
</a></div>
</li>
[% END %]
</ul>
[% END %]
[% END %]
[% INCLUDE makeLink uri = c.uri_for('/project' project.name 'edit') title = "Edit" %]
</ul>
[% END %]
</li>
[% END %]
</ul>
</li>
<li>
<div class="title">Admin</div>
<ul class="submenu">
[% IF c.user_exists %]
[% INCLUDE makeLink uri = c.uri_for('/logout') title = "Logout" %]
[% ELSE %]
[% INCLUDE makeLink uri = c.uri_for('/login') title = "Login" %]
[% END %]
[% INCLUDE makeLink uri = c.uri_for('/create-project') title = "Create project" %]
</ul>
</li>
</ul>
<div id="logo"><a class="no-hover" href="/"><img src="/static/images/hydra.png" alt="Hydra" /></a></div>
[% PROCESS navbar.tt %]
</div>
<div id="content">

119
src/root/navbar.tt Normal file
View file

@ -0,0 +1,119 @@
[% BLOCK makeLinkWrapped %]
<li [% IF curUri == uri %]class="active"[% END %]>
<div class="title"><a href="[% uri %]">[% title %]</a></div>
[% content %]
</li>
[% END %]
[% BLOCK makeLink -%]
[% INCLUDE makeLinkWrapped content="" -%]
[% END %]
[% BLOCK makeSubMenu %]
[% extra = collapsed ? "collapsed" : "" %]
<li class="submenu">
<div class="title [% extra %]"><a class="[% collapsed ? "submenuToggleCollapsed" : "submenuToggleExpanded" %]"
href="javascript:">[% HTML.escape(title) %]</a></div>
<ul class="submenu [% extra %]">
[% content %]
</ul>
</li>
[% END %]
<ul class="menu">
[% WRAPPER makeSubMenu title="Hydra" collapsed=0 %]
[% INCLUDE makeLink
uri = c.uri_for(c.controller('Root').action_for('index'))
title = "Overview" %]
[% INCLUDE makeLink
uri = c.uri_for(c.controller('Root').action_for('queue'))
title = "Queue" %]
[% INCLUDE makeLink
uri = c.uri_for(c.controller('Root').action_for('all'))
title = "All builds" %]
[% INCLUDE makeLink
uri = c.uri_for(c.controller('Root').action_for('jobstatus'))
title = "Job status" %]
[% END %]
[% IF project %]
[% WRAPPER makeSubMenu title="Project" collapsed=(jobset || job) %]
[% INCLUDE makeLink
uri = c.uri_for(c.controller('Project').action_for('view'), [project.name])
title = "Overview" %]
[% INCLUDE makeLink
uri = c.uri_for(c.controller('Project').action_for('all'), [project.name])
title = "All builds" %]
[% INCLUDE makeLink
uri = c.uri_for(c.controller('Project').action_for('jobstatus'), [project.name])
title = "Job status" %]
[% END %]
[% END %]
[% IF jobset %]
[% WRAPPER makeSubMenu title="Jobset" collapsed=job %]
[% INCLUDE makeLink
uri = c.uri_for(c.controller('Jobset').action_for('index'), [project.name, jobset.name])
title = "Overview" %]
[% INCLUDE makeLink
uri = c.uri_for(c.controller('Jobset').action_for('all'), [project.name, jobset.name])
title = "All builds" %]
[% INCLUDE makeLink
uri = c.uri_for(c.controller('Jobset').action_for('jobstatus'), [project.name, jobset.name])
title = "Job status" %]
[% END %]
[% END %]
[% IF job %]
[% WRAPPER makeSubMenu title="Job" %]
[% INCLUDE makeLink
uri = c.uri_for(c.controller('Job').action_for('index'), [project.name, jobset.name, job.name])
title = "Overview" %]
[% INCLUDE makeLink
uri = c.uri_for(c.controller('Job').action_for('all'), [project.name, jobset.name, job.name])
title = "All builds" %]
[% INCLUDE makeLink
uri = c.uri_for(c.controller('Job').action_for('jobstatus'), [project.name, jobset.name, job.name])
title = "Job status" %]
[% END %]
[% END %]
[% WRAPPER makeSubMenu title="Admin" collapsed=0 %]
[% IF c.user_exists %]
[% INCLUDE makeLink
uri = c.uri_for(c.controller('Root').action_for('logout'))
title = "Logout" %]
[% ELSE %]
[% INCLUDE makeLink
uri = c.uri_for(c.controller('Root').action_for('login'))
title = "Login" %]
[% END %]
[% INCLUDE makeLink
uri = c.uri_for(c.controller('Project').action_for('create'))
title = "Create project" %]
[% END %]
</ul>
<script type="text/javascript">
$(document).ready(function() {
$('.submenuToggleExpanded').toggle(
function () { $(".submenu", $(this).parents(".submenu")).slideUp(); },
function () { $(".submenu", $(this).parents(".submenu")).slideDown(); }
);
$('.submenuToggleCollapsed').toggle(
function () { $(".submenu", $(this).parents(".submenu")).slideDown(); },
function () { $(".submenu", $(this).parents(".submenu")).slideUp(); }
);
});
</script>

59
src/root/overview.tt Normal file
View file

@ -0,0 +1,59 @@
[% WRAPPER layout.tt title="Overview" %]
[% PROCESS common.tt %]
<h1>Hydra Overview</h1>
<p>Welcome to Hydra, the <a href="http://nixos.org/">Nix-based</a>
continuous build system. Hydra continuously builds, tests and
releases software packages from source repositories. <a
href="http://nixos.org/hydra"><em>[Read more...]</em></a></p>
<h2>Projects</h2>
<p>The following projects are hosted on this server:</p>
<table class="tablesorter">
<thead>
<tr>
<th>Id</th>
<th>Name</th>
<th>Description</th>
</tr>
</thead>
<tbody>
[% FOREACH p IN projects %]
<tr class="clickable [% IF odd %] odd [% END; odd = !odd %]"
onclick="window.location = '[% c.uri_for('/project' p.name) %]'">
<td>[% INCLUDE renderProjectName project = p.name %]</td>
<td>[% HTML.escape(p.displayname) %]</td>
<td>[% WRAPPER maybeLink uri=p.homepage %][% HTML.escape(p.description) %][% END %]</td>
</tr>
[% END %]
</tbody>
</table>
<h2>Channels</h2>
<p>This server provides the following global Nix channels:</p>
<ul>
<li>
<a href="[% c.uri_for('channel' 'latest') %]"><tt>latest</tt></a> —
contains the latest successful build of every job.
</li>
<li>
<a href="[% c.uri_for('channel' 'all') %]"><tt>all</tt></a> —
contains every successful, non-garbage-collected build of every job.
</li>
</ul>
<h2>Statistics</h2>
[% INCLUDE showBuildStats %]
[% END %]

View file

@ -1,137 +1,5 @@
[% WRAPPER layout.tt title=(edit ? (create ? "New Project" : "Editing Project $project.name") : "Project $project.name") %]
[% PROCESS common.tt %]
[% USE HTML %]
[% BLOCK renderSelection %]
[% IF edit %]
<select [% HTML.attributes(id => param, name => param) %]>
[% FOREACH name IN options.keys.sort %]
<option [% HTML.attributes(value => name) %] [% IF name == curValue; "selected='selected'"; END %]>[% options.$name %]</option>
[% END %]
</select>
[% ELSE %]
[% options.$curValue %]
[% END %]
[% END %]
[% BLOCK maybeEditString;
IF edit -%]
<input type="text" class="string [% extraClass %]" [% HTML.attributes(id => param, name => param, value => value) %] />
[% ELSE;
HTML.escape(value);
END -%]
[% END -%]
[% BLOCK renderInputAlt %]
[% IF edit %]
<button type="button" onclick='$(this).parents(".inputalt").remove()'><img src="/static/images/failure.gif" alt="Delete value" /></button>
[% INCLUDE maybeEditString param=param value=alt.value %]
<br />
[% ELSE %]
[% INCLUDE maybeEditString param=param value=alt.value %]
[% END %]
[% END %]
[% BLOCK renderInput %]
<tr class="input [% extraClass %]" [% IF id %]id="[% id %]"[% END %]>
<td>
[% IF edit %]<button type="button" onclick='$(this).parents(".input").remove()'><img src="/static/images/failure.gif" alt="Delete input" /></button>[% END -%]
<tt>[% INCLUDE maybeEditString param="$baseName-name" value=input.name extraClass="shortString" %]</tt>
</td>
<td>
[% INCLUDE renderSelection curValue=input.type param="$baseName-type" options=inputTypes %]
</td>
<td class="inputalts" id="[% baseName %]">
[% FOREACH alt IN input.jobsetinputalts -%]
<tt class="inputalt">
[% IF input.type == "string" && !edit %]
"[% HTML.escape(alt.value) %]"
[% ELSE %]
[% INCLUDE renderInputAlt alt=alt param="$baseName-values" %]
[% END %]
</tt>
[% END %]
[% IF edit %]<button type="button" onclick='return false' class="add-inputalt">+</button>[% END %]
</td>
</tr>
[% END %]
[% BLOCK renderJobset %]
<div class="jobset[% IF edit %] jobset-edit[% END %]" id="[% "jobset-$baseName" %]">
<input type="hidden" [% HTML.attributes(name => "jobset-$baseName-oldName", value => jobset.name) %] />
<h3>
[% IF edit %]<button type="button" onclick='$(this).parents(".jobset").remove()'><img src="/static/images/failure.gif" alt="Delete value" /></button>[% END %]
[% IF jobset %]Jobset <tt>[% jobset.name %]</tt>[% ELSE %]New jobset[% END %]
</h3>
<h4>Information</h4>
<table class="layoutTable">
[% IF edit %]
<tr>
<th>Identifier:</th>
<td>[% INCLUDE maybeEditString param="jobset-$baseName-name" value=jobset.name %]</td>
</tr>
[% END %]
<tr>
<th>Description:</th>
<td>[% INCLUDE maybeEditString param="jobset-$baseName-description" value=jobset.description %]</td>
</tr>
<tr>
<th>Nix expression:</th>
<td>
<tt>[% INCLUDE maybeEditString param="jobset-$baseName-nixexprpath" value=jobset.nixexprpath extraClass="shortString" %]</tt> in input
<tt>[% INCLUDE maybeEditString param="jobset-$baseName-nixexprinput" value=jobset.nixexprinput extraClass="shortString" %]</tt>
</td>
</tr>
[% IF !edit %]
<tr>
<th>Last checked:</th>
<td>
[% IF jobset.lastcheckedtime %]
[% INCLUDE renderDateTime timestamp = jobset.lastcheckedtime -%][% IF jobset.errormsg -%]<em>, evaluation error</em>:
<pre class="multiLineMsg error">[% HTML.escape(jobset.errormsg) %]</pre>
[% ELSE %], <em>no errors</em>
[% END %]
[% ELSE %]
<em>never</em>
[% END %]
</td>
</tr>
[% END %]
</table>
<h4>Inputs</h4>
<table class="tablesorter">
<thead>
<tr><th>Input name</th><th>Type</th><th>Values</th></tr>
</thead>
<tbody class="inputs">
[% FOREACH input IN jobset.jobsetinputs -%]
[% INCLUDE renderInput input=input baseName="jobset-$baseName-input-$input.name" %]
[% END %]
[% IF edit %]
<tr>
<td colspan="3"><button type="button" class="add-input">Add a new input</button></td>
</tr>
[% END %]
</tbody>
</table>
</div>
[% END %]
[% IF edit %]
@ -146,7 +14,7 @@
[% END %]
<h2>General information</h2>
<h2>Information[% IF !edit %] <a class="smallLink" href="[% c.uri_for('/project' project.name 'edit') %]">[Edit]</a>[% END %]</h2>
<table class="layoutTable">
[% IF edit %]
@ -190,83 +58,98 @@
</table>
[% IF !edit %]
<h2>Statistics</h2>
[% INCLUDE showBuildStats %]
[% END %]
<h2>Jobsets</h2>
[% IF project.jobsets && project.jobsets.size > 0 || edit %]
[% IF project.jobsets.size > 0 %]
[% IF edit %]
<p><button type="button" id="add-jobset">Add a new jobset</button></p>
<p>This project has the following jobsets:</p>
<div id="jobset-template" class="template">
[% INCLUDE renderJobset jobset="" baseName="template" %]
</div>
<table class="tablesorter">
<thead>
<tr>
<th>Id</th>
<th>Description</th>
<th>Last evaluated</th>
</tr>
</thead>
<tbody>
[% FOREACH j IN project.jobsets %]
<tr class="clickable [% IF odd %] odd [% END; odd = !odd %]"
onclick="window.location = '[% c.uri_for('/jobset' project.name j.name) %]'">
<td>[% INCLUDE renderJobsetName project = project.name jobset = j.name %]</td>
<td>[% HTML.escape(j.description) %]</td>
<td>[% INCLUDE renderDateTime timestamp = j.lastcheckedtime %]</td>
</tr>
[% END %]
</tbody>
</table>
<table class="template"> <!-- dummy wrapper needed because “hidden” trs are visible anyway -->
[% INCLUDE renderInput input="" extraClass="template" id="input-template" baseName="input-template" %]
</table>
<tt class="inputalt template" id="inputalt-template">
[% INCLUDE renderInputAlt alt=alt %]
</tt>
<script type="text/javascript">
$(document).ready(function() {
var id = 0;
$("#add-jobset").click(function() {
var newid = "jobset-" + id++;
var x = $("#jobset-template").clone(true).attr("id", newid).insertAfter($("#jobset-template")).slideDown("fast");
$("#jobset-template", x).attr("id", newid);
$("#jobset-template-name", x).attr("name", newid + "-name");
$("#jobset-template-description", x).attr("name", newid + "-description");
$("#jobset-template-nixexprpath", x).attr("name", newid + "-nixexprpath");
$("#jobset-template-nixexprinput", x).attr("name", newid + "-nixexprinput");
return false;
});
$(".add-input").click(function() {
var jobset = $(this).parents(".jobset");
var inputid = jobset.attr("id");
var newid = inputid + "-input-" + id++;
var x = $("#input-template").clone(true).attr("id", "").insertBefore($(this).parents("tr")).show();
$("#input-template-name", x).attr("name", newid + "-name");
$("#input-template-type", x).attr("name", newid + "-type");
$("#input-template", x).attr("id", newid);
return false;
});
$(".add-inputalt").click(function() {
var x = $("#inputalt-template").clone(true).insertBefore($(this)).attr("id", "").show();
$("input", x).attr("name", x.parents(".inputalts").attr("id") + "-values");
});
});
</script>
[% END %]
[% n = 0; FOREACH jobset IN project.jobsets -%]
[% INCLUDE renderJobset jobset=jobset baseName="e$n"; n = n + 1 %]
[% END -%]
[% ELSE %]
<p>No jobsets have been defined yet.</p>
[% END %]
<a href="[% c.uri_for(c.controller('Project').action_for('create_jobset'), [project.name]) %]">[Create a new jobset]</a>
<h2>Releases</h2>
[% IF releaseSets.size > 0 %]
<p>Project <tt>[% project.name %]</tt> has the following release sets:</p>
<ul>
[% FOREACH releaseSet IN releaseSets %]
<li>
<a href="[% c.uri_for('/releases' project.name releaseSet.name) %]"><tt>[% releaseSet.name %]</tt></a>
[<a href="[% c.uri_for('/releases' project.name releaseSet.name "edit") %]">Edit</a>]
</li>
[% END %]
</ul>
[% ELSE %]
<p>Project <tt>[% project.name %]</tt> has no release sets.</p>
[% END %]
<p><a href="[% c.uri_for('/create_releaseset' project.name) %]">[Create a new release set]</a></p>
<h2>Channels</h2>
<p>This project provides the following Nix channels:</p>
<ul>
<li>
<a href="[% c.uri_for('/project' project.name 'channel' 'latest') %]"><tt>latest</tt></a> —
contains the latest successful build of every job in this project.
</li>
<li>
<a href="[% c.uri_for('/project' project.name 'channel' 'all') %]"><tt>all</tt></a> —
contains every successful, non-garbage-collected build of every
job in this project.
</li>
</ul>
<h2>Statistics</h2>
[% INCLUDE showBuildStats %]
[% END %]
[% IF edit %]
<hr />
<p><button type="submit"><img src="/static/images/success.gif" />[%IF create %]Create[% ELSE %]Apply changes[% END %]</button></p>
</form>

View file

@ -14,19 +14,19 @@
<p class="error">This is an incomplete release. One of its jobs has not been built (yet). See below for details.</p>
[% END %]
[% FOREACH job IN release.jobs %]
[% FOREACH j IN release.jobs %]
<h2>
[% IF job.build %]<a href="[% c.uri_for('/build' job.build.id) %]">[% END %]
[% INCLUDE renderReleaseJobName job=job.job %]
[% IF job.build %]</a>[% END %]
[% IF j.build %]<a href="[% c.uri_for('/build' job.build.id) %]">[% END %]
[% INCLUDE renderReleaseJobName job=j.job %]
[% IF j.build %]</a>[% END %]
</h2>
[% IF job.build %]
[% IF j.build %]
[% IF job.build.resultInfo.buildstatus == 0 %]
[% IF j.build.resultInfo.buildstatus == 0 %]
[% INCLUDE renderProductList build=job.build %]
[% INCLUDE renderProductList build=j.build %]
[% ELSE %]

View file

@ -16,8 +16,8 @@
<th>#</th>
<th>Release</th>
<th>Date</th>
[% FOREACH job IN jobs %]
<th class="releaseSetJobName">[% INCLUDE renderReleaseJobName %]</th>
[% FOREACH j IN jobs %]
<th class="releaseSetJobName">[% INCLUDE renderReleaseJobName job=j %]</th>
[% END %]
</tr>
</thead>
@ -44,11 +44,11 @@
[% END %]
</td>
<td>[% INCLUDE renderDateTime timestamp=release.timestamp %]</td>
[% FOREACH job IN release.jobs %]
[% FOREACH j IN release.jobs %]
<td class="centered">
[% IF job.build %]
<a href="[% c.uri_for('/build' job.build.id) %]">
[% IF job.build.get_column('buildstatus') == 0 %]
[% IF j.build %]
<a href="[% c.uri_for('/build' j.build.id) %]">
[% IF j.build.get_column('buildstatus') == 0 %]
<img src="/static/images/success.gif" />
[% ELSE %]
<img src="/static/images/failure.gif" />

View file

@ -1,28 +0,0 @@
[% WRAPPER layout.tt title="Release Sets" %]
[% PROCESS common.tt %]
<h1>Release Sets</h1>
[% IF releaseSets.size > 0 %]
<p>Project <tt>[% project.name %]</tt> has the following release sets:</p>
<ul>
[% FOREACH releaseSet IN releaseSets %]
<li>
<a href="[% c.uri_for('/releases' project.name releaseSet.name) %]"><tt>[% releaseSet.name %]</tt></a>
[<a href="[% c.uri_for('/releases' project.name releaseSet.name "edit") %]">Edit</a>]
</li>
[% END %]
</ul>
[% ELSE %]
<p>Project <tt>[% project.name %]</tt> has no release sets.</p>
[% END %]
<p>[<a href="[% c.uri_for('/create_releaseset' project.name) %]">Create a new release set</a>]</p>
[% END %]

View file

@ -65,7 +65,6 @@ td.centered {
}
th {
vertical-align: center;
background: #ffffc0;
}
@ -101,6 +100,7 @@ td.date, span.date, span.svnrev {
a:link { color: #0048b3; }
a:visited { color: #002a6a; }
a:hover { background: #ffffcd; }
a.no-hover:hover { background: none; }
span.relname {
font-weight: bold;
@ -136,6 +136,11 @@ a:hover, a:visited:hover {
text-decoration: underline;
}
a.smallLink {
font-size: 60%;
vertical-align: top;
}
img {
border-style: none;
}
@ -196,23 +201,6 @@ ul.productList li {
display: none;
}
div.jobset {
border: solid black 1px;
-moz-border-radius: 1em;
border-radius: 1em;
padding-left: 1em;
padding-right: 1em;
margin-bottom: 1em;
}
div.jobset-edit {
background-color: #f8f8f8;
}
div.jobset-edit h3, div.jobset h3 {
margin-top: 0.5em;
}
div.help {
border: solid black 1px;
padding-left: 1em;
@ -314,11 +302,25 @@ h1 {
#leftnavbar ul.menu > li > div.title {
text-align: center;
font-weight: bold;
color: black;
border-width: 0px;
border-bottom-width: 1px;
border-style: solid;
border-color: #c0c0c0;
padding-bottom: 0.5em;
background-image: url(/static/images/arrow-down.gif);
background-repeat: no-repeat;
background-position: 0.3em center;
}
#leftnavbar ul.menu > li > div.title > a {
display: block;
background: none;
color: black;
}
#leftnavbar ul.menu > li > div.title > a:focus {
outline: none;
}
#leftnavbar ul.submenu {
@ -327,6 +329,10 @@ h1 {
margin-right: 0em;
}
#leftnavbar ul.collapsed {
display: none;
}
#leftnavbar ul.submenu > li {
font-size: 90%;
list-style: none;
@ -416,6 +422,10 @@ h1 {
color: #606060;
}
.hidden {
display: none;
}
#footer {
font-size: 80%;
}