2022-06-02 12:45:41 +02:00
|
|
|
import { Component, OnInit } from '@angular/core';
|
2024-07-02 19:19:05 +02:00
|
|
|
import { RecordingDeleteRequestedEvent, RecordingInfo } from 'openvidu-components-angular';
|
2022-06-22 12:42:02 +02:00
|
|
|
import { RestService } from 'src/app/services/rest.service';
|
2022-06-02 12:45:41 +02:00
|
|
|
|
|
|
|
@Component({
|
2025-04-30 12:21:38 +02:00
|
|
|
selector: 'app-admin-dashboard',
|
|
|
|
templateUrl: './admin-dashboard.component.html',
|
|
|
|
styleUrls: ['./admin-dashboard.component.scss'],
|
|
|
|
standalone: false
|
2022-06-02 12:45:41 +02:00
|
|
|
})
|
|
|
|
export class AdminDashboardComponent implements OnInit {
|
2024-07-02 19:19:05 +02:00
|
|
|
recordings: RecordingInfo[] = [];
|
2022-06-22 12:42:02 +02:00
|
|
|
logged: boolean;
|
|
|
|
error: any;
|
2024-07-02 19:19:05 +02:00
|
|
|
private continuationToken: string;
|
|
|
|
constructor(
|
|
|
|
private restService: RestService,
|
|
|
|
) {}
|
2022-06-02 12:45:41 +02:00
|
|
|
|
2022-06-22 12:42:02 +02:00
|
|
|
async ngOnInit() {
|
2024-07-02 19:19:05 +02:00
|
|
|
// try {
|
|
|
|
// const resp: any = await this.restService.login('');
|
|
|
|
// this.logged = true;
|
|
|
|
// this.recordings = resp.recordings;
|
|
|
|
// } catch (error) {
|
|
|
|
// this.logged = false;
|
|
|
|
// console.log(error);
|
|
|
|
// }
|
2022-06-22 12:42:02 +02:00
|
|
|
}
|
2022-06-02 12:45:41 +02:00
|
|
|
|
2024-07-02 19:19:05 +02:00
|
|
|
async login(credentials: { username: string; password: string }) {
|
|
|
|
console.log('LOGIN', credentials);
|
2022-06-22 12:42:02 +02:00
|
|
|
try {
|
2024-07-02 19:19:05 +02:00
|
|
|
const resp: any = await this.restService.login(credentials);
|
2022-06-22 12:42:02 +02:00
|
|
|
this.logged = true;
|
2024-07-02 19:19:05 +02:00
|
|
|
|
|
|
|
const response = await this.restService.getRecordings(this.continuationToken);
|
|
|
|
|
|
|
|
this.recordings = response.recordings;
|
|
|
|
this.continuationToken = response.continuationToken;
|
2022-06-22 12:42:02 +02:00
|
|
|
} catch (error) {
|
|
|
|
this.error = error;
|
|
|
|
console.log(error);
|
|
|
|
}
|
|
|
|
}
|
2022-06-02 12:45:41 +02:00
|
|
|
|
2022-06-22 12:42:02 +02:00
|
|
|
async onLogoutClicked() {
|
|
|
|
this.logged = false;
|
|
|
|
await this.restService.logout();
|
|
|
|
}
|
|
|
|
|
|
|
|
async onRefreshRecordingsClicked() {
|
|
|
|
console.log('GET ALL ');
|
2024-07-02 19:19:05 +02:00
|
|
|
const response = await this.restService.getRecordings();
|
|
|
|
this.recordings = response.recordings;
|
|
|
|
this.continuationToken = response.continuationToken;
|
2022-06-22 12:42:02 +02:00
|
|
|
}
|
|
|
|
|
2024-07-02 19:19:05 +02:00
|
|
|
async onLoadMoreRecordingsRequested() {
|
|
|
|
if (!this.continuationToken) return console.warn('No more recordings to load');
|
|
|
|
const response = await this.restService.getRecordings(this.continuationToken);
|
|
|
|
this.recordings = response.recordings;
|
|
|
|
this.continuationToken = response.continuationToken;
|
|
|
|
}
|
|
|
|
|
|
|
|
async onDeleteRecordingClicked(recording: RecordingDeleteRequestedEvent) {
|
|
|
|
console.warn('DELETE RECORDING CLICKED', recording);
|
2022-06-22 12:42:02 +02:00
|
|
|
|
|
|
|
try {
|
2024-07-02 19:19:05 +02:00
|
|
|
await this.restService.deleteRecordingByAdmin(recording.recordingId);
|
|
|
|
const response = await this.restService.getRecordings();
|
|
|
|
this.recordings = response.recordings;
|
2022-06-22 12:42:02 +02:00
|
|
|
} catch (error) {
|
|
|
|
console.error(error);
|
|
|
|
}
|
|
|
|
}
|
2022-06-02 12:45:41 +02:00
|
|
|
}
|