Root Dir cleanup

This commit is contained in:
kay.one 2011-06-29 23:15:06 -07:00
parent 07312780f1
commit cece6e9bf6
10 changed files with 144 additions and 59 deletions

View File

@ -0,0 +1,23 @@
.actionButton
{
margin: 5px 0px;
padding: 5px 10px 5px 10px;
background-repeat: no-repeat;
background-position: 5px center;
background-color: #dbe4e9;
margin-bottom: 10px;
display: inline-block;
font-size: 15px;
}
.actionButton img
{
cursor: pointer;
vertical-align: middle;
position: relative;
bottom: 1px;
}
.delete
{
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 570 B

View File

@ -87,6 +87,12 @@ namespace NzbDrone.Web.Controllers
return View(rootDirs);
}
public ActionResult Test()
{
return View();
}
public ActionResult AddExisting()
{
var rootDirs = _rootFolderProvider.GetAll();
@ -185,18 +191,15 @@ namespace NzbDrone.Web.Controllers
//Root Directory
[HttpPost]
public JsonResult SaveRootDir(int id, string path)
public JsonResult SaveRootDir(string path)
{
if (String.IsNullOrWhiteSpace(path))
return new JsonResult { Data = "failed" };
try
{
if (id == 0)
id = _rootFolderProvider.Add(new RootDir { Path = path });
_rootFolderProvider.Add(new RootDir { Path = path });
else
_rootFolderProvider.Update(new RootDir { Id = id, Path = path });
}
catch (Exception ex)
{
@ -206,7 +209,7 @@ namespace NzbDrone.Web.Controllers
return new JsonResult { Data = "failed" };
}
return new JsonResult { Data = id };
return new JsonResult { };
}
public PartialViewResult AddRootDir()
@ -238,11 +241,19 @@ namespace NzbDrone.Web.Controllers
return PartialView("RootDir", model);
}
public JsonResult DeleteRootDir(int rootDirId)
public ActionResult RootDir()
{
var rootDir = _rootFolderProvider.GetAll().Select(c => c.Path);
return PartialView("RootDir", rootDir);
}
public JsonResult DeleteRootDir(string path)
{
try
{
_rootFolderProvider.Remove(rootDirId);
var id = _rootFolderProvider.GetAll().Where(c => c.Path == path).First().Id;
_rootFolderProvider.Remove(id);
}
catch (Exception)

View File

@ -2,6 +2,7 @@
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Helpers;
using System.Web.Mvc;
using NzbDrone.Core.Providers.Core;
@ -28,26 +29,28 @@ namespace NzbDrone.Web.Controllers
};
}
public SelectList GetDirectories(string text)
[HttpGet]
public JsonResult GetDirectories(string q)
{
try
{
//Windows (Including UNC)
var windowsSep = text.LastIndexOf('\\');
var windowsSep = q.LastIndexOf('\\');
if (windowsSep > -1)
{
var dirs = _diskProvider.GetDirectories(text.Substring(0, windowsSep + 1));
return new SelectList(dirs, dirs.FirstOrDefault());
var dirs = _diskProvider.GetDirectories(q.Substring(0, windowsSep + 1));
return Json(dirs, JsonRequestBehavior.AllowGet);
}
return Json(new string[] { }, JsonRequestBehavior.AllowGet);
//Unix
var index = text.LastIndexOf('/');
var index = q.LastIndexOf('/');
if (index > -1)
{
var dirs = _diskProvider.GetDirectories(text.Substring(0, index + 1));
return new SelectList(dirs, dirs.FirstOrDefault());
var dirs = _diskProvider.GetDirectories(q.Substring(0, index + 1));
//return new SelectList(dirs, dirs.FirstOrDefault());
}
}
catch
@ -55,7 +58,7 @@ namespace NzbDrone.Web.Controllers
//Swallow the exceptions so proper JSON is returned to the client (Empty results)
}
return new SelectList(new List<string>());
return Json(new string[]{}, JsonRequestBehavior.AllowGet);
}
}
}

View File

@ -490,6 +490,7 @@
<Content Include="Content\2011.1.414\Windows7\slider-vs-right.gif" />
<Content Include="Content\2011.1.414\Windows7\sprite-vertical.png" />
<Content Include="Content\2011.1.414\Windows7\sprite.png" />
<Content Include="Content\ActionButton.css" />
<Content Include="Content\Blueprint\ie.css" />
<Content Include="Content\Blueprint\screen.css" />
<Content Include="Content\Blueprint\liquid.css" />
@ -682,6 +683,9 @@
<ItemGroup>
<Content Include="Views\System\PendingProcessing.cshtml" />
</ItemGroup>
<ItemGroup>
<Content Include="Views\AddSeries\Test.cshtml" />
</ItemGroup>
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
<Import Project="$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v10.0\WebApplications\Microsoft.WebApplication.targets" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.

View File

@ -0,0 +1,13 @@
function bindFolderAutoComplete(selector) {
YUI().use("autocomplete", "autocomplete-highlighters", 'autocomplete-filters', function (Y) {
Y.one('body').addClass('yui3-skin-sam');
Y.one(selector).plug(Y.Plugin.AutoComplete, {
resultHighlighter: 'startsWith',
resultFilters: 'phraseMatch',
source: '/Directory/GetDirectories/?q={query}'
});
})
}

View File

