@milabench/bujang 0.1.7 → 0.1.9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -1
- package/dist/api.d.ts +40 -1
- package/dist/components/LinkableCard.d.ts +27 -0
- package/dist/components/SshConnectDialog.d.ts +31 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.js +4618 -3593
- package/dist/index.js.map +1 -1
- package/dist/paths.d.ts +8 -3
- package/dist/routes.d.ts +1 -1
- package/dist/types.d.ts +185 -1
- package/dist/views/JanitorView.d.ts +5 -0
- package/package.json +1 -1
- package/src/api.ts +110 -0
- package/src/components/LinkableCard.tsx +120 -0
- package/src/components/SshConnectDialog.tsx +377 -0
- package/src/index.ts +2 -0
- package/src/paths.ts +13 -4
- package/src/routes.tsx +3 -1
- package/src/types.ts +197 -1
- package/src/views/JanitorView.tsx +693 -0
- package/src/views/JobLogs.tsx +2 -1
- package/src/views/JobSubmit.tsx +139 -13
- package/src/views/JobsView.tsx +5 -62
- package/src/views/PipelineGraph.tsx +33 -3
- package/src/views/SettingsView.tsx +112 -48
|
@@ -0,0 +1,377 @@
|
|
|
1
|
+
import React, { useEffect, useRef, useState } from 'react';
|
|
2
|
+
import { Badge, Box, Button, Code, Dialog, HStack, IconButton, Input, Spinner, Table, Text, VStack } from '@chakra-ui/react';
|
|
3
|
+
import { useMutation, useQuery, useQueryClient } from '@tanstack/react-query';
|
|
4
|
+
import { LuCircleCheck, LuCircleX, LuEye, LuEyeOff, LuPlug } from 'react-icons/lu';
|
|
5
|
+
import { answerSshLogin, cancelSshLogin, getSshConnections, getSshLogin, startSshLogin } from '../api';
|
|
6
|
+
import type { ApiError, SshConnection, SshConnections, SshLogin } from '../types';
|
|
7
|
+
import { toaster } from '../toast';
|
|
8
|
+
|
|
9
|
+
export const SSH_CONNECTIONS_KEY = ['ssh-connections'];
|
|
10
|
+
|
|
11
|
+
const ACTIVE = ['starting', 'prompt', 'waiting'];
|
|
12
|
+
|
|
13
|
+
const errorMessage = (error: unknown) => (error as ApiError)?.message || String(error);
|
|
14
|
+
|
|
15
|
+
const inputStyle = {
|
|
16
|
+
bg: 'var(--color-input-bg)',
|
|
17
|
+
borderColor: 'var(--color-input-border)',
|
|
18
|
+
color: 'var(--color-text)',
|
|
19
|
+
} as const;
|
|
20
|
+
|
|
21
|
+
/** The state of a host's shared connection as a badge */
|
|
22
|
+
export const MasterBadge: React.FC<{ master: SshConnection['master'] }> = ({ master }) => {
|
|
23
|
+
if (master === 'open') return <Badge colorPalette="green" variant="subtle">connected</Badge>;
|
|
24
|
+
if (master === 'none') {
|
|
25
|
+
return (
|
|
26
|
+
<Badge colorPalette="gray" variant="subtle" title="The ssh config keeps no shared connection (ControlMaster) for this host: each ssh connects on its own">
|
|
27
|
+
no shared connection
|
|
28
|
+
</Badge>
|
|
29
|
+
);
|
|
30
|
+
}
|
|
31
|
+
return <Badge colorPalette="orange" variant="subtle">not connected</Badge>;
|
|
32
|
+
};
|
|
33
|
+
|
|
34
|
+
/** One login in progress: the prompt of ssh (MFA passcode, password, host key) and its answer */
|
|
35
|
+
const LoginPanel: React.FC<{
|
|
36
|
+
login: SshLogin;
|
|
37
|
+
onRetry: () => void;
|
|
38
|
+
onCancel: () => void;
|
|
39
|
+
}> = ({ login, onRetry, onCancel }) => {
|
|
40
|
+
const [answer, setAnswer] = useState('');
|
|
41
|
+
const [show, setShow] = useState(false);
|
|
42
|
+
const inputRef = useRef<HTMLInputElement>(null);
|
|
43
|
+
const send = useMutation({
|
|
44
|
+
mutationFn: (text: string) => answerSshLogin(login.id, text),
|
|
45
|
+
onSuccess: () => setAnswer(''),
|
|
46
|
+
onError: (error) => toaster.create({ title: 'Could not send the answer', description: errorMessage(error), type: 'error' }),
|
|
47
|
+
});
|
|
48
|
+
|
|
49
|
+
// a new prompt: focus the input
|
|
50
|
+
useEffect(() => {
|
|
51
|
+
if (login.state === 'prompt') inputRef.current?.focus();
|
|
52
|
+
}, [login.state, login.prompts]);
|
|
53
|
+
|
|
54
|
+
const info = login.info.filter(line => line.trim() !== (login.prompt || '').trim());
|
|
55
|
+
const submit = () => { if (answer && !send.isPending) send.mutate(answer); };
|
|
56
|
+
|
|
57
|
+
return (
|
|
58
|
+
<Box borderWidth="1px" borderColor="var(--color-border)" borderRadius="md" p={4}>
|
|
59
|
+
<VStack align="stretch" gap={3}>
|
|
60
|
+
<HStack justify="space-between">
|
|
61
|
+
<Text fontWeight="semibold" color="var(--color-text)">
|
|
62
|
+
{login.cluster ? `${login.cluster} · ` : ''}<Code fontSize="sm">{login.host}</Code>
|
|
63
|
+
</Text>
|
|
64
|
+
{ACTIVE.includes(login.state) && login.state !== 'prompt' && (
|
|
65
|
+
<HStack gap={2} color="var(--color-text-muted)" fontSize="sm">
|
|
66
|
+
<Spinner size="xs" />
|
|
67
|
+
<Text>{login.state === 'starting' ? 'connecting…' : 'checking the answer…'}</Text>
|
|
68
|
+
</HStack>
|
|
69
|
+
)}
|
|
70
|
+
</HStack>
|
|
71
|
+
|
|
72
|
+
{info.length > 0 && (
|
|
73
|
+
<Box as="pre" fontFamily="mono" fontSize="xs" whiteSpace="pre-wrap" bg="var(--color-bg-subtle, rgba(127,127,127,0.08))"
|
|
74
|
+
p={2} borderRadius="sm" maxH="160px" overflowY="auto" color="var(--color-text-muted)">
|
|
75
|
+
{info.join('\n')}
|
|
76
|
+
</Box>
|
|
77
|
+
)}
|
|
78
|
+
|
|
79
|
+
{login.state === 'prompt' && login.kind === 'confirm' && (
|
|
80
|
+
<VStack align="stretch" gap={2}>
|
|
81
|
+
<Text fontSize="sm" whiteSpace="pre-wrap" color="var(--color-text)">{login.prompt}</Text>
|
|
82
|
+
<HStack>
|
|
83
|
+
<Button size="sm" colorPalette="blue" loading={send.isPending} onClick={() => send.mutate('yes')}>Yes</Button>
|
|
84
|
+
<Button size="sm" variant="outline" disabled={send.isPending} onClick={() => send.mutate('no')}>No</Button>
|
|
85
|
+
</HStack>
|
|
86
|
+
</VStack>
|
|
87
|
+
)}
|
|
88
|
+
|
|
89
|
+
{login.state === 'prompt' && login.kind !== 'confirm' && (
|
|
90
|
+
<VStack align="stretch" gap={2}>
|
|
91
|
+
<Text fontSize="sm" whiteSpace="pre-wrap" color="var(--color-text)">{login.prompt}</Text>
|
|
92
|
+
<HStack>
|
|
93
|
+
<Input
|
|
94
|
+
{...inputStyle}
|
|
95
|
+
ref={inputRef}
|
|
96
|
+
size="sm"
|
|
97
|
+
fontFamily="mono"
|
|
98
|
+
type={show ? 'text' : 'password'}
|
|
99
|
+
autoComplete="one-time-code"
|
|
100
|
+
value={answer}
|
|
101
|
+
onChange={(e) => setAnswer(e.target.value)}
|
|
102
|
+
onKeyDown={(e) => { if (e.key === 'Enter') submit(); }}
|
|
103
|
+
/>
|
|
104
|
+
<IconButton size="sm" variant="ghost" aria-label={show ? 'Hide' : 'Show'} onClick={() => setShow(s => !s)}>
|
|
105
|
+
{show ? <LuEyeOff /> : <LuEye />}
|
|
106
|
+
</IconButton>
|
|
107
|
+
<Button size="sm" colorPalette="blue" loading={send.isPending} disabled={!answer} onClick={submit}>
|
|
108
|
+
Send
|
|
109
|
+
</Button>
|
|
110
|
+
</HStack>
|
|
111
|
+
<Text fontSize="xs" color="var(--color-text-muted)">
|
|
112
|
+
Handed to ssh only: bujang never stores or logs it.
|
|
113
|
+
</Text>
|
|
114
|
+
</VStack>
|
|
115
|
+
)}
|
|
116
|
+
|
|
117
|
+
{login.state === 'ok' && (
|
|
118
|
+
<HStack gap={2} color="var(--color-status-running, green)">
|
|
119
|
+
<LuCircleCheck />
|
|
120
|
+
<Text fontSize="sm">{login.message || 'connected'}</Text>
|
|
121
|
+
</HStack>
|
|
122
|
+
)}
|
|
123
|
+
{(login.state === 'failed' || login.state === 'cancelled') && (
|
|
124
|
+
<HStack gap={2} justify="space-between">
|
|
125
|
+
<HStack gap={2} color="var(--color-status-failed, red)">
|
|
126
|
+
<LuCircleX />
|
|
127
|
+
<Text fontSize="sm">{login.message || login.state}</Text>
|
|
128
|
+
</HStack>
|
|
129
|
+
<Button size="xs" variant="outline" onClick={onRetry}>Retry</Button>
|
|
130
|
+
</HStack>
|
|
131
|
+
)}
|
|
132
|
+
|
|
133
|
+
{ACTIVE.includes(login.state) && (
|
|
134
|
+
<HStack justify="flex-end">
|
|
135
|
+
<Button size="xs" variant="ghost" onClick={onCancel}>Cancel</Button>
|
|
136
|
+
</HStack>
|
|
137
|
+
)}
|
|
138
|
+
</VStack>
|
|
139
|
+
</Box>
|
|
140
|
+
);
|
|
141
|
+
};
|
|
142
|
+
|
|
143
|
+
export interface SshConnectDialogProps {
|
|
144
|
+
open: boolean;
|
|
145
|
+
onClose: () => void;
|
|
146
|
+
/** Start the login to this cluster's login node right away (submit to a cluster not connected yet) */
|
|
147
|
+
cluster?: string | null;
|
|
148
|
+
/** The login to `cluster` succeeded: the dialog closes itself */
|
|
149
|
+
onConnected?: () => void;
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
/**
|
|
153
|
+
* Open the shared ssh connection (ControlMaster) of the clusters: the hosts and their state, a
|
|
154
|
+
* Connect button each; the prompts of ssh (MFA passcode / Duo option, password, host key) are
|
|
155
|
+
* answered here. Every other ssh of bujang reuses the connection and never prompts.
|
|
156
|
+
*/
|
|
157
|
+
export const SshConnectDialog: React.FC<SshConnectDialogProps> = ({ open, onClose, cluster, onConnected }) => {
|
|
158
|
+
const queryClient = useQueryClient();
|
|
159
|
+
const [loginId, setLoginId] = useState<string | null>(null);
|
|
160
|
+
const autoStarted = useRef(false);
|
|
161
|
+
|
|
162
|
+
const { data: connections, isLoading, error } = useQuery<SshConnections>({
|
|
163
|
+
queryKey: SSH_CONNECTIONS_KEY,
|
|
164
|
+
queryFn: () => getSshConnections(),
|
|
165
|
+
enabled: open,
|
|
166
|
+
refetchOnWindowFocus: false,
|
|
167
|
+
});
|
|
168
|
+
|
|
169
|
+
const { data: login } = useQuery<SshLogin>({
|
|
170
|
+
queryKey: ['ssh-login', loginId],
|
|
171
|
+
queryFn: () => getSshLogin(loginId as string),
|
|
172
|
+
enabled: open && !!loginId,
|
|
173
|
+
refetchInterval: (q) => (q.state.data && !ACTIVE.includes(q.state.data.state) ? false : 1000),
|
|
174
|
+
refetchOnWindowFocus: false,
|
|
175
|
+
});
|
|
176
|
+
|
|
177
|
+
const start = useMutation({
|
|
178
|
+
mutationFn: startSshLogin,
|
|
179
|
+
onSuccess: (data) => {
|
|
180
|
+
queryClient.setQueryData(['ssh-login', data.id], data);
|
|
181
|
+
setLoginId(data.id);
|
|
182
|
+
},
|
|
183
|
+
onError: (err) => toaster.create({ title: 'Could not start the ssh login', description: errorMessage(err), type: 'error' }),
|
|
184
|
+
});
|
|
185
|
+
|
|
186
|
+
// submit flow: connect to the cluster at once
|
|
187
|
+
useEffect(() => {
|
|
188
|
+
if (open && cluster && !autoStarted.current) {
|
|
189
|
+
autoStarted.current = true;
|
|
190
|
+
start.mutate({ cluster });
|
|
191
|
+
}
|
|
192
|
+
if (!open) {
|
|
193
|
+
autoStarted.current = false;
|
|
194
|
+
setLoginId(null);
|
|
195
|
+
}
|
|
196
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps -- once per opening
|
|
197
|
+
}, [open, cluster]);
|
|
198
|
+
|
|
199
|
+
// the outcome: refresh the states; the submit flow goes on by itself
|
|
200
|
+
const lastState = useRef<string | null>(null);
|
|
201
|
+
useEffect(() => {
|
|
202
|
+
if (!login || login.state === lastState.current) return;
|
|
203
|
+
lastState.current = login.state;
|
|
204
|
+
if (!ACTIVE.includes(login.state)) queryClient.invalidateQueries({ queryKey: SSH_CONNECTIONS_KEY });
|
|
205
|
+
if (login.state === 'ok' && cluster && login.cluster === cluster && onConnected) onConnected();
|
|
206
|
+
}, [login, cluster, onConnected, queryClient]);
|
|
207
|
+
|
|
208
|
+
const close = () => {
|
|
209
|
+
// a login still waiting for an answer gives up (the connections already open stay)
|
|
210
|
+
if (login && ACTIVE.includes(login.state)) cancelSshLogin(login.id).catch(() => undefined);
|
|
211
|
+
onClose();
|
|
212
|
+
};
|
|
213
|
+
|
|
214
|
+
const connect = (c: SshConnection) => start.mutate({ host: c.host, cluster: c.cluster });
|
|
215
|
+
const busy = !!login && ACTIVE.includes(login.state);
|
|
216
|
+
const hosts = connections?.hosts || [];
|
|
217
|
+
|
|
218
|
+
return (
|
|
219
|
+
<Dialog.Root open={open} onOpenChange={(d) => { if (!d.open) close(); }} size="lg">
|
|
220
|
+
<Dialog.Backdrop />
|
|
221
|
+
<Dialog.Positioner>
|
|
222
|
+
<Dialog.Content>
|
|
223
|
+
<Dialog.Header>
|
|
224
|
+
<Dialog.Title>{cluster ? `Connect to ${cluster}` : 'Connect to the clusters'}</Dialog.Title>
|
|
225
|
+
<Dialog.CloseTrigger />
|
|
226
|
+
</Dialog.Header>
|
|
227
|
+
<Dialog.Body>
|
|
228
|
+
<VStack align="stretch" gap={4}>
|
|
229
|
+
<Text fontSize="sm" color="var(--color-text-muted)">
|
|
230
|
+
{cluster
|
|
231
|
+
? `${cluster} has no open connection: log in once (two-factor authentication included), then the job is submitted.`
|
|
232
|
+
: 'Log in once per cluster (two-factor authentication included): bujang reuses the connection for every ssh, rsync and scp until it expires.'}
|
|
233
|
+
</Text>
|
|
234
|
+
|
|
235
|
+
{login && (
|
|
236
|
+
<LoginPanel
|
|
237
|
+
login={login}
|
|
238
|
+
onRetry={() => start.mutate({ host: login.host, cluster: login.cluster || undefined })}
|
|
239
|
+
onCancel={() => cancelSshLogin(login.id).catch(() => undefined)}
|
|
240
|
+
/>
|
|
241
|
+
)}
|
|
242
|
+
|
|
243
|
+
{connections && !connections.writable && (
|
|
244
|
+
<Text fontSize="sm" color="var(--color-status-failed)">
|
|
245
|
+
{connections.read_only_reason || 'This server cannot open ssh connections.'}
|
|
246
|
+
</Text>
|
|
247
|
+
)}
|
|
248
|
+
{isLoading && <Spinner />}
|
|
249
|
+
{error && <Text fontSize="sm" color="var(--color-status-failed)">{errorMessage(error)}</Text>}
|
|
250
|
+
{connections && hosts.length === 0 && (
|
|
251
|
+
<Text fontSize="sm" color="var(--color-text-muted)">No cluster reached over ssh.</Text>
|
|
252
|
+
)}
|
|
253
|
+
|
|
254
|
+
{!cluster && hosts.length > 0 && (
|
|
255
|
+
<Table.Root size="sm">
|
|
256
|
+
<Table.Header>
|
|
257
|
+
<Table.Row>
|
|
258
|
+
<Table.ColumnHeader>Cluster</Table.ColumnHeader>
|
|
259
|
+
<Table.ColumnHeader>Host</Table.ColumnHeader>
|
|
260
|
+
<Table.ColumnHeader>State</Table.ColumnHeader>
|
|
261
|
+
<Table.ColumnHeader />
|
|
262
|
+
</Table.Row>
|
|
263
|
+
</Table.Header>
|
|
264
|
+
<Table.Body>
|
|
265
|
+
{hosts.map(c => (
|
|
266
|
+
<Table.Row key={`${c.cluster}/${c.host}`}>
|
|
267
|
+
<Table.Cell>{c.cluster}</Table.Cell>
|
|
268
|
+
<Table.Cell fontFamily="mono" fontSize="xs">
|
|
269
|
+
{c.host}
|
|
270
|
+
{!c.login_node && <Badge ml={2} size="xs" variant="outline">data mover</Badge>}
|
|
271
|
+
</Table.Cell>
|
|
272
|
+
<Table.Cell><MasterBadge master={c.master} /></Table.Cell>
|
|
273
|
+
<Table.Cell textAlign="end">
|
|
274
|
+
<Button
|
|
275
|
+
size="xs"
|
|
276
|
+
variant={c.master === 'open' ? 'ghost' : 'outline'}
|
|
277
|
+
disabled={!connections?.writable || busy || start.isPending}
|
|
278
|
+
loading={start.isPending && start.variables?.host === c.host}
|
|
279
|
+
onClick={() => connect(c)}
|
|
280
|
+
>
|
|
281
|
+
<LuPlug /> {c.master === 'open' ? 'Check' : 'Connect'}
|
|
282
|
+
</Button>
|
|
283
|
+
</Table.Cell>
|
|
284
|
+
</Table.Row>
|
|
285
|
+
))}
|
|
286
|
+
</Table.Body>
|
|
287
|
+
</Table.Root>
|
|
288
|
+
)}
|
|
289
|
+
</VStack>
|
|
290
|
+
</Dialog.Body>
|
|
291
|
+
<Dialog.Footer>
|
|
292
|
+
<Button variant="outline" onClick={close}>Close</Button>
|
|
293
|
+
</Dialog.Footer>
|
|
294
|
+
</Dialog.Content>
|
|
295
|
+
</Dialog.Positioner>
|
|
296
|
+
</Dialog.Root>
|
|
297
|
+
);
|
|
298
|
+
};
|
|
299
|
+
|
|
300
|
+
/** The "Connect" button of the jobs page: how many clusters are connected, opens SshConnectDialog */
|
|
301
|
+
export const SshConnectButton: React.FC = () => {
|
|
302
|
+
const [open, setOpen] = useState(false);
|
|
303
|
+
const { data } = useQuery<SshConnections>({
|
|
304
|
+
queryKey: SSH_CONNECTIONS_KEY,
|
|
305
|
+
queryFn: () => getSshConnections(),
|
|
306
|
+
refetchInterval: 60000,
|
|
307
|
+
refetchOnWindowFocus: false,
|
|
308
|
+
retry: false,
|
|
309
|
+
});
|
|
310
|
+
const logins = (data?.hosts || []).filter(h => h.login_node);
|
|
311
|
+
const shared = logins.filter(h => h.master !== 'none');
|
|
312
|
+
const connected = shared.filter(h => h.master === 'open').length;
|
|
313
|
+
const missing = shared.length - connected;
|
|
314
|
+
|
|
315
|
+
return (
|
|
316
|
+
<>
|
|
317
|
+
<Button
|
|
318
|
+
size="sm"
|
|
319
|
+
variant="outline"
|
|
320
|
+
borderRadius="full"
|
|
321
|
+
onClick={() => setOpen(true)}
|
|
322
|
+
title={data
|
|
323
|
+
? `${connected} of ${shared.length} clusters connected${missing ? ': log in to the others' : ''}`
|
|
324
|
+
: 'Open the ssh connections of the clusters'}
|
|
325
|
+
>
|
|
326
|
+
<LuPlug />
|
|
327
|
+
Connect
|
|
328
|
+
{connected > 0 && (
|
|
329
|
+
<Badge colorPalette="green" variant="solid" size="xs" ml={1}>
|
|
330
|
+
{connected}
|
|
331
|
+
</Badge>
|
|
332
|
+
)}
|
|
333
|
+
</Button>
|
|
334
|
+
<SshConnectDialog open={open} onClose={() => setOpen(false)} />
|
|
335
|
+
</>
|
|
336
|
+
);
|
|
337
|
+
};
|
|
338
|
+
|
|
339
|
+
/**
|
|
340
|
+
* Before a submit: when the cluster's login node has no open connection, ask for a login first.
|
|
341
|
+
* `ensure(cluster, go)` runs `go` now, or once the login dialog succeeded; render `dialog`.
|
|
342
|
+
*/
|
|
343
|
+
export const useSshConnectGate = () => {
|
|
344
|
+
const [cluster, setCluster] = useState<string | null>(null);
|
|
345
|
+
const pending = useRef<(() => void) | null>(null);
|
|
346
|
+
|
|
347
|
+
const ensure = async (name: string, go: () => void) => {
|
|
348
|
+
let state: SshConnections | null = null;
|
|
349
|
+
try {
|
|
350
|
+
state = await getSshConnections(name);
|
|
351
|
+
} catch {
|
|
352
|
+
state = null; // unknown or local cluster, no ssh: the submit says what is wrong
|
|
353
|
+
}
|
|
354
|
+
const host = state?.hosts.find(h => h.login_node);
|
|
355
|
+
if (!state || !state.writable || !host || host.master !== 'no') {
|
|
356
|
+
go();
|
|
357
|
+
return;
|
|
358
|
+
}
|
|
359
|
+
pending.current = go;
|
|
360
|
+
setCluster(name);
|
|
361
|
+
};
|
|
362
|
+
|
|
363
|
+
const dialog = (
|
|
364
|
+
<SshConnectDialog
|
|
365
|
+
open={!!cluster}
|
|
366
|
+
cluster={cluster}
|
|
367
|
+
onClose={() => { pending.current = null; setCluster(null); }}
|
|
368
|
+
onConnected={() => {
|
|
369
|
+
const go = pending.current;
|
|
370
|
+
pending.current = null;
|
|
371
|
+
setCluster(null);
|
|
372
|
+
go?.();
|
|
373
|
+
}}
|
|
374
|
+
/>
|
|
375
|
+
);
|
|
376
|
+
return { ensure, dialog };
|
|
377
|
+
};
|
package/src/index.ts
CHANGED
|
@@ -9,6 +9,8 @@ export type { GraphStep } from './views/PipelineGraph';
|
|
|
9
9
|
export { ScheduledJobsView } from './views/ScheduledJobsView';
|
|
10
10
|
export { AgentActivityView, AgentBadge, McpHelp } from './views/AgentActivityView';
|
|
11
11
|
export { SettingsView } from './views/SettingsView';
|
|
12
|
+
export { JanitorView } from './views/JanitorView';
|
|
13
|
+
export { LinkableCard, useHashScroll } from './components/LinkableCard';
|
|
12
14
|
export { JobSubmissionForm } from './views/JobSubmit';
|
|
13
15
|
export type { JobSubmissionInitialData } from './views/JobSubmit';
|
|
14
16
|
export { LogDisplay } from './views/LogDisplay';
|
package/src/paths.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { IconType } from 'react-icons';
|
|
2
|
-
import { LuBot, LuCalendarClock, LuList, LuSend, LuSettings, LuWorkflow } from 'react-icons/lu';
|
|
2
|
+
import { LuBot, LuBrush, LuCalendarClock, LuList, LuSend, LuSettings, LuWorkflow } from 'react-icons/lu';
|
|
3
3
|
|
|
4
4
|
/** Names of the bujang views. */
|
|
5
5
|
export type BujangView =
|
|
@@ -11,6 +11,7 @@ export type BujangView =
|
|
|
11
11
|
| 'pipelineDetails'
|
|
12
12
|
| 'scheduled'
|
|
13
13
|
| 'agent'
|
|
14
|
+
| 'janitor'
|
|
14
15
|
| 'settings';
|
|
15
16
|
|
|
16
17
|
/** URL builders the views use to link to each other. */
|
|
@@ -25,8 +26,13 @@ export interface BujangPaths {
|
|
|
25
26
|
scheduled: () => string;
|
|
26
27
|
/** Agent activity, optionally filtered on one session. */
|
|
27
28
|
agent: (session?: string) => string;
|
|
28
|
-
/**
|
|
29
|
-
|
|
29
|
+
/** Janitor: background tasks (running, periodic, history), sync queue, cleanups. `section`: a card id. */
|
|
30
|
+
janitor: (section?: string) => string;
|
|
31
|
+
/**
|
|
32
|
+
* Settings: folders, database, SSH, secrets (read-only unless the server allows edits).
|
|
33
|
+
* `section` links to one card: general, folders, database, ssh, secrets.
|
|
34
|
+
*/
|
|
35
|
+
settings: (section?: string) => string;
|
|
30
36
|
}
|
|
31
37
|
|
|
32
38
|
/** Default URL layout (react-router patterns), relative to the host's basePath. */
|
|
@@ -39,6 +45,7 @@ export const defaultRoutePatterns: Record<BujangView, string> = {
|
|
|
39
45
|
pipelineDetails: '/pipelines/:pipelineName',
|
|
40
46
|
scheduled: '/scheduled',
|
|
41
47
|
agent: '/agent',
|
|
48
|
+
janitor: '/janitor',
|
|
42
49
|
settings: '/settings',
|
|
43
50
|
};
|
|
44
51
|
|
|
@@ -62,7 +69,8 @@ export function createBujangPaths(basePath: string = ''): BujangPaths {
|
|
|
62
69
|
pipelineDetails: (name, runId) => `${b}/pipelines/${seg(name)}${runId ? `?run=${encodeURIComponent(runId)}` : ''}`,
|
|
63
70
|
scheduled: () => `${b}/scheduled`,
|
|
64
71
|
agent: (session) => (session ? `${b}/agent?session=${encodeURIComponent(session)}` : `${b}/agent`),
|
|
65
|
-
|
|
72
|
+
janitor: (section) => `${b}/janitor${section ? `#${encodeURIComponent(section)}` : ''}`,
|
|
73
|
+
settings: (section) => `${b}/settings${section ? `#${encodeURIComponent(section)}` : ''}`,
|
|
66
74
|
};
|
|
67
75
|
}
|
|
68
76
|
|
|
@@ -82,6 +90,7 @@ export function bujangNavItems(paths: BujangPaths = createBujangPaths()): Bujang
|
|
|
82
90
|
{ view: 'scheduled', label: 'Scheduled Jobs', path: paths.scheduled(), icon: LuCalendarClock },
|
|
83
91
|
{ view: 'pipelines', label: 'Pipelines', path: paths.pipelines(), icon: LuWorkflow },
|
|
84
92
|
{ view: 'agent', label: 'Agent Activity', path: paths.agent(), icon: LuBot },
|
|
93
|
+
{ view: 'janitor', label: 'Janitor', path: paths.janitor(), icon: LuBrush },
|
|
85
94
|
{ view: 'settings', label: 'Settings', path: paths.settings(), icon: LuSettings },
|
|
86
95
|
];
|
|
87
96
|
}
|
package/src/routes.tsx
CHANGED
|
@@ -10,6 +10,7 @@ import { PipelineDetailsView, PipelinesView } from './views/PipelinesView';
|
|
|
10
10
|
import { ScheduledJobsView } from './views/ScheduledJobsView';
|
|
11
11
|
import { AgentActivityView } from './views/AgentActivityView';
|
|
12
12
|
import { SettingsView } from './views/SettingsView';
|
|
13
|
+
import { JanitorView } from './views/JanitorView';
|
|
13
14
|
|
|
14
15
|
export interface BujangRoutesOptions {
|
|
15
16
|
/** Prefix the routes are mounted under, e.g. "/slurm". Must match BujangProvider's basePath. Default "". */
|
|
@@ -34,13 +35,14 @@ const elements: Record<BujangView, () => React.ReactElement> = {
|
|
|
34
35
|
pipelineDetails: () => <PipelineDetailsView />,
|
|
35
36
|
scheduled: () => <ScheduledJobsView />,
|
|
36
37
|
agent: () => <AgentActivityView />,
|
|
38
|
+
janitor: () => <JanitorView />,
|
|
37
39
|
settings: () => <SettingsView />,
|
|
38
40
|
};
|
|
39
41
|
|
|
40
42
|
/**
|
|
41
43
|
* Route objects for the default bujang URL layout under `basePath`:
|
|
42
44
|
* /jobs, /jobs/submit, /jobrunner/:slurmJobId/:jrJobId, /joblogs/:slurmJobId/:jrJobId,
|
|
43
|
-
* /pipelines, /pipelines/:pipelineName, /scheduled, /agent, /settings.
|
|
45
|
+
* /pipelines, /pipelines/:pipelineName, /scheduled, /agent, /janitor, /settings.
|
|
44
46
|
*/
|
|
45
47
|
export function bujangRoutes(options: BujangRoutesOptions = {}): BujangRouteObject[] {
|
|
46
48
|
const base = normalizeBasePath(options.basePath);
|