diff options
Diffstat (limited to 'client/src/app/videos/+video-edit')
7 files changed, 81 insertions, 44 deletions
diff --git a/client/src/app/videos/+video-edit/video-add.component.html b/client/src/app/videos/+video-edit/video-add.component.html index 3bf4101f4..a70788ed8 100644 --- a/client/src/app/videos/+video-edit/video-add.component.html +++ b/client/src/app/videos/+video-edit/video-add.component.html | |||
@@ -28,7 +28,6 @@ | |||
28 | <div class="form-group"> | 28 | <div class="form-group"> |
29 | <label for="category">Channel</label> | 29 | <label for="category">Channel</label> |
30 | <select class="form-control" id="channelId" formControlName="channelId"> | 30 | <select class="form-control" id="channelId" formControlName="channelId"> |
31 | <option></option> | ||
32 | <option *ngFor="let channel of userVideoChannels" [value]="channel.id">{{ channel.label }}</option> | 31 | <option *ngFor="let channel of userVideoChannels" [value]="channel.id">{{ channel.label }}</option> |
33 | </select> | 32 | </select> |
34 | 33 | ||
@@ -103,11 +102,8 @@ | |||
103 | 102 | ||
104 | <div class="form-group"> | 103 | <div class="form-group"> |
105 | <label for="description">Description</label> | 104 | <label for="description">Description</label> |
106 | <textarea | 105 | <my-video-description formControlName="description"></my-video-description> |
107 | id="description" class="form-control" placeholder="Description..." | 106 | |
108 | formControlName="description" | ||
109 | > | ||
110 | </textarea> | ||
111 | <div *ngIf="formErrors.description" class="alert alert-danger"> | 107 | <div *ngIf="formErrors.description" class="alert alert-danger"> |
112 | {{ formErrors.description }} | 108 | {{ formErrors.description }} |
113 | </div> | 109 | </div> |
diff --git a/client/src/app/videos/+video-edit/video-add.component.ts b/client/src/app/videos/+video-edit/video-add.component.ts index 92b03e8c9..5b5557ed9 100644 --- a/client/src/app/videos/+video-edit/video-add.component.ts +++ b/client/src/app/videos/+video-edit/video-add.component.ts | |||
@@ -82,7 +82,7 @@ export class VideoAddComponent extends FormReactive implements OnInit { | |||
82 | category: [ '', VIDEO_CATEGORY.VALIDATORS ], | 82 | category: [ '', VIDEO_CATEGORY.VALIDATORS ], |
83 | licence: [ '', VIDEO_LICENCE.VALIDATORS ], | 83 | licence: [ '', VIDEO_LICENCE.VALIDATORS ], |
84 | language: [ '', VIDEO_LANGUAGE.VALIDATORS ], | 84 | language: [ '', VIDEO_LANGUAGE.VALIDATORS ], |
85 | channelId: [ this.userVideoChannels[0].id, VIDEO_CHANNEL.VALIDATORS ], | 85 | channelId: [ '', VIDEO_CHANNEL.VALIDATORS ], |
86 | description: [ '', VIDEO_DESCRIPTION.VALIDATORS ], | 86 | description: [ '', VIDEO_DESCRIPTION.VALIDATORS ], |
87 | videofile: [ '', VIDEO_FILE.VALIDATORS ], | 87 | videofile: [ '', VIDEO_FILE.VALIDATORS ], |
88 | tags: [ '' ] | 88 | tags: [ '' ] |
@@ -96,10 +96,22 @@ export class VideoAddComponent extends FormReactive implements OnInit { | |||
96 | this.videoLicences = this.serverService.getVideoLicences() | 96 | this.videoLicences = this.serverService.getVideoLicences() |
97 | this.videoLanguages = this.serverService.getVideoLanguages() | 97 | this.videoLanguages = this.serverService.getVideoLanguages() |
98 | 98 | ||
99 | const user = this.authService.getUser() | ||
100 | this.userVideoChannels = user.videoChannels.map(v => ({ id: v.id, label: v.name })) | ||
101 | |||
102 | this.buildForm() | 99 | this.buildForm() |
100 | |||
101 | this.authService.userInformationLoaded | ||
102 | .subscribe( | ||
103 | () => { | ||
104 | const user = this.authService.getUser() | ||
105 | if (!user) return | ||
106 | |||
107 | const videoChannels = user.videoChannels | ||
108 | if (Array.isArray(videoChannels) === false) return | ||
109 | |||
110 | this.userVideoChannels = videoChannels.map(v => ({ id: v.id, label: v.name })) | ||
111 | |||
112 | this.form.patchValue({ channelId: this.userVideoChannels[0].id }) | ||
113 | } | ||
114 | ) | ||
103 | } | 115 | } |
104 | 116 | ||
105 | // The goal is to keep reactive form validation (required field) | 117 | // The goal is to keep reactive form validation (required field) |
diff --git a/client/src/app/videos/+video-edit/video-add.module.ts b/client/src/app/videos/+video-edit/video-add.module.ts index 141d33ad2..3d937b008 100644 --- a/client/src/app/videos/+video-edit/video-add.module.ts +++ b/client/src/app/videos/+video-edit/video-add.module.ts | |||
@@ -1,17 +1,14 @@ | |||
1 | import { NgModule } from '@angular/core' | 1 | import { NgModule } from '@angular/core' |
2 | 2 | ||
3 | import { TagInputModule } from 'ngx-chips' | ||
4 | |||
5 | import { VideoAddRoutingModule } from './video-add-routing.module' | 3 | import { VideoAddRoutingModule } from './video-add-routing.module' |
6 | import { VideoAddComponent } from './video-add.component' | 4 | import { VideoAddComponent } from './video-add.component' |
7 | import { VideoService } from '../shared' | 5 | import { VideoEditModule } from './video-edit.module' |
8 | import { SharedModule } from '../../shared' | 6 | import { SharedModule } from '../../shared' |
9 | 7 | ||
10 | @NgModule({ | 8 | @NgModule({ |
11 | imports: [ | 9 | imports: [ |
12 | TagInputModule, | ||
13 | |||
14 | VideoAddRoutingModule, | 10 | VideoAddRoutingModule, |
11 | VideoEditModule, | ||
15 | SharedModule | 12 | SharedModule |
16 | ], | 13 | ], |
17 | 14 | ||
@@ -23,8 +20,6 @@ import { SharedModule } from '../../shared' | |||
23 | VideoAddComponent | 20 | VideoAddComponent |
24 | ], | 21 | ], |
25 | 22 | ||
26 | providers: [ | 23 | providers: [ ] |
27 | VideoService | ||
28 | ] | ||
29 | }) | 24 | }) |
30 | export class VideoAddModule { } | 25 | export class VideoAddModule { } |
diff --git a/client/src/app/videos/+video-edit/video-edit.module.ts b/client/src/app/videos/+video-edit/video-edit.module.ts new file mode 100644 index 000000000..33f654960 --- /dev/null +++ b/client/src/app/videos/+video-edit/video-edit.module.ts | |||
@@ -0,0 +1,33 @@ | |||
1 | import { NgModule } from '@angular/core' | ||
2 | |||
3 | import { TagInputModule } from 'ngx-chips' | ||
4 | import { TabsModule } from 'ngx-bootstrap/tabs' | ||
5 | |||
6 | import { VideoService, MarkdownService, VideoDescriptionComponent } from '../shared' | ||
7 | import { SharedModule } from '../../shared' | ||
8 | |||
9 | @NgModule({ | ||
10 | imports: [ | ||
11 | TagInputModule, | ||
12 | TabsModule.forRoot(), | ||
13 | |||
14 | SharedModule | ||
15 | ], | ||
16 | |||
17 | declarations: [ | ||
18 | VideoDescriptionComponent | ||
19 | ], | ||
20 | |||
21 | exports: [ | ||
22 | TagInputModule, | ||
23 | TabsModule, | ||
24 | |||
25 | VideoDescriptionComponent | ||
26 | ], | ||
27 | |||
28 | providers: [ | ||
29 | VideoService, | ||
30 | MarkdownService | ||
31 | ] | ||
32 | }) | ||
33 | export class VideoEditModule { } | ||
diff --git a/client/src/app/videos/+video-edit/video-update.component.html b/client/src/app/videos/+video-edit/video-update.component.html index 4dcb3ea56..ec040630e 100644 --- a/client/src/app/videos/+video-edit/video-update.component.html +++ b/client/src/app/videos/+video-edit/video-update.component.html | |||
@@ -62,7 +62,7 @@ | |||
62 | </div> | 62 | </div> |
63 | 63 | ||
64 | <div class="form-group"> | 64 | <div class="form-group"> |
65 | <label for="tags" class="label-tags">Tags</label> <span class="little-information">(press enter to add the tag)</span> | 65 | <label class="label-tags">Tags</label> <span class="little-information">(press enter to add the tag)</span> |
66 | <tag-input | 66 | <tag-input |
67 | [ngModel]="tags" [validators]="tagValidators" [errorMessages]="tagValidatorsMessages" | 67 | [ngModel]="tags" [validators]="tagValidators" [errorMessages]="tagValidatorsMessages" |
68 | formControlName="tags" maxItems="5" modelAsStrings="true" | 68 | formControlName="tags" maxItems="5" modelAsStrings="true" |
@@ -71,11 +71,8 @@ | |||
71 | 71 | ||
72 | <div class="form-group"> | 72 | <div class="form-group"> |
73 | <label for="description">Description</label> | 73 | <label for="description">Description</label> |
74 | <textarea | 74 | <my-video-description formControlName="description"></my-video-description> |
75 | id="description" class="form-control" placeholder="Description..." | 75 | |
76 | formControlName="description" | ||
77 | > | ||
78 | </textarea> | ||
79 | <div *ngIf="formErrors.description" class="alert alert-danger"> | 76 | <div *ngIf="formErrors.description" class="alert alert-danger"> |
80 | {{ formErrors.description }} | 77 | {{ formErrors.description }} |
81 | </div> | 78 | </div> |
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 30390ac05..6ced77f1a 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,8 @@ | |||
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 { Observable } from 'rxjs/Observable' | ||
5 | import 'rxjs/add/observable/forkJoin' | ||
4 | 6 | ||
5 | import { NotificationsService } from 'angular2-notifications' | 7 | import { NotificationsService } from 'angular2-notifications' |
6 | 8 | ||
@@ -84,19 +86,26 @@ export class VideoUpdateComponent extends FormReactive implements OnInit { | |||
84 | this.videoLanguages = this.serverService.getVideoLanguages() | 86 | this.videoLanguages = this.serverService.getVideoLanguages() |
85 | 87 | ||
86 | const uuid: string = this.route.snapshot.params['uuid'] | 88 | const uuid: string = this.route.snapshot.params['uuid'] |
87 | this.videoService.getVideo(uuid) | ||
88 | .subscribe( | ||
89 | video => { | ||
90 | this.video = new VideoEdit(video) | ||
91 | |||
92 | this.hydrateFormFromVideo() | ||
93 | }, | ||
94 | 89 | ||
95 | err => { | 90 | this.videoService.getVideo(uuid) |
96 | console.error(err) | 91 | .switchMap(video => { |
97 | this.error = 'Cannot fetch video.' | 92 | return this.videoService |
98 | } | 93 | .loadCompleteDescription(video.descriptionPath) |
99 | ) | 94 | .do(description => video.description = description) |
95 | .map(() => video) | ||
96 | }) | ||
97 | .subscribe( | ||
98 | video => { | ||
99 | this.video = new VideoEdit(video) | ||
100 | |||
101 | this.hydrateFormFromVideo() | ||
102 | }, | ||
103 | |||
104 | err => { | ||
105 | console.error(err) | ||
106 | this.error = 'Cannot fetch video.' | ||
107 | } | ||
108 | ) | ||
100 | } | 109 | } |
101 | 110 | ||
102 | checkForm () { | 111 | 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 eeb2e35e2..f7bd77c75 100644 --- a/client/src/app/videos/+video-edit/video-update.module.ts +++ b/client/src/app/videos/+video-edit/video-update.module.ts | |||
@@ -1,17 +1,14 @@ | |||
1 | import { NgModule } from '@angular/core' | 1 | import { NgModule } from '@angular/core' |
2 | 2 | ||
3 | import { TagInputModule } from 'ngx-chips' | ||
4 | |||
5 | import { VideoUpdateRoutingModule } from './video-update-routing.module' | 3 | import { VideoUpdateRoutingModule } from './video-update-routing.module' |
6 | import { VideoUpdateComponent } from './video-update.component' | 4 | import { VideoUpdateComponent } from './video-update.component' |
7 | import { VideoService } from '../shared' | 5 | import { VideoEditModule } from './video-edit.module' |
8 | import { SharedModule } from '../../shared' | 6 | import { SharedModule } from '../../shared' |
9 | 7 | ||
10 | @NgModule({ | 8 | @NgModule({ |
11 | imports: [ | 9 | imports: [ |
12 | TagInputModule, | ||
13 | |||
14 | VideoUpdateRoutingModule, | 10 | VideoUpdateRoutingModule, |
11 | VideoEditModule, | ||
15 | SharedModule | 12 | SharedModule |
16 | ], | 13 | ], |
17 | 14 | ||
@@ -23,8 +20,6 @@ import { SharedModule } from '../../shared' | |||
23 | VideoUpdateComponent | 20 | VideoUpdateComponent |
24 | ], | 21 | ], |
25 | 22 | ||
26 | providers: [ | 23 | providers: [ ] |
27 | VideoService | ||
28 | ] | ||
29 | }) | 24 | }) |
30 | export class VideoUpdateModule { } | 25 | export class VideoUpdateModule { } |