Skip to content

Commit

Permalink
frontend: Moved guards to common library
Browse files Browse the repository at this point in the history
  • Loading branch information
CSantosM committed Oct 25, 2024
1 parent c0a036f commit 8112dbe
Show file tree
Hide file tree
Showing 10 changed files with 20 additions and 229 deletions.
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
import { inject } from '@angular/core';
import { ActivatedRouteSnapshot, CanActivateFn, Router, RouterStateSnapshot } from '@angular/router';
import { ContextService, ApplicationMode } from 'shared-call-components';
import { ContextService } from '../services';
import { ApplicationMode } from '../models';


export const embeddedGuard: CanActivateFn = async (route: ActivatedRouteSnapshot, state: RouterStateSnapshot) => {
const contextService = inject(ContextService);
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
export * from './embedded.guard';
export * from './non-embedded.guard';
export * from './standard.guard';
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { inject } from '@angular/core';
import { ActivatedRouteSnapshot, Router, RouterStateSnapshot, CanActivateFn } from '@angular/router';
import { ApplicationMode, ContextService } from 'shared-call-components';
import { ContextService } from '../services';
import { ApplicationMode } from '../models';

export const standardGuard: CanActivateFn = async (route: ActivatedRouteSnapshot, state: RouterStateSnapshot) => {
const contextService = inject(ContextService);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ export class ContextService {
* @param isEmbedded - A boolean indicating whether the application is in embedded mode.
*/
setApplicationMode(mode: ApplicationMode): void {
console.warn('SET APP MODE', mode);
this.log.d('Setting application mode', mode);
this.context.mode = mode;
}

Expand Down
3 changes: 2 additions & 1 deletion frontend/projects/shared-call-components/src/public-api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,5 @@
export * from './lib/components/index';
export * from './lib/services/index';
export * from './lib/models/index';
export * from './lib/pages/index';
export * from './lib/pages/index';
export * from './lib/guards/index';
10 changes: 5 additions & 5 deletions frontend/src/app/app.routes.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
import { Routes } from '@angular/router';
import { HomeComponent } from '@app/pages/home/home.component';
import { VideoRoomComponent } from '@app/pages/video-room/video-room.component';
import { standardGuard } from '@app/guards/standard.guard';
import { embeddedGuard } from '@app/guards/embedded.guard';
import { nonEmbeddedGuard } from '@app/guards/non-embedded.guard';

import {
RoomPreferencesComponent,
Expand All @@ -13,7 +10,10 @@ import {
ConsoleComponent,
AboutComponent,
SecurityPreferencesComponent,
OverviewComponent
OverviewComponent,
embeddedGuard,
nonEmbeddedGuard,
standardGuard
} from 'shared-call-components';
export const routes: Routes = [
// Embedded mode
Expand Down Expand Up @@ -44,5 +44,5 @@ export const routes: Routes = [
{ path: 'unauthorized', component: UnauthorizedComponent },

// Redirect all other routes to home
{path: '**', redirectTo: 'home'}
{ path: '**', redirectTo: 'home' }
];
8 changes: 4 additions & 4 deletions frontend/src/app/pages/home/home.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import { ActivatedRoute, Router } from '@angular/router';

import { Subscription } from 'rxjs';

import { ConfigService } from '@app/services/config.service';
// import { ConfigService } from '@app/services/config.service';
import { StorageAppService } from '@app/services/storage.service';
import { HttpService } from 'shared-call-components';

Expand Down Expand Up @@ -48,7 +48,7 @@ export class HomeComponent implements OnInit, OnDestroy {
public formBuilder: UntypedFormBuilder,
private httpService: HttpService,
private storageService: StorageAppService,
private callService: ConfigService,
// private callService: ConfigService,
private fb: FormBuilder,
private route: ActivatedRoute
) {
Expand All @@ -70,8 +70,8 @@ export class HomeComponent implements OnInit, OnDestroy {
this.subscribeToQueryParams();

try {
await this.callService.initialize();
this.isPrivateAccess = this.callService.isPrivateAccess();
// await this.callService.initialize();
// this.isPrivateAccess = this.callService.isPrivateAccess();

if (this.isPrivateAccess) {
const userCredentials = this.storageService.getParticipantCredentials();
Expand Down
40 changes: 0 additions & 40 deletions frontend/src/app/services/config.service.ts

This file was deleted.

176 changes: 0 additions & 176 deletions frontend/src/app/services/http.service.ts

This file was deleted.

0 comments on commit 8112dbe

Please sign in to comment.