mirror of
https://github.com/amir20/dozzle.git
synced 2025-12-24 06:28:42 +01:00
Uses .flush()
This commit is contained in:
@@ -25,6 +25,7 @@ export default {
|
|||||||
created() {
|
created() {
|
||||||
this.es = null;
|
this.es = null;
|
||||||
this.loadLogs(this.id);
|
this.loadLogs(this.id);
|
||||||
|
this.flushBuffer = debounce(this.flushNow, 250, { maxWait: 1000 });
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
loadLogs(id) {
|
loadLogs(id) {
|
||||||
@@ -39,21 +40,20 @@ export default {
|
|||||||
this.es.addEventListener("container-stopped", (e) => {
|
this.es.addEventListener("container-stopped", (e) => {
|
||||||
this.es.close();
|
this.es.close();
|
||||||
this.buffer.push({ event: "container-stopped", message: "Container stopped", date: new Date() });
|
this.buffer.push({ event: "container-stopped", message: "Container stopped", date: new Date() });
|
||||||
flushNow();
|
this.flushBuffer();
|
||||||
|
this.flushBuffer.flush();
|
||||||
});
|
});
|
||||||
this.es.addEventListener("error", (e) => console.log("EventSource failed: " + JSON.stringify(e)));
|
this.es.addEventListener("error", (e) => console.log("EventSource failed: " + JSON.stringify(e)));
|
||||||
|
|
||||||
const flushBuffer = debounce(() => flushNow(), 250, { maxWait: 1000 });
|
|
||||||
const flushNow = () => {
|
|
||||||
this.messages.push(...this.buffer);
|
|
||||||
this.buffer = [];
|
|
||||||
};
|
|
||||||
this.es.onmessage = (e) => {
|
this.es.onmessage = (e) => {
|
||||||
this.buffer.push(this.parseMessage(e.data));
|
this.buffer.push(this.parseMessage(e.data));
|
||||||
flushBuffer();
|
this.flushBuffer();
|
||||||
};
|
};
|
||||||
this.$once("hook:beforeDestroy", () => this.es.close());
|
this.$once("hook:beforeDestroy", () => this.es.close());
|
||||||
},
|
},
|
||||||
|
flushNow() {
|
||||||
|
this.messages.push(...this.buffer);
|
||||||
|
this.buffer = [];
|
||||||
|
},
|
||||||
async loadOlderLogs() {
|
async loadOlderLogs() {
|
||||||
if (this.messages.length < 300) return;
|
if (this.messages.length < 300) return;
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user