Add existing now does is reall time TvDb lookup

pull/3113/head
Keivan 14 years ago
parent 0556c31846
commit e33f5206fa

@ -37,17 +37,16 @@ namespace NzbDrone.Core
_startupPath = AppPath;
//Sqlite
string connectionString = String.Format("Data Source={0};Version=3;", Path.Combine(AppPath, "nzbdrone.db"));
var dbProvider = ProviderFactory.GetProvider(connectionString, "System.Data.SQLite");
var AppDataPath = new DirectoryInfo(Path.Combine(AppPath, "App_Data", "nzbdrone.db"));
if (!AppDataPath.Exists) AppDataPath.Create();
//SQLExpress
//string connectionString = String.Format(@"server=.\SQLExpress; database=NzbDrone; Trusted_Connection=True;");
//var dbProvider = ProviderFactory.GetProvider(connectionString, "System.Data.SqlClient");
string connectionString = String.Format("Data Source={0};Version=3;", Path.Combine(AppDataPath.FullName, "nzbdrone.db"));
var dbProvider = ProviderFactory.GetProvider(connectionString, "System.Data.SQLite");
//Sqlite
string logConnectionString = String.Format("Data Source={0};Version=3;", Path.Combine(AppPath, "log.db"));
string logConnectionString = String.Format("Data Source={0};Version=3;", Path.Combine(AppDataPath.FullName, "log.db"));
var logDbProvider = ProviderFactory.GetProvider(logConnectionString, "System.Data.SQLite");
//SQLExpress
//string logConnectionString = String.Format(@"server=.\SQLExpress; database=NzbDroneLogs; Trusted_Connection=True;");
//var logDbProvider = ProviderFactory.GetProvider(logConnectionString, "System.Data.SqlClient");
@ -55,7 +54,7 @@ namespace NzbDrone.Core
//dbProvider.ExecuteQuery(new QueryCommand("VACUUM", dbProvider));
dbProvider.Log = new NlogWriter();
_kernel.Bind<ISeriesProvider>().To<SeriesProvider>().InSingletonScope();
_kernel.Bind<ISeasonProvider>().To<SeasonProvider>();
_kernel.Bind<IEpisodeProvider>().To<EpisodeProvider>();

@ -31,7 +31,7 @@
<BootstrapperEnabled>true</BootstrapperEnabled>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|x86' ">
<PlatformTarget>AnyCPU</PlatformTarget>
<PlatformTarget>x86</PlatformTarget>
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>

@ -1,24 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
Note: Add entries to the App.config file for configuration settings
that apply only to the Test project.
-->
<configuration>
<appSettings>
<add key="ClientSettingsProvider.ServiceUri" value="" />
</appSettings>
<connectionStrings>
</connectionStrings>
<system.web>
<membership defaultProvider="ClientAuthenticationMembershipProvider">
<providers>
<add name="ClientAuthenticationMembershipProvider" type="System.Web.ClientServices.Providers.ClientFormsAuthenticationMembershipProvider, System.Web.Extensions, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" serviceUri="" />
</providers>
</membership>
<roleManager defaultProvider="ClientRoleProvider" enabled="true">
<providers>
<add name="ClientRoleProvider" type="System.Web.ClientServices.Providers.ClientRoleProvider, System.Web.Extensions, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" serviceUri="" cacheTimeout="86400" />
</providers>
</roleManager>
</system.web>
</configuration>

