Skip to content

Commit

Permalink
Created reset()
Browse files Browse the repository at this point in the history
  • Loading branch information
amir20 committed Jul 20, 2020
1 parent cd7ea2f commit 2ebb6d1
Showing 1 changed file with 9 additions and 7 deletions.
16 changes: 9 additions & 7 deletions assets/components/LogEventSource.vue
Original file line number Diff line number Diff line change
Expand Up @@ -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() });
Expand All @@ -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;
Expand Down

0 comments on commit 2ebb6d1

Please sign in to comment.