Get initial build trigger UI working

This commit is contained in:
Joseph Schorr 2014-02-19 17:38:00 -05:00
parent 9e426816a5
commit 5b0300ab62
3 changed files with 101 additions and 9 deletions

View file

@ -1899,6 +1899,13 @@ p.editable:hover i {
left: 4px;
}
.repo-admin .right-controls {
text-align: right;
margin-top: 10px;
padding-top: 10px;
border-top: 1px solid #eee;
}
.repo-admin .right-info {
font-size: 11px;
margin-top: 10px;

View file

@ -1145,7 +1145,7 @@ function RepoBuildCtrl($scope, Restangular, ApiService, $routeParams, $rootScope
fetchRepository();
}
function RepoAdminCtrl($scope, Restangular, ApiService, KeyService, $routeParams, $rootScope) {
function RepoAdminCtrl($scope, Restangular, ApiService, KeyService, $routeParams, $rootScope, $location) {
var namespace = $routeParams.namespace;
var name = $routeParams.name;
@ -1378,19 +1378,38 @@ function RepoAdminCtrl($scope, Restangular, ApiService, KeyService, $routeParams
});
};
$scope.showBuild = function(buildInfo) {
$location.path('/repository/' + namespace + '/' + name + '/build');
$location.search('current', buildInfo.id);
};
$scope.loadTriggerBuildHistory = function(trigger) {
trigger.$loadingHistory = true;
var params = {
'repository': namespace + '/' + name,
'trigger_uuid': trigger.id,
'limit': 3
};
ApiService.listTriggerRecentBuilds(null, params).then(function(resp) {
trigger.$builds = resp['builds'];
trigger.$loadingHistory = false;
});
};
$scope.loadTriggers = function() {
var params = {
'repository': namespace + '/' + name
};
$scope.newWebhook = {};
$scope.triggersResource = ApiService.listBuildTriggersAsResource(params).get(function(resp) {
$scope.triggers = resp.triggers;
return $scope.triggers;
});
};
$scope.deletetrigger = function(trigger) {
$scope.deleteTrigger = function(trigger) {
var params = {
'repository': namespace + '/' + name,
'trigger_uuid': trigger.id

View file

@ -211,16 +211,82 @@
<div id="trigger" class="tab-pane">
<div class="panel panel-default">
<div class="panel-heading">Build Triggers
<i class="info-icon fa fa-info-circle" data-placement="left" data-content="SCM push callbacks which can cause the repository to be built and updated."></i>
<i class="info-icon fa fa-info-circle" data-placement="left" data-content="Callbacks from various services (suchas GitHub) which can cause the repository to be built and updated."></i>
</div>
<div class="panel-body">
<div class="resource-view" resource="triggersResource" error-message="'Could not load triggers'">
<a class="btn btn-primary" href="https://github.com/login/oauth/authorize?client_id={{ githubClientId }}&scope=repo&redirect_uri={{ githubRedirectUri }}/trigger/{{ repo.namespace }}/{{ repo.name }}">Link to Github</a>
</div>
<!-- Resource view -->
<div class="resource-view" resource="triggersResource" error-message="'Could not load build triggers'">
<div ng-show="!triggers.length">No build triggers defined for this repository</div>
<table class="permissions" ng-show="triggers.length">
<thead>
<tr>
<td style="width: 562px;">Trigger</td>
<td style="width: 104px;"></td>
</tr>
</thead>
<tbody>
<tr ng-repeat="trigger in triggers">
<td>
<div ng-switch on="trigger.service">
<div ng-switch-when="github">
<i class="fa fa-github fa-lg" style="margin-right: 6px" title="GitHub" bs-tooltip="tooltip.title"></i>
Push to GitHub repository <a href="https://github.com/{{ trigger.config.build_source }}" target="_new">{{ trigger.config.build_source }}</a>
</div>
<div ng-switch-default>
Unknown
</div>
</div>
</td>
<td style="white-space: nowrap;">
<div class="dropdown" style="display: inline-block">
<button class="btn btn-default dropdown-toggle" data-toggle="dropdown" title="Build History" bs-tooltip="tooltip.title" data-container="body"
ng-click="loadTriggerBuildHistory(trigger)">
<i class="fa fa-tasks"></i>
<b class="caret"></b>
</button>
<ul class="dropdown-menu dropdown-menu-right pull-right">
<li ng-show="trigger.$loadingHistory" style="text-align: center"><span class="quay-spinner" style="padding: 4px;"></span></li>
<li role="presentation" class="dropdown-header" ng-show="!trigger.$loadingHistory && !trigger.$builds.length">No builds have been triggered</li>
<li role="presentation" class="dropdown-header" ng-show="!trigger.$loadingHistory && trigger.$builds.length">Build History</li>
<li ng-repeat="buildInfo in trigger.$builds">
<div class="build-info clickable" ng-click="showBuild(buildInfo)">
<span class="build-status" build="buildInfo"></span>
</div>
</li>
</ul>
</div>
<div class="dropdown" style="display: inline-block">
<button class="btn btn-default dropdown-toggle" data-toggle="dropdown" title="Trigger Settings" bs-tooltip="tooltip.title" data-container="body">
<i class="fa fa-cog"></i>
<b class="caret"></b>
</button>
<ul class="dropdown-menu dropdown-menu-right pull-right">
<li><a href="javascript:void(0)" ng-click="deleteTrigger(trigger)"><i class="fa fa-times"></i>Delete Trigger</a></li>
</ul>
</div>
</td>
</tr>
</tbody>
</table>
<!-- Right controls -->
<div class="right-controls">
<div class="dropdown">
<button class="btn btn-primary dropdown-toggle" data-toggle="dropdown">
New Trigger
<b class="caret"></b>
</button>
<ul class="dropdown-menu dropdown-menu-right pull-right">
<li><a href="https://github.com/login/oauth/authorize?client_id={{ githubClientId }}&scope=repo&redirect_uri={{ githubRedirectUri }}/trigger/{{ repo.namespace }}/{{ repo.name }}"><i class="fa fa-github fa-lg"></i>GitHub - Repository Push</a></li>
</ul>
</div>
</div>
<div class="right-info">
Quay will do something.
</div>
</div>
</div>