@ -1,402 +0,0 @@
using System;
using System.Security.Principal;
using System.Web;
using System.Web.Mvc;
using System.Web.Routing;
using System.Web.Security;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using NzbDrone.Web;
using NzbDrone.Web.Controllers;
using NzbDrone.Web.Models;
namespace NzbDrone.Web.Tests.Controllers
{
[TestClass]
public class AccountControllerTest
{
[TestMethod]
public void ChangePassword_Get_ReturnsView()
{
// Arrange
AccountController controller = GetAccountController();
// Act
ActionResult result = controller.ChangePassword();
// Assert
Assert.IsInstanceOfType(result, typeof(ViewResult));
Assert.AreEqual(10, ((ViewResult)result).ViewData["PasswordLength"]);
}
[TestMethod]
public void ChangePassword_Post_ReturnsRedirectOnSuccess()
{
// Arrange
AccountController controller = GetAccountController();
ChangePasswordModel model = new ChangePasswordModel()
{
OldPassword = "goodOldPassword",
NewPassword = "goodNewPassword",
ConfirmPassword = "goodNewPassword"
};
// Act
ActionResult result = controller.ChangePassword(model);
// Assert
Assert.IsInstanceOfType(result, typeof(RedirectToRouteResult));
RedirectToRouteResult redirectResult = (RedirectToRouteResult)result;
Assert.AreEqual("ChangePasswordSuccess", redirectResult.RouteValues["action"]);
}
[TestMethod]
public void ChangePassword_Post_ReturnsViewIfChangePasswordFails()
{
// Arrange
AccountController controller = GetAccountController();
ChangePasswordModel model = new ChangePasswordModel()
{
OldPassword = "goodOldPassword",
NewPassword = "badNewPassword",
ConfirmPassword = "badNewPassword"
};
// Act
ActionResult result = controller.ChangePassword(model);
// Assert
Assert.IsInstanceOfType(result, typeof(ViewResult));
ViewResult viewResult = (ViewResult)result;
Assert.AreEqual(model, viewResult.ViewData.Model);
Assert.AreEqual("The current password is incorrect or the new password is invalid.", controller.ModelState[""].Errors[0].ErrorMessage);
Assert.AreEqual(10, viewResult.ViewData["PasswordLength"]);
}
[TestMethod]
public void ChangePassword_Post_ReturnsViewIfModelStateIsInvalid()
{
// Arrange
AccountController controller = GetAccountController();
ChangePasswordModel model = new ChangePasswordModel()
{
OldPassword = "goodOldPassword",
NewPassword = "goodNewPassword",
ConfirmPassword = "goodNewPassword"
};
controller.ModelState.AddModelError("", "Dummy error message.");
// Act
ActionResult result = controller.ChangePassword(model);
// Assert
Assert.IsInstanceOfType(result, typeof(ViewResult));
ViewResult viewResult = (ViewResult)result;
Assert.AreEqual(model, viewResult.ViewData.Model);
Assert.AreEqual(10, viewResult.ViewData["PasswordLength"]);
}
[TestMethod]
public void ChangePasswordSuccess_ReturnsView()
{
// Arrange
AccountController controller = GetAccountController();
// Act
ActionResult result = controller.ChangePasswordSuccess();
// Assert
Assert.IsInstanceOfType(result, typeof(ViewResult));
}
[TestMethod]
public void LogOff_LogsOutAndRedirects()
{
// Arrange
AccountController controller = GetAccountController();
// Act
ActionResult result = controller.LogOff();
// Assert
Assert.IsInstanceOfType(result, typeof(RedirectToRouteResult));
RedirectToRouteResult redirectResult = (RedirectToRouteResult)result;
Assert.AreEqual("Home", redirectResult.RouteValues["controller"]);
Assert.AreEqual("Index", redirectResult.RouteValues["action"]);
Assert.IsTrue(((MockFormsAuthenticationService)controller.FormsService).SignOut_WasCalled);
}
[TestMethod]
public void LogOn_Get_ReturnsView()
{
// Arrange
AccountController controller = GetAccountController();
// Act
ActionResult result = controller.LogOn();
// Assert
Assert.IsInstanceOfType(result, typeof(ViewResult));
}
[TestMethod]
public void LogOn_Post_ReturnsRedirectOnSuccess_WithoutReturnUrl()
{
// Arrange
AccountController controller = GetAccountController();
LogOnModel model = new LogOnModel()
{
UserName = "someUser",
Password = "goodPassword",
RememberMe = false
};
// Act
ActionResult result = controller.LogOn(model, null);
// Assert
Assert.IsInstanceOfType(result, typeof(RedirectToRouteResult));
RedirectToRouteResult redirectResult = (RedirectToRouteResult)result;
Assert.AreEqual("Home", redirectResult.RouteValues["controller"]);
Assert.AreEqual("Index", redirectResult.RouteValues["action"]);
Assert.IsTrue(((MockFormsAuthenticationService)controller.FormsService).SignIn_WasCalled);
}
[TestMethod]
public void LogOn_Post_ReturnsRedirectOnSuccess_WithReturnUrl()
{
// Arrange
AccountController controller = GetAccountController();
LogOnModel model = new LogOnModel()
{
UserName = "someUser",
Password = "goodPassword",
RememberMe = false
};
// Act
ActionResult result = controller.LogOn(model, "/someUrl");
// Assert
Assert.IsInstanceOfType(result, typeof(RedirectResult));
RedirectResult redirectResult = (RedirectResult)result;
Assert.AreEqual("/someUrl", redirectResult.Url);
Assert.IsTrue(((MockFormsAuthenticationService)controller.FormsService).SignIn_WasCalled);
}
[TestMethod]
public void LogOn_Post_ReturnsViewIfModelStateIsInvalid()
{
// Arrange
AccountController controller = GetAccountController();
LogOnModel model = new LogOnModel()
{
UserName = "someUser",
Password = "goodPassword",
RememberMe = false
};
controller.ModelState.AddModelError("", "Dummy error message.");
// Act
ActionResult result = controller.LogOn(model, null);
// Assert
Assert.IsInstanceOfType(result, typeof(ViewResult));
ViewResult viewResult = (ViewResult)result;
Assert.AreEqual(model, viewResult.ViewData.Model);
}
[TestMethod]
public void LogOn_Post_ReturnsViewIfValidateUserFails()
{
// Arrange
AccountController controller = GetAccountController();
LogOnModel model = new LogOnModel()
{
UserName = "someUser",
Password = "badPassword",
RememberMe = false
};
// Act
ActionResult result = controller.LogOn(model, null);
// Assert
Assert.IsInstanceOfType(result, typeof(ViewResult));
ViewResult viewResult = (ViewResult)result;
Assert.AreEqual(model, viewResult.ViewData.Model);
Assert.AreEqual("The user name or password provided is incorrect.", controller.ModelState[""].Errors[0].ErrorMessage);
}
[TestMethod]
public void Register_Get_ReturnsView()
{
// Arrange
AccountController controller = GetAccountController();
// Act
ActionResult result = controller.Register();
// Assert
Assert.IsInstanceOfType(result, typeof(ViewResult));
Assert.AreEqual(10, ((ViewResult)result).ViewData["PasswordLength"]);
}
[TestMethod]
public void Register_Post_ReturnsRedirectOnSuccess()
{
// Arrange
AccountController controller = GetAccountController();
RegisterModel model = new RegisterModel()
{
UserName = "someUser",
Email = "goodEmail",
Password = "goodPassword",
ConfirmPassword = "goodPassword"
};
// Act
ActionResult result = controller.Register(model);
// Assert
Assert.IsInstanceOfType(result, typeof(RedirectToRouteResult));
RedirectToRouteResult redirectResult = (RedirectToRouteResult)result;
Assert.AreEqual("Home", redirectResult.RouteValues["controller"]);
Assert.AreEqual("Index", redirectResult.RouteValues["action"]);
}
[TestMethod]
public void Register_Post_ReturnsViewIfRegistrationFails()
{
// Arrange
AccountController controller = GetAccountController();
RegisterModel model = new RegisterModel()
{
UserName = "duplicateUser",
Email = "goodEmail",
Password = "goodPassword",
ConfirmPassword = "goodPassword"
};
// Act
ActionResult result = controller.Register(model);
// Assert
Assert.IsInstanceOfType(result, typeof(ViewResult));
ViewResult viewResult = (ViewResult)result;
Assert.AreEqual(model, viewResult.ViewData.Model);
Assert.AreEqual("Username already exists. Please enter a different user name.", controller.ModelState[""].Errors[0].ErrorMessage);
Assert.AreEqual(10, viewResult.ViewData["PasswordLength"]);
}
[TestMethod]
public void Register_Post_ReturnsViewIfModelStateIsInvalid()
{
// Arrange
AccountController controller = GetAccountController();
RegisterModel model = new RegisterModel()
{
UserName = "someUser",
Email = "goodEmail",
Password = "goodPassword",
ConfirmPassword = "goodPassword"
};
controller.ModelState.AddModelError("", "Dummy error message.");
// Act
ActionResult result = controller.Register(model);
// Assert
Assert.IsInstanceOfType(result, typeof(ViewResult));
ViewResult viewResult = (ViewResult)result;
Assert.AreEqual(model, viewResult.ViewData.Model);
Assert.AreEqual(10, viewResult.ViewData["PasswordLength"]);
}
private static AccountController GetAccountController()
{
AccountController controller = new AccountController()
{
FormsService = new MockFormsAuthenticationService(),
MembershipService = new MockMembershipService()
};
controller.ControllerContext = new ControllerContext()
{
Controller = controller,
RequestContext = new RequestContext(new MockHttpContext(), new RouteData())
};
return controller;
}
private class MockFormsAuthenticationService : IFormsAuthenticationService
{
public bool SignIn_WasCalled;
public bool SignOut_WasCalled;
public void SignIn(string userName, bool createPersistentCookie)
{
// verify that the arguments are what we expected
Assert.AreEqual("someUser", userName);
Assert.IsFalse(createPersistentCookie);
SignIn_WasCalled = true;
}
public void SignOut()
{
SignOut_WasCalled = true;
}
}
private class MockHttpContext : HttpContextBase
{
private readonly IPrincipal _user = new GenericPrincipal(new GenericIdentity("someUser"), null /* roles */);
public override IPrincipal User
{
get
{
return _user;
}
set
{
base.User = value;
}
}
}
private class MockMembershipService : IMembershipService
{
public int MinPasswordLength
{
get { return 10; }
}
public bool ValidateUser(string userName, string password)
{
return (userName == "someUser" && password == "goodPassword");
}
public MembershipCreateStatus CreateUser(string userName, string password, string email)
{
if (userName == "duplicateUser")
{
return MembershipCreateStatus.DuplicateUserName;
}
// verify that values are what we expected
Assert.AreEqual("goodPassword", password);
Assert.AreEqual("goodEmail", email);
return MembershipCreateStatus.Success;
}
public bool ChangePassword(string userName, string oldPassword, string newPassword)
{
return (userName == "someUser" && oldPassword == "goodOldPassword" && newPassword == "goodNewPassword");
}
}
}
}

