X-Git-Url: https://git.immae.eu/?a=blobdiff_plain;ds=sidebyside;f=client%2Fsrc%2Fapp%2F%2Badmin%2Fplugins%2Fplugin-list-installed%2Fplugin-list-installed.component.ts;h=6d66869dd1c08499503805ab9cd9d1ac5434c6ca;hb=2accfdd8ecd092de7e8c71fbd1235e139ad29832;hp=6af2249207b552e63b353dd30ca4dfd001fb8359;hpb=5b1a6d45b5d6e50102e1c7c8c845401b76b11b4d;p=github%2FChocobozzz%2FPeerTube.git diff --git a/client/src/app/+admin/plugins/plugin-list-installed/plugin-list-installed.component.ts b/client/src/app/+admin/plugins/plugin-list-installed/plugin-list-installed.component.ts index 6af224920..6d66869dd 100644 --- a/client/src/app/+admin/plugins/plugin-list-installed/plugin-list-installed.component.ts +++ b/client/src/app/+admin/plugins/plugin-list-installed/plugin-list-installed.component.ts @@ -4,21 +4,16 @@ import { ActivatedRoute, Router } from '@angular/router' import { PluginApiService } from '@app/+admin/plugins/shared/plugin-api.service' import { ComponentPagination, ConfirmService, hasMoreItems, Notifier } from '@app/core' import { PluginService } from '@app/core/plugins/plugin.service' -import { compareSemVer } from '@shared/core-utils/miscs/miscs' +import { compareSemVer } from '@shared/core-utils' import { PeerTubePlugin, PluginType } from '@shared/models' @Component({ selector: 'my-plugin-list-installed', templateUrl: './plugin-list-installed.component.html', - styleUrls: [ - '../shared/toggle-plugin-type.scss', - '../shared/plugin-list.component.scss', - './plugin-list-installed.component.scss' - ] + styleUrls: [ './plugin-list-installed.component.scss' ] }) export class PluginListInstalledComponent implements OnInit { - pluginTypeOptions: { label: string, value: PluginType }[] = [] - pluginType: PluginType = PluginType.PLUGIN + pluginType: PluginType pagination: ComponentPagination = { currentPage: 1, @@ -40,37 +35,43 @@ export class PluginListInstalledComponent implements OnInit { private router: Router, private route: ActivatedRoute ) { - this.pluginTypeOptions = this.pluginApiService.getPluginTypeOptions() } ngOnInit () { - const query = this.route.snapshot.queryParams - if (query['pluginType']) this.pluginType = parseInt(query['pluginType'], 10) + if (!this.route.snapshot.queryParams['pluginType']) { + const queryParams = { pluginType: PluginType.PLUGIN } - this.reloadPlugins() + this.router.navigate([], { queryParams }) + } + + this.route.queryParams.subscribe(query => { + if (!query['pluginType']) return + + this.pluginType = parseInt(query['pluginType'], 10) + + this.reloadPlugins() + }) } reloadPlugins () { this.pagination.currentPage = 1 this.plugins = [] - this.router.navigate([], { queryParams: { pluginType: this.pluginType } }) - this.loadMorePlugins() } loadMorePlugins () { this.pluginApiService.getPlugins(this.pluginType, this.pagination, this.sort) - .subscribe( - res => { + .subscribe({ + next: res => { this.plugins = this.plugins.concat(res.data) this.pagination.totalItems = res.total this.onDataSubject.next(res.data) }, - err => this.notifier.error(err.message) - ) + error: err => this.notifier.error(err.message) + }) } onNearOfBottom () { @@ -113,16 +114,16 @@ export class PluginListInstalledComponent implements OnInit { if (res === false) return this.pluginApiService.uninstall(plugin.name, plugin.type) - .subscribe( - () => { + .subscribe({ + next: () => { this.notifier.success($localize`${plugin.name} uninstalled.`) this.plugins = this.plugins.filter(p => p.name !== plugin.name) this.pagination.totalItems-- }, - err => this.notifier.error(err.message) - ) + error: err => this.notifier.error(err.message) + }) } async update (plugin: PeerTubePlugin) { @@ -143,8 +144,8 @@ export class PluginListInstalledComponent implements OnInit { this.pluginApiService.update(plugin.name, plugin.type) .pipe() - .subscribe( - res => { + .subscribe({ + next: res => { this.updating[updatingKey] = false this.notifier.success($localize`${plugin.name} updated.`) @@ -152,8 +153,8 @@ export class PluginListInstalledComponent implements OnInit { Object.assign(plugin, res) }, - err => this.notifier.error(err.message) - ) + error: err => this.notifier.error(err.message) + }) } getShowRouterLink (plugin: PeerTubePlugin) {