diff options
author | Christian Franke <nobody@nowhere.ws> | 2013-06-23 02:29:08 +0200 |
---|---|---|
committer | Christian Franke <nobody@nowhere.ws> | 2013-06-23 02:29:08 +0200 |
commit | 366f705642808a6fe14fd30138519c0ac75e0fdf (patch) | |
tree | 0fdad5aacb09ba3df2991ff853b43f08b3ccb57c /frontend/repo-create.js |
Initial commit of repo_service
Diffstat (limited to 'frontend/repo-create.js')
-rw-r--r-- | frontend/repo-create.js | 56 |
1 files changed, 56 insertions, 0 deletions
diff --git a/frontend/repo-create.js b/frontend/repo-create.js new file mode 100644 index 0000000..e2744be --- /dev/null +++ b/frontend/repo-create.js @@ -0,0 +1,56 @@ +$(function () { + $('#the_form').submit(function() { + var repo_name; + $('#message').hide(); + $('#submit')[0].disabled = true; + $('#spinner').show(); + + repo_name = this["name"].value; + $.xmlrpc({ + url: 'api', + methodName: 'create_repo', + params: [ + 'sublab', + repo_name, + this["description"].value + ], + + success: function(response, status, jqXHR) { + var error; + + $('#spinner').hide(); + $('#submit')[0].disabled = false; + + if (response != 'SUCCESS') { + error = 'Unknown error ' + response + if (response == 'ERROR_NAME') + error = 'Invalid name'; + if (response == 'ERROR_DESC') + error = 'Invalid description'; + if (response == 'ERROR_EXISTS') + error = 'Repository does already exist'; + if (response == 'ERROR_GITOLIE') + error = 'Couldn\'t change gitolite config'; + if (response == 'ERROR_CGIT') + error = 'Couldn\'t change cgit config'; + $('#message').text('Error creating repository: ' + + error).show(); + return; + } + + $('#the_form').hide(400); + $('#message').text('Repository created successfuly. You will' + + ' be redirected shortly.').show(); + setTimeout(function() { + window.location.href = 'https://git.sublab.org/' + repo_name + '/'; + }, 3000); + }, + error: function(jqXHR, status, error) { + $('#message').text('Coulnd\'t create Repo: ' + error); + } + }); + return false; + }); + $('#message').hide(); + $('#the_form').show(); +}); |