feat: display uploaded video after successful upload

This commit is contained in:
Chneemann 2025-05-02 08:38:37 +02:00
parent 3861464092
commit 039711b18f
3 changed files with 16 additions and 3 deletions

View file

@ -92,5 +92,6 @@
@if (uploadVideoOverview) {
<app-upload-video
(toggleUploadVideoOverview)="toggleUploadVideoOverview($event)"
(uploadedVideo)="onVideoUploaded($event)"
></app-upload-video>
}

View file

@ -92,6 +92,14 @@ export class HomeComponent implements OnInit {
}
}
onVideoUploaded(video: Video) {
this.currentVideo = null;
setTimeout(() => {
this.currentVideo = video;
this.videos.push(video);
}, 1);
}
isWideScreen() {
return window.innerWidth > 600;
}

View file

@ -5,6 +5,7 @@ import { ErrorService } from '../../../services/error.service';
import { BtnLargeComponent } from '../../../shared/components/buttons/btn-large/btn-large.component';
import { VideoService } from '../../../services/video.service';
import { LoadingDialogComponent } from '../../../shared/components/loading-dialog/loading-dialog.component';
import { Video } from '../../../interfaces/video.interface';
@Component({
selector: 'app-upload-video',
@ -20,6 +21,7 @@ import { LoadingDialogComponent } from '../../../shared/components/loading-dialo
})
export class UploadVideoComponent {
@Output() toggleUploadVideoOverview = new EventEmitter<boolean>();
@Output() uploadedVideo = new EventEmitter<Video>();
errorMsgFileSize: string | null = null;
maxFileSizeMB = 20;
@ -73,12 +75,14 @@ export class UploadVideoComponent {
try {
this.videoData.send = true;
let formData = this.createFormData();
await this.videoService.uploadVideo(formData);
const formData = this.createFormData();
const uploaded = await this.videoService.uploadVideo(formData);
this.uploadedVideo.emit(uploaded);
ngForm.resetForm();
this.closeVideoUploadOverview();
this.videoData.send = false;
window.location.reload();
this.errorService.clearError();
} catch (error) {
this.errorService.handleError(error);