Created reset()

This commit is contained in:
Amir Raminfar
2020-07-19 17:16:39 -07:00
parent cd7ea2f904
commit 2ebb6d128d

View File

@@ -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;