webdav portal statistic added

This commit is contained in:
vfedosevich 2015-01-20 04:51:23 -08:00
parent a882072b02
commit d82dfbfb56
11 changed files with 87 additions and 6 deletions

View file

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

View file

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

View file

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

View file

@ -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
{

View file

@ -46,3 +46,12 @@ textarea {
#logout :hover {
color: white;
}
.web-dav-folder-progress {
margin-bottom: 0px;
}
.modal-vertical-centered {
margin-top: 25%;
}

View file

@ -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]

View file

@ -87,6 +87,15 @@ namespace WebsitePanel.WebDavPortal.UI {
}
}
/// <summary>
/// Looks up a localized string similar to Gb.
/// </summary>
public static string GigabyteShort {
get {
return ResourceManager.GetString("GigabyteShort", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to Processing.
/// </summary>

View file

@ -126,6 +126,9 @@
<data name="FileUpload" xml:space="preserve">
<value>File Upload</value>
</data>
<data name="GigabyteShort" xml:space="preserve">
<value>Gb</value>
</data>
<data name="Processing" xml:space="preserve">
<value>Processing</value>
</data>

View file

@ -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);
}
}
<div class="col-sm-2 element-container">
<a href="@href" @Html.Raw(isTargetBlank ? "target=\"_blank\"" : string.Empty) title="@name">
<img class="icon-size" src="@Url.Content(actualPath)" />
<p style="word-wrap: break-word;">@name</p>
</a>
@if (showStatistic)
{
<div class="progress web-dav-folder-progress">
<div class="progress-bar" role="progressbar" aria-valuenow="@percent" aria-valuemin="0" aria-valuemax="100" style="width: @percent%;">
@percent%
</div>
</div>
<p>@Math.Round(Convert.ToDecimal(resource.ContentLength) / 1024, 2) / @Math.Round(Convert.ToDecimal(resource.AllocatedSpace) / 1024, 2) @Resources.GigabyteShort</p>
}
</div>

View file

@ -1,10 +1,16 @@
@using WebsitePanel.WebDavPortal.UI
<div id="processDialog" class="modal fade" tabindex="-1" role="dialog" data-backdrop="static" data-keyboard="false" aria-hidden="true" style="display: none;">
<div class="modal-dialog">
<div id="processDialog" class="modal fade" tabindex="-1" role="dialog" aria-labelledby="modal-process-dialog-title" data-backdrop="static" data-keyboard="false" aria-hidden="true" style="display: none;">
<div class="modal-dialog modal-vertical-centered">
<div class="modal-content">
<div class="modal-header">
<h4 class="modal-title" id="modal-process-dialog-title">@Resources.ProcessingWithDots</h4>
</div>
<div class="modal-body">
<h4 class="modal-title">@Resources.ProcessingWithDots</h4>
<div class="progress progress-striped active">
<div class="progress-bar" role="progressbar" aria-valuenow="100" aria-valuemin="0" aria-valuemax="100" style="width: 100%;">
</div>
</div>
</div>
</div><!-- /.modal-content -->
</div><!-- /.modal-dialog -->

View file

@ -264,7 +264,7 @@
<Content Include="Views\FileSystem\ShowOfficeDocument.cshtml" />
<Content Include="Views\FileSystem\_ResourseCollectionPartial.cshtml" />
<Content Include="Views\FileSystem\_ResoursePartial.cshtml" />
<Content Include="Views\Shared\ProcessDialog.cshtml" />
<Content Include="Views\Shared\_ProcessDialog.cshtml" />
</ItemGroup>
<ItemGroup>
<Folder Include="Views\Owa\" />