Free diskspace in UI

New: View Diskspace for root directories visible in UI
#ND-98 fixed
This commit is contained in:
Mark McDowall 2012-12-22 21:35:36 -08:00
parent 2bd866f590
commit 4212da9146
9 changed files with 95 additions and 32 deletions

View File

@ -139,13 +139,13 @@
</Reference> </Reference>
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<Compile Include="HelperTests\XElementHelperFixture.cs" /> <Compile Include="HelperTests\XElementHelperTests\ConvertToTFixture.cs" />
<Compile Include="JobTests\RenameSeasonJobFixture.cs" /> <Compile Include="JobTests\RenameSeasonJobFixture.cs" />
<Compile Include="ProviderTests\SearchProviderTests\GetSeriesTitleFixture.cs" /> <Compile Include="ProviderTests\SearchProviderTests\GetSeriesTitleFixture.cs" />
<Compile Include="ProviderTests\TvRageMappingProviderTests\FindMatchingTvRageSeriesFixture.cs" /> <Compile Include="ProviderTests\TvRageMappingProviderTests\FindMatchingTvRageSeriesFixture.cs" />
<Compile Include="ProviderTests\TvRageMappingProviderTests\ProcessResultsFixture.cs" /> <Compile Include="ProviderTests\TvRageMappingProviderTests\ProcessResultsFixture.cs" />
<Compile Include="ProviderTests\TvRageProviderTests\GetSeriesFixture.cs" /> <Compile Include="ProviderTests\TvRageProviderTests\GetSeriesFixture.cs" />
<Compile Include="ProviderTests\TvRageProviderTests\ParseDayOfWeekFixture.cs" /> <Compile Include="HelperTests\XElementHelperTests\ConvertToDayOfWeekFixture.cs" />
<Compile Include="ProviderTests\TvRageProviderTests\GetUtcOffsetFixture.cs" /> <Compile Include="ProviderTests\TvRageProviderTests\GetUtcOffsetFixture.cs" />
<Compile Include="ProviderTests\TvRageProviderTests\SearchSeriesFixture.cs" /> <Compile Include="ProviderTests\TvRageProviderTests\SearchSeriesFixture.cs" />
<Compile Include="QualityTypesTest.cs" /> <Compile Include="QualityTypesTest.cs" />

View File

@ -112,6 +112,12 @@ namespace NzbDrone.Core
private const Decimal ONE_GIGABYTE = ONE_MEGABYTE * 1024M; private const Decimal ONE_GIGABYTE = ONE_MEGABYTE * 1024M;
public static string ToBestFileSize(this long bytes, int precision = 0) 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) if (bytes == 0)
return "0B"; return "0B";

View File

@ -4,6 +4,7 @@ using System.IO;
using Ninject; using Ninject;
using NLog; using NLog;
using NzbDrone.Common; using NzbDrone.Common;
using NzbDrone.Core.Model;
using NzbDrone.Core.Providers.Core; using NzbDrone.Core.Providers.Core;
using NzbDrone.Core.Repository; using NzbDrone.Core.Repository;
using PetaPoco; using PetaPoco;
@ -25,8 +26,6 @@ namespace NzbDrone.Core.Providers
_seriesProvider = seriesProvider; _seriesProvider = seriesProvider;
} }
#region IRootDirProvider
public virtual List<RootDir> GetAll() public virtual List<RootDir> GetAll()
{ {
return _database.Fetch<RootDir>(); return _database.Fetch<RootDir>();
@ -51,7 +50,7 @@ namespace NzbDrone.Core.Providers
_database.Delete<RootDir>(rootDirId); _database.Delete<RootDir>(rootDirId);
} }
public List<String> GetUnmappedFolders(string path) public virtual List<String> GetUnmappedFolders(string path)
{ {
Logger.Debug("Generating list of unmapped folders"); Logger.Debug("Generating list of unmapped folders");
if (String.IsNullOrEmpty(path)) if (String.IsNullOrEmpty(path))
@ -77,26 +76,16 @@ namespace NzbDrone.Core.Providers
return results; return results;
} }
public virtual string GetMostFreeRootDir() public virtual List<RootDir> AllWithFreeSpace()
{ {
ulong maxSize = 0;
var maxPath = String.Empty;
var rootDirs = GetAll(); var rootDirs = GetAll();
foreach (var rootDir in rootDirs) foreach (var rootDir in rootDirs)
{ {
rootDir.FreeSpace = _diskProvider.FreeDiskSpace(new DirectoryInfo(rootDir.Path)); rootDir.FreeSpace = _diskProvider.FreeDiskSpace(new DirectoryInfo(rootDir.Path));
if (rootDir.FreeSpace > maxSize)
{
maxPath = rootDir.Path;
maxSize = rootDir.FreeSpace;
}
} }
return maxPath; return rootDirs;
} }
#endregion
} }
} }

