11import {
22 Component ,
3+ computed ,
34 EventEmitter ,
5+ inject ,
46 OnInit ,
57 Output ,
6- inject ,
78 signal ,
89 viewChild ,
910} from '@angular/core' ;
@@ -12,7 +13,6 @@ import { MAT_DIALOG_DATA, MatDialogRef } from '@angular/material/dialog';
1213import { MatFormFieldModule } from '@angular/material/form-field' ;
1314import { MatInputModule } from '@angular/material/input' ;
1415import { MatProgressBarModule } from '@angular/material/progress-bar' ;
15- import { MatSelectModule } from '@angular/material/select' ;
1616import { SignagePlugin } from '@placeos/ts-client' ;
1717import { Observable } from 'rxjs' ;
1818
@@ -28,6 +28,7 @@ import { TranslatePipe } from '../../ui/translate.pipe';
2828import { SchemaFormComponent } from './schema-form.component' ;
2929import {
3030 PluginErrorPayload ,
31+ PluginLoadedPayload ,
3132 SignagePluginEmbedComponent ,
3233} from './signage-plugin-embed.component' ;
3334import { generateSignagePluginFormFields } from './signage-plugins.utilities' ;
@@ -126,16 +127,13 @@ export interface SignagePluginModalData {
126127 }}
127128 </label>
128129 <mat-form-field appearance="outline">
129- <mat-select
130+ <input
131+ id="playback-type"
132+ matInput
130133 name="playback-type"
131- formControlName="playback_type"
132- >
133- @for (type of playback_types; track type.id) {
134- <mat-option [value]="type.id">
135- {{ type.name }}
136- </mat-option>
137- }
138- </mat-select>
134+ [value]="playback_type_name()"
135+ readonly
136+ />
139137 </mat-form-field>
140138 </div>
141139 <div class="field mb-4">
@@ -150,12 +148,12 @@ export interface SignagePluginModalData {
150148 </div>
151149 <!-- Schema / Defaults section -->
152150 <div class="field">
153- <label >
151+ <div class="mb-2" >
154152 {{
155153 'ADMIN.SIGNAGE_PLUGINS_FIELD_DEFAULTS'
156154 | translate
157155 }}
158- </label >
156+ </div >
159157 @if (schema_loading()) {
160158 <div
161159 class="flex items-center space-x-2 py-2 text-sm opacity-60"
@@ -209,6 +207,7 @@ export interface SignagePluginModalData {
209207 <div class="hidden">
210208 <signage-plugin-embed
211209 [plugin]="embed_plugin()"
210+ (detailsChange)="onPluginLoaded($event)"
212211 (schemaChange)="onSchemaLoaded($event)"
213212 (plugin_error)="onPluginError($event)"
214213 />
@@ -223,7 +222,6 @@ export interface SignagePluginModalData {
223222 MatFormFieldModule ,
224223 MatInputModule ,
225224 MatProgressBarModule ,
226- MatSelectModule ,
227225 SchemaFormComponent ,
228226 SettingsToggleComponent ,
229227 SignagePluginEmbedComponent ,
@@ -252,25 +250,25 @@ export class SignagePluginModalComponent
252250 public readonly schema = signal < Record < string , unknown > > ( null ) ;
253251 public readonly schema_loading = signal ( false ) ;
254252 public readonly schema_error = signal ( false ) ;
255-
256- public readonly playback_types = [
257- {
258- id : 'static' ,
259- name : i18n ( 'ADMIN.SIGNAGE_PLUGINS_PLAYBACK_STATIC' ) ,
260- } ,
261- {
262- id : 'interactive' ,
263- name : i18n ( 'ADMIN.SIGNAGE_PLUGINS_PLAYBACK_INTERACTIVE' ) ,
264- } ,
265- {
266- id : 'playsthrough' ,
267- name : i18n ( 'ADMIN.SIGNAGE_PLUGINS_PLAYBACK_PLAYSTHROUGH' ) ,
268- } ,
269- ] ;
253+ public readonly playback_type = signal ( 'static' ) ;
254+ public readonly playback_type_name = computed ( ( ) => {
255+ const playback_type = this . playback_type ( ) ;
256+ switch ( playback_type ) {
257+ case 'interactive' :
258+ return i18n ( 'ADMIN.SIGNAGE_PLUGINS_PLAYBACK_INTERACTIVE' ) ;
259+ case 'playsthrough' :
260+ return i18n ( 'ADMIN.SIGNAGE_PLUGINS_PLAYBACK_PLAYSTHROUGH' ) ;
261+ default :
262+ return i18n ( 'ADMIN.SIGNAGE_PLUGINS_PLAYBACK_STATIC' ) ;
263+ }
264+ } ) ;
270265
271266 public ngOnInit ( ) : void {
272267 this . edit = ! ! this . _data . item ?. id ;
273268 this . form = generateSignagePluginFormFields ( this . _data . item ) ;
269+ this . playback_type . set (
270+ this . form . controls . playback_type . value || 'static' ,
271+ ) ;
274272
275273 // If editing and we already have a URI, load the plugin to get schema
276274 if ( this . _data . item ?. uri ) {
@@ -291,6 +289,11 @@ export class SignagePluginModalComponent
291289 this . schema . set ( null ) ;
292290 this . schema_loading . set ( false ) ;
293291 this . schema_error . set ( false ) ;
292+ this . playback_type . set ( 'static' ) ;
293+ this . form . patchValue (
294+ { playback_type : 'static' } ,
295+ { emitEvent : false } ,
296+ ) ;
294297 }
295298 } ,
296299 800 ,
@@ -314,6 +317,13 @@ export class SignagePluginModalComponent
314317 }
315318 }
316319
320+ public onPluginLoaded ( details : PluginLoadedPayload ) : void {
321+ const playback_type = this . _resolvePlaybackType ( details ) ;
322+ if ( ! playback_type ) return ;
323+ this . playback_type . set ( playback_type ) ;
324+ this . form . patchValue ( { playback_type } , { emitEvent : false } ) ;
325+ }
326+
317327 public onPluginError ( _error : PluginErrorPayload ) : void {
318328 this . schema_loading . set ( false ) ;
319329 this . schema_error . set ( true ) ;
@@ -348,7 +358,10 @@ export class SignagePluginModalComponent
348358 metadata : { item : result } ,
349359 } ) ;
350360 notifySuccess ( i18n ( 'ADMIN.SIGNAGE_PLUGINS_SAVE_SUCCESS' ) ) ;
351- this . _dialog_ref . close ( ) ;
361+ this . _dialog_ref . close ( {
362+ reason : 'done' ,
363+ metadata : { item : result } ,
364+ } ) ;
352365 } ,
353366 error : async ( err ) => {
354367 this . loading = null ;
@@ -381,4 +394,12 @@ export class SignagePluginModalComponent
381394 10000 ,
382395 ) ;
383396 }
397+
398+ private _resolvePlaybackType ( details : PluginLoadedPayload ) {
399+ const capabilities = details ?. capabilities ;
400+ if ( ! capabilities ) return null ;
401+ if ( capabilities . static_media ) return 'static' ;
402+ if ( capabilities . can_finish ) return 'playsthrough' ;
403+ return 'interactive' ;
404+ }
384405}
0 commit comments