diff --git a/src/HydraFrontend/lib/HydraFrontend/Controller/Root.pm b/src/HydraFrontend/lib/HydraFrontend/Controller/Root.pm index 14356877..42682d4c 100644 --- a/src/HydraFrontend/lib/HydraFrontend/Controller/Root.pm +++ b/src/HydraFrontend/lib/HydraFrontend/Controller/Root.pm @@ -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}; + } } diff --git a/src/HydraFrontend/root/hydra.css b/src/HydraFrontend/root/hydra.css index 2f3f5d89..f6187731 100644 --- a/src/HydraFrontend/root/hydra.css +++ b/src/HydraFrontend/root/hydra.css @@ -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 */ diff --git a/src/HydraFrontend/root/project.tt b/src/HydraFrontend/root/project.tt index 38b4b3c5..569e43d1 100644 --- a/src/HydraFrontend/root/project.tt +++ b/src/HydraFrontend/root/project.tt @@ -4,69 +4,34 @@ [% BLOCK maybeEditString %] [% IF edit %] - param, value => value) %] /> + param, name => param, value => value) %] /> [% ELSE %] [% HTML.escape(value) %] [% END %] [% END %] -[% IF edit %] -
- + [% IF !create %] + + + + + [% END %] + [% END %]