diff --git a/src/HydraFrontend/lib/HydraFrontend/Controller/Root.pm b/src/HydraFrontend/lib/HydraFrontend/Controller/Root.pm index 4fff69be..826c3918 100644 --- a/src/HydraFrontend/lib/HydraFrontend/Controller/Root.pm +++ b/src/HydraFrontend/lib/HydraFrontend/Controller/Root.pm @@ -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. diff --git a/src/HydraFrontend/lib/HydraFrontend/Schema.pm b/src/HydraFrontend/lib/HydraFrontend/Schema.pm index 4752c1fb..8485c5a3 100644 --- a/src/HydraFrontend/lib/HydraFrontend/Schema.pm +++ b/src/HydraFrontend/lib/HydraFrontend/Schema.pm @@ -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 diff --git a/src/HydraFrontend/lib/HydraFrontend/Schema/Buildinputs.pm b/src/HydraFrontend/lib/HydraFrontend/Schema/Buildinputs.pm index 80afec46..65bad866 100644 --- a/src/HydraFrontend/lib/HydraFrontend/Schema/Buildinputs.pm +++ b/src/HydraFrontend/lib/HydraFrontend/Schema/Buildinputs.pm @@ -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 diff --git a/src/HydraFrontend/lib/HydraFrontend/Schema/Buildlogs.pm b/src/HydraFrontend/lib/HydraFrontend/Schema/Buildlogs.pm index 9e6700ee..4767ff8e 100644 --- a/src/HydraFrontend/lib/HydraFrontend/Schema/Buildlogs.pm +++ b/src/HydraFrontend/lib/HydraFrontend/Schema/Buildlogs.pm @@ -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 diff --git a/src/HydraFrontend/lib/HydraFrontend/Schema/Buildproducts.pm b/src/HydraFrontend/lib/HydraFrontend/Schema/Buildproducts.pm index d455bc94..3e33bcf2 100644 --- a/src/HydraFrontend/lib/HydraFrontend/Schema/Buildproducts.pm +++ b/src/HydraFrontend/lib/HydraFrontend/Schema/Buildproducts.pm @@ -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 diff --git a/src/HydraFrontend/lib/HydraFrontend/Schema/Buildresultinfo.pm b/src/HydraFrontend/lib/HydraFrontend/Schema/Buildresultinfo.pm index 2662fe47..031e5d12 100644 --- a/src/HydraFrontend/lib/HydraFrontend/Schema/Buildresultinfo.pm +++ b/src/HydraFrontend/lib/HydraFrontend/Schema/Buildresultinfo.pm @@ -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 diff --git a/src/HydraFrontend/lib/HydraFrontend/Schema/Builds.pm b/src/HydraFrontend/lib/HydraFrontend/Schema/Builds.pm index fe9dabe2..b4520229 100644 --- a/src/HydraFrontend/lib/HydraFrontend/Schema/Builds.pm +++ b/src/HydraFrontend/lib/HydraFrontend/Schema/Builds.pm @@ -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'); diff --git a/src/HydraFrontend/lib/HydraFrontend/Schema/Buildschedulinginfo.pm b/src/HydraFrontend/lib/HydraFrontend/Schema/Buildschedulinginfo.pm index 909e337c..7fda16a5 100644 --- a/src/HydraFrontend/lib/HydraFrontend/Schema/Buildschedulinginfo.pm +++ b/src/HydraFrontend/lib/HydraFrontend/Schema/Buildschedulinginfo.pm @@ -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 diff --git a/src/HydraFrontend/lib/HydraFrontend/Schema/Buildsteps.pm b/src/HydraFrontend/lib/HydraFrontend/Schema/Buildsteps.pm index 2f787b6b..9b3cab72 100644 --- a/src/HydraFrontend/lib/HydraFrontend/Schema/Buildsteps.pm +++ b/src/HydraFrontend/lib/HydraFrontend/Schema/Buildsteps.pm @@ -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 diff --git a/src/HydraFrontend/lib/HydraFrontend/Schema/Jobsetinputalts.pm b/src/HydraFrontend/lib/HydraFrontend/Schema/Jobsetinputalts.pm index 80031258..6653ee41 100644 --- a/src/HydraFrontend/lib/HydraFrontend/Schema/Jobsetinputalts.pm +++ b/src/HydraFrontend/lib/HydraFrontend/Schema/Jobsetinputalts.pm @@ -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 diff --git a/src/HydraFrontend/lib/HydraFrontend/Schema/Jobsetinputs.pm b/src/HydraFrontend/lib/HydraFrontend/Schema/Jobsetinputs.pm index 409675f1..0e643ff8 100644 --- a/src/HydraFrontend/lib/HydraFrontend/Schema/Jobsetinputs.pm +++ b/src/HydraFrontend/lib/HydraFrontend/Schema/Jobsetinputs.pm @@ -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 diff --git a/src/HydraFrontend/lib/HydraFrontend/Schema/Jobsets.pm b/src/HydraFrontend/lib/HydraFrontend/Schema/Jobsets.pm index 2ffc0533..fc7bb8f7 100644 --- a/src/HydraFrontend/lib/HydraFrontend/Schema/Jobsets.pm +++ b/src/HydraFrontend/lib/HydraFrontend/Schema/Jobsets.pm @@ -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 diff --git a/src/HydraFrontend/lib/HydraFrontend/Schema/Projects.pm b/src/HydraFrontend/lib/HydraFrontend/Schema/Projects.pm index 36ac294e..2e59a536 100644 --- a/src/HydraFrontend/lib/HydraFrontend/Schema/Projects.pm +++ b/src/HydraFrontend/lib/HydraFrontend/Schema/Projects.pm @@ -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 diff --git a/src/HydraFrontend/root/hydra.css b/src/HydraFrontend/root/hydra.css index 23148282..2bd1a535 100644 --- a/src/HydraFrontend/root/hydra.css +++ b/src/HydraFrontend/root/hydra.css @@ -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; +} diff --git a/src/HydraFrontend/root/project.tt b/src/HydraFrontend/root/project.tt index 6d71f163..687c98d7 100644 --- a/src/HydraFrontend/root/project.tt +++ b/src/HydraFrontend/root/project.tt @@ -4,13 +4,29 @@ [% BLOCK maybeEditString %] [% IF edit %] - param, name => param, value => value) %] /> + 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 %] + +[% END %] + + [% BLOCK renderJobset %]
@@ -33,8 +49,8 @@ Nix expression: - [% INCLUDE maybeEditString param="jobset-$baseName-nixexprpath" value=jobset.nixexprpath %] in input - [% INCLUDE maybeEditString param="jobset-$baseName-nixexprinput" value=jobset.nixexprinput %] + [% INCLUDE maybeEditString param="jobset-$baseName-nixexprpath" value=jobset.nixexprpath extraClass="shortString" %] in input + [% INCLUDE maybeEditString param="jobset-$baseName-nixexprinput" value=jobset.nixexprinput extraClass="shortString" %] @@ -48,34 +64,29 @@ [% FOREACH input IN jobset.jobsetinputs -%] - [% INCLUDE maybeEditString value=input.name %] - + [% INCLUDE maybeEditString param="jobset-$baseName-input-$input.name-name" value=input.name extraClass="shortString" %] + [% IF edit %] - + [% 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" %] [% ELSE %] - [% input.type %] + [% INCLUDE renderInputType type=input.type %] [% END %] - + [% FOREACH alt IN input.jobsetinputalts -%] - [% IF input.type == "string" %] - - [% IF edit %] - -
- [% ELSE %] - "[% alt.value %]" - [% END %] -
- [% ELSE %] - [% INCLUDE maybeEditString value=alt.uri %] - [% END %] + + [% IF input.type == "string" && !edit %] + "[% HTML.escape(alt.value) %]" + [% ELSE %] + [% INCLUDE maybeEditString param="jobset-$baseName-input-$input.name-values" value=alt.value %] + [% END %] + [% END %] @@ -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"); diff --git a/src/hydra.sql b/src/hydra.sql index 3b406f48..58eca6bc 100644 --- a/src/hydra.sql +++ b/src/hydra.sql @@ -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 diff --git a/src/test.sql b/src/test.sql index 8c7ad093..aaabc823 100644 --- a/src/test.sql +++ b/src/test.sql @@ -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');