From 366f705642808a6fe14fd30138519c0ac75e0fdf Mon Sep 17 00:00:00 2001 From: Christian Franke Date: Sun, 23 Jun 2013 02:29:08 +0200 Subject: Initial commit of repo_service --- frontend/repo-create.js | 56 +++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 56 insertions(+) create mode 100644 frontend/repo-create.js (limited to 'frontend/repo-create.js') 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(); +}); -- cgit v1.2.1