mirror of
https://github.com/woodpecker-ci/woodpecker.git
synced 2024-11-24 08:02:18 +02:00
website subscribes to build events, update pages
This commit is contained in:
parent
8e6fbc8ceb
commit
96b49cf0fc
4
.gitignore
vendored
4
.gitignore
vendored
@ -13,9 +13,7 @@ drone.sublime-workspace
|
|||||||
*.db
|
*.db
|
||||||
*.txt
|
*.txt
|
||||||
*.toml
|
*.toml
|
||||||
|
*.min.js
|
||||||
bindata.go
|
bindata.go
|
||||||
|
|
||||||
# combined assets
|
|
||||||
server/static/drone.js
|
|
||||||
|
|
||||||
drone
|
drone
|
||||||
|
2
Makefile
2
Makefile
@ -23,7 +23,7 @@ concat:
|
|||||||
server/static/scripts/services/*.js \
|
server/static/scripts/services/*.js \
|
||||||
server/static/scripts/filters/*.js \
|
server/static/scripts/filters/*.js \
|
||||||
server/static/scripts/controllers/*.js \
|
server/static/scripts/controllers/*.js \
|
||||||
server/static/scripts/term.js > server/static/drone.js
|
server/static/scripts/term.js > server/static/scripts/drone.min.js
|
||||||
|
|
||||||
bindata_debug:
|
bindata_debug:
|
||||||
go-bindata --debug server/static/...
|
go-bindata --debug server/static/...
|
||||||
|
12
drone.go
12
drone.go
@ -109,12 +109,16 @@ func main() {
|
|||||||
|
|
||||||
queue := api.Group("/queue")
|
queue := api.Group("/queue")
|
||||||
{
|
{
|
||||||
queue.Use(server.SetRepo())
|
|
||||||
queue.GET("", server.GetQueue)
|
queue.GET("", server.GetQueue)
|
||||||
queue.POST("/pull", server.PollBuild)
|
queue.POST("/pull", server.PollBuild)
|
||||||
queue.POST("/push/:owner/:name", server.PushBuild)
|
|
||||||
queue.POST("/push/:owner/:name/:build", server.PushTask)
|
push := queue.Group("/push/:owner/:name")
|
||||||
queue.POST("/push/:owner/:name/:build/:task/logs", server.PushLogs)
|
{
|
||||||
|
push.Use(server.SetRepo())
|
||||||
|
push.POST("", server.PushBuild)
|
||||||
|
push.POST("/:build", server.PushTask)
|
||||||
|
push.POST("/:build/:task/logs", server.PushLogs)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
events := api.Group("/stream")
|
events := api.Group("/stream")
|
||||||
|
@ -48,9 +48,11 @@ func PushBuild(c *gin.Context) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
if repo.Last == nil || build.Number >= repo.Last.Number {
|
if build.State != common.StatePending && build.State != common.StateRunning {
|
||||||
repo.Last = build
|
if repo.Last == nil || build.Number >= repo.Last.Number {
|
||||||
store.SetRepo(repo)
|
repo.Last = build
|
||||||
|
store.SetRepo(repo)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// <-- FIXME
|
// <-- FIXME
|
||||||
|
@ -47,17 +47,28 @@
|
|||||||
}
|
}
|
||||||
// update repository
|
// update repository
|
||||||
$scope.repo = event.repo;
|
$scope.repo = event.repo;
|
||||||
$scope.apply();
|
|
||||||
|
|
||||||
if (event.build.number !== parseInt(number)) {
|
|
||||||
return; // ignore
|
|
||||||
}
|
|
||||||
// update the build status
|
|
||||||
$scope.build.state = event.build.state;
|
|
||||||
$scope.build.started = event.build.started;
|
|
||||||
$scope.build.finished = event.build.finished;
|
|
||||||
$scope.build.duration = event.build.duration;
|
|
||||||
$scope.$apply();
|
$scope.$apply();
|
||||||
|
|
||||||
|
var added = false;
|
||||||
|
for (var i=0;i<$scope.builds.length;i++) {
|
||||||
|
var build = $scope.builds[i];
|
||||||
|
if (event.build.number !== build.number) {
|
||||||
|
continue; // ignore
|
||||||
|
}
|
||||||
|
// update the build status
|
||||||
|
build.state = event.build.state;
|
||||||
|
build.started_at = event.build.started_at;
|
||||||
|
build.finished_at = event.build.finished_at;
|
||||||
|
build.duration = event.build.duration;
|
||||||
|
$scope.builds[i] = build;
|
||||||
|
$scope.$apply();
|
||||||
|
added = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!added) {
|
||||||
|
$scope.builds.push(event.build);
|
||||||
|
$scope.$apply();
|
||||||
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -97,7 +108,9 @@
|
|||||||
|
|
||||||
// fetch the logs for the finished build.
|
// fetch the logs for the finished build.
|
||||||
logs.get(fullName, number, step).then(function(payload){
|
logs.get(fullName, number, step).then(function(payload){
|
||||||
$scope.logs = payload.data;
|
var convert = new Filter({stream:false,newline:false});
|
||||||
|
var term = document.getElementById("term")
|
||||||
|
term.innerHTML = convert.toHtml(payload.data);
|
||||||
}).catch(function(err){
|
}).catch(function(err){
|
||||||
$scope.error = err;
|
$scope.error = err;
|
||||||
});
|
});
|
||||||
@ -127,8 +140,8 @@
|
|||||||
}
|
}
|
||||||
// update the build status
|
// update the build status
|
||||||
$scope.build.state = event.build.state;
|
$scope.build.state = event.build.state;
|
||||||
$scope.build.started = event.build.started;
|
$scope.build.started_at = event.build.started_at;
|
||||||
$scope.build.finished = event.build.finished;
|
$scope.build.finished_at = event.build.finished_at;
|
||||||
$scope.build.duration = event.build.duration;
|
$scope.build.duration = event.build.duration;
|
||||||
$scope.$apply();
|
$scope.$apply();
|
||||||
|
|
||||||
@ -137,8 +150,8 @@
|
|||||||
}
|
}
|
||||||
// update the task status
|
// update the task status
|
||||||
$scope.task.state = event.task.state;
|
$scope.task.state = event.task.state;
|
||||||
$scope.task.started = event.task.started;
|
$scope.task.started_at = event.task.started_at;
|
||||||
$scope.task.finished = event.task.finished;
|
$scope.task.finished_at = event.task.finished_at;
|
||||||
$scope.task.duration = event.task.duration;
|
$scope.task.duration = event.task.duration;
|
||||||
$scope.task.exit_code = event.task.exit_code;
|
$scope.task.exit_code = event.task.exit_code;
|
||||||
$scope.$apply();
|
$scope.$apply();
|
||||||
|
@ -57,7 +57,7 @@
|
|||||||
|
|
||||||
<hr>
|
<hr>
|
||||||
|
|
||||||
<pre>{{ logs }}</pre>
|
<pre id="term">{{ logs }}</pre>
|
||||||
|
|
||||||
<table border="1">
|
<table border="1">
|
||||||
<thead>
|
<thead>
|
||||||
|
@ -21,7 +21,7 @@
|
|||||||
</tr>
|
</tr>
|
||||||
</thead>
|
</thead>
|
||||||
<tbody>
|
<tbody>
|
||||||
<tr ng-repeat="build in builds">
|
<tr ng-repeat="build in builds | orderBy:'-number'">
|
||||||
<td><a ng-href="/{{ repo.full_name }}/{{ build.number }}">{{ build.number }}</a></td>
|
<td><a ng-href="/{{ repo.full_name }}/{{ build.number }}">{{ build.number }}</a></td>
|
||||||
<td>{{ build.state }}</td>
|
<td>{{ build.state }}</td>
|
||||||
<td>{{ build.started_at | fromNow }}</td>
|
<td>{{ build.started_at | fromNow }}</td>
|
||||||
|
Loading…
Reference in New Issue
Block a user