Added a switch to use the new search or not, just in case people do not like it.

added a migration to turn on the new search.
pull/1011/head
Jamie.Rees 8 years ago
parent 16c94f2414
commit b2417d8477

@ -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<List<SearchMovie>> SearchMovie(string searchTerm)
{
var results = await Client.SearchMovie(searchTerm);

@ -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<CustomizationSettings> custom)
{
Customization = custom;
}
public int Version => 22000;
private ISettingsService<CustomizationSettings> 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);
}
}
}

@ -69,6 +69,7 @@
<Compile Include="MigrationAttribute.cs" />
<Compile Include="MigrationRunner.cs" />
<Compile Include="Migrations\BaseMigration.cs" />
<Compile Include="Migrations\Version2200.cs" />
<Compile Include="Migrations\Version1100.cs" />
<Compile Include="Migrations\Version195.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />

@ -53,5 +53,7 @@ namespace Ombi.Core.SettingModels
public int DefaultLang { get; set; }
public bool NewSearch { get; set; }
}
}

@ -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;

@ -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; }
}
}

@ -77,7 +77,7 @@ namespace Ombi.UI.Modules
ISettingsService<PlexSettings> plexService, ISettingsService<AuthenticationSettings> auth,
IRepository<UsersToNotify> u, ISettingsService<EmailNotificationSettings> email,
IIssueService issue, IAnalytics a, IRepository<RequestLimit> rl, ITransientFaultQueue tfQueue, IRepository<PlexContent> content,
ISecurityExtensions security, IMovieSender movieSender, IRadarrCacher radarrCacher, ITraktApi traktApi)
ISecurityExtensions security, IMovieSender movieSender, IRadarrCacher radarrCacher, ITraktApi traktApi, ISettingsService<CustomizationSettings> 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<RequestLimit> RequestLimitRepo { get; }
private IRadarrCacher RadarrCacher { get; }
private ISettingsService<CustomizationSettings> CustomizationSettings { get; }
private static Logger Log = LogManager.GetCurrentClassLogger();
private async Task<Negotiator> 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<Response> UpcomingMovies()

@ -252,6 +252,7 @@
<Compile Include="Models\Requests\RequestsIndexViewModel.cs" />
<Compile Include="Models\RootFolderModel.cs" />
<Compile Include="Models\ScheduledJobsViewModel.cs" />
<Compile Include="Models\SearchLoadViewModel.cs" />
<Compile Include="Models\SearchViewModel.cs" />
<Compile Include="Models\SearchMusicViewModel.cs" />
<Compile Include="Models\SearchMovieViewModel.cs" />

@ -40,6 +40,8 @@
</div>
</div>
@Html.Checkbox(Model.Settings.NewSearch, "NewSearch", "Use New Search")
<div class="form-group">
<label for="lang" class="control-label">Default Language</label>
<div id="langSelect">

