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