diff options
author | Chocobozzz <me@florianbigard.com> | 2018-08-13 11:54:11 +0200 |
---|---|---|
committer | Chocobozzz <me@florianbigard.com> | 2018-08-14 09:27:17 +0200 |
commit | efc9e8450a8bbeeef9cd18e3ad6037abc0f815c3 (patch) | |
tree | 4698ca4a1e0ddca385a99cd5ae3628d666f28b7d /client/src/app/shared | |
parent | 7f7680641b6e7625d2099ff3ffc28a1a6ec5b9cf (diff) | |
download | PeerTube-efc9e8450a8bbeeef9cd18e3ad6037abc0f815c3.tar.gz PeerTube-efc9e8450a8bbeeef9cd18e3ad6037abc0f815c3.tar.zst PeerTube-efc9e8450a8bbeeef9cd18e3ad6037abc0f815c3.zip |
Add ability to delete and update abuse on client
Diffstat (limited to 'client/src/app/shared')
-rw-r--r-- | client/src/app/shared/forms/form-validators/video-abuse-validators.service.ts | 10 | ||||
-rw-r--r-- | client/src/app/shared/video-abuse/video-abuse.service.ts | 23 |
2 files changed, 31 insertions, 2 deletions
diff --git a/client/src/app/shared/forms/form-validators/video-abuse-validators.service.ts b/client/src/app/shared/forms/form-validators/video-abuse-validators.service.ts index 774e6a488..6e9806611 100644 --- a/client/src/app/shared/forms/form-validators/video-abuse-validators.service.ts +++ b/client/src/app/shared/forms/form-validators/video-abuse-validators.service.ts | |||
@@ -6,6 +6,7 @@ import { BuildFormValidator } from '@app/shared' | |||
6 | @Injectable() | 6 | @Injectable() |
7 | export class VideoAbuseValidatorsService { | 7 | export class VideoAbuseValidatorsService { |
8 | readonly VIDEO_ABUSE_REASON: BuildFormValidator | 8 | readonly VIDEO_ABUSE_REASON: BuildFormValidator |
9 | readonly VIDEO_ABUSE_MODERATION_COMMENT: BuildFormValidator | ||
9 | 10 | ||
10 | constructor (private i18n: I18n) { | 11 | constructor (private i18n: I18n) { |
11 | this.VIDEO_ABUSE_REASON = { | 12 | this.VIDEO_ABUSE_REASON = { |
@@ -16,5 +17,14 @@ export class VideoAbuseValidatorsService { | |||
16 | 'maxlength': this.i18n('Report reason cannot be more than 300 characters long.') | 17 | 'maxlength': this.i18n('Report reason cannot be more than 300 characters long.') |
17 | } | 18 | } |
18 | } | 19 | } |
20 | |||
21 | this.VIDEO_ABUSE_MODERATION_COMMENT = { | ||
22 | VALIDATORS: [ Validators.required, Validators.minLength(2), Validators.maxLength(300) ], | ||
23 | MESSAGES: { | ||
24 | 'required': this.i18n('Moderation comment is required.'), | ||
25 | 'minlength': this.i18n('Moderation comment must be at least 2 characters long.'), | ||
26 | 'maxlength': this.i18n('Moderation comment cannot be more than 300 characters long.') | ||
27 | } | ||
28 | } | ||
19 | } | 29 | } |
20 | } | 30 | } |
diff --git a/client/src/app/shared/video-abuse/video-abuse.service.ts b/client/src/app/shared/video-abuse/video-abuse.service.ts index 6fab3ef43..61b7e1b98 100644 --- a/client/src/app/shared/video-abuse/video-abuse.service.ts +++ b/client/src/app/shared/video-abuse/video-abuse.service.ts | |||
@@ -3,7 +3,7 @@ import { HttpClient, HttpParams } from '@angular/common/http' | |||
3 | import { Injectable } from '@angular/core' | 3 | import { Injectable } from '@angular/core' |
4 | import { SortMeta } from 'primeng/components/common/sortmeta' | 4 | import { SortMeta } from 'primeng/components/common/sortmeta' |
5 | import { Observable } from 'rxjs' | 5 | import { Observable } from 'rxjs' |
6 | import { ResultList, VideoAbuse } from '../../../../../shared' | 6 | import { ResultList, VideoAbuse, VideoAbuseUpdate } from '../../../../../shared' |
7 | import { environment } from '../../../environments/environment' | 7 | import { environment } from '../../../environments/environment' |
8 | import { RestExtractor, RestPagination, RestService } from '../rest' | 8 | import { RestExtractor, RestPagination, RestService } from '../rest' |
9 | 9 | ||
@@ -42,4 +42,23 @@ export class VideoAbuseService { | |||
42 | catchError(res => this.restExtractor.handleError(res)) | 42 | catchError(res => this.restExtractor.handleError(res)) |
43 | ) | 43 | ) |
44 | } | 44 | } |
45 | } | 45 | |
46 | updateVideoAbuse (videoAbuse: VideoAbuse, abuseUpdate: VideoAbuseUpdate) { | ||
47 | const url = VideoAbuseService.BASE_VIDEO_ABUSE_URL + videoAbuse.video.uuid + '/abuse/' + videoAbuse.id | ||
48 | |||
49 | return this.authHttp.put(url, abuseUpdate) | ||
50 | .pipe( | ||
51 | map(this.restExtractor.extractDataBool), | ||
52 | catchError(res => this.restExtractor.handleError(res)) | ||
53 | ) | ||
54 | } | ||
55 | |||
56 | removeVideoAbuse (videoAbuse: VideoAbuse) { | ||
57 | const url = VideoAbuseService.BASE_VIDEO_ABUSE_URL + videoAbuse.video.uuid + '/abuse/' + videoAbuse.id | ||
58 | |||
59 | return this.authHttp.delete(url) | ||
60 | .pipe( | ||
61 | map(this.restExtractor.extractDataBool), | ||
62 | catchError(res => this.restExtractor.handleError(res)) | ||
63 | ) | ||
64 | }} | ||