Use the REST API in the web interface for editing jobsets

[?]
Oct 3, 2013, 4:49 PM
TQVKZQUGCFYNH5P56LXMXRXZNTD56MH5T5GX2BMQ5YSRPGHAUYMAC

Dependencies

  • [2] ORIQGBTP Fix jobset update
  • [3] KZRH4VFK Include the email override list in the Jobset serialization
  • [4] ZCTQCN3E Use inputTypes from plugins to determine valid input types
  • [5] GEADFVZ5 hydra-queue-runner: Improved scheduling
  • [6] KYSBJAYN Allow dashes in jobset input names
  • [7] IRRNAEVL Use notFound instead of status_not_found
  • [8] DAPOSS44 Use the REST API in the web interface for editing projects
  • [9] 2G63HKCH Fix some wellformedness issues
  • [10] UWVMQIAC * Refactoring.
  • [11] UMFB2767 Hydra/64: Leaving number of builds empty gives DBIx error
  • [12] 3PNG7NIB Remove trailing whitespace
  • [13] A6XVP6FE Make the hide/unhide actions a checkbox in the project settings
  • [14] LZO3C2KI * Hack around those SQLite timeouts: just retry the transaction.
  • [15] OX6NYJDV Split viewing and editing a jobset
  • [16] VJFLX7B6 Fix rendering of jobset inputs
  • [17] HQGXL4MX Add validation for project and jobset names
  • [18] 75XUS62Y * Added a page to quickly see all failed builds and failed evaluations
  • [19] FPK5LF53 * Put the project-related actions in a separate controller. Put the
  • [20] QTC3SYBM Jobset page: Load the jobs and status tabs on demand
  • [21] JAH3UPWA Support revision control systems via plugins
  • [22] OOQ2D3KC * Refactoring: move fetchInput out of hydra_scheduler into a separate
  • [23] BV7V5RGN Allow only project owners to delete projects / jobsets
  • [24] ODNCGFQ5 * Improved the navigation bar: don't include all projects (since that
  • [25] JARRBLZD Bootstrapify the Hydra forms (except the project and jobset edit pages)
  • [26] 2P7VNAAC Move common Javascript code into a separate file
  • [27] M4TBFHHJ "limit" -> "rows"
  • [28] 4NTIBJ74 Implement DELETE for jobsets and use it in the web interface
  • [29] 6Q2JPSWG Fix lazy tab loading
  • [30] JY7BXXOP Split viewing and editing a project
  • [31] 3HZY24CX * Make jobsets viewable under
  • [32] ZRRPBEI4 Make jobset deletion consistent with project deletion
  • [33] LZVO64YG Merge in the first bits of the API work

