* Editing of jobset inputs.

This commit is contained in:
Eelco Dolstra 2008-11-17 11:44:51 +00:00
parent 66f752beaf
commit 2650094643
17 changed files with 133 additions and 70 deletions

View file

@ -88,16 +88,17 @@ sub updateProject {
$jobsetNames{$jobsetName} = 1;
my $jobset;
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
$jobset = $project->jobsets->create(
{ 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});
$jobset = ($project->jobsets->search({name => $baseName}))[0];
die unless defined $jobset;
$jobset->name($jobsetName);
$jobset->description($c->request->params->{"jobset-$baseName-description"});
@ -105,6 +106,43 @@ sub updateProject {
$jobset->nixexprinput($nixExprInput);
$jobset->update;
}
# 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 = $c->request->params->{"jobset-$baseName-input-$baseName2-name"};
die "Invalid input name: $inputName" unless $inputName =~ /^[[:alpha:]]\w*$/;
my $inputType = $c->request->params->{"jobset-$baseName-input-$baseName2-type"};
die "Invalid input type: $inputType" unless
$inputType eq "svn" || $inputType eq "cvs" || $inputType eq "tarball" ||
$inputType eq "string" || $inputType eq "path";
my $input;
if ($baseName2 =~ /^\d+$/) { # numeric base name is auto-generated, i.e. a new entry
} else { # it's an existing jobset
$input = ($jobset->jobsetinputs->search({name => $baseName2}))[0];
die unless defined $input;
$input->name($inputName);
$input->type($inputType);
$input->update;
}
# 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 = [$values] unless ref($values) eq 'ARRAY';
my $altnr = 0;
foreach my $value (@{$values}) {
print STDERR "VALUE: $value\n";
$input->jobsetinputalts->create({altnr => $altnr++, value => $value});
}
}
}
# Get rid of deleted jobsets, i.e., ones that are no longer submitted in the parameters.

View file

@ -8,8 +8,8 @@ use base 'DBIx::Class::Schema';
__PACKAGE__->load_classes;
# Created by DBIx::Class::Schema::Loader v0.04005 @ 2008-11-13 00:41:19
# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:UDG/z2SeOSq/K7iVpzF0mw
# Created by DBIx::Class::Schema::Loader v0.04005 @ 2008-11-17 12:36:40
# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:KEl9aBHuDTOb+pkc2Wde0A
# You can replace this text with custom content, and it will be preserved on regeneration

View file

@ -40,8 +40,8 @@ __PACKAGE__->belongs_to(
);
# Created by DBIx::Class::Schema::Loader v0.04005 @ 2008-11-13 00:41:19
# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:fClAPzHpXV7YT8eHUeU4zw
# Created by DBIx::Class::Schema::Loader v0.04005 @ 2008-11-17 12:36:40
# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:wkxzzlIrlNAnzUlBQMkx/A
# You can replace this text with custom content, and it will be preserved on regeneration

View file

@ -21,8 +21,8 @@ __PACKAGE__->set_primary_key("build", "logphase");
__PACKAGE__->belongs_to("build", "HydraFrontend::Schema::Builds", { id => "build" });
# Created by DBIx::Class::Schema::Loader v0.04005 @ 2008-11-13 00:41:19
# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:lW6yq7QOyzpa+zM/J/7VFQ
# Created by DBIx::Class::Schema::Loader v0.04005 @ 2008-11-17 12:36:40
# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:q7krNxyxcF4PlLGT8dmkLQ
# You can replace this text with custom content, and it will be preserved on regeneration

View file

@ -33,8 +33,8 @@ __PACKAGE__->set_primary_key("build", "productnr");
__PACKAGE__->belongs_to("build", "HydraFrontend::Schema::Builds", { id => "build" });
# Created by DBIx::Class::Schema::Loader v0.04005 @ 2008-11-13 00:41:19
# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:2qyh04FF7LrOgo+/Ixap2A
# Created by DBIx::Class::Schema::Loader v0.04005 @ 2008-11-17 12:36:40
# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:60iPYEFvRtct6aHFChM8Eg
# You can replace this text with custom content, and it will be preserved on regeneration

View file

