From 2accfdd8ecd092de7e8c71fbd1235e139ad29832 Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Wed, 29 Dec 2021 12:14:06 +0100 Subject: Refactor admin plugins --- .../plugin-list-installed.component.ts | 26 ++++++++++++---------- 1 file changed, 14 insertions(+), 12 deletions(-) (limited to 'client/src/app/+admin/plugins/plugin-list-installed/plugin-list-installed.component.ts') 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 6fd238848..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 @@ -10,14 +10,10 @@ import { PeerTubePlugin, PluginType } from '@shared/models' @Component({ selector: 'my-plugin-list-installed', templateUrl: './plugin-list-installed.component.html', - styleUrls: [ - '../shared/toggle-plugin-type.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, @@ -39,22 +35,28 @@ 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() } -- cgit v1.2.3