@ -1,42 +0,0 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Web.Mvc;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using NzbDrone.Web;
using NzbDrone.Web.Controllers;
namespace NzbDrone.Web.Tests.Controllers
{
[TestClass]
public class HomeControllerTest
{
[TestMethod]
public void Index()
{
// Arrange
HomeController controller = new HomeController();
// Act
ViewResult result = controller.Index() as ViewResult;
// Assert
ViewDataDictionary viewData = result.ViewData;
Assert.AreEqual("Welcome to ASP.NET MVC!", viewData["Message"]);
}
[TestMethod]
public void About()
{
// Arrange
HomeController controller = new HomeController();
// Act
ViewResult result = controller.About() as ViewResult;
// Assert
Assert.IsNotNull(result);
}
}
}

@ -1,79 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProductVersion>
</ProductVersion>
<SchemaVersion>2.0</SchemaVersion>
<ProjectGuid>{99CDD5DC-698F-4624-B431-2D6381CE3A15}</ProjectGuid>
<OutputType>Library</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>NzbDrone.Web.Tests</RootNamespace>
<AssemblyName>NzbDrone.Web.Tests</AssemblyName>
<TargetFrameworkVersion>v4.0</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<ProjectTypeGuids>{3AC096D0-A1C2-E12C-1390-A8335801FDAB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<PlatformTarget>x86</PlatformTarget>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<ItemGroup>
<Reference Include="Microsoft.VisualStudio.QualityTools.UnitTestFramework, Version=10.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL" />
<Reference Include="System" />
<Reference Include="System.ComponentModel.DataAnnotations">
<RequiredTargetFramework>3.5</RequiredTargetFramework>
</Reference>
<Reference Include="System.Configuration" />
<Reference Include="System.Core">
<RequiredTargetFramework>3.5</RequiredTargetFramework>
</Reference>
<Reference Include="System.Data" />
<Reference Include="System.Web" />
<Reference Include="System.Web.ApplicationServices" />
<Reference Include="System.Web.Extensions">
<RequiredTargetFramework>3.5</RequiredTargetFramework>
</Reference>
<Reference Include="System.Web.Abstractions" />
<Reference Include="System.Web.Mvc, Version=2.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL" />
<Reference Include="System.Web.Routing" />
<Reference Include="System.Xml" />
</ItemGroup>
<ItemGroup>
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="Controllers\HomeControllerTest.cs" />
<Compile Include="Controllers\AccountControllerTest.cs" />
</ItemGroup>
<ItemGroup>
<Content Include="App.config" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\NzbDrone.Web\NzbDrone.Web.csproj">
<Project>{43BD3BBD-1531-4D8F-9C08-E1CD544AB2CD}</Project>
<Name>NzbDrone.Web</Name>
</ProjectReference>
</ItemGroup>
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets.
<Target Name="BeforeBuild">
</Target>
<Target Name="AfterBuild">
</Target>
-->
</Project>

@ -1,35 +0,0 @@
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
// General Information about an assembly is controlled through the following
// set of attributes. Change these attribute values to modify the information
// associated with an assembly.
[assembly: AssemblyTitle("NzbDrone.Web.Tests")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("Microsoft")]
[assembly: AssemblyProduct("NzbDrone.Web.Tests")]
[assembly: AssemblyCopyright("Copyright © Microsoft 2010")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]
// Setting ComVisible to false makes the types in this assembly not visible
// to COM components. If you need to access a type in this assembly from
// COM, set the ComVisible attribute to true on that type.
[assembly: ComVisible(false)]
// The following GUID is for the ID of the typelib if this project is exposed to COM
[assembly: Guid("c9fcd1a2-85d4-4224-863f-83afe37490d0")]
// Version information for an assembly consists of the following four values:
//
// Major Version
// Minor Version
// Build Number
// Revision
//
// You can specify all the values or you can default the Revision and Build Numbers
// by using the '*' as shown below:
[assembly: AssemblyVersion("1.0.0.0")]
[assembly: AssemblyFileVersion("1.0.0.0")]

@ -77,39 +77,18 @@ namespace NzbDrone.Web.Controllers
return View(unmappedList);
}
public ActionResult AddExistingManual(string path)
{
var profiles = _qualityProvider.GetAllProfiles();
var selectList = new SelectList(profiles, "QualityProfileId", "Name");
var defaultQuality = _configProvider.DefaultQualityProfile;
var model = new AddExistingManualModel();
model.Path = path;
model.FolderName = new DirectoryInfo(path).Name;
model.QualityProfileId = defaultQuality;
model.QualitySelectList = selectList;
return View(model);
}
public ActionResult RenderPartial(string path)
{
var dataVal = _tvDbProvider.SearchSeries(new DirectoryInfo(path).Name);
var names = dataVal.Select(tvdb => tvdb.SeriesName).ToList();
if (dataVal.Count == 0) return null;
var ids = dataVal.Select(tvdb => tvdb.Id).ToList();
var list = new SelectList(dataVal, "Id", "SeriesName");
var suggestions = GetSuggestionList(new DirectoryInfo(path).Name);
ViewData["guid"] = Guid.NewGuid();
ViewData["path"] = path;
ViewData["javaPath"] = path.Replace(Path.DirectorySeparatorChar, '|').Replace(Path.VolumeSeparatorChar, '^');
return PartialView("AddSeriesItem", list);
return PartialView("AddSeriesItem", suggestions);
}
public JsonResult AddSeries(string path, int seriesId, int qualityProfileId)
{
//Get TVDB Series Name
@ -121,5 +100,24 @@ namespace NzbDrone.Web.Controllers
return new JsonResult() { Data = "ok" };
}
[HttpPost]
public ActionResult _textLookUp(string text, int? filterMode)
{
var suggestions = GetSuggestionList(text);
return new JsonResult
{
JsonRequestBehavior = JsonRequestBehavior.AllowGet,
Data = suggestions
};
}
public SelectList GetSuggestionList(string searchString)
{
var dataVal = _tvDbProvider.SearchSeries(searchString);
return new SelectList(dataVal, "Id", "SeriesName");
}
}
}

