11<script setup lang="ts">
22import type { SessionContext } from ' ~~/shared/types'
3+ import type { ClientSettings } from ' ~/state/settings'
34import { useRpc } from ' #imports'
45import { useAsyncState } from ' @vueuse/core'
6+ import { settings } from ' ~/state/settings'
57
68const props = defineProps <{
79 session: SessionContext
810}>()
911
12+ const assetViewTpyes = [
13+ {
14+ label: ' List' ,
15+ value: ' list' ,
16+ icon: ' i-ph-list-duotone' ,
17+ },
18+ {
19+ label: ' Folder' ,
20+ value: ' folder' ,
21+ icon: ' i-ph-folder-duotone' ,
22+ },
23+ {
24+ label: ' Flamechart' ,
25+ value: ' flamechart' ,
26+ icon: ' i-ph-chart-donut-duotone' ,
27+ },
28+ ] as const
1029const rpc = useRpc ()
1130const { state : assets, isLoading } = useAsyncState (
1231 async () => {
@@ -16,26 +35,35 @@ const { state: assets, isLoading } = useAsyncState(
1635 },
1736 null ,
1837)
38+
39+ function toggleDisplay(type : ClientSettings [' assetViewType' ]) {
40+ settings .value .assetViewType = type
41+ }
1942 </script >
2043
2144<template >
2245 <VisualLoading v-if =" isLoading" />
23- <div p5 flex =" ~ col gap-4" >
24- Assets
25- <!--
26- WIP:
27- - Use tree view to show assets
28- - Show asssets detail on the right panel
29- - View of Flamechart with nanovis
30- -->
31- <template v-for =" asset of assets " :key =" asset .filename " >
32- <pre >{{
33- {
34- filename: asset.filename,
35- size: asset.size,
36- chunk: asset.chunk_id,
37- }
38- }}</pre >
46+ <div v-else p4 flex =" ~ col gap-4" >
47+ <div flex =" ~ gap-2" >
48+ <button
49+ v-for =" viewType of assetViewTpyes"
50+ :key =" viewType.value"
51+ btn-action
52+ :class =" settings.assetViewType === viewType.value ? 'bg-active' : 'grayscale op50'"
53+ @click =" toggleDisplay(viewType.value)"
54+ >
55+ <div :class =" viewType.icon" />
56+ {{ viewType.label }}
57+ </button >
58+ </div >
59+ <template v-if =" settings .assetViewType === ' list' " >
60+ <AssetsList v-if =" assets?.length" :assets =" assets" :session =" session" />
61+ </template >
62+ <template v-else-if =" settings .assetViewType === ' folder' " >
63+ <AssetsFolder v-if =" assets?.length" :assets =" assets" :session =" session" />
64+ </template >
65+ <template v-else >
66+ WIP: Flamechart view
3967 </template >
4068 </div >
4169</template >
0 commit comments