Split viewing and editing a jobset

This commit is contained in:
Eelco Dolstra 2013-02-21 02:33:57 +01:00
parent 9c7b416f8b
commit 547e41263d
6 changed files with 277 additions and 239 deletions

View file

@ -115,7 +115,7 @@ sub edit : Chained('jobset') PathPart Args(0) {
requireProjectOwner($c, $c->stash->{project}); requireProjectOwner($c, $c->stash->{project});
$c->stash->{template} = 'jobset.tt'; $c->stash->{template} = 'edit-jobset.tt';
$c->stash->{edit} = 1; $c->stash->{edit} = 1;
} }
@ -235,8 +235,8 @@ sub updateJobset {
, description => trim($c->request->params->{"description"}) , description => trim($c->request->params->{"description"})
, nixexprpath => $nixExprPath , nixexprpath => $nixExprPath
, nixexprinput => $nixExprInput , nixexprinput => $nixExprInput
, enabled => trim($c->request->params->{enabled}) eq "1" ? 1 : 0 , enabled => defined $c->request->params->{enabled} ? 1 : 0
, enableemail => trim($c->request->params->{enableemail}) eq "1" ? 1 : 0 , enableemail => defined $c->request->params->{enableemail} ? 1 : 0
, emailoverride => trim($c->request->params->{emailoverride}) || "" , emailoverride => trim($c->request->params->{emailoverride}) || ""
, keepnr => trim($c->request->params->{keepnr}) || 3 , keepnr => trim($c->request->params->{keepnr}) || 3
}); });

View file

@ -110,7 +110,7 @@ sub create_jobset : Chained('project') PathPart('create-jobset') Args(0) {
requireProjectOwner($c, $c->stash->{project}); requireProjectOwner($c, $c->stash->{project});
$c->stash->{template} = 'jobset.tt'; $c->stash->{template} = 'edit-jobset.tt';
$c->stash->{create} = 1; $c->stash->{create} = 1;
$c->stash->{edit} = 1; $c->stash->{edit} = 1;
} }

View file