@ -1,5 +1,6 @@
@using Ombi.UI.Helpers
@using Ombi.UI.Resources
@inherits Nancy.ViewEngines.Razor.NancyRazorViewBase<Ombi.UI.Models.SearchLoadViewModel>
@{
var baseUrl = Html.GetBaseUrl();
var url = string.Empty;
@ -9,6 +10,8 @@
}
}
<div>
<div hidden="hidden" id="useNewSearch">@Model.CustomizationSettings.NewSearch</div>
<h1 id="searchTitle">@UI.Search_Title</h1>
<h4>@UI.Search_Paragraph</h4>
<br />
@ -16,21 +19,21 @@
<ul id="nav-tabs" class="nav nav-tabs" role="tablist">
@if (Model.SearchForMovies)
@if (Model.Settings.SearchForMovies)
{
<li role="presentation" class="active">
<a id="movieTabButton" href="#MoviesTab" aria-controls="home" role="tab" data-toggle="tab"><i class="fa fa-film"></i> @UI.Search_Movies</a>
</li>
}
@if (Model.SearchForTvShows)
@if (Model.Settings.SearchForTvShows)
{
<li role="presentation">
<a id="tvTabButton" href="#TvShowTab" aria-controls="profile" role="tab" data-toggle="tab"><i class="fa fa-television"></i> @UI.Search_TvShows</a>
</li>
}
@if (Model.SearchForMusic)
@if (Model.Settings.SearchForMusic)
{
<li role="presentation">
<a href="#MusicTab" aria-controls="profile" role="tab" data-toggle="tab"><i class="fa fa-music"></i>@UI.Search_Albums</a>
@ -41,7 +44,7 @@
<!-- Tab panes -->
<div class="tab-content">
@if (Model.SearchForMovies)
@if (Model.Settings.SearchForMovies)
{
<!-- Movie tab -->
<div role="tabpanel" class="tab-pane active" id="MoviesTab">
@ -70,7 +73,7 @@
}
@if (Model.SearchForTvShows)
@if (Model.Settings.SearchForTvShows)
{
<!-- TV tab -->
<div role="tabpanel" class="tab-pane" id="TvShowTab">
@ -99,7 +102,7 @@
</div>
}
@if (Model.SearchForMusic)
@if (Model.Settings.SearchForMusic)
{
<!-- Music tab -->
<div role="tabpanel" class="tab-pane" id="MusicTab">
@ -118,7 +121,7 @@
}
<script id="search-template" type="text/x-handlebars-template">
<script id="search-templateNew" type="text/x-handlebars-template">
<div class="row">
<div id="{{id}}imgDiv" class="col-sm-2">
@ -153,40 +156,49 @@
<div class="row">
<div class="col-md-7 col-xs-7">
<div class="col-md-7 col-xs-7">
{{#if available}}
<span class="label label-success">@UI.Search_Available_on_plex</span>
{{else}}
{{#if approved}}
<span class="label label-info">@UI.Search_Processing_Request</span>
{{else if requested}}
<span class="label label-warning">@UI.Search_Pending_approval</span>
{{else}}
<span class="label label-danger">@UI.Search_Not_Requested_Yet</span>
{{/if}}
{{/if}}
{{#if firstAired}}
<span class="label label-info" target="_blank">Air Date: {{firstAired}}</span>
{{/if}}
{{#if available}}
<span class="label label-success">@UI.Search_Available_on_plex</span>
{{else}}
{{#if approved}}
<span class="label label-info">@UI.Search_Processing_Request</span>
{{else if requested}}
<span class="label label-warning">@UI.Search_Pending_approval</span>
{{else}}
<span class="label label-danger">@UI.Search_Not_Requested_Yet</span>
{{/if}}
{{/if}}
{{#if firstAired}}
<span class="label label-info" target="_blank">Air Date: {{firstAired}}</span>
{{/if}}
{{#if releaseDate}}
<span class="label label-info" target="_blank">Release Date: {{releaseDate}}</span>
{{/if}}
<span id="{{id}}netflixTab"></span>
<span id="{{id}}netflixTab"></span>
</div>
<!--Info Labels-->
<div class="col-md-5 col-xs-5" style="text-align:right;">
{{#if homepage}}
<a href="{{homepage}}" target="_blank"><span class="label label-info">HomePage</span></a>
{{/if}}
{{#if trailer}}
<a href="{{trailer}}" target="_blank"><span class="label label-info">Trailer</span></a>
{{/if}}
</div>
</div>
<!--Info Labels-->
<div class="col-md-5 col-xs-5" style="text-align:right;">
{{#if homepage}}
<a href="{{homepage}}" target="_blank"><span class="label label-info">HomePage</span></a>
{{/if}}
{{#if trailer}}
<a href="{{trailer}}" target="_blank"><span class="label label-info">Trailer</span></a>
{{/if}}
<div class="row">
<!-- Description -->
<p style="font-size:0.9rem !important">{{overview}}</p>
<br />
<br />
</div>
<!-- Description -->
<p style="font-size:0.9rem !important">{{overview}}</p>
<br />
<br />
<form method="POST" action="@url/search/request/{{type}}" id="form{{id}}">
<input name="{{type}}Id" type="text" value="{{id}}" hidden="hidden" />
@ -271,7 +283,7 @@
</script>
<!-- Movie and TV Results template -->
<script id="search-template2" type="text/x-handlebars-template">
<script id="search-template" type="text/x-handlebars-template">
<div class="row">
<div id="{{id}}imgDiv" class="col-sm-2">

Loading…
Cancel
Save