webdav portal search view added

This commit is contained in:
vfedosevich 2015-03-03 06:41:52 -08:00
parent 839f6cda2b
commit 0ebe24141e
24 changed files with 345 additions and 99 deletions

View file

@ -145,6 +145,7 @@ namespace WebsitePanel.Providers.OS
}
public string RelativeUrl { get; set; }
public string Summary { get; set; }
public string DriveLetter
{

View file

@ -304,7 +304,7 @@ namespace WebsitePanel.Providers.EnterpriseStorage
var rootFolder = Path.Combine(settings.LocationDrive + ":\\", settings.HomeFolder);
rootFolder = Path.Combine(rootFolder, organizationId);
var wsSql = string.Format(@"SELECT System.FileName, System.DateModified, System.Size, System.Kind, System.ItemPathDisplay, System.ItemType FROM SYSTEMINDEX WHERE System.FileName LIKE '%{0}%' AND ({1})",
var wsSql = string.Format(@"SELECT System.FileName, System.DateModified, System.Size, System.Kind, System.ItemPathDisplay, System.ItemType, System.Search.AutoSummary FROM SYSTEMINDEX WHERE System.FileName LIKE '%{0}%' AND ({1})",
searchText, string.Join(" OR ", searchPaths.Select(x => string.Format("{0} = '{1}'", recursive ? "SCOPE" : "DIRECTORY", Path.Combine(rootFolder, x))).ToArray()));
conn.Open();
@ -318,7 +318,7 @@ namespace WebsitePanel.Providers.EnterpriseStorage
var file = new SystemFile {Name = reader[0] as string};
file.Changed = file.CreatedDate = reader[1] is DateTime ? (DateTime)reader[1] : new DateTime();
file.Size = reader[2] is long ? (long) reader[2] : 0;
file.Size = reader[2] is Decimal ? Convert.ToInt64((Decimal) reader[2]) : 0;
var kind = reader[3] is IEnumerable ? ((IEnumerable)reader[3]).Cast<string>().ToList() : null;
var itemType = reader[5] as string ?? string.Empty;
@ -342,6 +342,8 @@ namespace WebsitePanel.Providers.EnterpriseStorage
}
}
file.Summary = reader[6] as string;
result.Add(file);
}
}

View file

@ -3,7 +3,7 @@ using System.Linq;
namespace WebsitePanel.WebDav.Core.Extensions
{
static class UriExtensions
public static class UriExtensions
{
public static Uri Append(this Uri uri, params string[] paths)
{

View file

@ -9,6 +9,7 @@ namespace WebsitePanel.WebDav.Core
long ContentLength { get; }
long AllocatedSpace { get; set; }
string ContentType { get; }
string Summary { get; set; }
void Download(string filename);
byte[] Download();

View file

@ -89,6 +89,8 @@ namespace WebsitePanel.WebDav.Core
}
}
public string Summary { get; set; }
/// <summary>
/// Downloads content of the resource to a file specified by filename
/// </summary>

View file

@ -19,5 +19,6 @@ namespace WebsitePanel.WebDav.Core.Interfaces.Managers
string GetFileUrl(string path);
void DeleteResource(string path);
void LockFile(string path);
string GetFileFolderPath(string path);
}
}

View file

