implements a directory component

main
Paul Schneider 9 years ago
parent f280593a1c
commit 00ac0834c6
4 changed files with 65 additions and 5 deletions

@ -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>
</div> </div>
@await Component.InvokeAsync("Directory","")
<div > <div >
<form id="postfiles" class="dropzone" method="post" enctype="multipart/form-data"> <form id="postfiles" class="dropzone" method="post" enctype="multipart/form-data">
<div class="fallback"> <div class="fallback">

@ -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…