9498: show top-level container requests in project#Pipelines_and_processes tab.
[arvados.git] / apps / workbench / app / assets / javascripts / add_repository.js
1 $(document).on('shown.bs.modal', '#add-repository-modal', function(event) {
2     $('input[type=text]', event.target).val('');
3     $('#add-repository-error', event.target).hide();
4 }).on('submit', '#add-repository-form', function(event) {
5     var $form = $(event.target),
6     $submit = $(':submit', $form),
7     $error = $('#add-repository-error', $form),
8     repo_owner_uuid = $('input[name="add_repo_owner_uuid"]', $form).val(),
9     repo_prefix = $('input[name="add_repo_prefix"]', $form).val(),
10     repo_basename = $('input[name="add_repo_basename"]', $form).val();
11
12     $submit.prop('disabled', true);
13     $error.hide();
14     $.ajax('/repositories',
15            {method: 'POST',
16             dataType: 'json',
17             data: {repository: {owner_uuid: repo_owner_uuid,
18                                 name: repo_prefix + repo_basename}},
19             context: $form}).
20         done(function(data, status, jqxhr) {
21             location.reload();
22         }).
23         fail(function(jqxhr, status, error) {
24             var errlist = jqxhr.responseJSON.errors;
25             var errmsg;
26             if (Array.isArray(errlist)) {
27                 errmsg = errlist.join();
28             } else {
29                 errmsg = ("The server returned an error when making " +
30                           "this repository (status " + jqxhr.status +
31                           ": " + errlist + ").");
32             }
33             $error.text(errmsg);
34             $error.show();
35             $submit.prop('disabled', false);
36         });
37     return false;
38 });