mirror of
https://github.com/woodpecker-ci/woodpecker.git
synced 2024-11-22 18:01:02 +00:00
migrating most of angular app to new data structure
This commit is contained in:
parent
e6cb22f190
commit
5ec17e9172
7 changed files with 46 additions and 43 deletions
|
@ -45,7 +45,7 @@
|
|||
var added = false;
|
||||
for (var i=0;i<$scope.builds.length;i++) {
|
||||
var build = $scope.builds[i];
|
||||
if (event.sequence !== build.sequence) {
|
||||
if (event.number !== build.number) {
|
||||
continue; // ignore
|
||||
}
|
||||
// update the build status
|
||||
|
@ -91,7 +91,7 @@
|
|||
});
|
||||
|
||||
repos.subscribe(fullName, function(event) {
|
||||
if (event.sequence !== parseInt(number)) {
|
||||
if (event.number !== parseInt(number)) {
|
||||
return; // ignore
|
||||
}
|
||||
// update the build
|
||||
|
@ -150,11 +150,11 @@
|
|||
// Gets the build
|
||||
builds.get(fullName, number).then(function(payload){
|
||||
$scope.build = payload.data;
|
||||
$scope.task = payload.data.builds[step-1];
|
||||
$scope.task = payload.data.jobs[step-1];
|
||||
|
||||
if (['pending', 'killed'].indexOf($scope.task.state) !== -1) {
|
||||
if (['pending', 'killed'].indexOf($scope.task.status) !== -1) {
|
||||
// do nothing
|
||||
} else if ($scope.task.state === 'running') {
|
||||
} else if ($scope.task.status === 'running') {
|
||||
// stream the build
|
||||
stream();
|
||||
} else {
|
||||
|
@ -195,7 +195,7 @@
|
|||
};
|
||||
|
||||
repos.subscribe(fullName, function(event) {
|
||||
if (event.sequence !== parseInt(number)) {
|
||||
if (event.number !== parseInt(number)) {
|
||||
return; // ignore
|
||||
}
|
||||
// update the build
|
||||
|
@ -204,7 +204,7 @@
|
|||
$scope.$apply();
|
||||
|
||||
// start streaming the current build
|
||||
if ($scope.task.state === 'running') {
|
||||
if ($scope.task.status === 'running') {
|
||||
stream();
|
||||
} else {
|
||||
// resets our streaming state
|
||||
|
|
|
@ -45,7 +45,7 @@
|
|||
var added = false;
|
||||
for (var i=0;i<$scope.builds.length;i++) {
|
||||
var build = $scope.builds[i];
|
||||
if (event.sequence !== build.sequence) {
|
||||
if (event.number !== build.number) {
|
||||
continue; // ignore
|
||||
}
|
||||
// update the build status
|
||||
|
|
|
@ -12,7 +12,7 @@
|
|||
<a ng-href="/{{ repo.full_name }}" class="icon icon-home"></a>
|
||||
<a ng-href="/{{ repo.full_name }}">{{ repo.owner }} / {{ repo.name }}</a>
|
||||
<span class="spacer"></span>
|
||||
<a ng-href="#">{{ build.sequence }}</a>
|
||||
<a ng-href="#">{{ build.number }}</a>
|
||||
</div>
|
||||
|
||||
<div class="menu">
|
||||
|
@ -31,28 +31,28 @@
|
|||
<section class="commit-section">
|
||||
<div class="row build-row">
|
||||
<div>
|
||||
<div ng-class="[ 'build-num', build.state ]"></div>
|
||||
<div ng-class="[ 'build-num', build.status ]"></div>
|
||||
</div>
|
||||
<div>
|
||||
<h3>{{ build.message }}</h3>
|
||||
<p><strong>{{ build.author }}</strong> pushed to <strong>{{ build.branch }}</strong> {{ build.started_at | fromNow }}</p>
|
||||
<div style="position:absolute;top:30px;right:30px;color:#CCC;"># {{build.sequence}}</div>
|
||||
<h3>{{ build.head_commit.message }}</h3>
|
||||
<p><strong>{{ build.head_commit.author.login }}</strong> pushed to <strong>{{ build.head_commit.branch }}</strong> {{ build.started_at | fromNow }}</p>
|
||||
<div style="position:absolute;top:30px;right:30px;color:#CCC;"># {{build.number}}</div>
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
|
||||
<section>
|
||||
<a class="row build-row sub-build-row" ng-repeat="task in build.builds" ng-href="{{ repo.full_name }}/{{ build.sequence }}/{{ task.sequence }}">
|
||||
<a class="row build-row sub-build-row" ng-repeat="job in build.jobs" ng-href="{{ repo.full_name }}/{{ build.number }}/{{ job.number }}">
|
||||
<div>
|
||||
<div ng-class="[ 'build-num', build.state ]"></div>
|
||||
<div ng-class="[ 'build-num', build.status ]"></div>
|
||||
</div>
|
||||
<div>
|
||||
<h3>
|
||||
<div ng-repeat="(key, value) in task.environment">
|
||||
<div ng-repeat="(key, value) in job.environment">
|
||||
{{ key.toUpperCase() }}={{ value }}
|
||||
</div>
|
||||
</h3>
|
||||
<div style="position:absolute;top:30px;right:30px;color:#CCC;"># {{task.sequence}}</div>
|
||||
<div style="position:absolute;top:30px;right:30px;color:#CCC;"># {{job.number}}</div>
|
||||
</div>
|
||||
</a>
|
||||
</section>
|
||||
|
@ -60,5 +60,5 @@
|
|||
|
||||
|
||||
|
||||
<button ng-if="build.state !== 'pending' && build.state !== 'running'" ng-click="restart()">Restart</button>
|
||||
<button ng-if="build.state === 'pending' || build.state === 'running'" ng-click="cancel()">Cancel</button>
|
||||
<button ng-if="build.status !== 'pending' && build.status !== 'running'" ng-click="restart()">Restart</button>
|
||||
<button ng-if="build.status === 'pending' || build.status === 'running'" ng-click="cancel()">Cancel</button>
|
||||
|
|
|
@ -32,16 +32,16 @@
|
|||
<section class="commit-section">
|
||||
<div class="row build-row">
|
||||
<div>
|
||||
<div ng-class="[ 'build-num', task.state ]" ng-if="task"></div>
|
||||
<div ng-class="[ 'build-num', build.state ]" ng-if="!task"></div>
|
||||
<div ng-class="[ 'build-num', task.status ]" ng-if="task"></div>
|
||||
<div ng-class="[ 'build-num', build.status ]" ng-if="!task"></div>
|
||||
</div>
|
||||
<div>
|
||||
<h3>{{ build.message }}</h3>
|
||||
<p><strong>{{ build.author }}</strong> pushed to <strong>{{ build.branch }}</strong> {{ build.started_at | fromNow }}</p>
|
||||
<h3>{{ build.head_commit.message }}</h3>
|
||||
<p><strong>{{ build.head_commit.author.login }}</strong> pushed to <strong>{{ build.head_commit.branch }}</strong> {{ build.started_at | fromNow }}</p>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="row build-row sub-build-row" ng-if="build.builds.length > 1">
|
||||
<div class="row build-row sub-build-row" ng-if="build.jobs.length > 1">
|
||||
<div>
|
||||
|
||||
</div>
|
||||
|
@ -58,11 +58,11 @@
|
|||
|
||||
|
||||
|
||||
<pre id="term" ng-if="task && task.state !== 'pending'"></pre>
|
||||
<button class="fab" ng-if="build.state === 'running'" ng-click="tail()"></button>
|
||||
<pre id="term" ng-if="task && task.status !== 'pending'"></pre>
|
||||
<button class="fab" ng-if="build.status === 'running'" ng-click="tail()"></button>
|
||||
</article>
|
||||
|
||||
|
||||
|
||||
<button ng-if="build.state !== 'pending' && build.state !== 'running'" ng-click="restart()">Restart</button>
|
||||
<button ng-if="build.state === 'pending' || build.state === 'running'" ng-click="cancel()">Cancel</button>
|
||||
<button ng-if="build.status !== 'pending' && build.status !== 'running'" ng-click="restart()">Restart</button>
|
||||
<button ng-if="build.status === 'pending' || build.status === 'running'" ng-click="cancel()">Cancel</button>
|
||||
|
|
|
@ -25,14 +25,14 @@
|
|||
|
||||
<article>
|
||||
<section>
|
||||
<a class="row build-row" ng-repeat="build in builds | orderBy:'-sequence'" ng-href="/{{ repo.full_name }}/{{ build.sequence }}">
|
||||
<a class="row build-row" ng-repeat="build in builds | orderBy:'-number'" ng-href="/{{ repo.full_name }}/{{ build.number }}">
|
||||
<div>
|
||||
<div ng-class="[ 'build-num', build.state ]"></div>
|
||||
<div ng-class="[ 'build-num', build.status ]"></div>
|
||||
</div>
|
||||
<div>
|
||||
<h3>{{ build.message }}</h3>
|
||||
<p><strong>{{ build.author }}</strong> pushed to <strong>{{ build.branch }}</strong> {{ build.started_at | fromNow }}</p>
|
||||
<div style="position:absolute;top:30px;right:30px;color:#CCC;"># {{build.sequence}}</div>
|
||||
<h3>{{ build.head_commit.message }}</h3>
|
||||
<p><strong>{{ build.head_commit.author.login }}</strong> pushed to <strong>{{ build.head_commit.branch }}</strong> {{ build.started_at | fromNow }}</p>
|
||||
<div style="position:absolute;top:30px;right:30px;color:#CCC;"># {{build.number}}</div>
|
||||
</div>
|
||||
</a>
|
||||
</section>
|
||||
|
|
|
@ -29,14 +29,14 @@
|
|||
<div class="row">
|
||||
<div>Post Commit Hooks</div>
|
||||
<div>
|
||||
<input id="post_commits" type="checkbox" hidden="hidden" ng-model="repo.post_commits" ng-change="save(repo)" />
|
||||
<input id="post_commits" type="checkbox" hidden="hidden" ng-model="repo.hooks.push" ng-change="save(repo)" />
|
||||
<label for="post_commits" class="switch"></label>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div>Pull Request Hooks</div>
|
||||
<div>
|
||||
<input id="pull_requests" type="checkbox" hidden="hidden" ng-model="repo.pull_requests" ng-change="save(repo)" />
|
||||
<input id="pull_requests" type="checkbox" hidden="hidden" ng-model="repo.hooks.pull_request" ng-change="save(repo)" />
|
||||
<label for="pull_requests" class="switch"></label>
|
||||
</div>
|
||||
</div>
|
||||
|
|
|
@ -31,10 +31,13 @@ type repoResp struct {
|
|||
// accept null values, effectively patching an existing
|
||||
// repository object with only the supplied fields.
|
||||
type repoReq struct {
|
||||
PostCommit *bool `json:"post_commits"`
|
||||
PullRequest *bool `json:"pull_requests"`
|
||||
Trusted *bool `json:"trusted"`
|
||||
Timeout *int64 `json:"timeout"`
|
||||
Trusted *bool `json:"trusted"`
|
||||
Timeout *int64 `json:"timeout"`
|
||||
|
||||
Hooks struct {
|
||||
PullReqeust *bool `json:"pull_request"`
|
||||
Push *bool `json:"push"`
|
||||
}
|
||||
|
||||
// optional private parameters can only be
|
||||
// supplied by the repository admin.
|
||||
|
@ -95,11 +98,11 @@ func PutRepo(c *gin.Context) {
|
|||
repo.Params = *in.Params
|
||||
}
|
||||
|
||||
if in.PostCommit != nil {
|
||||
repo.Hooks.Push = *in.PostCommit
|
||||
if in.Hooks.Push != nil {
|
||||
repo.Hooks.Push = *in.Hooks.Push
|
||||
}
|
||||
if in.PullRequest != nil {
|
||||
repo.Hooks.PullRequest = *in.PullRequest
|
||||
if in.Hooks.PullReqeust != nil {
|
||||
repo.Hooks.PullRequest = *in.Hooks.PullReqeust
|
||||
}
|
||||
if in.Trusted != nil && user.Admin {
|
||||
repo.Trusted = *in.Trusted
|
||||
|
|
Loading…
Reference in a new issue