-
Notifications
You must be signed in to change notification settings - Fork 19
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
11 changed files
with
172 additions
and
101 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,79 @@ | ||
<script setup lang="ts"> | ||
import Card from 'primevue/card' | ||
import type { FileInfo } from '@/api/v0' | ||
import { formatNumber, formatBytes } from '@/utils' | ||
defineProps<{ | ||
name: string | ||
files: FileInfo[] | null | ||
}>() | ||
defineEmits<{ | ||
(e: 'click', file: FileInfo, index: number): void, | ||
}>() | ||
</script> | ||
<template> | ||
<Card> | ||
<template #title> | ||
<div class="flex-row-center"> | ||
<lable>{{ name }}</lable> | ||
</div> | ||
</template> | ||
<template #content> | ||
<template v-if="!files"> | ||
<i>Loading...</i> | ||
</template> | ||
<template v-else> | ||
<div class="file-list-box"> | ||
<div v-for="(file, i) in files" v-key="file.name" class="file-elem"> | ||
<div class="file-name" @click="$emit('click', file, i)"> | ||
{{file.name}} | ||
</div> | ||
<div class="flex-row-center"> | ||
<div class="file-size">{{formatBytes(file.size)}}</div> | ||
<slot :index="i" :file="file" /> | ||
</div> | ||
</div> | ||
</div> | ||
</template> | ||
</template> | ||
</Card> | ||
</template> | ||
<style scoped> | ||
.file-list-box { | ||
display: flex; | ||
flex-direction: column; | ||
width: 100%; | ||
} | ||
.file-elem { | ||
display: flex; | ||
flex-direction: row; | ||
justify-content: space-between; | ||
width: 100%; | ||
padding: 0.5rem 0.2rem; | ||
border-bottom: var(--surface-border) 1px solid; | ||
} | ||
.file-name { | ||
width: 10rem; | ||
padding-right: 0.3rem; | ||
font-weight: bold; | ||
cursor: pointer; | ||
user-select: all; | ||
} | ||
.file-name:hover { | ||
color: var(--surface-900); | ||
text-decoration: underline; | ||
} | ||
.file-size { | ||
width: 5rem; | ||
margin-right: 0.3rem; | ||
font-weight: 200; | ||
user-select: none; | ||
} | ||
</style> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
<script setup lang="ts"> | ||
import { ref, inject, onMounted, type Ref } from 'vue' | ||
import Button from 'primevue/button' | ||
import { useToast } from 'primevue/usetoast' | ||
import FileListCard from '@/components/FileListCard.vue' | ||
import { | ||
getLogFiles, | ||
getLogFile, | ||
getLogFileURL, | ||
type FileInfo, | ||
} from '@/api/v0' | ||
import { tr } from '@/lang' | ||
const toast = useToast() | ||
const token = inject('token') as Ref<string | null> | ||
const logList = ref<FileInfo[] | null>(null) | ||
async function refreshFileList(): Promise<void> { | ||
if (!token.value) { | ||
return | ||
} | ||
logList.value = await getLogFiles(token.value) | ||
} | ||
async function openFile(file: FileInfo): Promise<void> { | ||
if (!token.value) { | ||
return | ||
} | ||
const buf = await getLogFile(token.value, file.name, true) | ||
console.log(buf) | ||
alert('TODO: display log file content') | ||
} | ||
async function downloadLogFile(file: FileInfo): Promise<void> { | ||
if (!token.value) { | ||
return | ||
} | ||
const u = await getLogFileURL(token.value, file.name, false) | ||
window.open(u) | ||
} | ||
onMounted(() => { | ||
refreshFileList() | ||
}) | ||
</script> | ||
<template> | ||
<div> | ||
<h1> | ||
{{ tr('title.logs') }} | ||
</h1> | ||
<FileListCard class="filelist-card" :name="'logs/'" :files="logList" v-slot="{ index, file }" @click="openFile"> | ||
<Button icon="pi pi-file-export" @click="downloadLogFile(file)"/> | ||
</FileListCard> | ||
</div> | ||
</template> | ||
<style scoped> | ||
.filelist-card { | ||
} | ||
</style> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters