diff options
Diffstat (limited to 'client')
-rw-r--r-- | client/src/app/app.component.ts | 10 | ||||
-rw-r--r-- | client/src/app/core/config/config.service.ts | 26 | ||||
-rw-r--r-- | client/src/app/core/config/index.ts | 1 | ||||
-rw-r--r-- | client/src/app/core/core.module.ts | 4 | ||||
-rw-r--r-- | client/src/app/core/index.ts | 2 | ||||
-rw-r--r-- | client/src/app/core/menu/menu.component.ts | 6 | ||||
-rw-r--r-- | client/src/app/core/server/index.ts | 1 | ||||
-rw-r--r-- | client/src/app/core/server/server.service.ts | 67 | ||||
-rw-r--r-- | client/src/app/videos/+video-edit/video-add.component.ts | 12 | ||||
-rw-r--r-- | client/src/app/videos/+video-edit/video-update.component.ts | 13 | ||||
-rw-r--r-- | client/src/app/videos/shared/video.service.ts | 32 | ||||
-rw-r--r-- | client/src/app/videos/video-list/video-miniature.component.ts | 15 | ||||
-rw-r--r-- | client/src/app/videos/videos.component.ts | 14 |
13 files changed, 99 insertions, 104 deletions
diff --git a/client/src/app/app.component.ts b/client/src/app/app.component.ts index 82e647c98..68719f73d 100644 --- a/client/src/app/app.component.ts +++ b/client/src/app/app.component.ts | |||
@@ -1,7 +1,7 @@ | |||
1 | import { Component, OnInit, ViewContainerRef } from '@angular/core' | 1 | import { Component, OnInit, ViewContainerRef } from '@angular/core' |
2 | import { Router } from '@angular/router' | 2 | import { Router } from '@angular/router' |
3 | 3 | ||
4 | import { AuthService, ConfigService } from './core' | 4 | import { AuthService, ServerService } from './core' |
5 | import { UserService } from './shared' | 5 | import { UserService } from './shared' |
6 | 6 | ||
7 | @Component({ | 7 | @Component({ |
@@ -28,7 +28,7 @@ export class AppComponent implements OnInit { | |||
28 | constructor ( | 28 | constructor ( |
29 | private router: Router, | 29 | private router: Router, |
30 | private authService: AuthService, | 30 | private authService: AuthService, |
31 | private configService: ConfigService, | 31 | private serverService: ServerService, |
32 | private userService: UserService | 32 | private userService: UserService |
33 | ) {} | 33 | ) {} |
34 | 34 | ||
@@ -40,7 +40,11 @@ export class AppComponent implements OnInit { | |||
40 | this.userService.checkTokenValidity() | 40 | this.userService.checkTokenValidity() |
41 | } | 41 | } |
42 | 42 | ||
43 | this.configService.loadConfig() | 43 | // Load custom data from server |
44 | this.serverService.loadConfig() | ||
45 | this.serverService.loadVideoCategories() | ||
46 | this.serverService.loadVideoLanguages() | ||
47 | this.serverService.loadVideoLicences() | ||
44 | 48 | ||
45 | // Do not display menu on small screens | 49 | // Do not display menu on small screens |
46 | if (window.innerWidth < 600) { | 50 | if (window.innerWidth < 600) { |
diff --git a/client/src/app/core/config/config.service.ts b/client/src/app/core/config/config.service.ts deleted file mode 100644 index 3c479bcb8..000000000 --- a/client/src/app/core/config/config.service.ts +++ /dev/null | |||
@@ -1,26 +0,0 @@ | |||
1 | import { Injectable } from '@angular/core' | ||
2 | import { HttpClient } from '@angular/common/http' | ||
3 | |||
4 | import { ServerConfig } from '../../../../../shared' | ||
5 | |||
6 | @Injectable() | ||
7 | export class ConfigService { | ||
8 | private static BASE_CONFIG_URL = API_URL + '/api/v1/config/' | ||
9 | |||
10 | private config: ServerConfig = { | ||
11 | signup: { | ||
12 | allowed: false | ||
13 | } | ||
14 | } | ||
15 | |||
16 | constructor (private http: HttpClient) {} | ||
17 | |||
18 | loadConfig () { | ||
19 | this.http.get<ServerConfig>(ConfigService.BASE_CONFIG_URL) | ||
20 | .subscribe(data => this.config = data) | ||
21 | } | ||
22 | |||
23 | getConfig () { | ||
24 | return this.config | ||
25 | } | ||
26 | } | ||
diff --git a/client/src/app/core/config/index.ts b/client/src/app/core/config/index.ts deleted file mode 100644 index 3724e12f2..000000000 --- a/client/src/app/core/config/index.ts +++ /dev/null | |||
@@ -1 +0,0 @@ | |||
1 | export * from './config.service' | ||
diff --git a/client/src/app/core/core.module.ts b/client/src/app/core/core.module.ts index 9ca94dd0e..fd1586f8e 100644 --- a/client/src/app/core/core.module.ts +++ b/client/src/app/core/core.module.ts | |||
@@ -8,7 +8,7 @@ import { SimpleNotificationsModule } from 'angular2-notifications' | |||
8 | import { ModalModule } from 'ngx-bootstrap/modal' | 8 | import { ModalModule } from 'ngx-bootstrap/modal' |
9 | 9 | ||
10 | import { AuthService } from './auth' | 10 | import { AuthService } from './auth' |
11 | import { ConfigService } from './config' | 11 | import { ServerService } from './server' |
12 | import { ConfirmComponent, ConfirmService } from './confirm' | 12 | import { ConfirmComponent, ConfirmService } from './confirm' |
13 | import { MenuComponent, MenuAdminComponent } from './menu' | 13 | import { MenuComponent, MenuAdminComponent } from './menu' |
14 | import { throwIfAlreadyLoaded } from './module-import-guard' | 14 | import { throwIfAlreadyLoaded } from './module-import-guard' |
@@ -41,7 +41,7 @@ import { throwIfAlreadyLoaded } from './module-import-guard' | |||
41 | providers: [ | 41 | providers: [ |
42 | AuthService, | 42 | AuthService, |
43 | ConfirmService, | 43 | ConfirmService, |
44 | ConfigService | 44 | ServerService |
45 | ] | 45 | ] |
46 | }) | 46 | }) |
47 | export class CoreModule { | 47 | export class CoreModule { |
diff --git a/client/src/app/core/index.ts b/client/src/app/core/index.ts index 31322138f..8358261ae 100644 --- a/client/src/app/core/index.ts +++ b/client/src/app/core/index.ts | |||
@@ -1,5 +1,5 @@ | |||
1 | export * from './auth' | 1 | export * from './auth' |
2 | export * from './config' | 2 | export * from './server' |
3 | export * from './confirm' | 3 | export * from './confirm' |
4 | export * from './menu' | 4 | export * from './menu' |
5 | export * from './routing' | 5 | export * from './routing' |
diff --git a/client/src/app/core/menu/menu.component.ts b/client/src/app/core/menu/menu.component.ts index 669fc6572..8f15d8838 100644 --- a/client/src/app/core/menu/menu.component.ts +++ b/client/src/app/core/menu/menu.component.ts | |||
@@ -2,7 +2,7 @@ import { Component, OnInit } from '@angular/core' | |||
2 | import { Router } from '@angular/router' | 2 | import { Router } from '@angular/router' |
3 | 3 | ||
4 | import { AuthService, AuthStatus } from '../auth' | 4 | import { AuthService, AuthStatus } from '../auth' |
5 | import { ConfigService } from '../config' | 5 | import { ServerService } from '../server' |
6 | 6 | ||
7 | @Component({ | 7 | @Component({ |
8 | selector: 'my-menu', | 8 | selector: 'my-menu', |
@@ -14,7 +14,7 @@ export class MenuComponent implements OnInit { | |||
14 | 14 | ||
15 | constructor ( | 15 | constructor ( |
16 | private authService: AuthService, | 16 | private authService: AuthService, |
17 | private configService: ConfigService, | 17 | private serverService: ServerService, |
18 | private router: Router | 18 | private router: Router |
19 | ) {} | 19 | ) {} |
20 | 20 | ||
@@ -37,7 +37,7 @@ export class MenuComponent implements OnInit { | |||
37 | } | 37 | } |
38 | 38 | ||
39 | isRegistrationAllowed () { | 39 | isRegistrationAllowed () { |
40 | return this.configService.getConfig().signup.allowed | 40 | return this.serverService.getConfig().signup.allowed |
41 | } | 41 | } |
42 | 42 | ||
43 | isUserAdmin () { | 43 | isUserAdmin () { |
diff --git a/client/src/app/core/server/index.ts b/client/src/app/core/server/index.ts new file mode 100644 index 000000000..224da121a --- /dev/null +++ b/client/src/app/core/server/index.ts | |||
@@ -0,0 +1 @@ | |||
export * from './server.service' | |||
diff --git a/client/src/app/core/server/server.service.ts b/client/src/app/core/server/server.service.ts new file mode 100644 index 000000000..f24df5a89 --- /dev/null +++ b/client/src/app/core/server/server.service.ts | |||
@@ -0,0 +1,67 @@ | |||
1 | import { Injectable } from '@angular/core' | ||
2 | import { HttpClient } from '@angular/common/http' | ||
3 | |||
4 | import { ServerConfig } from '../../../../../shared' | ||
5 | |||
6 | @Injectable() | ||
7 | export class ServerService { | ||
8 | private static BASE_CONFIG_URL = API_URL + '/api/v1/config/' | ||
9 | private static BASE_VIDEO_URL = API_URL + '/api/v1/videos/' | ||
10 | |||
11 | private config: ServerConfig = { | ||
12 | signup: { | ||
13 | allowed: false | ||
14 | } | ||
15 | } | ||
16 | private videoCategories: Array<{ id: number, label: string }> = [] | ||
17 | private videoLicences: Array<{ id: number, label: string }> = [] | ||
18 | private videoLanguages: Array<{ id: number, label: string }> = [] | ||
19 | |||
20 | constructor (private http: HttpClient) {} | ||
21 | |||
22 | loadConfig () { | ||
23 | this.http.get<ServerConfig>(ServerService.BASE_CONFIG_URL) | ||
24 | .subscribe(data => this.config = data) | ||
25 | } | ||
26 | |||
27 | loadVideoCategories () { | ||
28 | return this.loadVideoAttributeEnum('categories', this.videoCategories) | ||
29 | } | ||
30 | |||
31 | loadVideoLicences () { | ||
32 | return this.loadVideoAttributeEnum('licences', this.videoLicences) | ||
33 | } | ||
34 | |||
35 | loadVideoLanguages () { | ||
36 | return this.loadVideoAttributeEnum('languages', this.videoLanguages) | ||
37 | } | ||
38 | |||
39 | getConfig () { | ||
40 | return this.config | ||
41 | } | ||
42 | |||
43 | getVideoCategories () { | ||
44 | return this.videoCategories | ||
45 | } | ||
46 | |||
47 | getVideoLicences () { | ||
48 | return this.videoLicences | ||
49 | } | ||
50 | |||
51 | getVideoLanguages () { | ||
52 | return this.videoLanguages | ||
53 | } | ||
54 | |||
55 | private loadVideoAttributeEnum (attributeName: 'categories' | 'licences' | 'languages', hashToPopulate: { id: number, label: string }[]) { | ||
56 | return this.http.get(ServerService.BASE_VIDEO_URL + attributeName) | ||
57 | .subscribe(data => { | ||
58 | Object.keys(data) | ||
59 | .forEach(dataKey => { | ||
60 | hashToPopulate.push({ | ||
61 | id: parseInt(dataKey, 10), | ||
62 | label: data[dataKey] | ||
63 | }) | ||
64 | }) | ||
65 | }) | ||
66 | } | ||
67 | } | ||
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' |
17 | import { ServerService} from '../../core' | ||
16 | import { VideoService } from '../shared' | 18 | import { VideoService } from '../shared' |
17 | import { VideoCreate } from '../../../../../shared' | 19 | import { VideoCreate } from '../../../../../shared' |
18 | import { HttpEventType, HttpResponse } from '@angular/common/http' | 20 | import { HttpEventType, HttpResponse } from '@angular/common/http' |
19 | import { 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 @@ | |||
1 | import { Component, ElementRef, 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 | 4 | ||
5 | import { NotificationsService } from 'angular2-notifications' | 5 | import { NotificationsService } from 'angular2-notifications' |
6 | 6 | ||
7 | import { AuthService } from '../../core' | 7 | import { ServerService } from '../../core' |
8 | import { | 8 | import { |
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 { | |||
14 | import { Video } from './video.model' | 14 | import { Video } from './video.model' |
15 | import { VideoPagination } from './video-pagination.model' | 15 | import { VideoPagination } from './video-pagination.model' |
16 | import { | 16 | import { |
17 | VideoCreate, | ||
18 | UserVideoRate, | 17 | UserVideoRate, |
19 | VideoRateType, | 18 | VideoRateType, |
20 | VideoUpdate, | 19 | VideoUpdate, |
@@ -28,28 +27,12 @@ import { | |||
28 | export class VideoService { | 27 | export 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 @@ | |||
1 | import { Component, Input, Output, EventEmitter } from '@angular/core' | 1 | import { Component, Input } from '@angular/core' |
2 | 2 | ||
3 | import { NotificationsService } from 'angular2-notifications' | 3 | import { SortField, Video } from '../shared' |
4 | |||
5 | import { ConfirmService, ConfigService } from '../../core' | ||
6 | import { SortField, Video, VideoService } from '../shared' | ||
7 | import { User } from '../../shared' | 4 | import { 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 | |||
15 | export class VideoMiniatureComponent { | 11 | export 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 @@ | |||
1 | import { Component, OnInit } from '@angular/core' | 1 | import { Component } from '@angular/core' |
2 | |||
3 | import { VideoService } from './shared' | ||
4 | 2 | ||
5 | @Component({ | 3 | @Component({ |
6 | template: '<router-outlet></router-outlet>' | 4 | template: '<router-outlet></router-outlet>' |
7 | }) | 5 | }) |
8 | export class VideosComponent implements OnInit { | 6 | export class VideosComponent {} |
9 | constructor (private videoService: VideoService) {} | ||
10 | |||
11 | ngOnInit () { | ||
12 | this.videoService.loadVideoCategories() | ||
13 | this.videoService.loadVideoLicences() | ||
14 | this.videoService.loadVideoLanguages() | ||
15 | } | ||
16 | } | ||