blob: 9458eb636bec576f64c8af7acf3d75a0b27bdf3c (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
|
import { faDownload, faSync, faTrash } from "@fortawesome/free-solid-svg-icons";
import React, { FunctionComponent, useCallback, useState } from "react";
import { Container, Row } from "react-bootstrap";
import { Helmet } from "react-helmet";
import { systemUpdateLogs } from "../../@redux/actions";
import { useSystemLogs } from "../../@redux/hooks";
import { useReduxAction } from "../../@redux/hooks/base";
import { SystemApi } from "../../apis";
import { AsyncOverlay, ContentHeader } from "../../components";
import { useBaseUrl } from "../../utilities";
import Table from "./table";
interface Props {}
const SystemLogsView: FunctionComponent<Props> = () => {
const logs = useSystemLogs();
const update = useReduxAction(systemUpdateLogs);
const [resetting, setReset] = useState(false);
const baseUrl = useBaseUrl(true);
const download = useCallback(() => {
window.open(`${baseUrl}bazarr.log`);
}, [baseUrl]);
return (
<AsyncOverlay ctx={logs}>
{({ content, state }) => (
<Container fluid>
<Helmet>
<title>Logs - Bazarr (System)</title>
</Helmet>
<ContentHeader>
<ContentHeader.Button
updating={state === "loading"}
icon={faSync}
onClick={update}
>
Refresh
</ContentHeader.Button>
<ContentHeader.Button icon={faDownload} onClick={download}>
Download
</ContentHeader.Button>
<ContentHeader.Button
updating={resetting}
icon={faTrash}
onClick={() => {
setReset(true);
SystemApi.deleteLogs().finally(() => {
setReset(false);
update();
});
}}
>
Empty
</ContentHeader.Button>
</ContentHeader>
<Row>
<Table logs={content ?? []}></Table>
</Row>
</Container>
)}
</AsyncOverlay>
);
};
export default SystemLogsView;
|