mirror of
https://github.com/woodpecker-ci/woodpecker.git
synced 2024-11-22 18:01:02 +00:00
Merge pull request #146 from movableink/buffer-websocket-log-output
logline output buffers rather than updating on every ws message
This commit is contained in:
commit
4689d53305
1 changed files with 30 additions and 7 deletions
|
@ -133,16 +133,39 @@
|
||||||
outputWS.onopen = function () { console.log('output websocket open'); };
|
outputWS.onopen = function () { console.log('output websocket open'); };
|
||||||
outputWS.onerror = function (e) { console.log('websocket error: ' + e); };
|
outputWS.onerror = function (e) { console.log('websocket error: ' + e); };
|
||||||
outputWS.onclose = function (e) { window.location.reload(); };
|
outputWS.onclose = function (e) { window.location.reload(); };
|
||||||
outputWS.onmessage = function (e) {
|
|
||||||
outputBox.innerHTML += formatLine(e.data);
|
window.requestAnimationFrame = window.requestAnimationFrame ||
|
||||||
if (window.autofollow) {
|
window.webkitRequestAnimationFrame ||
|
||||||
window.scrollTo(0, document.body.scrollHeight);
|
function(callback, element) {
|
||||||
}
|
return window.setTimeout(function() {
|
||||||
|
callback(+new Date());
|
||||||
|
}, 1000 / 60);
|
||||||
|
};
|
||||||
|
|
||||||
|
var lineBuffer = "";
|
||||||
|
|
||||||
|
outputWS.onmessage = function (e) {
|
||||||
|
lineBuffer += formatLine(e.data);
|
||||||
};
|
};
|
||||||
{{ else }}
|
|
||||||
|
function updateScreen() {
|
||||||
|
if(lineBuffer.length > 0) {
|
||||||
|
outputBox.innerHTML += lineBuffer;
|
||||||
|
lineBuffer = '';
|
||||||
|
|
||||||
|
if (window.autofollow) {
|
||||||
|
window.scrollTo(0, document.body.scrollHeight);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
requestAnimationFrame(updateScreen);
|
||||||
|
}
|
||||||
|
|
||||||
|
requestAnimationFrame(updateScreen);
|
||||||
|
|
||||||
|
{{ else }}
|
||||||
$.get("/{{ .Repo.Slug }}/commit/{{ .Commit.Hash }}/build/{{ .Build.Slug }}/out.txt", function( data ) {
|
$.get("/{{ .Repo.Slug }}/commit/{{ .Commit.Hash }}/build/{{ .Build.Slug }}/out.txt", function( data ) {
|
||||||
$( "#stdout" ).html(formatLine(data));
|
$( "#stdout" ).html(formatLine(data));
|
||||||
});
|
});
|
||||||
{{ end }}
|
{{ end }}
|
||||||
</script>
|
</script>
|
||||||
{{ end }}
|
{{ end }}
|
Loading…
Reference in a new issue