import { Component, OnInit } from '@angular/core'
import { FormBuilder, FormGroup } from '@angular/forms'
import { ActivatedRoute, Router } from '@angular/router'
+import { LoadingBarService } from '@ngx-loading-bar/core'
import { NotificationsService } from 'angular2-notifications'
import 'rxjs/add/observable/forkJoin'
import { VideoPrivacy } from '../../../../../shared/models/videos'
export class VideoUpdateComponent extends FormReactive implements OnInit {
video: VideoEdit
+ isUpdatingVideo = false
form: FormGroup
formErrors: { [ id: string ]: string } = {}
validationMessages: ValidatorMessage = {}
private notificationsService: NotificationsService,
private serverService: ServerService,
private videoService: VideoService,
- private authService: AuthService
+ private authService: AuthService,
+ private loadingBar: LoadingBarService
) {
super()
}
this.video.patch(this.form.value)
+ this.loadingBar.start()
+ this.isUpdatingVideo = true
this.videoService.updateVideo(this.video)
.subscribe(
() => {
+ this.isUpdatingVideo = false
+ this.loadingBar.complete()
this.notificationsService.success('Success', 'Video updated.')
this.router.navigate([ '/videos/watch', this.video.uuid ])
},
err => {
+ this.isUpdatingVideo = false
this.notificationsService.error('Error', err.message)
console.error(err)
}