feat(observatory): show present equipment and compact router and telemetry panes
This commit is contained in:
@@ -12,6 +12,7 @@ import {sensorContribution,type SensorUiContribution,wirelessContributions} from
|
||||
import type {RerunHostFactory} from './rerunHost';
|
||||
import './sensors.css';
|
||||
import {InventoryObserver} from './inventoryObserver';
|
||||
import {visibleSensors} from './presence';
|
||||
import {BoardSections,type BoardSectionsProps} from './BoardSections';
|
||||
import {WirelessEnrollmentWindow} from './WirelessEnrollmentWindow';
|
||||
export interface SensorBoardContent {settings:ReactNode;devices:ReactNode;refresh:()=>Promise<void>;addDevice:()=>void;canAddDevice:boolean;showingSavedDevices:boolean}
|
||||
@@ -46,7 +47,7 @@ export function SensorWorkspace({onOpenDetail,sceneSeedKey,transport,enabled=tru
|
||||
setInventory(value);setFresh(true);setSelected(target.id);setAdding(false);
|
||||
}
|
||||
const device=inventory?.items.find(v=>v.id===selected);
|
||||
const connected=inventory?.items.filter(v=>readOfflineInventory||v.online||sensorContribution(contributions,v)?.retainOffline)??[];
|
||||
const connected=visibleSensors(inventory,enabled&&fresh);
|
||||
const editingCurrent=inventory?.items.find(v=>v.id===editing?.id);
|
||||
const settingsDevice=editingCurrent??editing;
|
||||
const settingsFor=(item:Sensor)=>{const contribution=sensorContribution(contributions,item);return {supportsPreparation:contribution?.supportsPreparation!==false,supportsRenaming:contribution?.supportsRenaming,facts:contribution?.settingsFacts?.(item)};};
|
||||
@@ -63,7 +64,7 @@ export function SensorWorkspace({onOpenDetail,sceneSeedKey,transport,enabled=tru
|
||||
const prep=devicePreparation(inventory!,item);
|
||||
const status=(sensorContribution(contributions,item)?.status??sensorStatus)(item,enabled&&fresh);const label=busy?(operation?.action_id==='prepare'?'Подготовка устройства':'Выполняется команда'):status.label;
|
||||
return <li key={item.id}><ResourceRow icon={<Icon name={sensorContribution(contributions,item)?.icon??'camera'}/>} title={item.name} description={item.model} metadata={<span>{item.connection_label||`USB ${item.usb}`}</span>} statusPlacement={configured?'leading':'trailing'} aria-busy={busy} progress={busy&&pending==='prepare'?preparationProgress(prep,label):undefined} status={<StatusBadge variant={configured?'indicator':'badge'} tone={status.tone} aria-label={label} title={label}>{configured?null:label}</StatusBadge>} actions={<><SensorRowActions device={item} actions={sensorContribution(contributions,item)?.rowActions?.(item)} enabled={enabled&&fresh} busy={busy} pending={pending} perform={(name,parameters)=>void action(item,name,parameters)}/>{!configured&&sensorContribution(contributions,item)?.supportsPreparation!==false&&<IconButton label={`Подготовить и проверить: ${item.name}`} disabled={!enabled||!fresh||busy||item.initializable===false||item.preparation_safe===false||!item.online||item.snapshot.acquisition==='streaming'||item.snapshot.acquisition==='stopping'} onClick={()=>void action(item,'prepare')}><Icon name="download"/></IconButton>}{sensorContribution(contributions,item)?.settingsInDetail?<IconButton label={`${sensorContribution(contributions,item)?.detailLabel??'Настройки'}: ${item.name}`} disabled={busy} onClick={()=>openDetail(item)}><Icon name="settings"/></IconButton>:<>{sensorContribution(contributions,item)?.supportsRenaming!==false&&<IconButton label={`Настройки: ${item.name}`} disabled={!enabled||!fresh||busy} onClick={()=>{setEditing(item);}}><Icon name="settings"/></IconButton>}{sensorContribution(contributions,item)?.detailLabel?<Button disabled={!item.prepared||busy} onClick={()=>openDetail(item)}>{sensorContribution(contributions,item)?.detailLabel}</Button>:<IconButton label={`Просмотр: ${item.name}`} disabled={!item.prepared||busy} onClick={()=>openDetail(item)}><Icon name="eye"/></IconButton>}</>}</>}/></li>;})}</ResourceList>
|
||||
{!inventory&&enabled&&!error?<LoadingRegion loading label="Получение устройств БК"/>:!enabled?(!renderBoard?<SettingsCard title="БК недоступен" description="Показаны последние сохранённые устройства. Их состояние обновится после восстановления связи."/>:null):inventory&&connected.length===0?<SettingsCard title="Поддерживаемые устройства не обнаружены" description="Подключите устройство кабелем или добавьте беспроводное устройство через плюс."/>:null}
|
||||
{!inventory&&enabled&&!error?<LoadingRegion loading label="Получение устройств БК"/>:!enabled?(!renderBoard?<SettingsCard title="БК недоступен" description="Устройства появятся после восстановления связи с бортом."/>:null):null}
|
||||
<SensorPreparations inventory={enabled&&fresh?inventory:null}/>
|
||||
</>;
|
||||
const boardSettings=contributions.filter(value=>value.BoardSettings&&contributions.filter(other=>other.kind===value.kind).length===1);
|
||||
|
||||
@@ -27,7 +27,6 @@ export interface SensorUiContribution {
|
||||
kind:string;
|
||||
Detail:ComponentType<SensorDetailProps>;
|
||||
icon:IconName;
|
||||
retainOffline:boolean;
|
||||
supportsPreparation:boolean;
|
||||
supportsRenaming?:boolean;
|
||||
detailLabel?:string;
|
||||
|
||||
@@ -0,0 +1,7 @@
|
||||
import type {Sensor,SensorInventory} from './contracts';
|
||||
|
||||
// Persistent identity/settings are not evidence that an instance is present.
|
||||
// Both Core and Node use the same live inventory projection, keyed by device ID.
|
||||
export function visibleSensors(inventory:SensorInventory|null,fresh:boolean):Sensor[]{
|
||||
return fresh&&inventory?.fresh!==false?inventory?.items.filter(device=>device.online)??[]:[];
|
||||
}
|
||||
Reference in New Issue
Block a user