mirror of
https://github.com/amir20/dozzle.git
synced 2025-12-26 07:13:41 +01:00
* Fixes css to have full containers * Adds split panes * Fixes background color * Fixes splitter * Fixes tests * Adds more tests * Updates tests * Adds vuex * Moves splitpane to app * Moves the panes to app * Fixes columns with min-width * Update packages * Updates html to have better components * Updates npm packages * Fixes scrollar * Creates a scrollable view * Fixes App specs * Adds vuex for component * Updates to use splitpanes * Styles splitter * Removes fetch-mock
56 lines
1.1 KiB
Vue
56 lines
1.1 KiB
Vue
<template lang="html">
|
|
<div>
|
|
<slot v-bind:messages="messages"></slot>
|
|
</div>
|
|
</template>
|
|
|
|
<script>
|
|
let nextId = 0;
|
|
function parseMessage(data) {
|
|
const date = new Date(data.substring(0, 30));
|
|
const message = data.substring(30);
|
|
const key = nextId++;
|
|
return {
|
|
key,
|
|
date,
|
|
message
|
|
};
|
|
}
|
|
|
|
export default {
|
|
props: ["id"],
|
|
name: "LogEventSource",
|
|
data() {
|
|
return {
|
|
messages: []
|
|
};
|
|
},
|
|
created() {
|
|
this.es = null;
|
|
this.loadLogs(this.id);
|
|
},
|
|
methods: {
|
|
loadLogs(id) {
|
|
if (this.es) {
|
|
this.es.close();
|
|
this.messages = [];
|
|
this.es = null;
|
|
}
|
|
this.es = new EventSource(`${BASE_PATH}/api/logs/stream?id=${this.id}`);
|
|
this.es.onmessage = e => this.messages.push(parseMessage(e.data));
|
|
this.es.onerror = function(e) {
|
|
console.log("EventSource failed." + e);
|
|
};
|
|
this.$once("hook:beforeDestroy", () => this.es.close());
|
|
}
|
|
},
|
|
watch: {
|
|
id(newValue, oldValue) {
|
|
if (oldValue !== newValue) {
|
|
this.loadLogs(newValue);
|
|
}
|
|
}
|
|
}
|
|
};
|
|
</script>
|