webdav portal owa fixes
This commit is contained in:
parent
2968fbb967
commit
eb8c879605
6 changed files with 48 additions and 24 deletions
|
@ -190,6 +190,8 @@ namespace WebsitePanel.WebDav.Core.Managers
|
|||
public void DeleteResource(string path)
|
||||
{
|
||||
path = RemoveLeadingFromPath(path, "office365");
|
||||
path = RemoveLeadingFromPath(path, "view");
|
||||
path = RemoveLeadingFromPath(path, "edit");
|
||||
path = RemoveLeadingFromPath(path, WspContext.User.OrganizationId);
|
||||
|
||||
string folderPath = GetFileFolder(path);
|
||||
|
|
|
@ -45,11 +45,23 @@ namespace WebsitePanel.WebDavPortal
|
|||
);
|
||||
|
||||
routes.MapRoute(
|
||||
name: FileSystemRouteNames.ShowOfficeOnlinePath,
|
||||
url: "office365/{org}/{*pathPart}",
|
||||
defaults: new { controller = "FileSystem", action = "ShowOfficeDocument", pathPart = UrlParameter.Optional }
|
||||
name: FileSystemRouteNames.ViewOfficeOnline,
|
||||
url: "office365/view/{org}/{*pathPart}",
|
||||
defaults: new { controller = "FileSystem", action = "ViewOfficeDocument", pathPart = UrlParameter.Optional }
|
||||
);
|
||||
|
||||
routes.MapRoute(
|
||||
name: FileSystemRouteNames.EditOfficeOnline,
|
||||
url: "office365/edit/{org}/{*pathPart}",
|
||||
defaults: new { controller = "FileSystem", action = "EditOfficeDocument", pathPart = UrlParameter.Optional }
|
||||
);
|
||||
|
||||
//routes.MapRoute(
|
||||
// name: FileSystemRouteNames.ShowOfficeOnlinePath,
|
||||
// url: "office365/{org}/{*pathPart}",
|
||||
// defaults: new { controller = "FileSystem", action = "ShowOfficeDocument", pathPart = UrlParameter.Optional }
|
||||
// );
|
||||
|
||||
routes.MapRoute(
|
||||
name: FileSystemRouteNames.ShowAdditionalContent,
|
||||
url: "show-additional-content/{*path}",
|
||||
|
|
|
@ -177,8 +177,8 @@ namespace WebsitePanel.WebDavPortal.Controllers.Api
|
|||
|
||||
var newToken = _tokenManager.CreateToken(WspContext.User,newFilePath);
|
||||
|
||||
var readUrlPart = Url.Route(FileSystemRouteNames.ShowOfficeOnlinePath, new { org = WspContext.User.OrganizationId, pathPart = newFilePath, fileAccess = FileAccess.Read });
|
||||
var writeUrlPart = Url.Route(FileSystemRouteNames.ShowOfficeOnlinePath, new { org = WspContext.User.OrganizationId, pathPart = newFilePath, fileAccess = FileAccess.Write });
|
||||
var readUrlPart = Url.Route(FileSystemRouteNames.ViewOfficeOnline, new { org = WspContext.User.OrganizationId, pathPart = newFilePath});
|
||||
var writeUrlPart = Url.Route(FileSystemRouteNames.EditOfficeOnline, new { org = WspContext.User.OrganizationId, pathPart = newFilePath });
|
||||
|
||||
result.HostEditUrl = new Uri(Request.RequestUri, writeUrlPart).ToString();
|
||||
result.HostViewUrl = new Uri(Request.RequestUri, readUrlPart).ToString(); ;
|
||||
|
|
|
@ -4,6 +4,7 @@ using System.Diagnostics;
|
|||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Net.Mime;
|
||||
using System.Security.Policy;
|
||||
using System.Web;
|
||||
using System.Web.Mvc;
|
||||
using System.Web.Routing;
|
||||
|
@ -83,12 +84,8 @@ namespace WebsitePanel.WebDavPortal.Controllers
|
|||
}
|
||||
}
|
||||
|
||||
public ActionResult ShowOfficeDocument(string org, string pathPart = "", FileAccess? fileAccess = null)
|
||||
public ActionResult ShowOfficeDocument(string org, string pathPart, string owaOpenerUri)
|
||||
{
|
||||
var permissions = _webDavAuthorizationService.GetPermissions(WspContext.User, pathPart);
|
||||
|
||||
var owaOpener = WebDavAppConfigManager.Instance.OfficeOnline.Single(x => x.Extension == Path.GetExtension(pathPart));
|
||||
|
||||
string fileUrl = WebDavAppConfigManager.Instance.WebdavRoot+ org + "/" + pathPart.TrimStart('/');
|
||||
var accessToken = _tokenManager.CreateToken(WspContext.User, pathPart);
|
||||
|
||||
|
@ -97,22 +94,32 @@ namespace WebsitePanel.WebDavPortal.Controllers
|
|||
|
||||
string wopiSrc = Server.UrlDecode(url);
|
||||
|
||||
string owaOpenerUri = string.Empty;
|
||||
|
||||
if (fileAccess == null)
|
||||
{
|
||||
owaOpenerUri = permissions.HasFlag(WebDavPermissions.Write) ? owaOpener.OwaEditor : owaOpener.OwaView;
|
||||
}
|
||||
else
|
||||
{
|
||||
owaOpenerUri = permissions.HasFlag(WebDavPermissions.Write) && fileAccess == FileAccess.Write ? owaOpener.OwaEditor : owaOpener.OwaView;
|
||||
}
|
||||
|
||||
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();
|
||||
|
||||
return View(new OfficeOnlineModel(uri, fileName));
|
||||
return View("ShowOfficeDocument", new OfficeOnlineModel(uri, fileName));
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
public ActionResult EditOfficeDocument(string org, string pathPart)
|
||||
{
|
||||
var permissions = _webDavAuthorizationService.GetPermissions(WspContext.User, pathPart);
|
||||
|
||||
if (permissions.HasFlag(WebDavPermissions.Write) == false)
|
||||
{
|
||||
return new RedirectToRouteResult(FileSystemRouteNames.ViewOfficeOnline, null);
|
||||
}
|
||||
|
||||
var owaOpener = WebDavAppConfigManager.Instance.OfficeOnline.Single(x => x.Extension == Path.GetExtension(pathPart));
|
||||
|
||||
return ShowOfficeDocument(org, pathPart, owaOpener.OwaEditor);
|
||||
}
|
||||
|
||||
[HttpPost]
|
||||
|
|
|
@ -8,7 +8,10 @@ namespace WebsitePanel.WebDavPortal.UI.Routes
|
|||
public class FileSystemRouteNames
|
||||
{
|
||||
public const string ShowContentPath = "ShowContentRoute";
|
||||
public const string ShowOfficeOnlinePath = "ShowOfficeOnlineRoute";
|
||||
public const string ShowOfficeOnlinePath_ = "ShowOfficeOnlineRoute";
|
||||
public const string ViewOfficeOnline = "ViewOfficeOnlineRoute";
|
||||
public const string EditOfficeOnline = "EditOfficeOnlineRoute";
|
||||
|
||||
public const string ShowAdditionalContent = "ShowAdditionalContentRoute";
|
||||
|
||||
public const string UploadFile = "UplaodFIleRoute";
|
||||
|
|
|
@ -18,7 +18,7 @@
|
|||
case FileOpenerType.OfficeOnline:
|
||||
isTargetBlank = true;
|
||||
var pathPart = Model.Href.AbsolutePath.Replace("/" + WspContext.User.OrganizationId, "").TrimStart('/');
|
||||
href = string.Concat(Url.RouteUrl(FileSystemRouteNames.ShowOfficeOnlinePath, new { org = WspContext.User.OrganizationId, pathPart = "" }), pathPart);
|
||||
href = string.Concat(Url.RouteUrl(FileSystemRouteNames.EditOfficeOnline, new { org = WspContext.User.OrganizationId, pathPart = "" }), pathPart);
|
||||
break;
|
||||
default:
|
||||
isTargetBlank = false;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue