diff options
author | Chocobozzz <me@florianbigard.com> | 2019-07-22 16:04:44 +0200 |
---|---|---|
committer | Chocobozzz <chocobozzz@cpy.re> | 2019-07-24 10:58:16 +0200 |
commit | e8f902c05cb35f6d5e9b75a23ddabd51c220a976 (patch) | |
tree | eb6297bc50206546cbae12c6abc5b50ed802b17e | |
parent | 93cae47925e4dd68b7d34a41927b2740b4fab1b4 (diff) | |
download | PeerTube-e8f902c05cb35f6d5e9b75a23ddabd51c220a976.tar.gz PeerTube-e8f902c05cb35f6d5e9b75a23ddabd51c220a976.tar.zst PeerTube-e8f902c05cb35f6d5e9b75a23ddabd51c220a976.zip |
Use search client scope
8 files changed, 25 insertions, 16 deletions
diff --git a/client/src/app/core/plugins/plugin.service.ts b/client/src/app/core/plugins/plugin.service.ts index 14310f093..7c1d69bec 100644 --- a/client/src/app/core/plugins/plugin.service.ts +++ b/client/src/app/core/plugins/plugin.service.ts | |||
@@ -28,6 +28,7 @@ export class PluginService implements ClientHook { | |||
28 | 28 | ||
29 | pluginsLoaded: { [ scope in PluginClientScope ]: ReplaySubject<boolean> } = { | 29 | pluginsLoaded: { [ scope in PluginClientScope ]: ReplaySubject<boolean> } = { |
30 | common: new ReplaySubject<boolean>(1), | 30 | common: new ReplaySubject<boolean>(1), |
31 | search: new ReplaySubject<boolean>(1), | ||
31 | 'video-watch': new ReplaySubject<boolean>(1) | 32 | 'video-watch': new ReplaySubject<boolean>(1) |
32 | } | 33 | } |
33 | 34 | ||
@@ -109,7 +110,11 @@ export class PluginService implements ClientHook { | |||
109 | if (!isReload) this.loadedScopes.push(scope) | 110 | if (!isReload) this.loadedScopes.push(scope) |
110 | 111 | ||
111 | const toLoad = this.scopes[ scope ] | 112 | const toLoad = this.scopes[ scope ] |
112 | if (!Array.isArray(toLoad)) return | 113 | if (!Array.isArray(toLoad)) { |
114 | this.pluginsLoaded[scope].next(true) | ||
115 | |||
116 | return | ||
117 | } | ||
113 | 118 | ||
114 | const promises: Promise<any>[] = [] | 119 | const promises: Promise<any>[] = [] |
115 | for (const pluginInfo of toLoad) { | 120 | for (const pluginInfo of toLoad) { |
diff --git a/client/src/app/search/search.component.ts b/client/src/app/search/search.component.ts index b1d732d68..55637771e 100644 --- a/client/src/app/search/search.component.ts +++ b/client/src/app/search/search.component.ts | |||
@@ -11,6 +11,7 @@ import { VideoChannel } from '@app/shared/video-channel/video-channel.model' | |||
11 | import { immutableAssign } from '@app/shared/misc/utils' | 11 | import { immutableAssign } from '@app/shared/misc/utils' |
12 | import { Video } from '@app/shared/video/video.model' | 12 | import { Video } from '@app/shared/video/video.model' |
13 | import { HooksService } from '@app/core/plugins/hooks.service' | 13 | import { HooksService } from '@app/core/plugins/hooks.service' |
14 | import { PluginService } from '@app/core/plugins/plugin.service' | ||
14 | 15 | ||
15 | @Component({ | 16 | @Component({ |
16 | selector: 'my-search', | 17 | selector: 'my-search', |
@@ -43,7 +44,8 @@ export class SearchComponent implements OnInit, OnDestroy { | |||
43 | private notifier: Notifier, | 44 | private notifier: Notifier, |
44 | private searchService: SearchService, | 45 | private searchService: SearchService, |
45 | private authService: AuthService, | 46 | private authService: AuthService, |
46 | private hooks: HooksService | 47 | private hooks: HooksService, |
48 | private pluginService: PluginService | ||
47 | ) { } | 49 | ) { } |
48 | 50 | ||
49 | get user () { | 51 | get user () { |
@@ -51,6 +53,8 @@ export class SearchComponent implements OnInit, OnDestroy { | |||
51 | } | 53 | } |
52 | 54 | ||
53 | ngOnInit () { | 55 | ngOnInit () { |
56 | this.pluginService.loadPluginsByScope('search') | ||
57 | |||
54 | this.subActivatedRoute = this.route.queryParams.subscribe( | 58 | this.subActivatedRoute = this.route.queryParams.subscribe( |
55 | queryParams => { | 59 | queryParams => { |
56 | const querySearch = queryParams['search'] | 60 | const querySearch = queryParams['search'] |
@@ -175,7 +179,7 @@ export class SearchComponent implements OnInit, OnDestroy { | |||
175 | return this.hooks.wrapObsFun( | 179 | return this.hooks.wrapObsFun( |
176 | this.searchService.searchVideos.bind(this.searchService), | 180 | this.searchService.searchVideos.bind(this.searchService), |
177 | params, | 181 | params, |
178 | 'common', | 182 | 'search', |
179 | 'filter:api.search.videos.list.params', | 183 | 'filter:api.search.videos.list.params', |
180 | 'filter:api.search.videos.list.result' | 184 | 'filter:api.search.videos.list.result' |
181 | ) | 185 | ) |
@@ -190,7 +194,7 @@ export class SearchComponent implements OnInit, OnDestroy { | |||
190 | return this.hooks.wrapObsFun( | 194 | return this.hooks.wrapObsFun( |
191 | this.searchService.searchVideoChannels.bind(this.searchService), | 195 | this.searchService.searchVideoChannels.bind(this.searchService), |
192 | params, | 196 | params, |
193 | 'common', | 197 | 'search', |
194 | 'filter:api.search.video-channels.list.params', | 198 | 'filter:api.search.video-channels.list.params', |
195 | 'filter:api.search.video-channels.list.result' | 199 | 'filter:api.search.video-channels.list.result' |
196 | ) | 200 | ) |
diff --git a/client/src/app/videos/+video-watch/comment/video-comment.service.ts b/client/src/app/videos/+video-watch/comment/video-comment.service.ts index eb608a1a3..550d42fa8 100644 --- a/client/src/app/videos/+video-watch/comment/video-comment.service.ts +++ b/client/src/app/videos/+video-watch/comment/video-comment.service.ts | |||
@@ -52,7 +52,7 @@ export class VideoCommentService { | |||
52 | videoId: number | string, | 52 | videoId: number | string, |
53 | componentPagination: ComponentPagination, | 53 | componentPagination: ComponentPagination, |
54 | sort: VideoSortField | 54 | sort: VideoSortField |
55 | }): Observable<{ comments: VideoComment[], totalComments: number}> { | 55 | }): Observable<ResultList<VideoComment>> { |
56 | const { videoId, componentPagination, sort } = parameters | 56 | const { videoId, componentPagination, sort } = parameters |
57 | 57 | ||
58 | const pagination = this.restService.componentPaginationToRestPagination(componentPagination) | 58 | const pagination = this.restService.componentPaginationToRestPagination(componentPagination) |
@@ -61,10 +61,9 @@ export class VideoCommentService { | |||
61 | params = this.restService.addRestGetParams(params, pagination, sort) | 61 | params = this.restService.addRestGetParams(params, pagination, sort) |
62 | 62 | ||
63 | const url = VideoCommentService.BASE_VIDEO_URL + videoId + '/comment-threads' | 63 | const url = VideoCommentService.BASE_VIDEO_URL + videoId + '/comment-threads' |
64 | return this.authHttp | 64 | return this.authHttp.get<ResultList<VideoComment>>(url, { params }) |
65 | .get(url, { params }) | ||
66 | .pipe( | 65 | .pipe( |
67 | map(this.extractVideoComments), | 66 | map(result => this.extractVideoComments(result)), |
68 | catchError(err => this.restExtractor.handleError(err)) | 67 | catchError(err => this.restExtractor.handleError(err)) |
69 | ) | 68 | ) |
70 | } | 69 | } |
@@ -136,7 +135,7 @@ export class VideoCommentService { | |||
136 | comments.push(new VideoComment(videoCommentJson)) | 135 | comments.push(new VideoComment(videoCommentJson)) |
137 | } | 136 | } |
138 | 137 | ||
139 | return { comments, totalComments } | 138 | return { data: comments, total: totalComments } |
140 | } | 139 | } |
141 | 140 | ||
142 | private extractVideoCommentTree (tree: VideoCommentThreadTree) { | 141 | private extractVideoCommentTree (tree: VideoCommentThreadTree) { |
diff --git a/client/src/app/videos/+video-watch/comment/video-comments.component.ts b/client/src/app/videos/+video-watch/comment/video-comments.component.ts index 3c1a0986c..5bafc55e5 100644 --- a/client/src/app/videos/+video-watch/comment/video-comments.component.ts +++ b/client/src/app/videos/+video-watch/comment/video-comments.component.ts | |||
@@ -122,8 +122,8 @@ export class VideoCommentsComponent implements OnInit, OnChanges, OnDestroy { | |||
122 | 122 | ||
123 | obs.subscribe( | 123 | obs.subscribe( |
124 | res => { | 124 | res => { |
125 | this.comments = this.comments.concat(res.comments) | 125 | this.comments = this.comments.concat(res.data) |
126 | this.componentPagination.totalItems = res.totalComments | 126 | this.componentPagination.totalItems = res.total |
127 | }, | 127 | }, |
128 | 128 | ||
129 | err => this.notifier.error(err.message) | 129 | err => this.notifier.error(err.message) |
diff --git a/client/src/app/videos/+video-watch/video-watch.component.ts b/client/src/app/videos/+video-watch/video-watch.component.ts index eed2ec048..0d9b6d680 100644 --- a/client/src/app/videos/+video-watch/video-watch.component.ts +++ b/client/src/app/videos/+video-watch/video-watch.component.ts | |||
@@ -103,7 +103,7 @@ export class VideoWatchComponent implements OnInit, OnDestroy { | |||
103 | } | 103 | } |
104 | 104 | ||
105 | async ngOnInit () { | 105 | async ngOnInit () { |
106 | await this.pluginService.loadPluginsByScope('video-watch') | 106 | this.pluginService.loadPluginsByScope('video-watch') |
107 | 107 | ||
108 | this.configSub = this.serverService.configLoaded | 108 | this.configSub = this.serverService.configLoaded |
109 | .subscribe(() => { | 109 | .subscribe(() => { |
diff --git a/shared/models/plugins/plugin-client-scope.type.ts b/shared/models/plugins/plugin-client-scope.type.ts index a2112eed7..0c616c5ed 100644 --- a/shared/models/plugins/plugin-client-scope.type.ts +++ b/shared/models/plugins/plugin-client-scope.type.ts | |||
@@ -1 +1 @@ | |||
export type PluginClientScope = 'common' | 'video-watch' | export type PluginClientScope = 'common' | 'video-watch' | 'search' | ||
diff --git a/shared/models/plugins/plugin-package-json.model.ts b/shared/models/plugins/plugin-package-json.model.ts index f8029ec34..87a48e97f 100644 --- a/shared/models/plugins/plugin-package-json.model.ts +++ b/shared/models/plugins/plugin-package-json.model.ts | |||
@@ -1,6 +1,8 @@ | |||
1 | import { PluginClientScope } from './plugin-client-scope.type' | ||
2 | |||
1 | export type ClientScript = { | 3 | export type ClientScript = { |
2 | script: string, | 4 | script: string, |
3 | scopes: string[] | 5 | scopes: PluginClientScope[] |
4 | } | 6 | } |
5 | 7 | ||
6 | export type PluginPackageJson = { | 8 | export type PluginPackageJson = { |
diff --git a/shared/models/server/server-config.model.ts b/shared/models/server/server-config.model.ts index 49bb01708..3498f86d7 100644 --- a/shared/models/server/server-config.model.ts +++ b/shared/models/server/server-config.model.ts | |||
@@ -1,12 +1,11 @@ | |||
1 | import { NSFWPolicyType } from '../videos/nsfw-policy.type' | 1 | import { NSFWPolicyType } from '../videos/nsfw-policy.type' |
2 | import { ClientScript } from '../plugins/plugin-package-json.model' | 2 | import { ClientScript } from '../plugins/plugin-package-json.model' |
3 | import { PluginClientScope } from '../plugins/plugin-scope.type' | ||
4 | 3 | ||
5 | export interface ServerConfigPlugin { | 4 | export interface ServerConfigPlugin { |
6 | name: string | 5 | name: string |
7 | version: string | 6 | version: string |
8 | description: string | 7 | description: string |
9 | clientScripts: { [name in PluginClientScope]: ClientScript } | 8 | clientScripts: { [name: string]: ClientScript } |
10 | } | 9 | } |
11 | 10 | ||
12 | export interface ServerConfigTheme extends ServerConfigPlugin { | 11 | export interface ServerConfigTheme extends ServerConfigPlugin { |