api-client/components/realtime/Log.vue

78 lines
1.5 KiB
Vue
Raw Normal View History

<template>
2020-12-11 16:54:34 +00:00
<div class="flex flex-col">
2021-07-18 07:47:58 +00:00
<div
class="
bg-primary
border-b border-dividerLight
flex flex-1
pl-4
top-0
z-10
sticky
items-center
justify-between
"
>
<label for="log" class="font-semibold py-2">{{ title }}</label>
2021-07-18 07:47:58 +00:00
</div>
2021-05-17 13:47:57 +00:00
<div ref="log" name="log" class="realtime-log">
<span v-if="log" class="space-y-2">
2021-05-17 13:47:57 +00:00
<span
2021-07-13 23:49:08 +00:00
v-for="(entry, index) in log"
:key="`entry-${index}`"
:style="{ color: entry.color }"
>@ {{ entry.ts }}{{ getSourcePrefix(entry.source)
}}{{ entry.payload }}</span
>
</span>
<span v-else>{{ $t("waiting_for_connection") }}</span>
</div>
</div>
</template>
2021-05-17 13:47:57 +00:00
<script>
import { getSourcePrefix } from "~/helpers/utils/string"
export default {
props: {
log: { type: Array, default: () => [] },
title: {
type: String,
default: "",
},
},
updated() {
this.$nextTick(function () {
if (this.$refs.log) {
this.$refs.log.scrollBy(0, this.$refs.log.scrollHeight + 100)
}
})
},
methods: {
getSourcePrefix,
},
}
</script>
<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;
2021-06-12 16:46:17 +00:00
@apply bg-primaryDark;
@apply text-secondary;
2020-09-22 17:06:37 +00:00
@apply overflow-auto;
2020-10-16 01:40:07 +00:00
height: 256px;
&,
span {
@apply font-mono font-semibold;
2020-09-22 17:06:37 +00:00
@apply select-text;
}
span {
2020-09-22 17:06:37 +00:00
@apply block;
2021-06-26 10:41:19 +00:00
@apply break-words break-all;
}
}
</style>