diff options
author | Chocobozzz <me@florianbigard.com> | 2021-12-29 12:14:06 +0100 |
---|---|---|
committer | Chocobozzz <me@florianbigard.com> | 2021-12-29 12:17:11 +0100 |
commit | 2accfdd8ecd092de7e8c71fbd1235e139ad29832 (patch) | |
tree | 24b5bb7da7192fa11054a48ac0e4384b8ec8fb72 /client/src/app/+admin/plugins/plugin-search | |
parent | 9744bb2ae8284c4589b66055c1d99997abf18748 (diff) | |
download | PeerTube-2accfdd8ecd092de7e8c71fbd1235e139ad29832.tar.gz PeerTube-2accfdd8ecd092de7e8c71fbd1235e139ad29832.tar.zst PeerTube-2accfdd8ecd092de7e8c71fbd1235e139ad29832.zip |
Refactor admin plugins
Diffstat (limited to 'client/src/app/+admin/plugins/plugin-search')
3 files changed, 38 insertions, 39 deletions
diff --git a/client/src/app/+admin/plugins/plugin-search/plugin-search.component.html b/client/src/app/+admin/plugins/plugin-search/plugin-search.component.html index 14f28f7ef..33575ef52 100644 --- a/client/src/app/+admin/plugins/plugin-search/plugin-search.component.html +++ b/client/src/app/+admin/plugins/plugin-search/plugin-search.component.html | |||
@@ -1,28 +1,27 @@ | |||
1 | <div class="toggle-plugin-type"> | 1 | <my-plugin-navigation [pluginType]="pluginType"></my-plugin-navigation> |
2 | <p-selectButton [options]="pluginTypeOptions" [(ngModel)]="pluginType" (ngModelChange)="reloadPlugins()"></p-selectButton> | ||
3 | </div> | ||
4 | |||
5 | <div class="search-bar"> | ||
6 | <input type="text" (input)="onSearchChange($event)" i18n-placeholder placeholder="Search..." myAutofocus /> | ||
7 | </div> | ||
8 | 2 | ||
9 | <div class="alert alert-info" i18n *ngIf="pluginInstalled"> | 3 | <div class="alert alert-info" i18n *ngIf="pluginInstalled"> |
10 | To load your new installed plugins or themes, refresh the page. | 4 | To load your new installed plugins or themes, refresh the page. |
11 | </div> | 5 | </div> |
12 | 6 | ||
13 | <div class="result-title" *ngIf="!isSearching"> | 7 | <div class="result-and-search"> |
14 | <ng-container *ngIf="!search"> | 8 | <ng-container *ngIf="!search"> |
15 | <my-global-icon iconName="trending" aria-hidden="true"></my-global-icon> | 9 | <my-global-icon iconName="trending" aria-hidden="true"></my-global-icon> |
16 | <ng-container i18n>Popular</ng-container> | 10 | <ng-container *ngIf="!isThemeSearch()" i18n>Popular plugins</ng-container> |
11 | <ng-container *ngIf="isThemeSearch()" i18n>Popular themes</ng-container> | ||
17 | </ng-container> | 12 | </ng-container> |
18 | 13 | ||
19 | <ng-container *ngIf="!!search"> | 14 | <ng-container *ngIf="search && !isSearching"> |
20 | <my-global-icon iconName="search"></my-global-icon> | 15 | <my-global-icon iconName="search"></my-global-icon> |
21 | 16 | ||
22 | <ng-container i18n> | 17 | <ng-container i18n> |
23 | {{ pagination.totalItems }} {pagination.totalItems, plural, =1 {result} other {results}} for "{{ search }}" | 18 | {{ pagination.totalItems }} {pagination.totalItems, plural, =1 {result} other {results}} for "{{ search }}" |
24 | </ng-container> | 19 | </ng-container> |
25 | </ng-container> | 20 | </ng-container> |
21 | |||
22 | <div class="search-bar"> | ||
23 | <input type="text" (input)="onSearchChange($event)" i18n-placeholder placeholder="Search..." myAutofocus /> | ||
24 | </div> | ||
26 | </div> | 25 | </div> |
27 | 26 | ||
28 | <div class="no-results" i18n *ngIf="pagination.totalItems === 0"> | 27 | <div class="no-results" i18n *ngIf="pagination.totalItems === 0"> |
diff --git a/client/src/app/+admin/plugins/plugin-search/plugin-search.component.scss b/client/src/app/+admin/plugins/plugin-search/plugin-search.component.scss index 16b838682..8bb710fc2 100644 --- a/client/src/app/+admin/plugins/plugin-search/plugin-search.component.scss +++ b/client/src/app/+admin/plugins/plugin-search/plugin-search.component.scss | |||
@@ -1,24 +1,24 @@ | |||
1 | @use '_variables' as *; | 1 | @use '_variables' as *; |
2 | @use '_mixins' as *; | 2 | @use '_mixins' as *; |
3 | 3 | ||
4 | .search-bar { | 4 | .result-and-search { |
5 | font-size: 22px; | ||
6 | font-weight: 600; | ||
7 | margin: 30px 0 15px; | ||
5 | display: flex; | 8 | display: flex; |
6 | justify-content: center; | ||
7 | margin: 30px 0; | ||
8 | 9 | ||
9 | input { | 10 | my-global-icon { |
10 | @include peertube-input-text(60%); | 11 | @include margin-right(5px); |
11 | height: 35px; | ||
12 | } | 12 | } |
13 | } | 13 | } |
14 | 14 | ||
15 | .result-title { | 15 | .search-bar { |
16 | font-size: 22px; | 16 | margin-left: auto; |
17 | font-weight: 600; | ||
18 | margin-bottom: 15px; | ||
19 | 17 | ||
20 | my-global-icon { | 18 | input { |
21 | @include margin-right(5px); | 19 | @include peertube-input-text(500px); |
20 | |||
21 | height: 35px; | ||
22 | } | 22 | } |
23 | } | 23 | } |
24 | 24 | ||
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 | ||