Auto complete for paths added. Config text boxes are now wider.

pull/3113/head
Mark McDowall 14 years ago
parent ff673f3d7d
commit bda226096b

@ -190,14 +190,14 @@ hr
/* Config Pages */
.config-section
{
width: 650px;
width: 800px;
height: 45px;
display: block;
}
.config-group
{
width: 300px;
width: 385px;
display: block;
float: left;
height: 20px;
@ -205,7 +205,7 @@ hr
.config-group2
{
width: 300px;
width: 385px;
display: block;
float: right;
height: 20px;
@ -223,6 +223,11 @@ hr
float: right;
}
input[type=text]
{
width: 220px;
}
.config-validation
{
color: Red;

@ -184,6 +184,7 @@ namespace NzbDrone.Web.Controllers
return new SelectList(dataVal, "Id", "SeriesName", selectId);
}
//Root Directory
[HttpPost]
public JsonResult SaveRootDir(int id, string path)
{
@ -202,23 +203,29 @@ namespace NzbDrone.Web.Controllers
return new JsonResult { Data = "ok" };
}
public ViewResult AddRootDir()
public PartialViewResult AddRootDir()
{
var rootDir = new RootDir { Path = String.Empty };
var id = _rootFolderProvider.Add(rootDir);
rootDir.Id = id;
ViewData["RootDirId"] = id;
var model = new RootDirModel();
model.Id = rootDir.Id;
model.Path = rootDir.Path;
model.SelectList = new SelectList(new List<string> { rootDir.Path }, rootDir.Path);
return View("RootDir", rootDir);
return PartialView("RootDir", model);
}
public ActionResult GetRootDirView(RootDir rootDir)
{
ViewData["RootDirId"] = rootDir.Id;
var model = new RootDirModel();
model.Id = rootDir.Id;
model.Path = rootDir.Path;
model.SelectList = new SelectList(new List<string> { rootDir.Path }, rootDir.Path);
return PartialView("RootDir", rootDir);
return PartialView("RootDir", model);
}
public JsonResult DeleteRootDir(int rootDirId)
@ -235,28 +242,5 @@ namespace NzbDrone.Web.Controllers
return new JsonResult { Data = "ok" };
}
public JsonResult JsonAutoCompletePath(string term)
{
var windowsSep = term.LastIndexOf('\\');
if (windowsSep > -1)
{
var start = term.Substring(windowsSep + 1);
var dirs = _diskProvider.GetDirectories(term.Substring(0, windowsSep + 1)).Where(d => new DirectoryInfo(d).Name.ToLower().StartsWith(start.ToLower())).Take(10);
return Json(dirs.ToArray(), JsonRequestBehavior.AllowGet);
}
var index = term.LastIndexOf('/');
if (index > -1)
{
var start = term.Substring(index + 1);
var dirs = _diskProvider.GetDirectories(term.Substring(0, index + 1)).Where(d => new DirectoryInfo(d).Name.ToLower().StartsWith(start.ToLower())).Take(10);
return Json(dirs.ToArray(), JsonRequestBehavior.AllowGet);
}
return Json(new JsonResult(), JsonRequestBehavior.AllowGet);
}
}
}

@ -0,0 +1,59 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using NzbDrone.Core.Providers.Core;
namespace NzbDrone.Web.Controllers
{
public class DirectoryController : Controller
{
private readonly DiskProvider _diskProvider;
public DirectoryController(DiskProvider diskProvider)
{
_diskProvider = diskProvider;
}
public ActionResult Test()
{
return Content("Testing...");
}
[HttpPost]
public ActionResult _autoCompletePath(string text, int? filterMode)
{
var data = GetDirectories(text);
return new JsonResult
{
JsonRequestBehavior = JsonRequestBehavior.AllowGet,
Data = data
};
}
public SelectList GetDirectories(string text)
{
//Windows (Including UNC)
var windowsSep = text.LastIndexOf('\\');
if (windowsSep > -1)
{
var dirs = _diskProvider.GetDirectories(text.Substring(0, windowsSep + 1));
return new SelectList(dirs, dirs.FirstOrDefault());
}
//Unix
var index = text.LastIndexOf('/');
if (index > -1)
{
var dirs = _diskProvider.GetDirectories(text.Substring(0, index + 1));
return new SelectList(dirs, dirs.FirstOrDefault());
}
return new SelectList(new List<string>());
}
}
}

@ -96,6 +96,9 @@ namespace NzbDrone.Web.Controllers
{
ViewData["viewName"] = "Sabnzbd";
var sabDropDir = _configProvider.SabDropDirectory;
var selectList = new SelectList(new List<string> {sabDropDir}, sabDropDir);
var model = new SabnzbdSettingsModel
{
SabHost = _configProvider.SabHost,
@ -105,7 +108,8 @@ namespace NzbDrone.Web.Controllers
SabPassword = _configProvider.SabPassword,
SabTvCategory = _configProvider.SabTvCategory,
SabTvPriority = _configProvider.SabTvPriority,
SabDropDirectory = _configProvider.SabDropDirectory
SabDropDirectory = sabDropDir,
SabDropDirectorySelectList = selectList
};
return View("Index", model);

@ -2,12 +2,15 @@
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
namespace NzbDrone.Web.Models
{
public class RootDirModel
{
public int Id { get; set; }
public string Path { get; set; }
public string CleanPath { get; set; }
public SelectList SelectList { get; set; }
}
}

@ -56,5 +56,7 @@ namespace NzbDrone.Web.Models
[Description("The directory where SABnzbd stores TV shows (NzbDrone will sort them for you)")]
[DisplayFormat(ConvertEmptyStringToNull = false)]
public string SabDropDirectory { get; set; }
public SelectList SabDropDirectorySelectList { get; set; }
}
}

