Skip to content

Commit 4b61941

Browse files
committed
Merge branch '436-activity-ui-improvements' into 'master'
fix: improvements for activity view (#436) Closes #436 See merge request postgres-ai/database-lab!610
2 parents 55e5760 + a146661 commit 4b61941

File tree

6 files changed

+55
-15
lines changed

6 files changed

+55
-15
lines changed

Diff for: ui/packages/ce/src/api/instances/getInstanceRetrieval.ts

+2-1
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,13 @@
66
*/
77

88
import { request } from 'helpers/request'
9+
import { formatInstanceRetrieval } from '@postgres.ai/shared/types/api/entities/instanceRetrieval'
910

1011
export const getInstanceRetrieval = async () => {
1112
const response = await request('/instance/retrieval')
1213

1314
return {
14-
response: response.ok ? response : null,
15+
response: response.ok ? formatInstanceRetrieval(await response.json()) : null,
1516
error: response.ok ? null : response,
1617
}
1718
}

Diff for: ui/packages/shared/pages/Instance/Info/Retrieval/RetrievalTable/index.tsx

+9-5
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ export const RetrievalTable = ({
2020
<Table>
2121
<TableHead>
2222
<TableRow>
23-
<TableCell>Activity on the {activity}</TableCell>
23+
<TableCell className={styles.tableSubtitle}>Activity on the {activity}</TableCell>
2424
</TableRow>
2525
</TableHead>
2626
<TableBody className={styles.tableBody}>
@@ -30,16 +30,20 @@ export const RetrievalTable = ({
3030
{Object.entries(item).map((val, index) => (
3131
<TableRow key={index} hover className={styles.tableRow}>
3232
<TableCell>
33-
{val[0]} : {val[1]}
33+
{val[0]}: {val[1]}
3434
</TableCell>
3535
</TableRow>
3636
))}
3737
</div>
3838
))
3939
) : (
40-
<TableRow className={styles.tableRow}>
41-
<TableCell>No activity on the {activity}</TableCell>
42-
</TableRow>
40+
<TableBody className={styles.tableBody}>
41+
<div>
42+
<TableRow className={styles.tableRow}>
43+
<TableCell>No activity on the {activity}</TableCell>
44+
</TableRow>
45+
</div>
46+
</TableBody>
4347
)}
4448
</TableBody>
4549
</Table>

Diff for: ui/packages/shared/pages/Instance/Info/Retrieval/RetrievalTable/styles.module.scss

+9-2
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,18 @@
1212
}
1313

1414
div {
15-
padding-bottom: 0.75rem;
15+
padding: 0.75rem 0;
1616
}
1717

1818
td {
1919
border-bottom: 0;
20-
padding: 12px 18px;
20+
padding: 0px 18px;
21+
font-size: 13px;
22+
font-family: 'Fira Code', monospace;
2123
}
2224
}
25+
26+
.tableSubtitle {
27+
font-size: 15px;
28+
font-weight: bold;
29+
}

Diff for: ui/packages/shared/pages/Instance/stores/Main.ts

+3-3
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ import { getTextFromUnknownApiError } from '@postgres.ai/shared/utils/api'
2323
import { dbSource } from 'types/api/entities/dbSource'
2424
import { GetFullConfig } from 'types/api/endpoints/getFullConfig'
2525
import { GetInstanceRetrieval } from 'types/api/endpoints/getInstanceRetrieval'
26-
import { InstanceRetrieval } from 'types/api/entities/instanceRetrieval'
26+
import { InstanceRetrievalType } from 'types/api/entities/instanceRetrieval'
2727

2828
const POLLING_TIME = 2000
2929

@@ -51,7 +51,7 @@ type Error = {
5151

5252
export class MainStore {
5353
instance: Instance | null = null
54-
instanceRetrieval: InstanceRetrieval | null = null
54+
instanceRetrieval: InstanceRetrievalType | null = null
5555
config: Config | null = null
5656
fullConfig?: string
5757
instanceError: Error | null = null
@@ -108,7 +108,7 @@ export class MainStore {
108108
})
109109

110110
if (response)
111-
this.instanceRetrieval = await response?.json()
111+
this.instanceRetrieval = response
112112

113113
if (error)
114114
this.instanceError = { message: await getTextFromUnknownApiError(error) }
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
1+
import { InstanceRetrievalType } from '@postgres.ai/shared/types/api/entities/instanceRetrieval'
2+
13
export type GetInstanceRetrieval = (args: { instanceId: string }) => Promise<{
2-
response: Response | null
4+
response: InstanceRetrievalType | null
35
error: Response | null
46
}>

Diff for: ui/packages/shared/types/api/entities/instanceRetrieval.ts

+29-3
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
export interface ActivityType {
22
user?: string
33
query?: string
4-
duration?: string
5-
wait_event_type?: string
6-
wait_event?: string
4+
duration?: number | string
5+
waitEventType?: string
6+
waitEvent?: string
77
}
88

99
export type InstanceRetrieval = {
@@ -18,3 +18,29 @@ export type InstanceRetrieval = {
1818
target: ActivityType[]
1919
}
2020
}
21+
22+
const replaceSinglequote = (string?: string) => string?.replace(/'/g, '')
23+
24+
const formatActivity = (activity: ActivityType[]) =>
25+
activity?.map((item) => {
26+
return {
27+
user: replaceSinglequote(item.user),
28+
query: replaceSinglequote(item.query),
29+
duration: replaceSinglequote(`${item.duration}ms`),
30+
'wait type/event': replaceSinglequote(
31+
`${item.waitEventType}/${item.waitEvent}`,
32+
),
33+
}
34+
})
35+
36+
export const formatInstanceRetrieval = (retrieval: InstanceRetrieval) => {
37+
return {
38+
...retrieval,
39+
activity: {
40+
source: formatActivity(retrieval.activity?.source),
41+
target: formatActivity(retrieval.activity?.target),
42+
},
43+
}
44+
}
45+
46+
export type InstanceRetrievalType = ReturnType<typeof formatInstanceRetrieval>

0 commit comments

Comments
 (0)