From 2d43ba507cbf7350e2416d727c121a257defe83a Mon Sep 17 00:00:00 2001 From: Brad Rydzewski Date: Mon, 14 Jul 2014 00:00:04 -0700 Subject: [PATCH] settings page now display configured remotes --- server/app/scripts/app.js | 23 +---- server/app/scripts/controllers/conf.js | 39 +++++++++ server/app/scripts/controllers/home.js | 1 - server/app/views/config.html | 51 +++++++++++ server/app/views/repo.html | 2 +- server/app/views/sys_config.html | 112 ------------------------- 6 files changed, 92 insertions(+), 136 deletions(-) create mode 100644 server/app/views/config.html delete mode 100644 server/app/views/sys_config.html diff --git a/server/app/scripts/app.js b/server/app/scripts/app.js index 153ab3716..7ef766a79 100644 --- a/server/app/scripts/app.js +++ b/server/app/scripts/app.js @@ -87,15 +87,12 @@ app.config(['$routeProvider', '$locationProvider', function($routeProvider, $loc } }) .when('/admin/settings', { - templateUrl: '/views/sys_config.html', + templateUrl: '/views/config.html', controller: 'ConfigController', title: 'System Settings', resolve: { user: function(authService) { return authService.getUser(); - }, - conf: function(confService) { - return confService.getConfig(); } } }) @@ -189,24 +186,6 @@ app.controller("AccountReposController", function($scope, $http, user) { }); - -app.controller("ConfigController", function($scope, $http, user) { - - $scope.user = user; - - $http({method: 'GET', url: '/v1/config'}). - success(function(data, status, headers, config) { - $scope.config = data; - }). - error(function(data, status, headers, config) { - console.log(data); - }); -}); - - - - - app.controller("CommitController", function($scope, $http, $routeParams, stdout, feed) { var remote = $routeParams.remote; diff --git a/server/app/scripts/controllers/conf.js b/server/app/scripts/controllers/conf.js index ad9a93a7c..6e42b7f89 100644 --- a/server/app/scripts/controllers/conf.js +++ b/server/app/scripts/controllers/conf.js @@ -1 +1,40 @@ 'use strict'; + +angular.module('app').controller("ConfigController", function($scope, $http, remotes) { + $scope.state=0; + + $scope.user = remotes.get().success(function (data) { + $scope.remotes = (typeof data==="string")?[]:data; + $scope.state = 1; + + // loop through the remotes and add each + // remote to the page scope. + for (remote in $scope.remotes) { + switch (remote.type) { + case 'github.com': + $scope.github = remote; + break; + + case 'enterprise.github.com': + $scope.githubEnterprise = remote; + break; + + case 'gitlab.com': + $scope.gitlab = remote; + break; + + case 'bitbucket.org': + $scope.bitbucket = remote; + break; + + case 'stash.atlassian.com': + $scope.stash = remote; + break; + } + } + }) + .error(function (error) { + $scope.remotes = []; + $scope.state = 1; + }); +}); diff --git a/server/app/scripts/controllers/home.js b/server/app/scripts/controllers/home.js index e6fdf7688..84285f346 100644 --- a/server/app/scripts/controllers/home.js +++ b/server/app/scripts/controllers/home.js @@ -8,7 +8,6 @@ angular.module('app').controller("HomeController", function($scope, $http, feed) $http({method: 'GET', url: '/v1/user/feed'}). success(function(data, status, headers, config) { - console.log(data) $scope.feed = (typeof data==='string')?[]:data; }). error(function(data, status, headers, config) { diff --git a/server/app/views/config.html b/server/app/views/config.html new file mode 100644 index 000000000..6e6d285c5 --- /dev/null +++ b/server/app/views/config.html @@ -0,0 +1,51 @@ +
+ + +
+
+
+

{{ remote.type | remoteName }}

+
+
+ +
+ +
+
+ +
+ +
+ +
+
+ +
+ +
+ +
+
+ +
+ +
+ +
+
+ +
+ + + Enable Self-Registration +
+ + +
+
+
+
+
diff --git a/server/app/views/repo.html b/server/app/views/repo.html index a70e3e6f8..d6fc4d5a1 100644 --- a/server/app/views/repo.html +++ b/server/app/views/repo.html @@ -37,7 +37,7 @@

{{group.branch}}

- +

{{ commit.message }}

{{ commit.finished_at | fromNow }} diff --git a/server/app/views/sys_config.html b/server/app/views/sys_config.html deleted file mode 100644 index 381869967..000000000 --- a/server/app/views/sys_config.html +++ /dev/null @@ -1,112 +0,0 @@ -
- - - -
- - - - - - - - - - - - - -
Host{{ config.host }}
Scheme{{ config.scheme }}
Registration{{ config.registration }}
- -

GitHub

- - - - - - - - - - - - - - - - - - - - - -
Enabled{{ config.github.enabled }}
URL{{ config.github.url }}
API{{ config.github.api }}
Client{{ config.github.client }}
Secret{{ config.github.secret }}
- -

GitHub Enterprise

- - - - - - - - - - - - - - - - - - - - - -
Enabled{{ config.githubEnterprise.enabled }}
URL{{ config.githubEnterprise.url }}
API{{ config.githubEnterprise.api }}
Client{{ config.githubEnterprise.client }}
Secret{{ config.githubEnterprise.secret }}
- -

Bitbucket

- - - - - - - - - - - - - - - - - - - - - -
Enabled{{ config.bitbucket.enabled }}
URL{{ config.bitbucket.url }}
API{{ config.bitbucket.api }}
Client{{ config.bitbucket.client }}
Secret{{ config.bitbucket.secret }}
- -

Gitlab

- - - - - - - - - -
Enabled{{ config.bitbucket.enabled }}
URL{{ config.bitbucket.url }}
-
-
\ No newline at end of file