* issue #196 * fixed missattribution of var * fix styling issue * renamed videoUpload to videoUploadObservable * added created path to gitignore * changed uploadCancel method name to cancelUpload
This commit is contained in:
parent
f8b8c36b2a
commit
8c4890cbfe
|
@ -17,3 +17,8 @@
|
||||||
peertube.zip
|
peertube.zip
|
||||||
/profiling/
|
/profiling/
|
||||||
/*.zip
|
/*.zip
|
||||||
|
thumbnails/
|
||||||
|
torrents/
|
||||||
|
videos/
|
||||||
|
previews/
|
||||||
|
logs/
|
||||||
|
|
|
@ -32,10 +32,15 @@
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<div
|
||||||
|
*ngIf="isUploadingVideo"
|
||||||
|
>
|
||||||
<p-progressBar
|
<p-progressBar
|
||||||
*ngIf="isUploadingVideo" [value]="videoUploadPercents"
|
[value]="videoUploadPercents"
|
||||||
[ngClass]="{ processing: videoUploadPercents === 100 && videoUploaded === false }"
|
[ngClass]="{ processing: videoUploadPercents === 100 && videoUploaded === false }"
|
||||||
></p-progressBar>
|
></p-progressBar>
|
||||||
|
<input type="button" value="Cancel" (click)="cancelUpload()" />
|
||||||
|
</div>
|
||||||
|
|
||||||
<!-- Hidden because we need to load the component -->
|
<!-- Hidden because we need to load the component -->
|
||||||
<form [hidden]="!isUploadingVideo" novalidate [formGroup]="form">
|
<form [hidden]="!isUploadingVideo" novalidate [formGroup]="form">
|
||||||
|
|
|
@ -27,6 +27,7 @@ export class VideoAddComponent extends FormReactive implements OnInit {
|
||||||
|
|
||||||
isUploadingVideo = false
|
isUploadingVideo = false
|
||||||
videoUploaded = false
|
videoUploaded = false
|
||||||
|
videoUploadObservable = null
|
||||||
videoUploadPercents = 0
|
videoUploadPercents = 0
|
||||||
videoUploadedIds = {
|
videoUploadedIds = {
|
||||||
id: 0,
|
id: 0,
|
||||||
|
@ -93,6 +94,16 @@ export class VideoAddComponent extends FormReactive implements OnInit {
|
||||||
return this.form.valid
|
return this.form.valid
|
||||||
}
|
}
|
||||||
|
|
||||||
|
cancelUpload () {
|
||||||
|
if (this.videoUploadObservable !== null) {
|
||||||
|
this.videoUploadObservable.unsubscribe()
|
||||||
|
this.isUploadingVideo = false
|
||||||
|
this.videoUploadPercents = 0
|
||||||
|
this.notificationsService.error('Error', 'Upload cancelled')
|
||||||
|
this.videoUploadObservable = null
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
uploadFirstStep () {
|
uploadFirstStep () {
|
||||||
const videofile = this.videofileInput.nativeElement.files[0]
|
const videofile = this.videofileInput.nativeElement.files[0]
|
||||||
if (!videofile) return
|
if (!videofile) return
|
||||||
|
@ -132,7 +143,7 @@ export class VideoAddComponent extends FormReactive implements OnInit {
|
||||||
channelId
|
channelId
|
||||||
})
|
})
|
||||||
|
|
||||||
this.videoService.uploadVideo(formData).subscribe(
|
this.videoUploadObservable = this.videoService.uploadVideo(formData).subscribe(
|
||||||
event => {
|
event => {
|
||||||
if (event.type === HttpEventType.UploadProgress) {
|
if (event.type === HttpEventType.UploadProgress) {
|
||||||
this.videoUploadPercents = Math.round(100 * event.loaded / event.total)
|
this.videoUploadPercents = Math.round(100 * event.loaded / event.total)
|
||||||
|
@ -142,6 +153,8 @@ export class VideoAddComponent extends FormReactive implements OnInit {
|
||||||
this.videoUploaded = true
|
this.videoUploaded = true
|
||||||
|
|
||||||
this.videoUploadedIds = event.body.video
|
this.videoUploadedIds = event.body.video
|
||||||
|
|
||||||
|
this.videoUploadObservable = null
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
|
@ -149,6 +162,7 @@ export class VideoAddComponent extends FormReactive implements OnInit {
|
||||||
// Reset progress
|
// Reset progress
|
||||||
this.isUploadingVideo = false
|
this.isUploadingVideo = false
|
||||||
this.videoUploadPercents = 0
|
this.videoUploadPercents = 0
|
||||||
|
this.videoUploadObservable = null
|
||||||
this.notificationsService.error('Error', err.message)
|
this.notificationsService.error('Error', err.message)
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
|
Loading…
Reference in New Issue