webdav portal create new ability added

This commit is contained in:
vfedosevich 2015-03-11 05:34:35 -07:00
parent 6b1c1660fe
commit 50e902b94d
26 changed files with 473 additions and 38 deletions

View file

@ -13,12 +13,14 @@ namespace WebsitePanel.WebDav.Core.Config.Entities
{ {
IsEnabled = ConfigSection.OfficeOnline.IsEnabled; IsEnabled = ConfigSection.OfficeOnline.IsEnabled;
Url = ConfigSection.OfficeOnline.Url; Url = ConfigSection.OfficeOnline.Url;
NewFilePath = ConfigSection.OfficeOnline.CobaltNewFilePath;
CobaltFileTtl = ConfigSection.OfficeOnline.CobaltFileTtl; CobaltFileTtl = ConfigSection.OfficeOnline.CobaltFileTtl;
_officeExtensions = ConfigSection.OfficeOnline.Cast<OfficeOnlineElement>().ToList(); _officeExtensions = ConfigSection.OfficeOnline.Cast<OfficeOnlineElement>().ToList();
} }
public bool IsEnabled { get; private set; } public bool IsEnabled { get; private set; }
public string Url { get; private set; } public string Url { get; private set; }
public string NewFilePath { get; private set; }
public int CobaltFileTtl { get; private set; } public int CobaltFileTtl { get; private set; }
public IEnumerator<OfficeOnlineElement> GetEnumerator() public IEnumerator<OfficeOnlineElement> GetEnumerator()

View file

@ -8,6 +8,7 @@ namespace WebsitePanel.WebDavPortal.WebConfigSections
private const string OwaViewKey = "OwaView"; private const string OwaViewKey = "OwaView";
private const string OwaEditorKey = "OwaEditor"; private const string OwaEditorKey = "OwaEditor";
private const string OwaMobileViewKey = "OwaMobileView"; private const string OwaMobileViewKey = "OwaMobileView";
private const string OwaNewFileViewKey = "OwaNewFileView";
[ConfigurationProperty(ExtensionKey, IsKey = true, IsRequired = true)] [ConfigurationProperty(ExtensionKey, IsKey = true, IsRequired = true)]
public string Extension public string Extension
@ -37,5 +38,12 @@ namespace WebsitePanel.WebDavPortal.WebConfigSections
get { return this[OwaMobileViewKey].ToString(); } get { return this[OwaMobileViewKey].ToString(); }
set { this[OwaMobileViewKey] = value; } set { this[OwaMobileViewKey] = value; }
} }
[ConfigurationProperty(OwaNewFileViewKey, IsKey = true, IsRequired = true)]
public string OwaNewFileView
{
get { return this[OwaNewFileViewKey].ToString(); }
set { this[OwaNewFileViewKey] = value; }
}
} }
} }

View file

@ -9,6 +9,7 @@ namespace WebsitePanel.WebDavPortal.WebConfigSections
private const string UrlKey = "url"; private const string UrlKey = "url";
private const string IsEnabledKey = "isEnabled"; private const string IsEnabledKey = "isEnabled";
private const string CobaltFileTtlKey = "cobaltFileTtl"; private const string CobaltFileTtlKey = "cobaltFileTtl";
private const string CobaltNewFilePathKey = "cobaltNewFilePath";
[ConfigurationProperty(UrlKey, IsKey = true, IsRequired = true)] [ConfigurationProperty(UrlKey, IsKey = true, IsRequired = true)]
public string Url public string Url
@ -24,6 +25,13 @@ namespace WebsitePanel.WebDavPortal.WebConfigSections
set { this[IsEnabledKey] = value; } 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)] [ConfigurationProperty(CobaltFileTtlKey, IsKey = true, IsRequired = true)]
public int CobaltFileTtl public int CobaltFileTtl
{ {

View file

@ -37,6 +37,10 @@ namespace WebsitePanel.WebDav.Core.Entities.Owa
public bool RestrictedWebViewOnly { get; set; } public bool RestrictedWebViewOnly { get; set; }
[DataMember] [DataMember]
public string ClientUrl { get; set; } public string ClientUrl { get; set; }
[DataMember]
public bool CloseButtonClosesWindow { get; set; }
//[DataMember]
//public string CloseUrl { get; set; }
//[DataMember] //[DataMember]
//public bool UserCanNotWriteRelative { get; set; } //public bool UserCanNotWriteRelative { get; set; }
@ -59,8 +63,7 @@ namespace WebsitePanel.WebDav.Core.Entities.Owa
//public string BreadcrumbFolderUrl { get; set; } //public string BreadcrumbFolderUrl { get; set; }
//[DataMember] //[DataMember]
//public string ClientUrl { get; set; } //public string ClientUrl { get; set; }
//[DataMember]
//public bool CloseButtonClosesWindow { get; set; }
//[DataMember] //[DataMember]
//public string CloseUrl { get; set; } //public string CloseUrl { get; set; }
//[DataMember] //[DataMember]

View file

@ -1,4 +1,4 @@
using System.Web.Mvc; using WebsitePanel.EnterpriseServer.Base.HostedSolution;
using WebsitePanel.WebDav.Core.Client; using WebsitePanel.WebDav.Core.Client;
using WebsitePanel.WebDav.Core.Entities.Owa; using WebsitePanel.WebDav.Core.Entities.Owa;
@ -6,7 +6,7 @@ namespace WebsitePanel.WebDav.Core.Interfaces.Owa
{ {
public interface IWopiServer public interface IWopiServer
{ {
CheckFileInfo GetCheckFileInfo(string path); CheckFileInfo GetCheckFileInfo(WebDavAccessToken token);
FileResult GetFile(string path); byte[] GetFileBytes(int accessTokenId);
} }
} }

View file

@ -240,9 +240,9 @@ namespace WebsitePanel.WebDav.Core.Managers
return _currentFolder.GetResource(resourceName); return _currentFolder.GetResource(resourceName);
} }
catch (InvalidOperationException exception) catch (Exception)
{ {
throw new ResourceNotFoundException("Resource not found", exception); return null;
} }
} }

View file

@ -2,8 +2,10 @@
using System.Collections.Concurrent; using System.Collections.Concurrent;
using System.Collections.Generic; using System.Collections.Generic;
using System.Globalization; using System.Globalization;
using System.IO;
using System.Linq; using System.Linq;
using System.Runtime.Caching; using System.Runtime.Caching;
using System.Web;
using Cobalt; using Cobalt;
using WebsitePanel.WebDav.Core.Client; using WebsitePanel.WebDav.Core.Client;
using WebsitePanel.WebDav.Core.Config; using WebsitePanel.WebDav.Core.Config;
@ -72,9 +74,20 @@ namespace WebsitePanel.WebDav.Core.Owa
var token = _tokenManager.GetToken(accessTokenId); var token = _tokenManager.GetToken(accessTokenId);
Atom atom;
if (_webDavManager.FileExist(token.FilePath))
{
var fileBytes = _webDavManager.GetFileBytes(token.FilePath); var fileBytes = _webDavManager.GetFileBytes(token.FilePath);
var atom = new AtomFromByteArray(fileBytes); 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; Cobalt.Metrics o1;
cobaltFile.GetCobaltFilePartition(FilePartitionId.Content).SetStream(RootId.Default.Value, atom, out o1); cobaltFile.GetCobaltFilePartition(FilePartitionId.Content).SetStream(RootId.Default.Value, atom, out o1);

View file

@ -6,6 +6,8 @@ using System.Runtime.Serialization.Json;
using System.Text; using System.Text;
using System.Web; using System.Web;
using System.Web.Mvc; using System.Web.Mvc;
using Cobalt;
using WebsitePanel.EnterpriseServer.Base.HostedSolution;
using WebsitePanel.WebDav.Core.Client; using WebsitePanel.WebDav.Core.Client;
using WebsitePanel.WebDav.Core.Config; using WebsitePanel.WebDav.Core.Config;
using WebsitePanel.WebDav.Core.Entities.Owa; using WebsitePanel.WebDav.Core.Entities.Owa;
@ -22,27 +24,30 @@ namespace WebsitePanel.WebDav.Core.Owa
private readonly IWebDavManager _webDavManager; private readonly IWebDavManager _webDavManager;
private readonly IAccessTokenManager _tokenManager; private readonly IAccessTokenManager _tokenManager;
private readonly IWebDavAuthorizationService _webDavAuthorizationService; 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; _webDavManager = webDavManager;
_tokenManager = tokenManager; _tokenManager = tokenManager;
_webDavAuthorizationService = webDavAuthorizationService; _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 readOnly = permissions.HasFlag(WebDavPermissions.Write) == false || permissions.HasFlag(WebDavPermissions.OwaEdit) == false;
var cFileInfo = new CheckFileInfo 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, OwnerId = WspContext.User.Login,
Size = resource.ContentLength, Size = resource == null ? 0 : resource.ContentLength,
Version = DateTime.Now.ToString("s"), Version = DateTime.Now.ToString("s"),
SupportsCoauth = true, SupportsCoauth = true,
SupportsCobalt = true, SupportsCobalt = true,
@ -53,17 +58,34 @@ namespace WebsitePanel.WebDav.Core.Owa
SupportsUpdate = true, SupportsUpdate = true,
UserCanWrite = !readOnly, UserCanWrite = !readOnly,
ReadOnly = readOnly, ReadOnly = readOnly,
RestrictedWebViewOnly = false RestrictedWebViewOnly = false,
CloseButtonClosesWindow = true
}; };
if (resource != null)
{
cFileInfo.ClientUrl = _webDavManager.GetFileUrl(token.FilePath);
}
return cFileInfo; 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();
} }
} }
} }

