From ae0648b8f4fb0d3ce4ee320d8d54d5f889838d2e Mon Sep 17 00:00:00 2001 From: Mark McDowall Date: Sun, 23 Dec 2012 23:16:43 -0800 Subject: [PATCH] Free space widgets Fixed: Free space widgets take up less space on smaller screens --- NzbDrone.Common/DiskProvider.cs | 5 ++++ NzbDrone.Core/Providers/RootDirProvider.cs | 17 ++++++++++++ NzbDrone.Web/Content/NzbDrone.css | 28 +++++++++++++++++--- NzbDrone.Web/Controllers/SharedController.cs | 2 +- NzbDrone.Web/Views/Shared/FreeSpace.cshtml | 14 +++++++--- 5 files changed, 59 insertions(+), 7 deletions(-) diff --git a/NzbDrone.Common/DiskProvider.cs b/NzbDrone.Common/DiskProvider.cs index 4879b8296..afb5f5a65 100644 --- a/NzbDrone.Common/DiskProvider.cs +++ b/NzbDrone.Common/DiskProvider.cs @@ -275,5 +275,10 @@ namespace NzbDrone.Common return false; } + + public virtual string GetPathRoot(string path) + { + return Path.GetPathRoot(path); + } } } \ No newline at end of file diff --git a/NzbDrone.Core/Providers/RootDirProvider.cs b/NzbDrone.Core/Providers/RootDirProvider.cs index b49336655..6dba0ee00 100644 --- a/NzbDrone.Core/Providers/RootDirProvider.cs +++ b/NzbDrone.Core/Providers/RootDirProvider.cs @@ -87,5 +87,22 @@ namespace NzbDrone.Core.Providers return rootDirs; } + + public virtual Dictionary FreeSpaceOnDrives() + { + var freeSpace = new Dictionary(); + + var rootDirs = GetAll(); + + foreach (var rootDir in rootDirs) + { + var pathRoot = _diskProvider.GetPathRoot(rootDir.Path); + + if (!freeSpace.ContainsKey(pathRoot)) + freeSpace.Add(pathRoot, _diskProvider.FreeDiskSpace(new DirectoryInfo(rootDir.Path))); + } + + return freeSpace; + } } } \ No newline at end of file diff --git a/NzbDrone.Web/Content/NzbDrone.css b/NzbDrone.Web/Content/NzbDrone.css index d2e18480e..dcf674f09 100644 --- a/NzbDrone.Web/Content/NzbDrone.css +++ b/NzbDrone.Web/Content/NzbDrone.css @@ -16,7 +16,7 @@ body margin-right: auto; width: 85%; margin-left: auto; - min-width: 850px; + min-width: 1050px; max-width: 1400px; } @@ -102,8 +102,6 @@ hr text-decoration: none; } - - .sub-field { width: 70%; @@ -299,4 +297,28 @@ i[class*="icon-"]:not(.gridAction):hover { .free-space span { color: #191919; +} + +#free-space-small { + font-size: 18px; + display: none; + width: 23px; + margin-top: 2px; + padding-left: 3px; + padding-right: 3px; + height: 28px; + line-height: 24px; + background-color: #6e6e6e; + color: #d0d0d0; + cursor: default; +} + +@media all and (max-width: 1500px) { + .free-space { + display: none; + } + + #free-space-small { + display: inline-block; + } } \ No newline at end of file diff --git a/NzbDrone.Web/Controllers/SharedController.cs b/NzbDrone.Web/Controllers/SharedController.cs index f35196e55..a4f43d8d5 100644 --- a/NzbDrone.Web/Controllers/SharedController.cs +++ b/NzbDrone.Web/Controllers/SharedController.cs @@ -32,7 +32,7 @@ namespace NzbDrone.Web.Controllers [OutputCache(Duration = 600)] public ActionResult FreeSpace() { - var rootDirs = _rootDirProvider.AllWithFreeSpace(); + var rootDirs = _rootDirProvider.FreeSpaceOnDrives(); return PartialView(rootDirs); } diff --git a/NzbDrone.Web/Views/Shared/FreeSpace.cshtml b/NzbDrone.Web/Views/Shared/FreeSpace.cshtml index 5eb2ba311..603045c15 100644 --- a/NzbDrone.Web/Views/Shared/FreeSpace.cshtml +++ b/NzbDrone.Web/Views/Shared/FreeSpace.cshtml @@ -1,15 +1,23 @@ @using NzbDrone.Core -@model IEnumerable +@model Dictionary @{ Layout = null; } @{ + var rootDirString = ""; + foreach(var rootDir in Model) { -
- @rootDir.FreeSpace.ToBestFileSize(1) Free +
+ @rootDir.Value.ToBestFileSize(1) Free
+ + rootDirString += String.Format("{0} - {1} Free\r\n", rootDir.Key, rootDir.Value.ToBestFileSize(1)); } + +
+ +
} \ No newline at end of file