diff --git a/Ombi.Api/TheMovieDbApi.cs b/Ombi.Api/TheMovieDbApi.cs index cf9245b92..ad3f01251 100644 --- a/Ombi.Api/TheMovieDbApi.cs +++ b/Ombi.Api/TheMovieDbApi.cs @@ -28,6 +28,7 @@ using System; using System.Collections.Generic; using System.Threading.Tasks; +using NLog; using NLog.Fluent; using Ombi.Api.Models.Movie; using RestSharp; @@ -50,6 +51,7 @@ namespace Ombi.Api private ApiRequest Api { get; } public TMDbClient Client { get; set; } private const string BaseUrl = "https://api.themoviedb.org/3/"; + private static Logger Log = LogManager.GetCurrentClassLogger(); public async Task> SearchMovie(string searchTerm) { var results = await Client.SearchMovie(searchTerm); diff --git a/Ombi.Core.Migration/Migrations/Version2200.cs b/Ombi.Core.Migration/Migrations/Version2200.cs new file mode 100644 index 000000000..108a0aa27 --- /dev/null +++ b/Ombi.Core.Migration/Migrations/Version2200.cs @@ -0,0 +1,64 @@ +#region Copyright + +// /************************************************************************ +// Copyright (c) 2016 Jamie Rees +// File: Version1100.cs +// Created By: Jamie Rees +// +// Permission is hereby granted, free of charge, to any person obtaining +// a copy of this software and associated documentation files (the +// "Software"), to deal in the Software without restriction, including +// without limitation the rights to use, copy, modify, merge, publish, +// distribute, sublicense, and/or sell copies of the Software, and to +// permit persons to whom the Software is furnished to do so, subject to +// the following conditions: +// +// The above copyright notice and this permission notice shall be +// included in all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE +// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION +// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION +// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +// ************************************************************************/ + +#endregion + +using System.Data; +using NLog; +using Ombi.Core.SettingModels; + +namespace Ombi.Core.Migration.Migrations +{ + [Migration(22000, "v2.20.0.0")] + public class Version2200 : BaseMigration, IMigration + { + public Version2200(ISettingsService custom) + { + Customization = custom; + } + + public int Version => 22000; + private ISettingsService Customization { get; set; } + + + private static Logger Logger = LogManager.GetCurrentClassLogger(); + + public void Start(IDbConnection con) + { + UpdateCustomSettings(); + UpdateSchema(con, Version); + } + + private void UpdateCustomSettings() + { + var settings = Customization.GetSettings(); + settings.NewSearch = true; // Use the new search + + Customization.SaveSettings(settings); + } + } +} diff --git a/Ombi.Core.Migration/Ombi.Core.Migration.csproj b/Ombi.Core.Migration/Ombi.Core.Migration.csproj index 222f18fde..06dfda84d 100644 --- a/Ombi.Core.Migration/Ombi.Core.Migration.csproj +++ b/Ombi.Core.Migration/Ombi.Core.Migration.csproj @@ -69,6 +69,7 @@ + diff --git a/Ombi.Core/SettingModels/CustomizationSettings.cs b/Ombi.Core/SettingModels/CustomizationSettings.cs index 2fa664f35..d7aff1e51 100644 --- a/Ombi.Core/SettingModels/CustomizationSettings.cs +++ b/Ombi.Core/SettingModels/CustomizationSettings.cs @@ -53,5 +53,7 @@ namespace Ombi.Core.SettingModels public int DefaultLang { get; set; } + public bool NewSearch { get; set; } + } } \ No newline at end of file diff --git a/Ombi.UI/Content/search.js b/Ombi.UI/Content/search.js index b8f9f5504..cf31aba0f 100644 --- a/Ombi.UI/Content/search.js +++ b/Ombi.UI/Content/search.js @@ -24,7 +24,8 @@ Function.prototype.bind = function (parent) { $(function () { - var searchSource = $("#search-template").html(); + var useNewSearch = $('#useNewSearch').text() == 'True'; + var searchSource = useNewSearch ? $("#search-templateNew").html() : $("#search-template").html(); var seasonsSource = $("#seasons-template").html(); var musicSource = $("#music-template").html(); var seasonsNumberSource = $("#seasonNumber-template").html(); @@ -470,7 +471,10 @@ $(function () { requested: result.requested, approved: result.approved, available: result.available, - url: result.plexUrl + url: result.plexUrl, + trailer: result.trailer, + homepage: result.homepage, + releaseDate: Humanize(result.releaseDate) }; return context; diff --git a/Ombi.UI/Models/SearchLoadViewModel.cs b/Ombi.UI/Models/SearchLoadViewModel.cs new file mode 100644 index 000000000..2bdf5078c --- /dev/null +++ b/Ombi.UI/Models/SearchLoadViewModel.cs @@ -0,0 +1,37 @@ +#region Copyright +// /************************************************************************ +// Copyright (c) 2017 Jamie Rees +// File: SearchLoadViewModel.cs +// Created By: Jamie Rees +// +// Permission is hereby granted, free of charge, to any person obtaining +// a copy of this software and associated documentation files (the +// "Software"), to deal in the Software without restriction, including +// without limitation the rights to use, copy, modify, merge, publish, +// distribute, sublicense, and/or sell copies of the Software, and to +// permit persons to whom the Software is furnished to do so, subject to +// the following conditions: +// +// The above copyright notice and this permission notice shall be +// included in all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE +// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION +// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION +// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +// ************************************************************************/ +#endregion + +using Ombi.Core.SettingModels; + +namespace Ombi.UI.Models +{ + public class SearchLoadViewModel + { + public PlexRequestSettings Settings { get; set; } + public CustomizationSettings CustomizationSettings { get; set; } + } +} \ No newline at end of file diff --git a/Ombi.UI/Modules/SearchModule.cs b/Ombi.UI/Modules/SearchModule.cs index 36bc608d7..5af2d49fa 100644 --- a/Ombi.UI/Modules/SearchModule.cs +++ b/Ombi.UI/Modules/SearchModule.cs @@ -77,7 +77,7 @@ namespace Ombi.UI.Modules ISettingsService plexService, ISettingsService auth, IRepository u, ISettingsService email, IIssueService issue, IAnalytics a, IRepository rl, ITransientFaultQueue tfQueue, IRepository content, - ISecurityExtensions security, IMovieSender movieSender, IRadarrCacher radarrCacher, ITraktApi traktApi) + ISecurityExtensions security, IMovieSender movieSender, IRadarrCacher radarrCacher, ITraktApi traktApi, ISettingsService cus) : base("search", prSettings, security) { Auth = auth; @@ -111,6 +111,7 @@ namespace Ombi.UI.Modules WatcherCacher = watcherCacher; RadarrCacher = radarrCacher; TraktApi = traktApi; + CustomizationSettings = cus; Get["SearchIndex", "/", true] = async (x, ct) => await RequestLoad(); @@ -169,14 +170,22 @@ namespace Ombi.UI.Modules private ITransientFaultQueue FaultQueue { get; } private IRepository RequestLimitRepo { get; } private IRadarrCacher RadarrCacher { get; } + private ISettingsService CustomizationSettings { get; } private static Logger Log = LogManager.GetCurrentClassLogger(); private async Task RequestLoad() { var settings = await PrService.GetSettingsAsync(); + var custom = await CustomizationSettings.GetSettingsAsync(); + var searchViewModel = new SearchLoadViewModel + { + Settings = settings, + CustomizationSettings = custom + }; + - return View["Search/Index", settings]; + return View["Search/Index", searchViewModel]; } private async Task UpcomingMovies() diff --git a/Ombi.UI/Ombi.UI.csproj b/Ombi.UI/Ombi.UI.csproj index 32f4b17a3..24fa57f52 100644 --- a/Ombi.UI/Ombi.UI.csproj +++ b/Ombi.UI/Ombi.UI.csproj @@ -252,6 +252,7 @@ + diff --git a/Ombi.UI/Views/Customization/Customization.cshtml b/Ombi.UI/Views/Customization/Customization.cshtml index ff2e7a296..d7b44f2fa 100644 --- a/Ombi.UI/Views/Customization/Customization.cshtml +++ b/Ombi.UI/Views/Customization/Customization.cshtml @@ -40,6 +40,8 @@ + @Html.Checkbox(Model.Settings.NewSearch, "NewSearch", "Use New Search") +
diff --git a/Ombi.UI/Views/Search/Index.cshtml b/Ombi.UI/Views/Search/Index.cshtml index 0c5b90930..d1190ddb1 100644 --- a/Ombi.UI/Views/Search/Index.cshtml +++ b/Ombi.UI/Views/Search/Index.cshtml @@ -1,5 +1,6 @@ @using Ombi.UI.Helpers @using Ombi.UI.Resources +@inherits Nancy.ViewEngines.Razor.NancyRazorViewBase @{ var baseUrl = Html.GetBaseUrl(); var url = string.Empty; @@ -9,6 +10,8 @@ } }
+ +

@UI.Search_Title

@UI.Search_Paragraph


@@ -16,21 +19,21 @@