View file

@ -46,6 +46,20 @@ namespace WebsitePanel.WebDavPortal
#region Enterprise storage #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( routes.MapRoute(
name: FileSystemRouteNames.SearchFiles, name: FileSystemRouteNames.SearchFiles,
url: "storage/search/{org}/{*pathPart}", url: "storage/search/{org}/{*pathPart}",

View file

@ -12,6 +12,9 @@ namespace WebsitePanel.WebDavPortal.UI.Routes
public const string ShowContentDetails = "ShowContentDetailsRoute"; public const string ShowContentDetails = "ShowContentDetailsRoute";
public const string ShowOfficeOnlinePath_ = "ShowOfficeOnlineRoute"; public const string ShowOfficeOnlinePath_ = "ShowOfficeOnlineRoute";
public const string ViewOfficeOnline = "ViewOfficeOnlineRoute"; 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 EditOfficeOnline = "EditOfficeOnlineRoute";
public const string ShowAdditionalContent = "ShowAdditionalContentRoute"; public const string ShowAdditionalContent = "ShowAdditionalContentRoute";

View file

@ -251,12 +251,17 @@ tr.selected-file {
.file-actions-menu .file-deletion { .file-actions-menu .file-deletion {
display: none; display: none;
margin-right: 10px;
} }
.file-actions-menu .file-upload { .file-actions-menu .file-upload {
display: inline-block; display: inline-block;
} }
.create-new-item {
margin-top: -2px;
}
#message-area { #message-area {
margin-top: 15px; margin-top: 15px;
} }
@ -336,6 +341,11 @@ tr.selected-file {
top: 20%; top: 20%;
} }
.small-processing {
display: none;
}
/* Theme Mods */ /* Theme Mods */
input,div{border-radius:0px!important;} input,div{border-radius:0px!important;}

View file

@ -54,22 +54,24 @@ namespace WebsitePanel.WebDavPortal.Controllers.Api
{ {
var token = _tokenManager.GetToken(accessTokenId); 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(); var url = new Uri(Request.RequestUri, urlPart).ToString();
fileInfo.DownloadUrl = url; fileInfo.DownloadUrl = url;
fileInfo.ClientUrl = _webDavManager.GetFileUrl(token.FilePath);
return fileInfo; return fileInfo;
} }
public HttpResponseMessage GetFile(int accessTokenId) public HttpResponseMessage GetFile(int accessTokenId)
{ {
var token = _tokenManager.GetToken(accessTokenId); var bytes = _wopiServer.GetFileBytes(accessTokenId);
var bytes = _webDavManager.GetFileBytes(token.FilePath);
var result = new HttpResponseMessage(HttpStatusCode.OK); var result = new HttpResponseMessage(HttpStatusCode.OK);

View file

@ -303,6 +303,36 @@ namespace WebsitePanel.WebDavPortal.Controllers
return Json(model); 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 #region Owa Actions
public ActionResult ShowOfficeDocument(string org, string pathPart, string owaOpenerUri) public ActionResult ShowOfficeDocument(string org, string pathPart, string owaOpenerUri)
@ -345,6 +375,7 @@ namespace WebsitePanel.WebDavPortal.Controllers
return ShowOfficeDocument(org, pathPart, owaOpener.OwaEditor); return ShowOfficeDocument(org, pathPart, owaOpener.OwaEditor);
} }
#endregion #endregion
private void FillContentModel(IEnumerable<ResourceTableItemModel> items, string organizationId) private void FillContentModel(IEnumerable<ResourceTableItemModel> items, string organizationId)

