Skip to content
This repository was archived by the owner on Apr 5, 2024. It is now read-only.

Commit 84df00b

Browse files
committed
Remove Logout from Health
1 parent 92c9b79 commit 84df00b

File tree

1 file changed

+108
-124
lines changed

1 file changed

+108
-124
lines changed
Lines changed: 108 additions & 124 deletions
Original file line numberDiff line numberDiff line change
@@ -1,145 +1,129 @@
11
import React, { useEffect, useState } from "react";
22
import logo from "../../../assets/images/logos/logo.png";
3-
import {
4-
Button,
5-
Table,
6-
Container,
7-
OverlayTrigger,
8-
Tooltip,
9-
} from "react-bootstrap";
10-
import {
11-
callBackendHealth,
12-
DataIntegrity,
13-
SystemHealthData,
14-
} from "../../../background/api/api";
3+
import { Container, OverlayTrigger, Table, Tooltip } from "react-bootstrap";
4+
import { callBackendHealth, DataIntegrity, SystemHealthData } from "../../../background/api/api";
155
import { audioOnOff, setAudioVolumeByID } from "../../../background/methods/sound";
16-
import { logout } from "../../../background/api/auth";
176
import { getDurationAsString } from "../../../background/methods/dataTypes/time";
187
import { hasKey } from "../../../background/methods/dataTypes/objects/ObjectKeysTS";
198
import { formatBytes } from "../../../background/methods/dataTypes/bytes";
209
import { FFLoading } from "../../basicElements/Loading";
2110
import traffic_light from "../../../assets/images/icons/material.io/traffic_light.svg";
2211

