aboutsummaryrefslogtreecommitdiffhomepage
path: root/client/src/app/+admin/plugins/shared/plugin-api.service.ts
diff options
context:
space:
mode:
authorChocobozzz <me@florianbigard.com>2019-07-10 18:30:27 +0200
committerChocobozzz <chocobozzz@cpy.re>2019-07-24 10:58:16 +0200
commitd00dc28dd73ad9dd419d5a5ac6ac747cefbc6e8b (patch)
treec94c2b22de6707eaafcc4348f69934f265c52f52 /client/src/app/+admin/plugins/shared/plugin-api.service.ts
parentad91e7006e41f8ee5b8dcefee30f99e8ca44133a (diff)
downloadPeerTube-d00dc28dd73ad9dd419d5a5ac6ac747cefbc6e8b.tar.gz
PeerTube-d00dc28dd73ad9dd419d5a5ac6ac747cefbc6e8b.tar.zst
PeerTube-d00dc28dd73ad9dd419d5a5ac6ac747cefbc6e8b.zip
WIP plugins: list installed plugins in client
Diffstat (limited to 'client/src/app/+admin/plugins/shared/plugin-api.service.ts')
-rw-r--r--client/src/app/+admin/plugins/shared/plugin-api.service.ts50
1 files changed, 50 insertions, 0 deletions
diff --git a/client/src/app/+admin/plugins/shared/plugin-api.service.ts b/client/src/app/+admin/plugins/shared/plugin-api.service.ts
new file mode 100644
index 000000000..bfc2b918f
--- /dev/null
+++ b/client/src/app/+admin/plugins/shared/plugin-api.service.ts
@@ -0,0 +1,50 @@
1import { catchError } from 'rxjs/operators'
2import { HttpClient, HttpParams } from '@angular/common/http'
3import { Injectable } from '@angular/core'
4import { environment } from '../../../../environments/environment'
5import { RestExtractor, RestService } from '../../../shared'
6import { I18n } from '@ngx-translate/i18n-polyfill'
7import { PluginType } from '@shared/models/plugins/plugin.type'
8import { ComponentPagination } from '@app/shared/rest/component-pagination.model'
9import { ResultList } from '@shared/models'
10import { PeerTubePlugin } from '@shared/models/plugins/peertube-plugin.model'
11
12@Injectable()
13export class PluginApiService {
14 private static BASE_APPLICATION_URL = environment.apiUrl + '/api/v1/plugins'
15
16 constructor (
17 private authHttp: HttpClient,
18 private restExtractor: RestExtractor,
19 private restService: RestService,
20 private i18n: I18n
21 ) { }
22
23 getPluginTypeOptions () {
24 return [
25 {
26 label: this.i18n('Plugin'),
27 value: PluginType.PLUGIN
28 },
29 {
30 label: this.i18n('Theme'),
31 value: PluginType.THEME
32 }
33 ]
34 }
35
36 getPlugins (
37 type: PluginType,
38 componentPagination: ComponentPagination,
39 sort: string
40 ) {
41 const pagination = this.restService.componentPaginationToRestPagination(componentPagination)
42
43 let params = new HttpParams()
44 params = this.restService.addRestGetParams(params, pagination, sort)
45 params = params.append('type', type.toString())
46
47 return this.authHttp.get<ResultList<PeerTubePlugin>>(PluginApiService.BASE_APPLICATION_URL, { params })
48 .pipe(catchError(res => this.restExtractor.handleError(res)))
49 }
50}