@ -196,11 +196,6 @@ BLOCK maybeLink;
END; END;
BLOCK maybeButton;
IF uri %]<a class="btn btn-mini" [% HTML.attributes(href => uri); IF confirmmsg %]onclick="javascript:return confirm('[% confirmmsg %]')"[% END; content %]</a>[% ELSE; content; END;
END;
BLOCK renderSelection; BLOCK renderSelection;
IF edit; IF edit;
IF radiobuttons; %] IF radiobuttons; %]
@ -227,21 +222,8 @@ BLOCK renderSelection;
END; END;
BLOCK maybeEditString; BLOCK editString; %]
IF edit %]
<input type="text" class="string [% extraClass %]" [% HTML.attributes(id => param, name => param, value => value) %] />
[% ELSE;
HTML.escape(value);
END;
END;
BLOCK editString;
IF edit %]
<input type="text" class="string" [% HTML.attributes(id => param, name => param, value => value) %] /> <input type="text" class="string" [% HTML.attributes(id => param, name => param, value => value) %] />
[% ELSE;
HTML.escape(value);
END;
END; END;

143
src/root/edit-jobset.tt Normal file
View file

@ -0,0 +1,143 @@
[% WRAPPER layout.tt title=(create ? "Create jobset in project $project.name" : "Editing jobset $project.name:$jobset.name") %]
[% PROCESS common.tt %]
[% BLOCK renderInputAlt %]
<button type="button" class="btn btn-warning" onclick='$(this).parents(".inputalt").remove()'><i class="icon-trash icon-white"></i></button>
<input type="text" [% HTML.attributes(value => alt.value, name => name) %]></input>
<br />
[% END %]
[% BLOCK renderInput %]
<tr class="input [% extraClass %]" [% IF id %]id="[% id %]"[% END %]>
<td>
<button type="button" class="btn btn-warning" onclick='$(this).parents(".input").remove()'><i class="icon-trash icon-white"></i></button>
<tt><input type="text" name="[% baseName %]-name" [% HTML.attributes(value => input.name) %]></input>
</td>
<td>
[% INCLUDE renderSelection curValue=input.type param="$baseName-type" options=inputTypes %]
</td>
<td class="inputalts" id="[% baseName %]">
[% FOREACH alt IN input.jobsetinputalts %]
<span class="inputalt">
[% INCLUDE renderInputAlt alt=alt name="$baseName-values" %]
</span>
[% END %]
[% IF edit %]<button type="button" class="add-inputalt btn btn-success" onclick='return false'><i class="icon-plus icon-white"></i></button>[% END %]
</td>
</tr>
[% END %]
[% BLOCK renderInputs %]
<table class="table table-striped table-condensed">
<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 %]
<tr>
<td colspan="3" style="text-align: center;"><button type="button" class="add-input btn btn-success"><i class="icon-plus icon-white"></i> Add a new input</button></td
</tr>
</tbody>
</table>
[% END %]
<form class="form-horizontal" 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">
<fieldset>
<div class="control-group">
<div class="controls">
<label class="checkbox">
<input type="checkbox" name="enabled" [% IF jobset.enabled; 'checked="checked"'; END %]></input>Enabled
</label>
</div>
</div>
<div class="control-group">
<label class="control-label">Identifier</label>
<div class="controls">
<input type="text" class="span3" name="name" [% HTML.attributes(value => jobset.name) %]></input>
</div>
</div>
<div class="control-group">
<label class="control-label">Description</label>
<div class="controls">
<input type="text" class="span3" name="description" [% HTML.attributes(value => jobset.description) %]></input>
</div>
</div>
<div class="control-group">
<label class="control-label">Nix expression</label>
<div class="controls">
<input type="text" class="span3" name="nixexprpath" [% HTML.attributes(value => jobset.nixexprpath) %]></input>
in
<input type="text" class="span3" name="nixexprinput" [% HTML.attributes(value => jobset.nixexprinput) %]></input>
</div>
</div>
<div class="control-group">
<div class="controls">
<label class="checkbox">
<input type="checkbox" name="enableemail" [% IF jobset.enableemail; 'checked="checked"'; END %]></input>Email notification
</label>
</div>
</div>
<div class="control-group">
<label class="control-label">Email override</label>
<div class="controls">
<input type="text" class="span3" name="emailoverride" [% HTML.attributes(value => jobset.emailoverride) %]></input>
</div>
</div>
<div class="control-group">
<label class="control-label">Number of builds to keep</label>
<div class="controls">
<input type="number" class="span3" name="keepnr" [% HTML.attributes(value => jobset.keepnr) %]></input>
</div>
</div>
[% INCLUDE renderInputs %]
<div class="form-actions">
<button type="submit" class="btn btn-primary"><i class="icon-ok icon-white"></i> [%IF create %]Create[% ELSE %]Apply changes[% END %]</button>
</div>
</fieldset>
<table class="hidden">
[% INCLUDE renderInput input="" extraClass="template" id="input-template" baseName="input-template" %]
</table>
<tt class="inputalt hidden" 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>
</form>
[% END %]

View file

@ -8,12 +8,12 @@
<div class="control-group"> <div class="control-group">
<div class="controls"> <div class="controls">
<label class="checkbox"> <label class="checkbox">
<input type="checkbox" name="enabled" value="enabled" [% IF project.enabled; 'checked="checked"'; END %]></input>Enabled <input type="checkbox" name="enabled" [% IF project.enabled; 'checked="checked"'; END %]></input>Enabled
</label> </label>
</div> </div>
<div class="controls"> <div class="controls">
<label class="checkbox"> <label class="checkbox">
<input type="checkbox" name="visible" value="visible" [% IF !project.hidden; 'checked="checked"'; END %]></input>Visible in the list of projects <input type="checkbox" name="visible" [% IF !project.hidden; 'checked="checked"'; END %]></input>Visible in the list of projects
</label> </label>
</div> </div>
</div> </div>