@ -25,8 +25,8 @@ __PACKAGE__->set_primary_key("id");
__PACKAGE__->belongs_to("id", "HydraFrontend::Schema::Builds", { id => "id" });
# Created by DBIx::Class::Schema::Loader v0.04005 @ 2008-11-13 00:41:19
# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:ko+bQKdwDzow15p/aTdgYw
# Created by DBIx::Class::Schema::Loader v0.04005 @ 2008-11-17 12:36:40
# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:twJAkSC32lJGcGItKegomg
# You can replace this text with custom content, and it will be preserved on regeneration

View file

@ -79,8 +79,8 @@ __PACKAGE__->has_many(
);
# Created by DBIx::Class::Schema::Loader v0.04005 @ 2008-11-13 00:41:19
# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:9VXVDomeYpjysKc8NxWogw
# Created by DBIx::Class::Schema::Loader v0.04005 @ 2008-11-17 12:36:40
# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:kTvNLSNfUxIbzFQ82v+AHg
__PACKAGE__->has_many(dependents => 'HydraFrontend::Schema::Buildinputs', 'dependency');

View file

@ -23,8 +23,8 @@ __PACKAGE__->set_primary_key("id");
__PACKAGE__->belongs_to("id", "HydraFrontend::Schema::Builds", { id => "id" });
# Created by DBIx::Class::Schema::Loader v0.04005 @ 2008-11-13 00:41:19
# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:v2j9A4bXqe96Qy1zz/C+VQ
# Created by DBIx::Class::Schema::Loader v0.04005 @ 2008-11-17 12:36:40
# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:a9oTOE0Aw1nHAamSOf+AVw
# You can replace this text with custom content, and it will be preserved on regeneration

View file

@ -35,8 +35,8 @@ __PACKAGE__->set_primary_key("id", "stepnr");
__PACKAGE__->belongs_to("id", "HydraFrontend::Schema::Builds", { id => "id" });
# Created by DBIx::Class::Schema::Loader v0.04005 @ 2008-11-13 00:41:19
# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:tCirOuLYfhBxoEkH5HAQlQ
# Created by DBIx::Class::Schema::Loader v0.04005 @ 2008-11-17 12:36:40
# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:8JPNCq31oRo9w3tQGPpwMw
# You can replace this text with custom content, and it will be preserved on regeneration

View file

