Free space widgets

Fixed: Free space widgets take up less space on smaller screens
This commit is contained in:
Mark McDowall 2012-12-23 23:16:43 -08:00
parent 607f1b07d3
commit ae0648b8f4
5 changed files with 59 additions and 7 deletions

View File

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

View File

@ -87,5 +87,22 @@ namespace NzbDrone.Core.Providers
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;
}
}
}

View File

@ -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;
}
}

View File

@ -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);
}

View File

@ -1,15 +1,23 @@
@using NzbDrone.Core
@model IEnumerable<NzbDrone.Core.Repository.RootDir>
@model Dictionary<string, ulong>
@{
Layout = null;
}
@{
var rootDirString = "";
foreach(var rootDir in Model)
{
<div class="free-space" title="@rootDir.Path">
@rootDir.FreeSpace.ToBestFileSize(1) <span>Free</span>
<div class="free-space" title="@rootDir.Key">
@rootDir.Value.ToBestFileSize(1) <span>Free</span>
</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>
}