diff options
Diffstat (limited to 'client/src/app/+admin/plugins/plugin-search/plugin-search.component.ts')
-rw-r--r-- | client/src/app/+admin/plugins/plugin-search/plugin-search.component.ts | 34 |
1 files changed, 17 insertions, 17 deletions
diff --git a/client/src/app/+admin/plugins/plugin-search/plugin-search.component.ts b/client/src/app/+admin/plugins/plugin-search/plugin-search.component.ts index ef704c83b..d39c2ea1c 100644 --- a/client/src/app/+admin/plugins/plugin-search/plugin-search.component.ts +++ b/client/src/app/+admin/plugins/plugin-search/plugin-search.component.ts | |||
@@ -9,14 +9,10 @@ import { PeerTubePluginIndex, PluginType } from '@shared/models' | |||
9 | @Component({ | 9 | @Component({ |
10 | selector: 'my-plugin-search', | 10 | selector: 'my-plugin-search', |
11 | templateUrl: './plugin-search.component.html', | 11 | templateUrl: './plugin-search.component.html', |
12 | styleUrls: [ | 12 | styleUrls: [ './plugin-search.component.scss' ] |
13 | '../shared/toggle-plugin-type.scss', | ||
14 | './plugin-search.component.scss' | ||
15 | ] | ||
16 | }) | 13 | }) |
17 | export class PluginSearchComponent implements OnInit { | 14 | export class PluginSearchComponent implements OnInit { |
18 | pluginTypeOptions: { label: string, value: PluginType }[] = [] | 15 | pluginType: PluginType |
19 | pluginType: PluginType = PluginType.PLUGIN | ||
20 | 16 | ||
21 | pagination: ComponentPagination = { | 17 | pagination: ComponentPagination = { |
22 | currentPage: 1, | 18 | currentPage: 1, |
@@ -44,24 +40,30 @@ export class PluginSearchComponent implements OnInit { | |||
44 | private router: Router, | 40 | private router: Router, |
45 | private route: ActivatedRoute | 41 | private route: ActivatedRoute |
46 | ) { | 42 | ) { |
47 | this.pluginTypeOptions = this.pluginApiService.getPluginTypeOptions() | ||
48 | } | 43 | } |
49 | 44 | ||
50 | ngOnInit () { | 45 | ngOnInit () { |
51 | const query = this.route.snapshot.queryParams | 46 | if (!this.route.snapshot.queryParams['pluginType']) { |
52 | if (query['pluginType']) this.pluginType = parseInt(query['pluginType'], 10) | 47 | const queryParams = { pluginType: PluginType.PLUGIN } |
48 | |||
49 | this.router.navigate([], { queryParams }) | ||
50 | } | ||
51 | |||
52 | this.route.queryParams.subscribe(query => { | ||
53 | if (!query['pluginType']) return | ||
54 | |||
55 | this.pluginType = parseInt(query['pluginType'], 10) | ||
56 | this.search = query['search'] || '' | ||
57 | |||
58 | this.reloadPlugins() | ||
59 | }) | ||
53 | 60 | ||
54 | this.searchSubject.asObservable() | 61 | this.searchSubject.asObservable() |
55 | .pipe( | 62 | .pipe( |
56 | debounceTime(400), | 63 | debounceTime(400), |
57 | distinctUntilChanged() | 64 | distinctUntilChanged() |
58 | ) | 65 | ) |
59 | .subscribe(search => { | 66 | .subscribe(search => this.router.navigate([], { queryParams: { search }, queryParamsHandling: 'merge' })) |
60 | this.search = search | ||
61 | this.reloadPlugins() | ||
62 | }) | ||
63 | |||
64 | this.reloadPlugins() | ||
65 | } | 67 | } |
66 | 68 | ||
67 | onSearchChange (event: Event) { | 69 | onSearchChange (event: Event) { |
@@ -74,8 +76,6 @@ export class PluginSearchComponent implements OnInit { | |||
74 | this.pagination.currentPage = 1 | 76 | this.pagination.currentPage = 1 |
75 | this.plugins = [] | 77 | this.plugins = [] |
76 | 78 | ||
77 | this.router.navigate([], { queryParams: { pluginType: this.pluginType } }) | ||
78 | |||
79 | this.loadMorePlugins() | 79 | this.loadMorePlugins() |
80 | } | 80 | } |
81 | 81 | ||