diff --git a/assets/components/LogEventSource.vue b/assets/components/LogEventSource.vue index c19ade03..524a7bef 100644 --- a/assets/components/LogEventSource.vue +++ b/assets/components/LogEventSource.vue @@ -29,14 +29,8 @@ export default { }, methods: { loadLogs(id) { - if (this.es) { - this.es.close(); - this.messages = []; - this.buffer = []; - this.es = null; - } + this.reset(); this.es = new EventSource(`${config.base}/api/logs/stream?id=${this.id}`); - this.es.addEventListener("container-stopped", (e) => { this.es.close(); this.buffer.push({ event: "container-stopped", message: "Container stopped", date: new Date() }); @@ -54,6 +48,14 @@ export default { this.messages.push(...this.buffer); this.buffer = []; }, + reset() { + if (this.es) { + this.es.close(); + this.es = null; + } + this.messages = []; + this.buffer = []; + }, async loadOlderLogs() { if (this.messages.length < 300) return;