1
0
mirror of https://github.com/lana-k/sqliteviz.git synced 2025-12-06 10:08:52 +08:00

add Logs component

This commit is contained in:
lana-k
2021-04-08 19:43:15 +02:00
parent 98cc09741c
commit 2acfc75da2
3 changed files with 88 additions and 0 deletions

View File

@@ -0,0 +1,5 @@
<svg width="20" height="20" viewBox="0 0 20 20" fill="none" xmlns="http://www.w3.org/2000/svg">
<path d="M9.99984 16.6667C6.32484 16.6667 3.33317 13.675 3.33317 10C3.33317 6.32502 6.32484 3.33335 9.99984 3.33335C13.6748 3.33335 16.6665 6.32502 16.6665 10C16.6665 13.675 13.6748 16.6667 9.99984 16.6667ZM9.99984 1.66669C8.90549 1.66669 7.82186 1.88224 6.81081 2.30102C5.79976 2.71981 4.8811 3.33364 4.10728 4.10746C2.54448 5.67027 1.6665 7.78988 1.6665 10C1.6665 12.2102 2.54448 14.3298 4.10728 15.8926C4.8811 16.6664 5.79976 17.2802 6.81081 17.699C7.82186 18.1178 8.90549 18.3334 9.99984 18.3334C12.21 18.3334 14.3296 17.4554 15.8924 15.8926C17.4552 14.3298 18.3332 12.2102 18.3332 10C18.3332 8.90567 18.1176 7.82204 17.6988 6.81099C17.28 5.79995 16.6662 4.88129 15.8924 4.10746C15.1186 3.33364 14.1999 2.71981 13.1889 2.30102C12.1778 1.88224 11.0942 1.66669 9.99984 1.66669Z" fill="#EF553B"/>
<rect x="6.36768" y="7.54855" width="1.67" height="8.60363" transform="rotate(-45 6.36768 7.54855)" fill="#EF553B"/>
<rect x="12.4517" y="6.36771" width="1.67" height="8.60363" transform="rotate(45 12.4517 6.36771)" fill="#EF553B"/>
</svg>

After

Width:  |  Height:  |  Size: 1.1 KiB

View File

@@ -0,0 +1,5 @@
<svg width="21" height="20" viewBox="0 0 21 20" fill="none" xmlns="http://www.w3.org/2000/svg">
<path d="M10.4998 16.6667C6.82484 16.6667 3.83317 13.675 3.83317 10C3.83317 6.32502 6.82484 3.33335 10.4998 3.33335C14.1748 3.33335 17.1665 6.32502 17.1665 10C17.1665 13.675 14.1748 16.6667 10.4998 16.6667ZM10.4998 1.66669C9.40549 1.66669 8.32186 1.88224 7.31081 2.30102C6.29976 2.71981 5.3811 3.33364 4.60728 4.10746C3.04448 5.67027 2.1665 7.78988 2.1665 10C2.1665 12.2102 3.04448 14.3298 4.60728 15.8926C5.3811 16.6664 6.29976 17.2802 7.31081 17.699C8.32186 18.1178 9.40549 18.3334 10.4998 18.3334C12.71 18.3334 14.8296 17.4554 16.3924 15.8926C17.9552 14.3298 18.8332 12.2102 18.8332 10C18.8332 8.90567 18.6176 7.82204 18.1988 6.81099C17.78 5.79995 17.1662 4.88129 16.3924 4.10746C15.6186 3.33364 14.6999 2.71981 13.6889 2.30102C12.6778 1.88224 11.5942 1.66669 10.4998 1.66669Z" fill="#00CC96"/>
<rect x="6.09717" y="10.2771" width="1.67" height="4.345" transform="rotate(-45 6.09717 10.2771)" fill="#00CC96"/>
<rect x="13.752" y="6.97589" width="1.67" height="7.74359" transform="rotate(45 13.752 6.97589)" fill="#00CC96"/>
</svg>

After

Width:  |  Height:  |  Size: 1.1 KiB

78
src/components/Logs.vue Normal file
View File

@@ -0,0 +1,78 @@
<template>
<div class="logs-container" ref="logsContainer">
<div v-for="(msg, index) in messages" :key="index" class="msg">
<img v-if="msg.type === 'error'" :src="require('@/assets/images/error.svg')">
<img v-if="msg.type === 'info'" :src="require('@/assets/images/info.svg')" width="20px">
<img v-if="msg.type === 'success'" :src="require('@/assets/images/success.svg')">
<loading-indicator v-if="msg.type === 'loading'" :progress="msg.progress" />
<span class="msg-text">{{ serializeMessage(msg) }}</span>
</div>
</div>
</template>
<script>
import LoadingIndicator from '@/components/LoadingIndicator'
export default {
name: 'logs',
props: ['messages'],
components: { LoadingIndicator },
watch: {
'messages.length': 'scrollToBottom'
},
mounted () {
this.scrollToBottom()
},
methods: {
async scrollToBottom () {
const container = this.$refs.logsContainer
if (container) {
await this.$nextTick()
container.scrollTop = container.scrollHeight
}
},
serializeMessage (msg) {
let result = ''
if (msg.row !== null && msg.row !== undefined) {
result += `Error in row ${msg.row}. `
}
result += msg.message
if (msg.hint) {
if (!(result[0] in ['.', '!', '?'])) {
result += '.'
}
result += ` ${msg.hint}`
}
return result
}
}
}
</script>
<style scoped>
.logs-container {
background-color: var(--color-white);
padding: 0 5px;
border-radius: 5px;
border: 1px solid var(--color-border-light);
box-sizing: border-box;
overflow-y: scroll;
}
.msg {
padding: 16px 7px;
border-bottom: 1px solid var(--color-border-light);
display: flex;
align-items: flex-start;
font-family: monospace;
}
.msg:last-child {
border-bottom: none;
}
.msg-text {
margin-left: 6px;
margin-top: 2px;
}
</style>