View file

@ -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> /// <summary>
/// Looks up a localized string similar to Delete. /// Looks up a localized string similar to Delete.
/// </summary> /// </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> /// <summary>
/// Looks up a localized string similar to Error. /// Looks up a localized string similar to Error.
/// </summary> /// </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> /// <summary>
/// Looks up a localized string similar to File. /// Looks up a localized string similar to File.
/// </summary> /// </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> /// <summary>
/// Looks up a localized string similar to File Upload. /// Looks up a localized string similar to File Upload.
/// </summary> /// </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> /// <summary>
/// Looks up a localized string similar to {0} items was removed.. /// Looks up a localized string similar to {0} items was removed..
/// </summary> /// </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> /// <summary>
/// Looks up a localized string similar to Processing. /// Looks up a localized string similar to Processing.
/// </summary> /// </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> /// <summary>
/// Looks up a localized string similar to Yes. /// Looks up a localized string similar to Yes.
/// </summary> /// </summary>

View file

@ -132,6 +132,9 @@
<data name="Confirm" xml:space="preserve"> <data name="Confirm" xml:space="preserve">
<value>Confirm</value> <value>Confirm</value>
</data> </data>
<data name="Create" xml:space="preserve">
<value>Create</value>
</data>
<data name="Delete" xml:space="preserve"> <data name="Delete" xml:space="preserve">
<value>Delete</value> <value>Delete</value>
</data> </data>
@ -144,12 +147,24 @@
<data name="DialogsContentConfrimFileDeletion" xml:space="preserve"> <data name="DialogsContentConfrimFileDeletion" xml:space="preserve">
<value>Are you sure you want to delete {0} item(s)?</value> <value>Are you sure you want to delete {0} item(s)?</value>
</data> </data>
<data name="EnterFileName" xml:space="preserve">
<value>Enter file name</value>
</data>
<data name="Error" xml:space="preserve"> <data name="Error" xml:space="preserve">
<value>Error</value> <value>Error</value>
</data> </data>
<data name="ExcelWorkbook" xml:space="preserve">
<value>Excel workbook</value>
</data>
<data name="File" xml:space="preserve"> <data name="File" xml:space="preserve">
<value>File</value> <value>File</value>
</data> </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"> <data name="FileUpload" xml:space="preserve">
<value>File Upload</value> <value>File Upload</value>
</data> </data>
@ -159,6 +174,9 @@
<data name="Info" xml:space="preserve"> <data name="Info" xml:space="preserve">
<value>Info</value> <value>Info</value>
</data> </data>
<data name="ItemExist" xml:space="preserve">
<value>File already exist</value>
</data>
<data name="ItemsWasRemovedFormat" xml:space="preserve"> <data name="ItemsWasRemovedFormat" xml:space="preserve">
<value>{0} items was removed.</value> <value>{0} items was removed.</value>
</data> </data>
@ -180,6 +198,9 @@
<data name="PleaseWaitWithDots" xml:space="preserve"> <data name="PleaseWaitWithDots" xml:space="preserve">
<value>Please wait...</value> <value>Please wait...</value>
</data> </data>
<data name="PowerPointPresentation" xml:space="preserve">
<value>Powerpoint presentation</value>
</data>
<data name="Processing" xml:space="preserve"> <data name="Processing" xml:space="preserve">
<value>Processing</value> <value>Processing</value>
</data> </data>
@ -210,6 +231,9 @@
<data name="Upload" xml:space="preserve"> <data name="Upload" xml:space="preserve">
<value>Upload</value> <value>Upload</value>
</data> </data>
<data name="WordDocument" xml:space="preserve">
<value>Word document</value>
</data>
<data name="Yes" xml:space="preserve"> <data name="Yes" xml:space="preserve">
<value>Yes</value> <value>Yes</value>
</data> </data>

