1
0
Fork 0
mirror of https://github.com/jellyfin/jellyfin-web synced 2025-03-30 19:56:21 +00:00

Move server logs to mui

This commit is contained in:
viown 2025-01-14 01:57:43 +03:00
parent 30204a4db5
commit 941da45faa
3 changed files with 26 additions and 22 deletions

View file

@ -6,7 +6,7 @@ import type { AxiosRequestConfig } from 'axios';
const fetchServerLogs = async (api?: Api, options?: AxiosRequestConfig) => { const fetchServerLogs = async (api?: Api, options?: AxiosRequestConfig) => {
if (!api) { if (!api) {
console.error('[useLogEntries] No API instance available'); console.error('[useServerLogs] No API instance available');
return; return;
} }
@ -19,7 +19,7 @@ export const useServerLogs = () => {
const { api } = useApi(); const { api } = useApi();
return useQuery({ return useQuery({
queryKey: [ 'LogEntries' ], queryKey: [ 'ServerLogs' ],
queryFn: ({ signal }) => fetchServerLogs(api, { signal }), queryFn: ({ signal }) => fetchServerLogs(api, { signal }),
enabled: !!api enabled: !!api
}); });

View file

@ -1,7 +1,7 @@
import type { LogFile } from '@jellyfin/sdk/lib/generated-client/models/log-file';
import LinkButton from 'elements/emby-button/LinkButton';
import { useApi } from 'hooks/useApi';
import React, { FunctionComponent } from 'react'; import React, { FunctionComponent } from 'react';
import type { LogFile } from '@jellyfin/sdk/lib/generated-client/models/log-file';
import { Card, CardActionArea, CardContent, ListItemText } from '@mui/material';
import { useApi } from 'hooks/useApi';
import datetime from 'scripts/datetime'; import datetime from 'scripts/datetime';
type LogItemProps = { type LogItemProps = {
@ -12,7 +12,7 @@ const LogItem: FunctionComponent<LogItemProps> = ({ logFile }: LogItemProps) =>
const { api } = useApi(); const { api } = useApi();
const getLogFileUrl = () => { const getLogFileUrl = () => {
if (!api) return; if (!api) return '';
let url = api.basePath + '/System/Logs/Log'; let url = api.basePath + '/System/Logs/Log';
@ -28,12 +28,18 @@ const LogItem: FunctionComponent<LogItemProps> = ({ logFile }: LogItemProps) =>
}; };
return ( return (
<LinkButton href={getLogFileUrl()} target='_blank' rel='noreferrer' className='listItem listItem-border' style={{ color: 'inherit' }}> <Card>
<div className='listItemBody two-line'> <CardActionArea href={getLogFileUrl()} target='_blank'>
<h3 className='listItemBodyText' dir='ltr' style={{ textAlign: 'left' }}>{logFile.Name}</h3> <CardContent>
<div className='listItemBodyText secondary'>{getDate()}</div> <ListItemText
</div> primary={logFile.Name}
</LinkButton> primaryTypographyProps={{ variant: 'h3' }}
secondary={getDate()}
secondaryTypographyProps={{ variant: 'body1' }}
/>
</CardContent>
</CardActionArea>
</Card>
); );
}; };

View file

@ -121,16 +121,14 @@ const Logs = () => {
</Button> </Button>
</Stack> </Stack>
</Form> </Form>
<div className='serverLogs readOnlyContent'> <Stack className='serverLogs readOnlyContent' spacing={1} sx={{ mt: 1 }}>
<div className='paperList'> {logs?.map(log => {
{logs?.map(log => { return <LogItem
return <LogItem key={log.Name}
key={log.Name} logFile={log}
logFile={log} />;
/>; })}
})} </Stack>
</div>
</div>
</Box> </Box>
</Page> </Page>
); );