From 4f5d045960b042eb27e10bac1bdaf1c074c9fa2a Mon Sep 17 00:00:00 2001 From: Rigel Kent Date: Thu, 23 Jul 2020 21:30:04 +0200 Subject: harmonize search for libraries --- .../my-account-subscriptions.component.html | 15 ++++++-- .../my-account-subscriptions.component.scss | 4 ++ .../my-account-subscriptions.component.ts | 43 ++++++++++++++++------ 3 files changed, 48 insertions(+), 14 deletions(-) (limited to 'client/src/app/+my-account/my-account-subscriptions') diff --git a/client/src/app/+my-account/my-account-subscriptions/my-account-subscriptions.component.html b/client/src/app/+my-account/my-account-subscriptions/my-account-subscriptions.component.html index 3b4c3022e..6cec7c0d5 100644 --- a/client/src/app/+my-account/my-account-subscriptions/my-account-subscriptions.component.html +++ b/client/src/app/+my-account/my-account-subscriptions/my-account-subscriptions.component.html @@ -1,6 +1,15 @@ -

- - My subscriptions +

+ + + My subscriptions + {{ pagination.totalItems }} + + +
+ + + Clear filters +

You don't have any subscriptions yet.
diff --git a/client/src/app/+my-account/my-account-subscriptions/my-account-subscriptions.component.scss b/client/src/app/+my-account/my-account-subscriptions/my-account-subscriptions.component.scss index dd990c42b..884959070 100644 --- a/client/src/app/+my-account/my-account-subscriptions/my-account-subscriptions.component.scss +++ b/client/src/app/+my-account/my-account-subscriptions/my-account-subscriptions.component.scss @@ -1,6 +1,10 @@ @import '_variables'; @import '_mixins'; +input[type=text] { + @include peertube-input-text(300px); +} + .video-channel { @include row-blocks; diff --git a/client/src/app/+my-account/my-account-subscriptions/my-account-subscriptions.component.ts b/client/src/app/+my-account/my-account-subscriptions/my-account-subscriptions.component.ts index 390293a28..994fe5142 100644 --- a/client/src/app/+my-account/my-account-subscriptions/my-account-subscriptions.component.ts +++ b/client/src/app/+my-account/my-account-subscriptions/my-account-subscriptions.component.ts @@ -3,6 +3,7 @@ import { Component, OnInit } from '@angular/core' import { ComponentPagination, Notifier } from '@app/core' import { VideoChannel } from '@app/shared/shared-main' import { UserSubscriptionService } from '@app/shared/shared-user-subscription' +import { debounceTime } from 'rxjs/operators' @Component({ selector: 'my-account-subscriptions', @@ -20,6 +21,9 @@ export class MyAccountSubscriptionsComponent implements OnInit { onDataSubject = new Subject() + subscriptionsSearch: string + subscriptionsSearchChanged = new Subject() + constructor ( private userSubscriptionService: UserSubscriptionService, private notifier: Notifier @@ -27,20 +31,22 @@ export class MyAccountSubscriptionsComponent implements OnInit { ngOnInit () { this.loadSubscriptions() - } - loadSubscriptions () { - this.userSubscriptionService.listSubscriptions(this.pagination) - .subscribe( - res => { - this.videoChannels = this.videoChannels.concat(res.data) - this.pagination.totalItems = res.total + this.subscriptionsSearchChanged + .pipe(debounceTime(500)) + .subscribe(() => { + this.pagination.currentPage = 1 + this.loadSubscriptions(false) + }) + } - this.onDataSubject.next(res.data) - }, + resetSearch () { + this.subscriptionsSearch = '' + this.onSubscriptionsSearchChanged() + } - error => this.notifier.error(error.message) - ) + onSubscriptionsSearchChanged () { + this.subscriptionsSearchChanged.next() } onNearOfBottom () { @@ -51,4 +57,19 @@ export class MyAccountSubscriptionsComponent implements OnInit { this.loadSubscriptions() } + private loadSubscriptions (more = true) { + this.userSubscriptionService.listSubscriptions({ pagination: this.pagination, search: this.subscriptionsSearch }) + .subscribe( + res => { + this.videoChannels = more + ? this.videoChannels.concat(res.data) + : res.data + this.pagination.totalItems = res.total + + this.onDataSubject.next(res.data) + }, + + error => this.notifier.error(error.message) + ) + } } -- cgit v1.2.3