mirror of
https://github.com/lidarr/lidarr.git
synced 2025-08-22 14:33:30 -07:00
Auto complete for paths added. Config text boxes are now wider.
This commit is contained in:
parent
ff673f3d7d
commit
bda226096b
12 changed files with 117 additions and 41 deletions
|
@ -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);
|
||||
}
|
||||
}
|
||||
}
|
59
NzbDrone.Web/Controllers/DirectoryController.cs
Normal file
59
NzbDrone.Web/Controllers/DirectoryController.cs
Normal file
|
@ -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);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue