diff --git a/src/components/log.vue b/src/components/log.vue index 87efb3e..00c2ad7 100644 --- a/src/components/log.vue +++ b/src/components/log.vue @@ -1,11 +1,44 @@ @@ -36,7 +69,11 @@ export default { lines: [], formatter: formatter, es: null, - fetching: false + fetching: false, + streaming: false, + done: false, + logExists: null, + error: null }; }, methods: { @@ -54,6 +91,9 @@ export default { }, async getLogs(follow) { this.items = []; + this.logExists = null; + this.error = null; + let path = "/logs?runID=" + this.runid + "&taskID=" + this.taskid; if (this.setup) { path += "&setup"; @@ -68,6 +108,7 @@ export default { this.fetching = true; let res = await fetch(apiurl(path), { signal: this.fetchAbort.signal }); if (res.status == 200) { + this.streaming = true; const reader = res.body.getReader(); let lastline = ""; @@ -76,6 +117,8 @@ export default { let { done, value } = await reader.read(); if (done) { this.fetching = false; + this.streaming = false; + this.done = true; return; } @@ -113,11 +156,18 @@ export default { j += part.length; this.lastitem = this.formatter.ansi_to_html(lastline); } + } else if (res.status == 404) { + this.logExists = false; + } else if (res.status == 500) { + this.error = true; } } catch (e) { + this.error = true; // TODO(sgotti) show that log fetching has failed } this.fetching = false; + this.streaming = false; + this.done = false; }, abortFetch() { if (this.fetchAbort) { @@ -170,6 +220,3 @@ export default { } }; - - \ No newline at end of file