fix(ui): align project overview counts and complete functional labels
Device Core qualification / qualify (push) Successful in 8m43s
Device Core qualification / qualify (push) Successful in 8m43s
This commit is contained in:
@@ -116,7 +116,7 @@ export function B2HostSettings({ host, workspace, onClose, onChanged, onError }:
|
||||
<ResourceList>{apps.map(applicationRow)}</ResourceList>
|
||||
{!apps.length && creating !== item.projectRef ? <p>Ключи приложений ещё не выданы</p> : null}
|
||||
{creating === item.projectRef ? <div className="b2-settings">
|
||||
<TextField label="Название приложения" value={name} disabled={busy || Boolean(creationIntent)} maxLength={160} onChange={(event) => setName(event.target.value)} />
|
||||
<TextField label="Название приложения" autoFocus value={name} disabled={busy || Boolean(creationIntent)} maxLength={160} onChange={(event) => setName(event.target.value)} />
|
||||
<div className="b2-actions"><Button disabled={busy} onClick={() => { setCreating(''); setCreationIntent(null); }}>Отмена</Button><Button loading={pending === 'application-connect'} disabled={busy || !name.trim()} onClick={() => {
|
||||
const intent = creationIntent || { id: crypto.randomUUID().replaceAll('-', ''), name: name.trim() };
|
||||
setCreationIntent(intent);
|
||||
|
||||
@@ -3,20 +3,19 @@ import { b2Request, type B2Device } from './api';
|
||||
export type B2HostState = { hostRef: string; name: string; endpoint: string; contours: number; reachable: boolean; checkedAt: string; devices: number | null };
|
||||
export type B2Inventory = { items: Array<B2Device & { hostRef: string; hostName: string }>; hosts: B2HostState[] };
|
||||
export function useB2Inventory(projectRef: string, refreshSignal: unknown) {
|
||||
const [data, setData] = useState<B2Inventory | null>(null);
|
||||
const [error, setError] = useState('');
|
||||
const [snapshot, setSnapshot] = useState<{ projectRef: string; data: B2Inventory | null; error: string } | null>(null);
|
||||
useEffect(() => {
|
||||
let active = true, timer: ReturnType<typeof setTimeout>;
|
||||
async function load() {
|
||||
try {
|
||||
const next = await b2Request<B2Inventory>(projectRef, '', 'inventory');
|
||||
if (active) { setData(next); setError(''); }
|
||||
if (active) setSnapshot({ projectRef, data: next, error: '' });
|
||||
} catch (reason) {
|
||||
if (active) { setData(null); setError(reason instanceof Error ? reason.message : 'VPS недоступен'); }
|
||||
if (active) setSnapshot({ projectRef, data: null, error: reason instanceof Error ? reason.message : 'VPS недоступен' });
|
||||
} finally { if (active) timer = setTimeout(load, 30_000); }
|
||||
}
|
||||
void load();
|
||||
return () => { active = false; clearTimeout(timer); };
|
||||
}, [projectRef, refreshSignal]);
|
||||
return { data, error };
|
||||
return snapshot?.projectRef === projectRef ? snapshot : { data: null, error: '' };
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user