View file

@ -1,28 +1,11 @@
[% WRAPPER layout.tt title=(edit ? (create ? "Create jobset in project $project.name" : "Editing jobset $project.name:$jobset.name") : "Jobset $project.name:$jobset.name") %] [% WRAPPER layout.tt title="Jobset $project.name:$jobset.name" %]
[% PROCESS common.tt %] [% PROCESS common.tt %]
[% IF edit %]
<form class="form-horizontal" 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 %]
[% BLOCK renderInputAlt %]
[% IF edit %]
<button type="button" class="btn btn-warning" onclick='$(this).parents(".inputalt").remove()'><i class="icon-trash icon-white"></i></button>
[% INCLUDE maybeEditString param=param value=alt.value %]
<br />
[% ELSE %]
[% INCLUDE maybeEditString param=param value=alt.value %]
[% END %]
[% END %]
[% BLOCK renderInput %] [% BLOCK renderInput %]
<tr class="input [% extraClass %]" [% IF id %]id="[% id %]"[% END %]> <tr class="input [% extraClass %]" [% IF id %]id="[% id %]"[% END %]>
<td> <td>
[% IF edit %]<button type="button" class="btn btn-warning" onclick='$(this).parents(".input").remove()'><i class="icon-trash icon-white"></i></button>[% END %] <tt>[% HTML.escape(input.name) %]</tt>
<tt>[% INCLUDE maybeEditString param="$baseName-name" value=input.name %]</tt>
</td> </td>
<td> <td>
[% INCLUDE renderSelection curValue=input.type param="$baseName-type" options=inputTypes %] [% INCLUDE renderSelection curValue=input.type param="$baseName-type" options=inputTypes %]
@ -30,23 +13,20 @@
<td class="inputalts" id="[% baseName %]"> <td class="inputalts" id="[% baseName %]">
[% FOREACH alt IN input.jobsetinputalts %] [% FOREACH alt IN input.jobsetinputalts %]
<tt class="inputalt"> <tt class="inputalt">
[% IF input.type == "string" && !edit %] [% IF input.type == "string" %]
"[% HTML.escape(alt.value) %]" "[% HTML.escape(alt.value) %]"
[% ELSE %] [% ELSE %]
[% INCLUDE renderInputAlt alt=alt param="$baseName-values" %] [% HTML.escape(alt.value) %]
[% END %] [% END %]
</tt> </tt>
[% END %] [% END %]
[% IF edit %]<button type="button" class="add-inputalt btn btn-success" onclick='return false'><i class="icon-plus icon-white"></i></button>[% END %]
</td> </td>
</tr> </tr>
[% END %] [% END %]
[% BLOCK renderInputs %] [% BLOCK renderInputs %]
<h3>Inputs</h3> <h3>Inputs</h3>
<table class="tablesorter table table-striped table-condensed"> <table class="tablesorter table table-striped table-condensed">
<thead> <thead>
<tr><th>Input name</th><th>Type</th><th>Values</th></tr> <tr><th>Input name</th><th>Type</th><th>Values</th></tr>
@ -55,33 +35,30 @@
[% FOREACH input IN jobset.jobsetinputs %] [% FOREACH input IN jobset.jobsetinputs %]
[% INCLUDE renderInput input=input baseName="input-$input.name" %] [% INCLUDE renderInput input=input baseName="input-$input.name" %]
[% END %] [% END %]
[% IF edit %]
<tr>
<td colspan="3" style="text-align: center;"><button type="button" class="add-input btn btn-success"><i class="icon-plus icon-white"></i> Add a new input</button></td>
</tr>
[% END %]
</tbody> </tbody>
</table> </table>
[% END %] [% END %]
<ul class="nav nav-tabs"> <ul class="nav nav-tabs">
[% IF !edit %]
<li class="active"><a href="#tabs-information" data-toggle="tab">Jobset</a></li> <li class="active"><a href="#tabs-information" data-toggle="tab">Jobset</a></li>
[% IF jobset.errormsg %]<li><a href="#tabs-errors" data-toggle="tab"><img src="/static/images/error_16.png" /> Evaluation errors</a></li>[% END %] [% IF jobset.errormsg %]
<li><a href="#tabs-jobs" data-toggle="tab">Jobs ([% activeJobs.size %])</a></li> <li><a href="#tabs-errors" data-toggle="tab"><img src="/static/images/error_16.png" /> Evaluation errors</a></li>
[% END %] [% END %]
<li><a href="#tabs-setup" data-toggle="tab">Setup</a></li> <li><a href="#tabs-jobs" data-toggle="tab">Jobs ([% activeJobs.size %])</a></li>
</ul> <li><a href="#tabs-setup" data-toggle="tab">Configuration</a></li>
</ul>
<div id="generic-tabs" class="tab-content"> <div id="generic-tabs" class="tab-content">
<div id="tabs-information" class="tab-pane active"> <div id="tabs-information" class="tab-pane active">
[% IF !edit && evals.size() > 0 %]
[% IF evals.size() > 0 %]
<h2>Most recent evaluations</h2> <h2>Most recent evaluations</h2>
[% INCLUDE renderEvals linkToAll=c.uri_for(c.controller('Jobset').action_for('evals'), [project.name, jobset.name]) %] [% INCLUDE renderEvals linkToAll=c.uri_for(c.controller('Jobset').action_for('evals'), [project.name, jobset.name]) %]
[% END %] [% END %]
[% IF !edit && activeJobsStatus %]
[% IF activeJobsStatus %]
<h2>Status</h2> <h2>Status</h2>
<table class="table table-striped table-condensed"> <table class="table table-striped table-condensed">
<thead><tr><th>Job</th>[% FOREACH s IN systems %]<th>[% s.system %]</th>[% END %]</tr></thead> <thead><tr><th>Job</th>[% FOREACH s IN systems %]<th>[% s.system %]</th>[% END %]</tr></thead>
@ -105,8 +82,7 @@
[% END %] [% END %]
</tbody> </tbody>
</table> </table>
[% END %] [% ELSE %]
[% IF !edit && !activeJobsStatus %]
<h2>Status</h2> <h2>Status</h2>
<p> <p>
[ <a href="[% c.uri_for('/jobset' project.name jobset.name 'with-status' ) %]">Show status overview</a> ] [ <a href="[% c.uri_for('/jobset' project.name jobset.name 'with-status' ) %]">Show status overview</a> ]
@ -114,7 +90,6 @@
[% END %] [% END %]
</div> </div>
[% IF !edit %]
[% IF jobset.errormsg %] [% IF jobset.errormsg %]
<div id="tabs-errors" class="tab-pane"> <div id="tabs-errors" class="tab-pane">
@ -125,75 +100,54 @@
<pre class="multiLineMsg error">[% HTML.escape(jobset.errormsg) %]</pre> <pre class="multiLineMsg error">[% HTML.escape(jobset.errormsg) %]</pre>
</div> </div>
[% END %] [% END %]
[% END %]
<div id="tabs-setup" class="tab-pane [% IF edit %]active[% END %]"> <div id="tabs-setup" class="tab-pane">
<h2>Information</h2> <h2>Information</h2>
<table class="layoutTable"> <table class="layoutTable">
[% IF edit %]
<tr>
<th>Identifier:</th>
<td>[% INCLUDE maybeEditString param="name" value=jobset.name %]</td>
</tr>
[% END %]
<tr> <tr>
<th>Description:</th> <th>Description:</th>
<td>[% INCLUDE maybeEditString param="description" value=jobset.description %]</td> <td>[% HTML.escape(jobset.description) %]</td>
</tr> </tr>
<tr> <tr>
<th>Nix expression:</th> <th>Nix expression:</th>
<td> <td>
<tt>[% INCLUDE maybeEditString param="nixexprpath" value=jobset.nixexprpath %]</tt> in input <tt>[% HTML.escape(jobset.nixexprpath) %]</tt> in input
<tt>[% INCLUDE maybeEditString param="nixexprinput" value=jobset.nixexprinput %]</tt> <tt>[% HTML.escape(jobset.nixexprinput) %]</tt>
</td> </td>
</tr> </tr>
<tr> <tr>
<th>Enabled:</th> <th>Enabled:</th>
<td> <td>[% jobset.enabled ? "Yes" : "No" %]</td>
[% INCLUDE renderSelection param="enabled" curValue=jobset.enabled radiobuttons=1 options={"1" = "Yes", "0" = "No"} %]
</td>
</tr> </tr>
<tr> <tr>
<th>Enable email notification:</th> <th>Enable email notification:</th>
<td> <td>[% jobset.enableemail ? "Yes" : "No" %]</td>
[% INCLUDE renderSelection param="enableemail" curValue=jobset.enableemail radiobuttons=1 options={"1" = "Yes", "0" = "No"} %]
</td>
</tr> </tr>
<tr> <tr>
<th>Email override:</th> <th>Email override:</th>
<td> <td>[% HTML.escape(jobset.emailoverride) %]</td>
[% INCLUDE maybeEditString param="emailoverride" value=jobset.emailoverride %]
</td>
</tr> </tr>
<tr> <tr>
<th>Number of builds to keep:</th> <th>Number of builds to keep:</th>
<td> <td>[% jobset.keepnr %]</td>
[% INCLUDE maybeEditString param="keepnr" value=jobset.keepnr %]
</td>
</tr> </tr>
[% IF !edit %]
<tr> <tr>
<th>Last checked:</th> <th>Last checked:</th>
<td> <td>
[% IF jobset.lastcheckedtime %] [% IF jobset.lastcheckedtime %]
[% INCLUDE renderDateTime timestamp = jobset.lastcheckedtime %][% IF jobset.errormsg %]<em>, with errors!</em> [% INCLUDE renderDateTime timestamp = jobset.lastcheckedtime %][% IF jobset.errormsg %]<em>, with errors!</em>[% ELSE %], <em>no errors</em>[% END %]
[% ELSE %], <em>no errors</em>
[% END %]
[% ELSE %] [% ELSE %]
<em>never</em> <em>never</em>
[% END %] [% END %]
</td> </td>
</tr> </tr>
[% END %]
</table> </table>
[% INCLUDE renderInputs %] [% INCLUDE renderInputs %]
</div> </div>
[% IF !edit %]
<div id="tabs-jobs" class="tab-pane">
<h2>Jobs</h2> <div id="tabs-jobs" class="tab-pane">
<p>This jobset currently contains the following [% activeJobs.size %] jobs: <p>This jobset currently contains the following [% activeJobs.size %] jobs:
@ -209,51 +163,10 @@
[% IF inactiveJobs.size == 0 %]<em>(none)</em>[% END %] [% IF inactiveJobs.size == 0 %]<em>(none)</em>[% END %]
[% FOREACH j IN inactiveJobs %][% INCLUDE renderJobName project=project.name jobset=jobset.name job=j %]<br/>[% END %] [% FOREACH j IN inactiveJobs %][% INCLUDE renderJobName project=project.name jobset=jobset.name job=j %]<br/>[% END %]
</blockquote> </blockquote>
</p> </p>
</div> </div>
[% END %]
</div> </div>
[% 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>
<div class="form-actions">
<button type="submit" class="btn btn-primary"><i class="icon-ok icon-white"></i> [%IF create %]Create[% ELSE %]Apply changes[% END %]</button>
</div>
</form>
[% END %]
[% END %] [% END %]