aboutsummaryrefslogtreecommitdiffhomepage
path: root/client/src/app/videos
diff options
context:
space:
mode:
authorChocobozzz <florian.bigard@gmail.com>2017-10-09 19:12:40 +0200
committerChocobozzz <florian.bigard@gmail.com>2017-10-09 19:12:40 +0200
commitdb7af09bd8e9de57cdda88c2e32387551235b3a4 (patch)
tree8e3cac831be63a2c66e3b6d5e3b22e33492fb726 /client/src/app/videos
parentbcd1c9e19447a98d605385fab69b5cfa58d0ba4b (diff)
downloadPeerTube-db7af09bd8e9de57cdda88c2e32387551235b3a4.tar.gz
PeerTube-db7af09bd8e9de57cdda88c2e32387551235b3a4.tar.zst
PeerTube-db7af09bd8e9de57cdda88c2e32387551235b3a4.zip
Client: fix loading server configurations
Diffstat (limited to 'client/src/app/videos')
-rw-r--r--client/src/app/videos/+video-edit/video-add.component.ts12
-rw-r--r--client/src/app/videos/+video-edit/video-update.component.ts13
-rw-r--r--client/src/app/videos/shared/video.service.ts32
-rw-r--r--client/src/app/videos/video-list/video-miniature.component.ts15
-rw-r--r--client/src/app/videos/videos.component.ts14
5 files changed, 18 insertions, 68 deletions
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 21311b184..d930423c2 100644
--- a/client/src/app/videos/+video-edit/video-add.component.ts
+++ b/client/src/app/videos/+video-edit/video-add.component.ts
@@ -11,12 +11,13 @@ import {
11 VIDEO_LICENCE, 11 VIDEO_LICENCE,
12 VIDEO_LANGUAGE, 12 VIDEO_LANGUAGE,
13 VIDEO_DESCRIPTION, 13 VIDEO_DESCRIPTION,
14 VIDEO_TAGS 14 VIDEO_TAGS,
15 VIDEO_FILE
15} from '../../shared' 16} from '../../shared'
17import { ServerService} from '../../core'
16import { VideoService } from '../shared' 18import { VideoService } from '../shared'
17import { VideoCreate } from '../../../../../shared' 19import { VideoCreate } from '../../../../../shared'
18import { HttpEventType, HttpResponse } from '@angular/common/http' 20import { HttpEventType, HttpResponse } from '@angular/common/http'
19import { VIDEO_FILE } from '../../shared/forms/form-validators/video'
20 21
21@Component({ 22@Component({
22 selector: 'my-videos-add', 23 selector: 'my-videos-add',
@@ -59,6 +60,7 @@ export class VideoAddComponent extends FormReactive implements OnInit {
59 private formBuilder: FormBuilder, 60 private formBuilder: FormBuilder,
60 private router: Router, 61 private router: Router,
61 private notificationsService: NotificationsService, 62 private notificationsService: NotificationsService,
63 private serverService: ServerService,
62 private videoService: VideoService 64 private videoService: VideoService
63 ) { 65 ) {
64 super() 66 super()
@@ -84,9 +86,9 @@ export class VideoAddComponent extends FormReactive implements OnInit {
84 } 86 }
85 87
86 ngOnInit () { 88 ngOnInit () {
87 this.videoCategories = this.videoService.videoCategories 89 this.videoCategories = this.serverService.getVideoCategories()
88 this.videoLicences = this.videoService.videoLicences 90 this.videoLicences = this.serverService.getVideoLicences()
89 this.videoLanguages = this.videoService.videoLanguages 91 this.videoLanguages = this.serverService.getVideoLanguages()
90 92
91 this.buildForm() 93 this.buildForm()
92 } 94 }
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 141ed3522..6d45265e7 100644
--- a/client/src/app/videos/+video-edit/video-update.component.ts
+++ b/client/src/app/videos/+video-edit/video-update.component.ts
@@ -1,10 +1,10 @@
1import { Component, ElementRef, OnInit } from '@angular/core' 1import { Component, OnInit } from '@angular/core'
2import { FormBuilder, FormGroup } from '@angular/forms' 2import { FormBuilder, FormGroup } from '@angular/forms'
3import { ActivatedRoute, Router } from '@angular/router' 3import { ActivatedRoute, Router } from '@angular/router'
4 4
5import { NotificationsService } from 'angular2-notifications' 5import { NotificationsService } from 'angular2-notifications'
6 6
7import { AuthService } from '../../core' 7import { ServerService } from '../../core'
8import { 8import {
9 FormReactive, 9 FormReactive,
10 VIDEO_NAME, 10 VIDEO_NAME,
@@ -52,12 +52,11 @@ export class VideoUpdateComponent extends FormReactive implements OnInit {
52 fileError = '' 52 fileError = ''
53 53
54 constructor ( 54 constructor (
55 private authService: AuthService,
56 private elementRef: ElementRef,
57 private formBuilder: FormBuilder, 55 private formBuilder: FormBuilder,
58 private route: ActivatedRoute, 56 private route: ActivatedRoute,
59 private router: Router, 57 private router: Router,
60 private notificationsService: NotificationsService, 58 private notificationsService: NotificationsService,
59 private serverService: ServerService,
61 private videoService: VideoService 60 private videoService: VideoService
62 ) { 61 ) {
63 super() 62 super()
@@ -80,9 +79,9 @@ export class VideoUpdateComponent extends FormReactive implements OnInit {
80 ngOnInit () { 79 ngOnInit () {
81 this.buildForm() 80 this.buildForm()
82 81
83 this.videoCategories = this.videoService.videoCategories 82 this.videoCategories = this.serverService.getVideoCategories()
84 this.videoLicences = this.videoService.videoLicences 83 this.videoLicences = this.serverService.getVideoLicences()
85 this.videoLanguages = this.videoService.videoLanguages 84 this.videoLanguages = this.serverService.getVideoLanguages()
86 85
87 const uuid: string = this.route.snapshot.params['uuid'] 86 const uuid: string = this.route.snapshot.params['uuid']
88 this.videoService.getVideo(uuid) 87 this.videoService.getVideo(uuid)
diff --git a/client/src/app/videos/shared/video.service.ts b/client/src/app/videos/shared/video.service.ts
index cfce4cb16..037c20416 100644
--- a/client/src/app/videos/shared/video.service.ts
+++ b/client/src/app/videos/shared/video.service.ts
@@ -14,7 +14,6 @@ import {
14import { Video } from './video.model' 14import { Video } from './video.model'
15import { VideoPagination } from './video-pagination.model' 15import { VideoPagination } from './video-pagination.model'
16import { 16import {
17 VideoCreate,
18 UserVideoRate, 17 UserVideoRate,
19 VideoRateType, 18 VideoRateType,
20 VideoUpdate, 19 VideoUpdate,
@@ -28,28 +27,12 @@ import {
28export class VideoService { 27export class VideoService {
29 private static BASE_VIDEO_URL = API_URL + '/api/v1/videos/' 28 private static BASE_VIDEO_URL = API_URL + '/api/v1/videos/'
30 29
31 videoCategories: Array<{ id: number, label: string }> = []
32 videoLicences: Array<{ id: number, label: string }> = []
33 videoLanguages: Array<{ id: number, label: string }> = []
34
35 constructor ( 30 constructor (
36 private authHttp: HttpClient, 31 private authHttp: HttpClient,
37 private restExtractor: RestExtractor, 32 private restExtractor: RestExtractor,
38 private restService: RestService 33 private restService: RestService
39 ) {} 34 ) {}
40 35
41 loadVideoCategories () {
42 return this.loadVideoAttributeEnum('categories', this.videoCategories)
43 }
44
45 loadVideoLicences () {
46 return this.loadVideoAttributeEnum('licences', this.videoLicences)
47 }
48
49 loadVideoLanguages () {
50 return this.loadVideoAttributeEnum('languages', this.videoLanguages)
51 }
52
53 getVideo (uuid: string) { 36 getVideo (uuid: string) {
54 return this.authHttp.get<VideoServerModel>(VideoService.BASE_VIDEO_URL + uuid) 37 return this.authHttp.get<VideoServerModel>(VideoService.BASE_VIDEO_URL + uuid)
55 .map(videoHash => new Video(videoHash)) 38 .map(videoHash => new Video(videoHash))
@@ -74,8 +57,7 @@ export class VideoService {
74 .catch(this.restExtractor.handleError) 57 .catch(this.restExtractor.handleError)
75 } 58 }
76 59
77 // uploadVideo (video: VideoCreate) { 60 uploadVideo (video: FormData) {
78 uploadVideo (video: any) {
79 const req = new HttpRequest('POST', `${VideoService.BASE_VIDEO_URL}/upload`, video, { reportProgress: true }) 61 const req = new HttpRequest('POST', `${VideoService.BASE_VIDEO_URL}/upload`, video, { reportProgress: true })
80 62
81 return this.authHttp.request(req) 63 return this.authHttp.request(req)
@@ -175,16 +157,4 @@ export class VideoService {
175 157
176 return { videos, totalVideos } 158 return { videos, totalVideos }
177 } 159 }
178
179 private loadVideoAttributeEnum (attributeName: 'categories' | 'licences' | 'languages', hashToPopulate: { id: number, label: string }[]) {
180 return this.authHttp.get(VideoService.BASE_VIDEO_URL + attributeName)
181 .subscribe(data => {
182 Object.keys(data).forEach(dataKey => {
183 hashToPopulate.push({
184 id: parseInt(dataKey, 10),
185 label: data[dataKey]
186 })
187 })
188 })
189 }
190} 160}
diff --git a/client/src/app/videos/video-list/video-miniature.component.ts b/client/src/app/videos/video-list/video-miniature.component.ts
index 1cfeacf36..8d8b817ee 100644
--- a/client/src/app/videos/video-list/video-miniature.component.ts
+++ b/client/src/app/videos/video-list/video-miniature.component.ts
@@ -1,9 +1,6 @@
1import { Component, Input, Output, EventEmitter } from '@angular/core' 1import { Component, Input } from '@angular/core'
2 2
3import { NotificationsService } from 'angular2-notifications' 3import { SortField, Video } from '../shared'
4
5import { ConfirmService, ConfigService } from '../../core'
6import { SortField, Video, VideoService } from '../shared'
7import { User } from '../../shared' 4import { User } from '../../shared'
8 5
9@Component({ 6@Component({
@@ -11,19 +8,11 @@ import { User } from '../../shared'
11 styleUrls: [ './video-miniature.component.scss' ], 8 styleUrls: [ './video-miniature.component.scss' ],
12 templateUrl: './video-miniature.component.html' 9 templateUrl: './video-miniature.component.html'
13}) 10})
14
15export class VideoMiniatureComponent { 11export class VideoMiniatureComponent {
16 @Input() currentSort: SortField 12 @Input() currentSort: SortField
17 @Input() user: User 13 @Input() user: User
18 @Input() video: Video 14 @Input() video: Video
19 15
20 constructor (
21 private notificationsService: NotificationsService,
22 private confirmService: ConfirmService,
23 private configService: ConfigService,
24 private videoService: VideoService
25 ) {}
26
27 getVideoName () { 16 getVideoName () {
28 if (this.isVideoNSFWForThisUser()) { 17 if (this.isVideoNSFWForThisUser()) {
29 return 'NSFW' 18 return 'NSFW'
diff --git a/client/src/app/videos/videos.component.ts b/client/src/app/videos/videos.component.ts
index 80ff46a0a..585a3ad9a 100644
--- a/client/src/app/videos/videos.component.ts
+++ b/client/src/app/videos/videos.component.ts
@@ -1,16 +1,6 @@
1import { Component, OnInit } from '@angular/core' 1import { Component } from '@angular/core'
2
3import { VideoService } from './shared'
4 2
5@Component({ 3@Component({
6 template: '<router-outlet></router-outlet>' 4 template: '<router-outlet></router-outlet>'
7}) 5})
8export class VideosComponent implements OnInit { 6export class VideosComponent {}
9 constructor (private videoService: VideoService) {}
10
11 ngOnInit () {
12 this.videoService.loadVideoCategories()
13 this.videoService.loadVideoLicences()
14 this.videoService.loadVideoLanguages()
15 }
16}