View File

@ -1,6 +1,7 @@
#menu #menu
{ {
height: 60px; height: 60px;
display: inline-block;
} }
#menu ul #menu ul
@ -9,6 +10,7 @@
padding: 5px 0px 5px 0px; padding: 5px 0px 5px 0px;
list-style: none; list-style: none;
line-height: normal; line-height: normal;
overflow: hidden;
} }
#menu li #menu li

View File

@ -211,19 +211,6 @@ button span, input[type="button"] span, input[type="submit"] span, input[type="r
cursor: pointer !important; 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 .ui-dialog-buttonset .ui-delete-button
{ {
background: url("jQueryUI/images/ui-bg_flat_30_b40404_40x100.png") repeat-x scroll 50% 50% #B40404; background: url("jQueryUI/images/ui-bg_flat_30_b40404_40x100.png") repeat-x scroll 50% 50% #B40404;
@ -268,3 +255,48 @@ i[class*="icon-"]:not(.gridAction):hover {
background-color: #065EFE; background-color: #065EFE;
color: #191919; 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;
}

View File

@ -1,5 +1,6 @@
using System.Web.Mvc; using System.Web.Mvc;
using NzbDrone.Common; using NzbDrone.Common;
using NzbDrone.Core.Providers;
using NzbDrone.Web.Models; using NzbDrone.Web.Models;
namespace NzbDrone.Web.Controllers namespace NzbDrone.Web.Controllers
@ -7,10 +8,12 @@ namespace NzbDrone.Web.Controllers
public class SharedController : Controller public class SharedController : Controller
{ {
private readonly EnvironmentProvider _environmentProvider; private readonly EnvironmentProvider _environmentProvider;
private readonly RootDirProvider _rootDirProvider;
public SharedController(EnvironmentProvider environmentProvider) public SharedController(EnvironmentProvider environmentProvider, RootDirProvider rootDirProvider)
{ {
_environmentProvider = environmentProvider; _environmentProvider = environmentProvider;
_rootDirProvider = rootDirProvider;
} }
public ActionResult Index() public ActionResult Index()
@ -24,5 +27,14 @@ namespace NzbDrone.Web.Controllers
{ {
return PartialView(new FooterModel { BuildTime = _environmentProvider.BuildDateTime, Version = _environmentProvider.Version }); return PartialView(new FooterModel { BuildTime = _environmentProvider.BuildDateTime, Version = _environmentProvider.Version });
} }
[ChildActionOnly]
//[OutputCache(Duration = 600)]
public ActionResult FreeSpace()
{
var rootDirs = _rootDirProvider.AllWithFreeSpace();
return PartialView(rootDirs);
}
} }
} }

View File

@ -418,6 +418,7 @@
<Content Include="Views\System\Indexers.cshtml" /> <Content Include="Views\System\Indexers.cshtml" />
<Content Include="Views\System\Config.cshtml" /> <Content Include="Views\System\Config.cshtml" />
<Content Include="Views\Settings\_SettingsLayout.cshtml" /> <Content Include="Views\Settings\_SettingsLayout.cshtml" />
<Content Include="Views\Shared\FreeSpace.cshtml" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<Folder Include="App_Data\" /> <Folder Include="App_Data\" />

View File

@ -0,0 +1,15 @@
@using NzbDrone.Core
@model IEnumerable<NzbDrone.Core.Repository.RootDir>
@{
Layout = null;
}
@{
foreach(var rootDir in Model)
{
<div class="free-space" title="@rootDir.Path">
@rootDir.FreeSpace.ToBestFileSize(1) <span>Free</span>
</div>
}
}

View File

@ -32,8 +32,14 @@
@MvcHtmlString.Create(Html.CurrentControllerLink("Logs", "Index", "Log")) @MvcHtmlString.Create(Html.CurrentControllerLink("Logs", "Index", "Log"))
<li id="donate" title="Donate to support the development of NzbDrone"><a href="https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=KRTE52U3XJDSQ" target="_blank">Donate</a></li> <li id="donate" title="Donate to support the development of NzbDrone"><a href="https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=KRTE52U3XJDSQ" target="_blank">Donate</a></li>
</ul> </ul>
<input id="localSeriesLookup" type="text" />
</div> </div>
<div id="right-menu">
<ul>
<li>@{ Html.RenderAction("FreeSpace", "Shared"); }</li>
<li><input id="localSeriesLookup" type="text" /></li>
</ul>
</div>
<div id="logo"> <div id="logo">
<span>@ViewBag.Title</span> <span>@ViewBag.Title</span>
</div> </div>