aboutsummaryrefslogtreecommitdiffhomepage
path: root/client/src/app
diff options
context:
space:
mode:
Diffstat (limited to 'client/src/app')
-rw-r--r--client/src/app/+my-account/my-account-videos/my-account-videos.component.ts2
-rw-r--r--client/src/app/videos/+video-edit/video-update-routing.module.ts6
-rw-r--r--client/src/app/videos/+video-edit/video-update.component.ts70
-rw-r--r--client/src/app/videos/+video-edit/video-update.module.ts5
-rw-r--r--client/src/app/videos/+video-edit/video-update.resolver.ts45
5 files changed, 78 insertions, 50 deletions
diff --git a/client/src/app/+my-account/my-account-videos/my-account-videos.component.ts b/client/src/app/+my-account/my-account-videos/my-account-videos.component.ts
index e698b75ec..54830c75e 100644
--- a/client/src/app/+my-account/my-account-videos/my-account-videos.component.ts
+++ b/client/src/app/+my-account/my-account-videos/my-account-videos.component.ts
@@ -38,10 +38,10 @@ export class MyAccountVideosComponent extends AbstractVideoList implements OnIni
38 protected route: ActivatedRoute, 38 protected route: ActivatedRoute,
39 protected authService: AuthService, 39 protected authService: AuthService,
40 protected notificationsService: NotificationsService, 40 protected notificationsService: NotificationsService,
41 protected confirmService: ConfirmService,
42 protected location: Location, 41 protected location: Location,
43 protected screenService: ScreenService, 42 protected screenService: ScreenService,
44 protected i18n: I18n, 43 protected i18n: I18n,
44 private confirmService: ConfirmService,
45 private videoService: VideoService, 45 private videoService: VideoService,
46 @Inject(LOCALE_ID) private localeId: string 46 @Inject(LOCALE_ID) private localeId: string
47 ) { 47 ) {
diff --git a/client/src/app/videos/+video-edit/video-update-routing.module.ts b/client/src/app/videos/+video-edit/video-update-routing.module.ts
index 22c27a072..dfeeb8a90 100644
--- a/client/src/app/videos/+video-edit/video-update-routing.module.ts
+++ b/client/src/app/videos/+video-edit/video-update-routing.module.ts
@@ -5,12 +5,16 @@ import { MetaGuard } from '@ngx-meta/core'
5 5
6import { LoginGuard } from '../../core' 6import { LoginGuard } from '../../core'
7import { VideoUpdateComponent } from './video-update.component' 7import { VideoUpdateComponent } from './video-update.component'
8import { VideoUpdateResolver } from '@app/videos/+video-edit/video-update.resolver'
8 9
9const videoUpdateRoutes: Routes = [ 10const videoUpdateRoutes: Routes = [
10 { 11 {
11 path: '', 12 path: '',
12 component: VideoUpdateComponent, 13 component: VideoUpdateComponent,
13 canActivate: [ MetaGuard, LoginGuard ] 14 canActivate: [ MetaGuard, LoginGuard ],
15 resolve: {
16 videoData: VideoUpdateResolver
17 }
14 } 18 }
15] 19]
16 20
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 4fe65bccd..774772e14 100644
--- a/client/src/app/videos/+video-edit/video-update.component.ts
+++ b/client/src/app/videos/+video-edit/video-update.component.ts
@@ -49,55 +49,31 @@ export class VideoUpdateComponent extends FormReactive implements OnInit {
49 this.buildForm({}) 49 this.buildForm({})
50 50
51 this.serverService.videoPrivaciesLoaded 51 this.serverService.videoPrivaciesLoaded
52 .subscribe(() => this.videoPrivacies = this.serverService.getVideoPrivacies()) 52 .subscribe(() => this.videoPrivacies = this.serverService.getVideoPrivacies())
53
54 this.route.data
55 .pipe(map(data => data.videoData))
56 .subscribe(({ video, videoChannels, videoCaptions }) => {
57 this.video = new VideoEdit(video)
58 this.userVideoChannels = videoChannels
59 this.videoCaptions = videoCaptions
60
61 // We cannot set private a video that was not private
62 if (this.video.privacy !== VideoPrivacy.PRIVATE) {
63 this.videoPrivacies = this.videoPrivacies.filter(p => p.id.toString() !== VideoPrivacy.PRIVATE.toString())
64 } else { // We can schedule video publication only if it it is private
65 this.schedulePublicationPossible = this.video.privacy === VideoPrivacy.PRIVATE
66 }
53 67
54 const uuid: string = this.route.snapshot.params[ 'uuid' ] 68 // FIXME: Angular does not detec
55 this.videoService.getVideo(uuid) 69 setTimeout(() => this.hydrateFormFromVideo())
56 .pipe( 70 },
57 switchMap(video => {
58 return this.videoService
59 .loadCompleteDescription(video.descriptionPath)
60 .pipe(map(description => Object.assign(video, { description })))
61 }),
62 switchMap(video => {
63 return this.videoChannelService
64 .listAccountVideoChannels(video.account)
65 .pipe(
66 map(result => result.data),
67 map(videoChannels => videoChannels.map(c => ({ id: c.id, label: c.displayName, support: c.support }))),
68 map(videoChannels => ({ video, videoChannels }))
69 )
70 }),
71 switchMap(({ video, videoChannels }) => {
72 return this.videoCaptionService
73 .listCaptions(video.id)
74 .pipe(
75 map(result => result.data),
76 map(videoCaptions => ({ video, videoChannels, videoCaptions }))
77 )
78 })
79 )
80 .subscribe(
81 ({ video, videoChannels, videoCaptions }) => {
82 this.video = new VideoEdit(video)
83 this.userVideoChannels = videoChannels
84 this.videoCaptions = videoCaptions
85
86 // We cannot set private a video that was not private
87 if (this.video.privacy !== VideoPrivacy.PRIVATE) {
88 this.videoPrivacies = this.videoPrivacies.filter(p => p.id.toString() !== VideoPrivacy.PRIVATE.toString())
89 } else { // We can schedule video publication only if it it is private
90 this.schedulePublicationPossible = this.video.privacy === VideoPrivacy.PRIVATE
91 }
92
93 this.hydrateFormFromVideo()
94 },
95 71
96 err => { 72 err => {
97 console.error(err) 73 console.error(err)
98 this.notificationsService.error(this.i18n('Error'), err.message) 74 this.notificationsService.error(this.i18n('Error'), err.message)
99 } 75 }
100 ) 76 )
101 } 77 }
102 78
103 checkForm () { 79 checkForm () {
diff --git a/client/src/app/videos/+video-edit/video-update.module.ts b/client/src/app/videos/+video-edit/video-update.module.ts
index 3b45c72a5..4f5d72cec 100644
--- a/client/src/app/videos/+video-edit/video-update.module.ts
+++ b/client/src/app/videos/+video-edit/video-update.module.ts
@@ -3,6 +3,7 @@ import { SharedModule } from '../../shared'
3import { VideoEditModule } from './shared/video-edit.module' 3import { VideoEditModule } from './shared/video-edit.module'
4import { VideoUpdateRoutingModule } from './video-update-routing.module' 4import { VideoUpdateRoutingModule } from './video-update-routing.module'
5import { VideoUpdateComponent } from './video-update.component' 5import { VideoUpdateComponent } from './video-update.component'
6import { VideoUpdateResolver } from '@app/videos/+video-edit/video-update.resolver'
6 7
7@NgModule({ 8@NgModule({
8 imports: [ 9 imports: [
@@ -19,6 +20,8 @@ import { VideoUpdateComponent } from './video-update.component'
19 VideoUpdateComponent 20 VideoUpdateComponent
20 ], 21 ],
21 22
22 providers: [ ] 23 providers: [
24 VideoUpdateResolver
25 ]
23}) 26})
24export class VideoUpdateModule { } 27export class VideoUpdateModule { }
diff --git a/client/src/app/videos/+video-edit/video-update.resolver.ts b/client/src/app/videos/+video-edit/video-update.resolver.ts
new file mode 100644
index 000000000..269fe3684
--- /dev/null
+++ b/client/src/app/videos/+video-edit/video-update.resolver.ts
@@ -0,0 +1,45 @@
1import { Injectable } from '@angular/core'
2import { VideoService } from '@app/shared/video/video.service'
3import { ActivatedRouteSnapshot, Resolve } from '@angular/router'
4import { map, switchMap } from 'rxjs/operators'
5import { VideoChannelService } from '@app/shared/video-channel/video-channel.service'
6import { VideoCaptionService } from '@app/shared/video-caption'
7
8@Injectable()
9export class VideoUpdateResolver implements Resolve<any> {
10 constructor (
11 private videoService: VideoService,
12 private videoChannelService: VideoChannelService,
13 private videoCaptionService: VideoCaptionService
14 ) {}
15
16 resolve (route: ActivatedRouteSnapshot) {
17 const uuid: string = route.params[ 'uuid' ]
18
19 return this.videoService.getVideo(uuid)
20 .pipe(
21 switchMap(video => {
22 return this.videoService
23 .loadCompleteDescription(video.descriptionPath)
24 .pipe(map(description => Object.assign(video, { description })))
25 }),
26 switchMap(video => {
27 return this.videoChannelService
28 .listAccountVideoChannels(video.account)
29 .pipe(
30 map(result => result.data),
31 map(videoChannels => videoChannels.map(c => ({ id: c.id, label: c.displayName, support: c.support }))),
32 map(videoChannels => ({ video, videoChannels }))
33 )
34 }),
35 switchMap(({ video, videoChannels }) => {
36 return this.videoCaptionService
37 .listCaptions(video.id)
38 .pipe(
39 map(result => result.data),
40 map(videoCaptions => ({ video, videoChannels, videoCaptions }))
41 )
42 })
43 )
44 }
45}