diff options
author | Chocobozzz <me@florianbigard.com> | 2021-05-03 14:33:34 +0200 |
---|---|---|
committer | Chocobozzz <me@florianbigard.com> | 2021-05-03 16:42:15 +0200 |
commit | 2e46eb97154da909b82d5efe1d336a3412594ff0 (patch) | |
tree | a86b6ca6439f62c8498887c4e1c3ece9a302d116 /client/src/app/+my-library/my-videos | |
parent | 514e8168fbad08e70ce12dab587f720b4e91b19e (diff) | |
download | PeerTube-2e46eb97154da909b82d5efe1d336a3412594ff0.tar.gz PeerTube-2e46eb97154da909b82d5efe1d336a3412594ff0.tar.zst PeerTube-2e46eb97154da909b82d5efe1d336a3412594ff0.zip |
Refactor search filters
Diffstat (limited to 'client/src/app/+my-library/my-videos')
-rw-r--r-- | client/src/app/+my-library/my-videos/my-videos.component.html | 4 | ||||
-rw-r--r-- | client/src/app/+my-library/my-videos/my-videos.component.ts | 21 |
2 files changed, 12 insertions, 13 deletions
diff --git a/client/src/app/+my-library/my-videos/my-videos.component.html b/client/src/app/+my-library/my-videos/my-videos.component.html index 7c1cdb511..8d8b482ad 100644 --- a/client/src/app/+my-library/my-videos/my-videos.component.html +++ b/client/src/app/+my-library/my-videos/my-videos.component.html | |||
@@ -19,7 +19,7 @@ | |||
19 | </h1> | 19 | </h1> |
20 | 20 | ||
21 | <div class="videos-header d-flex justify-content-between"> | 21 | <div class="videos-header d-flex justify-content-between"> |
22 | <my-advanced-input-filter [filters]="inputFilters" (search)="onSearch($event)" (resetTableFilter)="resetTableFilter()"></my-advanced-input-filter> | 22 | <my-advanced-input-filter [filters]="inputFilters" (search)="onSearch($event)"></my-advanced-input-filter> |
23 | 23 | ||
24 | <div class="peertube-select-container peertube-select-button"> | 24 | <div class="peertube-select-container peertube-select-button"> |
25 | <select [(ngModel)]="sort" (ngModelChange)="onChangeSortColumn()" class="form-control"> | 25 | <select [(ngModel)]="sort" (ngModelChange)="onChangeSortColumn()" class="form-control"> |
@@ -41,6 +41,7 @@ | |||
41 | [titlePage]="titlePage" | 41 | [titlePage]="titlePage" |
42 | [getVideosObservableFunction]="getVideosObservableFunction" | 42 | [getVideosObservableFunction]="getVideosObservableFunction" |
43 | [user]="user" | 43 | [user]="user" |
44 | [loadOnInit]="false" | ||
44 | #videosSelection | 45 | #videosSelection |
45 | > | 46 | > |
46 | <ng-template ptTemplate="globalButtons"> | 47 | <ng-template ptTemplate="globalButtons"> |
@@ -59,6 +60,5 @@ | |||
59 | </ng-template> | 60 | </ng-template> |
60 | </my-videos-selection> | 61 | </my-videos-selection> |
61 | 62 | ||
62 | |||
63 | <my-video-change-ownership #videoChangeOwnershipModal></my-video-change-ownership> | 63 | <my-video-change-ownership #videoChangeOwnershipModal></my-video-change-ownership> |
64 | <my-live-stream-information #liveStreamInformationModal></my-live-stream-information> | 64 | <my-live-stream-information #liveStreamInformationModal></my-live-stream-information> |
diff --git a/client/src/app/+my-library/my-videos/my-videos.component.ts b/client/src/app/+my-library/my-videos/my-videos.component.ts index f9c1b32b0..1e4a4406d 100644 --- a/client/src/app/+my-library/my-videos/my-videos.component.ts +++ b/client/src/app/+my-library/my-videos/my-videos.component.ts | |||
@@ -1,8 +1,8 @@ | |||
1 | import { concat, Observable } from 'rxjs' | 1 | import { concat, Observable } from 'rxjs' |
2 | import { tap, toArray } from 'rxjs/operators' | 2 | import { tap, toArray } from 'rxjs/operators' |
3 | import { AfterViewInit, Component, OnInit, ViewChild } from '@angular/core' | 3 | import { Component, OnInit, ViewChild } from '@angular/core' |
4 | import { ActivatedRoute, Router } from '@angular/router' | 4 | import { ActivatedRoute, Router } from '@angular/router' |
5 | import { AuthService, ComponentPagination, ConfirmService, Notifier, RouteFilter, ScreenService, ServerService, User } from '@app/core' | 5 | import { AuthService, ComponentPagination, ConfirmService, Notifier, ScreenService, ServerService, User } from '@app/core' |
6 | import { DisableForReuseHook } from '@app/core/routing/disable-for-reuse-hook' | 6 | import { DisableForReuseHook } from '@app/core/routing/disable-for-reuse-hook' |
7 | import { immutableAssign } from '@app/helpers' | 7 | import { immutableAssign } from '@app/helpers' |
8 | import { AdvancedInputFilter } from '@app/shared/shared-forms' | 8 | import { AdvancedInputFilter } from '@app/shared/shared-forms' |
@@ -16,7 +16,7 @@ import { VideoChangeOwnershipComponent } from './modals/video-change-ownership.c | |||
16 | templateUrl: './my-videos.component.html', | 16 | templateUrl: './my-videos.component.html', |
17 | styleUrls: [ './my-videos.component.scss' ] | 17 | styleUrls: [ './my-videos.component.scss' ] |
18 | }) | 18 | }) |
19 | export class MyVideosComponent extends RouteFilter implements OnInit, AfterViewInit, DisableForReuseHook { | 19 | export class MyVideosComponent implements OnInit, DisableForReuseHook { |
20 | @ViewChild('videosSelection', { static: true }) videosSelection: VideosSelectionComponent | 20 | @ViewChild('videosSelection', { static: true }) videosSelection: VideosSelectionComponent |
21 | @ViewChild('videoChangeOwnershipModal', { static: true }) videoChangeOwnershipModal: VideoChangeOwnershipComponent | 21 | @ViewChild('videoChangeOwnershipModal', { static: true }) videoChangeOwnershipModal: VideoChangeOwnershipComponent |
22 | @ViewChild('liveStreamInformationModal', { static: true }) liveStreamInformationModal: LiveStreamInformationComponent | 22 | @ViewChild('liveStreamInformationModal', { static: true }) liveStreamInformationModal: LiveStreamInformationComponent |
@@ -42,6 +42,7 @@ export class MyVideosComponent extends RouteFilter implements OnInit, AfterViewI | |||
42 | 42 | ||
43 | videos: Video[] = [] | 43 | videos: Video[] = [] |
44 | getVideosObservableFunction = this.getVideosObservable.bind(this) | 44 | getVideosObservableFunction = this.getVideosObservable.bind(this) |
45 | |||
45 | sort: VideoSortField = '-publishedAt' | 46 | sort: VideoSortField = '-publishedAt' |
46 | 47 | ||
47 | user: User | 48 | user: User |
@@ -53,6 +54,8 @@ export class MyVideosComponent extends RouteFilter implements OnInit, AfterViewI | |||
53 | } | 54 | } |
54 | ] | 55 | ] |
55 | 56 | ||
57 | private search: string | ||
58 | |||
56 | constructor ( | 59 | constructor ( |
57 | protected router: Router, | 60 | protected router: Router, |
58 | protected serverService: ServerService, | 61 | protected serverService: ServerService, |
@@ -63,8 +66,6 @@ export class MyVideosComponent extends RouteFilter implements OnInit, AfterViewI | |||
63 | private confirmService: ConfirmService, | 66 | private confirmService: ConfirmService, |
64 | private videoService: VideoService | 67 | private videoService: VideoService |
65 | ) { | 68 | ) { |
66 | super() | ||
67 | |||
68 | this.titlePage = $localize`My videos` | 69 | this.titlePage = $localize`My videos` |
69 | } | 70 | } |
70 | 71 | ||
@@ -72,16 +73,14 @@ export class MyVideosComponent extends RouteFilter implements OnInit, AfterViewI | |||
72 | this.buildActions() | 73 | this.buildActions() |
73 | 74 | ||
74 | this.user = this.authService.getUser() | 75 | this.user = this.authService.getUser() |
75 | |||
76 | this.initSearch() | ||
77 | this.listenToSearchChange() | ||
78 | } | 76 | } |
79 | 77 | ||
80 | ngAfterViewInit () { | 78 | onSearch (search: string) { |
81 | if (this.search) this.setTableFilter(this.search, false) | 79 | this.search = search |
80 | this.reloadData() | ||
82 | } | 81 | } |
83 | 82 | ||
84 | loadData () { | 83 | reloadData () { |
85 | this.videosSelection.reloadVideos() | 84 | this.videosSelection.reloadVideos() |
86 | } | 85 | } |
87 | 86 | ||