blob: af95c63c0294529443bd3d02e91ce400e0253d2e (
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
|
import React, { useState, useEffect } from 'react';
import './App.css';
import Path from './Path';
import Log from './Log';
import Options from './Options';
import Info from './Info';
import Setup from './Setup';
function App() {
const [setupStatus, setSetupStatus] = useState(null);
useEffect(() => {
const checkStatus = async () => {
try {
const resp = await fetch('http://localhost:8000/api/setup/status');
const rootResp = await fetch('http://localhost:8000/');
if (resp.ok && rootResp.ok) {
const data = await resp.json();
const rootData = await rootResp.json();
data.backend_ready = rootData.ready;
setSetupStatus(data);
if (!rootData.ready) {
setTimeout(checkStatus, 2000);
}
} else {
setTimeout(checkStatus, 2000);
}
} catch (e) {
console.error("Could not reach backend API, retrying in 2s...");
setTimeout(checkStatus, 2000);
}
};
checkStatus();
}, []);
if (!setupStatus) {
return <div className="loading">Initializing Backend Connection...</div>;
}
if (!setupStatus.data_ready || !setupStatus.auth_ready || !setupStatus.backend_ready) {
return <Setup status={setupStatus} onComplete={() => window.location.reload()} />;
}
return (
<div className="App flex flex-wrap h-screen">
<div className="w-2/3 h-full overflow-auto hide-scrollbar">
<Path />
</div>
<div className="w-1/3 h-full flex flex-col">
<div className="h-1/4 overflow-auto">
<Info />
</div>
<div className="h-1/4 overflow-auto">
<Options />
</div>
<div className="flex-1 overflow-auto">
<Log/>
</div>
</div>
</div>
);
}
export default App;
|