import { Component, OnInit } from '@angular/core'
import { ActivatedRoute, Router } from '@angular/router'
import { LoadingBarService } from '@ngx-loading-bar/core'
-import { NotificationsService } from 'angular2-notifications'
+import { Notifier } from '@app/core'
import { VideoConstant, VideoPrivacy } from '../../../../../shared/models/videos'
import { ServerService } from '../../core'
import { FormReactive } from '../../shared'
import { FormValidatorService } from '@app/shared/forms/form-validators/form-validator.service'
import { VideoCaptionService } from '@app/shared/video-caption'
import { VideoCaptionEdit } from '@app/shared/video-caption/video-caption-edit.model'
+import { VideoDetails } from '@app/shared/video/video-details.model'
@Component({
selector: 'my-videos-update',
userVideoChannels: { id: number, label: string, support: string }[] = []
schedulePublicationPossible = false
videoCaptions: VideoCaptionEdit[] = []
+ waitTranscodingEnabled = true
private updateDone = false
protected formValidatorService: FormValidatorService,
private route: ActivatedRoute,
private router: Router,
- private notificationsService: NotificationsService,
+ private notifier: Notifier,
private serverService: ServerService,
private videoService: VideoService,
private loadingBar: LoadingBarService,
this.videoPrivacies = this.videoService.explainedPrivacyLabels(this.videoPrivacies)
+ const videoFiles = (video as VideoDetails).files
+ if (videoFiles.length > 1) { // Already transcoded
+ this.waitTranscodingEnabled = false
+ }
+
// FIXME: Angular does not detect the change inside this subscription, so use the patched setTimeout
setTimeout(() => this.hydrateFormFromVideo())
},
err => {
console.error(err)
- this.notificationsService.error(this.i18n('Error'), err.message)
+ this.notifier.error(err.message)
}
)
}
}
update () {
- if (this.checkForm() === false) {
+ if (this.checkForm() === false
+ || this.isUpdatingVideo === true) {
return
}
this.updateDone = true
this.isUpdatingVideo = false
this.loadingBar.complete()
- this.notificationsService.success(this.i18n('Success'), this.i18n('Video updated.'))
+ this.notifier.success(this.i18n('Video updated.'))
this.router.navigate([ '/videos/watch', this.video.uuid ])
},
err => {
this.loadingBar.complete()
this.isUpdatingVideo = false
- this.notificationsService.error(this.i18n('Error'), err.message)
+ this.notifier.error(err.message)
console.error(err)
}
)