aboutsummaryrefslogtreecommitdiffhomepage
path: root/client/src/app/shared
diff options
context:
space:
mode:
Diffstat (limited to 'client/src/app/shared')
-rw-r--r--client/src/app/shared/buttons/button.component.html4
-rw-r--r--client/src/app/shared/buttons/button.component.scss12
-rw-r--r--client/src/app/shared/buttons/button.component.ts18
-rw-r--r--client/src/app/shared/forms/form-validators/index.ts2
-rw-r--r--client/src/app/shared/forms/form-validators/video-accept-ownership-validators.service.ts18
-rw-r--r--client/src/app/shared/forms/form-validators/video-change-ownership-validators.service.ts18
-rw-r--r--client/src/app/shared/shared.module.ts10
-rw-r--r--client/src/app/shared/users/user.service.ts12
-rw-r--r--client/src/app/shared/video-ownership/index.ts1
-rw-r--r--client/src/app/shared/video-ownership/video-ownership.service.ts67
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 @@
1import { Component, Input } from '@angular/core'
2
3@Component({
4 selector: 'my-button',
5 styleUrls: ['./button.component.scss'],
6 templateUrl: './button.component.html'
7})
8
9export 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'
10export * from './video-comment-validators.service' 10export * from './video-comment-validators.service'
11export * from './video-validators.service' 11export * from './video-validators.service'
12export * from './video-captions-validators.service' 12export * from './video-captions-validators.service'
13export * from './video-change-ownership-validators.service'
14export * 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 @@
1import { I18n } from '@ngx-translate/i18n-polyfill'
2import { Validators } from '@angular/forms'
3import { Injectable } from '@angular/core'
4import { BuildFormValidator } from '@app/shared'
5
6@Injectable()
7export 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 @@
1import { I18n } from '@ngx-translate/i18n-polyfill'
2import { Validators } from '@angular/forms'
3import { Injectable } from '@angular/core'
4import { BuildFormValidator } from '@app/shared'
5
6@Injectable()
7export 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'
12import { SharedModule as PrimeSharedModule } from 'primeng/components/common/shared' 12import { SharedModule as PrimeSharedModule } from 'primeng/components/common/shared'
13 13
14import { AUTH_INTERCEPTOR_PROVIDER } from './auth' 14import { AUTH_INTERCEPTOR_PROVIDER } from './auth'
15import { ButtonComponent } from './buttons/button.component'
15import { DeleteButtonComponent } from './buttons/delete-button.component' 16import { DeleteButtonComponent } from './buttons/delete-button.component'
16import { EditButtonComponent } from './buttons/edit-button.component' 17import { EditButtonComponent } from './buttons/edit-button.component'
17import { FromNowPipe } from './misc/from-now.pipe' 18import { FromNowPipe } from './misc/from-now.pipe'
@@ -22,6 +23,7 @@ import { RestExtractor, RestService } from './rest'
22import { UserService } from './users' 23import { UserService } from './users'
23import { VideoAbuseService } from './video-abuse' 24import { VideoAbuseService } from './video-abuse'
24import { VideoBlacklistService } from './video-blacklist' 25import { VideoBlacklistService } from './video-blacklist'
26import { VideoOwnershipService } from './video-ownership'
25import { VideoMiniatureComponent } from './video/video-miniature.component' 27import { VideoMiniatureComponent } from './video/video-miniature.component'
26import { VideoFeedComponent } from './video/video-feed.component' 28import { VideoFeedComponent } from './video/video-feed.component'
27import { VideoThumbnailComponent } from './video/video-thumbnail.component' 29import { 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'
45import { I18nPrimengCalendarService } from '@app/shared/i18n/i18n-primeng-calendar' 48import { I18nPrimengCalendarService } from '@app/shared/i18n/i18n-primeng-calendar'
46import { ScreenService } from '@app/shared/misc/screen.service' 49import { 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 @@
1import { Observable } from 'rxjs'
1import { catchError, map } from 'rxjs/operators' 2import { catchError, map } from 'rxjs/operators'
2import { HttpClient } from '@angular/common/http' 3import { HttpClient, HttpParams } from '@angular/common/http'
3import { Injectable } from '@angular/core' 4import { Injectable } from '@angular/core'
4import { UserCreate, UserUpdateMe, UserVideoQuota } from '../../../../../shared' 5import { UserCreate, UserUpdateMe, UserVideoQuota } from '../../../../../shared'
5import { environment } from '../../../environments/environment' 6import { 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 @@
1import { catchError, map } from 'rxjs/operators'
2import { HttpClient, HttpParams } from '@angular/common/http'
3import { Injectable } from '@angular/core'
4import { environment } from '../../../environments/environment'
5import { RestExtractor, RestService } from '../rest'
6import { VideoChangeOwnershipCreate } from '../../../../../shared/models/videos'
7import { Observable } from 'rxjs/index'
8import { SortMeta } from 'primeng/components/common/sortmeta'
9import { ResultList, VideoChangeOwnership } from '../../../../../shared'
10import { RestPagination } from '@app/shared/rest'
11import { VideoChangeOwnershipAccept } from '../../../../../shared/models/videos/video-change-ownership-accept.model'
12
13@Injectable()
14export 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}