diff options
author | Chocobozzz <me@florianbigard.com> | 2019-07-10 18:30:27 +0200 |
---|---|---|
committer | Chocobozzz <chocobozzz@cpy.re> | 2019-07-24 10:58:16 +0200 |
commit | d00dc28dd73ad9dd419d5a5ac6ac747cefbc6e8b (patch) | |
tree | c94c2b22de6707eaafcc4348f69934f265c52f52 /client/src/app/+admin/plugins/shared | |
parent | ad91e7006e41f8ee5b8dcefee30f99e8ca44133a (diff) | |
download | PeerTube-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')
-rw-r--r-- | client/src/app/+admin/plugins/shared/plugin-api.service.ts | 50 |
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 @@ | |||
1 | import { catchError } 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 '../../../shared' | ||
6 | import { I18n } from '@ngx-translate/i18n-polyfill' | ||
7 | import { PluginType } from '@shared/models/plugins/plugin.type' | ||
8 | import { ComponentPagination } from '@app/shared/rest/component-pagination.model' | ||
9 | import { ResultList } from '@shared/models' | ||
10 | import { PeerTubePlugin } from '@shared/models/plugins/peertube-plugin.model' | ||
11 | |||
12 | @Injectable() | ||
13 | export 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 | } | ||