Skip to content
This repository was archived by the owner on May 13, 2025. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 16 additions & 10 deletions src/hooks/useAlertsEditor.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,23 @@ import { notifyError, notifySuccess } from '@/utils/notification';
import { AxiosError, isAxiosError } from 'axios';

export const useAlertsEditor = (streamName: string) => {
const { mutate: updateLogStreamAlerts } = useMutation((data: any) => putLogStreamAlerts(streamName, data), {
onSuccess: () => notifySuccess({ message: 'Updated Successfully' }),
onError: (data: AxiosError) => {
if (isAxiosError(data) && data.response) {
const error = data.response?.data as string;
typeof error === 'string' && notifyError({ message: error });
} else if (data.message && typeof data.message === 'string') {
notifyError({ message: data.message });
}
const { mutate: updateLogStreamAlerts } = useMutation(
(data: { config: any; onSuccess?: () => void }) => putLogStreamAlerts(streamName, data.config),
{
onSuccess: (_data, variables) => {
variables.onSuccess && variables.onSuccess();
notifySuccess({ message: 'Updated Successfully' });
},
onError: (data: AxiosError) => {
if (isAxiosError(data) && data.response) {
const error = data.response?.data as string;
typeof error === 'string' && notifyError({ message: error });
} else if (data.message && typeof data.message === 'string') {
notifyError({ message: data.message });
}
},
},
});
);

return {
updateLogStreamAlerts,
Expand Down
26 changes: 16 additions & 10 deletions src/hooks/useRetentionEditor.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,23 @@ import { notifyError, notifySuccess } from '@/utils/notification';
import { AxiosError, isAxiosError } from 'axios';

export const useRetentionEditor = (streamName: string) => {
const { mutate: updateLogStreamRetention } = useMutation((data: any) => putLogStreamRetention(streamName, data), {
onSuccess: () => notifySuccess({ message: 'Updated Successfully' }),
onError: (data: AxiosError) => {
if (isAxiosError(data) && data.response) {
const error = data.response?.data as string;
typeof error === 'string' && notifyError({ message: error });
} else if (data.message && typeof data.message === 'string') {
notifyError({ message: data.message });
}
const { mutate: updateLogStreamRetention } = useMutation(
(data: { config: any; onSuccess?: () => void }) => putLogStreamRetention(streamName, data.config),
{
onSuccess: (_data, variables) => {
notifySuccess({ message: 'Updated Successfully' });
variables.onSuccess && variables.onSuccess();
},
onError: (data: AxiosError) => {
if (isAxiosError(data) && data.response) {
const error = data.response?.data as string;
typeof error === 'string' && notifyError({ message: error });
} else if (data.message && typeof data.message === 'string') {
notifyError({ message: data.message });
}
},
},
});
);

return {
updateLogStreamRetention,
Expand Down
2 changes: 1 addition & 1 deletion src/pages/Logs/AlertsModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ const AlertsModal = () => {
} catch (e) {
return notifyError({ message: 'Unable to parse config' });
}
updateLogStreamAlerts(parsedConfig);
updateLogStreamAlerts({config: parsedConfig, onSuccess: closeAlertsModal});
} else {
return notifyError({ message: 'Unable to parse config' });
}
Expand Down
111 changes: 59 additions & 52 deletions src/pages/Logs/LogTable.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ const TotalLogsCount = (props: TotalLogsCountProps) => {

const renderTotalCount = useCallback(() => (<Tooltip label={totalCount}><Text>{HumanizeNumber(totalCount)}</Text></Tooltip>), [totalCount]);
return (
<Stack style={{ alignItems: 'center', justifyContent: 'center', flexDirection: 'row' }} gap={6}>
<Stack style={{ alignItems: 'center', justifyContent: 'center', flexDirection: 'row'}} gap={6}>
<Text>{`Showing ${loadedCount < LOAD_LIMIT ? loadedCount : LOAD_LIMIT} out of`}</Text>
{renderTotalCount()}
</Stack>
Expand Down Expand Up @@ -498,57 +498,64 @@ const LogTable: FC = () => {
</Center>
)}
<Box className={tableStyles.footerContainer}>
<TotalLogsCount totalCount={totalCount} loadedCount={loadedCount} />
{!loading && !logsLoading ? (
<Pagination.Root
total={pageLogData?.totalPages || 1}
value={pageLogData?.page || 1}
onChange={(page) => {
goToPage(page, pageLogData?.limit || 1);
pagination.setPage(page);
}}>
<Group gap={5} justify="center">
<Pagination.First
onClick={() => {
if (pageOffset !== 0) setPageOffset((value) => value - loadLimit);
}}
disabled={pageOffset === 0}
/>
<Pagination.Previous />
{pagination.range.map((page) => {
if (page === 'dots') {
return <Pagination.Dots key={page} />;
} else {
return (
<Pagination.Control
value={page}
key={page}
active={pageLogData?.page === page}
onClick={() => {
goToPage(page);
pagination.setPage(page);
}}>
{pageLogData?.limit ? page + pageOffset / pageLogData?.limit ?? 1 : page}
</Pagination.Control>
);
}
})}

<Pagination.Next />
<Pagination.Last
onClick={() => {
setPageOffset((value) => {
return value + loadLimit;
});
}}
disabled={false}
/>
</Group>
</Pagination.Root>
) : (
<Loader variant="dots" />
)}
<LimitControl value={pageLogData?.limit || 0} onChange={setPageLimit} />
<Stack w="100%" justify="center" align="flex-start">
<TotalLogsCount totalCount={totalCount} loadedCount={loadedCount} />
</Stack>
<Stack w="100%" justify="center">
{!loading && !logsLoading ? (
<Pagination.Root
total={pageLogData?.totalPages || 1}
value={pageLogData?.page || 1}
onChange={(page) => {
goToPage(page, pageLogData?.limit || 1);
pagination.setPage(page);
}}>
<Group gap={5} justify="center">
<Pagination.First
onClick={() => {
if (pageOffset !== 0) setPageOffset((value) => value - loadLimit);
}}
disabled={pageOffset === 0}
/>
<Pagination.Previous />
{pagination.range.map((page) => {
if (page === 'dots') {
return <Pagination.Dots key={page} />;
} else {
return (
<Pagination.Control
value={page}
key={page}
active={pageLogData?.page === page}
onClick={() => {
goToPage(page);
pagination.setPage(page);
}}>
{pageLogData?.limit ? page + pageOffset / pageLogData?.limit ?? 1 : page}
</Pagination.Control>
);
}
})}
<Pagination.Next />
<Pagination.Last
onClick={() => {
setPageOffset((value) => {
return value + loadLimit;
});
}}
disabled={false}
/>
</Group>
</Pagination.Root>
) : (
<Stack w="100%" align="center">
<Loader variant="dots" />
</Stack>
)}
</Stack>
<Stack w="100%" align="flex-end">
<LimitControl value={pageLogData?.limit || 0} onChange={setPageLimit} />
</Stack>
</Box>
</Box>
);
Expand Down
2 changes: 1 addition & 1 deletion src/pages/Logs/QueryCodeEditor.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ const QueryCodeEditor: FC = () => {
</Stack>
</ScrollArea>
<Stack className={queryCodeStyles.footer} style={{ alignItems: 'center' }}>
<Button onClick={resetQuerySearch} disabled={!isSqlSearchActive}>
<Button onClick={resetQuerySearch} disabled={!isSqlSearchActive} variant='outline'>
Clear
</Button>
<Button onClick={() => runQuery(query)}>Apply</Button>
Expand Down
4 changes: 2 additions & 2 deletions src/pages/Logs/RetentionModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ const RententionModal = () => {
const { handleCacheToggle, isCacheEnabled } = useCacheToggle(currentStream);

const { getLogRetentionData } = useGetRetention(currentStream);
const {updateLogStreamRetention} = useRetentionEditor(currentStream);
const { updateLogStreamRetention } = useRetentionEditor(currentStream);

const switchStyles = {
track: isCacheEnabled ? classes.trackStyle : {},
Expand All @@ -35,7 +35,7 @@ const RententionModal = () => {
} catch (e) {
return notifyError({ message: 'Unable to parse config' });
}
updateLogStreamRetention(parsedConfig);
updateLogStreamRetention({ config: parsedConfig, onSuccess: closeRetentionModal });
} else {
return notifyError({ message: 'Unable to parse config' });
}
Expand Down