@ -236,6 +236,7 @@
<DesignTime>True</DesignTime>
<DependentUpon>UploadLocalization.en-US.resx</DependentUpon>
</Compile>
<Compile Include="Controllers\DirectoryController.cs" />
<Compile Include="Controllers\EpisodeController.cs" />
<Compile Include="Controllers\HealthController.cs" />
<Compile Include="Controllers\HistoryController.cs" />

@ -153,7 +153,7 @@
var saveRootDirUrl = '@Url.Action("SaveRootDir", "AddSeries")';
function saveRootDir(id) {
var path = $('#path_' + id).val();
var path = $("#path_" + id).data("tComboBox").value();
$.ajax({
type: "POST",

@ -1,4 +1,4 @@
@model NzbDrone.Core.Repository.RootDir
@model NzbDrone.Web.Models.RootDirModel
@{
Layout = null;
@ -6,8 +6,17 @@
<div class="rootDirSection" id="rootDir_@(Model.Id)" style="padding: 7px; padding-left: 3px;">
<fieldset style="padding: 5px; height: 40px;">
@Html.TextBoxFor(m => m.Path, new { @class = "root_dir_text", id = "path_" + Model.Id })
<a href="#" class="deleteRow" onclick="deleteRootDir('@ViewData["RootDirId"]')">
@{Html.Telerik().ComboBox()
.Name("path_" + Model.Id)
.BindTo(Model.SelectList)
.DataBinding(binding => binding.Ajax().Select("_autoCompletePath", "Directory").Delay(400).Cache(false))
.Filterable(f => f.FilterMode(AutoCompleteFilterMode.StartsWith))
.HighlightFirstMatch(true)
.HtmlAttributes(new { style = "width: 300px;" })
.Render();}
<a href="#RemoveRootDir" class="deleteRow" onclick="deleteRootDir(@Model.Id); return false;">
<img src="../../Content/Images/X.png" alt="Delete" width="20px" height="20px" style="vertical-align: middle; margin-top: 7px;"/></a>
<button style="padding: 2px 10px 2px 10px; vertical-align: middle; margin: 0px; margin-top: 7px;" onclick="saveRootDir(@Model.Id)">Save</button>

@ -32,7 +32,7 @@
.indexer_group
{
width: 220px;
width: 290px;
}
.indexer_left
@ -48,8 +48,10 @@
.indexer_checkbox
{
margin-right: 135px;
margin-right: 205px;
margin-top: 8px;
}
</style>
@using (Html.BeginForm("SaveIndexers", "Settings", FormMethod.Post, new { id = "form", name = "form" })) {
@ -60,7 +62,7 @@
<div>
@{ Html.Telerik().PanelBar()
.Name("PanelBar")
.HtmlAttributes(new { style = "width: 300px; margin: 10px;" })
.HtmlAttributes(new { style = "width: 500px; margin: 10px;" })
.ExpandMode(PanelBarExpandMode.Single)
.SelectedIndex(0)
.Items(indexerItem =>

@ -49,7 +49,7 @@
</div>
<div class="config-group" style="width: 255px; margin-bottom: 5px; margin-left: 5px;">
<div class="config-title">@Html.LabelFor(x => x.Name)</div>
<div class="config-value">@Html.TextBoxFor(x => x.Name, new { maxlength = 15 })</div>
<div class="config-value">@Html.TextBoxFor(x => x.Name, new { maxlength = 15, style="width: 150px" })</div>
<div class="config-validation">@Html.ValidationMessageFor(x => x.Name)</div>
</div>
<div class="config-group" style="width: 255px; margin-bottom: 5px; margin-left: 5px;">

@ -112,7 +112,14 @@
<div class="config-section">
<div class="config-group">
<div class="config-title">@Html.LabelFor(m => m.SabDropDirectory)</div>
<div class="config-value">@Html.TextBoxFor(m => m.SabDropDirectory)</div>
<div class="config-value">@{Html.Telerik().ComboBoxFor(m => m.SabDropDirectory)
.BindTo(Model.SabDropDirectorySelectList)
.DataBinding(binding => binding.Ajax().Select("_autoCompletePath", "Directory").Delay(400).Cache(false))
.Filterable(f => f.FilterMode(AutoCompleteFilterMode.StartsWith))
.HighlightFirstMatch(true)
.HtmlAttributes(new { style = "margin-left: -2px; width: 220px;" })
.Render();}</div>
</div>
<div class="config-group2">
<div class="config-validation">@Html.ValidationMessageFor(m => m.SabDropDirectory)</div>

Loading…
Cancel
Save