diff --git a/WebsitePanel/Sources/WebsitePanel.WebDav.Core/IHierarchyItem.cs b/WebsitePanel/Sources/WebsitePanel.WebDav.Core/IHierarchyItem.cs index 94f7348f..55369709 100644 --- a/WebsitePanel/Sources/WebsitePanel.WebDav.Core/IHierarchyItem.cs +++ b/WebsitePanel/Sources/WebsitePanel.WebDav.Core/IHierarchyItem.cs @@ -17,8 +17,9 @@ namespace WebsitePanel.WebDav.Core DateTime CreationDate { get; } string CreatorDisplayName { get; } string DisplayName { get; } + bool IsRootItem { get; set; } Uri Href { get; } - ItemType ItemType { get; } + ItemType ItemType { get;} DateTime LastModified { get; } Property[] Properties { get; } @@ -73,6 +74,8 @@ namespace WebsitePanel.WebDav.Core } } + public bool IsRootItem { get; set; } + public Uri Href { get { return _href; } diff --git a/WebsitePanel/Sources/WebsitePanel.WebDav.Core/IItemContent.cs b/WebsitePanel/Sources/WebsitePanel.WebDav.Core/IItemContent.cs index 1a2d8e84..399aeba0 100644 --- a/WebsitePanel/Sources/WebsitePanel.WebDav.Core/IItemContent.cs +++ b/WebsitePanel/Sources/WebsitePanel.WebDav.Core/IItemContent.cs @@ -7,6 +7,7 @@ namespace WebsitePanel.WebDav.Core public interface IItemContent { long ContentLength { get; } + long AllocatedSpace { get; set; } string ContentType { get; } void Download(string filename); diff --git a/WebsitePanel/Sources/WebsitePanel.WebDav.Core/IResource.cs b/WebsitePanel/Sources/WebsitePanel.WebDav.Core/IResource.cs index b105483a..6766553b 100644 --- a/WebsitePanel/Sources/WebsitePanel.WebDav.Core/IResource.cs +++ b/WebsitePanel/Sources/WebsitePanel.WebDav.Core/IResource.cs @@ -64,6 +64,7 @@ namespace WebsitePanel.WebDav.Core public long ContentLength { get { return _contentLength; } + set { _contentLength = value; } } public string ContentType @@ -250,14 +251,19 @@ namespace WebsitePanel.WebDav.Core } } + public long AllocatedSpace { get; set; } + public bool IsRootItem { get; set; } + public Uri Href { get { return _href; } + set { SetHref(value.ToString(), new Uri(value.Scheme + "://" + value.Host + value.Segments[0] + value.Segments[1])); } } public ItemType ItemType { get { return _itemType; } + set { _itemType = value; } } public DateTime LastModified diff --git a/WebsitePanel/Sources/WebsitePanel.WebDav.Core/Managers/WebDavManager.cs b/WebsitePanel/Sources/WebsitePanel.WebDav.Core/Managers/WebDavManager.cs index 43567727..fc6ab6ff 100644 --- a/WebsitePanel/Sources/WebsitePanel.WebDav.Core/Managers/WebDavManager.cs +++ b/WebsitePanel/Sources/WebsitePanel.WebDav.Core/Managers/WebDavManager.cs @@ -42,7 +42,25 @@ namespace WebsitePanel.WebDav.Core.Managers if (string.IsNullOrWhiteSpace(pathPart)) { - children = ConnectToWebDavServer().Select(x => new WebDavHierarchyItem { Href = new Uri(x.Url), ItemType = ItemType.Folder }).ToArray(); + var resources = ConnectToWebDavServer().Select(x => new WebDavResource { Href = new Uri(x.Url), ItemType = ItemType.Folder }).ToArray(); + + var items = WSP.Services.EnterpriseStorage.GetEnterpriseFolders(WspContext.User.ItemId); + + foreach (var resource in resources) + { + var folder = items.FirstOrDefault(x => x.Name == resource.DisplayName); + + if (folder == null) + { + continue; + } + + resource.ContentLength = folder.Size; + resource.AllocatedSpace = folder.FRSMQuotaMB; + resource.IsRootItem = true; + } + + children = resources; } else { diff --git a/WebsitePanel/Sources/WebsitePanel.WebDavPortal/Content/Site.css b/WebsitePanel/Sources/WebsitePanel.WebDavPortal/Content/Site.css index 2389aea4..88729f71 100644 --- a/WebsitePanel/Sources/WebsitePanel.WebDavPortal/Content/Site.css +++ b/WebsitePanel/Sources/WebsitePanel.WebDavPortal/Content/Site.css @@ -45,4 +45,13 @@ textarea { #logout :hover { color: white; +} + + +.web-dav-folder-progress { + margin-bottom: 0px; +} + +.modal-vertical-centered { + margin-top: 25%; } \ No newline at end of file diff --git a/WebsitePanel/Sources/WebsitePanel.WebDavPortal/Controllers/FileSystemController.cs b/WebsitePanel/Sources/WebsitePanel.WebDavPortal/Controllers/FileSystemController.cs index 29405582..2ac65019 100644 --- a/WebsitePanel/Sources/WebsitePanel.WebDavPortal/Controllers/FileSystemController.cs +++ b/WebsitePanel/Sources/WebsitePanel.WebDavPortal/Controllers/FileSystemController.cs @@ -7,6 +7,7 @@ using System.Net.Mime; using System.Web; using System.Web.Mvc; using System.Web.Routing; +using log4net; using WebsitePanel.WebDav.Core; using WebsitePanel.WebDav.Core.Client; using WebsitePanel.WebDav.Core.Config; @@ -32,6 +33,7 @@ namespace WebsitePanel.WebDavPortal.Controllers private readonly IAuthenticationService _authenticationService; private readonly IAccessTokenManager _tokenManager; private readonly IWebDavAuthorizationService _webDavAuthorizationService; + private readonly ILog Log; public FileSystemController(ICryptography cryptography, IWebDavManager webdavManager, IAuthenticationService authenticationService, IAccessTokenManager tokenManager, IWebDavAuthorizationService webDavAuthorizationService) { @@ -40,6 +42,8 @@ namespace WebsitePanel.WebDavPortal.Controllers _authenticationService = authenticationService; _tokenManager = tokenManager; _webDavAuthorizationService = webDavAuthorizationService; + + Log = LogManager.GetLogger(this.GetType()); } [HttpGet] diff --git a/WebsitePanel/Sources/WebsitePanel.WebDavPortal/UI/Resources.Designer.cs b/WebsitePanel/Sources/WebsitePanel.WebDavPortal/UI/Resources.Designer.cs index 0fa7cc7a..8c1b3158 100644 --- a/WebsitePanel/Sources/WebsitePanel.WebDavPortal/UI/Resources.Designer.cs +++ b/WebsitePanel/Sources/WebsitePanel.WebDavPortal/UI/Resources.Designer.cs @@ -87,6 +87,15 @@ namespace WebsitePanel.WebDavPortal.UI { } } + /// + /// Looks up a localized string similar to Gb. + /// + public static string GigabyteShort { + get { + return ResourceManager.GetString("GigabyteShort", resourceCulture); + } + } + /// /// Looks up a localized string similar to Processing. /// diff --git a/WebsitePanel/Sources/WebsitePanel.WebDavPortal/UI/Resources.resx b/WebsitePanel/Sources/WebsitePanel.WebDavPortal/UI/Resources.resx index f11f7791..8329ece5 100644 --- a/WebsitePanel/Sources/WebsitePanel.WebDavPortal/UI/Resources.resx +++ b/WebsitePanel/Sources/WebsitePanel.WebDavPortal/UI/Resources.resx @@ -126,6 +126,9 @@ File Upload + + Gb + Processing diff --git a/WebsitePanel/Sources/WebsitePanel.WebDavPortal/Views/FileSystem/_ResoursePartial.cshtml b/WebsitePanel/Sources/WebsitePanel.WebDavPortal/Views/FileSystem/_ResoursePartial.cshtml index 7d1abcf1..674917d1 100644 --- a/WebsitePanel/Sources/WebsitePanel.WebDavPortal/Views/FileSystem/_ResoursePartial.cshtml +++ b/WebsitePanel/Sources/WebsitePanel.WebDavPortal/Views/FileSystem/_ResoursePartial.cshtml @@ -3,6 +3,7 @@ @using WebsitePanel.WebDav.Core.Config @using WebsitePanel.WebDavPortal.FileOperations @using Ninject; +@using WebsitePanel.WebDavPortal.UI @using WebsitePanel.WebDavPortal.UI.Routes @model IHierarchyItem @@ -24,10 +25,31 @@ href = Model.Href.AbsolutePath; break; } + + var resource = Model as IResource; + + bool showStatistic = Model.ItemType == ItemType.Folder && Model.IsRootItem && resource != null; + + int percent = 0; + + if (showStatistic) + { + percent = (int)(resource.AllocatedSpace != 0 ? 100 * resource.ContentLength / resource.AllocatedSpace : 0); + } } +

@name

+ @if (showStatistic) + { +
+
+ @percent% +
+
+

@Math.Round(Convert.ToDecimal(resource.ContentLength) / 1024, 2) / @Math.Round(Convert.ToDecimal(resource.AllocatedSpace) / 1024, 2) @Resources.GigabyteShort

+ }
\ No newline at end of file diff --git a/WebsitePanel/Sources/WebsitePanel.WebDavPortal/Views/Shared/_ProcessDialog.cshtml b/WebsitePanel/Sources/WebsitePanel.WebDavPortal/Views/Shared/_ProcessDialog.cshtml index b26ffd6f..9ef40b84 100644 --- a/WebsitePanel/Sources/WebsitePanel.WebDavPortal/Views/Shared/_ProcessDialog.cshtml +++ b/WebsitePanel/Sources/WebsitePanel.WebDavPortal/Views/Shared/_ProcessDialog.cshtml @@ -1,10 +1,16 @@ @using WebsitePanel.WebDavPortal.UI -