api-client/components/realtime/Log.vue

56 lines
1.1 KiB
Vue
Raw Normal View History

<template>
2020-12-11 16:54:34 +00:00
<div class="flex flex-col">
<label for="log">{{ title }}</label>
<div name="log" class="realtime-log" ref="log">
<span v-if="log">
<span v-for="(logEntry, index) in log" :style="{ color: logEntry.color }" :key="index"
>@ {{ logEntry.ts }}{{ getSourcePrefix(logEntry.source) }}{{ logEntry.payload }}</span
>
</span>
<span v-else>{{ $t("waiting_for_connection") }}</span>
</div>
</div>
</template>
<style scoped lang="scss">
2020-09-22 17:06:37 +00:00
.realtime-log {
2020-12-11 16:54:34 +00:00
@apply p-4;
2020-09-22 17:06:37 +00:00
@apply bg-bgDarkColor;
@apply text-fgColor;
@apply overflow-auto;
2020-10-16 01:40:07 +00:00
height: 256px;
&,
span {
2020-09-22 17:06:37 +00:00
@apply font-mono;
@apply font-normal;
@apply select-text;
}
span {
2020-09-22 17:06:37 +00:00
@apply block;
@apply break-words;
@apply break-all;
}
}
</style>
<script>
import { getSourcePrefix } from "~/helpers/utils/string"
export default {
props: ["log", "title"],
methods: {
getSourcePrefix,
},
2020-10-21 06:50:32 +00:00
updated() {
2020-06-19 06:56:04 +00:00
this.$nextTick(function () {
if (this.$refs.log) {
this.$refs.log.scrollBy(0, this.$refs.log.scrollHeight + 100)
}
})
},
}
</script>