From d00dc28dd73ad9dd419d5a5ac6ac747cefbc6e8b Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Wed, 10 Jul 2019 18:30:27 +0200 Subject: WIP plugins: list installed plugins in client --- .../+admin/plugins/shared/plugin-api.service.ts | 50 ++++++++++++++++++++++ 1 file changed, 50 insertions(+) create mode 100644 client/src/app/+admin/plugins/shared/plugin-api.service.ts (limited to 'client/src/app/+admin/plugins/shared/plugin-api.service.ts') 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 @@ +import { catchError } from 'rxjs/operators' +import { HttpClient, HttpParams } from '@angular/common/http' +import { Injectable } from '@angular/core' +import { environment } from '../../../../environments/environment' +import { RestExtractor, RestService } from '../../../shared' +import { I18n } from '@ngx-translate/i18n-polyfill' +import { PluginType } from '@shared/models/plugins/plugin.type' +import { ComponentPagination } from '@app/shared/rest/component-pagination.model' +import { ResultList } from '@shared/models' +import { PeerTubePlugin } from '@shared/models/plugins/peertube-plugin.model' + +@Injectable() +export class PluginApiService { + private static BASE_APPLICATION_URL = environment.apiUrl + '/api/v1/plugins' + + constructor ( + private authHttp: HttpClient, + private restExtractor: RestExtractor, + private restService: RestService, + private i18n: I18n + ) { } + + getPluginTypeOptions () { + return [ + { + label: this.i18n('Plugin'), + value: PluginType.PLUGIN + }, + { + label: this.i18n('Theme'), + value: PluginType.THEME + } + ] + } + + getPlugins ( + type: PluginType, + componentPagination: ComponentPagination, + sort: string + ) { + const pagination = this.restService.componentPaginationToRestPagination(componentPagination) + + let params = new HttpParams() + params = this.restService.addRestGetParams(params, pagination, sort) + params = params.append('type', type.toString()) + + return this.authHttp.get>(PluginApiService.BASE_APPLICATION_URL, { params }) + .pipe(catchError(res => this.restExtractor.handleError(res))) + } +} -- cgit v1.2.3