-
-
Notifications
You must be signed in to change notification settings - Fork 1.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
11 changed files
with
235 additions
and
15 deletions.
There are no files selected for viewing
91 changes: 91 additions & 0 deletions
91
client/src/app/+accounts/account-search/account-search.component.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,91 @@ | ||
import { Subscription } from 'rxjs' | ||
import { first, tap } from 'rxjs/operators' | ||
import { Component, OnDestroy, OnInit } from '@angular/core' | ||
import { ActivatedRoute, Router } from '@angular/router' | ||
import { AuthService, ConfirmService, LocalStorageService, Notifier, ScreenService, ServerService, UserService } from '@app/core' | ||
import { immutableAssign } from '@app/helpers' | ||
import { Account, AccountService, VideoService } from '@app/shared/shared-main' | ||
import { AbstractVideoList } from '@app/shared/shared-video-miniature' | ||
import { VideoFilter } from '@shared/models' | ||
|
||
@Component({ | ||
selector: 'my-account-search', | ||
templateUrl: '../../shared/shared-video-miniature/abstract-video-list.html', | ||
styleUrls: [ | ||
'../../shared/shared-video-miniature/abstract-video-list.scss' | ||
] | ||
}) | ||
export class AccountSearchComponent extends AbstractVideoList implements OnInit, OnDestroy { | ||
titlePage: string | ||
loadOnInit = false | ||
|
||
filter: VideoFilter = null | ||
|
||
private account: Account | ||
private accountSub: Subscription | ||
|
||
constructor ( | ||
protected router: Router, | ||
protected serverService: ServerService, | ||
protected route: ActivatedRoute, | ||
protected authService: AuthService, | ||
protected userService: UserService, | ||
protected notifier: Notifier, | ||
protected confirmService: ConfirmService, | ||
protected screenService: ScreenService, | ||
protected storageService: LocalStorageService, | ||
private accountService: AccountService, | ||
private videoService: VideoService | ||
) { | ||
super() | ||
} | ||
|
||
ngOnInit () { | ||
super.ngOnInit() | ||
|
||
this.enableAllFilterIfPossible() | ||
|
||
// Parent get the account for us | ||
this.accountSub = this.accountService.accountLoaded | ||
.pipe(first()) | ||
.subscribe(account => { | ||
this.account = account | ||
|
||
this.reloadVideos() | ||
this.generateSyndicationList() | ||
}) | ||
} | ||
|
||
ngOnDestroy () { | ||
if (this.accountSub) this.accountSub.unsubscribe() | ||
|
||
super.ngOnDestroy() | ||
} | ||
|
||
getVideosObservable (page: number) { | ||
const newPagination = immutableAssign(this.pagination, { currentPage: page }) | ||
const options = { | ||
account: this.account, | ||
videoPagination: newPagination, | ||
sort: this.sort, | ||
nsfwPolicy: this.nsfwPolicy, | ||
videoFilter: this.filter | ||
} | ||
|
||
return this.videoService | ||
.getAccountVideos(options) | ||
.pipe( | ||
tap(({ total }) => { | ||
this.titlePage = $localize`${total} results on this account for TODO` | ||
}) | ||
) | ||
} | ||
|
||
toggleModerationDisplay () { | ||
this.filter = this.buildLocalFilter(this.filter, null) | ||
|
||
this.reloadVideos() | ||
} | ||
|
||
generateSyndicationList () {} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
export * from './help.component' | ||
export * from './list-overflow.component' | ||
export * from './top-menu-dropdown.component' | ||
export * from './simple-search-input.component' |
13 changes: 13 additions & 0 deletions
13
client/src/app/shared/shared-main/misc/simple-search-input.component.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
<my-global-icon iconName="search" aria-label="Search" role="button" (click)="showInput()"></my-global-icon> | ||
|
||
<input | ||
#searchVideos | ||
name="search-videos" | ||
type="text" | ||
[(ngModel)]="search" | ||
(ngModelChange)="searchChange" | ||
i18n-placeholder placeholder="Search videos" | ||
(focusout)="focusLost()" | ||
(keyup.enter)="navigate()" | ||
[hidden]="!shown" | ||
> |
24 changes: 24 additions & 0 deletions
24
client/src/app/shared/shared-main/misc/simple-search-input.component.scss
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
@import '_variables'; | ||
@import '_mixins'; | ||
|
||
my-global-icon { | ||
height: 18px; | ||
position: relative; | ||
top: -2px; | ||
|
||
opacity: .6; | ||
color: pvar(--mainForegroundColor); | ||
} | ||
|
||
input { | ||
@include peertube-input-text(150px); | ||
|
||
height: 24px; // maximum height for the account/video-channels links | ||
padding-left: 10px; | ||
background-color: transparent; | ||
border: none; | ||
|
||
&::placeholder { | ||
font-size: 15px; | ||
} | ||
} |
58 changes: 58 additions & 0 deletions
58
client/src/app/shared/shared-main/misc/simple-search-input.component.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
import { Component, ElementRef, EventEmitter, Input, OnInit, Output, ViewChild } from '@angular/core' | ||
import { ActivatedRoute, Router } from '@angular/router' | ||
import { Subject } from 'rxjs' | ||
import { debounceTime, distinctUntilChanged } from 'rxjs/operators' | ||
|
||
@Component({ | ||
selector: 'simple-search-input', | ||
templateUrl: './simple-search-input.component.html', | ||
styleUrls: [ './simple-search-input.component.scss' ] | ||
}) | ||
export class SimpleSearchInputComponent implements OnInit { | ||
@ViewChild("searchVideos") input: ElementRef | ||
|
||
@Input() enter: string | ||
|
||
@Output() searchChanged = new EventEmitter<string>() | ||
|
||
search = '' | ||
shown: boolean | ||
|
||
private searchSubject= new Subject<string>() | ||
|
||
constructor ( | ||
private router: Router, | ||
private route: ActivatedRoute | ||
) {} | ||
|
||
ngOnInit () { | ||
this.searchSubject | ||
.pipe( | ||
debounceTime(400), | ||
distinctUntilChanged() | ||
) | ||
.subscribe(value => this.searchChanged.emit(value)) | ||
|
||
this.searchSubject.next(this.search) | ||
} | ||
|
||
showInput () { | ||
this.shown = true | ||
setTimeout(()=> { | ||
this.input.nativeElement.focus() | ||
}) | ||
} | ||
|
||
focusLost () { | ||
if (this.search !== '') return | ||
this.shown = false | ||
} | ||
|
||
searchChange () { | ||
this.searchChanged.emit(this.search) | ||
} | ||
|
||
navigate () { | ||
this.router.navigate(['./search'], { relativeTo: this.route }) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -656,6 +656,11 @@ | |
font-size: 130%; | ||
} | ||
} | ||
|
||
list-overflow { | ||
display: inline-block; | ||
width: max-content; | ||
} | ||
} | ||
} | ||
|
||
|