webdav portal mobile view added, content type counted

This commit is contained in:
vfedosevich 2015-02-25 02:36:39 -08:00
parent 4122caa16d
commit 346059195e
13 changed files with 111 additions and 41 deletions

View file

@ -7,6 +7,7 @@ namespace WebsitePanel.WebDavPortal.WebConfigSections
private const string ExtensionKey = "extension";
private const string OwaViewKey = "OwaView";
private const string OwaEditorKey = "OwaEditor";
private const string OwaMobileViewKey = "OwaMobileView";
[ConfigurationProperty(ExtensionKey, IsKey = true, IsRequired = true)]
public string Extension
@ -28,5 +29,13 @@ namespace WebsitePanel.WebDavPortal.WebConfigSections
get { return this[OwaEditorKey].ToString(); }
set { this[OwaEditorKey] = value; }
}
[ConfigurationProperty(OwaMobileViewKey, IsKey = true, IsRequired = true)]
public string OwaMobileViev
{
get { return this[OwaMobileViewKey].ToString(); }
set { this[OwaMobileViewKey] = value; }
}
}
}

View file

@ -418,6 +418,7 @@ namespace WebsitePanel.WebDav.Core
SetComment(item.Comment);
SetCreatorDisplayName(item.CreatorDisplayName);
SetLastModified(item.LastModified);
foreach (Property property in item.Properties)
{
SetProperty(property);

View file

@ -159,7 +159,7 @@ namespace WebsitePanel.WebDav.Core
{
_creationDate = DateTime.Parse(creationDate);
}
public void SetCreationDate(DateTime creationDate)
{
_creationDate = creationDate;

View file

@ -2,6 +2,7 @@
using System.IO;
using System.Linq;
using System.Net;
using System.Net.Mime;
using System.Net.Security;
using System.Net.Sockets;
using System.Reflection;
@ -28,7 +29,6 @@ namespace WebsitePanel.WebDav.Core
private bool _checkedOut = false;
private string _comment = "";
private long _contentLength;
private string _contentType = "";
private DateTime _creationDate = new DateTime(0);
private string _creatorDisplayName = "";
private ICredentials _credentials = new NetworkCredential();
@ -79,7 +79,14 @@ namespace WebsitePanel.WebDav.Core
public string ContentType
{
get { return _contentType; }
get
{
{
var property = _properties.FirstOrDefault(x => x.Name.Name == "getcontenttype");
return property == null ? MediaTypeNames.Application.Octet : property.StringValue;
}
}
}
/// <summary>

View file

@ -47,25 +47,14 @@ namespace WebsitePanel.WebDav.Core.Managers
if (string.IsNullOrWhiteSpace(pathPart))
{
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)
children = ConnectToWebDavServer().Select(x => new WebDavResource
{
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;
Href = new Uri(x.Url),
ItemType = ItemType.Folder,
ContentLength = x.Size,
AllocatedSpace = x.FRSMQuotaMB,
IsRootItem = true
}).ToArray();
}
else
{

View file

@ -27,6 +27,10 @@ textarea {
margin-bottom: 15px;
/*text-align:center;*/
cursor: pointer;
margin-top: 14px;
margin-left: 1px;
margin-right: 1px;
padding: 3px;
}
.element-container .element {
@ -235,6 +239,10 @@ tr.selected-file {
display: none;
}
.file-actions-menu .file-upload {
display: inline-block;
}
#message-area {
margin-top: 15px;
}
@ -249,6 +257,7 @@ tr.selected-file {
}
.search-block {
float: right;
}
.search-block input, .search-block label {
@ -257,6 +266,39 @@ tr.selected-file {
font-weight: normal;
}
.elements-container {
padding-top: 10px;
}
@media (min-width: 768px) {
.col-sm-2.element-container {
width: 15.666667%;
}
}
@media (max-width: 768px) {
.col-sm-2.element-container {
float: left;
width: 48%;
}
}
@media (max-width: 250px) {
.col-sm-2.element-container {
float: left;
width: 100%;
}
}
.back-button {
font-size: 30px;
color: white;
padding-left: 10px;
padding-top: 3px;
display: block;
}
/* Theme Mods */
input,div{border-radius:0px!important;}

View file

@ -15,6 +15,7 @@ using WebsitePanel.WebDav.Core.Client;
using WebsitePanel.WebDav.Core.Config;
using WebsitePanel.WebDav.Core.Entities.Account.Enums;
using WebsitePanel.WebDav.Core.Exceptions;
using WebsitePanel.WebDav.Core.Extensions;
using WebsitePanel.WebDav.Core.Interfaces.Managers;
using WebsitePanel.WebDav.Core.Interfaces.Managers.Users;
using WebsitePanel.WebDav.Core.Interfaces.Security;
@ -79,12 +80,11 @@ namespace WebsitePanel.WebDavPortal.Controllers
return new HttpStatusCodeResult(HttpStatusCode.NoContent);
}
string fileName = pathPart.Split('/').Last();
if (_webdavManager.IsFile(pathPart))
{
var fileBytes = _webdavManager.GetFileBytes(pathPart);
return File(fileBytes, MediaTypeNames.Application.Octet, fileName);
var resource = _webdavManager.GetResource(pathPart);
return new FileStreamResult(resource.GetReadStream(), resource.ContentType);
}
try
@ -293,22 +293,25 @@ namespace WebsitePanel.WebDavPortal.Controllers
var uri = string.Format("{0}/{1}WOPISrc={2}&access_token={3}", WebDavAppConfigManager.Instance.OfficeOnline.Url, owaOpenerUri, Server.UrlEncode(wopiSrc), Server.UrlEncode(accessToken.AccessToken.ToString("N")));
string fileName = fileUrl.Split('/').Last();
string folder = pathPart.ReplaceLast(fileName, "").Trim('/');
return View("ShowOfficeDocument", new OfficeOnlineModel(uri, fileName));
return View("ShowOfficeDocument", new OfficeOnlineModel(uri, fileName, folder));
}
public ActionResult ViewOfficeDocument(string org, string pathPart)
{
var owaOpener = WebDavAppConfigManager.Instance.OfficeOnline.Single(x => x.Extension == Path.GetExtension(pathPart));
return ShowOfficeDocument(org, pathPart, owaOpener.OwaView);
var owaOpenerUrl = Request.Browser.IsMobileDevice ? owaOpener.OwaMobileViev : owaOpener.OwaView;
return ShowOfficeDocument(org, pathPart, owaOpenerUrl);
}
public ActionResult EditOfficeDocument(string org, string pathPart)
{
var permissions = _webDavAuthorizationService.GetPermissions(WspContext.User, pathPart);
if (permissions.HasFlag(WebDavPermissions.Write) == false)
if (permissions.HasFlag(WebDavPermissions.Write) == false || Request.Browser.IsMobileDevice)
{
return new RedirectToRouteResult(FileSystemRouteNames.ViewOfficeOnline, null);
}

View file

@ -6,11 +6,13 @@ namespace WebsitePanel.WebDavPortal.Models
{
public string Url { get; set; }
public string FileName { get; set; }
public string Backurl { get; set; }
public OfficeOnlineModel(string url, string fileName)
public OfficeOnlineModel(string url, string fileName, string backUrl)
{
Url = url;
FileName = fileName;
Backurl = backUrl;
}
}
}

View file

@ -19,7 +19,7 @@
else
{
@Html.Partial("_ShowContentTopMenu", Model)
@Html.Action("ContentList", "FileSystem", new { model = Model });
}

View file

@ -1,6 +1,7 @@
@model WebsitePanel.WebDavPortal.Models.OfficeOnlineModel
@using WebsitePanel.WebDavPortal.UI.Routes
@model WebsitePanel.WebDavPortal.Models.OfficeOnlineModel
@{
Layout = null;
Layout = null;
}
<!DOCTYPE html>
@ -8,9 +9,25 @@
<head>
<meta name="viewport" content="width=device-width" />
<title>@Html.Raw(Model.FileName)</title>
@if (Request.Browser.IsMobileDevice)
{
@Styles.Render("~/Content/css")
}
</head>
<body>
<iframe src='@Model.Url' width="100%" height="100%" frameborder='0' style="bottom: 0px; left: 0px; position: fixed; right: 0px; top: 0px;">
@if (Request.Browser.IsMobileDevice)
{
<div class="navbar navbar-inverse navbar-fixed-top">
<div class="container top-container">
<div class="navbar-header">
<a class="back-button" href="@Url.RouteUrl(FileSystemRouteNames.ShowContentPath, new {pathPart = Model.Backurl})">
<i class="glyphicon glyphicon-circle-arrow-left"></i>
</a>
</div>
</div>
</div>
}
<iframe src="@Model.Url" width="100%" height="100%" frameborder='0' style="position: absolute;top: 0;left: 0;bottom: 0;right: 0; @(Request.Browser.IsMobileDevice ? "margin-top: 50px;" : "")">
This is an embedded
<a target='_blank' href='http://office.com'>Microsoft Office</a> document, powered by
<a target='_blank' href='http://office.com/webapps'>Office Web Apps</a>.

View file

@ -17,7 +17,7 @@
switch (opener)
{
case FileOpenerType.OfficeOnline:
isTargetBlank = true;
isTargetBlank = !Request.Browser.IsMobileDevice;
var pathPart = Model.Href.AbsolutePath.Replace("/" + WspContext.User.OrganizationId, "").TrimStart('/');
href = string.Concat(Url.RouteUrl(FileSystemRouteNames.EditOfficeOnline, new { org = WspContext.User.OrganizationId, pathPart = "" }), pathPart);
break;

View file

@ -31,7 +31,7 @@
</div>
}
<div class="navbar-right">
<div class="file-upload navbar-right">
@if (Request.Browser.IsMobileDevice == false)
{
<div class="btn-toolbar change-view-block" role="toolbar">

View file

@ -85,12 +85,12 @@
<add browser="Safari" version="4" />
</owaSupportedBrowsers>
<officeOnline isEnabled="True" url="https://vir-owa.virtuworks.net" cobaltFileTtl="1">
<add extension=".doc" OwaView="wv/wordviewerframe.aspx?" OwaEditor="wv/wordviewerframe.aspx?" />
<add extension=".docx" OwaView="wv/wordviewerframe.aspx?" OwaEditor="we/wordeditorframe.aspx?" />
<add extension=".xls" OwaView="x/_layouts/xlviewerinternal.aspx?" OwaEditor="x/_layouts/xlviewerinternal.aspx?edit=1&amp;" />
<add extension=".xlsx" OwaView="x/_layouts/xlviewerinternal.aspx?" OwaEditor="x/_layouts/xlviewerinternal.aspx?edit=1&amp;" />
<add extension=".ppt" OwaView="p/PowerPointFrame.aspx?" OwaEditor="p/PowerPointFrame.aspx?" />
<add extension=".pptx" OwaView="p/PowerPointFrame.aspx?" OwaEditor="p/PowerPointFrame.aspx?PowerPointView=EditView&amp;" />
<add extension=".doc" OwaView="wv/wordviewerframe.aspx?" OwaEditor="wv/wordviewerframe.aspx?" OwaMobileView="wv/mWord.aspx?wdMobileHost=3&amp;"/>
<add extension=".docx" OwaView="wv/wordviewerframe.aspx?" OwaEditor="we/wordeditorframe.aspx?" OwaMobileView="wv/mWord.aspx?wdMobileHost=3&amp;"/>
<add extension=".xls" OwaView="x/_layouts/xlviewerinternal.aspx?" OwaEditor="x/_layouts/xlviewerinternal.aspx?edit=1&amp;" OwaMobileView="x/_layouts/mobile/mXL.aspx?wdMobileHost=3&amp;"/>
<add extension=".xlsx" OwaView="x/_layouts/xlviewerinternal.aspx?" OwaEditor="x/_layouts/xlviewerinternal.aspx?edit=1&amp;" OwaMobileView="x/_layouts/mobile/mXL.aspx?wdMobileHost=3&amp;" />
<add extension=".ppt" OwaView="p/PowerPointFrame.aspx?" OwaEditor="p/PowerPointFrame.aspx?" OwaMobileView="p/mPPT.aspx?wdMobileHost=3&amp;"/>
<add extension=".pptx" OwaView="p/PowerPointFrame.aspx?" OwaEditor="p/PowerPointFrame.aspx?PowerPointView=EditView&amp;" OwaMobileView="p/mPPT.aspx?wdMobileHost=3&amp;"/>
</officeOnline>
</webDavExplorerConfigurationSettings>
<!--