Added dialog implementation

Signed-off-by: jbicker <jan.bicker@typefox.io>
This commit is contained in:
jbicker
2019-07-08 11:58:59 +02:00
parent 4c66dec36e
commit 769689ff6d
9 changed files with 370 additions and 24 deletions

View File

@@ -4,8 +4,8 @@ export const BoardsServicePath = '/services/boards-service';
export const BoardsService = Symbol('BoardsService');
export interface BoardsService {
getAttachedBoards(): Promise<{ boards: Board[] }>;
selectBoard(board: Board): Promise<void>;
getSelectBoard(): Promise<Board | undefined>;
selectBoard(board: Board | AttachedSerialBoard | AttachedNetworkBoard): Promise<void>;
getSelectBoard(): Promise<Board | AttachedSerialBoard | AttachedNetworkBoard | undefined>;
search(options: { query?: string }): Promise<{ items: BoardPackage[] }>;
install(item: BoardPackage): Promise<void>;
@@ -23,31 +23,29 @@ export interface Board {
export interface AttachedSerialBoard extends Board {
port: string;
serialNumber: string;
productID: string;
vendorID: string;
type: 'serial';
serialNumber?: string;
productID?: string;
vendorID?: string;
}
export namespace AttachedSerialBoard {
export function is(b: Board): b is AttachedSerialBoard {
return 'port' in b
&& 'serialNumber' in b
&& 'productID' in b
&& 'vendorID' in b;
return 'type' in b && (b as Board & { type: any }).type === 'serial' &&
'port' in b && !!(b as Board & { port: any }).port && typeof (b as Board & { port: any }).port === 'string';
}
}
export interface AttachedNetworkBoard extends Board {
info: string;
address: string;
info?: string;
address?: string;
port: number;
type: 'network';
}
export namespace AttachedNetworkBoard {
export function is(b: Board): b is AttachedNetworkBoard {
return 'name' in b
&& 'info' in b
&& 'address' in b
&& 'port' in b;
return 'type' in b && (b as Board & { type: any }).type === 'network' &&
'port' in b && !!(b as Board & { port: any }).port && typeof (b as Board & { port: any }).port === 'number';
}
}