@@ -26,6 +26,9 @@ import { useNotificationsStore } from "@/store/notifications"
2626const cacheStore = useCacheStore ()
2727const notificationsStore = useNotificationsStore ()
2828
29+ const route = useRoute ()
30+ const router = useRouter ()
31+
2932const props = defineProps ({
3033 rollup: {
3134 type: Object ,
@@ -43,14 +46,15 @@ const tabs = ref([
4346 icon: " namespace" ,
4447 },
4548])
46- const activeTab = ref (tabs .value [0 ].name )
49+ const preselectedTab = route .query .tab && tabs .value .map ((tab ) => tab .name ).includes (route .query .tab ) ? route .query .tab : tabs .value [0 ].name
50+ const activeTab = ref (preselectedTab)
4751
4852const isRefetching = ref (false )
4953const namespaces = ref ([])
5054const blobs = ref ([])
5155
5256const page = ref (1 )
53- const pages = computed (() => activeTab .value === " Blobs" ? Math .ceil (props .rollup .blobs_count / 10 ) : 1 )
57+ const pages = computed (() => ( activeTab .value === " Blobs" ? Math .ceil (props .rollup .blobs_count / 10 ) : 1 ) )
5458
5559const handleNext = () => {
5660 page .value += 1
@@ -93,7 +97,8 @@ const getNamespaces = async () => {
9397}
9498
9599/** Initital fetch for blobs */
96- await getBlobs ()
100+ if (activeTab .value === " Blobs" ) await getBlobs ()
101+ if (activeTab .value === " Namespaces" ) await getNamespaces ()
97102
98103/** Refetch Blobs/Messages on new page */
99104watch (
@@ -115,6 +120,12 @@ watch(
115120watch (
116121 () => activeTab .value ,
117122 () => {
123+ router .replace ({
124+ query: {
125+ tab: activeTab .value ,
126+ },
127+ })
128+
118129 page .value = 1
119130
120131 switch (activeTab .value ) {
@@ -160,7 +171,7 @@ const handleCSVDownload = async (period) => {
160171 break
161172 }
162173 let to = parseInt (DateTime .now ().toMillis () / 1_000 )
163-
174+
164175 const { data } = await fetchRollupExportData ({
165176 id: props .rollup .id ,
166177 from: from,
@@ -180,13 +191,13 @@ const handleCSVDownload = async (period) => {
180191 return
181192 }
182193
183- const blob = new Blob ([data .value ], { type: ' text/csv;charset=utf-8;' })
194+ const blob = new Blob ([data .value ], { type: " text/csv;charset=utf-8;" })
184195 const link = document .createElement (" a" )
185196
186197 link .href = URL .createObjectURL (blob)
187198 link .download = ` ${ props .rollup .slug } -blobs-last-${ period} .csv`
188199
189- link .style .visibility = ' hidden'
200+ link .style .visibility = " hidden"
190201 document .body .appendChild (link)
191202 link .click ()
192203 document .body .removeChild (link)
@@ -200,7 +211,6 @@ const handleCSVDownload = async (period) => {
200211 },
201212 })
202213}
203-
204214< / script>
205215
206216< template>
@@ -307,7 +317,10 @@ const handleCSVDownload = async (period) => {
307317
308318 < Flex align= " center" justify= " between" >
309319 < Text size= " 12" weight= " 600" color= " tertiary" > Blob Fees Paid< / Text >
310- < AmountInCurrency : amount= " { value: rollup.fee }" : styles= " { amount: { color: 'secondary' }, currency: { color: 'secondary' } }" / >
320+ < AmountInCurrency
321+ : amount= " { value: rollup.fee }"
322+ : styles= " { amount: { color: 'secondary' }, currency: { color: 'secondary' } }"
323+ / >
311324 < / Flex>
312325
313326 < Flex align= " start" justify= " between" >
@@ -387,7 +400,7 @@ const handleCSVDownload = async (period) => {
387400 < Icon name= " arrow-right-stop" size= " 12" color= " primary" / >
388401 < / Button>
389402 < / Flex>
390- < / template>
403+ < / template>
391404 <!-- Namespaces Table -->
392405 < template v- if = " activeTab === 'Namespaces'" >
393406 < NamespacesTable v- if = " namespaces.length" : namespaces= " namespaces" / >
@@ -416,7 +429,6 @@ const handleCSVDownload = async (period) => {
416429 < Icon name= " arrow-right" size= " 12" color= " primary" / >
417430 < / Button>
418431 < / Flex>
419-
420432 < / template>
421433 < / Flex>
422434 < / Flex>
0 commit comments