Skip to content

Commit

Permalink
frontend: Renamed rest services to http service
Browse files Browse the repository at this point in the history
  • Loading branch information
CSantosM committed Aug 19, 2024
1 parent aee51d7 commit 55dc727
Show file tree
Hide file tree
Showing 6 changed files with 27 additions and 27 deletions.
4 changes: 2 additions & 2 deletions openvidu-call-front/src/app/core/guards/room.guard.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,13 @@ import { inject } from '@angular/core';
import { ActivatedRouteSnapshot, Router, RouterStateSnapshot } from '@angular/router';
import { ConfigService } from '../services/config.service';
import { StorageService } from '../services/storage.service';
import { RestService } from '../services/rest.service';
import { HttpService } from '../services/http.service';
import { CanActivateFn } from '@angular/router';

export const roomGuard: CanActivateFn = async (route: ActivatedRouteSnapshot, state: RouterStateSnapshot) => {
const configService = inject(ConfigService);
const storageService = inject(StorageService);
const restService = inject(RestService);
const restService = inject(HttpService);
const router = inject(Router);

try {
Expand Down
4 changes: 2 additions & 2 deletions openvidu-call-front/src/app/core/services/config.service.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { Injectable } from '@angular/core';
import { RestService } from './rest.service';
import { HttpService } from './http.service';

@Injectable({
providedIn: 'root'
Expand All @@ -8,7 +8,7 @@ export class ConfigService {
private config: { isPrivate: boolean };
private initialization: Promise<void>;

constructor(private restService: RestService) {}
constructor(private restService: HttpService) {}

async initialize(): Promise<void> {
if (!this.initialization) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import { StorageService } from './storage.service';
@Injectable({
providedIn: 'root'
})
export class RestService {
export class HttpService {
// private baseHref: string;
private pathPrefix = 'call/api';

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { Component, OnDestroy, OnInit } from '@angular/core';
import { RestService } from '@services/rest.service';
import { HttpService } from '@services/http.service';
import { StorageService } from '@services/storage.service';
import { OpenViduComponentsModule, ApiDirectiveModule } from 'openvidu-components-angular';

Expand All @@ -17,7 +17,7 @@ export class AdminDashboardComponent implements OnInit, OnDestroy {
error: any;
private continuationToken: string;
constructor(
private restService: RestService,
private httpService: HttpService,
private storageService: StorageService
) {}

Expand All @@ -41,9 +41,9 @@ export class AdminDashboardComponent implements OnInit, OnDestroy {

async onLoginClicked(credentials: { username: string; password: string }) {
try {
await this.restService.adminLogin(credentials);
await this.httpService.adminLogin(credentials);
this.storageService.setAdminCredentials(credentials);
const { recordings, continuationToken } = await this.restService.getRecordings();
const { recordings, continuationToken } = await this.httpService.getRecordings();
this.recordings = recordings;
this.continuationToken = continuationToken;
this.isParticipantLoggedIn = true;
Expand All @@ -60,7 +60,7 @@ export class AdminDashboardComponent implements OnInit, OnDestroy {
this.storageService.clearAdminCredentials();
this.recordings = [];
this.continuationToken = null;
await this.restService.adminLogout();
await this.httpService.adminLogout();
} catch (error) {
console.error(error);
}
Expand All @@ -69,14 +69,14 @@ export class AdminDashboardComponent implements OnInit, OnDestroy {
async onLoadMoreRecordingsRequested() {
if (!this.continuationToken) return console.warn('No more recordings to load');

const response = await this.restService.getRecordings(this.continuationToken);
const response = await this.httpService.getRecordings(this.continuationToken);
this.recordings = response.recordings;
this.continuationToken = response.continuationToken;
}

async onRefreshRecordingsClicked() {
try {
const response = await this.restService.getRecordings();
const response = await this.httpService.getRecordings();
this.recordings = response.recordings;
this.continuationToken = response.continuationToken;
} catch (error) {
Expand All @@ -86,8 +86,8 @@ export class AdminDashboardComponent implements OnInit, OnDestroy {

async onDeleteRecordingClicked(recordingId: string) {
try {
await this.restService.deleteRecordingByAdmin(recordingId);
const response = await this.restService.getRecordings();
await this.httpService.deleteRecordingByAdmin(recordingId);
const response = await this.httpService.getRecordings();
this.recordings = response.recordings;
this.continuationToken = response.continuationToken;
} catch (error) {
Expand Down
10 changes: 5 additions & 5 deletions openvidu-call-front/src/app/pages/home/home.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ import { ActivatedRoute, Router } from '@angular/router';
import { Subscription } from 'rxjs';

import { ConfigService } from '@services/config.service';
import { RestService } from '@services/rest.service';
import { HttpService } from '@services/http.service';
import { StorageService } from '@services/storage.service';

import packageInfo from '../../../../package.json';
Expand Down Expand Up @@ -55,7 +55,7 @@ export class HomeComponent implements OnInit, OnDestroy {
constructor(
private router: Router,
public formBuilder: UntypedFormBuilder,
private restService: RestService,
private httpService: HttpService,
private storageService: StorageService,
private callService: ConfigService,
private fb: FormBuilder,
Expand Down Expand Up @@ -84,7 +84,7 @@ export class HomeComponent implements OnInit, OnDestroy {

if (!userCredentials) return;

await this.restService.userLogin(userCredentials);
await this.httpService.userLogin(userCredentials);
this.storageService.setUserCredentials(userCredentials);
this.username = this.storageService.getUserName();
this.isUserLogged = true;
Expand Down Expand Up @@ -126,7 +126,7 @@ export class HomeComponent implements OnInit, OnDestroy {
const password = this.loginForm.get('password').value;

try {
await this.restService.userLogin({ username: this.username, password });
await this.httpService.userLogin({ username: this.username, password });
this.storageService.setUserCredentials({ username: this.username, password });
this.isUserLogged = true;
} catch (error) {
Expand All @@ -138,7 +138,7 @@ export class HomeComponent implements OnInit, OnDestroy {

async logout() {
try {
await this.restService.userLogout();
await this.httpService.userLogout();
this.storageService.clearUserCredentials();
this.loginError = false;
this.isUserLogged = false;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import {
} from 'openvidu-components-angular';
import { MatIcon } from '@angular/material/icon';

import { RestService } from '@services/rest.service';
import { HttpService } from '@services/http.service';

@Component({
selector: 'app-video-room',
Expand All @@ -28,7 +28,7 @@ export class VideoRoomComponent implements OnInit {
loading = true;

constructor(
private restService: RestService,
private httpService: HttpService,
private router: Router,
private route: ActivatedRoute
) {}
Expand All @@ -41,7 +41,7 @@ export class VideoRoomComponent implements OnInit {

async onTokenRequested(participantName: string) {
try {
const { token } = await this.restService.getToken(this.roomName, participantName);
const { token } = await this.httpService.getToken(this.roomName, participantName);
this.token = token;
} catch (error) {
console.error(error);
Expand All @@ -60,7 +60,7 @@ export class VideoRoomComponent implements OnInit {
async onRecordingStartRequested(event: RecordingStartRequestedEvent) {
try {
const { roomName } = event;
await this.restService.startRecording(roomName);
await this.httpService.startRecording(roomName);
} catch (error) {
console.error(error);
}
Expand All @@ -72,7 +72,7 @@ export class VideoRoomComponent implements OnInit {

if(!recordingId) throw new Error('Recording ID not found when stopping recording');

await this.restService.stopRecording(recordingId);
await this.httpService.stopRecording(recordingId);
} catch (error) {
console.error(error);
}
Expand All @@ -84,7 +84,7 @@ export class VideoRoomComponent implements OnInit {

if(!recordingId) throw new Error('Recording ID not found when deleting recording');

await this.restService.deleteRecording(recordingId);
await this.httpService.deleteRecording(recordingId);
} catch (error) {
console.error(error);
}
Expand All @@ -93,7 +93,7 @@ export class VideoRoomComponent implements OnInit {
async onBroadcastingStartRequested(event: BroadcastingStartRequestedEvent) {
try {
const { roomName, broadcastUrl } = event;
await this.restService.startBroadcasting(roomName, broadcastUrl);
await this.httpService.startBroadcasting(roomName, broadcastUrl);
} catch (error) {
console.error(error);
}
Expand All @@ -102,7 +102,7 @@ export class VideoRoomComponent implements OnInit {
async onBroadcastingStopRequested(event: BroadcastingStopRequestedEvent) {
try {
const { broadcastingId } = event;
await this.restService.stopBroadcasting(broadcastingId);
await this.httpService.stopBroadcasting(broadcastingId);
} catch (error) {
console.error(error);
}
Expand Down

0 comments on commit 55dc727

Please sign in to comment.