mirror of https://github.com/Ombi-app/Ombi
parent
33cefe1a62
commit
b38cfbc091
@ -0,0 +1,15 @@
|
||||
<mat-form-field class="quater-width">
|
||||
<input [(ngModel)]="searchText" (keyup)="search($event)" matInput [matAutocomplete]="auto">
|
||||
<mat-autocomplete #auto="matAutocomplete">
|
||||
<mat-option *ngFor="let option of searchResult" [value]="option">
|
||||
<img src="https://image.tmdb.org/t/p/w92/{{option.poster_path}}" class="autocomplete-img" aria-hidden/>
|
||||
<span *ngIf="option.media_type == 'tv'">
|
||||
{{option.name}}
|
||||
</span>
|
||||
<span *ngIf="option.media_type == 'movie'">
|
||||
{{option.title}}
|
||||
</span>
|
||||
</mat-option>
|
||||
</mat-autocomplete>
|
||||
</mat-form-field>
|
||||
</mat-toolbar>
|
@ -0,0 +1,14 @@
|
||||
.quater-width {
|
||||
width: 25%;
|
||||
}
|
||||
|
||||
.autocomplete-img {
|
||||
vertical-align: middle;
|
||||
height: 63px;
|
||||
}
|
||||
|
||||
.mat-option {
|
||||
height: 50px;
|
||||
line-height: 50px;
|
||||
padding: 0px 5px;
|
||||
}
|
@ -0,0 +1,34 @@
|
||||
import { Component, Input } from '@angular/core';
|
||||
import { BreakpointObserver, Breakpoints } from '@angular/cdk/layout';
|
||||
import { Observable, Subject } from 'rxjs';
|
||||
import { map, debounceTime, distinctUntilChanged } from 'rxjs/operators';
|
||||
|
||||
import { SearchV2Service } from '../services/searchV2.service';
|
||||
import { IMultiSearchResult } from '../interfaces';
|
||||
|
||||
@Component({
|
||||
selector: 'app-nav-search',
|
||||
templateUrl: './nav-search.component.html',
|
||||
styleUrls: ['./nav-search.component.scss']
|
||||
})
|
||||
export class NavSearchComponent {
|
||||
|
||||
public searchChanged: Subject<string> = new Subject<string>();
|
||||
public searchText: string;
|
||||
public searchResult: IMultiSearchResult[];
|
||||
public option: IMultiSearchResult;
|
||||
|
||||
constructor(private searchService: SearchV2Service) {
|
||||
this.searchChanged.pipe(
|
||||
debounceTime(600), // Wait Xms after the last event before emitting last event
|
||||
distinctUntilChanged(), // only emit if value is different from previous value
|
||||
).subscribe(x => {
|
||||
this.searchText = x as string;
|
||||
this.searchService.multiSearch(this.searchText).subscribe(x => this.searchResult = x)
|
||||
});
|
||||
}
|
||||
|
||||
public search(text: any) {
|
||||
this.searchChanged.next(text.target.value);
|
||||
}
|
||||
}
|
Loading…
Reference in new issue