2312
export default function Health() {
24-
const [systemHealthData, setSystemHealthData] = useState<
25-
SystemHealthData | null | "loading"
26-
>("loading");
27-
const errorMsg = "not reachable";
13+
const [systemHealthData, setSystemHealthData] = useState<SystemHealthData | null | "loading">("loading");
14+
const errorMsg = "not reachable";
2815

29-
useEffect(() => {
30-
updateVariables();
31-
}, []);
16+
useEffect(() => {
17+
updateVariables();
18+
}, []);
3219

33-
useEffect(() => {
34-
const timer = setTimeout(() => {
35-
updateVariables();
36-
}, 60000);
37-
// Clear timeout if the component is unmounted
38-
return () => clearTimeout(timer);
39-
});
20+
useEffect(() => {
21+
const timer = setTimeout(() => {
22+
updateVariables();
23+
}, 60000);
24+
// Clear timeout if the component is unmounted
25+
return () => clearTimeout(timer);
26+
});
4027

41-
function updateVariables(): void {
42-
Promise.all([callBackendHealth()])
43-
.then(([data]) => {
44-
setSystemHealthData(data);
45-
})
46-
.catch(() => {
47-
setSystemHealthData(null);
48-
});
49-
}
50-
51-
function getPathOfDataIntegrity(dataIntegrity: string): string {
52-
if (hasKey(DataIntegrity, dataIntegrity)) {
53-
return DataIntegrity[dataIntegrity];
28+
function updateVariables(): void {
29+
Promise.all([callBackendHealth()])
30+
.then(([data]) => {
31+
setSystemHealthData(data);
32+
})
33+
.catch(() => {
34+
setSystemHealthData(null);
35+
});
5436
}
55-
console.log("[HEALTH] Couldn't parse SystemHealth string to enum.");
56-
return errorMsg;
57-
}
5837

59-
function HealthContainer(): JSX.Element {
60-
if (systemHealthData === null) {
61-
return <p>{errorMsg}</p>;
38+
function getPathOfDataIntegrity(dataIntegrity: string): string {
39+
if (hasKey(DataIntegrity, dataIntegrity)) {
40+
return DataIntegrity[dataIntegrity];
41+
}
42+
console.log("[HEALTH] Couldn't parse SystemHealth string to enum.");
43+
return errorMsg;
6244
}
63-
if (systemHealthData === "loading") {
64-
return <FFLoading />;
65-
} else {
66-
return (
67-
<Container>
68-
<div>
69-
<Table striped bordered hover id={"ff-heath-table"}>
70-
<thead>
71-
<tr>
72-
<th>System Health</th>
73-
</tr>
74-
</thead>
75-
<tbody>
76-
<tr>
77-
<td>Deployment Type</td>
78-
<td>{systemHealthData.deployment}</td>
79-
</tr>
80-
<tr>
81-
<td>Version</td>
82-
<td>{systemHealthData.version}</td>
83-
</tr>
84-
<tr>
85-
<td>Uptime</td>
86-
<td>
87-
{getDurationAsString(systemHealthData.uptimeInSeconds)}
88-
</td>
89-
</tr>
90-
<tr>
91-
<td>Usercount</td>
92-
<td>{systemHealthData.userCount}</td>
93-
</tr>
94-
<tr>
95-
<td>Used Storage</td>
96-
<td>{formatBytes(systemHealthData.usedStorageInBytes)}</td>
97-
</tr>
98-
<tr>
99-
<td>Data Integrity</td>
100-
<td>
101-
<OverlayTrigger
102-
placement="right"
103-
delay={{ show: 250, hide: 400 }}
104-
overlay={
105-
<Tooltip id="button-tooltip" className={"pl-3"}>
106-
{systemHealthData.dataIntegrity}
107-
</Tooltip>
108-
}
109-
>
110-
<img
111-
className={getPathOfDataIntegrity(
112-
systemHealthData.dataIntegrity
113-
)}
114-
src={traffic_light}
115-
alt={systemHealthData.dataIntegrity}
116-
/>
117-
</OverlayTrigger>
118-
</td>
119-
</tr>
120-
</tbody>
121-
</Table>
122-
</div>
123-
<Button onClick={() => logout()}>Logout</Button>
124-
</Container>
125-
);
45+
46+
function HealthContainer(): JSX.Element {
47+
if (systemHealthData === null) {
48+
return <p>{errorMsg}</p>;
49+
}
50+
if (systemHealthData === "loading") {
51+
return <FFLoading />;
52+
} else {
53+
return (
54+
<Container>
55+
<Table striped bordered hover id={"ff-heath-table"}>
56+
<thead>
57+
<tr>
58+
<th>System Health</th>
59+
</tr>
60+
</thead>
61+
<tbody>
62+
<tr>
63+
<td>Deployment Type</td>
64+
<td>{systemHealthData.deployment}</td>
65+
</tr>
66+
<tr>
67+
<td>Version</td>
68+
<td>{systemHealthData.version}</td>
69+
</tr>
70+
<tr>
71+
<td>Uptime</td>
72+
<td>
73+
{getDurationAsString(systemHealthData.uptimeInSeconds)}
74+
</td>
75+
</tr>
76+
<tr>
77+
<td>Usercount</td>
78+
<td>{systemHealthData.userCount}</td>
79+
</tr>
80+
<tr>
81+
<td>Used Storage</td>
82+
<td>{formatBytes(systemHealthData.usedStorageInBytes)}</td>
83+
</tr>
84+
<tr>
85+
<td>Data Integrity</td>
86+
<td>
87+
<OverlayTrigger
88+
placement="right"
89+
delay={{ show: 250, hide: 400 }}
90+
overlay={
91+
<Tooltip id="button-tooltip" className={"pl-3"}>
92+
{systemHealthData.dataIntegrity}
93+
</Tooltip>
94+
}
95+
>
96+
<img
97+
className={getPathOfDataIntegrity(
98+
systemHealthData.dataIntegrity
99+
)}
100+
src={traffic_light}
101+
alt={systemHealthData.dataIntegrity}
102+
/>
103+
</OverlayTrigger>
104+
</td>
105+
</tr>
106+
</tbody>
107+
</Table>
108+
</Container>
109+
);
110+
}
126111
}
127-
}
128112

129-
return (
130-
<Container>
131-
<h1>FileFighter</h1>
113+
return (
114+
<Container>
115+
<h1>FileFighter</h1>
132116

133-
<img
134-
src={logo}
135-
alt="Logo FileFighter"
136-
onClick={() => {
137-
setAudioVolumeByID("audio_viking", 0.5);
138-
audioOnOff("audio_viking");
139-
}}
140-
/>
117+
<img
118+
src={logo}
119+
alt="Logo FileFighter"
120+
onClick={() => {
121+
setAudioVolumeByID("audio_viking", 0.5);
122+
audioOnOff("audio_viking");
123+
}}
124+
/>
141125

142-
<HealthContainer />
143-
</Container>
144-
);
126+
<HealthContainer />
127+
</Container>
128+
);
145129
}

0 commit comments

Comments
 (0)