View file

@ -1,5 +1,9 @@
function WspDialogs() { function WspDialogs() {
this.settings = { dialogId: "#confirm-dialog", processDialogId: "#processDialog" }; this.settings = {
dialogId: "#confirm-dialog",
processDialogId: "#processDialog",
inlineProcessDialog: '.glyphicon-refresh'
};
} }
WspDialogs.prototype = WspDialogs.prototype =
@ -36,6 +40,14 @@ WspDialogs.prototype =
hideProcessDialog: function() { hideProcessDialog: function() {
$(this.settings.processDialogId).modal('hide'); $(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();
}
}; };

View file

@ -2,8 +2,15 @@
this.settings = { this.settings = {
deletionBlockSelector: ".file-actions-menu .file-deletion", deletionBlockSelector: ".file-actions-menu .file-deletion",
deletionUrl: "storage/files-group-action/delete", deletionUrl: "storage/files-group-action/delete",
fileExistUrl: "storage/fileExist",
textDateModified: "Date modified", textDateModified: "Date modified",
textSize: "Size" textSize: "Size",
textItemExist: "File already exists",
textItemExistFunc: function() {
return textItemExist;
} ,
createNewItemDialogId: "#createNewItemDialog",
createNewItemButtonId: "#create-button"
}; };
this.itemsTable = null; this.itemsTable = null;
this.searchTable = null; this.searchTable = null;
@ -272,6 +279,38 @@ WspFileBrowser.prototype = {
var sizes = ['Bytes', 'KB', 'MB', 'GB', 'TB', 'PB', 'EB', 'ZB', 'YB']; var sizes = ['Bytes', 'KB', 'MB', 'GB', 'TB', 'PB', 'EB', 'ZB', 'YB'];
var i = Math.floor(Math.log(bytes) / Math.log(k)); var i = Math.floor(Math.log(bytes) / Math.log(k));
return (bytes / Math.pow(k, i)).toPrecision(3) + ' ' + sizes[i]; 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);
}
};
} }
}; };

View file

@ -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() { function isMobileDevice() {
return (/android|webos|iphone|ipad|ipod|blackberry|iemobile|opera mini/i.test(navigator.userAgent.toLowerCase())); return (/android|webos|iphone|ipad|ipod|blackberry|iemobile|opera mini/i.test(navigator.userAgent.toLowerCase()));
} }

View file