@ -16,14 +16,12 @@ __PACKAGE__->add_columns(
{ data_type => "text", is_nullable => 0, size => undef },
"altnr",
{ data_type => "integer", is_nullable => 0, size => undef },
"uri",
"value",
{ data_type => "text", is_nullable => 0, size => undef },
"revision",
{ data_type => "integer", is_nullable => 0, size => undef },
"tag",
{ data_type => "text", is_nullable => 0, size => undef },
"value",
{ data_type => "text", is_nullable => 0, size => undef },
);
__PACKAGE__->set_primary_key("project", "jobset", "input", "altnr");
__PACKAGE__->belongs_to(
@ -33,8 +31,8 @@ __PACKAGE__->belongs_to(
);
# Created by DBIx::Class::Schema::Loader v0.04005 @ 2008-11-13 00:41:19
# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:GgHinSVpD7x20xFqfvau0Q
# Created by DBIx::Class::Schema::Loader v0.04005 @ 2008-11-17 12:36:40
# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:EVQbKQiSBV7xXLVym+lUxQ
# You can replace this text with custom content, and it will be preserved on regeneration

View file

@ -43,8 +43,8 @@ __PACKAGE__->has_many(
);
# Created by DBIx::Class::Schema::Loader v0.04005 @ 2008-11-13 00:41:19
# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:F9AunJfDCrzuCOBHjNaurw
# Created by DBIx::Class::Schema::Loader v0.04005 @ 2008-11-17 12:36:40
# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:DcDEOgQY24GPqdhDlleLsQ
# You can replace this text with custom content, and it will be preserved on regeneration

View file

@ -48,8 +48,8 @@ __PACKAGE__->has_many(
);
# Created by DBIx::Class::Schema::Loader v0.04005 @ 2008-11-13 00:41:19
# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:oQnTi5ALlqDF0gP9P/hTeg
# Created by DBIx::Class::Schema::Loader v0.04005 @ 2008-11-17 12:36:40
# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:nsVTqxR1wQaamEpy5nNOTQ
# You can replace this text with custom content, and it will be preserved on regeneration

View file

@ -28,8 +28,8 @@ __PACKAGE__->has_many(
);
# Created by DBIx::Class::Schema::Loader v0.04005 @ 2008-11-13 00:41:19
# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:z7XJulBG7643ilgAj1hDwg
# Created by DBIx::Class::Schema::Loader v0.04005 @ 2008-11-17 12:36:40
# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:TNoQBA0pY/OwfunCJ+/9Gw
# You can replace this text with custom content, and it will be preserved on regeneration

View file

@ -1,5 +1,4 @@
body
{
body {
font-family: sans-serif;
background: white;
margin: 2em 1em 2em 1em;
@ -361,3 +360,7 @@ input.string {
background-color: #fffff0;
width: 30em;
}
input.shortString {
width: 10em;
}

View file

@ -4,13 +4,29 @@
[% BLOCK maybeEditString %]
[% IF edit %]
<input type="text" class="string" [% HTML.attributes(id => param, name => param, value => value) %] />
<input type="text" class="string [% extraClass %]" [% HTML.attributes(id => param, name => param, value => value) %] />
[% ELSE %]
[% HTML.escape(value) %]
[% END %]
[% END %]
[% BLOCK renderInputType %]
[% SWITCH type %]
[% CASE "svn" %]Subversion checkout
[% CASE "cvs" %]CVS checkout
[% CASE "tarball" %]Download of a tarball
[% CASE "string" %]String value
[% CASE "path" %]Local path
[% END %]
[% END %]
[% BLOCK renderInputTypeOption %]
<option value="[% type %]" [% IF value == type %]selected="selected"[%END %]>[% INCLUDE renderInputType %]</option>
[% END %]
[% BLOCK renderJobset %]
<div class="jobset[% IF edit %] jobset-edit[% END %]">
@ -33,8 +49,8 @@
<tr>
<th>Nix expression:</th>
<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>
<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>
</table>
@ -48,34 +64,29 @@
<tbody>
[% FOREACH input IN jobset.jobsetinputs -%]
<tr>
<td><tt>[% INCLUDE maybeEditString value=input.name %]</tt></td>
<td><tt>
<td><tt>[% INCLUDE maybeEditString param="jobset-$baseName-input-$input.name-name" value=input.name extraClass="shortString" %]</tt></td>
<td>
[% IF edit %]
<select>
<option>svn</option>
<option>cvs</option>
<option>uri</option>
<option>string</option>
<option>path</option>
<select name="[% "jobset-$baseName-input-$input.name-type" %]">
[% INCLUDE renderInputTypeOption value=input.type type="svn" %]
[% INCLUDE renderInputTypeOption value=input.type type="cvs" %]
[% INCLUDE renderInputTypeOption value=input.type type="tarball" %]
[% INCLUDE renderInputTypeOption value=input.type type="string" %]
[% INCLUDE renderInputTypeOption value=input.type type="path" %]
</select>
[% ELSE %]
[% input.type %]
[% INCLUDE renderInputType type=input.type %]
[% END %]
</tt></td>
</td>
<td>
[% FOREACH alt IN input.jobsetinputalts -%]
[% IF input.type == "string" %]
<tt>
[% IF edit %]
<input type='text' class='string' value='[% alt.value %]' />
<br />
[% ELSE %]
"[% alt.value %]"
[% END %]
</tt>
[% ELSE %]
<tt>[% INCLUDE maybeEditString value=alt.uri %]</tt>
[% END %]
<tt>
[% IF input.type == "string" && !edit %]
"[% HTML.escape(alt.value) %]"
[% ELSE %]
[% INCLUDE maybeEditString param="jobset-$baseName-input-$input.name-values" value=alt.value %]
[% END %]
</tt>
[% END %]
</td>
</tr>
@ -140,7 +151,7 @@
$("#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", "trunk");
$("#jobset-template-name", $("#" + newid)).attr("name", newid + "-name");
$("#jobset-template-description", $("#" + newid)).attr("name", newid + "-description");
$("#jobset-template-nixexprpath", $("#" + newid)).attr("name", newid + "-nixexprpath");
$("#jobset-template-nixexprinput", $("#" + newid)).attr("name", newid + "-nixexprinput");

View file

@ -138,7 +138,7 @@ create table BuildLogs (
-- Emulate "on delete cascade" foreign key constraints.
create trigger cascadeBuildDeletion
before delete on builds
before delete on Builds
for each row begin
delete from BuildSchedulingInfo where id = old.id;
delete from BuildResultInfo where id = old.id;
@ -181,11 +181,11 @@ create table Jobsets (
create trigger cascadeJobsetUpdate
update of name on jobsets
update of name on Jobsets
for each row begin
update JobsetInputs set jobset = new.name where jobset = old.name;
update JobsetInputAlts set jobset = new.name where jobset = old.name;
update Builds set jobset = new.name where jobset = old.name;
update JobsetInputs set jobset = new.name where project = old.project and jobset = old.name;
update JobsetInputAlts set jobset = new.name where project = old.project and jobset = old.name;
update Builds set jobset = new.name where project = old.project and jobset = old.name;
end;
@ -199,17 +199,30 @@ create table JobsetInputs (
);
create trigger cascadeJobsetInputUpdate
update of name on JobsetInputs
for each row begin
update JobsetInputAlts set input = new.name where project = old.project and jobset = old.jobset and input = old.name;
end;
create trigger cascadeJobsetInputDelete
before delete on JobsetInputs
for each row begin
delete from JobsetInputAlts where project = old.project and jobset = old.jobset and input = old.name;
end;
create table JobsetInputAlts (
project text not null,
jobset text not null,
input text not null,
altnr integer,
altnr integer not null,
-- urgh
uri text,
value text, -- for most types, a URI; for 'path', an absolute path; for 'string', an arbitrary value
revision integer, -- for type == 'svn'
tag text, -- for type == 'cvs'
value text, -- for type == 'string'
primary key (project, jobset, input, altnr),
foreign key (project, jobset, input) references JobsetInputs(project, jobset, name) on delete cascade -- ignored by sqlite

View file

@ -1,11 +1,11 @@
insert into projects(name, displayName, description) values('patchelf', 'PatchELF', 'A tool for modifying ELF binaries');
insert into jobSets(project, name, description, nixExprInput, nixExprPath) values('patchelf', 'trunk', 'PatchELF trunk', 'patchelfSrc', 'release.nix');
insert into jobSetInputs(project, jobset, name, type) values('patchelf', 'trunk', 'patchelfSrc', 'path');
insert into jobSetInputAlts(project, jobset, input, altnr, uri) values('patchelf', 'trunk', 'patchelfSrc', 0, '/home/eelco/Dev/patchelf-wc');
insert into jobSetInputAlts(project, jobset, input, altnr, value) values('patchelf', 'trunk', 'patchelfSrc', 0, '/home/eelco/Dev/patchelf-wc');
insert into jobSetInputs(project, jobset, name, type) values('patchelf', 'trunk', 'nixpkgs', 'path');
insert into jobSetInputAlts(project, jobset, input, altnr, uri) values('patchelf', 'trunk', 'nixpkgs', 0, '/home/eelco/Dev/nixpkgs-wc');
insert into jobSetInputAlts(project, jobset, input, altnr, value) values('patchelf', 'trunk', 'nixpkgs', 0, '/home/eelco/Dev/nixpkgs-wc');
insert into jobSetInputs(project, jobset, name, type) values('patchelf', 'trunk', 'release', 'path');
insert into jobSetInputAlts(project, jobset, input, altnr, uri) values('patchelf', 'trunk', 'release', 0, '/home/eelco/Dev/release');
insert into jobSetInputAlts(project, jobset, input, altnr, value) values('patchelf', 'trunk', 'release', 0, '/home/eelco/Dev/release');
insert into jobSetInputs(project, jobset, name, type) values('patchelf', 'trunk', 'system', 'string');
insert into jobSetInputAlts(project, jobset, input, altnr, value) values('patchelf', 'trunk', 'system', 0, 'i686-linux');
insert into jobSetInputAlts(project, jobset, input, altnr, value) values('patchelf', 'trunk', 'system', 1, 'x86_64-linux');