make all frontend functions works (#466)

This commit is contained in:
Sijie.Sun
2024-11-10 11:06:58 +08:00
committed by GitHub
parent e948dbfcc1
commit 88e6de9d7e
36 changed files with 1039 additions and 483 deletions
@@ -0,0 +1,35 @@
<script setup lang="ts">
import { useI18n } from 'vue-i18n';
import { EventType } from '../types/network'
import { computed } from 'vue';
import { Fieldset } from 'primevue';
const props = defineProps<{
event: {
[key: string]: any
}
}>()
const { t } = useI18n()
const eventKey = computed(() => {
const key = Object.keys(props.event)[0]
return Object.keys(EventType).includes(key) ? key : 'Unknown'
})
const eventValue = computed(() => {
const value = props.event[eventKey.value]
return typeof value === 'object' ? value : value
})
</script>
<template>
<Fieldset :legend="t(`event.${eventKey}`)">
<template v-if="eventKey !== 'Unknown'">
<div v-if="event.DhcpIpv4Changed">
{{ `${eventValue[0]} -> ${eventValue[1]}` }}
</div>
<pre v-else>{{ eventValue }}</pre>
</template>
<pre v-else>{{ eventValue }}</pre>
</Fieldset>
</template>
@@ -181,7 +181,7 @@ const myNodeInfoChips = computed(() => {
const listeners = my_node_info.listeners
for (const [idx, listener] of listeners?.entries()) {
chips.push({
label: `Listener ${idx}: ${listener}`,
label: `Listener ${idx}: ${listener.url}`,
icon: '',
} as Chip)
}
@@ -295,7 +295,7 @@ function showEventLogs() {
if (!detail)
return
dialogContent.value = detail.events
dialogContent.value = detail.events.map((event: string) => JSON.parse(event))
dialogHeader.value = 'event_log'
dialogVisible.value = true
}
@@ -309,10 +309,11 @@ function showEventLogs() {
</ScrollPanel>
<Timeline v-else :value="dialogContent">
<template #opposite="slotProps">
<small class="text-surface-500 dark:text-surface-400">{{ useTimeAgo(Date.parse(slotProps.item[0])) }}</small>
<small class="text-surface-500 dark:text-surface-400">{{ useTimeAgo(Date.parse(slotProps.item.time))
}}</small>
</template>
<template #content="slotProps">
<HumanEvent :event="slotProps.item[1]" />
<HumanEvent :event="slotProps.item.event" />
</template>
</Timeline>
</Dialog>