frontend: remove AdminDashboardComponent and add RoomRecordingsComponent structure
This commit is contained in:
parent
c80b88fc67
commit
1a3b567f29
@ -13,3 +13,4 @@ export * from './login/login.component';
|
|||||||
export * from './video-room/video-room.component';
|
export * from './video-room/video-room.component';
|
||||||
export * from './participant-name-form/participant-name-form.component';
|
export * from './participant-name-form/participant-name-form.component';
|
||||||
export * from './disconnected/disconnected.component';
|
export * from './disconnected/disconnected.component';
|
||||||
|
export * from './room-recordings/room-recordings.component';
|
||||||
|
|||||||
@ -0,0 +1,8 @@
|
|||||||
|
@if (!loading) {
|
||||||
|
<ov-admin-dashboard
|
||||||
|
[recordingsList]="[]"
|
||||||
|
(onLoadMoreRecordingsRequested)="onLoadMoreRecordingsRequested()"
|
||||||
|
(onRefreshRecordingsRequested)="onRefreshRecordingsClicked()"
|
||||||
|
(onRecordingDeleteRequested)="onDeleteRecordingClicked($event)"
|
||||||
|
></ov-admin-dashboard>
|
||||||
|
}
|
||||||
@ -0,0 +1,23 @@
|
|||||||
|
import { ComponentFixture, TestBed } from '@angular/core/testing';
|
||||||
|
import { RoomRecordingsComponent } from './room-recordings.component';
|
||||||
|
|
||||||
|
describe('RoomRecordingsComponent', () => {
|
||||||
|
let component: RoomRecordingsComponent;
|
||||||
|
let fixture: ComponentFixture<RoomRecordingsComponent>;
|
||||||
|
|
||||||
|
beforeEach(async () => {
|
||||||
|
await TestBed.configureTestingModule({
|
||||||
|
imports: [RoomRecordingsComponent]
|
||||||
|
}).compileComponents();
|
||||||
|
});
|
||||||
|
|
||||||
|
beforeEach(() => {
|
||||||
|
fixture = TestBed.createComponent(RoomRecordingsComponent);
|
||||||
|
component = fixture.componentInstance;
|
||||||
|
fixture.detectChanges();
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should create', () => {
|
||||||
|
expect(component).toBeTruthy();
|
||||||
|
});
|
||||||
|
});
|
||||||
@ -0,0 +1,63 @@
|
|||||||
|
import { HttpErrorResponse } from '@angular/common/http';
|
||||||
|
import { Component, OnInit } from '@angular/core';
|
||||||
|
import { HttpService } from '@lib/services';
|
||||||
|
import {
|
||||||
|
OpenViduComponentsModule,
|
||||||
|
ApiDirectiveModule,
|
||||||
|
RecordingDeleteRequestedEvent
|
||||||
|
} from 'openvidu-components-angular';
|
||||||
|
import { MeetRecordingInfo } from 'shared-meet-components';
|
||||||
|
|
||||||
|
@Component({
|
||||||
|
selector: 'app-room-recordings',
|
||||||
|
templateUrl: './room-recordings.component.html',
|
||||||
|
styleUrls: ['./room-recordings.component.scss'],
|
||||||
|
standalone: true,
|
||||||
|
imports: [OpenViduComponentsModule, ApiDirectiveModule]
|
||||||
|
})
|
||||||
|
export class RoomRecordingsComponent implements OnInit {
|
||||||
|
recordings: MeetRecordingInfo[] = [];
|
||||||
|
loading = true;
|
||||||
|
error = '';
|
||||||
|
private continuationToken: string | undefined;
|
||||||
|
|
||||||
|
constructor(private httpService: HttpService) {}
|
||||||
|
|
||||||
|
async ngOnInit() {
|
||||||
|
await this.loadRecordings();
|
||||||
|
console.log('Recordings loaded:', this.recordings);
|
||||||
|
}
|
||||||
|
|
||||||
|
async onLoadMoreRecordingsRequested() {
|
||||||
|
if (!this.continuationToken) {
|
||||||
|
console.warn('No more recordings to load');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
await this.loadRecordings();
|
||||||
|
}
|
||||||
|
|
||||||
|
async onRefreshRecordingsClicked() {
|
||||||
|
await this.loadRecordings();
|
||||||
|
}
|
||||||
|
|
||||||
|
async onDeleteRecordingClicked(deleteRequest: RecordingDeleteRequestedEvent) {
|
||||||
|
try {
|
||||||
|
await this.httpService.deleteRecording(deleteRequest.recordingId!);
|
||||||
|
} catch (error) {
|
||||||
|
console.log(error);
|
||||||
|
}
|
||||||
|
|
||||||
|
await this.loadRecordings();
|
||||||
|
}
|
||||||
|
|
||||||
|
private async loadRecordings() {
|
||||||
|
try {
|
||||||
|
const { recordings, continuationToken } = await this.httpService.getRecordings(this.continuationToken);
|
||||||
|
this.recordings = recordings;
|
||||||
|
this.continuationToken = continuationToken;
|
||||||
|
} catch (error) {
|
||||||
|
console.log(error);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -1,13 +0,0 @@
|
|||||||
@if (!loading && !isParticipantLoggedIn) {
|
|
||||||
<ov-admin-login [error]="error" (onLoginRequested)="onLoginClicked($event)"></ov-admin-login>
|
|
||||||
}
|
|
||||||
|
|
||||||
@if (!loading && isParticipantLoggedIn) {
|
|
||||||
<ov-admin-dashboard
|
|
||||||
[recordingsList]="recordings"
|
|
||||||
(onLogoutRequested)="onLogoutClicked()"
|
|
||||||
(onLoadMoreRecordingsRequested)="onLoadMoreRecordingsRequested($event)"
|
|
||||||
(onRefreshRecordingsRequested)="onRefreshRecordingsClicked()"
|
|
||||||
(onRecordingDeleteRequested)="onDeleteRecordingClicked($event)"
|
|
||||||
></ov-admin-dashboard>
|
|
||||||
}
|
|
||||||
@ -1,23 +0,0 @@
|
|||||||
import { ComponentFixture, TestBed } from '@angular/core/testing';
|
|
||||||
import { AdminDashboardComponent } from './admin-dashboard.component';
|
|
||||||
|
|
||||||
describe('AdminDashboardComponent', () => {
|
|
||||||
let component: AdminDashboardComponent;
|
|
||||||
let fixture: ComponentFixture<AdminDashboardComponent>;
|
|
||||||
|
|
||||||
beforeEach(async () => {
|
|
||||||
await TestBed.configureTestingModule({
|
|
||||||
imports: [AdminDashboardComponent]
|
|
||||||
}).compileComponents();
|
|
||||||
});
|
|
||||||
|
|
||||||
beforeEach(() => {
|
|
||||||
fixture = TestBed.createComponent(AdminDashboardComponent);
|
|
||||||
component = fixture.componentInstance;
|
|
||||||
fixture.detectChanges();
|
|
||||||
});
|
|
||||||
|
|
||||||
it('should create', () => {
|
|
||||||
expect(component).toBeTruthy();
|
|
||||||
});
|
|
||||||
});
|
|
||||||
@ -1,97 +0,0 @@
|
|||||||
import { Component, OnDestroy, OnInit } from '@angular/core';
|
|
||||||
import { HttpService } from '@services/http.service';
|
|
||||||
import { StorageAppService } from '@services/storage.service';
|
|
||||||
import { OpenViduComponentsModule, ApiDirectiveModule } from 'openvidu-components-angular';
|
|
||||||
|
|
||||||
@Component({
|
|
||||||
selector: 'app-admin-dashboard',
|
|
||||||
templateUrl: './admin-dashboard.component.html',
|
|
||||||
styleUrls: ['./admin-dashboard.component.scss'],
|
|
||||||
standalone: true,
|
|
||||||
imports: [OpenViduComponentsModule, ApiDirectiveModule]
|
|
||||||
})
|
|
||||||
export class AdminDashboardComponent implements OnInit, OnDestroy {
|
|
||||||
recordings = [];
|
|
||||||
loading = true;
|
|
||||||
isParticipantLoggedIn = false;
|
|
||||||
error: any;
|
|
||||||
private continuationToken: string;
|
|
||||||
constructor(
|
|
||||||
private httpService: HttpService,
|
|
||||||
private storageService: StorageAppService
|
|
||||||
) {}
|
|
||||||
|
|
||||||
async ngOnInit() {
|
|
||||||
try {
|
|
||||||
const adminCredentials = this.storageService.getAdminCredentials();
|
|
||||||
|
|
||||||
if (adminCredentials) {
|
|
||||||
await this.onLoginClicked(adminCredentials);
|
|
||||||
}
|
|
||||||
} catch (error) {
|
|
||||||
this.storageService.clearAdminCredentials();
|
|
||||||
}
|
|
||||||
|
|
||||||
this.loading = false;
|
|
||||||
}
|
|
||||||
|
|
||||||
ngOnDestroy() {
|
|
||||||
this.onLogoutClicked();
|
|
||||||
}
|
|
||||||
|
|
||||||
async onLoginClicked(credentials: { username: string; password: string }) {
|
|
||||||
try {
|
|
||||||
await this.httpService.adminLogin(credentials);
|
|
||||||
this.storageService.setAdminCredentials(credentials);
|
|
||||||
const { recordings, continuationToken } = await this.httpService.getRecordings();
|
|
||||||
this.recordings = recordings;
|
|
||||||
this.continuationToken = continuationToken;
|
|
||||||
this.isParticipantLoggedIn = true;
|
|
||||||
} catch (error) {
|
|
||||||
console.log(error);
|
|
||||||
this.onLogoutClicked();
|
|
||||||
this.error = error;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
async onLogoutClicked() {
|
|
||||||
try {
|
|
||||||
this.isParticipantLoggedIn = false;
|
|
||||||
this.storageService.clearAdminCredentials();
|
|
||||||
this.recordings = [];
|
|
||||||
this.continuationToken = null;
|
|
||||||
await this.httpService.adminLogout();
|
|
||||||
} catch (error) {
|
|
||||||
console.error(error);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
async onLoadMoreRecordingsRequested() {
|
|
||||||
if (!this.continuationToken) return console.warn('No more recordings to load');
|
|
||||||
|
|
||||||
const response = await this.httpService.getRecordings(this.continuationToken);
|
|
||||||
this.recordings = response.recordings;
|
|
||||||
this.continuationToken = response.continuationToken;
|
|
||||||
}
|
|
||||||
|
|
||||||
async onRefreshRecordingsClicked() {
|
|
||||||
try {
|
|
||||||
const response = await this.httpService.getRecordings();
|
|
||||||
this.recordings = response.recordings;
|
|
||||||
this.continuationToken = response.continuationToken;
|
|
||||||
} catch (error) {
|
|
||||||
this.onLogoutClicked();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
async onDeleteRecordingClicked(recordingId: string) {
|
|
||||||
try {
|
|
||||||
await this.httpService.deleteRecordingByAdmin(recordingId);
|
|
||||||
const response = await this.httpService.getRecordings();
|
|
||||||
this.recordings = response.recordings;
|
|
||||||
this.continuationToken = response.continuationToken;
|
|
||||||
} catch (error) {
|
|
||||||
console.error(error);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
Loading…
x
Reference in New Issue
Block a user