Skip to content

Commit e64004f

Browse files
committed
allow to clear logs
1 parent 559c6c0 commit e64004f

File tree

1 file changed

+44
-9
lines changed

1 file changed

+44
-9
lines changed

frontend/src/pages/services/service-logs.tsx

Lines changed: 44 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,63 @@
11
import { createComponent, Shade } from '@furystack/shades'
2-
import { Button, Icon, icons, PageContainer, PageHeader, Paper } from '@furystack/shades-common-components'
2+
import { Button, Icon, icons, NotyService, PageContainer, PageHeader, Paper } from '@furystack/shades-common-components'
33

44
import { LogViewer } from '../../components/log-viewer.js'
5+
import { ServicesApiClient } from '../../services/api-clients/services-api-client.js'
56

67
type ServiceLogsProps = {
78
serviceId: string
89
}
910

1011
export const ServiceLogs = Shade<ServiceLogsProps>({
1112
shadowDomName: 'shade-service-logs',
12-
render: ({ props }) => {
13+
render: ({ props, injector }) => {
14+
const api = injector.getInstance(ServicesApiClient)
15+
const notyService = injector.getInstance(NotyService)
16+
17+
const handleClearLogs = async () => {
18+
try {
19+
await api.call({
20+
method: 'DELETE',
21+
action: '/services/:id/logs',
22+
url: { id: props.serviceId },
23+
})
24+
notyService.emit('onNotyAdded', {
25+
title: 'Logs cleared',
26+
body: 'Service logs have been cleared.',
27+
type: 'success',
28+
})
29+
} catch (error) {
30+
notyService.emit('onNotyAdded', {
31+
title: 'Error',
32+
body: error instanceof Error ? error.message : 'Failed to clear logs',
33+
type: 'error',
34+
})
35+
}
36+
}
37+
1338
return (
1439
<PageContainer>
1540
<PageHeader
1641
icon="📋"
1742
title="Service Logs"
1843
actions={
19-
<Button
20-
variant="outlined"
21-
onclick={() => history.back()}
22-
startIcon={<Icon icon={icons.chevronLeft} size="small" />}
23-
>
24-
Back
25-
</Button>
44+
<div style={{ display: 'flex', gap: '8px' }}>
45+
<Button
46+
variant="outlined"
47+
color="error"
48+
onclick={() => void handleClearLogs()}
49+
startIcon={<Icon icon={icons.trash} size="small" />}
50+
>
51+
Clear Logs
52+
</Button>
53+
<Button
54+
variant="outlined"
55+
onclick={() => history.back()}
56+
startIcon={<Icon icon={icons.chevronLeft} size="small" />}
57+
>
58+
Back
59+
</Button>
60+
</div>
2661
}
2762
/>
2863
<Paper style={{ flex: '1', overflow: 'hidden' }}>

0 commit comments

Comments
 (0)