@ -103,7 +103,7 @@ namespace WebsitePanel.WebDav.Core.Managers
public bool IsFile(string path)
{
string folder = GetFileFolder(path);
string folder = GetFileFolderPath(path);
if (string.IsNullOrWhiteSpace(folder))
{
@ -124,7 +124,7 @@ namespace WebsitePanel.WebDav.Core.Managers
{
try
{
string folder = GetFileFolder(path);
string folder = GetFileFolderPath(path);
var resourceName = GetResourceName(path);
@ -212,7 +212,7 @@ namespace WebsitePanel.WebDav.Core.Managers
path = RemoveLeadingFromPath(path, "edit");
path = RemoveLeadingFromPath(path, WspContext.User.OrganizationId);
string folderPath = GetFileFolder(path);
string folderPath = GetFileFolderPath(path);
OpenFolder(folderPath);
@ -232,7 +232,7 @@ namespace WebsitePanel.WebDav.Core.Managers
{
try
{
string folder = GetFileFolder(path);
string folder = GetFileFolderPath(path);
var resourceName = GetResourceName(path);
@ -250,7 +250,7 @@ namespace WebsitePanel.WebDav.Core.Managers
{
try
{
string folder = GetFileFolder(path);
string folder = GetFileFolderPath(path);
var resourceName = GetResourceName(path);
@ -270,7 +270,7 @@ namespace WebsitePanel.WebDav.Core.Managers
{
try
{
string folder = GetFileFolder(path);
string folder = GetFileFolderPath(path);
var resourceName = GetResourceName(path);
@ -345,6 +345,7 @@ namespace WebsitePanel.WebDav.Core.Managers
webDavitem.SetLastModified(file.Changed);
webDavitem.ContentLength = file.Size;
webDavitem.AllocatedSpace = file.FRSMQuotaMB;
webDavitem.Summary = file.Summary;
convertResult.Add(webDavitem);
}
@ -372,7 +373,7 @@ namespace WebsitePanel.WebDav.Core.Managers
targetStream.Write(buffer, 0, n);
}
private string GetFileFolder(string path)
public string GetFileFolderPath(string path)
{
path = path.TrimEnd('/');

View file

@ -46,6 +46,18 @@ namespace WebsitePanel.WebDavPortal
#region Enterprise storage
routes.MapRoute(
name: FileSystemRouteNames.SearchFiles,
url: "storage/search/{org}/{*pathPart}",
defaults: new { controller = "FileSystem", action = "SearchFiles", pathPart = UrlParameter.Optional }
);
routes.MapRoute(
name: FileSystemRouteNames.SearchFilesContent,
url: "storage/ajax/search/{org}/{*pathPart}",
defaults: new { controller = "FileSystem", action = "SearchFilesContent", pathPart = UrlParameter.Optional }
);
routes.MapRoute(
name: FileSystemRouteNames.ChangeWebDavViewType,
url: "storage/change-view-type/{viewType}",

View file

@ -21,5 +21,8 @@ namespace WebsitePanel.WebDavPortal.UI.Routes
public const string DeleteFiles = "DeleteFilesRoute";
public const string DownloadFile = "DownloadFileRoute";
public const string SearchFiles = "SearchFilesRoute";
public const string SearchFilesContent = "SearchFilesPostRoute";
}
}

View file

@ -60,6 +60,17 @@ tr.selected-file {
.table-icon {
height: 30px;
vertical-align: top;
}
.column-name .file-info {
display: inline-block;
padding-left: 5px;
width: 90%;
}
.table-icon.search {
height: 45px;
}
.noselect {
@ -77,6 +88,8 @@ tr.selected-file {
#webdav-items-table .file-link {
padding-left: 5px;
padding-top: 5px;
display: inline-block;
vertical-align: middle !important;
}
@ -86,6 +99,11 @@ tr.selected-file {
height: 32px;
}
#summary.summary {
font-size: 11px;
color: rgb(152, 152, 152);
}
.drag-and-drop-area input {
/* IE 8 */
-ms-filter: "progid:DXImageTransform.Microsoft.Alpha(Opacity=0)";
@ -252,16 +270,29 @@ tr.selected-file {
width: 200px;
}
.search-block {
float: right;
.breadcrumb-wsp {
display: inline-block;
padding-top: 5px;
}
.search-block input, .search-block label {
.search-block {
float: right;
margin-right: 10px !important;
width: 36%;
}
.search-block input{
display: inline-block;
font-weight: normal;
}
.search-block label {
display: inline-block;
width: initial;
font-weight: normal;
}
.elements-container {
padding-top: 10px;
}
@ -372,3 +403,9 @@ div#breadcrumb_wrapper a:last-child {
float: none;
display: inline-block;
}
@media (min-width: 768px) {
.navbar-right {
margin-right: 0;
}
}

View file

@ -35,6 +35,7 @@ using WebsitePanel.WebDavPortal.Models.Common.Enums;
using WebsitePanel.WebDavPortal.Models.FileSystem;
using WebsitePanel.WebDavPortal.UI;
using WebsitePanel.WebDavPortal.UI.Routes;
using WebsitePanel.WebDav.Core.Extensions;
namespace WebsitePanel.WebDavPortal.Controllers
@ -143,7 +144,6 @@ namespace WebsitePanel.WebDavPortal.Controllers
}
}
[HttpGet]
public ActionResult GetContentDetails(string org, string pathPart, [ModelBinder(typeof (JqueryDataTableModelBinder))] JqueryDataTableRequest dtRequest)
{
@ -160,7 +160,7 @@ namespace WebsitePanel.WebDavPortal.Controllers
var tableItems = Mapper.Map<IEnumerable<WebDavResource>, IEnumerable<ResourceTableItemModel>>(folderItems).ToList();
FillContentModel(tableItems);
FillContentModel(tableItems, org);
var orders = dtRequest.Orders.ToList();
orders.Insert(0, new JqueryDataTableOrder{Column = 3, Ascending = false});
@ -184,6 +184,24 @@ namespace WebsitePanel.WebDavPortal.Controllers
return PartialView("_ResourseCollectionPartial", result);
}
public ActionResult SearchFiles(string org, string pathPart, string searchValue)
{
if (string.IsNullOrEmpty(searchValue))
{
return RedirectToRoute(FileSystemRouteNames.ShowContentPath);
}
var model = new ModelForWebDav
{
UrlSuffix = pathPart,
Permissions = _webDavAuthorizationService.GetPermissions(WspContext.User, pathPart),
UserSettings = _userSettingsManager.GetUserSettings(WspContext.User.AccountId),
SearchValue = searchValue
};
return View("ShowContentSearchResultTable", model);
}
[HttpGet]
public ActionResult DownloadFile(string org, string pathPart)
{
@ -329,17 +347,17 @@ namespace WebsitePanel.WebDavPortal.Controllers
}
#endregion
private void FillContentModel(IEnumerable<ResourceTableItemModel> items)
private void FillContentModel(IEnumerable<ResourceTableItemModel> items, string organizationId)
{
foreach (var item in items)
{
var opener = _openerManager[Path.GetExtension(item.DisplayName)];
var pathPart = item.Href.AbsolutePath.Replace("/" + WspContext.User.OrganizationId, "").TrimStart('/');
switch (opener)
{
case FileOpenerType.OfficeOnline:
{
var pathPart = item.Href.AbsolutePath.Replace("/" + WspContext.User.OrganizationId, "").TrimStart('/');
item.Url = string.Concat(Url.RouteUrl(FileSystemRouteNames.EditOfficeOnline, new {org = WspContext.User.OrganizationId, pathPart = ""}), pathPart);
break;
}
@ -350,6 +368,11 @@ namespace WebsitePanel.WebDavPortal.Controllers
}
}
var folderPath = Server.UrlDecode(_webdavManager.GetFileFolderPath(pathPart));
item.FolderUrlAbsoluteString = Server.UrlDecode(Url.RouteUrl(FileSystemRouteNames.ShowContentPath, new {org = organizationId, pathPart = folderPath}, Request.Url.Scheme));
item.FolderUrlLocalString = Url.RouteUrl(FileSystemRouteNames.ShowContentPath, new { org = organizationId, pathPart = folderPath });
if (Request.Browser.IsMobileDevice)
{
item.IsTargetBlank = false;

View file

@ -45,6 +45,7 @@ namespace WebsitePanel.WebDavPortal.Mapping.Profiles.Webdav
.ForMember(ti => ti.LastModified, x => x.MapFrom(hi => hi.LastModified))
.ForMember(ti => ti.LastModifiedFormated, x => x.MapFrom(hi => hi.LastModified == DateTime.MinValue ? "--" : (new WebDavResource(null, hi)).LastModified.ToString("dd/MM/yyyy hh:mm tt")))
.ForMember(ti => ti.Summary, x => x.MapFrom(hi => hi.Summary))
.ForMember(ti => ti.IsRoot, x => x.MapFrom(hi => hi.IsRootItem))
.ForMember(ti => ti.Size, x => x.MapFrom(hi => hi.ContentLength))
.ForMember(ti => ti.Quota, x => x.MapFrom(hi => hi.AllocatedSpace))

View file

@ -18,7 +18,10 @@ namespace WebsitePanel.WebDavPortal.Models.FileSystem
public DateTime LastModified { get; set; }
public string LastModifiedFormated { get; set; }
public string IconHref { get; set; }
public string FolderUrlAbsoluteString { get; set; }
public string FolderUrlLocalString { get; set; }
public string FolderName { get; set; }
public string Summary { get; set; }
public override dynamic this[int index]
{

View file

@ -150,6 +150,15 @@ namespace WebsitePanel.WebDavPortal.Resources {
}
}
/// <summary>
/// Looks up a localized string similar to File.
/// </summary>
public static string File {
get {
return ResourceManager.GetString("File", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to File Upload.
/// </summary>
@ -168,6 +177,15 @@ namespace WebsitePanel.WebDavPortal.Resources {
}
}
/// <summary>
/// Looks up a localized string similar to Info.
/// </summary>
public static string Info {
get {
return ResourceManager.GetString("Info", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to {0} items was removed..
/// </summary>
@ -258,6 +276,24 @@ namespace WebsitePanel.WebDavPortal.Resources {
}
}
/// <summary>
/// Looks up a localized string similar to Search Documents.
/// </summary>
public static string SearchDocuments {
get {
return ResourceManager.GetString("SearchDocuments", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to Search Results.
/// </summary>
public static string SearchResults {
get {
return ResourceManager.GetString("SearchResults", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to Select files to upload.
/// </summary>

View file

@ -147,12 +147,18 @@
<data name="Error" xml:space="preserve">
<value>Error</value>
</data>
<data name="File" xml:space="preserve">
<value>File</value>
</data>
<data name="FileUpload" xml:space="preserve">
<value>File Upload</value>
</data>
<data name="GigabyteShort" xml:space="preserve">
<value>Gb</value>
</data>
<data name="Info" xml:space="preserve">
<value>Info</value>
</data>
<data name="ItemsWasRemovedFormat" xml:space="preserve">
<value>{0} items was removed.</value>
</data>
@ -183,6 +189,12 @@
<data name="Search" xml:space="preserve">
<value>Search</value>
</data>
<data name="SearchDocuments" xml:space="preserve">
<value>Search Documents</value>
</data>
<data name="SearchResults" xml:space="preserve">
<value>Search Results</value>
</data>
<data name="SelectFilesToUpload" xml:space="preserve">
<value>Select files to upload</value>
</data>

View file

@ -1,18 +1,19 @@
function CheckAuthenticationExpiration(authcookieName, logoutUrl) {
var c = $.cookie(authcookieName);
function CheckAuthenticationExpiration(authTimeOutCookieName, authCookieName, logoutUrl) {
var c = $.cookie(authTimeOutCookieName);
if (c != null && c != "" && !isNaN(c)) {
var now = new Date();
var ms = parseInt(c, 10);
var expiration = new Date().setTime(ms);
if (now > expiration) {
$.removeCookie(authTimeOutCookieName, { path: '/' });
window.location.replace(logoutUrl);
}
}
}
function StartAuthExpirationCheckTimer(authcookieName, logoutUrl) {
function StartAuthExpirationCheckTimer(authTimeOutCookieName, authCookieName, logoutUrl) {
setInterval(function() {
CheckAuthenticationExpiration(authcookieName, logoutUrl);
CheckAuthenticationExpiration(authTimeOutCookieName, authCookieName, logoutUrl);
}, 20000);
}

View file

@ -1,6 +1,12 @@
function WspFileBrowser() {
this.settings = { deletionBlockSelector: ".file-actions-menu .file-deletion", deletionUrl: "storage/files-group-action/delete" };
this.table = null;
this.settings = {
deletionBlockSelector: ".file-actions-menu .file-deletion",
deletionUrl: "storage/files-group-action/delete",
textDateModified: "Date modified",
textSize: "Size"
};
this.itemsTable = null;
this.searchTable = null;
}
WspFileBrowser.prototype = {
@ -35,6 +41,7 @@ WspFileBrowser.prototype = {
},
deleteSelectedItems: function (e) {
$.ajax({
type: 'POST',
url: wsp.fileBrowser.settings.deletionUrl,
@ -45,7 +52,7 @@ WspFileBrowser.prototype = {
wsp.fileBrowser.clearDeletedItems(model.DeletedFiles);
wsp.fileBrowser.refreshDeletionBlock();
wsp.fileBrowser.refreshDataTable();
wsp.fileBrowser.refreshDataTable(wsp.fileBrowser.itemsTable);
wsp.dialogs.hideProcessDialog();
},
@ -53,7 +60,7 @@ WspFileBrowser.prototype = {
wsp.messages.addErrorMessage(errorThrown);
wsp.fileBrowser.refreshDeletionBlock();
wsp.fileBrowser.refreshDataTable();
wsp.fileBrowser.refreshDataTable(wsp.fileBrowser.itemsTable);
wsp.dialogs.hideProcessDialog();
}
@ -79,10 +86,11 @@ WspFileBrowser.prototype = {
},
initDataTable: function (tableId, ajaxUrl) {
this.table = $(tableId).dataTable({
this.itemsTable = $(tableId).dataTable({
"ajax": ajaxUrl,
"processing": false,
"serverSide": true,
"dom": 'rtlp',
"columnDefs": [
{
"render": function(data, type, row) {
@ -128,18 +136,87 @@ WspFileBrowser.prototype = {
$(tableId).removeClass('dataTable');
var oTable = this.table;
$(tableId+'_filter input').unbind();
$(tableId+'_filter input').bind('keyup', function (e) {
if (e.keyCode == 13) {
oTable.fnFilter(this.value);
}
});
//var oTable = this.table;
//$(searchInputId).bind('keyup', function (e) {
// if (e.keyCode == 13) {
// oTable.fnFilter(this.value);
// }
//});
//$(searchInputId).keydown(function (event) {
// if (event.keyCode == 13) {
// event.preventDefault();
// return false;
// }
// return true;
//});
},
refreshDataTable: function () {
if (this.table != null) {
this.table.fnDraw(false);
initSearchDataTable: function (tableId, ajaxUrl, initSearch) {
var settings = this.settings;
var classThis = this;
this.searchTable = $(tableId).dataTable({
"ajax": ajaxUrl,
"processing": false,
"serverSide": true,
"oSearch": { "sSearch": initSearch },
"dom": 'rtlp',
"columnDefs": [
{
"render": function (data, type, row) {
return '<div class="column-name">' +
'<img class="table-icon search" src="' + row.IconHref + '"/>' +
'<div class="file-info">' +
'<a href="' + row.Url + '" ' + (row.IsTargetBlank ? 'target="_blank"' : '') + ' class="file-link" title="' + row.DisplayName + '">' +
row.DisplayName +
'</a>' +
'<div id="summary" class="summary">' + (row.Summary ? (row.Summary + '').substring(0, 500) + '...' : '') + '</div>' +
'<div>' +
'<a href="' + row.FolderUrlLocalString + '" ' + 'target="_blank" class="file-link" >' +
row.FolderUrlAbsoluteString +
'</a>' +
'</div>' +
'</div>' +
'</div>';
},
"targets": 0
},
{
"render": function (data, type, row) {
return '<div>' +settings.textDateModified+': '+ row.LastModifiedFormated+ '</div>' +
'<div>' + settings.textSize + ': ' + classThis.bytesToSize(row.Size) + '</div>';
},
"orderable": false,
"width": "25%",
"targets": 1
}
],
"createdRow": function (row, data, index) {
$(row).addClass('element-container');
},
"fnPreDrawCallback": function () {
// gather info to compose a message
wsp.dialogs.showProcessDialog();
return true;
},
"fnDrawCallback": function () {
// in case your overlay needs to be put away automatically you can put it here
wsp.dialogs.hideProcessDialog();
}
});
$(tableId).removeClass('dataTable');
},
refreshDataTable: function (table) {
if (table != null) {
table.fnDraw(false);
}
},

View file

@ -53,9 +53,3 @@ else
</script>
}
}
@section popups
{
@Html.Partial("_ProcessDialog", null)
@Html.Partial("_ConfirmDialog")
}

View file

@ -0,0 +1,28 @@
@using WebsitePanel.WebDavPortal.Resources
@using WebsitePanel.WebDavPortal.UI.Routes
@model WebsitePanel.WebDavPortal.Models.ModelForWebDav
@Html.Partial("_ShowContentTopMenu", Model)
<div class="prevent-deselect container">
<table id="search-items-table" class="display table table-striped table-bordered noselect" cellspacing="0" width="100%">
<thead>
<tr>
<th>@UI.File</th>
<th>@UI.Details</th>
</tr>
</thead>
</table>
</div>
@section scripts
{
<script>
$(document).ready(function() {
wsp.fileBrowser.setSettings({ deletionUrl: "@Url.RouteUrl(FileSystemRouteNames.DeleteFiles)" });
wsp.fileBrowser.initSearchDataTable('#search-items-table', '@Url.RouteUrl(FileSystemRouteNames.ShowContentDetails)', '@Model.SearchValue');
});
</script>
}

View file

@ -3,21 +3,6 @@
@using WebsitePanel.WebDavPortal.UI.Routes
@model WebsitePanel.WebDavPortal.Models.ModelForWebDav
<div class="container">
<div class="search-block navbar-right">
<div>
@using (Html.BeginRouteForm(FileSystemRouteNames.ShowContentPath))
{
<label>
@UI.Search:
</label>
@Html.TextBoxFor(x => x.SearchValue, new { @class = "form-control input-sm"})
}
</div>
</div>
</div>
<div class="container">

View file

@ -15,8 +15,3 @@
</table>
</div>
@section popups
{
@Html.Partial("_ProcessDialog", null)
@Html.Partial("_ConfirmDialog")
}

View file

@ -10,15 +10,42 @@
@if (Model != null)
{
string header = WspContext.User.OrganizationId;
<a href="/@header/" class="processing-dialog">@header</a>
string[] elements = Model.UrlSuffix.Split(new[] { "/" }, StringSplitOptions.RemoveEmptyEntries);
<div class="breadcrumb-wsp">
@if (String.IsNullOrEmpty(Model.SearchValue))
{
<a href="/@header/" class="processing-dialog">@header</a>
for (int i = 0; i < elements.Length; i++)
{
<span style="top: 2px;"> / </span>
<a href="@string.Concat("/" + header + "/", string.Join("/", elements.Take(i + 1)))" class="processing-dialog">@elements[i]</a>
}
}
else
{
<a href="@Url.RouteUrl(FileSystemRouteNames.ShowContentPath)" class="processing-dialog">@UI.SearchResults</a>
}
</div>
<div class="search-block navbar-right">
<div>
@using (Html.BeginRouteForm(FileSystemRouteNames.SearchFiles, FormMethod.Post))
{
<div>
<label>
@UI.SearchDocuments:
</label>
@Html.TextBox("searchValue", Model.SearchValue, new { @class = "form-control input-sm" })
</div>
}
</div>
</div>
}
</div>
@if (string.IsNullOrEmpty(Model.SearchValue))
{
<div class="container file-actions-menu prevent-deselect">
@if (Model.Permissions.HasFlag(WebDavPermissions.Write))
{
@ -47,5 +74,5 @@
<a id="upload-button" class="btn btn-success btn-sm active" href="@Url.RouteUrl(FileSystemRouteNames.UploadFile)" role="button">@UI.FileUpload</a>
}
</div>
</div>
}

View file

@ -47,6 +47,9 @@
</div>
<div class="prevent-deselect">
@Html.Partial("_ProcessDialog", null)
@Html.Partial("_ConfirmDialog")
@RenderSection("popups", required: false)
</div>
@ -63,7 +66,7 @@
<script>
$(document).ready(function () {
StartAuthExpirationCheckTimer("@WebDavAppConfigManager.Instance.AuthTimeoutCookieName", "@Url.RouteUrl(AccountRouteNames.Logout)");
StartAuthExpirationCheckTimer("@WebDavAppConfigManager.Instance.AuthTimeoutCookieName", "@FormsAuthentication.FormsCookieName", "@Url.RouteUrl(AccountRouteNames.Logout)");
});
</script>
}

View file

@ -459,6 +459,7 @@
<Content Include="Views\FileSystem\_ShowContentTopMenu.cshtml" />
<Content Include="Views\FileSystem\_ShowContentBigIcons.cshtml" />
<Content Include="Views\FileSystem\UploadFiles.cshtml" />
<Content Include="Views\FileSystem\ShowContentSearchResultTable.cshtml" />
</ItemGroup>
<ItemGroup>
<Folder Include="Models\FileSystem\Enums\" />