@ -1,25 +1,44 @@
@model NzbDrone.Web.Models.RootDirModel
@using NzbDrone.Web.Models
@model IEnumerable<String>
@{
Layout = null;
}
<div id="rootDirs">
@foreach (var root in Model)
{
<div class="actionButton delete">
<img src="/Content/Images/x_16.png" alt="delete" id='@root'/>
<span>@root</span>
</div>
}
</div>
<br />
<label for="ac-input">
Enter a GitHub username:</label>
<input id="rootDirInput" type="text" style="width: 100px" />
<button id="saveDir">
Save</button>
@(Html.Telerik().ScriptRegistrar().DefaultGroup(c => c.Add("http://ajax.googleapis.com/ajax/libs/yui/3.3.0/build/yui/yui-min.js")
.Add("AutoComplete.js")
).OnDocumentReady("bindFolderAutoComplete('#rootDirInput')"))
<script type="text/javascript">
<div class="rootDirSection" id="rootDir_@(ViewData["guid"])" style="padding: 7px; padding-left: 3px;">
<fieldset style="padding: 5px; height: 40px;">
@{Html.Telerik().ComboBox()
.Name("path_" + ViewData["guid"])
.BindTo(Model.SelectList)
.DataBinding(binding => binding.Ajax().Select("_autoCompletePath", "Directory").Delay(400).Cache(true))
.Filterable(f => f.FilterMode(AutoCompleteFilterMode.StartsWith))
.HighlightFirstMatch(true)
.HtmlAttributes(new { style = "width: 300px;" })
.Render();}
$(document).ready(function () {
$('#saveDir').click(saveRootDir);
function saveRootDir() {
var path = $("#rootDirInput").val();
$.post("/AddSeries/SaveRootDir", { Path: path });
}
});
<a href="#RemoveRootDir" class="deleteRow" onclick="deleteRootDir('@ViewData["guid"]'); 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('@ViewData["guid"]')">Save</button>
@Html.HiddenFor(x => x.Id, new { id = "id_" + ViewData["guid"] })
</fieldset>
</div>
$(document).ready(function () {
$('#rootDirs .actionButton img').live('click',
function (image) {
var path = $(image.srcElement).attr('id');
$.post("/AddSeries/DeleteRootDir", { Path: path });
});
});
</script>

View File

@ -0,0 +1,14 @@
@{
ViewBag.Title = "Test";
Layout = "~/Views/Shared/_Layout.cshtml";
}
@{Html.RenderAction("RootDir");}
@(Html.Telerik().ScriptRegistrar().Scripts(c => c.AddGroup("TestGroup", group => group
.Add("telerik.common.js")
.Add("telerik.combobox.js")
.Add("telerik.list.js")
.Add("telerik.autocomplete.js")
)))

View File

@ -99,7 +99,23 @@ Series
@section Scripts{
<script type="text/javascript">
var windowElement;
(function ($) {
$.fn.episodeProgress = function (episodes, totalEpisodes) {
return this.each(
function () {
var div = $(this);
var progressBar = div.find(".progress");
var width = Math.round(episodes / totalEpisodes * 100);
progressBar.css("width", width + "%");
div.find(".progressText").html(episodes + " / " + totalEpisodes);
});
};
})(jQuery);
function grid_edit(args) {
$(args.form)
.closest(".t-window")
@ -146,22 +162,7 @@ Series
$("#progressbar_" + seriesId).episodeProgress(episodeFileCount, episodeCount);
}
</script>
<script type="text/javascript" src="../../Scripts/doTimeout.js"></script>
<script type="text/javascript">
(function ($) {
$.fn.episodeProgress = function (episodes, totalEpisodes) {
return this.each(
function () {
var div = $(this);
var progressBar = div.find(".progress");
var width = Math.round(episodes / totalEpisodes * 100);
progressBar.css("width", width + "%");
div.find(".progressText").html(episodes + " / " + totalEpisodes);
});
};
})(jQuery);
</script>
}

View File

@ -5,7 +5,7 @@
<link rel="SHORTCUT ICON" href="../../favicon.ico" />
<title>NZBDrone</title>
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
@MvcMiniProfiler.MiniProfiler.RenderIncludes()
<link href="/Content/Blueprint/screen.css" rel="stylesheet" type="text/css" />
<link href="/Content/Blueprint/ie.css" rel="stylesheet" type="text/css" />
<link type="text/css" href="http://aspnet-skins.telerikstatic.com/mvcz/2011.1.414/telerik.common.min.css"
@ -16,6 +16,7 @@
rel="stylesheet" />
<link href="/Content/Site.css" rel="stylesheet" type="text/css" />
<link href="/Content/Notibar.css" rel="stylesheet" type="text/css" />
<link href="/Content/ActionButton.css" rel="stylesheet" type="text/css" />
@RenderSection("HeaderContent", required: false)
</head>
<body>
@ -51,16 +52,12 @@
<div id="msgBox">
<span id="msgText">Scanning Series Folder...</span>
</div>
@(Html.Telerik().ScriptRegistrar().jQuery(true).Scripts(
@(Html.Telerik().ScriptRegistrar().Scripts(
c => c.AddGroup("CDN", group => group
.Add("http://ajax.googleapis.com/ajax/libs/jqueryui/1.8.13/jquery-ui.min.js")
//.Add("http://ajax.googleapis.com/ajax/libs/jqueryui/1.8.13/jquery-ui.min.js")
.Add("http://ajax.aspnetcdn.com/ajax/4.0/1/MicrosoftAjax.js"))
.Add("2011.1.414/telerik.list.min.js")
.Add("2011.1.414/telerik.combobox.min.js")
.Add("2011.1.414/telerik.textbox.min.js")
.Add("2011.1.414/telerik.window.min.js")
.Add("2011.1.414/telerik.autocomplete.min.js")
.AddGroup("3rdParty", group => group
.AddGroup("3rdParty", group => group
.Add("jquery.form.js")
.Add("jquery.jgrowl.js")
.Add("jquery-tgc-countdown-1.0.js")