frontend: remove application mode guard and update app data service to handle application mode initialization
This commit is contained in:
parent
82756ef151
commit
8e95f1e372
@ -1,21 +0,0 @@
|
||||
import { inject } from '@angular/core';
|
||||
import { ActivatedRouteSnapshot, CanActivateFn, RouterStateSnapshot } from '@angular/router';
|
||||
import { ApplicationMode } from '@lib/models';
|
||||
import { AppDataService, WebComponentManagerService } from '@lib/services';
|
||||
|
||||
export const applicationModeGuard: CanActivateFn = (_route: ActivatedRouteSnapshot, _state: RouterStateSnapshot) => {
|
||||
const appDataService = inject(AppDataService);
|
||||
const commandsManagerService = inject(WebComponentManagerService);
|
||||
|
||||
const isRequestedFromIframe = window.self !== window.top;
|
||||
|
||||
const applicationMode = isRequestedFromIframe ? ApplicationMode.EMBEDDED : ApplicationMode.STANDALONE;
|
||||
appDataService.setApplicationMode(applicationMode);
|
||||
|
||||
if (appDataService.isEmbeddedMode()) {
|
||||
// Start listening for commands from the iframe
|
||||
commandsManagerService.startCommandsListener();
|
||||
}
|
||||
|
||||
return true;
|
||||
};
|
||||
@ -1,4 +1,3 @@
|
||||
export * from './application-mode.guard';
|
||||
export * from './auth.guard';
|
||||
export * from './extract-query-params.guard';
|
||||
export * from './moderator-secret.guard';
|
||||
|
||||
@ -1,6 +1,5 @@
|
||||
import { Routes } from '@angular/router';
|
||||
import {
|
||||
applicationModeGuard,
|
||||
checkParticipantRoleAndAuthGuard,
|
||||
checkRecordingAuthGuard,
|
||||
checkUserAuthenticatedGuard,
|
||||
@ -18,11 +17,11 @@ import {
|
||||
ErrorComponent,
|
||||
LoginComponent,
|
||||
OverviewComponent,
|
||||
UsersPermissionsComponent,
|
||||
RecordingsComponent,
|
||||
RoomRecordingsComponent,
|
||||
RoomsComponent,
|
||||
RoomWizardComponent,
|
||||
UsersPermissionsComponent,
|
||||
VideoRoomComponent,
|
||||
ViewRecordingComponent
|
||||
} from '@lib/pages';
|
||||
@ -36,16 +35,13 @@ export const baseRoutes: Routes = [
|
||||
{
|
||||
path: 'room/:room-id',
|
||||
component: VideoRoomComponent,
|
||||
canActivate: [
|
||||
runGuardsSerially(applicationModeGuard, extractRoomQueryParamsGuard, checkParticipantRoleAndAuthGuard)
|
||||
]
|
||||
canActivate: [runGuardsSerially(extractRoomQueryParamsGuard, checkParticipantRoleAndAuthGuard)]
|
||||
},
|
||||
{
|
||||
path: 'room/:room-id/recordings',
|
||||
component: RoomRecordingsComponent,
|
||||
canActivate: [
|
||||
runGuardsSerially(
|
||||
applicationModeGuard,
|
||||
extractRecordingQueryParamsGuard,
|
||||
checkParticipantRoleAndAuthGuard,
|
||||
validateRecordingAccessGuard,
|
||||
@ -56,7 +52,7 @@ export const baseRoutes: Routes = [
|
||||
{
|
||||
path: 'recording/:recording-id',
|
||||
component: ViewRecordingComponent,
|
||||
canActivate: [runGuardsSerially(applicationModeGuard, checkRecordingAuthGuard)]
|
||||
canActivate: [checkRecordingAuthGuard]
|
||||
},
|
||||
{ path: 'disconnected', component: DisconnectedComponent },
|
||||
{ path: 'error', component: ErrorComponent },
|
||||
|
||||
@ -1,5 +1,6 @@
|
||||
import { Injectable } from '@angular/core';
|
||||
import { AppData, ApplicationMode, Edition } from '@lib/models';
|
||||
import { WebComponentManagerService } from '@lib/services';
|
||||
|
||||
@Injectable({
|
||||
providedIn: 'root'
|
||||
@ -11,9 +12,20 @@ export class AppDataService {
|
||||
version: ''
|
||||
};
|
||||
|
||||
setApplicationMode(mode: ApplicationMode): void {
|
||||
console.log(`Starting application in ${mode} mode`);
|
||||
this.appData.mode = mode;
|
||||
constructor(protected wcManagerService: WebComponentManagerService) {
|
||||
this.setApplicationMode();
|
||||
}
|
||||
|
||||
private setApplicationMode(): void {
|
||||
const isRequestedFromIframe = window.self !== window.top;
|
||||
const appMode = isRequestedFromIframe ? ApplicationMode.EMBEDDED : ApplicationMode.STANDALONE;
|
||||
this.appData.mode = appMode;
|
||||
console.log(`Starting application in ${appMode} mode`);
|
||||
|
||||
if (this.isEmbeddedMode()) {
|
||||
// Initialize the WebComponentManagerService only in embedded mode
|
||||
this.wcManagerService.initialize();
|
||||
}
|
||||
}
|
||||
|
||||
isEmbeddedMode(): boolean {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user