Skip to content

Commit

Permalink
feat: adds room config updates and useIRoomEventSchedule hook
Browse files Browse the repository at this point in the history
  • Loading branch information
ndorin committed Apr 4, 2024
1 parent 867bf9c commit 5678df9
Show file tree
Hide file tree
Showing 6 changed files with 52 additions and 3 deletions.
1 change: 1 addition & 0 deletions src/lib/shared/hooks/interfaces/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ export * from "./useILevelControls";
export * from "./useILightingScenes";
export * from "./useIMatrixRouting";

Check failure on line 14 in src/lib/shared/hooks/interfaces/index.ts

View workflow job for this annotation

GitHub Actions / build

Cannot find module './useIMatrixRouting' or its corresponding type declarations.
export * from "./useINumeric";
export * from "./useIRoomEventSchedule";
export * from "./useIRunDirectRouteAction";
export * from "./useIRunRouteAction";
export * from "./useISetTopBoxcontrols";
Expand Down
20 changes: 20 additions & 0 deletions src/lib/shared/hooks/interfaces/useIRoomEventSchedule.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
import { ScheduleEvent, ScheduleState, useGetDevice } from 'src/lib';
import { useWebsocketContext } from 'src/lib/utils/useWebsocketContext';

export function useIRoomEventSchedule(key: string): IRoomEventScheduleReturn | undefined {
const { sendMessage } = useWebsocketContext();
const device = useGetDevice<ScheduleState>(key);

if (!device) return undefined;

const save = (events: ScheduleEvent[]) => {
sendMessage(`/room/${key}/saveScheduledEvents`, events);
};

return { roomEventScheduleState: device, save };
}

export interface IRoomEventScheduleReturn {
roomEventScheduleState: ScheduleState;
save: (events: ScheduleEvent[]) => void;
}
10 changes: 10 additions & 0 deletions src/lib/shared/hooks/useGetDeviceStateFromRoomConfiguration.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,16 @@ export const useGetAllDeviceStateFromRoomConfiguration = ({config}: {config: Roo
deviceKeys.push(config.videoCodecKey);
}

if (config.matrixRoutingKey) {
deviceKeys.push(config.matrixRoutingKey);
}

if (config.endpointKeys) {
config.endpointKeys.forEach((ek) => {
deviceKeys.push(ek);
});
}

for (const value of Object.values(config.sourceList)) {
// if the source has a source key, add it to the list of device keys
if(value.sourceKey && value.sourceKey !== "$off")
Expand Down
10 changes: 10 additions & 0 deletions src/lib/types/state/state/DeviceState.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,4 +31,14 @@ export interface DeviceState extends IKeyName {
interfaces: InterfaceNames[];

commMonitor?: CommunicationMonitorState;

/**
* For future use
*/
state: unknown;

/**
* For future use
*/
// configuration: unknown;
}
9 changes: 7 additions & 2 deletions src/lib/types/state/state/MatrixRoutingState.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,16 +8,21 @@ export interface MatrixRoutingState {
outputs: Record<string, OutputSlot>;
}

export interface InputSlot extends DeviceState, IKeyName, IOnline, IVideoSync {
export interface InputSlot extends DeviceState, IKeyName, IOnline, IVideoSync, ISlotNumber {
txDeviceKey: string;
supportedSignalTypes: SignalType;
}

export interface OutputSlot extends IKeyName {
export interface OutputSlot extends IKeyName, ISlotNumber, IOnline {
rxDeviceKey: string;

currentRoutes: Record<SignalType, InputSlot>;
}

export interface IVideoSync {
videoSyncDetected: boolean;
}

export interface ISlotNumber {
slotNumber: number;
}
5 changes: 4 additions & 1 deletion src/lib/types/state/state/RoomState.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import { DeviceState } from './DeviceState';
import { ShareState } from './ShareState';

/** Base device state class */
export interface RoomState extends DeviceState {
export interface RoomState extends DeviceState{
activityMode?: number;
advancedSharingActive?: boolean;
configuration?: RoomConfiguration; // update with typed class later
Expand Down Expand Up @@ -37,6 +37,9 @@ export interface RoomConfiguration {
videoCodecKey?: string;
touchpanelKeys?: string[];
zoomRoomControllerKey?: string;
matrixRoutingKey?: string;
endpointKeys?: string[];
shutdownPromptSeconds: number;
}

export interface EssentialsRoomUiBehaviorConfiguration {
Expand Down

0 comments on commit 5678df9

Please sign in to comment.