webdav portal statistic added
This commit is contained in:
parent
a882072b02
commit
d82dfbfb56
11 changed files with 87 additions and 6 deletions
|
@ -17,8 +17,9 @@ namespace WebsitePanel.WebDav.Core
|
||||||
DateTime CreationDate { get; }
|
DateTime CreationDate { get; }
|
||||||
string CreatorDisplayName { get; }
|
string CreatorDisplayName { get; }
|
||||||
string DisplayName { get; }
|
string DisplayName { get; }
|
||||||
|
bool IsRootItem { get; set; }
|
||||||
Uri Href { get; }
|
Uri Href { get; }
|
||||||
ItemType ItemType { get; }
|
ItemType ItemType { get;}
|
||||||
DateTime LastModified { get; }
|
DateTime LastModified { get; }
|
||||||
Property[] Properties { get; }
|
Property[] Properties { get; }
|
||||||
|
|
||||||
|
@ -73,6 +74,8 @@ namespace WebsitePanel.WebDav.Core
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public bool IsRootItem { get; set; }
|
||||||
|
|
||||||
public Uri Href
|
public Uri Href
|
||||||
{
|
{
|
||||||
get { return _href; }
|
get { return _href; }
|
||||||
|
|
|
@ -7,6 +7,7 @@ namespace WebsitePanel.WebDav.Core
|
||||||
public interface IItemContent
|
public interface IItemContent
|
||||||
{
|
{
|
||||||
long ContentLength { get; }
|
long ContentLength { get; }
|
||||||
|
long AllocatedSpace { get; set; }
|
||||||
string ContentType { get; }
|
string ContentType { get; }
|
||||||
|
|
||||||
void Download(string filename);
|
void Download(string filename);
|
||||||
|
|
|
@ -64,6 +64,7 @@ namespace WebsitePanel.WebDav.Core
|
||||||
public long ContentLength
|
public long ContentLength
|
||||||
{
|
{
|
||||||
get { return _contentLength; }
|
get { return _contentLength; }
|
||||||
|
set { _contentLength = value; }
|
||||||
}
|
}
|
||||||
|
|
||||||
public string ContentType
|
public string ContentType
|
||||||
|
@ -250,14 +251,19 @@ namespace WebsitePanel.WebDav.Core
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public long AllocatedSpace { get; set; }
|
||||||
|
public bool IsRootItem { get; set; }
|
||||||
|
|
||||||
public Uri Href
|
public Uri Href
|
||||||
{
|
{
|
||||||
get { return _href; }
|
get { return _href; }
|
||||||
|
set { SetHref(value.ToString(), new Uri(value.Scheme + "://" + value.Host + value.Segments[0] + value.Segments[1])); }
|
||||||
}
|
}
|
||||||
|
|
||||||
public ItemType ItemType
|
public ItemType ItemType
|
||||||
{
|
{
|
||||||
get { return _itemType; }
|
get { return _itemType; }
|
||||||
|
set { _itemType = value; }
|
||||||
}
|
}
|
||||||
|
|
||||||
public DateTime LastModified
|
public DateTime LastModified
|
||||||
|
|
|
@ -42,7 +42,25 @@ namespace WebsitePanel.WebDav.Core.Managers
|
||||||
|
|
||||||
if (string.IsNullOrWhiteSpace(pathPart))
|
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
|
else
|
||||||
{
|
{
|
||||||
|
|
|
@ -45,4 +45,13 @@ textarea {
|
||||||
|
|
||||||
#logout :hover {
|
#logout :hover {
|
||||||
color: white;
|
color: white;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
.web-dav-folder-progress {
|
||||||
|
margin-bottom: 0px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.modal-vertical-centered {
|
||||||
|
margin-top: 25%;
|
||||||
}
|
}
|
|
@ -7,6 +7,7 @@ using System.Net.Mime;
|
||||||
using System.Web;
|
using System.Web;
|
||||||
using System.Web.Mvc;
|
using System.Web.Mvc;
|
||||||
using System.Web.Routing;
|
using System.Web.Routing;
|
||||||
|
using log4net;
|
||||||
using WebsitePanel.WebDav.Core;
|
using WebsitePanel.WebDav.Core;
|
||||||
using WebsitePanel.WebDav.Core.Client;
|
using WebsitePanel.WebDav.Core.Client;
|
||||||
using WebsitePanel.WebDav.Core.Config;
|
using WebsitePanel.WebDav.Core.Config;
|
||||||
|
@ -32,6 +33,7 @@ namespace WebsitePanel.WebDavPortal.Controllers
|
||||||
private readonly IAuthenticationService _authenticationService;
|
private readonly IAuthenticationService _authenticationService;
|
||||||
private readonly IAccessTokenManager _tokenManager;
|
private readonly IAccessTokenManager _tokenManager;
|
||||||
private readonly IWebDavAuthorizationService _webDavAuthorizationService;
|
private readonly IWebDavAuthorizationService _webDavAuthorizationService;
|
||||||
|
private readonly ILog Log;
|
||||||
|
|
||||||
public FileSystemController(ICryptography cryptography, IWebDavManager webdavManager, IAuthenticationService authenticationService, IAccessTokenManager tokenManager, IWebDavAuthorizationService webDavAuthorizationService)
|
public FileSystemController(ICryptography cryptography, IWebDavManager webdavManager, IAuthenticationService authenticationService, IAccessTokenManager tokenManager, IWebDavAuthorizationService webDavAuthorizationService)
|
||||||
{
|
{
|
||||||
|
@ -40,6 +42,8 @@ namespace WebsitePanel.WebDavPortal.Controllers
|
||||||
_authenticationService = authenticationService;
|
_authenticationService = authenticationService;
|
||||||
_tokenManager = tokenManager;
|
_tokenManager = tokenManager;
|
||||||
_webDavAuthorizationService = webDavAuthorizationService;
|
_webDavAuthorizationService = webDavAuthorizationService;
|
||||||
|
|
||||||
|
Log = LogManager.GetLogger(this.GetType());
|
||||||
}
|
}
|
||||||
|
|
||||||
[HttpGet]
|
[HttpGet]
|
||||||
|
|
|
@ -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>
|
/// <summary>
|
||||||
/// Looks up a localized string similar to Processing.
|
/// Looks up a localized string similar to Processing.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|
|
@ -126,6 +126,9 @@
|
||||||
<data name="FileUpload" xml:space="preserve">
|
<data name="FileUpload" xml:space="preserve">
|
||||||
<value>File Upload</value>
|
<value>File Upload</value>
|
||||||
</data>
|
</data>
|
||||||
|
<data name="GigabyteShort" xml:space="preserve">
|
||||||
|
<value>Gb</value>
|
||||||
|
</data>
|
||||||
<data name="Processing" xml:space="preserve">
|
<data name="Processing" xml:space="preserve">
|
||||||
<value>Processing</value>
|
<value>Processing</value>
|
||||||
</data>
|
</data>
|
||||||
|
|
|
@ -3,6 +3,7 @@
|
||||||
@using WebsitePanel.WebDav.Core.Config
|
@using WebsitePanel.WebDav.Core.Config
|
||||||
@using WebsitePanel.WebDavPortal.FileOperations
|
@using WebsitePanel.WebDavPortal.FileOperations
|
||||||
@using Ninject;
|
@using Ninject;
|
||||||
|
@using WebsitePanel.WebDavPortal.UI
|
||||||
@using WebsitePanel.WebDavPortal.UI.Routes
|
@using WebsitePanel.WebDavPortal.UI.Routes
|
||||||
@model IHierarchyItem
|
@model IHierarchyItem
|
||||||
|
|
||||||
|
@ -24,10 +25,31 @@
|
||||||
href = Model.Href.AbsolutePath;
|
href = Model.Href.AbsolutePath;
|
||||||
break;
|
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">
|
<div class="col-sm-2 element-container">
|
||||||
<a href="@href" @Html.Raw(isTargetBlank ? "target=\"_blank\"" : string.Empty) title="@name">
|
<a href="@href" @Html.Raw(isTargetBlank ? "target=\"_blank\"" : string.Empty) title="@name">
|
||||||
<img class="icon-size" src="@Url.Content(actualPath)" />
|
<img class="icon-size" src="@Url.Content(actualPath)" />
|
||||||
<p style="word-wrap: break-word;">@name</p>
|
<p style="word-wrap: break-word;">@name</p>
|
||||||
</a>
|
</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>
|
</div>
|
|
@ -1,10 +1,16 @@
|
||||||
@using WebsitePanel.WebDavPortal.UI
|
@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 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">
|
<div class="modal-dialog modal-vertical-centered">
|
||||||
<div class="modal-content">
|
<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">
|
<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>
|
||||||
</div><!-- /.modal-content -->
|
</div><!-- /.modal-content -->
|
||||||
</div><!-- /.modal-dialog -->
|
</div><!-- /.modal-dialog -->
|
||||||
|
|
|
@ -264,7 +264,7 @@
|
||||||
<Content Include="Views\FileSystem\ShowOfficeDocument.cshtml" />
|
<Content Include="Views\FileSystem\ShowOfficeDocument.cshtml" />
|
||||||
<Content Include="Views\FileSystem\_ResourseCollectionPartial.cshtml" />
|
<Content Include="Views\FileSystem\_ResourseCollectionPartial.cshtml" />
|
||||||
<Content Include="Views\FileSystem\_ResoursePartial.cshtml" />
|
<Content Include="Views\FileSystem\_ResoursePartial.cshtml" />
|
||||||
<Content Include="Views\Shared\ProcessDialog.cshtml" />
|
<Content Include="Views\Shared\_ProcessDialog.cshtml" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<Folder Include="Views\Owa\" />
|
<Folder Include="Views\Owa\" />
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue