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 %] -
-[% END %] +[% BLOCK renderJobset %] +
-[% IF create %] -

New Project

-[% ELSE %] -

Project [% curProject.name %]

-[% END %] +

Jobset [% INCLUDE maybeEditString param="jobset-$baseName-name" value=jobset.name %]

- -

General information

- - - [% IF edit %] - - - - - [% END %] - - - - - - - - -
Identifier:[% INCLUDE maybeEditString param="name" value=curProject.name %]
Display name:[% INCLUDE maybeEditString param="displayname" value=curProject.displayname %]
Description:[% INCLUDE maybeEditString param="description" value=curProject.description %]
- - -

Definition

- -[% IF curProject.jobsets.size > 0 %] - -[% FOREACH jobset IN curProject.jobsets -%] - -

Jobset [% jobset.name %]

+

Information

- [% IF edit %] - - - - - [% END %] - + - +
Identifier:[% INCLUDE maybeEditString value=jobset.name %]
Description:[% INCLUDE maybeEditString value=jobset.description %][% INCLUDE maybeEditString param="jobset-$baseName-description" value=jobset.description %]
Nix expression:[% INCLUDE maybeEditString value=jobset.nixexprpath %] in input [% INCLUDE maybeEditString value=jobset.nixexprinput %] + [% INCLUDE maybeEditString param="jobset-$baseName-nixexprpath" value=jobset.nixexprpath %] in input + [% INCLUDE maybeEditString param="jobset-$baseName-nixexprinput" value=jobset.nixexprinput %] +
@@ -114,7 +79,76 @@ -[% END -%] + [% IF edit %] +

+ [% END %] + +
+
+ +[% END %] + + +[% IF edit %] + +[% END %] + + +[% IF create %] +

New Project

+[% ELSE %] +

Project [% curProject.name %]

+[% END %] + + +

General information

+ + + [% IF edit %] + + + + + [% END %] + + + + + + + + +
Identifier:[% INCLUDE maybeEditString param="name" value=curProject.name %]
Display name:[% INCLUDE maybeEditString param="displayname" value=curProject.displayname %]
Description:[% INCLUDE maybeEditString param="description" value=curProject.description %]
+ + +

Jobsets

+ +[% IF curProject.jobsets && curProject.jobsets.size > 0 || edit %] + + [% IF edit %] +

+ +
+ [% INCLUDE renderJobset jobset="" baseName="template" %] +
+ + + [% END %] + + [% FOREACH jobset IN curProject.jobsets -%] + [% INCLUDE renderJobset jobset=jobset baseName=jobset.name %] + [% END -%] [% ELSE %] @@ -128,7 +162,7 @@

Jobs

-[% IF jobNames.size > 0 %] +[% IF jobName && jobNames.size > 0 %]