@ -26,7 +26,10 @@ else
@section scripts{ @section scripts{
<script> <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> </script>
@if (Model.UserSettings.WebDavViewType == FolderViewTypes.BigIcons) @if (Model.UserSettings.WebDavViewType == FolderViewTypes.BigIcons)
@ -47,9 +50,37 @@ else
{ {
<script> <script>
$(document).ready(function () { $(document).ready(function () {
wsp.fileBrowser.setSettings({ deletionUrl: "@Url.RouteUrl(FileSystemRouteNames.DeleteFiles)" });
wsp.fileBrowser.initDataTable('#webdav-items-table', '@Url.RouteUrl(FileSystemRouteNames.ShowContentDetails)'); wsp.fileBrowser.initDataTable('#webdav-items-table', '@Url.RouteUrl(FileSystemRouteNames.ShowContentDetails)');
}); });
</script> </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>
}

View file

@ -56,6 +56,17 @@
data-target-title-text="@UI.DeleteFileQuestion" data-target-title-text="@UI.DeleteFileQuestion"
data-target-content="@UI.DialogsContentConfrimFileDeletion">@UI.Delete</a> data-target-content="@UI.DialogsContentConfrimFileDeletion">@UI.Delete</a>
</div> </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"> <div class="file-upload navbar-right">

View file

@ -85,13 +85,13 @@
<add browser="InternetExplorer;IE" version="8" /> <add browser="InternetExplorer;IE" version="8" />
<add browser="Safari" version="4" /> <add browser="Safari" version="4" />
</owaSupportedBrowsers> </owaSupportedBrowsers>
<officeOnline isEnabled="True" url="https://vir-owa.virtuworks.net" cobaltFileTtl="1"> <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&amp;"/> <add extension=".doc" OwaView="wv/wordviewerframe.aspx?" OwaEditor="wv/wordviewerframe.aspx?" OwaMobileView="wv/mWord.aspx?wdMobileHost=3&amp;" OwaNewFileView="we/wordeditorframe.aspx?new=1&amp;"/>
<add extension=".docx" OwaView="wv/wordviewerframe.aspx?" OwaEditor="we/wordeditorframe.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;" OwaNewFileView="we/wordeditorframe.aspx?new=1&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=".xls" OwaView="x/_layouts/xlviewerinternal.aspx?" OwaEditor="x/_layouts/xlviewerinternal.aspx?edit=1&amp;" OwaMobileView="x/_layouts/mobile/mXL.aspx?wdMobileHost=3&amp;" OwaNewFileView="x/_layouts/xlviewerinternal.aspx?new=1&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=".xlsx" OwaView="x/_layouts/xlviewerinternal.aspx?" OwaEditor="x/_layouts/xlviewerinternal.aspx?edit=1&amp;" OwaMobileView="x/_layouts/mobile/mXL.aspx?wdMobileHost=3&amp;" OwaNewFileView="x/_layouts/xlviewerinternal.aspx?edit=1&amp;"/>
<add extension=".ppt" OwaView="p/PowerPointFrame.aspx?" OwaEditor="p/PowerPointFrame.aspx?" OwaMobileView="p/mPPT.aspx?wdMobileHost=3&amp;"/> <add extension=".ppt" OwaView="p/PowerPointFrame.aspx?" OwaEditor="p/PowerPointFrame.aspx?" OwaMobileView="p/mPPT.aspx?wdMobileHost=3&amp;" OwaNewFileView="p/PowerPointFrame.aspx?PowerPointView=EditView&amp;New=1&amp;"/>
<add extension=".pptx" OwaView="p/PowerPointFrame.aspx?" OwaEditor="p/PowerPointFrame.aspx?PowerPointView=EditView&amp;" 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;" OwaNewFileView="p/PowerPointFrame.aspx?PowerPointView=EditView&amp;New=1&amp;"/>
</officeOnline> </officeOnline>
<typeOpener> <typeOpener>
<add extension=".jpg" mimeType="image/jpeg" isTargetBlank="true" /> <add extension=".jpg" mimeType="image/jpeg" isTargetBlank="true" />

View file

@ -369,6 +369,8 @@
<Content Include="Content\bootstrap.css.map" /> <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.responsive.scss" />
<Content Include="Content\DataTables-1.10.4\css\dataTables.jqueryui.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" /> <None Include="Scripts\jquery-2.1.1.intellisense.js" />
<Content Include="Scripts\appScripts\authentication.js" /> <Content Include="Scripts\appScripts\authentication.js" />
<Content Include="Scripts\appScripts\dialogs.js" /> <Content Include="Scripts\appScripts\dialogs.js" />
@ -376,6 +378,7 @@
<Content Include="Scripts\appScripts\messages.js" /> <Content Include="Scripts\appScripts\messages.js" />
<Content Include="Scripts\appScripts\recalculateResourseHeight.js" /> <Content Include="Scripts\appScripts\recalculateResourseHeight.js" />
<Content Include="Scripts\appScripts\uploadingData2.js" /> <Content Include="Scripts\appScripts\uploadingData2.js" />
<Content Include="Scripts\appScripts\wsp-webdav.js" />
<Content Include="Scripts\appScripts\wsp.js" /> <Content Include="Scripts\appScripts\wsp.js" />
<Content Include="Scripts\bootstrap.js" /> <Content Include="Scripts\bootstrap.js" />
<Content Include="Scripts\bootstrap.min.js" /> <Content Include="Scripts\bootstrap.min.js" />