Change contents

  • edit in src/lib/Hydra/Controller/Jobset.pm at line 13
    [9.389]
    [9.389]
    $c->stash->{jobsetName} //= $jobsetName;
  • replacement in src/lib/Hydra/Controller/Jobset.pm at line 21
    [9.1][7.115:244]()
    $c->stash->{jobset_} = $project->jobsets->search({'me.name' => $jobsetName});
    my $jobset = $c->stash->{jobset_}->single;
    [9.1]
    [7.244]
    $c->stash->{jobset} = $project->jobsets->find({ name => $jobsetName });
  • replacement in src/lib/Hydra/Controller/Jobset.pm at line 23
    [7.245][7.245:444](),[7.444][9.6555:6572](),[9.6555][9.6555:6572](),[9.6572][7.445:514](),[7.514][9.6922:6932](),[9.6922][9.6922:6932](),[9.7086][9.7086:7092]()
    if ($jobset) {
    $c->stash->{jobset} = $jobset;
    } else {
    if ($c->action->name eq "jobset" and $c->request->method eq "PUT") {
    $c->stash->{jobsetName} = $jobsetName;
    } else {
    notFound($c, "Jobset ‘$jobsetName’ doesn't exist.");
    }
    }
    [7.245]
    [9.699]
    notFound($c, "Jobset ‘$jobsetName’ doesn't exist.")
    if !$c->stash->{jobset} && !($c->action->name eq "jobset" and $c->request->method eq "PUT");
  • replacement in src/lib/Hydra/Controller/Jobset.pm at line 41
    [9.7209][9.7209:7423](),[9.7423][3.0:40](),[3.40][9.7423:7860](),[9.7423][9.7423:7860]()
    $self->status_ok(
    $c,
    entity => $c->stash->{jobset_}->find({}, {
    columns => [
    'me.name',
    'me.project',
    'me.errormsg',
    'me.emailoverride',
    'jobsetinputs.name',
    {
    'jobsetinputs.jobsetinputalts.altnr' => 'jobsetinputalts.altnr',
    'jobsetinputs.jobsetinputalts.value' => 'jobsetinputalts.value'
    }
    ],
    join => { 'jobsetinputs' => 'jobsetinputalts' },
    collapse => 1,
    order_by => "me.name"
    })
    );
    [9.7209]
    [9.293]
    $self->status_ok($c, entity => $c->stash->{jobset});
  • edit in src/lib/Hydra/Controller/Jobset.pm at line 50
    [9.7995][9.7995:8225]()
    error($c, "Cannot rename jobset `$c->stash->{params}->{oldName}' over existing jobset `$c->stash->{jobset}->name") if defined $c->stash->{params}->{oldName} and $c->stash->{params}->{oldName} ne $c->stash->{jobset}->name;
  • edit in src/lib/Hydra/Controller/Jobset.pm at line 53
    [9.8334][9.8334:9683]()
    if ($c->req->looks_like_browser) {
    $c->res->redirect($c->uri_for($self->action_for("jobset"),
    [$c->stash->{project}->name, $c->stash->{jobset}->name]) . "#tabs-configuration");
    } else {
    $self->status_no_content($c);
    }
    } elsif (defined $c->stash->{params}->{oldName}) {
    my $jobset = $c->stash->{project}->jobsets->find({'me.name' => $c->stash->{params}->{oldName}});
    if (defined $jobset) {
    txn_do($c->model('DB')->schema, sub {
    updateJobset($c, $jobset);
    });
    my $uri = $c->uri_for($self->action_for("jobset"), [$c->stash->{project}->name, $jobset->name]);
    if ($c->req->looks_like_browser) {
    $c->res->redirect($uri . "#tabs-configuration");
    } else {
    $self->status_created(
    $c,
    location => "$uri",
    entity => { name => $jobset->name, uri => "$uri", type => "jobset" }
    );
    }
    } else {
    $self->status_not_found(
    $c,
    message => "Jobset $c->stash->{params}->{oldName} doesn't exist."
    );
    }
    } else {
    my $exprType =
    $c->stash->{params}->{"nixexprpath"} =~ /.scm$/ ? "guile" : "nix";
  • replacement in src/lib/Hydra/Controller/Jobset.pm at line 54
    [9.9684][9.9684:9805]()
    error($c, "Invalid jobset name: ‘$c->stash->{jobsetName}’") if $c->stash->{jobsetName} !~ /^$jobsetNameRE$/;
    [9.9684]
    [9.9805]
    my $uri = $c->uri_for($self->action_for("jobset"), [$c->stash->{project}->name, $c->stash->{jobset}->name]) . "#tabs-configuration";
    $self->status_ok($c, entity => { redirect => "$uri" });
    }
  • edit in src/lib/Hydra/Controller/Jobset.pm at line 58
    [9.9806]
    [9.9806]
    else {
  • replacement in src/lib/Hydra/Controller/Jobset.pm at line 64
    [9.10068][9.10068:10180]()
    {name => $c->stash->{jobsetName}, nixexprinput => "", nixexprpath => "", emailoverride => ""});
    [9.10068]
    [9.10180]
    {name => ".tmp", nixexprinput => "", nixexprpath => "", emailoverride => ""});
  • replacement in src/lib/Hydra/Controller/Jobset.pm at line 69
    [9.10337][9.10337:10659]()
    if ($c->req->looks_like_browser) {
    $c->res->redirect($uri . "#tabs-configuration");
    } else {
    $self->status_created(
    $c,
    location => "$uri",
    entity => { name => $jobset->name, uri => "$uri", type => "jobset" }
    );
    }
    [9.10337]
    [9.10659]
    $self->status_created($c,
    location => "$uri",
    entity => { name => $jobset->name, uri => "$uri", redirect => "$uri", type => "jobset" });
  • edit in src/lib/Hydra/Controller/Jobset.pm at line 153
    [5.867][9.705:709](),[9.705][9.705:709](),[9.709][9.10938:10993](),[9.10993][9.759:784](),[9.759][9.759:784](),[9.784][9.14:15](),[9.840][9.840:861](),[9.861][9.0:51](),[9.229][9.16:17](),[9.861][9.16:17](),[9.17][9.11122:11423]()
    }
    sub submit : Chained('jobsetChain') PathPart Args(0) {
    my ($self, $c) = @_;
    requirePost($c);
    requireProjectOwner($c, $c->stash->{project});
    my $newName = trim $c->stash->{params}->{name};
    my $oldName = trim $c->stash->{jobset}->name;
    unless ($oldName eq $newName) {
    $c->stash->{params}->{oldName} = $oldName;
    $c->stash->{jobsetName} = $newName;
    undef $c->stash->{jobset};
    }
    jobset_PUT($self, $c);
  • replacement in src/lib/Hydra/Controller/Jobset.pm at line 161
    [9.11489][9.1048:1142](),[9.1048][9.1048:1142]()
    error($c, "Invalid Nix expression path: $nixExprPath") if $nixExprPath !~ /^$relPathRE$/;
    [9.11489]
    [9.1142]
    error($c, "Invalid Nix expression path ‘$nixExprPath’.") if $nixExprPath !~ /^$relPathRE$/;
  • replacement in src/lib/Hydra/Controller/Jobset.pm at line 164
    [9.11557][6.0:113]()
    error($c, "Invalid Nix expression input name: $nixExprInput") unless $nixExprInput =~ /^[[:alpha:]][\w-]*$/;
    [9.11557]
    [9.1309]
    error($c, "Invalid Nix expression input name ‘$nixExprInput’.") unless $nixExprInput =~ /^[[:alpha:]][\w-]*$/;
  • replacement in src/lib/Hydra/Controller/Jobset.pm at line 173
    [9.2009][9.2009:2059]()
    error($c, "Invalid Boolean value: $value") if
    [9.2009]
    [9.2059]
    error($c, "Invalid Boolean value ‘$value’.") if
  • edit in src/lib/Hydra/Controller/Jobset.pm at line 181
    [9.1513]
    [9.1513]
    my $jobsetName = $c->stash->{params}->{name};
    error($c, "Invalid jobset identifier ‘$jobsetName’.") if $jobsetName !~ /^$jobsetNameRE$/;
  • replacement in src/lib/Hydra/Controller/Jobset.pm at line 185
    [9.1514][2.0:63](),[2.63][9.0:93](),[9.11621][9.0:93](),[9.1571][9.0:93]()
    my $jobsetName = $c->stash->{jobsetName} // $jobset->name;
    error($c, "Invalid jobset name: ‘$jobsetName’") if $jobsetName !~ /^$jobsetNameRE$/;
    [9.1514]
    [9.1667]
    error($c, "Cannot rename jobset to ‘$jobsetName’ since that identifier is already taken.")
    if $jobsetName ne $jobset->name && defined $c->stash->{project}->jobsets->find({ name => $jobsetName });
  • replacement in src/lib/Hydra/Controller/Jobset.pm at line 228
    [9.13038][6.114:210]()
    error($c, "Invalid input name: $inputName") unless $inputName =~ /^[[:alpha:]][\w-]*$/;
    [9.13038]
    [9.2750]
    error($c, "Invalid input name ‘$inputName’.") unless $inputName =~ /^[[:alpha:]][\w-]*$/;
  • replacement in src/lib/Hydra/Controller/Jobset.pm at line 232
    [4.1][4.1:107]()
    error($c, "Invalid input type: $inputType") unless defined $c->stash->{inputTypes}->{$inputType};
    [4.1]
    [9.186]
    error($c, "Invalid input type ‘$inputType’.") unless defined $c->stash->{inputTypes}->{$inputType};
  • replacement in src/lib/Hydra/Controller/Project.pm at line 31
    [7.577][7.577:682]()
    if (!$c->stash->{project} && !($c->action->name eq "project" and $c->request->method eq "PUT"));
    [7.577]
    [9.1753]
    if !$c->stash->{project} && !($c->action->name eq "project" and $c->request->method eq "PUT");
  • edit in src/lib/Hydra/Controller/Project.pm at line 142
    [9.5029][9.5029:5030]()
  • edit in src/lib/Hydra/Controller/Project.pm at line 143
    [9.5031][9.20063:20157](),[9.20157][9.5120:5145](),[9.5120][9.5120:5145]()
    sub create_jobset_submit : Chained('projectChain') PathPart('create-jobset/submit') Args(0) {
    my ($self, $c) = @_;
  • edit in src/lib/Hydra/Controller/Project.pm at line 144
    [9.5146][9.20158:20222](),[9.20222][9.2236:2237](),[9.5197][9.2236:2237](),[9.2237][9.20223:20277](),[9.5771][9.3745:3749](),[9.20277][9.3745:3749](),[9.3745][9.3745:3749]()
    $c->stash->{jobsetName} = trim $c->stash->{params}->{name};
    Hydra::Controller::Jobset::jobset_PUT($self, $c);
    }
  • replacement in src/root/edit-jobset.tt at line 47
    [9.2263][9.2263:2475]()
    <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">
    [9.2263]
    [9.2475]
    <form class="form-horizontal">
  • replacement in src/root/edit-jobset.tt at line 135
    [9.4510][9.4510:4659]()
    <button type="submit" class="btn btn-primary"><i class="icon-ok icon-white"></i> [%IF create %]Create[% ELSE %]Apply changes[% END %]</button>
    [9.4510]
    [9.4659]
    <button id="submit-jobset" type="submit" class="btn btn-primary"><i class="icon-ok icon-white"></i> [%IF create %]Create[% ELSE %]Apply changes[% END %]</button>
  • replacement in src/root/edit-jobset.tt at line 148
    [9.4934][9.4934:5021]()
    <script type="text/javascript">
    $(document).ready(function() {
    var id = 0;
    [9.4934]
    [9.5021]
    </form>
  • replacement in src/root/edit-jobset.tt at line 150
    [9.5022][9.5022:5427]()
    $(".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;
    });
    [9.5022]
    [9.5427]
    <script type="text/javascript">
    $(document).ready(function() {
    var id = 0;
  • replacement in src/root/edit-jobset.tt at line 154
    [9.5428][9.5428:5663]()
    $(".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");
    });
    [9.5428]
    [9.5663]
    $(".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;
  • replacement in src/root/edit-jobset.tt at line 162
    [9.5671][9.5671:5683]()
    </script>
    [9.5671]
    [9.5683]
    $(".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");
    });
    });
  • replacement in src/root/edit-jobset.tt at line 169
    [9.5684][9.5684:5692]()
    </form>
    [9.5684]
    [9.5692]
    $("#submit-jobset").click(function() {
    requestJSON({
    [% IF create %]
    url: "[% c.uri_for('/jobset' project.name '.new') %]",
    [% ELSE %]
    url: "[% c.uri_for('/jobset' project.name jobset.name) %]",
    [% END %]
    data: $(this).parents("form").serialize(),
    type: 'PUT',
    success: function(data) {
    window.location = data.redirect;
    },
    });
    return false;
    });
    </script>
  • edit in src/root/edit-project.tt at line 60
    [9.2553][9.2553:2593](),[9.2593][8.1209:1720](),[8.1720][9.2720:2752](),[9.2720][9.2720:2752]()
    <script type="text/javascript">
    $("#submit-project").click(function() {
    requestJSON({
    [% IF create %]
    url: "[% c.uri_for('/project' '.new') %]",
    [% ELSE %]
    url: "[% c.uri_for('/project' project.name) %]",
    [% END %]
    data: $(this).parents("form").serialize(),
    type: 'PUT',
    success: function(data) {
    window.location = data.redirect;
    },
    });
    return false;
    });
    </script>
  • edit in src/root/edit-project.tt at line 66
    [9.2107]
    [9.2107]
    <script type="text/javascript">
    $("#submit-project").click(function() {
    requestJSON({
    [% IF create %]
    url: "[% c.uri_for('/project' '.new') %]",
    [% ELSE %]
    url: "[% c.uri_for('/project' project.name) %]",
    [% END %]
    data: $(this).parents("form").serialize(),
    type: 'PUT',
    success: function(data) {
    window.location = data.redirect;
    },
    });
    return false;
    });
    </script>
  • edit in src/root/edit-project.tt at line 85
    [9.2108]
    [9.2108]
  • replacement in src/root/static/js/common.js at line 77
    [9.90][9.90:133]()
    var makeLazyTab = function(tabName, uri) {
    [9.90]
    [9.133]
    function makeLazyTab(tabName, uri) {
  • replacement in src/root/static/js/common.js at line 90
    [9.642][8.2294:2296]()
    }
    [9.642]
    [8.2296]
    };
  • replacement in src/root/static/js/common.js at line 92
    [8.2297][8.2297:2332]()
    var requestJSON = function(args) {
    [8.2297]
    [8.2332]
    function escapeHTML(s) {
    return $('<div/>').text(s).html();
    };
    function requestJSON(args) {
  • replacement in src/root/static/js/common.js at line 106
    [8.2575][8.2575:2614]()
    bootbox.alert(json.error);
    [8.2575]
    [8.2614]
    bootbox.alert(escapeHTML(json.error));
  • replacement in src/root/static/js/common.js at line 108
    [8.2650][8.2650:2715]()
    bootbox.alert("Server error: " + data.responseText);
    [8.2650]
    [8.2715]
    bootbox.alert("Server error: " + escapeHTML(data.responseText));
  • replacement in src/root/static/js/common.js at line 113
    [8.2812][9.642:644](),[9.642][9.642:644]()
    }
    [8.2812]
    [8.2813]
    };
  • replacement in src/root/static/js/common.js at line 115
    [8.2814][8.2814:2850]()
    var redirectJSON = function(args) {
    [8.2814]
    [8.2850]
    function redirectJSON(args) {
  • replacement in src/root/static/js/common.js at line 120
    [8.2964][8.2964:2966]()
    }
    [8.2964]
    };