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 './auth.guard';
|
||||||
export * from './extract-query-params.guard';
|
export * from './extract-query-params.guard';
|
||||||
export * from './moderator-secret.guard';
|
export * from './moderator-secret.guard';
|
||||||
|
|||||||
@ -1,6 +1,5 @@
|
|||||||
import { Routes } from '@angular/router';
|
import { Routes } from '@angular/router';
|
||||||
import {
|
import {
|
||||||
applicationModeGuard,
|
|
||||||
checkParticipantRoleAndAuthGuard,
|
checkParticipantRoleAndAuthGuard,
|
||||||
checkRecordingAuthGuard,
|
checkRecordingAuthGuard,
|
||||||
checkUserAuthenticatedGuard,
|
checkUserAuthenticatedGuard,
|
||||||
@ -18,11 +17,11 @@ import {
|
|||||||
ErrorComponent,
|
ErrorComponent,
|
||||||
LoginComponent,
|
LoginComponent,
|
||||||
OverviewComponent,
|
OverviewComponent,
|
||||||
UsersPermissionsComponent,
|
|
||||||
RecordingsComponent,
|
RecordingsComponent,
|
||||||
RoomRecordingsComponent,
|
RoomRecordingsComponent,
|
||||||
RoomsComponent,
|
RoomsComponent,
|
||||||
RoomWizardComponent,
|
RoomWizardComponent,
|
||||||
|
UsersPermissionsComponent,
|
||||||
VideoRoomComponent,
|
VideoRoomComponent,
|
||||||
ViewRecordingComponent
|
ViewRecordingComponent
|
||||||
} from '@lib/pages';
|
} from '@lib/pages';
|
||||||
@ -36,16 +35,13 @@ export const baseRoutes: Routes = [
|
|||||||
{
|
{
|
||||||
path: 'room/:room-id',
|
path: 'room/:room-id',
|
||||||
component: VideoRoomComponent,
|
component: VideoRoomComponent,
|
||||||
canActivate: [
|
canActivate: [runGuardsSerially(extractRoomQueryParamsGuard, checkParticipantRoleAndAuthGuard)]
|
||||||
runGuardsSerially(applicationModeGuard, extractRoomQueryParamsGuard, checkParticipantRoleAndAuthGuard)
|
|
||||||
]
|
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
path: 'room/:room-id/recordings',
|
path: 'room/:room-id/recordings',
|
||||||
component: RoomRecordingsComponent,
|
component: RoomRecordingsComponent,
|
||||||
canActivate: [
|
canActivate: [
|
||||||
runGuardsSerially(
|
runGuardsSerially(
|
||||||
applicationModeGuard,
|
|
||||||
extractRecordingQueryParamsGuard,
|
extractRecordingQueryParamsGuard,
|
||||||
checkParticipantRoleAndAuthGuard,
|
checkParticipantRoleAndAuthGuard,
|
||||||
validateRecordingAccessGuard,
|
validateRecordingAccessGuard,
|
||||||
@ -56,7 +52,7 @@ export const baseRoutes: Routes = [
|
|||||||
{
|
{
|
||||||
path: 'recording/:recording-id',
|
path: 'recording/:recording-id',
|
||||||
component: ViewRecordingComponent,
|
component: ViewRecordingComponent,
|
||||||
canActivate: [runGuardsSerially(applicationModeGuard, checkRecordingAuthGuard)]
|
canActivate: [checkRecordingAuthGuard]
|
||||||
},
|
},
|
||||||
{ path: 'disconnected', component: DisconnectedComponent },
|
{ path: 'disconnected', component: DisconnectedComponent },
|
||||||
{ path: 'error', component: ErrorComponent },
|
{ path: 'error', component: ErrorComponent },
|
||||||
|
|||||||
@ -1,5 +1,6 @@
|
|||||||
import { Injectable } from '@angular/core';
|
import { Injectable } from '@angular/core';
|
||||||
import { AppData, ApplicationMode, Edition } from '@lib/models';
|
import { AppData, ApplicationMode, Edition } from '@lib/models';
|
||||||
|
import { WebComponentManagerService } from '@lib/services';
|
||||||
|
|
||||||
@Injectable({
|
@Injectable({
|
||||||
providedIn: 'root'
|
providedIn: 'root'
|
||||||
@ -11,9 +12,20 @@ export class AppDataService {
|
|||||||
version: ''
|
version: ''
|
||||||
};
|
};
|
||||||
|
|
||||||
setApplicationMode(mode: ApplicationMode): void {
|
constructor(protected wcManagerService: WebComponentManagerService) {
|
||||||
console.log(`Starting application in ${mode} mode`);
|
this.setApplicationMode();
|
||||||
this.appData.mode = mode;
|
}
|
||||||
|
|
||||||
|
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 {
|
isEmbeddedMode(): boolean {
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user