You've already forked woodpecker
							
							
				mirror of
				https://github.com/woodpecker-ci/woodpecker.git
				synced 2025-10-30 23:27:39 +02:00 
			
		
		
		
	settings page now display configured remotes
This commit is contained in:
		| @@ -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; | ||||
|   | ||||
| @@ -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; | ||||
| 		}); | ||||
| }); | ||||
|   | ||||
| @@ -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) { | ||||
|   | ||||
							
								
								
									
										51
									
								
								server/app/views/config.html
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										51
									
								
								server/app/views/config.html
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,51 @@ | ||||
| <article id="setuppage"> | ||||
| 	<nav> | ||||
| 		<a href="/"><span class="fa fa-th"></span></a> | ||||
| 		<a href="#">Settings</a> | ||||
| 	</nav> | ||||
|  | ||||
| 	<section ng-repeat="remote in remotes"> | ||||
| 		<div class="pure-g"> | ||||
| 			<div class="pure-u-1"> | ||||
| 				<h2>{{ remote.type | remoteName }}</h2> | ||||
| 				<div class="pure-form"> | ||||
| 					<div ng-if="remote.type != 'github.com' && remote.type != 'bitbucket.org' "> | ||||
| 						<label>URL</label> | ||||
| 						<div ng-switch="remote.type"> | ||||
| 							<input ng-switch-default ng-model="remote.url" type="text" placeholder="https://www.foo.com" /> | ||||
| 						</div> | ||||
| 					</div> | ||||
|  | ||||
| 					<div ng-if="remote.type != 'github.com' && remote.type != 'bitbucket.org' "> | ||||
| 						<label>API URL</label> | ||||
| 						<div ng-switch="remote.type"> | ||||
| 							<input ng-switch-default ng-model="remote.api" type="text" placeholder="https://www.foo.com/api" /> | ||||
| 						</div> | ||||
| 					</div> | ||||
|  | ||||
| 					<div ng-if="remote.type != 'gitlab.com'"> | ||||
| 						<label>OAuth Client</label> | ||||
| 						<div> | ||||
| 							<input type="text" ng-model="remote.client" /> | ||||
| 						</div> | ||||
| 					</div> | ||||
|  | ||||
| 					<div ng-if="remote.type != 'gitlab.com'"> | ||||
| 						<label>OAuth Secret</label> | ||||
| 						<div> | ||||
| 							<input type="text" ng-model="remote.secret" /> | ||||
| 						</div> | ||||
| 					</div> | ||||
|  | ||||
| 					<div class="toggle"> | ||||
| 						<input type="checkbox" ng-model="remote.register" id="register" /> | ||||
| 						<label for="register"></label> | ||||
| 						<span>Enable Self-Registration</span> | ||||
| 					</div> | ||||
|  | ||||
| 					<button ng-click="save()" class="pure-button pure-button-primary">Save</button> | ||||
| 				</div> | ||||
| 			</div> | ||||
| 		</div> | ||||
| 	</section> | ||||
| </article> | ||||
| @@ -37,7 +37,7 @@ | ||||
| 		<section ng-repeat="group in commits | unique: 'branch'"> | ||||
| 			<div class="pure-g cards"> | ||||
| 				<h2 class="pure-u-1" style="font-size:22px;margin-bottom:20px;"><i class="fa fa-code-fork"></i> {{group.branch}}</h2> | ||||
| 				<a class="pure-u-1 pure-u-md-1-2 pure-u-lg-1-4 pure-u-xl-1-4 card card" href="/{{ repo | fullPath }}/{{ commit.branch }}/{{ commit.sha }}" ng-repeat="commit in commits | filter: { branch: group.branch } | limitTo:4" data-status="{{ commit.status }}"> | ||||
| 				<a class="pure-u-1 pure-u-md-1-4 pure-u-lg-1-4 pure-u-xl-1-4 card card" href="/{{ repo | fullPath }}/{{ commit.branch }}/{{ commit.sha }}" ng-repeat="commit in commits | filter: { branch: group.branch } | limitTo:4" data-status="{{ commit.status }}"> | ||||
| 					<div class="l-box"> | ||||
| 						<h2>{{ commit.message }}</h2> | ||||
| 						<em ng-if="commit.finished_at != 0">{{ commit.finished_at | fromNow }}</em> | ||||
|   | ||||
| @@ -1,112 +0,0 @@ | ||||
| <div class="row"> | ||||
| 	<div class="col-xs-6 col-sm-3"> | ||||
| 		<ul> | ||||
| 			<li><a href="/admin/settings">Config</a></li> | ||||
| 			<li><a href="/admin/users">Users</a></li> | ||||
| 			<li><a href="/admin/workers">Workers</a></li> | ||||
| 			<li><a href="/admin/queue">Queue</a></li> | ||||
| 		</ul> | ||||
| 	</div> | ||||
|  | ||||
| 	<!-- primary column --> | ||||
| 	<div class="col-xs-12 col-sm-9"> | ||||
| 		<table class="table table-bordered"> | ||||
| 			<tr> | ||||
| 				<th>Host</th> | ||||
| 				<td>{{ config.host }}</td> | ||||
| 			</tr> | ||||
| 			<tr> | ||||
| 				<th>Scheme</th> | ||||
| 				<td>{{ config.scheme }}</td> | ||||
| 			</tr> | ||||
| 			<tr> | ||||
| 				<th>Registration</th> | ||||
| 				<td>{{ config.registration }}</td> | ||||
| 			</tr> | ||||
| 		</table> | ||||
|  | ||||
| 		<h2>GitHub</h2> | ||||
| 		<table class="table table-bordered"> | ||||
| 			<tr> | ||||
| 				<th>Enabled</th> | ||||
| 				<td>{{ config.github.enabled }}</td> | ||||
| 			</tr> | ||||
| 			<tr> | ||||
| 				<th>URL</th> | ||||
| 				<td>{{ config.github.url }}</td> | ||||
| 			</tr> | ||||
| 			<tr> | ||||
| 				<th>API</th> | ||||
| 				<td>{{ config.github.api }}</td> | ||||
| 			</tr> | ||||
| 			<tr> | ||||
| 				<th>Client</th> | ||||
| 				<td>{{ config.github.client }}</td> | ||||
| 			</tr> | ||||
| 			<tr> | ||||
| 				<th>Secret</th> | ||||
| 				<td>{{ config.github.secret }}</td> | ||||
| 			</tr> | ||||
| 		</table> | ||||
|  | ||||
| 		<h2>GitHub Enterprise</h2> | ||||
| 		<table class="table table-bordered"> | ||||
| 			<tr> | ||||
| 				<th>Enabled</th> | ||||
| 				<td>{{ config.githubEnterprise.enabled }}</td> | ||||
| 			</tr> | ||||
| 			<tr> | ||||
| 				<th>URL</th> | ||||
| 				<td>{{ config.githubEnterprise.url }}</td> | ||||
| 			</tr> | ||||
| 			<tr> | ||||
| 				<th>API</th> | ||||
| 				<td>{{ config.githubEnterprise.api }}</td> | ||||
| 			</tr> | ||||
| 			<tr> | ||||
| 				<th>Client</th> | ||||
| 				<td>{{ config.githubEnterprise.client }}</td> | ||||
| 			</tr> | ||||
| 			<tr> | ||||
| 				<th>Secret</th> | ||||
| 				<td>{{ config.githubEnterprise.secret }}</td> | ||||
| 			</tr> | ||||
| 		</table> | ||||
|  | ||||
| 		<h2>Bitbucket</h2> | ||||
| 		<table class="table table-bordered"> | ||||
| 			<tr> | ||||
| 				<th>Enabled</th> | ||||
| 				<td>{{ config.bitbucket.enabled }}</td> | ||||
| 			</tr> | ||||
| 			<tr> | ||||
| 				<th>URL</th> | ||||
| 				<td>{{ config.bitbucket.url }}</td> | ||||
| 			</tr> | ||||
| 			<tr> | ||||
| 				<th>API</th> | ||||
| 				<td>{{ config.bitbucket.api }}</td> | ||||
| 			</tr> | ||||
| 			<tr> | ||||
| 				<th>Client</th> | ||||
| 				<td>{{ config.bitbucket.client }}</td> | ||||
| 			</tr> | ||||
| 			<tr> | ||||
| 				<th>Secret</th> | ||||
| 				<td>{{ config.bitbucket.secret }}</td> | ||||
| 			</tr> | ||||
| 		</table> | ||||
|  | ||||
| 		<h2>Gitlab</h2> | ||||
| 		<table class="table table-bordered"> | ||||
| 			<tr> | ||||
| 				<th>Enabled</th> | ||||
| 				<td>{{ config.bitbucket.enabled }}</td> | ||||
| 			</tr> | ||||
| 			<tr> | ||||
| 				<th>URL</th> | ||||
| 				<td>{{ config.bitbucket.url }}</td> | ||||
| 			</tr> | ||||
| 		</table> | ||||
| 	</div> | ||||
| </div> | ||||
		Reference in New Issue
	
	Block a user