diff options
Diffstat (limited to 'client/src/app/shared')
10 files changed, 160 insertions, 2 deletions
diff --git a/client/src/app/shared/buttons/button.component.html b/client/src/app/shared/buttons/button.component.html new file mode 100644 index 000000000..87a8daccf --- /dev/null +++ b/client/src/app/shared/buttons/button.component.html | |||
@@ -0,0 +1,4 @@ | |||
1 | <span class="action-button" [ngClass]="className" [title]="getTitle()"> | ||
2 | <span class="icon" [ngClass]="icon"></span> | ||
3 | <span class="button-label">{{ label }}</span> | ||
4 | </span> | ||
diff --git a/client/src/app/shared/buttons/button.component.scss b/client/src/app/shared/buttons/button.component.scss index 343aea207..168102f09 100644 --- a/client/src/app/shared/buttons/button.component.scss +++ b/client/src/app/shared/buttons/button.component.scss | |||
@@ -26,6 +26,18 @@ | |||
26 | &.icon-delete-grey { | 26 | &.icon-delete-grey { |
27 | background-image: url('../../../assets/images/global/delete-grey.svg'); | 27 | background-image: url('../../../assets/images/global/delete-grey.svg'); |
28 | } | 28 | } |
29 | |||
30 | &.icon-im-with-her { | ||
31 | background-image: url('../../../assets/images/global/im-with-her.svg'); | ||
32 | } | ||
33 | |||
34 | &.icon-tick { | ||
35 | background-image: url('../../../assets/images/global/tick.svg'); | ||
36 | } | ||
37 | |||
38 | &.icon-cross { | ||
39 | background-image: url('../../../assets/images/global/cross.svg'); | ||
40 | } | ||
29 | } | 41 | } |
30 | } | 42 | } |
31 | 43 | ||
diff --git a/client/src/app/shared/buttons/button.component.ts b/client/src/app/shared/buttons/button.component.ts new file mode 100644 index 000000000..967cb1409 --- /dev/null +++ b/client/src/app/shared/buttons/button.component.ts | |||
@@ -0,0 +1,18 @@ | |||
1 | import { Component, Input } from '@angular/core' | ||
2 | |||
3 | @Component({ | ||
4 | selector: 'my-button', | ||
5 | styleUrls: ['./button.component.scss'], | ||
6 | templateUrl: './button.component.html' | ||
7 | }) | ||
8 | |||
9 | export class ButtonComponent { | ||
10 | @Input() label = '' | ||
11 | @Input() className = undefined | ||
12 | @Input() icon = undefined | ||
13 | @Input() title = undefined | ||
14 | |||
15 | getTitle () { | ||
16 | return this.title || this.label | ||
17 | } | ||
18 | } | ||
diff --git a/client/src/app/shared/forms/form-validators/index.ts b/client/src/app/shared/forms/form-validators/index.ts index 9bc7615ca..74e385b3d 100644 --- a/client/src/app/shared/forms/form-validators/index.ts +++ b/client/src/app/shared/forms/form-validators/index.ts | |||
@@ -10,3 +10,5 @@ export * from './video-channel-validators.service' | |||
10 | export * from './video-comment-validators.service' | 10 | export * from './video-comment-validators.service' |
11 | export * from './video-validators.service' | 11 | export * from './video-validators.service' |
12 | export * from './video-captions-validators.service' | 12 | export * from './video-captions-validators.service' |
13 | export * from './video-change-ownership-validators.service' | ||
14 | export * from './video-accept-ownership-validators.service' | ||
diff --git a/client/src/app/shared/forms/form-validators/video-accept-ownership-validators.service.ts b/client/src/app/shared/forms/form-validators/video-accept-ownership-validators.service.ts new file mode 100644 index 000000000..48c7054a4 --- /dev/null +++ b/client/src/app/shared/forms/form-validators/video-accept-ownership-validators.service.ts | |||
@@ -0,0 +1,18 @@ | |||
1 | import { I18n } from '@ngx-translate/i18n-polyfill' | ||
2 | import { Validators } from '@angular/forms' | ||
3 | import { Injectable } from '@angular/core' | ||
4 | import { BuildFormValidator } from '@app/shared' | ||
5 | |||
6 | @Injectable() | ||
7 | export class VideoAcceptOwnershipValidatorsService { | ||
8 | readonly CHANNEL: BuildFormValidator | ||
9 | |||
10 | constructor (private i18n: I18n) { | ||
11 | this.CHANNEL = { | ||
12 | VALIDATORS: [ Validators.required ], | ||
13 | MESSAGES: { | ||
14 | 'required': this.i18n('The channel is required.') | ||
15 | } | ||
16 | } | ||
17 | } | ||
18 | } | ||
diff --git a/client/src/app/shared/forms/form-validators/video-change-ownership-validators.service.ts b/client/src/app/shared/forms/form-validators/video-change-ownership-validators.service.ts new file mode 100644 index 000000000..087b80b44 --- /dev/null +++ b/client/src/app/shared/forms/form-validators/video-change-ownership-validators.service.ts | |||
@@ -0,0 +1,18 @@ | |||
1 | import { I18n } from '@ngx-translate/i18n-polyfill' | ||
2 | import { Validators } from '@angular/forms' | ||
3 | import { Injectable } from '@angular/core' | ||
4 | import { BuildFormValidator } from '@app/shared' | ||
5 | |||
6 | @Injectable() | ||
7 | export class VideoChangeOwnershipValidatorsService { | ||
8 | readonly USERNAME: BuildFormValidator | ||
9 | |||
10 | constructor (private i18n: I18n) { | ||
11 | this.USERNAME = { | ||
12 | VALIDATORS: [ Validators.required ], | ||
13 | MESSAGES: { | ||
14 | 'required': this.i18n('The username is required.') | ||
15 | } | ||
16 | } | ||
17 | } | ||
18 | } | ||
diff --git a/client/src/app/shared/shared.module.ts b/client/src/app/shared/shared.module.ts index b96a9aa41..1e71feb86 100644 --- a/client/src/app/shared/shared.module.ts +++ b/client/src/app/shared/shared.module.ts | |||
@@ -12,6 +12,7 @@ import { BytesPipe, KeysPipe, NgPipesModule } from 'ngx-pipes' | |||
12 | import { SharedModule as PrimeSharedModule } from 'primeng/components/common/shared' | 12 | import { SharedModule as PrimeSharedModule } from 'primeng/components/common/shared' |
13 | 13 | ||
14 | import { AUTH_INTERCEPTOR_PROVIDER } from './auth' | 14 | import { AUTH_INTERCEPTOR_PROVIDER } from './auth' |
15 | import { ButtonComponent } from './buttons/button.component' | ||
15 | import { DeleteButtonComponent } from './buttons/delete-button.component' | 16 | import { DeleteButtonComponent } from './buttons/delete-button.component' |
16 | import { EditButtonComponent } from './buttons/edit-button.component' | 17 | import { EditButtonComponent } from './buttons/edit-button.component' |
17 | import { FromNowPipe } from './misc/from-now.pipe' | 18 | import { FromNowPipe } from './misc/from-now.pipe' |
@@ -22,6 +23,7 @@ import { RestExtractor, RestService } from './rest' | |||
22 | import { UserService } from './users' | 23 | import { UserService } from './users' |
23 | import { VideoAbuseService } from './video-abuse' | 24 | import { VideoAbuseService } from './video-abuse' |
24 | import { VideoBlacklistService } from './video-blacklist' | 25 | import { VideoBlacklistService } from './video-blacklist' |
26 | import { VideoOwnershipService } from './video-ownership' | ||
25 | import { VideoMiniatureComponent } from './video/video-miniature.component' | 27 | import { VideoMiniatureComponent } from './video/video-miniature.component' |
26 | import { VideoFeedComponent } from './video/video-feed.component' | 28 | import { VideoFeedComponent } from './video/video-feed.component' |
27 | import { VideoThumbnailComponent } from './video/video-thumbnail.component' | 29 | import { VideoThumbnailComponent } from './video/video-thumbnail.component' |
@@ -40,7 +42,8 @@ import { | |||
40 | VideoBlacklistValidatorsService, | 42 | VideoBlacklistValidatorsService, |
41 | VideoChannelValidatorsService, | 43 | VideoChannelValidatorsService, |
42 | VideoCommentValidatorsService, | 44 | VideoCommentValidatorsService, |
43 | VideoValidatorsService | 45 | VideoValidatorsService, |
46 | VideoChangeOwnershipValidatorsService, VideoAcceptOwnershipValidatorsService | ||
44 | } from '@app/shared/forms' | 47 | } from '@app/shared/forms' |
45 | import { I18nPrimengCalendarService } from '@app/shared/i18n/i18n-primeng-calendar' | 48 | import { I18nPrimengCalendarService } from '@app/shared/i18n/i18n-primeng-calendar' |
46 | import { ScreenService } from '@app/shared/misc/screen.service' | 49 | import { ScreenService } from '@app/shared/misc/screen.service' |
@@ -77,6 +80,7 @@ import { OverviewService } from '@app/shared/overview' | |||
77 | VideoThumbnailComponent, | 80 | VideoThumbnailComponent, |
78 | VideoMiniatureComponent, | 81 | VideoMiniatureComponent, |
79 | VideoFeedComponent, | 82 | VideoFeedComponent, |
83 | ButtonComponent, | ||
80 | DeleteButtonComponent, | 84 | DeleteButtonComponent, |
81 | EditButtonComponent, | 85 | EditButtonComponent, |
82 | ActionDropdownComponent, | 86 | ActionDropdownComponent, |
@@ -113,6 +117,7 @@ import { OverviewService } from '@app/shared/overview' | |||
113 | VideoThumbnailComponent, | 117 | VideoThumbnailComponent, |
114 | VideoMiniatureComponent, | 118 | VideoMiniatureComponent, |
115 | VideoFeedComponent, | 119 | VideoFeedComponent, |
120 | ButtonComponent, | ||
116 | DeleteButtonComponent, | 121 | DeleteButtonComponent, |
117 | EditButtonComponent, | 122 | EditButtonComponent, |
118 | ActionDropdownComponent, | 123 | ActionDropdownComponent, |
@@ -135,6 +140,7 @@ import { OverviewService } from '@app/shared/overview' | |||
135 | RestService, | 140 | RestService, |
136 | VideoAbuseService, | 141 | VideoAbuseService, |
137 | VideoBlacklistService, | 142 | VideoBlacklistService, |
143 | VideoOwnershipService, | ||
138 | UserService, | 144 | UserService, |
139 | VideoService, | 145 | VideoService, |
140 | AccountService, | 146 | AccountService, |
@@ -156,6 +162,8 @@ import { OverviewService } from '@app/shared/overview' | |||
156 | VideoCaptionsValidatorsService, | 162 | VideoCaptionsValidatorsService, |
157 | VideoBlacklistValidatorsService, | 163 | VideoBlacklistValidatorsService, |
158 | OverviewService, | 164 | OverviewService, |
165 | VideoChangeOwnershipValidatorsService, | ||
166 | VideoAcceptOwnershipValidatorsService, | ||
159 | 167 | ||
160 | I18nPrimengCalendarService, | 168 | I18nPrimengCalendarService, |
161 | ScreenService, | 169 | ScreenService, |
diff --git a/client/src/app/shared/users/user.service.ts b/client/src/app/shared/users/user.service.ts index 249c589b7..fad5b0980 100644 --- a/client/src/app/shared/users/user.service.ts +++ b/client/src/app/shared/users/user.service.ts | |||
@@ -1,5 +1,6 @@ | |||
1 | import { Observable } from 'rxjs' | ||
1 | import { catchError, map } from 'rxjs/operators' | 2 | import { catchError, map } from 'rxjs/operators' |
2 | import { HttpClient } from '@angular/common/http' | 3 | import { HttpClient, HttpParams } from '@angular/common/http' |
3 | import { Injectable } from '@angular/core' | 4 | import { Injectable } from '@angular/core' |
4 | import { UserCreate, UserUpdateMe, UserVideoQuota } from '../../../../../shared' | 5 | import { UserCreate, UserUpdateMe, UserVideoQuota } from '../../../../../shared' |
5 | import { environment } from '../../../environments/environment' | 6 | import { environment } from '../../../environments/environment' |
@@ -117,4 +118,13 @@ export class UserService { | |||
117 | catchError(err => this.restExtractor.handleError(err)) | 118 | catchError(err => this.restExtractor.handleError(err)) |
118 | ) | 119 | ) |
119 | } | 120 | } |
121 | |||
122 | autocomplete (search: string): Observable<string[]> { | ||
123 | const url = UserService.BASE_USERS_URL + 'autocomplete' | ||
124 | const params = new HttpParams().append('search', search) | ||
125 | |||
126 | return this.authHttp | ||
127 | .get<string[]>(url, { params }) | ||
128 | .pipe(catchError(res => this.restExtractor.handleError(res))) | ||
129 | } | ||
120 | } | 130 | } |
diff --git a/client/src/app/shared/video-ownership/index.ts b/client/src/app/shared/video-ownership/index.ts new file mode 100644 index 000000000..fe8902ee2 --- /dev/null +++ b/client/src/app/shared/video-ownership/index.ts | |||
@@ -0,0 +1 @@ | |||
export * from './video-ownership.service' | |||
diff --git a/client/src/app/shared/video-ownership/video-ownership.service.ts b/client/src/app/shared/video-ownership/video-ownership.service.ts new file mode 100644 index 000000000..aa9e4839a --- /dev/null +++ b/client/src/app/shared/video-ownership/video-ownership.service.ts | |||
@@ -0,0 +1,67 @@ | |||
1 | import { catchError, map } from 'rxjs/operators' | ||
2 | import { HttpClient, HttpParams } from '@angular/common/http' | ||
3 | import { Injectable } from '@angular/core' | ||
4 | import { environment } from '../../../environments/environment' | ||
5 | import { RestExtractor, RestService } from '../rest' | ||
6 | import { VideoChangeOwnershipCreate } from '../../../../../shared/models/videos' | ||
7 | import { Observable } from 'rxjs/index' | ||
8 | import { SortMeta } from 'primeng/components/common/sortmeta' | ||
9 | import { ResultList, VideoChangeOwnership } from '../../../../../shared' | ||
10 | import { RestPagination } from '@app/shared/rest' | ||
11 | import { VideoChangeOwnershipAccept } from '../../../../../shared/models/videos/video-change-ownership-accept.model' | ||
12 | |||
13 | @Injectable() | ||
14 | export class VideoOwnershipService { | ||
15 | private static BASE_VIDEO_CHANGE_OWNERSHIP_URL = environment.apiUrl + '/api/v1/videos/' | ||
16 | |||
17 | constructor ( | ||
18 | private authHttp: HttpClient, | ||
19 | private restService: RestService, | ||
20 | private restExtractor: RestExtractor | ||
21 | ) { | ||
22 | } | ||
23 | |||
24 | changeOwnership (id: number, username: string) { | ||
25 | const url = VideoOwnershipService.BASE_VIDEO_CHANGE_OWNERSHIP_URL + id + '/give-ownership' | ||
26 | const body: VideoChangeOwnershipCreate = { | ||
27 | username | ||
28 | } | ||
29 | |||
30 | return this.authHttp.post(url, body) | ||
31 | .pipe( | ||
32 | map(this.restExtractor.extractDataBool), | ||
33 | catchError(res => this.restExtractor.handleError(res)) | ||
34 | ) | ||
35 | } | ||
36 | |||
37 | getOwnershipChanges (pagination: RestPagination, sort: SortMeta): Observable<ResultList<VideoChangeOwnership>> { | ||
38 | const url = VideoOwnershipService.BASE_VIDEO_CHANGE_OWNERSHIP_URL + 'ownership' | ||
39 | |||
40 | let params = new HttpParams() | ||
41 | params = this.restService.addRestGetParams(params, pagination, sort) | ||
42 | |||
43 | return this.authHttp.get<ResultList<VideoChangeOwnership>>(url, { params }) | ||
44 | .pipe( | ||
45 | map(res => this.restExtractor.convertResultListDateToHuman(res)), | ||
46 | catchError(res => this.restExtractor.handleError(res)) | ||
47 | ) | ||
48 | } | ||
49 | |||
50 | acceptOwnership (id: number, input: VideoChangeOwnershipAccept) { | ||
51 | const url = VideoOwnershipService.BASE_VIDEO_CHANGE_OWNERSHIP_URL + 'ownership/' + id + '/accept' | ||
52 | return this.authHttp.post(url, input) | ||
53 | .pipe( | ||
54 | map(this.restExtractor.extractDataBool), | ||
55 | catchError(this.restExtractor.handleError) | ||
56 | ) | ||
57 | } | ||
58 | |||
59 | refuseOwnership (id: number) { | ||
60 | const url = VideoOwnershipService.BASE_VIDEO_CHANGE_OWNERSHIP_URL + 'ownership/' + id + '/refuse' | ||
61 | return this.authHttp.post(url, {}) | ||
62 | .pipe( | ||
63 | map(this.restExtractor.extractDataBool), | ||
64 | catchError(this.restExtractor.handleError) | ||
65 | ) | ||
66 | } | ||
67 | } | ||