From b38cfbc091e2c9f44e8cea7e46ffa8f39dad5817 Mon Sep 17 00:00:00 2001 From: tidusjar Date: Sat, 26 Jan 2019 13:26:43 +0000 Subject: [PATCH] tidy-up to the nav search !wip --- src/Ombi.TheMovieDbApi/Models/TvInfo.cs | 14 +++++++- src/Ombi.TheMovieDbApi/TheMovieDbApi.cs | 1 + src/Ombi/ClientApp/src/app/app.module.ts | 3 +- .../src/app/my-nav/my-nav.component.html | 25 ++++++-------- .../src/app/my-nav/my-nav.component.ts | 21 +----------- .../src/app/my-nav/nav-search.component.html | 15 ++++++++ .../src/app/my-nav/nav-search.component.scss | 14 ++++++++ .../src/app/my-nav/nav-search.component.ts | 34 +++++++++++++++++++ 8 files changed, 90 insertions(+), 37 deletions(-) create mode 100644 src/Ombi/ClientApp/src/app/my-nav/nav-search.component.html create mode 100644 src/Ombi/ClientApp/src/app/my-nav/nav-search.component.scss create mode 100644 src/Ombi/ClientApp/src/app/my-nav/nav-search.component.ts diff --git a/src/Ombi.TheMovieDbApi/Models/TvInfo.cs b/src/Ombi.TheMovieDbApi/Models/TvInfo.cs index 5692fcc17..f1070d658 100644 --- a/src/Ombi.TheMovieDbApi/Models/TvInfo.cs +++ b/src/Ombi.TheMovieDbApi/Models/TvInfo.cs @@ -1,4 +1,6 @@ -namespace Ombi.Api.TheMovieDb.Models +using Newtonsoft.Json; + +namespace Ombi.Api.TheMovieDb.Models { public class TvInfo { @@ -28,6 +30,7 @@ public string type { get; set; } public float vote_average { get; set; } public int vote_count { get; set; } + [JsonProperty("external_ids")] public TvExternalIds TvExternalIds { get; set; } } public class Created_By @@ -71,4 +74,13 @@ public int season_number { get; set; } } + public class TvExternalIds + { + [JsonProperty("imdb_id")] public string ImdbId { get; set; } + [JsonProperty("tvdb_id")] public string TvDbId { get; set; } + [JsonProperty("tvrage_id")] public string TvRageId { get; set; } + [JsonProperty("facebook_id")] public string FacebookId { get; set; } + [JsonProperty("instagram_id")] public string InstagramId { get; set; } + [JsonProperty("twitter_id")] public string TwitterHandle { get; set; } + } } \ No newline at end of file diff --git a/src/Ombi.TheMovieDbApi/TheMovieDbApi.cs b/src/Ombi.TheMovieDbApi/TheMovieDbApi.cs index 06711ba5f..32142507b 100644 --- a/src/Ombi.TheMovieDbApi/TheMovieDbApi.cs +++ b/src/Ombi.TheMovieDbApi/TheMovieDbApi.cs @@ -167,6 +167,7 @@ namespace Ombi.Api.TheMovieDb { var request = new Request($"/tv/{themoviedbid}", BaseUri, HttpMethod.Get); request.FullUri = request.FullUri.AddQueryParameter("api_key", ApiToken); + request.FullUri = request.FullUri.AddQueryParameter("append_to_response", "external_ids"); AddRetry(request); return await Api.Request(request); diff --git a/src/Ombi/ClientApp/src/app/app.module.ts b/src/Ombi/ClientApp/src/app/app.module.ts index 42b8e01e5..740c5dbac 100644 --- a/src/Ombi/ClientApp/src/app/app.module.ts +++ b/src/Ombi/ClientApp/src/app/app.module.ts @@ -47,6 +47,7 @@ import { IssuesService, JobService, PlexTvService, StatusService, SearchService, import { MyNavComponent } from './my-nav/my-nav.component'; import { LayoutModule } from '@angular/cdk/layout'; import { SearchV2Service } from "./services/searchV2.service"; +import { NavSearchComponent } from "./my-nav/nav-search.component"; const routes: Routes = [ { path: "*", component: PageNotFoundComponent }, @@ -143,7 +144,7 @@ export function JwtTokenGetter() { CookieComponent, LoginOAuthComponent, MyNavComponent, - + NavSearchComponent, ], providers: [ NotificationService, diff --git a/src/Ombi/ClientApp/src/app/my-nav/my-nav.component.html b/src/Ombi/ClientApp/src/app/my-nav/my-nav.component.html index 79e3ef0d0..204cb7105 100644 --- a/src/Ombi/ClientApp/src/app/my-nav/my-nav.component.html +++ b/src/Ombi/ClientApp/src/app/my-nav/my-nav.component.html @@ -16,24 +16,19 @@ - - - - - - - {{option.name}} - - - {{option.title}} - - - - + + + + + + - + +
+ + \ No newline at end of file diff --git a/src/Ombi/ClientApp/src/app/my-nav/my-nav.component.ts b/src/Ombi/ClientApp/src/app/my-nav/my-nav.component.ts index ca7929dad..9e22ed3d9 100644 --- a/src/Ombi/ClientApp/src/app/my-nav/my-nav.component.ts +++ b/src/Ombi/ClientApp/src/app/my-nav/my-nav.component.ts @@ -3,8 +3,6 @@ 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-my-nav', @@ -19,24 +17,7 @@ export class MyNavComponent { ); @Input() public showNav: boolean; - public searchChanged: Subject = new Subject(); - public searchText: string; - public searchResult: IMultiSearchResult[]; - public option: IMultiSearchResult; - constructor(private breakpointObserver: BreakpointObserver, - 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) - }); + constructor(private breakpointObserver: BreakpointObserver) { } - - public search(text: any) { - this.searchChanged.next(text.target.value); - } - } diff --git a/src/Ombi/ClientApp/src/app/my-nav/nav-search.component.html b/src/Ombi/ClientApp/src/app/my-nav/nav-search.component.html new file mode 100644 index 000000000..43028b94a --- /dev/null +++ b/src/Ombi/ClientApp/src/app/my-nav/nav-search.component.html @@ -0,0 +1,15 @@ + + + + + + + {{option.name}} + + + {{option.title}} + + + + + \ No newline at end of file diff --git a/src/Ombi/ClientApp/src/app/my-nav/nav-search.component.scss b/src/Ombi/ClientApp/src/app/my-nav/nav-search.component.scss new file mode 100644 index 000000000..7e650240c --- /dev/null +++ b/src/Ombi/ClientApp/src/app/my-nav/nav-search.component.scss @@ -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; +} \ No newline at end of file diff --git a/src/Ombi/ClientApp/src/app/my-nav/nav-search.component.ts b/src/Ombi/ClientApp/src/app/my-nav/nav-search.component.ts new file mode 100644 index 000000000..61342e3c0 --- /dev/null +++ b/src/Ombi/ClientApp/src/app/my-nav/nav-search.component.ts @@ -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 = new Subject(); + 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); + } +}