diff options
Diffstat (limited to 'client/src/app/+my-library/my-subscriptions')
3 files changed, 11 insertions, 32 deletions
diff --git a/client/src/app/+my-library/my-subscriptions/my-subscriptions.component.html b/client/src/app/+my-library/my-subscriptions/my-subscriptions.component.html index 853d47fe6..f91cebacf 100644 --- a/client/src/app/+my-library/my-subscriptions/my-subscriptions.component.html +++ b/client/src/app/+my-library/my-subscriptions/my-subscriptions.component.html | |||
@@ -7,12 +7,7 @@ | |||
7 | </h1> | 7 | </h1> |
8 | 8 | ||
9 | <div class="video-subscriptions-header"> | 9 | <div class="video-subscriptions-header"> |
10 | <div class="has-feedback has-clear"> | 10 | <my-advanced-input-filter (search)="onSearch($event)"></my-advanced-input-filter> |
11 | <input type="text" placeholder="Search your subscriptions" i18n-placeholder [(ngModel)]="subscriptionsSearch" | ||
12 | (ngModelChange)="onSubscriptionsSearchChanged()" /> | ||
13 | <a class="glyphicon glyphicon-remove-sign form-control-feedback form-control-clear" (click)="resetSearch()"></a> | ||
14 | <span class="sr-only" i18n>Clear filters</span> | ||
15 | </div> | ||
16 | </div> | 11 | </div> |
17 | 12 | ||
18 | <div class="no-results" i18n *ngIf="pagination.totalItems === 0">You don't have any subscription yet.</div> | 13 | <div class="no-results" i18n *ngIf="pagination.totalItems === 0">You don't have any subscription yet.</div> |
diff --git a/client/src/app/+my-library/my-subscriptions/my-subscriptions.component.scss b/client/src/app/+my-library/my-subscriptions/my-subscriptions.component.scss index 53ceaa250..6c1ddf716 100644 --- a/client/src/app/+my-library/my-subscriptions/my-subscriptions.component.scss +++ b/client/src/app/+my-library/my-subscriptions/my-subscriptions.component.scss | |||
@@ -58,6 +58,7 @@ input[type=text] { | |||
58 | 58 | ||
59 | .video-subscriptions-header { | 59 | .video-subscriptions-header { |
60 | margin-bottom: 30px; | 60 | margin-bottom: 30px; |
61 | display: flex; | ||
61 | } | 62 | } |
62 | 63 | ||
63 | @media screen and (max-width: $small-view) { | 64 | @media screen and (max-width: $small-view) { |
diff --git a/client/src/app/+my-library/my-subscriptions/my-subscriptions.component.ts b/client/src/app/+my-library/my-subscriptions/my-subscriptions.component.ts index 3b748eccf..1f4a931a0 100644 --- a/client/src/app/+my-library/my-subscriptions/my-subscriptions.component.ts +++ b/client/src/app/+my-library/my-subscriptions/my-subscriptions.component.ts | |||
@@ -1,6 +1,5 @@ | |||
1 | import { Subject } from 'rxjs' | 1 | import { Subject } from 'rxjs' |
2 | import { debounceTime } from 'rxjs/operators' | 2 | import { Component } from '@angular/core' |
3 | import { Component, OnInit } from '@angular/core' | ||
4 | import { ComponentPagination, Notifier } from '@app/core' | 3 | import { ComponentPagination, Notifier } from '@app/core' |
5 | import { VideoChannel } from '@app/shared/shared-main' | 4 | import { VideoChannel } from '@app/shared/shared-main' |
6 | import { UserSubscriptionService } from '@app/shared/shared-user-subscription' | 5 | import { UserSubscriptionService } from '@app/shared/shared-user-subscription' |
@@ -9,7 +8,7 @@ import { UserSubscriptionService } from '@app/shared/shared-user-subscription' | |||
9 | templateUrl: './my-subscriptions.component.html', | 8 | templateUrl: './my-subscriptions.component.html', |
10 | styleUrls: [ './my-subscriptions.component.scss' ] | 9 | styleUrls: [ './my-subscriptions.component.scss' ] |
11 | }) | 10 | }) |
12 | export class MySubscriptionsComponent implements OnInit { | 11 | export class MySubscriptionsComponent { |
13 | videoChannels: VideoChannel[] = [] | 12 | videoChannels: VideoChannel[] = [] |
14 | 13 | ||
15 | pagination: ComponentPagination = { | 14 | pagination: ComponentPagination = { |
@@ -20,34 +19,13 @@ export class MySubscriptionsComponent implements OnInit { | |||
20 | 19 | ||
21 | onDataSubject = new Subject<any[]>() | 20 | onDataSubject = new Subject<any[]>() |
22 | 21 | ||
23 | subscriptionsSearch: string | 22 | search: string |
24 | subscriptionsSearchChanged = new Subject<string>() | ||
25 | 23 | ||
26 | constructor ( | 24 | constructor ( |
27 | private userSubscriptionService: UserSubscriptionService, | 25 | private userSubscriptionService: UserSubscriptionService, |
28 | private notifier: Notifier | 26 | private notifier: Notifier |
29 | ) {} | 27 | ) {} |
30 | 28 | ||
31 | ngOnInit () { | ||
32 | this.loadSubscriptions() | ||
33 | |||
34 | this.subscriptionsSearchChanged | ||
35 | .pipe(debounceTime(500)) | ||
36 | .subscribe(() => { | ||
37 | this.pagination.currentPage = 1 | ||
38 | this.loadSubscriptions(false) | ||
39 | }) | ||
40 | } | ||
41 | |||
42 | resetSearch () { | ||
43 | this.subscriptionsSearch = '' | ||
44 | this.onSubscriptionsSearchChanged() | ||
45 | } | ||
46 | |||
47 | onSubscriptionsSearchChanged () { | ||
48 | this.subscriptionsSearchChanged.next() | ||
49 | } | ||
50 | |||
51 | onNearOfBottom () { | 29 | onNearOfBottom () { |
52 | // Last page | 30 | // Last page |
53 | if (this.pagination.totalItems <= (this.pagination.currentPage * this.pagination.itemsPerPage)) return | 31 | if (this.pagination.totalItems <= (this.pagination.currentPage * this.pagination.itemsPerPage)) return |
@@ -56,8 +34,13 @@ export class MySubscriptionsComponent implements OnInit { | |||
56 | this.loadSubscriptions() | 34 | this.loadSubscriptions() |
57 | } | 35 | } |
58 | 36 | ||
37 | onSearch (search: string) { | ||
38 | this.search = search | ||
39 | this.loadSubscriptions(false) | ||
40 | } | ||
41 | |||
59 | private loadSubscriptions (more = true) { | 42 | private loadSubscriptions (more = true) { |
60 | this.userSubscriptionService.listSubscriptions({ pagination: this.pagination, search: this.subscriptionsSearch }) | 43 | this.userSubscriptionService.listSubscriptions({ pagination: this.pagination, search: this.search }) |
61 | .subscribe( | 44 | .subscribe( |
62 | res => { | 45 | res => { |
63 | this.videoChannels = more | 46 | this.videoChannels = more |