feat: added logs tab to display server messages
This commit is contained in:
parent
15e279a2a5
commit
2ab0620e02
File diff suppressed because one or more lines are too long
@ -45,7 +45,6 @@ import TheContextMenu from '@components/globals/TheContextMenu.vue'
|
|||||||
import TheTrackPreview from '@components/globals/TheTrackPreview.vue'
|
import TheTrackPreview from '@components/globals/TheTrackPreview.vue'
|
||||||
import TheQualityModal from '@components/globals/TheQualityModal.vue'
|
import TheQualityModal from '@components/globals/TheQualityModal.vue'
|
||||||
// import ConfirmModal from '@components/globals/ConfirmModal.vue'
|
// import ConfirmModal from '@components/globals/ConfirmModal.vue'
|
||||||
|
|
||||||
import TheSidebar from '@components/TheSidebar.vue'
|
import TheSidebar from '@components/TheSidebar.vue'
|
||||||
import TheSearchBar from '@components/TheSearchBar.vue'
|
import TheSearchBar from '@components/TheSearchBar.vue'
|
||||||
import TheContent from '@components/TheContent.vue'
|
import TheContent from '@components/TheContent.vue'
|
||||||
@ -69,7 +68,7 @@ export default {
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
mounted() {
|
mounted() {
|
||||||
socket.addEventListener('open', event => {
|
socket.addEventListener('open', () => {
|
||||||
console.log('Connected to WebSocket')
|
console.log('Connected to WebSocket')
|
||||||
this.isSocketConnected = true
|
this.isSocketConnected = true
|
||||||
})
|
})
|
||||||
|
46
src/components/pages/Logs.vue
Normal file
46
src/components/pages/Logs.vue
Normal file
@ -0,0 +1,46 @@
|
|||||||
|
<template>
|
||||||
|
<div class="logs-container">
|
||||||
|
<h1 class="mb-8 text-5xl capitalize">{{ $t('sidebar.logs') }}</h1>
|
||||||
|
|
||||||
|
<table class="w-full text-center">
|
||||||
|
<tr>
|
||||||
|
<th></th>
|
||||||
|
<th class="pr-5 h-12">Event</th>
|
||||||
|
<th>Data</th>
|
||||||
|
</tr>
|
||||||
|
<tr v-for="(message, i) of logMessages" :key="i">
|
||||||
|
<td class="count"></td>
|
||||||
|
<td class="pr-5 w-1/3">{{ message.key }}</td>
|
||||||
|
<td class="w-2/3">{{ message.data || 'Empty' }}</td>
|
||||||
|
</tr>
|
||||||
|
</table>
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script>
|
||||||
|
import { useLogs } from '@/use/logs'
|
||||||
|
import { computed } from '@vue/composition-api'
|
||||||
|
|
||||||
|
export default {
|
||||||
|
name: 'Logs',
|
||||||
|
setup() {
|
||||||
|
const messages = useLogs()
|
||||||
|
const logMessages = computed(() => messages.value.slice(0, 50).reverse())
|
||||||
|
|
||||||
|
return {
|
||||||
|
logMessages
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<style scoped>
|
||||||
|
.logs-container {
|
||||||
|
counter-reset: logs;
|
||||||
|
}
|
||||||
|
|
||||||
|
.count::before {
|
||||||
|
content: counter(logs);
|
||||||
|
counter-increment: logs;
|
||||||
|
}
|
||||||
|
</style>
|
@ -41,6 +41,13 @@ export const links = [
|
|||||||
icon: 'settings',
|
icon: 'settings',
|
||||||
label: 'sidebar.settings'
|
label: 'sidebar.settings'
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
name: 'logs',
|
||||||
|
ariaLabel: 'logs',
|
||||||
|
routerName: 'Logs',
|
||||||
|
icon: 'description',
|
||||||
|
label: 'sidebar.logs'
|
||||||
|
},
|
||||||
{
|
{
|
||||||
name: 'about',
|
name: 'about',
|
||||||
ariaLabel: 'info',
|
ariaLabel: 'info',
|
||||||
|
@ -399,6 +399,7 @@ const en = {
|
|||||||
favorites: 'favorites',
|
favorites: 'favorites',
|
||||||
linkAnalyzer: 'link analyzer',
|
linkAnalyzer: 'link analyzer',
|
||||||
settings: 'settings',
|
settings: 'settings',
|
||||||
|
logs: 'logs',
|
||||||
about: 'about'
|
about: 'about'
|
||||||
},
|
},
|
||||||
tracklist: {
|
tracklist: {
|
||||||
|
@ -402,6 +402,7 @@ const it = {
|
|||||||
favorites: 'preferiti',
|
favorites: 'preferiti',
|
||||||
linkAnalyzer: 'analizza link',
|
linkAnalyzer: 'analizza link',
|
||||||
settings: 'impostazioni',
|
settings: 'impostazioni',
|
||||||
|
logs: 'log',
|
||||||
about: 'info'
|
about: 'info'
|
||||||
},
|
},
|
||||||
tracklist: {
|
tracklist: {
|
||||||
|
@ -11,9 +11,11 @@ import Errors from '@components/pages/Errors.vue'
|
|||||||
import Favorites from '@components/pages/Favorites.vue'
|
import Favorites from '@components/pages/Favorites.vue'
|
||||||
import Home from '@components/pages/Home.vue'
|
import Home from '@components/pages/Home.vue'
|
||||||
import LinkAnalyzer from '@components/pages/LinkAnalyzer.vue'
|
import LinkAnalyzer from '@components/pages/LinkAnalyzer.vue'
|
||||||
|
import Logs from '@components/pages/Logs.vue'
|
||||||
import Search from '@components/pages/Search.vue'
|
import Search from '@components/pages/Search.vue'
|
||||||
import Settings from '@components/pages/Settings.vue'
|
import Settings from '@components/pages/Settings.vue'
|
||||||
import Tracklist from '@components/pages/Tracklist.vue'
|
import Tracklist from '@components/pages/Tracklist.vue'
|
||||||
|
|
||||||
import { fetchData } from '@/utils/api'
|
import { fetchData } from '@/utils/api'
|
||||||
import EventBus from '@/utils/EventBus'
|
import EventBus from '@/utils/EventBus'
|
||||||
|
|
||||||
@ -77,6 +79,11 @@ const routes = [
|
|||||||
name: 'Errors',
|
name: 'Errors',
|
||||||
component: Errors
|
component: Errors
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
path: '/logs',
|
||||||
|
name: 'Logs',
|
||||||
|
component: Logs
|
||||||
|
},
|
||||||
{
|
{
|
||||||
path: '/link-analyzer',
|
path: '/link-analyzer',
|
||||||
name: 'Link Analyzer',
|
name: 'Link Analyzer',
|
||||||
|
14
src/use/logs.js
Normal file
14
src/use/logs.js
Normal file
@ -0,0 +1,14 @@
|
|||||||
|
import { ref } from '@vue/composition-api'
|
||||||
|
import { socket } from '@/utils/socket'
|
||||||
|
|
||||||
|
const messages = ref([])
|
||||||
|
|
||||||
|
socket.addEventListener('message', event => {
|
||||||
|
const newMessage = JSON.parse(event.data)
|
||||||
|
|
||||||
|
messages.value.push(Object.freeze(newMessage))
|
||||||
|
})
|
||||||
|
|
||||||
|
export const useLogs = () => {
|
||||||
|
return messages
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user