-import { Observable } from 'rxjs'
-import { catchError, map, switchMap } from 'rxjs/operators'
+import { catchError } from 'rxjs/operators'
import { HttpClient, HttpParams } from '@angular/common/http'
import { Injectable } from '@angular/core'
import { ComponentPagination, RestExtractor, RestService } from '@app/core'
import { PluginService } from '@app/core/plugins/plugin.service'
-import { peertubeTranslate } from '@shared/core-utils/i18n'
import {
InstallOrUpdatePlugin,
ManagePlugin,
private pluginService: PluginService
) { }
- getPluginTypeOptions () {
- return [
- {
- label: $localize`Plugins`,
- value: PluginType.PLUGIN
- },
- {
- label: $localize`Themes`,
- value: PluginType.THEME
- }
- ]
- }
-
getPluginTypeLabel (type: PluginType) {
if (type === PluginType.PLUGIN) {
return $localize`plugin`
componentPagination: ComponentPagination,
sort: string
) {
- const pagination = this.restService.componentPaginationToRestPagination(componentPagination)
+ const pagination = this.restService.componentToRestPagination(componentPagination)
let params = new HttpParams()
params = this.restService.addRestGetParams(params, pagination, sort)
sort: string,
search?: string
) {
- const pagination = this.restService.componentPaginationToRestPagination(componentPagination)
+ const pagination = this.restService.componentToRestPagination(componentPagination)
let params = new HttpParams()
params = this.restService.addRestGetParams(params, pagination, sort)
return this.authHttp.get<RegisteredServerSettings>(path)
.pipe(
- switchMap(res => this.translateSettingsLabel(npmName, res)),
catchError(res => this.restExtractor.handleError(res))
)
}
return `https://www.npmjs.com/package/peertube-${typeString}-${name}`
}
-
- private translateSettingsLabel (npmName: string, res: RegisteredServerSettings): Observable<RegisteredServerSettings> {
- return this.pluginService.translationsObservable
- .pipe(
- map(allTranslations => allTranslations[npmName]),
- map(translations => {
- const registeredSettings = res.registeredSettings
- .map(r => {
- return Object.assign({}, r, { label: peertubeTranslate(r.label, translations) })
- })
-
- return { registeredSettings }
- })
- )
- }
}