From 628a68f0202c92d7bb51398601c5a92ebfdd32dc Mon Sep 17 00:00:00 2001 From: Clement Denis Date: Wed, 8 Apr 2026 15:54:06 +0200 Subject: [PATCH 1/2] fix(deployement): Fix expand metrics --- web/pages/DeploymentPage.tsx | 115 +++++++++++++++++------------------ 1 file changed, 56 insertions(+), 59 deletions(-) diff --git a/web/pages/DeploymentPage.tsx b/web/pages/DeploymentPage.tsx index 5d952e6..0d17cbb 100644 --- a/web/pages/DeploymentPage.tsx +++ b/web/pages/DeploymentPage.tsx @@ -62,6 +62,7 @@ const toastSignal = new Signal< >( null, ) + function toast(message: string, type: 'info' | 'error' = 'info') { toastSignal.value = { message, type } setTimeout(() => (toastSignal.value = null), 3000) @@ -85,39 +86,32 @@ effect(() => { dep && schema.fetch({ url: dep }) }) +const activeTab = computed(() => { + const tab = url.params.tab as (keyof typeof TabViews) + return tab in TabViews ? tab : 'tables' +}) + effect(() => { - url.params.tab // clear expanded when params.tab change + activeTab.value // clear expanded when params.tab change navigate({ params: { expanded: null }, replace: true }) }) +async function sha(message: string) { + const data = new TextEncoder().encode(message) + const buff = await crypto.subtle.digest('SHA-1', data) + return new Uint8Array(buff).toHex() +} + const queryHash = new Signal('') effect(() => { const query = (url.params.q || '').trim() if (query) { - hashQuery(query).then((hash) => { - queryHash.value = hash - }) + sha(query).then((hash) => queryHash.value = hash) } else { queryHash.value = '' } }) -function sha(message: string) { - const data = new TextEncoder().encode(message) - return crypto.subtle.digest('SHA-1', data) -} - -function hashQuery(query: string) { - const hash = sha(query).then((hashBuffer) => { - const hashArray = Array.from(new Uint8Array(hashBuffer)) - const hashHex = hashArray.map((b) => b.toString(16).padStart(2, '0')).join( - '', - ) - return hashHex - }) - return hash -} - const onSave = () => { const query = (url.params.q || '').trim() if (query) { @@ -814,17 +808,15 @@ const TabButton = ( ) -function TabNavigation({ - activeTab = 'tables', -}: { activeTab?: 'tables' | 'queries' | 'logs' | 'metrics' }) { +function TabNavigation() { // Get column names from the currently selected table for tables tab + const tab = activeTab.value const selectedTableName = url.params.table || schema.data?.tables?.[0]?.table const selectedTable = schema.data?.tables?.find((t) => t.table === selectedTableName ) const tableColumnNames = selectedTable?.columns.map((c) => c.name) || [] - - const filterKeyOptions = activeTab === 'tables' ? tableColumnNames : [ + const filterKeyOptions = tab === 'tables' ? tableColumnNames : [ 'timestamp', 'trace_id', 'span_id', @@ -850,7 +842,7 @@ function TabNavigation({
- {(activeTab === 'tables' || activeTab === 'logs') && ( + {(tab === 'tables' || tab === 'logs') && ( )} - {activeTab !== 'logs' && ( + {tab !== 'logs' && ( runQuery(url.params.q || '') : undefined} class='btn btn-primary btn-sm' > - {activeTab === 'queries' + {tab === 'queries' ? : } )} - {activeTab !== 'queries' && activeTab !== 'metrics' && ( + {tab !== 'queries' && tab !== 'metrics' && ( <> - - + + )} - {activeTab === 'queries' && ( + {tab === 'queries' && ( <>