summaryrefslogtreecommitdiff
path: root/frontend/repo-create.js
diff options
context:
space:
mode:
Diffstat (limited to 'frontend/repo-create.js')
-rw-r--r--frontend/repo-create.js56
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();
+});