implements a directory component
This commit is contained in:
parent
f627678abe
commit
b5d48c54b0
4 changed files with 65 additions and 5 deletions
20
Yavsc/ViewComponents/DirectoryViewComponent.cs
Normal file
20
Yavsc/ViewComponents/DirectoryViewComponent.cs
Normal file
|
|
@ -0,0 +1,20 @@
|
|||
using Microsoft.AspNet.Mvc;
|
||||
|
||||
namespace Yavsc.ViewComponents
|
||||
{
|
||||
using System.Threading.Tasks;
|
||||
using Yavsc.ViewModels.UserFiles;
|
||||
|
||||
public class DirectoryViewComponent : ViewComponent
|
||||
{
|
||||
public async Task<IViewComponentResult> InvokeAsync(string dirname)
|
||||
{
|
||||
IViewComponentResult result = null;
|
||||
await Task.Run(() =>
|
||||
{
|
||||
result = View(new UserDirectoryInfo(User.Identity.Name, dirname));
|
||||
});
|
||||
return result;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -185,6 +185,7 @@ editorcontenu.on('text-change',function(delta,source){
|
|||
<div>
|
||||
|
||||
</div>
|
||||
@await Component.InvokeAsync("Directory","")
|
||||
<div >
|
||||
<form id="postfiles" class="dropzone" method="post" enctype="multipart/form-data">
|
||||
<div class="fallback">
|
||||
|
|
|
|||
44
Yavsc/Views/Shared/Components/Directory/Default.cshtml
Normal file
44
Yavsc/Views/Shared/Components/Directory/Default.cshtml
Normal file
|
|
@ -0,0 +1,44 @@
|
|||
@using Yavsc.ViewModels.UserFiles
|
||||
@model UserDirectoryInfo
|
||||
<div class="dirinfo">
|
||||
<strong>@Model.UserName / @Model.SubPath</strong>
|
||||
<div class="subdirs">
|
||||
@foreach (string subdir in Model.SubDirectories) {
|
||||
<a href="@subdir" class="subdir">@subdir</a>
|
||||
}
|
||||
</div>
|
||||
<style>
|
||||
tr.fileheaders th {
|
||||
border-bottom: 1px solid #ddd;
|
||||
font-style: italic;
|
||||
}
|
||||
tr.fileinfo td {
|
||||
padding: 1em;
|
||||
border-bottom: 1px solid #ddd;
|
||||
}
|
||||
tr.fileinfo:nth-child(even) {background-color: #f2f2f2}
|
||||
tr.fileinfo:hover {background-color: #f5f5f5}
|
||||
|
||||
</style>
|
||||
<table >
|
||||
<tr class="fileheaders">
|
||||
<th>Nom
|
||||
</th>
|
||||
<th>Taille
|
||||
</th>
|
||||
<th>Modification
|
||||
</th>
|
||||
</tr>
|
||||
@foreach (var fileinfo in Model.Files) {
|
||||
<tr class="fileinfo">
|
||||
<td class="filename">
|
||||
<a href="@fileinfo.FileLink(Model.UserName,Model.SubPath)">
|
||||
@fileinfo.Name
|
||||
</a></td>
|
||||
<td class="filesize">@fileinfo.Size</td>
|
||||
<td class="filemdate">@fileinfo.LastModified</td>
|
||||
</tr>
|
||||
}
|
||||
</table>
|
||||
</div>
|
||||
|
||||
|
|
@ -1,5 +0,0 @@
|
|||
@model UserDirectoryInfo
|
||||
@{
|
||||
var files = User.GetUserFiles();
|
||||
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue