mirror of
https://github.com/woodpecker-ci/woodpecker.git
synced 2024-11-27 04:11:03 +00:00
Merge pull request #1630 from bradrydzewski/master
quick hack to group log output by step
This commit is contained in:
commit
18feb303c2
6 changed files with 75 additions and 13 deletions
|
@ -1,7 +1,6 @@
|
|||
package server
|
||||
|
||||
import (
|
||||
"io"
|
||||
"net/http"
|
||||
"strconv"
|
||||
"time"
|
||||
|
@ -12,6 +11,7 @@ import (
|
|||
"github.com/drone/drone/remote"
|
||||
"github.com/drone/drone/shared/httputil"
|
||||
"github.com/drone/drone/store"
|
||||
"github.com/drone/drone/stream"
|
||||
"github.com/gin-gonic/gin"
|
||||
"github.com/square/go-jose"
|
||||
|
||||
|
@ -108,10 +108,10 @@ func GetBuildLogs(c *gin.Context) {
|
|||
|
||||
defer r.Close()
|
||||
if full {
|
||||
io.Copy(c.Writer, r)
|
||||
} else {
|
||||
io.Copy(c.Writer, io.LimitReader(r, 2000000))
|
||||
// TODO implement limited streaming to avoid crashing the browser
|
||||
}
|
||||
|
||||
stream.Copy(c.Writer, r)
|
||||
}
|
||||
|
||||
func DeleteBuild(c *gin.Context) {
|
||||
|
|
|
@ -5,7 +5,7 @@ function JobViewModel(repo, build, job, status) {
|
|||
self.status = status;
|
||||
|
||||
self.stream = function() {
|
||||
$( "#output" ).html("");
|
||||
$("#output").html("");
|
||||
$("#restart").hide();
|
||||
$("#cancel").show();
|
||||
|
||||
|
@ -141,10 +141,42 @@ function Logs(repo, build, job) {
|
|||
|
||||
$.get( "/api/repos/"+repo+"/logs/"+build+"/"+job, function( data ) {
|
||||
|
||||
var convert = new Filter({stream: false, newline: false});
|
||||
var escaped = convert.toHtml(escapeHTML(data));
|
||||
var lines = JSON.parse(data);
|
||||
|
||||
$( "#output" ).html( escaped );
|
||||
var groups = {}
|
||||
for (var i=0; i<lines.length; i++) {
|
||||
var line = lines[i];
|
||||
|
||||
if (!line.proc) {
|
||||
continue
|
||||
}
|
||||
|
||||
var group = groups[line.proc];
|
||||
|
||||
if (!group) {
|
||||
|
||||
// create an element to hold the group of output
|
||||
var pre = $("<pre>").attr("data-title", line.proc);
|
||||
$("#output").append(pre);
|
||||
|
||||
// create the buffer for the group of output
|
||||
var buf = new Drone.Buffer();
|
||||
buf.start(pre[0]);
|
||||
|
||||
// add items to the group
|
||||
group = {
|
||||
pre: pre,
|
||||
buf: buf,
|
||||
};
|
||||
groups[line.proc]=group;
|
||||
}
|
||||
|
||||
group.buf.write(line.out+"\n");
|
||||
}
|
||||
|
||||
for (var i=0; i<groups.length; i++) {
|
||||
groups[i].buf.stop();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
|
|
@ -17,6 +17,30 @@
|
|||
font-family: "Roboto Mono";
|
||||
min-height: calc(100vh - 205px);
|
||||
|
||||
#output > pre
|
||||
font-size: 13px;
|
||||
color: #eff1f5;
|
||||
border-radius: 2px;
|
||||
background: #2b303b;
|
||||
white-space: pre-wrap;
|
||||
word-wrap: break-word;
|
||||
box-sizing: border-box;
|
||||
padding: 0px;
|
||||
font-family: "Roboto Mono";
|
||||
margin: 0px;
|
||||
margin-top: 25px;
|
||||
|
||||
#output > pre:first-child
|
||||
margin-top: 0px;
|
||||
|
||||
#output > pre:before
|
||||
content: attr(data-title);
|
||||
display: block;
|
||||
padding: 5px;
|
||||
margin-bottom: 10px;
|
||||
border-bottom: 1px solid rgba(255,255,255,0.3);
|
||||
padding-left: 0px;
|
||||
|
||||
#follow
|
||||
position: absolute;
|
||||
|
||||
|
|
|
@ -134,6 +134,12 @@ input[type=range]:focus::-ms-fill-upper { background: #367ebd; }
|
|||
|
||||
#output { background: #0d1926; color: #d9e6f2; margin-right: 15px; font-size: 13px; color: #eff1f5; border-radius: 2px; background: #2b303b; white-space: pre-wrap; word-wrap: break-word; box-sizing: border-box; padding: 35px 40px; font-family: "Roboto Mono"; min-height: calc(100vh - 205px); }
|
||||
|
||||
#output > pre { font-size: 13px; color: #eff1f5; border-radius: 2px; background: #2b303b; white-space: pre-wrap; word-wrap: break-word; box-sizing: border-box; padding: 0px; font-family: "Roboto Mono"; margin: 0px; margin-top: 25px; }
|
||||
|
||||
#output > pre:first-child { margin-top: 0px; }
|
||||
|
||||
#output > pre:before { content: attr(data-title); display: block; padding: 5px; margin-bottom: 10px; border-bottom: 1px solid rgba(255, 255, 255, 0.3); padding-left: 0px; }
|
||||
|
||||
#follow { position: absolute; }
|
||||
|
||||
.build-summary { padding-left: 20px; }
|
||||
|
|
|
@ -84,7 +84,7 @@ block content
|
|||
if Job.Error != ""
|
||||
div.alert.alert-danger #{Job.Error}
|
||||
else
|
||||
pre#output
|
||||
div#output
|
||||
button.tail#tail
|
||||
i.material-icons expand_more
|
||||
|
||||
|
|
Loading…
Reference in a new issue