@ -1,94 +0,0 @@
<%@ Page Title="" Language="C#" MasterPageFile="~/Views/Shared/Site.Master" Inherits="System.Web.Mvc.ViewPage<NzbDrone.Web.Models.AddExistingManualModel>" %>
<asp:Content ID="Content1" ContentPlaceHolderID="TitleContent" runat="server">
Add Series Manually
<script type="text/javascript">
jQuery(document).ready(function () {
$('#searchButton').click();
$('#searchButton').attr('disabled', '');
});
</script>
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="MainContent" runat="server">
<div>
<h4><%= Html.Label(Model.Path) %></h4>
</div>
<div style="width: 60%">
<div style="display:inline">
<%= Html.Label("Enter a Series Name") %>
<%= Html.TextBoxFor(m => m.FolderName, new { id="existing_series_id" }) %>
<%= Html.TextBoxFor(m => m.Path, new { id ="series_path", style="display:none" }) %>
</div>
<div style="display:inline; float:right;">
<%= Html.LabelFor(m => m.QualityProfileId)%>
<%: Html.DropDownListFor(m => m.QualityProfileId, Model.QualitySelectList)%>
</div>
</div>
<p>
<button class="t.button" id="searchButton" disabled="disabled" onclick="searchSeries ()">Search</button>
</p>
<div id="result"></div>
<div id="addSeriesControls" style="display:none">
<button class="t.button" onclick="addSeries ()">Add Series</button>
</div>
<div id="addResult"></div>
<script type="text/javascript" language="javascript">
$('#existing_series_id').bind('keydown', function (e) {
if (e.keyCode == 13) {
$('#searchButton').click();
}
});
function searchSeries() {
var seriesSearch = $('#existing_series_id');
$("#result").text("Searching..."); //Tell the user that we're performing the search
document.getElementById('addSeriesControls').style.display = 'none'; //Hide the add button
$("#result").load('<%=Url.Action("SearchForSeries", "Series") %>', {
seriesName: seriesSearch.val()
});
}
$(".searchRadio").live("change", function () {
var checked = $(this).attr('checked');
if (checked) {
document.getElementById('addSeriesControls').style.display = 'inline';
}
});
function addSeries() {
//Get the selected tvdbid + selected root folder
//jquery bit below doesn't want to work...
var checkedSeries = $("input[name='selectedSeries']:checked").val();
var id = "#" + checkedSeries + "_text";
var seriesName = $(id).val();
var qualityProfileId = $("#QualityProfileId").val();
var pathTest = $('#series_path').val();
$('#tester').text(pathTest);
$("#addResult").load('<%=Url.Action("AddExistingManual", "AddSeries") %>', {
path: pathTest,
seriesId: checkedSeries,
qualityProfileId: qualityProfileId
});
}
</script>
<div id="tester"></div>
</asp:Content>

@ -10,6 +10,8 @@
// .AutoFill(true)
.BindTo(Model)
// .DataBinding(b => b.Ajax().Select("TvDbLookup", "AddSeries"))
.DataBinding(binding => binding.Ajax().Select("_textLookUp", "AddSeries").Delay(400).Cache(false))
.Filterable(f => f.FilterMode(AutoCompleteFilterMode.Contains))
.HighlightFirstMatch(true)
.HtmlAttributes(new { style = "width:70%; align:right" })
@ -28,8 +30,8 @@
function addSeries(guid, path) {
var qualityProfileId = $("#qualityProfileId").val();
var comboBox = $("#" + guid).data("tComboBox");
sendToServer(comboBox.value(), path, qualityProfileId);
var comboBox = $("#" + guid).data("tComboBox");
sendToServer(comboBox.value(), path, qualityProfileId);
$("#div_" + guid).hide();
}

Loading…
Cancel
Save