diff options
Diffstat (limited to 'client/src/app/shared')
-rw-r--r-- | client/src/app/shared/forms/form-validators/index.ts | 2 | ||||
-rw-r--r-- | client/src/app/shared/forms/form-validators/video-abuse.ts (renamed from client/src/app/shared/forms/form-validators/video-report.ts) | 2 | ||||
-rw-r--r-- | client/src/app/shared/index.ts | 1 | ||||
-rw-r--r-- | client/src/app/shared/shared.module.ts | 4 | ||||
-rw-r--r-- | client/src/app/shared/video-abuse/index.ts | 2 | ||||
-rw-r--r-- | client/src/app/shared/video-abuse/video-abuse.model.ts | 8 | ||||
-rw-r--r-- | client/src/app/shared/video-abuse/video-abuse.service.ts | 44 |
7 files changed, 60 insertions, 3 deletions
diff --git a/client/src/app/shared/forms/form-validators/index.ts b/client/src/app/shared/forms/form-validators/index.ts index 119b5d9bf..ab7c2df31 100644 --- a/client/src/app/shared/forms/form-validators/index.ts +++ b/client/src/app/shared/forms/form-validators/index.ts | |||
@@ -1,4 +1,4 @@ | |||
1 | export * from './host.validator'; | 1 | export * from './host.validator'; |
2 | export * from './user'; | 2 | export * from './user'; |
3 | export * from './video-report'; | 3 | export * from './video-abuse'; |
4 | export * from './video'; | 4 | export * from './video'; |
diff --git a/client/src/app/shared/forms/form-validators/video-report.ts b/client/src/app/shared/forms/form-validators/video-abuse.ts index 036ee1721..94a29a3b7 100644 --- a/client/src/app/shared/forms/form-validators/video-report.ts +++ b/client/src/app/shared/forms/form-validators/video-abuse.ts | |||
@@ -1,6 +1,6 @@ | |||
1 | import { Validators } from '@angular/forms'; | 1 | import { Validators } from '@angular/forms'; |
2 | 2 | ||
3 | export const VIDEO_REPORT_REASON = { | 3 | export const VIDEO_ABUSE_REASON = { |
4 | VALIDATORS: [ Validators.required, Validators.minLength(2), Validators.maxLength(300) ], | 4 | VALIDATORS: [ Validators.required, Validators.minLength(2), Validators.maxLength(300) ], |
5 | MESSAGES: { | 5 | MESSAGES: { |
6 | 'required': 'Report reason name is required.', | 6 | 'required': 'Report reason name is required.', |
diff --git a/client/src/app/shared/index.ts b/client/src/app/shared/index.ts index 52a647b83..7876e6f14 100644 --- a/client/src/app/shared/index.ts +++ b/client/src/app/shared/index.ts | |||
@@ -3,4 +3,5 @@ export * from './forms'; | |||
3 | export * from './rest'; | 3 | export * from './rest'; |
4 | export * from './search'; | 4 | export * from './search'; |
5 | export * from './users'; | 5 | export * from './users'; |
6 | export * from './video-abuse'; | ||
6 | export * from './shared.module'; | 7 | export * from './shared.module'; |
diff --git a/client/src/app/shared/shared.module.ts b/client/src/app/shared/shared.module.ts index 748c5d520..7b2386d6c 100644 --- a/client/src/app/shared/shared.module.ts +++ b/client/src/app/shared/shared.module.ts | |||
@@ -14,6 +14,7 @@ import { FileUploadModule } from 'ng2-file-upload/ng2-file-upload'; | |||
14 | import { AUTH_HTTP_PROVIDERS } from './auth'; | 14 | import { AUTH_HTTP_PROVIDERS } from './auth'; |
15 | import { RestExtractor, RestService } from './rest'; | 15 | import { RestExtractor, RestService } from './rest'; |
16 | import { SearchComponent, SearchService } from './search'; | 16 | import { SearchComponent, SearchService } from './search'; |
17 | import { VideoAbuseService } from './video-abuse'; | ||
17 | 18 | ||
18 | @NgModule({ | 19 | @NgModule({ |
19 | imports: [ | 20 | imports: [ |
@@ -57,7 +58,8 @@ import { SearchComponent, SearchService } from './search'; | |||
57 | AUTH_HTTP_PROVIDERS, | 58 | AUTH_HTTP_PROVIDERS, |
58 | RestExtractor, | 59 | RestExtractor, |
59 | RestService, | 60 | RestService, |
60 | SearchService | 61 | SearchService, |
62 | VideoAbuseService | ||
61 | ] | 63 | ] |
62 | }) | 64 | }) |
63 | export class SharedModule { } | 65 | export class SharedModule { } |
diff --git a/client/src/app/shared/video-abuse/index.ts b/client/src/app/shared/video-abuse/index.ts new file mode 100644 index 000000000..563533ba5 --- /dev/null +++ b/client/src/app/shared/video-abuse/index.ts | |||
@@ -0,0 +1,2 @@ | |||
1 | export * from './video-abuse.service'; | ||
2 | export * from './video-abuse.model'; | ||
diff --git a/client/src/app/shared/video-abuse/video-abuse.model.ts b/client/src/app/shared/video-abuse/video-abuse.model.ts new file mode 100644 index 000000000..bb0373027 --- /dev/null +++ b/client/src/app/shared/video-abuse/video-abuse.model.ts | |||
@@ -0,0 +1,8 @@ | |||
1 | export interface VideoAbuse { | ||
2 | id: string; | ||
3 | reason: string; | ||
4 | reporterPodHost: string; | ||
5 | reporterUsername: string; | ||
6 | videoId: string; | ||
7 | createdAt: Date; | ||
8 | } | ||
diff --git a/client/src/app/shared/video-abuse/video-abuse.service.ts b/client/src/app/shared/video-abuse/video-abuse.service.ts new file mode 100644 index 000000000..2750a41c7 --- /dev/null +++ b/client/src/app/shared/video-abuse/video-abuse.service.ts | |||
@@ -0,0 +1,44 @@ | |||
1 | import { Injectable } from '@angular/core'; | ||
2 | import { Http } from '@angular/http'; | ||
3 | import { Observable } from 'rxjs/Observable'; | ||
4 | import 'rxjs/add/operator/catch'; | ||
5 | import 'rxjs/add/operator/map'; | ||
6 | |||
7 | import { AuthService } from '../core'; | ||
8 | import { AuthHttp } from '../auth'; | ||
9 | import { RestExtractor, ResultList } from '../rest'; | ||
10 | import { VideoAbuse } from './video-abuse.model'; | ||
11 | |||
12 | @Injectable() | ||
13 | export class VideoAbuseService { | ||
14 | private static BASE_VIDEO_ABUSE_URL = '/api/v1/videos/'; | ||
15 | |||
16 | constructor( | ||
17 | private authHttp: AuthHttp, | ||
18 | private restExtractor: RestExtractor | ||
19 | ) {} | ||
20 | |||
21 | getVideoAbuses() { | ||
22 | return this.authHttp.get(VideoAbuseService.BASE_VIDEO_ABUSE_URL + 'abuse') | ||
23 | .map(this.restExtractor.extractDataList) | ||
24 | .map(this.extractVideoAbuses) | ||
25 | } | ||
26 | |||
27 | reportVideo(id: string, reason: string) { | ||
28 | const body = { | ||
29 | reason | ||
30 | }; | ||
31 | const url = VideoAbuseService.BASE_VIDEO_ABUSE_URL + id + '/abuse'; | ||
32 | |||
33 | return this.authHttp.post(url, body) | ||
34 | .map(this.restExtractor.extractDataBool) | ||
35 | .catch((res) => this.restExtractor.handleError(res)); | ||
36 | } | ||
37 | |||
38 | private extractVideoAbuses(result: ResultList) { | ||
39 | const videoAbuses: VideoAbuse[] = result.data; | ||
40 | const totalVideoAbuses = result.total; | ||
41 | |||
42 | return { videoAbuses, totalVideoAbuses }; | ||
43 | } | ||
44 | } | ||