64 lines
3.0 KiB
TypeScript
64 lines
3.0 KiB
TypeScript
import type {SceneSettings} from '../../spatial-ui/src/sceneSettings';
|
|
import type {ComponentType,ReactNode} from 'react';
|
|
import type {IconName} from '@nodedc/ui-react';
|
|
import type {Sensor, SensorInventory, SensorTransport} from './contracts';
|
|
import type {EnrollmentTransport} from './enrollment';
|
|
import type {RerunHostFactory} from './rerunHost';
|
|
|
|
export interface SensorDetailProps {
|
|
sceneSeedKey?:string;
|
|
/** Optional host slots for full-workspace detail presentation. */
|
|
headerActionsTarget?:HTMLElement|null;
|
|
fullscreenControl?:{fullscreen:boolean;setFullscreen:(value:boolean)=>void};
|
|
sceneProfile?:{view:string;settings?:SceneSettings;save:(value:SceneSettings)=>void};
|
|
device:Sensor; transport:SensorTransport; enabled:boolean; previewEnabled?:boolean;
|
|
back:()=>void; backLabel?:string; navigationTarget?:HTMLElement|null; refresh:()=>Promise<void>; failure:(error:unknown)=>void;
|
|
createRerunHost?:RerunHostFactory; reconnect?:()=>void;
|
|
generalSettings?:{supportsPreparation:boolean;supportsRenaming?:boolean;facts?:readonly {id:string;label:string;value:string}[]};
|
|
}
|
|
export interface SensorEnrollmentProps {
|
|
transport:EnrollmentTransport; onClose:()=>void; onChange:()=>void;
|
|
onComplete:(sessionId:string,signal?:AbortSignal)=>Promise<void>;
|
|
renderWindow:(view:{content:ReactNode;actions?:ReactNode;headerActions?:ReactNode;busy?:boolean})=>ReactNode;
|
|
}
|
|
export interface SensorUiContribution {
|
|
BoardSettings?:ComponentType<SensorBoardSettingsProps>;
|
|
observation?:import('./observation').SensorObservationContribution;
|
|
kind:string;
|
|
Detail:ComponentType<SensorDetailProps>;
|
|
icon:IconName;
|
|
retainOffline:boolean;
|
|
supportsPreparation:boolean;
|
|
supportsRenaming?:boolean;
|
|
detailLabel?:string;
|
|
detailPresentation?:'modal'|'workspace';
|
|
/** The detail modal includes generic settings and owns the single gear entry. */
|
|
settingsInDetail?:boolean;
|
|
settingsFacts?:(device:Sensor)=>readonly {id:string;label:string;value:string}[];
|
|
rowActions?:(device:Sensor)=>readonly SensorRowAction[];
|
|
status?:(device:Sensor,fresh:boolean)=>{label:string;tone:'neutral'|'success'|'warning'|'danger'};
|
|
wirelessEnrollment?:{label:string;View:ComponentType<SensorEnrollmentProps>};
|
|
}
|
|
|
|
export interface SensorBoardSettingsProps {
|
|
inventory:SensorInventory|null;transport:SensorTransport;enabled:boolean;
|
|
refresh:()=>Promise<void>;failure:(error:unknown)=>void;openDevice:(id:string)=>void;
|
|
}
|
|
|
|
export interface SensorRowAction {
|
|
actionId:string; label:string; description?:string; disabled?:boolean;
|
|
parameters?:Record<string,unknown>;
|
|
}
|
|
|
|
export function wirelessContributions(contributions:readonly SensorUiContribution[]):SensorUiContribution[] {
|
|
return contributions.filter(value=>value.wirelessEnrollment&&contributions.filter(other=>other.kind===value.kind).length===1);
|
|
}
|
|
|
|
export function sensorContribution(
|
|
contributions:readonly SensorUiContribution[], device:Sensor,
|
|
):SensorUiContribution|undefined {
|
|
const matches=contributions.filter(value=>value.kind===device.kind);
|
|
// An ambiguous renderer must not acquire authority over a device.
|
|
return matches.length===1?matches[0]:undefined;
|
|
}
|