* Happy Javascript hacking.
This commit is contained in:
parent
f6f5309a02
commit
77e1bb7527
|
@ -61,8 +61,51 @@ sub updateProject {
|
|||
$project->name($projectName);
|
||||
$project->displayname($displayName);
|
||||
$project->description($c->request->params->{description});
|
||||
|
||||
|
||||
$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 = $c->request->params->{"jobset-$baseName-name"};
|
||||
die "Invalid jobset name: $jobsetName" unless $jobsetName =~ /^[[:alpha:]]\w*$/;
|
||||
|
||||
my $nixExprPath = $c->request->params->{"jobset-$baseName-nixexprpath"};
|
||||
die "Invalid Nix expression path: $nixExprPath" unless $nixExprPath =~ /^\w++$/; # !!! stricter
|
||||
|
||||
my $nixExprInput = $c->request->params->{"jobset-$baseName-nixexprinput"};
|
||||
die "Invalid Nix expression input name: $nixExprInput" unless $nixExprInput =~ /^\w+$/;
|
||||
|
||||
$jobsetNames{$jobsetName} = 1;
|
||||
|
||||
if ($baseName =~ /^\d+$/) { # numeric base name is auto-generated, i.e. a new entry
|
||||
my $jobset = $c->model('DB::Jobsets')->create(
|
||||
{ project => $project->name
|
||||
, name => $jobsetName
|
||||
, description => $c->request->params->{"jobset-$baseName-description"}
|
||||
, nixexprpath => $nixExprPath
|
||||
, nixexprinput => $nixExprInput
|
||||
});
|
||||
} else { # it's an existing jobset
|
||||
(my $jobset) = $project->jobsets->search({name => $baseName});
|
||||
die unless defined $jobset;
|
||||
$jobset->name($jobsetName);
|
||||
$jobset->description($c->request->params->{"jobset-$baseName-description"});
|
||||
$jobset->nixexprpath($nixExprPath);
|
||||
$jobset->nixexprinput($nixExprInput);
|
||||
$jobset->update;
|
||||
}
|
||||
}
|
||||
|
||||
# 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};
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -16,10 +16,12 @@ h1 {
|
|||
|
||||
h2 {
|
||||
font-size: 130%;
|
||||
margin-top: 2em;
|
||||
}
|
||||
|
||||
h3 {
|
||||
font-size: 100%;
|
||||
margin-top: 1.5em;
|
||||
}
|
||||
|
||||
table {
|
||||
|
@ -179,6 +181,14 @@ tr.runningJob {
|
|||
margin-left: 3em;
|
||||
}
|
||||
|
||||
div.indent {
|
||||
padding-left: 2em;
|
||||
}
|
||||
|
||||
div.template {
|
||||
display: none;
|
||||
}
|
||||
|
||||
|
||||
/* Sortable tables */
|
||||
|
||||
|
|
|
@ -4,69 +4,34 @@
|
|||
|
||||
[% BLOCK maybeEditString %]
|
||||
[% IF edit %]
|
||||
<input type='text' class='string' [% HTML.attributes(name => param, value => value) %] />
|
||||
<input type="text" class="string" [% HTML.attributes(id => param, name => param, value => value) %] />
|
||||
[% ELSE %]
|
||||
[% HTML.escape(value) %]
|
||||
[% END %]
|
||||
[% END %]
|
||||
|
||||
|
||||
[% IF edit %]
|
||||
<form action="[% IF create %][% c.uri_for('/createproject/submit') %][% ELSE %][% c.uri_for('/project' curProject.name 'submit') %][% END %]" method="post">
|
||||
[% END %]
|
||||
[% BLOCK renderJobset %]
|
||||
|
||||
<div class="indent jobset">
|
||||
|
||||
[% IF create %]
|
||||
<h1>New Project</h1>
|
||||
[% ELSE %]
|
||||
<h1>Project <tt>[% curProject.name %]</tt></h1>
|
||||
[% END %]
|
||||
<h3>Jobset <tt>[% INCLUDE maybeEditString param="jobset-$baseName-name" value=jobset.name %]</tt></h3>
|
||||
|
||||
|
||||
<h2>General information</h2>
|
||||
|
||||
<table>
|
||||
[% IF edit %]
|
||||
<tr>
|
||||
<th>Identifier:</th>
|
||||
<td><tt>[% INCLUDE maybeEditString param="name" value=curProject.name %]</tt></td>
|
||||
</tr>
|
||||
[% END %]
|
||||
<tr>
|
||||
<th>Display name:</th>
|
||||
<td>[% INCLUDE maybeEditString param="displayname" value=curProject.displayname %]</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th>Description:</th>
|
||||
<td>[% INCLUDE maybeEditString param="description" value=curProject.description %]</td>
|
||||
</tr>
|
||||
</table>
|
||||
|
||||
|
||||
<h2>Definition</h2>
|
||||
|
||||
[% IF curProject.jobsets.size > 0 %]
|
||||
|
||||
[% FOREACH jobset IN curProject.jobsets -%]
|
||||
|
||||
<h3>Jobset <tt>[% jobset.name %]</tt></h3>
|
||||
<div class="indent">
|
||||
|
||||
<h4>Information</h4>
|
||||
|
||||
<table>
|
||||
[% IF edit %]
|
||||
<tr>
|
||||
<th>Identifier:</th>
|
||||
<td><tt>[% INCLUDE maybeEditString value=jobset.name %]</tt></td>
|
||||
</tr>
|
||||
[% END %]
|
||||
<tr>
|
||||
<th>Description:</th>
|
||||
<td>[% INCLUDE maybeEditString value=jobset.description %]</td>
|
||||
<td>[% INCLUDE maybeEditString param="jobset-$baseName-description" value=jobset.description %]</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th>Nix expression:</th>
|
||||
<td><tt>[% INCLUDE maybeEditString value=jobset.nixexprpath %]</tt> in input <tt>[% INCLUDE maybeEditString value=jobset.nixexprinput %]</tt></td>
|
||||
<td>
|
||||
<tt>[% INCLUDE maybeEditString param="jobset-$baseName-nixexprpath" value=jobset.nixexprpath %]</tt> in input
|
||||
<tt>[% INCLUDE maybeEditString param="jobset-$baseName-nixexprinput" value=jobset.nixexprinput %]</tt>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
|
||||
|
@ -114,7 +79,76 @@
|
|||
</tbody>
|
||||
</table>
|
||||
|
||||
[% END -%]
|
||||
[% IF edit %]
|
||||
<p><button onclick='$(this).parents(".jobset").remove()' id="jobset-[% baseName %]-delete">Delete this jobset</button></p>
|
||||
[% END %]
|
||||
|
||||
</div>
|
||||
</div>
|
||||
|
||||
[% END %]
|
||||
|
||||
|
||||
[% IF edit %]
|
||||
<form action="[% IF create %][% c.uri_for('/createproject/submit') %][% ELSE %][% c.uri_for('/project' curProject.name 'submit') %][% END %]" method="post">
|
||||
[% END %]
|
||||
|
||||
|
||||
[% IF create %]
|
||||
<h1>New Project</h1>
|
||||
[% ELSE %]
|
||||
<h1>Project <tt>[% curProject.name %]</tt></h1>
|
||||
[% END %]
|
||||
|
||||
|
||||
<h2>General information</h2>
|
||||
|
||||
<table>
|
||||
[% IF edit %]
|
||||
<tr>
|
||||
<th>Identifier:</th>
|
||||
<td><tt>[% INCLUDE maybeEditString param="name" value=curProject.name %]</tt></td>
|
||||
</tr>
|
||||
[% END %]
|
||||
<tr>
|
||||
<th>Display name:</th>
|
||||
<td>[% INCLUDE maybeEditString param="displayname" value=curProject.displayname %]</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th>Description:</th>
|
||||
<td>[% INCLUDE maybeEditString param="description" value=curProject.description %]</td>
|
||||
</tr>
|
||||
</table>
|
||||
|
||||
|
||||
<h2>Jobsets</h2>
|
||||
|
||||
[% IF curProject.jobsets && curProject.jobsets.size > 0 || edit %]
|
||||
|
||||
[% IF edit %]
|
||||
<p><button id="add-jobset">Add a new jobset</button></p>
|
||||
|
||||
<div id="jobset-template" class="template">
|
||||
[% INCLUDE renderJobset jobset="" baseName="template" %]
|
||||
</div>
|
||||
|
||||
<script>
|
||||
var id = 0;
|
||||
$("#add-jobset").click(function() {
|
||||
var newid = "jobset-" + id++;
|
||||
$("#jobset-template").clone(true).attr("id", newid).insertAfter($("#jobset-template")).show();
|
||||
$("#jobset-template-name", $("#" + newid)).attr("name", newid + "-name").attr("value", newid);
|
||||
$("#jobset-template-description", $("#" + newid)).attr("name", newid + "-description");
|
||||
$("#jobset-template-nixexprpath", $("#" + newid)).attr("name", newid + "-nixexprpath");
|
||||
$("#jobset-template-nixexprinput", $("#" + newid)).attr("name", newid + "-nixexprinput");
|
||||
return false;
|
||||
});
|
||||
</script>
|
||||
[% END %]
|
||||
|
||||
[% FOREACH jobset IN curProject.jobsets -%]
|
||||
[% INCLUDE renderJobset jobset=jobset baseName=jobset.name %]
|
||||
[% END -%]
|
||||
|
||||
[% ELSE %]
|
||||
|
||||
|
@ -128,7 +162,7 @@
|
|||
|
||||
<h2>Jobs</h2>
|
||||
|
||||
[% IF jobNames.size > 0 %]
|
||||
[% IF jobName && jobNames.size > 0 %]
|
||||
|
||||
<ul>
|
||||
[% FOREACH jobName IN jobNames -%]
|
||||
|
@ -178,14 +212,26 @@
|
|||
|
||||
[% IF edit %]
|
||||
|
||||
<p><input type="submit" value="Apply" /></p>
|
||||
<hr />
|
||||
|
||||
<p><input type="submit" value="[% IF create %]Create[% ELSE %]Apply changes[% END %]" /></p>
|
||||
|
||||
</form>
|
||||
|
||||
<form action="[% c.uri_for('/project' curProject.name 'delete') %]" method="post">
|
||||
<p><input type="submit" value="Delete this project" /></p>
|
||||
</form>
|
||||
[% IF !create %]
|
||||
|
||||
<form action="[% c.uri_for('/project' curProject.name 'delete') %]" method="post">
|
||||
<p><input id="delete-project" type="submit" value="Delete this project" /></p>
|
||||
</form>
|
||||
|
||||
<script>
|
||||
$("#delete-project").click(function() {
|
||||
return confirm("Are you sure you want to delete this project?");
|
||||
});
|
||||
</script>
|
||||
|
||||
[% END %]
|
||||
|
||||
[% END %]
|
||||
|
||||
|
||||
|
|
Loading…
Reference in a new issue