webdav portal create new ability added
This commit is contained in:
parent
6b1c1660fe
commit
50e902b94d
26 changed files with 473 additions and 38 deletions
|
@ -13,12 +13,14 @@ namespace WebsitePanel.WebDav.Core.Config.Entities
|
|||
{
|
||||
IsEnabled = ConfigSection.OfficeOnline.IsEnabled;
|
||||
Url = ConfigSection.OfficeOnline.Url;
|
||||
NewFilePath = ConfigSection.OfficeOnline.CobaltNewFilePath;
|
||||
CobaltFileTtl = ConfigSection.OfficeOnline.CobaltFileTtl;
|
||||
_officeExtensions = ConfigSection.OfficeOnline.Cast<OfficeOnlineElement>().ToList();
|
||||
}
|
||||
|
||||
public bool IsEnabled { get; private set; }
|
||||
public string Url { get; private set; }
|
||||
public string NewFilePath { get; private set; }
|
||||
public int CobaltFileTtl { get; private set; }
|
||||
|
||||
public IEnumerator<OfficeOnlineElement> GetEnumerator()
|
||||
|
|
|
@ -8,6 +8,7 @@ namespace WebsitePanel.WebDavPortal.WebConfigSections
|
|||
private const string OwaViewKey = "OwaView";
|
||||
private const string OwaEditorKey = "OwaEditor";
|
||||
private const string OwaMobileViewKey = "OwaMobileView";
|
||||
private const string OwaNewFileViewKey = "OwaNewFileView";
|
||||
|
||||
[ConfigurationProperty(ExtensionKey, IsKey = true, IsRequired = true)]
|
||||
public string Extension
|
||||
|
@ -37,5 +38,12 @@ namespace WebsitePanel.WebDavPortal.WebConfigSections
|
|||
get { return this[OwaMobileViewKey].ToString(); }
|
||||
set { this[OwaMobileViewKey] = value; }
|
||||
}
|
||||
|
||||
[ConfigurationProperty(OwaNewFileViewKey, IsKey = true, IsRequired = true)]
|
||||
public string OwaNewFileView
|
||||
{
|
||||
get { return this[OwaNewFileViewKey].ToString(); }
|
||||
set { this[OwaNewFileViewKey] = value; }
|
||||
}
|
||||
}
|
||||
}
|
|
@ -9,6 +9,7 @@ namespace WebsitePanel.WebDavPortal.WebConfigSections
|
|||
private const string UrlKey = "url";
|
||||
private const string IsEnabledKey = "isEnabled";
|
||||
private const string CobaltFileTtlKey = "cobaltFileTtl";
|
||||
private const string CobaltNewFilePathKey = "cobaltNewFilePath";
|
||||
|
||||
[ConfigurationProperty(UrlKey, IsKey = true, IsRequired = true)]
|
||||
public string Url
|
||||
|
@ -24,6 +25,13 @@ namespace WebsitePanel.WebDavPortal.WebConfigSections
|
|||
set { this[IsEnabledKey] = value; }
|
||||
}
|
||||
|
||||
[ConfigurationProperty(CobaltNewFilePathKey, IsKey = true, IsRequired = true)]
|
||||
public string CobaltNewFilePath
|
||||
{
|
||||
get { return this[CobaltNewFilePathKey].ToString(); }
|
||||
set { this[CobaltNewFilePathKey] = value; }
|
||||
}
|
||||
|
||||
[ConfigurationProperty(CobaltFileTtlKey, IsKey = true, IsRequired = true)]
|
||||
public int CobaltFileTtl
|
||||
{
|
||||
|
|
|
@ -37,6 +37,10 @@ namespace WebsitePanel.WebDav.Core.Entities.Owa
|
|||
public bool RestrictedWebViewOnly { get; set; }
|
||||
[DataMember]
|
||||
public string ClientUrl { get; set; }
|
||||
[DataMember]
|
||||
public bool CloseButtonClosesWindow { get; set; }
|
||||
//[DataMember]
|
||||
//public string CloseUrl { get; set; }
|
||||
//[DataMember]
|
||||
//public bool UserCanNotWriteRelative { get; set; }
|
||||
|
||||
|
@ -59,8 +63,7 @@ namespace WebsitePanel.WebDav.Core.Entities.Owa
|
|||
//public string BreadcrumbFolderUrl { get; set; }
|
||||
//[DataMember]
|
||||
//public string ClientUrl { get; set; }
|
||||
//[DataMember]
|
||||
//public bool CloseButtonClosesWindow { get; set; }
|
||||
|
||||
//[DataMember]
|
||||
//public string CloseUrl { get; set; }
|
||||
//[DataMember]
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
using System.Web.Mvc;
|
||||
using WebsitePanel.EnterpriseServer.Base.HostedSolution;
|
||||
using WebsitePanel.WebDav.Core.Client;
|
||||
using WebsitePanel.WebDav.Core.Entities.Owa;
|
||||
|
||||
|
@ -6,7 +6,7 @@ namespace WebsitePanel.WebDav.Core.Interfaces.Owa
|
|||
{
|
||||
public interface IWopiServer
|
||||
{
|
||||
CheckFileInfo GetCheckFileInfo(string path);
|
||||
FileResult GetFile(string path);
|
||||
CheckFileInfo GetCheckFileInfo(WebDavAccessToken token);
|
||||
byte[] GetFileBytes(int accessTokenId);
|
||||
}
|
||||
}
|
|
@ -240,9 +240,9 @@ namespace WebsitePanel.WebDav.Core.Managers
|
|||
|
||||
return _currentFolder.GetResource(resourceName);
|
||||
}
|
||||
catch (InvalidOperationException exception)
|
||||
catch (Exception)
|
||||
{
|
||||
throw new ResourceNotFoundException("Resource not found", exception);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -2,8 +2,10 @@
|
|||
using System.Collections.Concurrent;
|
||||
using System.Collections.Generic;
|
||||
using System.Globalization;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Runtime.Caching;
|
||||
using System.Web;
|
||||
using Cobalt;
|
||||
using WebsitePanel.WebDav.Core.Client;
|
||||
using WebsitePanel.WebDav.Core.Config;
|
||||
|
@ -72,9 +74,20 @@ namespace WebsitePanel.WebDav.Core.Owa
|
|||
|
||||
var token = _tokenManager.GetToken(accessTokenId);
|
||||
|
||||
var fileBytes = _webDavManager.GetFileBytes(token.FilePath);
|
||||
Atom atom;
|
||||
|
||||
var atom = new AtomFromByteArray(fileBytes);
|
||||
if (_webDavManager.FileExist(token.FilePath))
|
||||
{
|
||||
var fileBytes = _webDavManager.GetFileBytes(token.FilePath);
|
||||
|
||||
atom = new AtomFromByteArray(fileBytes);
|
||||
}
|
||||
else
|
||||
{
|
||||
var filePath = HttpContext.Current.Server.MapPath(WebDavAppConfigManager.Instance.OfficeOnline.NewFilePath + Path.GetExtension(token.FilePath));
|
||||
|
||||
atom = new AtomFromByteArray(File.ReadAllBytes(filePath));
|
||||
}
|
||||
|
||||
Cobalt.Metrics o1;
|
||||
cobaltFile.GetCobaltFilePartition(FilePartitionId.Content).SetStream(RootId.Default.Value, atom, out o1);
|
||||
|
|
|
@ -6,6 +6,8 @@ using System.Runtime.Serialization.Json;
|
|||
using System.Text;
|
||||
using System.Web;
|
||||
using System.Web.Mvc;
|
||||
using Cobalt;
|
||||
using WebsitePanel.EnterpriseServer.Base.HostedSolution;
|
||||
using WebsitePanel.WebDav.Core.Client;
|
||||
using WebsitePanel.WebDav.Core.Config;
|
||||
using WebsitePanel.WebDav.Core.Entities.Owa;
|
||||
|
@ -22,27 +24,30 @@ namespace WebsitePanel.WebDav.Core.Owa
|
|||
private readonly IWebDavManager _webDavManager;
|
||||
private readonly IAccessTokenManager _tokenManager;
|
||||
private readonly IWebDavAuthorizationService _webDavAuthorizationService;
|
||||
private readonly IWopiFileManager _fileManager;
|
||||
|
||||
public WopiServer(IWebDavManager webDavManager, IAccessTokenManager tokenManager, IWebDavAuthorizationService webDavAuthorizationService)
|
||||
|
||||
public WopiServer(IWebDavManager webDavManager, IAccessTokenManager tokenManager, IWebDavAuthorizationService webDavAuthorizationService, IWopiFileManager fileManager)
|
||||
{
|
||||
_webDavManager = webDavManager;
|
||||
_tokenManager = tokenManager;
|
||||
_webDavAuthorizationService = webDavAuthorizationService;
|
||||
_fileManager = fileManager;
|
||||
}
|
||||
|
||||
public CheckFileInfo GetCheckFileInfo(string path)
|
||||
public CheckFileInfo GetCheckFileInfo(WebDavAccessToken token)
|
||||
{
|
||||
var resource = _webDavManager.GetResource(path);
|
||||
var resource = _webDavManager.GetResource(token.FilePath);
|
||||
|
||||
var permissions = _webDavAuthorizationService.GetPermissions(WspContext.User, path);
|
||||
var permissions = _webDavAuthorizationService.GetPermissions(WspContext.User, token.FilePath);
|
||||
|
||||
var readOnly = permissions.HasFlag(WebDavPermissions.Write) == false || permissions.HasFlag(WebDavPermissions.OwaEdit) == false;
|
||||
|
||||
var cFileInfo = new CheckFileInfo
|
||||
{
|
||||
BaseFileName = resource.DisplayName.Split(new []{'/'},StringSplitOptions.RemoveEmptyEntries).LastOrDefault(),
|
||||
BaseFileName = resource == null ? token.FilePath.Split('/').Last() : resource.DisplayName.Split(new[] { '/' }, StringSplitOptions.RemoveEmptyEntries).LastOrDefault(),
|
||||
OwnerId = WspContext.User.Login,
|
||||
Size = resource.ContentLength,
|
||||
Size = resource == null ? 0 : resource.ContentLength,
|
||||
Version = DateTime.Now.ToString("s"),
|
||||
SupportsCoauth = true,
|
||||
SupportsCobalt = true,
|
||||
|
@ -53,17 +58,34 @@ namespace WebsitePanel.WebDav.Core.Owa
|
|||
SupportsUpdate = true,
|
||||
UserCanWrite = !readOnly,
|
||||
ReadOnly = readOnly,
|
||||
RestrictedWebViewOnly = false
|
||||
RestrictedWebViewOnly = false,
|
||||
CloseButtonClosesWindow = true
|
||||
};
|
||||
|
||||
if (resource != null)
|
||||
{
|
||||
cFileInfo.ClientUrl = _webDavManager.GetFileUrl(token.FilePath);
|
||||
}
|
||||
|
||||
return cFileInfo;
|
||||
}
|
||||
|
||||
public FileResult GetFile(string path)
|
||||
public byte[] GetFileBytes(int accessTokenId)
|
||||
{
|
||||
var fileBytes = _webDavManager.GetFileBytes(path);
|
||||
var token = _tokenManager.GetToken(accessTokenId);
|
||||
|
||||
return new FileContentResult(fileBytes, MediaTypeNames.Application.Octet);
|
||||
if (_webDavManager.FileExist(token.FilePath))
|
||||
{
|
||||
return _webDavManager.GetFileBytes(token.FilePath);
|
||||
}
|
||||
|
||||
var cobaltFile = _fileManager.Get(token.FilePath) ?? _fileManager.Create(accessTokenId);
|
||||
|
||||
var stream = new MemoryStream();
|
||||
|
||||
new GenericFda(cobaltFile.CobaltEndpoint, null).GetContentStream().CopyTo(stream);
|
||||
|
||||
return stream.ToArray();
|
||||
}
|
||||
}
|
||||
}
|
|
@ -46,6 +46,20 @@ namespace WebsitePanel.WebDavPortal
|
|||
|
||||
#region Enterprise storage
|
||||
|
||||
routes.MapRoute(
|
||||
name: FileSystemRouteNames.ItemExist,
|
||||
url: "storage/item-exist/{org}/{*pathPart}",
|
||||
defaults:
|
||||
new { controller = "FileSystem", action = "ItemExist", pathPart = UrlParameter.Optional }
|
||||
);
|
||||
|
||||
routes.MapRoute(
|
||||
name: FileSystemRouteNames.NewWebDavItem,
|
||||
url: "storage/new/{org}/{*pathPart}",
|
||||
defaults:
|
||||
new { controller = "FileSystem", action = "NewWebDavItem", pathPart = UrlParameter.Optional }
|
||||
);
|
||||
|
||||
routes.MapRoute(
|
||||
name: FileSystemRouteNames.SearchFiles,
|
||||
url: "storage/search/{org}/{*pathPart}",
|
||||
|
|
|
@ -12,6 +12,9 @@ namespace WebsitePanel.WebDavPortal.UI.Routes
|
|||
public const string ShowContentDetails = "ShowContentDetailsRoute";
|
||||
public const string ShowOfficeOnlinePath_ = "ShowOfficeOnlineRoute";
|
||||
public const string ViewOfficeOnline = "ViewOfficeOnlineRoute";
|
||||
public const string NewFileOfficeOnline = "NewFileOfficeOnlineRoute";
|
||||
public const string NewWebDavItem = "NewWebDavItemRoute";
|
||||
public const string ItemExist = "ItemExistRoute";
|
||||
public const string EditOfficeOnline = "EditOfficeOnlineRoute";
|
||||
|
||||
public const string ShowAdditionalContent = "ShowAdditionalContentRoute";
|
||||
|
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
|
@ -251,12 +251,17 @@ tr.selected-file {
|
|||
|
||||
.file-actions-menu .file-deletion {
|
||||
display: none;
|
||||
margin-right: 10px;
|
||||
}
|
||||
|
||||
.file-actions-menu .file-upload {
|
||||
display: inline-block;
|
||||
}
|
||||
|
||||
.create-new-item {
|
||||
margin-top: -2px;
|
||||
}
|
||||
|
||||
#message-area {
|
||||
margin-top: 15px;
|
||||
}
|
||||
|
@ -336,6 +341,11 @@ tr.selected-file {
|
|||
top: 20%;
|
||||
}
|
||||
|
||||
|
||||
.small-processing {
|
||||
display: none;
|
||||
}
|
||||
|
||||
/* Theme Mods */
|
||||
|
||||
input,div{border-radius:0px!important;}
|
||||
|
|
|
@ -54,22 +54,24 @@ namespace WebsitePanel.WebDavPortal.Controllers.Api
|
|||
{
|
||||
var token = _tokenManager.GetToken(accessTokenId);
|
||||
|
||||
var fileInfo = _wopiServer.GetCheckFileInfo(token.FilePath);
|
||||
var fileInfo = _wopiServer.GetCheckFileInfo(token);
|
||||
|
||||
var urlPart = Url.Route(FileSystemRouteNames.ShowContentPath, new { org = WspContext.User.OrganizationId, pathPart = token.FilePath });
|
||||
if (fileInfo.Size <= 1)
|
||||
{
|
||||
return fileInfo;
|
||||
}
|
||||
|
||||
var urlPart = Url.Route(FileSystemRouteNames.ShowContentPath, new {org = WspContext.User.OrganizationId, pathPart = token.FilePath});
|
||||
var url = new Uri(Request.RequestUri, urlPart).ToString();
|
||||
|
||||
fileInfo.DownloadUrl = url;
|
||||
fileInfo.ClientUrl = _webDavManager.GetFileUrl(token.FilePath);
|
||||
|
||||
return fileInfo;
|
||||
}
|
||||
|
||||
public HttpResponseMessage GetFile(int accessTokenId)
|
||||
{
|
||||
var token = _tokenManager.GetToken(accessTokenId);
|
||||
|
||||
var bytes = _webDavManager.GetFileBytes(token.FilePath);
|
||||
var bytes = _wopiServer.GetFileBytes(accessTokenId);
|
||||
|
||||
var result = new HttpResponseMessage(HttpStatusCode.OK);
|
||||
|
||||
|
|
|
@ -303,6 +303,36 @@ namespace WebsitePanel.WebDavPortal.Controllers
|
|||
return Json(model);
|
||||
}
|
||||
|
||||
public ActionResult NewWebDavItem(string org, string pathPart)
|
||||
{
|
||||
var permissions = _webDavAuthorizationService.GetPermissions(WspContext.User, pathPart);
|
||||
|
||||
var owaOpener = WebDavAppConfigManager.Instance.OfficeOnline.FirstOrDefault(x => x.Extension == Path.GetExtension(pathPart));
|
||||
|
||||
if (permissions.HasFlag(WebDavPermissions.Write) == false || (owaOpener != null && permissions.HasFlag(WebDavPermissions.OwaEdit) == false))
|
||||
{
|
||||
return new RedirectToRouteResult(FileSystemRouteNames.ShowContentPath, null);
|
||||
}
|
||||
|
||||
if (owaOpener != null)
|
||||
{
|
||||
return ShowOfficeDocument(org, pathPart, owaOpener.OwaNewFileView);
|
||||
}
|
||||
|
||||
return new RedirectToRouteResult(FileSystemRouteNames.ShowContentPath, null);
|
||||
}
|
||||
|
||||
[HttpPost]
|
||||
public JsonResult ItemExist(string org, string pathPart, string newItemName)
|
||||
{
|
||||
var exist = _webdavManager.FileExist(string.Format("{0}/{1}", pathPart, newItemName));
|
||||
|
||||
return new JsonResult()
|
||||
{
|
||||
Data = !exist
|
||||
};
|
||||
}
|
||||
|
||||
#region Owa Actions
|
||||
|
||||
public ActionResult ShowOfficeDocument(string org, string pathPart, string owaOpenerUri)
|
||||
|
@ -345,6 +375,7 @@ namespace WebsitePanel.WebDavPortal.Controllers
|
|||
|
||||
return ShowOfficeDocument(org, pathPart, owaOpener.OwaEditor);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
private void FillContentModel(IEnumerable<ResourceTableItemModel> items, string organizationId)
|
||||
|
|
|
@ -105,6 +105,15 @@ namespace WebsitePanel.WebDavPortal.Resources {
|
|||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to Create.
|
||||
/// </summary>
|
||||
public static string Create {
|
||||
get {
|
||||
return ResourceManager.GetString("Create", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to Delete.
|
||||
/// </summary>
|
||||
|
@ -141,6 +150,15 @@ namespace WebsitePanel.WebDavPortal.Resources {
|
|||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to Enter file name.
|
||||
/// </summary>
|
||||
public static string EnterFileName {
|
||||
get {
|
||||
return ResourceManager.GetString("EnterFileName", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to Error.
|
||||
/// </summary>
|
||||
|
@ -150,6 +168,15 @@ namespace WebsitePanel.WebDavPortal.Resources {
|
|||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to Excel workbook.
|
||||
/// </summary>
|
||||
public static string ExcelWorkbook {
|
||||
get {
|
||||
return ResourceManager.GetString("ExcelWorkbook", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to File.
|
||||
/// </summary>
|
||||
|
@ -159,6 +186,24 @@ namespace WebsitePanel.WebDavPortal.Resources {
|
|||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to File name.
|
||||
/// </summary>
|
||||
public static string FileName {
|
||||
get {
|
||||
return ResourceManager.GetString("FileName", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to File extension will be added automatically.
|
||||
/// </summary>
|
||||
public static string FileNameExtensionHint {
|
||||
get {
|
||||
return ResourceManager.GetString("FileNameExtensionHint", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to File Upload.
|
||||
/// </summary>
|
||||
|
@ -186,6 +231,15 @@ namespace WebsitePanel.WebDavPortal.Resources {
|
|||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to File already exist.
|
||||
/// </summary>
|
||||
public static string ItemExist {
|
||||
get {
|
||||
return ResourceManager.GetString("ItemExist", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to {0} items was removed..
|
||||
/// </summary>
|
||||
|
@ -249,6 +303,15 @@ namespace WebsitePanel.WebDavPortal.Resources {
|
|||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to Powerpoint presentation.
|
||||
/// </summary>
|
||||
public static string PowerPointPresentation {
|
||||
get {
|
||||
return ResourceManager.GetString("PowerPointPresentation", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to Processing.
|
||||
/// </summary>
|
||||
|
@ -339,6 +402,15 @@ namespace WebsitePanel.WebDavPortal.Resources {
|
|||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to Word document.
|
||||
/// </summary>
|
||||
public static string WordDocument {
|
||||
get {
|
||||
return ResourceManager.GetString("WordDocument", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to Yes.
|
||||
/// </summary>
|
||||
|
|
|
@ -132,6 +132,9 @@
|
|||
<data name="Confirm" xml:space="preserve">
|
||||
<value>Confirm</value>
|
||||
</data>
|
||||
<data name="Create" xml:space="preserve">
|
||||
<value>Create</value>
|
||||
</data>
|
||||
<data name="Delete" xml:space="preserve">
|
||||
<value>Delete</value>
|
||||
</data>
|
||||
|
@ -144,12 +147,24 @@
|
|||
<data name="DialogsContentConfrimFileDeletion" xml:space="preserve">
|
||||
<value>Are you sure you want to delete {0} item(s)?</value>
|
||||
</data>
|
||||
<data name="EnterFileName" xml:space="preserve">
|
||||
<value>Enter file name</value>
|
||||
</data>
|
||||
<data name="Error" xml:space="preserve">
|
||||
<value>Error</value>
|
||||
</data>
|
||||
<data name="ExcelWorkbook" xml:space="preserve">
|
||||
<value>Excel workbook</value>
|
||||
</data>
|
||||
<data name="File" xml:space="preserve">
|
||||
<value>File</value>
|
||||
</data>
|
||||
<data name="FileName" xml:space="preserve">
|
||||
<value>File name</value>
|
||||
</data>
|
||||
<data name="FileNameExtensionHint" xml:space="preserve">
|
||||
<value>File extension will be added automatically</value>
|
||||
</data>
|
||||
<data name="FileUpload" xml:space="preserve">
|
||||
<value>File Upload</value>
|
||||
</data>
|
||||
|
@ -159,6 +174,9 @@
|
|||
<data name="Info" xml:space="preserve">
|
||||
<value>Info</value>
|
||||
</data>
|
||||
<data name="ItemExist" xml:space="preserve">
|
||||
<value>File already exist</value>
|
||||
</data>
|
||||
<data name="ItemsWasRemovedFormat" xml:space="preserve">
|
||||
<value>{0} items was removed.</value>
|
||||
</data>
|
||||
|
@ -180,6 +198,9 @@
|
|||
<data name="PleaseWaitWithDots" xml:space="preserve">
|
||||
<value>Please wait...</value>
|
||||
</data>
|
||||
<data name="PowerPointPresentation" xml:space="preserve">
|
||||
<value>Powerpoint presentation</value>
|
||||
</data>
|
||||
<data name="Processing" xml:space="preserve">
|
||||
<value>Processing</value>
|
||||
</data>
|
||||
|
@ -210,6 +231,9 @@
|
|||
<data name="Upload" xml:space="preserve">
|
||||
<value>Upload</value>
|
||||
</data>
|
||||
<data name="WordDocument" xml:space="preserve">
|
||||
<value>Word document</value>
|
||||
</data>
|
||||
<data name="Yes" xml:space="preserve">
|
||||
<value>Yes</value>
|
||||
</data>
|
||||
|
|
|
@ -1,5 +1,9 @@
|
|||
function WspDialogs() {
|
||||
this.settings = { dialogId: "#confirm-dialog", processDialogId: "#processDialog" };
|
||||
this.settings = {
|
||||
dialogId: "#confirm-dialog",
|
||||
processDialogId: "#processDialog",
|
||||
inlineProcessDialog: '.glyphicon-refresh'
|
||||
};
|
||||
}
|
||||
|
||||
WspDialogs.prototype =
|
||||
|
@ -36,6 +40,14 @@ WspDialogs.prototype =
|
|||
|
||||
hideProcessDialog: function() {
|
||||
$(this.settings.processDialogId).modal('hide');
|
||||
}
|
||||
},
|
||||
|
||||
showInlineProcessing: function(itemId) {
|
||||
$(itemId).parent().find(this.settings.inlineProcessDialog).show();
|
||||
},
|
||||
|
||||
hideInlineProcessing: function (itemId) {
|
||||
$(itemId).parent().find(this.settings.inlineProcessDialog).hide();
|
||||
}
|
||||
};
|
||||
|
||||
|
|
|
@ -2,8 +2,15 @@
|
|||
this.settings = {
|
||||
deletionBlockSelector: ".file-actions-menu .file-deletion",
|
||||
deletionUrl: "storage/files-group-action/delete",
|
||||
fileExistUrl: "storage/fileExist",
|
||||
textDateModified: "Date modified",
|
||||
textSize: "Size"
|
||||
textSize: "Size",
|
||||
textItemExist: "File already exists",
|
||||
textItemExistFunc: function() {
|
||||
return textItemExist;
|
||||
} ,
|
||||
createNewItemDialogId: "#createNewItemDialog",
|
||||
createNewItemButtonId: "#create-button"
|
||||
};
|
||||
this.itemsTable = null;
|
||||
this.searchTable = null;
|
||||
|
@ -272,6 +279,38 @@ WspFileBrowser.prototype = {
|
|||
var sizes = ['Bytes', 'KB', 'MB', 'GB', 'TB', 'PB', 'EB', 'ZB', 'YB'];
|
||||
var i = Math.floor(Math.log(bytes) / Math.log(k));
|
||||
return (bytes / Math.pow(k, i)).toPrecision(3) + ' ' + sizes[i];
|
||||
},
|
||||
|
||||
showCreateNewItemDialog: function (extension, target) {
|
||||
$(this.settings.createNewItemButtonId).data('extension', extension);
|
||||
$(this.settings.createNewItemButtonId).data('target', target);
|
||||
|
||||
$(this.settings.createNewItemDialogId + " input").val("");
|
||||
|
||||
$(this.settings.createNewItemDialogId).modal();
|
||||
},
|
||||
|
||||
hideCreateNewItemDialog: function () {
|
||||
$(this.settings.createNewItemDialogId).modal('hide');
|
||||
},
|
||||
|
||||
uniqueFileNameFieldRule: function(fieldId) {
|
||||
|
||||
return {
|
||||
url: this.settings.fileExistUrl,
|
||||
type: "post",
|
||||
data: {
|
||||
newItemName: function() {
|
||||
return $(fieldId).val() + $(wsp.fileBrowser.settings.createNewItemButtonId).data('extension');
|
||||
}
|
||||
},
|
||||
beforeSend: function(response) {
|
||||
wsp.dialogs.showInlineProcessing(fieldId);
|
||||
},
|
||||
complete: function() {
|
||||
wsp.dialogs.hideInlineProcessing(fieldId);
|
||||
}
|
||||
};
|
||||
}
|
||||
};
|
||||
|
||||
|
|
|
@ -0,0 +1 @@
|
|||
|
|
@ -78,6 +78,132 @@ $('#drag-and-drop-area #file-input').click(function (e) {
|
|||
});
|
||||
|
||||
|
||||
|
||||
$("#create-button").click(function (e) {
|
||||
|
||||
if ($('#filenameForm').valid()) {
|
||||
|
||||
var fileName = $('#createNewItemDialog #filename').val() + $(this).data('extension');
|
||||
|
||||
$(this).attr('href', $(this).data('href') + '/' + fileName);
|
||||
|
||||
$(this).attr('target', $(this).data('target'));
|
||||
|
||||
wsp.fileBrowser.hideCreateNewItemDialog();
|
||||
//;
|
||||
} else {
|
||||
e.preventDefault();
|
||||
}
|
||||
});
|
||||
|
||||
$.fn.clearValidation = function () { var v = $(this).validate(); $('[name]', this).each(function () { v.successList.push(this); v.showErrors(); }); v.resetForm(); v.reset(); $(this).find('.form-group').removeClass('has-error'); };
|
||||
|
||||
$(document).ready(function() {
|
||||
//bootstrap jquery validate styles fix
|
||||
$.validator.setDefaults({
|
||||
highlight: function(element) {
|
||||
$(element).closest('.form-group').addClass('has-error');
|
||||
},
|
||||
unhighlight: function(element) {
|
||||
$(element).closest('.form-group').removeClass('has-error');
|
||||
},
|
||||
errorElement: 'span',
|
||||
errorClass: 'help-block',
|
||||
errorPlacement: function(error, element) {
|
||||
if (element.parent('.input-group').length) {
|
||||
error.insertAfter(element.parent());
|
||||
} else {
|
||||
error.insertAfter(element);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
$.validator.addMethod("synchronousRemote", function (value, element, param) {
|
||||
if (this.optional(element)) {
|
||||
return "dependency-mismatch";
|
||||
}
|
||||
|
||||
var previous = this.previousValue(element);
|
||||
if (!this.settings.messages[element.name]) {
|
||||
this.settings.messages[element.name] = {};
|
||||
}
|
||||
previous.originalMessage = this.settings.messages[element.name].remote;
|
||||
this.settings.messages[element.name].remote = previous.message;
|
||||
|
||||
param = typeof param === "string" && { url: param } || param;
|
||||
|
||||
if (previous.old === value) {
|
||||
return previous.valid;
|
||||
}
|
||||
|
||||
previous.old = value;
|
||||
var validator = this;
|
||||
this.startRequest(element);
|
||||
var data = {};
|
||||
data[element.name] = value;
|
||||
var valid = "pending";
|
||||
$.ajax($.extend(true, {
|
||||
url: param,
|
||||
async: false,
|
||||
mode: "abort",
|
||||
port: "validate" + element.name,
|
||||
dataType: "json",
|
||||
data: data,
|
||||
success: function (response) {
|
||||
validator.settings.messages[element.name].remote = previous.originalMessage;
|
||||
valid = response === true || response === "true";
|
||||
if (valid) {
|
||||
var submitted = validator.formSubmitted;
|
||||
validator.prepareElement(element);
|
||||
validator.formSubmitted = submitted;
|
||||
validator.successList.push(element);
|
||||
delete validator.invalid[element.name];
|
||||
validator.showErrors();
|
||||
} else {
|
||||
var errors = {};
|
||||
var message = response || validator.defaultMessage(element, "remote");
|
||||
errors[element.name] = previous.message = $.isFunction(message) ? message(value) : message;
|
||||
validator.invalid[element.name] = true;
|
||||
validator.showErrors(errors);
|
||||
}
|
||||
previous.valid = valid;
|
||||
validator.stopRequest(element, valid);
|
||||
}
|
||||
}, param));
|
||||
return valid;
|
||||
}, "Please fix this field.");
|
||||
|
||||
|
||||
$('#filenameForm').validate({
|
||||
onkeyup: false,
|
||||
onclick: false,
|
||||
async: false,
|
||||
rules: {
|
||||
filename: {
|
||||
required: true,
|
||||
synchronousRemote: wsp.fileBrowser.uniqueFileNameFieldRule("#filename")
|
||||
}
|
||||
},
|
||||
messages: {
|
||||
filename: {
|
||||
synchronousRemote: wsp.fileBrowser.settings.textItemExist
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
|
||||
$(".create-new-item li a").click(function () {
|
||||
|
||||
$("#filenameForm").clearValidation();
|
||||
|
||||
wsp.fileBrowser.showCreateNewItemDialog($(this).data('extension'), $(this).data('target'));
|
||||
|
||||
$("#filename").focus();
|
||||
});
|
||||
|
||||
|
||||
function isMobileDevice() {
|
||||
return (/android|webos|iphone|ipad|ipod|blackberry|iemobile|opera mini/i.test(navigator.userAgent.toLowerCase()));
|
||||
}
|
||||
|
|
|
@ -26,7 +26,10 @@ else
|
|||
|
||||
@section scripts{
|
||||
<script>
|
||||
wsp.fileBrowser.setSettings({ deletionUrl: "@Url.RouteUrl(FileSystemRouteNames.DeleteFiles)" });
|
||||
wsp.fileBrowser.setSettings({
|
||||
deletionUrl: "@Url.RouteUrl(FileSystemRouteNames.DeleteFiles)",
|
||||
fileExistUrl: "@Url.RouteUrl(FileSystemRouteNames.ItemExist)",
|
||||
textItemExist: "@UI.ItemExist." });
|
||||
</script>
|
||||
|
||||
@if (Model.UserSettings.WebDavViewType == FolderViewTypes.BigIcons)
|
||||
|
@ -47,9 +50,37 @@ else
|
|||
{
|
||||
<script>
|
||||
$(document).ready(function () {
|
||||
wsp.fileBrowser.setSettings({ deletionUrl: "@Url.RouteUrl(FileSystemRouteNames.DeleteFiles)" });
|
||||
wsp.fileBrowser.initDataTable('#webdav-items-table', '@Url.RouteUrl(FileSystemRouteNames.ShowContentDetails)');
|
||||
});
|
||||
</script>
|
||||
}
|
||||
}
|
||||
|
||||
@section popups{
|
||||
<div id="createNewItemDialog" 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-content">
|
||||
<div class="modal-header">
|
||||
<button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">×</span></button>
|
||||
<h4 class="modal-title" id="confirm-dalog-label">@UI.Create</h4>
|
||||
</div>
|
||||
|
||||
<div class="modal-body">
|
||||
<form id="filenameForm">
|
||||
<div class="form-group has-feedback">
|
||||
<label for="filename">@UI.FileName</label>
|
||||
<input type="text" class="form-control" id="filename" name="filename" autofocus required placeholder="@UI.EnterFileName">
|
||||
<span class="glyphicon glyphicon-refresh glyphicon-spin form-control-feedback small-processing" aria-hidden="true"></span>
|
||||
<span id="inputProcessingStatus" class="sr-only">(processing)</span>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
|
||||
<div class="modal-footer">
|
||||
<button type="button" class="btn btn-default" data-dismiss="modal">@UI.Cancel</button>
|
||||
<a href="@Url.RouteUrl(FileSystemRouteNames.NewWebDavItem)" data-href="@Url.RouteUrl(FileSystemRouteNames.NewWebDavItem)" id="create-button" class="btn btn-success danger">@UI.Create</a>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
}
|
|
@ -56,6 +56,17 @@
|
|||
data-target-title-text="@UI.DeleteFileQuestion"
|
||||
data-target-content="@UI.DialogsContentConfrimFileDeletion">@UI.Delete</a>
|
||||
</div>
|
||||
<div class="dropdown create-new-item navbar-left">
|
||||
<button class="btn btn-default dropdown-toggle" type="button" id="dropdownMenu1" data-toggle="dropdown" aria-expanded="true">
|
||||
@UI.Create
|
||||
<span class="caret"></span>
|
||||
</button>
|
||||
<ul class="dropdown-menu" role="menu" aria-labelledby="dropdownMenu1">
|
||||
<li role="presentation"><a role="menuitem" tabindex="-1" href="#" data-extension=".docx" data-target="_blank">@UI.WordDocument</a></li>
|
||||
<li role="presentation"><a role="menuitem" tabindex="-1" href="#" data-extension=".xlsx" data-target="_blank">@UI.ExcelWorkbook</a></li>
|
||||
<li role="presentation"><a role="menuitem" tabindex="-1" href="#" data-extension=".pptx" data-target="_blank">@UI.PowerPointPresentation</a></li>
|
||||
</ul>
|
||||
</div>
|
||||
}
|
||||
|
||||
<div class="file-upload navbar-right">
|
||||
|
@ -75,4 +86,4 @@
|
|||
}
|
||||
</div>
|
||||
</div>
|
||||
}
|
||||
}
|
||||
|
|
|
@ -85,13 +85,13 @@
|
|||
<add browser="InternetExplorer;IE" version="8" />
|
||||
<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?" OwaMobileView="wv/mWord.aspx?wdMobileHost=3&"/>
|
||||
<add extension=".docx" OwaView="wv/wordviewerframe.aspx?" OwaEditor="we/wordeditorframe.aspx?" OwaMobileView="wv/mWord.aspx?wdMobileHost=3&"/>
|
||||
<add extension=".xls" OwaView="x/_layouts/xlviewerinternal.aspx?" OwaEditor="x/_layouts/xlviewerinternal.aspx?edit=1&" OwaMobileView="x/_layouts/mobile/mXL.aspx?wdMobileHost=3&"/>
|
||||
<add extension=".xlsx" OwaView="x/_layouts/xlviewerinternal.aspx?" OwaEditor="x/_layouts/xlviewerinternal.aspx?edit=1&" OwaMobileView="x/_layouts/mobile/mXL.aspx?wdMobileHost=3&" />
|
||||
<add extension=".ppt" OwaView="p/PowerPointFrame.aspx?" OwaEditor="p/PowerPointFrame.aspx?" OwaMobileView="p/mPPT.aspx?wdMobileHost=3&"/>
|
||||
<add extension=".pptx" OwaView="p/PowerPointFrame.aspx?" OwaEditor="p/PowerPointFrame.aspx?PowerPointView=EditView&" OwaMobileView="p/mPPT.aspx?wdMobileHost=3&"/>
|
||||
<officeOnline isEnabled="True" url="https://vir-owa.virtuworks.net" cobaltFileTtl="1" cobaltNewFilePath="~/Content/OwaFiles/New">
|
||||
<add extension=".doc" OwaView="wv/wordviewerframe.aspx?" OwaEditor="wv/wordviewerframe.aspx?" OwaMobileView="wv/mWord.aspx?wdMobileHost=3&" OwaNewFileView="we/wordeditorframe.aspx?new=1&"/>
|
||||
<add extension=".docx" OwaView="wv/wordviewerframe.aspx?" OwaEditor="we/wordeditorframe.aspx?" OwaMobileView="wv/mWord.aspx?wdMobileHost=3&" OwaNewFileView="we/wordeditorframe.aspx?new=1&"/>
|
||||
<add extension=".xls" OwaView="x/_layouts/xlviewerinternal.aspx?" OwaEditor="x/_layouts/xlviewerinternal.aspx?edit=1&" OwaMobileView="x/_layouts/mobile/mXL.aspx?wdMobileHost=3&" OwaNewFileView="x/_layouts/xlviewerinternal.aspx?new=1&"/>
|
||||
<add extension=".xlsx" OwaView="x/_layouts/xlviewerinternal.aspx?" OwaEditor="x/_layouts/xlviewerinternal.aspx?edit=1&" OwaMobileView="x/_layouts/mobile/mXL.aspx?wdMobileHost=3&" OwaNewFileView="x/_layouts/xlviewerinternal.aspx?edit=1&"/>
|
||||
<add extension=".ppt" OwaView="p/PowerPointFrame.aspx?" OwaEditor="p/PowerPointFrame.aspx?" OwaMobileView="p/mPPT.aspx?wdMobileHost=3&" OwaNewFileView="p/PowerPointFrame.aspx?PowerPointView=EditView&New=1&"/>
|
||||
<add extension=".pptx" OwaView="p/PowerPointFrame.aspx?" OwaEditor="p/PowerPointFrame.aspx?PowerPointView=EditView&" OwaMobileView="p/mPPT.aspx?wdMobileHost=3&" OwaNewFileView="p/PowerPointFrame.aspx?PowerPointView=EditView&New=1&"/>
|
||||
</officeOnline>
|
||||
<typeOpener>
|
||||
<add extension=".jpg" mimeType="image/jpeg" isTargetBlank="true" />
|
||||
|
|
|
@ -369,6 +369,8 @@
|
|||
<Content Include="Content\bootstrap.css.map" />
|
||||
<Content Include="Content\DataTables-1.10.4\css\dataTables.responsive.scss" />
|
||||
<Content Include="Content\DataTables-1.10.4\css\dataTables.jqueryui.scss" />
|
||||
<Content Include="Content\OwaFiles\Empty.docx" />
|
||||
<Content Include="Content\OwaFiles\Empty.pptx" />
|
||||
<None Include="Scripts\jquery-2.1.1.intellisense.js" />
|
||||
<Content Include="Scripts\appScripts\authentication.js" />
|
||||
<Content Include="Scripts\appScripts\dialogs.js" />
|
||||
|
@ -376,6 +378,7 @@
|
|||
<Content Include="Scripts\appScripts\messages.js" />
|
||||
<Content Include="Scripts\appScripts\recalculateResourseHeight.js" />
|
||||
<Content Include="Scripts\appScripts\uploadingData2.js" />
|
||||
<Content Include="Scripts\appScripts\wsp-webdav.js" />
|
||||
<Content Include="Scripts\appScripts\wsp.js" />
|
||||
<Content Include="Scripts\bootstrap.js" />
|
||||
<Content Include="Scripts\bootstrap.min.js" />
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue