1+ module . exports = {
2+ getActions : function ( instance ) {
3+ const choices = instance . getSeatChoices ( )
4+ const interpreterChoices = instance . getInterpreterSeatChoices ( )
5+
6+ return {
7+ custom_command : {
8+ name : 'Custom Command' ,
9+ options : [
10+ {
11+ type : 'textinput' ,
12+ label : 'Operation' ,
13+ id : 'operation' ,
14+ default : '' ,
15+ } ,
16+ {
17+ type : 'textinput' ,
18+ label : 'Parameters (JSON)' ,
19+ id : 'parameters' ,
20+ default : '{}' ,
21+ } ,
22+ ] ,
23+ callback : async ( action ) => {
24+ try {
25+ const parameters = JSON . parse ( action . options . parameters )
26+ const message = {
27+ operation : action . options . operation ,
28+ parameters : parameters ,
29+ }
30+ if ( instance . ws && instance . ws . readyState === WebSocket . OPEN ) {
31+ instance . ws . send ( JSON . stringify ( message ) )
32+ } else {
33+ instance . log ( 'error' , '[CUSTOM] WebSocket not connected' )
34+ }
35+ } catch ( error ) {
36+ instance . log ( 'error' , `[CUSTOM] Error parsing parameters JSON: ${ error . message } ` )
37+ }
38+ } ,
39+ } ,
40+ toggle_microphone : {
41+ name : 'Toggle Microphone' ,
42+ options : [
43+ {
44+ type : 'dropdown' ,
45+ label : 'Seat' ,
46+ id : 'seat' ,
47+ default : choices [ 0 ] ?. id || '' ,
48+ choices : choices ,
49+ } ,
50+ ] ,
51+ callback : async ( action ) => {
52+ instance . toggleMicrophone ( action . options . seat )
53+ } ,
54+ } ,
55+ activate_microphone : {
56+ name : 'Activate Microphone' ,
57+ options : [
58+ {
59+ type : 'dropdown' ,
60+ label : 'Seat' ,
61+ id : 'seat' ,
62+ default : choices [ 0 ] ?. id || '' ,
63+ choices,
64+ } ,
65+ ] ,
66+ callback : async ( action ) => {
67+ instance . activateMicrophone ( instance . seats [ action . options . seat ] ?. seatId )
68+ } ,
69+ } ,
70+ deactivate_microphone : {
71+ name : 'Deactivate Microphone' ,
72+ options : [
73+ {
74+ type : 'dropdown' ,
75+ label : 'Seat' ,
76+ id : 'seat' ,
77+ default : choices [ 0 ] ?. id || '' ,
78+ choices,
79+ } ,
80+ ] ,
81+ callback : async ( action ) => {
82+ instance . deactivateMicrophone ( instance . seats [ action . options . seat ] ?. seatId )
83+ } ,
84+ } ,
85+ grant_interpretation : {
86+ name : 'Grant Interpretation' ,
87+ options : [
88+ {
89+ type : 'dropdown' ,
90+ label : 'Interpreter Seat' ,
91+ id : 'interpreter_seat' ,
92+ default : interpreterChoices [ 0 ] ?. id || '' ,
93+ choices : interpreterChoices ,
94+ } ,
95+ {
96+ type : 'dropdown' ,
97+ label : 'State' ,
98+ id : 'state' ,
99+ default : 'off' ,
100+ choices : [
101+ { id : 'off' , label : 'Off' } ,
102+ { id : 'activeOnOutputA' , label : 'Active on Output A' } ,
103+ { id : 'activeOnOutputB' , label : 'Active on Output B' } ,
104+ { id : 'activeOnOutputC' , label : 'Active on Output C' } ,
105+ ] ,
106+ } ,
107+ ] ,
108+ callback : async ( action ) => {
109+ instance . grantInterpretation ( instance . interpreterSeats [ action . options . interpreter_seat ] ?. seatId , action . options . state )
110+ } ,
111+ } ,
112+ }
113+ } ,
114+ }
0 commit comments