Free space widgets

Fixed: Free space widgets take up less space on smaller screens
pull/4/head
Mark McDowall 12 years ago
parent 607f1b07d3
commit ae0648b8f4

@ -275,5 +275,10 @@ namespace NzbDrone.Common
return false; return false;
} }
public virtual string GetPathRoot(string path)
{
return Path.GetPathRoot(path);
}
} }
} }

@ -87,5 +87,22 @@ namespace NzbDrone.Core.Providers
return rootDirs; return rootDirs;
} }
public virtual Dictionary<string, ulong> FreeSpaceOnDrives()
{
var freeSpace = new Dictionary<string, ulong>();
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;
}
} }
} }

@ -16,7 +16,7 @@ body
margin-right: auto; margin-right: auto;
width: 85%; width: 85%;
margin-left: auto; margin-left: auto;
min-width: 850px; min-width: 1050px;
max-width: 1400px; max-width: 1400px;
} }
@ -102,8 +102,6 @@ hr
text-decoration: none; text-decoration: none;
} }
.sub-field .sub-field
{ {
width: 70%; width: 70%;
@ -300,3 +298,27 @@ i[class*="icon-"]:not(.gridAction):hover {
.free-space span { .free-space span {
color: #191919; 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;
}
}

@ -32,7 +32,7 @@ namespace NzbDrone.Web.Controllers
[OutputCache(Duration = 600)] [OutputCache(Duration = 600)]
public ActionResult FreeSpace() public ActionResult FreeSpace()
{ {
var rootDirs = _rootDirProvider.AllWithFreeSpace(); var rootDirs = _rootDirProvider.FreeSpaceOnDrives();
return PartialView(rootDirs); return PartialView(rootDirs);
} }

@ -1,15 +1,23 @@
@using NzbDrone.Core @using NzbDrone.Core
@model IEnumerable<NzbDrone.Core.Repository.RootDir> @model Dictionary<string, ulong>
@{ @{
Layout = null; Layout = null;
} }
@{ @{
var rootDirString = "";
foreach(var rootDir in Model) foreach(var rootDir in Model)
{ {
<div class="free-space" title="@rootDir.Path"> <div class="free-space" title="@rootDir.Key">
@rootDir.FreeSpace.ToBestFileSize(1) <span>Free</span> @rootDir.Value.ToBestFileSize(1) <span>Free</span>
</div> </div>
rootDirString += String.Format("{0} - {1} Free\r\n", rootDir.Key, rootDir.Value.ToBestFileSize(1));
} }
<div id="free-space-small" title="@Html.Encode(rootDirString)">
<i class="icon-hdd"></i>
</div>
} }
Loading…
Cancel
Save