diff options
Diffstat (limited to 'client/src/app/+my-library/my-history')
-rw-r--r-- | client/src/app/+my-library/my-history/my-history.component.html | 32 | ||||
-rw-r--r-- | client/src/app/+my-library/my-history/my-history.component.ts | 75 |
2 files changed, 53 insertions, 54 deletions
diff --git a/client/src/app/+my-library/my-history/my-history.component.html b/client/src/app/+my-library/my-history/my-history.component.html index 9dec64645..45ca37e0d 100644 --- a/client/src/app/+my-library/my-history/my-history.component.html +++ b/client/src/app/+my-library/my-history/my-history.component.html | |||
@@ -5,14 +5,7 @@ | |||
5 | 5 | ||
6 | <div class="top-buttons"> | 6 | <div class="top-buttons"> |
7 | <div class="search-wrapper"> | 7 | <div class="search-wrapper"> |
8 | <div class="input-group has-feedback has-clear"> | 8 | <my-advanced-input-filter (search)="onSearch($event)"></my-advanced-input-filter> |
9 | <input | ||
10 | type="text" name="history-search" id="history-search" i18n-placeholder placeholder="Search your history" | ||
11 | (keyup)="onSearch($event)" | ||
12 | > | ||
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> | 9 | </div> |
17 | 10 | ||
18 | <div class="history-switch"> | 11 | <div class="history-switch"> |
@@ -26,14 +19,15 @@ | |||
26 | </button> | 19 | </button> |
27 | </div> | 20 | </div> |
28 | 21 | ||
29 | 22 | <my-videos-selection | |
30 | <div class="no-history" i18n *ngIf="hasDoneFirstQuery && videos.length === 0">You don't have any video in your watch history yet.</div> | 23 | [pagination]="pagination" |
31 | 24 | [(videosModel)]="videos" | |
32 | <div myInfiniteScroller (nearOfBottom)="onNearOfBottom()" [autoInit]="true" [dataObservable]="onDataSubject.asObservable()" class="videos"> | 25 | [miniatureDisplayOptions]="miniatureDisplayOptions" |
33 | <div class="video" *ngFor="let video of videos"> | 26 | [titlePage]="titlePage" |
34 | <my-video-miniature | 27 | [getVideosObservableFunction]="getVideosObservableFunction" |
35 | [video]="video" [displayAsRow]="true" | 28 | [user]="user" |
36 | (videoRemoved)="removeVideoFromArray(video)" (videoBlocked)="removeVideoFromArray(video)" | 29 | [loadOnInit]="false" |
37 | ></my-video-miniature> | 30 | i18n-noResultMessage noResultMessage="You don't have any video in your watch history yet." |
38 | </div> | 31 | [enableSelection]="false" |
39 | </div> | 32 | #videosSelection |
33 | ></my-videos-selection> | ||
diff --git a/client/src/app/+my-library/my-history/my-history.component.ts b/client/src/app/+my-library/my-history/my-history.component.ts index 1695bd7ad..ad83db7ab 100644 --- a/client/src/app/+my-library/my-history/my-history.component.ts +++ b/client/src/app/+my-library/my-history/my-history.component.ts | |||
@@ -1,36 +1,55 @@ | |||
1 | import { Component, ComponentFactoryResolver, OnDestroy, OnInit } from '@angular/core' | 1 | import { Subject } from 'rxjs' |
2 | import { tap } from 'rxjs/operators' | ||
3 | import { Component, ComponentFactoryResolver, OnInit, ViewChild } from '@angular/core' | ||
2 | import { ActivatedRoute, Router } from '@angular/router' | 4 | import { ActivatedRoute, Router } from '@angular/router' |
3 | import { | 5 | import { |
4 | AuthService, | 6 | AuthService, |
5 | ComponentPagination, | 7 | ComponentPagination, |
6 | ConfirmService, | 8 | ConfirmService, |
9 | DisableForReuseHook, | ||
7 | LocalStorageService, | 10 | LocalStorageService, |
8 | Notifier, | 11 | Notifier, |
9 | ScreenService, | 12 | ScreenService, |
10 | ServerService, | 13 | ServerService, |
14 | User, | ||
11 | UserService | 15 | UserService |
12 | } from '@app/core' | 16 | } from '@app/core' |
13 | import { immutableAssign } from '@app/helpers' | 17 | import { immutableAssign } from '@app/helpers' |
14 | import { UserHistoryService } from '@app/shared/shared-main' | 18 | import { UserHistoryService, Video } from '@app/shared/shared-main' |
15 | import { AbstractVideoList } from '@app/shared/shared-video-miniature' | 19 | import { MiniatureDisplayOptions, VideosSelectionComponent } from '@app/shared/shared-video-miniature' |
16 | import { Subject } from 'rxjs' | ||
17 | import { debounceTime, tap, distinctUntilChanged } from 'rxjs/operators' | ||
18 | 20 | ||
19 | @Component({ | 21 | @Component({ |
20 | templateUrl: './my-history.component.html', | 22 | templateUrl: './my-history.component.html', |
21 | styleUrls: [ './my-history.component.scss' ] | 23 | styleUrls: [ './my-history.component.scss' ] |
22 | }) | 24 | }) |
23 | export class MyHistoryComponent extends AbstractVideoList implements OnInit, OnDestroy { | 25 | export class MyHistoryComponent implements OnInit, DisableForReuseHook { |
26 | @ViewChild('videosSelection', { static: true }) videosSelection: VideosSelectionComponent | ||
27 | |||
24 | titlePage: string | 28 | titlePage: string |
25 | pagination: ComponentPagination = { | 29 | pagination: ComponentPagination = { |
26 | currentPage: 1, | 30 | currentPage: 1, |
27 | itemsPerPage: 5, | 31 | itemsPerPage: 5, |
28 | totalItems: null | 32 | totalItems: null |
29 | } | 33 | } |
34 | |||
30 | videosHistoryEnabled: boolean | 35 | videosHistoryEnabled: boolean |
31 | search: string | ||
32 | 36 | ||
33 | protected searchStream: Subject<string> | 37 | miniatureDisplayOptions: MiniatureDisplayOptions = { |
38 | date: true, | ||
39 | views: true, | ||
40 | by: true, | ||
41 | privacyLabel: false, | ||
42 | privacyText: true, | ||
43 | state: true, | ||
44 | blacklistInfo: true | ||
45 | } | ||
46 | |||
47 | getVideosObservableFunction = this.getVideosObservable.bind(this) | ||
48 | |||
49 | user: User | ||
50 | |||
51 | videos: Video[] = [] | ||
52 | search: string | ||
34 | 53 | ||
35 | constructor ( | 54 | constructor ( |
36 | protected router: Router, | 55 | protected router: Router, |
@@ -45,45 +64,31 @@ export class MyHistoryComponent extends AbstractVideoList implements OnInit, OnD | |||
45 | private userHistoryService: UserHistoryService, | 64 | private userHistoryService: UserHistoryService, |
46 | protected cfr: ComponentFactoryResolver | 65 | protected cfr: ComponentFactoryResolver |
47 | ) { | 66 | ) { |
48 | super() | ||
49 | |||
50 | this.titlePage = $localize`My watch history` | 67 | this.titlePage = $localize`My watch history` |
51 | } | 68 | } |
52 | 69 | ||
53 | ngOnInit () { | 70 | ngOnInit () { |
54 | super.ngOnInit() | 71 | this.user = this.authService.getUser() |
55 | 72 | ||
56 | this.authService.userInformationLoaded | 73 | this.authService.userInformationLoaded |
57 | .subscribe(() => { | 74 | .subscribe(() => this.videosHistoryEnabled = this.user.videosHistoryEnabled) |
58 | this.videosHistoryEnabled = this.authService.getUser().videosHistoryEnabled | 75 | } |
59 | }) | ||
60 | |||
61 | this.searchStream = new Subject() | ||
62 | 76 | ||
63 | this.searchStream | 77 | disableForReuse () { |
64 | .pipe( | 78 | this.videosSelection.disableForReuse() |
65 | debounceTime(400), | ||
66 | distinctUntilChanged() | ||
67 | ) | ||
68 | .subscribe(search => { | ||
69 | this.search = search | ||
70 | this.reloadVideos() | ||
71 | }) | ||
72 | } | 79 | } |
73 | 80 | ||
74 | onSearch (event: Event) { | 81 | enabledForReuse () { |
75 | const target = event.target as HTMLInputElement | 82 | this.videosSelection.enabledForReuse() |
76 | this.searchStream.next(target.value) | ||
77 | } | 83 | } |
78 | 84 | ||
79 | resetSearch () { | 85 | reloadData () { |
80 | const searchInput = document.getElementById('history-search') as HTMLInputElement | 86 | this.videosSelection.reloadVideos() |
81 | searchInput.value = '' | ||
82 | this.searchStream.next('') | ||
83 | } | 87 | } |
84 | 88 | ||
85 | ngOnDestroy () { | 89 | onSearch (search: string) { |
86 | super.ngOnDestroy() | 90 | this.search = search |
91 | this.reloadData() | ||
87 | } | 92 | } |
88 | 93 | ||
89 | getVideosObservable (page: number) { | 94 | getVideosObservable (page: number) { |
@@ -129,7 +134,7 @@ export class MyHistoryComponent extends AbstractVideoList implements OnInit, OnD | |||
129 | () => { | 134 | () => { |
130 | this.notifier.success($localize`Videos history deleted`) | 135 | this.notifier.success($localize`Videos history deleted`) |
131 | 136 | ||
132 | this.reloadVideos() | 137 | this.reloadData() |
133 | }, | 138 | }, |
134 | 139 | ||
135 | err => this.notifier.error(err.message) | 140 | err => this.notifier.error(err.message) |