log: read logs stream

This commit is contained in:
Simone Gotti 2019-05-10 19:52:46 +02:00
parent 07f5b69e9b
commit 6660db7a81
1 changed files with 18 additions and 2 deletions

View File

@ -78,8 +78,24 @@ export default {
} }
let res = await fetch(apiurl(path)); let res = await fetch(apiurl(path));
if (res.status == 200) { if (res.status == 200) {
let data = await res.text(); const reader = res.body.getReader();
this.items.push(this.formatter.ansi_to_html(data));
let items = this.items;
let formatter = this.formatter;
for (;;) {
let { done, value } = await reader.read();
if (done) {
return;
}
let data = String.fromCharCode.apply(null, value);
let lines = data.split("\n");
lines.forEach(line => {
items.push(formatter.ansi_to_html(line));
});
}
} }
} }
}, },