From 4212da9146db6aa99e26ae83df5ed06ff50fcab0 Mon Sep 17 00:00:00 2001 From: Mark McDowall Date: Sat, 22 Dec 2012 21:35:36 -0800 Subject: [PATCH] Free diskspace in UI New: View Diskspace for root directories visible in UI #ND-98 fixed --- NzbDrone.Core.Test/NzbDrone.Core.Test.csproj | 4 +- NzbDrone.Core/Fluent.cs | 6 ++ NzbDrone.Core/Providers/RootDirProvider.cs | 19 ++----- NzbDrone.Web/Content/Menu.css | 2 + NzbDrone.Web/Content/NzbDrone.css | 58 +++++++++++++++----- NzbDrone.Web/Controllers/SharedController.cs | 14 ++++- NzbDrone.Web/NzbDrone.Web.csproj | 1 + NzbDrone.Web/Views/Shared/FreeSpace.cshtml | 15 +++++ NzbDrone.Web/Views/Shared/_Layout.cshtml | 8 ++- 9 files changed, 95 insertions(+), 32 deletions(-) create mode 100644 NzbDrone.Web/Views/Shared/FreeSpace.cshtml diff --git a/NzbDrone.Core.Test/NzbDrone.Core.Test.csproj b/NzbDrone.Core.Test/NzbDrone.Core.Test.csproj index 4c8b55320..2e7cfd7c5 100644 --- a/NzbDrone.Core.Test/NzbDrone.Core.Test.csproj +++ b/NzbDrone.Core.Test/NzbDrone.Core.Test.csproj @@ -139,13 +139,13 @@ - + - + diff --git a/NzbDrone.Core/Fluent.cs b/NzbDrone.Core/Fluent.cs index 98e484f1d..4889d8cab 100644 --- a/NzbDrone.Core/Fluent.cs +++ b/NzbDrone.Core/Fluent.cs @@ -112,6 +112,12 @@ namespace NzbDrone.Core private const Decimal ONE_GIGABYTE = ONE_MEGABYTE * 1024M; public static string ToBestFileSize(this long bytes, int precision = 0) + { + var ulongBytes = (ulong)bytes; + return ulongBytes.ToBestFileSize(precision); + } + + public static string ToBestFileSize(this ulong bytes, int precision = 0) { if (bytes == 0) return "0B"; diff --git a/NzbDrone.Core/Providers/RootDirProvider.cs b/NzbDrone.Core/Providers/RootDirProvider.cs index ee30580b3..b49336655 100644 --- a/NzbDrone.Core/Providers/RootDirProvider.cs +++ b/NzbDrone.Core/Providers/RootDirProvider.cs @@ -4,6 +4,7 @@ using System.IO; using Ninject; using NLog; using NzbDrone.Common; +using NzbDrone.Core.Model; using NzbDrone.Core.Providers.Core; using NzbDrone.Core.Repository; using PetaPoco; @@ -25,8 +26,6 @@ namespace NzbDrone.Core.Providers _seriesProvider = seriesProvider; } - #region IRootDirProvider - public virtual List GetAll() { return _database.Fetch(); @@ -51,7 +50,7 @@ namespace NzbDrone.Core.Providers _database.Delete(rootDirId); } - public List GetUnmappedFolders(string path) + public virtual List GetUnmappedFolders(string path) { Logger.Debug("Generating list of unmapped folders"); if (String.IsNullOrEmpty(path)) @@ -77,26 +76,16 @@ namespace NzbDrone.Core.Providers return results; } - public virtual string GetMostFreeRootDir() + public virtual List AllWithFreeSpace() { - ulong maxSize = 0; - var maxPath = String.Empty; - var rootDirs = GetAll(); foreach (var rootDir in rootDirs) { rootDir.FreeSpace = _diskProvider.FreeDiskSpace(new DirectoryInfo(rootDir.Path)); - if (rootDir.FreeSpace > maxSize) - { - maxPath = rootDir.Path; - maxSize = rootDir.FreeSpace; - } } - return maxPath; + return rootDirs; } - - #endregion } } \ No newline at end of file diff --git a/NzbDrone.Web/Content/Menu.css b/NzbDrone.Web/Content/Menu.css index 16f28f5f7..25e764c3e 100644 --- a/NzbDrone.Web/Content/Menu.css +++ b/NzbDrone.Web/Content/Menu.css @@ -1,6 +1,7 @@ #menu { height: 60px; + display: inline-block; } #menu ul @@ -9,6 +10,7 @@ padding: 5px 0px 5px 0px; list-style: none; line-height: normal; + overflow: hidden; } #menu li diff --git a/NzbDrone.Web/Content/NzbDrone.css b/NzbDrone.Web/Content/NzbDrone.css index 7ed59f728..d2e18480e 100644 --- a/NzbDrone.Web/Content/NzbDrone.css +++ b/NzbDrone.Web/Content/NzbDrone.css @@ -211,19 +211,6 @@ button span, input[type="button"] span, input[type="submit"] span, input[type="r cursor: pointer !important; } -/* Local Series Search */ -#localSeriesLookup -{ - width: 220px; - float: right; - margin-top: 7px; - margin-bottom: 0px; - border: 0px; - background: rgb(75, 75, 75); - color: rgb(169, 169, 169); - padding: 4px; -} - .ui-dialog-buttonset .ui-delete-button { background: url("jQueryUI/images/ui-bg_flat_30_b40404_40x100.png") repeat-x scroll 50% 50% #B40404; @@ -267,4 +254,49 @@ i[class*="icon-"]:not(.gridAction):hover { #donate a { background-color: #065EFE; color: #191919; +} + +/* Right Menu */ +#right-menu { + float: right; + display: inline-block; + height: 60px; +} + +#right-menu ul { + list-style: none; + overflow: hidden; +} + +#right-menu li +{ + display: block; + float: left; + padding: 0px 0px 10px 15px; +} + +#localSeriesLookup +{ + width: 220px; + border: 0px; + background: rgb(75, 75, 75); + color: rgb(169, 169, 169); + padding: 4px; +} + +.free-space { + display: inline-block; + margin-top: 2px; + padding-left: 5px; + padding-right: 5px; + height: 28px; + line-height: 28px; + background-color: #6e6e6e; + color: #d0d0d0; + /*color: #FFFFFF;*/ + cursor: default; +} + +.free-space span { + color: #191919; } \ No newline at end of file diff --git a/NzbDrone.Web/Controllers/SharedController.cs b/NzbDrone.Web/Controllers/SharedController.cs index a4ce35d43..ae99fa795 100644 --- a/NzbDrone.Web/Controllers/SharedController.cs +++ b/NzbDrone.Web/Controllers/SharedController.cs @@ -1,5 +1,6 @@ using System.Web.Mvc; using NzbDrone.Common; +using NzbDrone.Core.Providers; using NzbDrone.Web.Models; namespace NzbDrone.Web.Controllers @@ -7,10 +8,12 @@ namespace NzbDrone.Web.Controllers public class SharedController : Controller { private readonly EnvironmentProvider _environmentProvider; + private readonly RootDirProvider _rootDirProvider; - public SharedController(EnvironmentProvider environmentProvider) + public SharedController(EnvironmentProvider environmentProvider, RootDirProvider rootDirProvider) { _environmentProvider = environmentProvider; + _rootDirProvider = rootDirProvider; } public ActionResult Index() @@ -24,5 +27,14 @@ namespace NzbDrone.Web.Controllers { return PartialView(new FooterModel { BuildTime = _environmentProvider.BuildDateTime, Version = _environmentProvider.Version }); } + + [ChildActionOnly] + //[OutputCache(Duration = 600)] + public ActionResult FreeSpace() + { + var rootDirs = _rootDirProvider.AllWithFreeSpace(); + + return PartialView(rootDirs); + } } } \ No newline at end of file diff --git a/NzbDrone.Web/NzbDrone.Web.csproj b/NzbDrone.Web/NzbDrone.Web.csproj index 354702db6..e97e6f500 100644 --- a/NzbDrone.Web/NzbDrone.Web.csproj +++ b/NzbDrone.Web/NzbDrone.Web.csproj @@ -418,6 +418,7 @@ + diff --git a/NzbDrone.Web/Views/Shared/FreeSpace.cshtml b/NzbDrone.Web/Views/Shared/FreeSpace.cshtml new file mode 100644 index 000000000..5eb2ba311 --- /dev/null +++ b/NzbDrone.Web/Views/Shared/FreeSpace.cshtml @@ -0,0 +1,15 @@ +@using NzbDrone.Core +@model IEnumerable +@{ + Layout = null; +} + + +@{ + foreach(var rootDir in Model) + { +
+ @rootDir.FreeSpace.ToBestFileSize(1) Free +
+ } +} \ No newline at end of file diff --git a/NzbDrone.Web/Views/Shared/_Layout.cshtml b/NzbDrone.Web/Views/Shared/_Layout.cshtml index 1ec68145b..6e83c9670 100644 --- a/NzbDrone.Web/Views/Shared/_Layout.cshtml +++ b/NzbDrone.Web/Views/Shared/_Layout.cshtml @@ -32,8 +32,14 @@ @MvcHtmlString.Create(Html.CurrentControllerLink("Logs", "Index", "Log")) - +
+
    +
  • @{ Html.RenderAction("FreeSpace", "Shared"); }
  • +
  • +
+
+