From 5941e962ecf9bdbac330f7ca731d9a3b54904a38 Mon Sep 17 00:00:00 2001 From: Jamie Rees Date: Mon, 2 Nov 2020 21:21:18 +0000 Subject: [PATCH 1/3] wip --- .../themoviedb/themoviedb.component.html | 22 +++++++++++++++++-- .../themoviedb/themoviedb.component.ts | 9 ++++++++ 2 files changed, 29 insertions(+), 2 deletions(-) diff --git a/src/Ombi/ClientApp/src/app/settings/themoviedb/themoviedb.component.html b/src/Ombi/ClientApp/src/app/settings/themoviedb/themoviedb.component.html index 9b325f299..85ffd4064 100644 --- a/src/Ombi/ClientApp/src/app/settings/themoviedb/themoviedb.component.html +++ b/src/Ombi/ClientApp/src/app/settings/themoviedb/themoviedb.component.html @@ -15,7 +15,7 @@ Excluded Keyword IDs for Movie Suggestions
- + + + + +
+ + + + + {{option.name}} + + + + +
+
+ + + + + {{option.name}} + + + -
- - - - - {{option.name}} - - - + + + {{key.name}} + cancel + + -
- -
+ + -
-
-
+
+
+ +
+
-
- + \ No newline at end of file diff --git a/src/Ombi/ClientApp/src/app/settings/themoviedb/themoviedb.component.ts b/src/Ombi/ClientApp/src/app/settings/themoviedb/themoviedb.component.ts index 892ff6755..228d4fc42 100644 --- a/src/Ombi/ClientApp/src/app/settings/themoviedb/themoviedb.component.ts +++ b/src/Ombi/ClientApp/src/app/settings/themoviedb/themoviedb.component.ts @@ -1,15 +1,13 @@ import {COMMA, ENTER} from "@angular/cdk/keycodes"; import { Component, OnInit, ElementRef, ViewChild } from "@angular/core"; -import { MatChipInputEvent } from "@angular/material/chips"; -import { MatAutocompleteSelectedEvent, MatAutocomplete } from "@angular/material/autocomplete"; -import { empty, of, Observable } from "rxjs"; +import { MatAutocomplete } from "@angular/material/autocomplete"; import { ITheMovieDbSettings, IMovieDbKeyword } from "../../interfaces"; import { NotificationService } from "../../services"; import { SettingsService } from "../../services"; import { TheMovieDbService } from "../../services"; -import { FormControl, FormBuilder, FormGroup } from "@angular/forms"; -import { startWith, map, debounceTime, tap, switchMap, finalize } from "rxjs/operators"; +import { FormBuilder, FormGroup } from "@angular/forms"; +import { debounceTime, switchMap } from "rxjs/operators"; interface IKeywordTag { id: number; @@ -28,9 +26,6 @@ export class TheMovieDbComponent implements OnInit { public tagForm: FormGroup; public filteredTags: IMovieDbKeyword[]; @ViewChild('fruitInput') public fruitInput: ElementRef; - @ViewChild('auto') public matAutocomplete: MatAutocomplete; - - private readonly separatorKeysCodes: number[] = [ENTER, COMMA]; constructor(private settingsService: SettingsService, private notificationService: NotificationService, @@ -50,6 +45,13 @@ export class TheMovieDbComponent implements OnInit { initial: true, })) : []; + this.excludedKeywords.forEach(key => { + this.tmdbService.getKeyword(key.id).subscribe(keyResult => { + this.excludedKeywords.filter((val, idx) => { + val.name = keyResult.name; + }) + }); + }); }); this.tagForm @@ -64,61 +66,8 @@ export class TheMovieDbComponent implements OnInit { ) .subscribe((r) => (this.filteredTags = r)); - // this.tagForm.controls.input.valueChanges - // .pipe( - // debounceTime(500), - // switchMap(value => this.tmdbService.getKeywords(value)) - // ) - // .subscribe((data: IMovieDbKeyword[]) => { - // this.filteredTags = data; - // }); - } - - public async selected(event: MatAutocompleteSelectedEvent) { - const keywordId = await this.tmdbService.getKeyword(+event.option.value).toPromise(); - this.excludedKeywords.push({ id: keywordId.id, name: keywordId.name, initial: false}); - this.fruitInput.nativeElement.value = ''; - this.tagForm.controls.input.setValue(null); - } - - public autocompleteKeyword = (text: string) => this.tmdbService.getKeywords(text); - - public onAddingKeyword = (tag: string | IKeywordTag) => { - if (typeof tag === "string") { - const id = Number(tag); - return isNaN(id) ? empty() : this.tmdbService.getKeyword(id); - } else { - return of(tag); - } - } - - public onKeywordSelect = (keyword: IKeywordTag) => { - if (keyword.initial) { - this.tmdbService.getKeyword(keyword.id) - .subscribe(k => { - keyword.name = k.name; - keyword.initial = false; - }); - } } - public async add(event: MatChipInputEvent) { - const input = event.input; - const value = event.value; - - // Add our fruit - if ((value || '').trim()) { - const keyword = await this.tmdbService.getKeywords(value).toPromise(); - this.excludedKeywords.push({ id: keyword[0].id, name: keyword[0].name, initial: false }); - } - - // Reset the input value - if (input) { - input.value = ''; - } - this.tagForm.controls.input.setValue(null); - } - public remove(tag: IKeywordTag): void { const index = this.excludedKeywords.indexOf(tag); From 3aa28a58e5f69f8967db9c99517094b5067aa944 Mon Sep 17 00:00:00 2001 From: Jamie Rees Date: Tue, 3 Nov 2020 08:20:26 +0000 Subject: [PATCH 3/3] Fixed unit tests --- .../Rule/Search/EmbyAvailabilityRuleTests.cs | 12 +++++++----- src/Ombi.Helpers/EmbyHelper.cs | 2 +- .../Context/Sqlite/SettingsSqliteContext.cs | 4 +++- 3 files changed, 11 insertions(+), 7 deletions(-) diff --git a/src/Ombi.Core.Tests/Rule/Search/EmbyAvailabilityRuleTests.cs b/src/Ombi.Core.Tests/Rule/Search/EmbyAvailabilityRuleTests.cs index becbeadc9..8e5c57d67 100644 --- a/src/Ombi.Core.Tests/Rule/Search/EmbyAvailabilityRuleTests.cs +++ b/src/Ombi.Core.Tests/Rule/Search/EmbyAvailabilityRuleTests.cs @@ -54,14 +54,15 @@ namespace Ombi.Core.Tests.Rule.Search { new EmbyServers { - ServerHostname = "http://test.com/" + ServerHostname = "http://test.com/", + ServerId = "8" } } }); ContextMock.Setup(x => x.GetByTheMovieDbId(It.IsAny())).ReturnsAsync(new EmbyContent { ProviderId = "123", - EmbyId = 1.ToString() + EmbyId = 1.ToString(), }); var search = new SearchMovieViewModel() { @@ -70,7 +71,7 @@ namespace Ombi.Core.Tests.Rule.Search var result = await Rule.Execute(search); Assert.True(result.Success); - Assert.That(search.EmbyUrl, Is.EqualTo("http://test.com/#!/item?id=1")); + Assert.That(search.EmbyUrl, Is.EqualTo("http://test.com/web/index.html#!/item?id=1&serverId=8")); } [Test] @@ -83,7 +84,8 @@ namespace Ombi.Core.Tests.Rule.Search { new EmbyServers { - ServerHostname = string.Empty + ServerHostname = string.Empty, + ServerId = "8" } } }); @@ -99,7 +101,7 @@ namespace Ombi.Core.Tests.Rule.Search var result = await Rule.Execute(search); Assert.True(result.Success); - Assert.That(search.EmbyUrl, Is.EqualTo("https://app.emby.media/#!/item?id=1")); + Assert.That(search.EmbyUrl, Is.EqualTo("https://app.emby.media/web/index.html#!/item?id=1&serverId=8")); } [Test] diff --git a/src/Ombi.Helpers/EmbyHelper.cs b/src/Ombi.Helpers/EmbyHelper.cs index 4d2bcfc57..785ca47d4 100644 --- a/src/Ombi.Helpers/EmbyHelper.cs +++ b/src/Ombi.Helpers/EmbyHelper.cs @@ -1,6 +1,6 @@ namespace Ombi.Helpers { - public class EmbyHelper + public static class EmbyHelper { public static string GetEmbyMediaUrl(string mediaId, string serverId, string customerServerUrl = null, bool isJellyfin = false) { diff --git a/src/Ombi.Store/Context/Sqlite/SettingsSqliteContext.cs b/src/Ombi.Store/Context/Sqlite/SettingsSqliteContext.cs index 4245ecb1e..9be3d84fb 100644 --- a/src/Ombi.Store/Context/Sqlite/SettingsSqliteContext.cs +++ b/src/Ombi.Store/Context/Sqlite/SettingsSqliteContext.cs @@ -23,7 +23,9 @@ namespace Ombi.Store.Context.Sqlite Database.ExecuteSqlRaw(@"INSERT OR IGNORE INTO __EFMigrationsHistory (MigrationId,ProductVersion) VALUES('20191103205204_Inital', '2.2.6-servicing-10079'); "); } - catch (Exception) +#pragma warning disable RCS1075 // Avoid empty catch clause that catches System.Exception. + catch (Exception) +#pragma warning restore RCS1075 // Avoid empty catch clause that catches System.Exception. { // ignored }