diff options
author | Chocobozzz <me@florianbigard.com> | 2018-02-16 17:24:47 +0100 |
---|---|---|
committer | Chocobozzz <me@florianbigard.com> | 2018-02-16 17:24:47 +0100 |
commit | 68e24d727969a73a13e3c29b4d3bcfe50c3c52be (patch) | |
tree | 9908a5b6f26dfc0fd80aa123e843ea11f39c7501 /client/src/app/videos/+video-edit/video-update.component.ts | |
parent | 6de36768980ef6063b8fcd730b59fa685dd2b99c (diff) | |
download | PeerTube-68e24d727969a73a13e3c29b4d3bcfe50c3c52be.tar.gz PeerTube-68e24d727969a73a13e3c29b4d3bcfe50c3c52be.tar.zst PeerTube-68e24d727969a73a13e3c29b4d3bcfe50c3c52be.zip |
Add loading bar when updating a video
Diffstat (limited to 'client/src/app/videos/+video-edit/video-update.component.ts')
-rw-r--r-- | client/src/app/videos/+video-edit/video-update.component.ts | 10 |
1 files changed, 9 insertions, 1 deletions
diff --git a/client/src/app/videos/+video-edit/video-update.component.ts b/client/src/app/videos/+video-edit/video-update.component.ts index ad6452835..de34555ab 100644 --- a/client/src/app/videos/+video-edit/video-update.component.ts +++ b/client/src/app/videos/+video-edit/video-update.component.ts | |||
@@ -1,6 +1,7 @@ | |||
1 | import { Component, OnInit } from '@angular/core' | 1 | import { Component, OnInit } from '@angular/core' |
2 | import { FormBuilder, FormGroup } from '@angular/forms' | 2 | import { FormBuilder, FormGroup } from '@angular/forms' |
3 | import { ActivatedRoute, Router } from '@angular/router' | 3 | import { ActivatedRoute, Router } from '@angular/router' |
4 | import { LoadingBarService } from '@ngx-loading-bar/core' | ||
4 | import { NotificationsService } from 'angular2-notifications' | 5 | import { NotificationsService } from 'angular2-notifications' |
5 | import 'rxjs/add/observable/forkJoin' | 6 | import 'rxjs/add/observable/forkJoin' |
6 | import { VideoPrivacy } from '../../../../../shared/models/videos' | 7 | import { VideoPrivacy } from '../../../../../shared/models/videos' |
@@ -21,6 +22,7 @@ import { VideoService } from '../../shared/video/video.service' | |||
21 | export class VideoUpdateComponent extends FormReactive implements OnInit { | 22 | export class VideoUpdateComponent extends FormReactive implements OnInit { |
22 | video: VideoEdit | 23 | video: VideoEdit |
23 | 24 | ||
25 | isUpdatingVideo = false | ||
24 | form: FormGroup | 26 | form: FormGroup |
25 | formErrors: { [ id: string ]: string } = {} | 27 | formErrors: { [ id: string ]: string } = {} |
26 | validationMessages: ValidatorMessage = {} | 28 | validationMessages: ValidatorMessage = {} |
@@ -34,7 +36,8 @@ export class VideoUpdateComponent extends FormReactive implements OnInit { | |||
34 | private notificationsService: NotificationsService, | 36 | private notificationsService: NotificationsService, |
35 | private serverService: ServerService, | 37 | private serverService: ServerService, |
36 | private videoService: VideoService, | 38 | private videoService: VideoService, |
37 | private authService: AuthService | 39 | private authService: AuthService, |
40 | private loadingBar: LoadingBarService | ||
38 | ) { | 41 | ) { |
39 | super() | 42 | super() |
40 | } | 43 | } |
@@ -98,14 +101,19 @@ export class VideoUpdateComponent extends FormReactive implements OnInit { | |||
98 | 101 | ||
99 | this.video.patch(this.form.value) | 102 | this.video.patch(this.form.value) |
100 | 103 | ||
104 | this.loadingBar.start() | ||
105 | this.isUpdatingVideo = true | ||
101 | this.videoService.updateVideo(this.video) | 106 | this.videoService.updateVideo(this.video) |
102 | .subscribe( | 107 | .subscribe( |
103 | () => { | 108 | () => { |
109 | this.isUpdatingVideo = false | ||
110 | this.loadingBar.complete() | ||
104 | this.notificationsService.success('Success', 'Video updated.') | 111 | this.notificationsService.success('Success', 'Video updated.') |
105 | this.router.navigate([ '/videos/watch', this.video.uuid ]) | 112 | this.router.navigate([ '/videos/watch', this.video.uuid ]) |
106 | }, | 113 | }, |
107 | 114 | ||
108 | err => { | 115 | err => { |
116 | this.isUpdatingVideo = false | ||
109 | this.notificationsService.error('Error', err.message) | 117 | this.notificationsService.error('Error', err.message) |
110 | console.error(err) | 118 | console.error(err) |
111 | } | 119 | } |