46 lines
1.4 KiB
Plaintext
46 lines
1.4 KiB
Plaintext
@namespace Oqtane.Modules.Admin.Files
|
|
@inherits ModuleBase
|
|
@inject NavigationManager NavigationManager
|
|
@inject IFileService FileService
|
|
|
|
@if (Files == null)
|
|
{
|
|
<p><em>Loading...</em></p>
|
|
}
|
|
else
|
|
{
|
|
<ActionLink Action="Add" Text="Add File" Style="float: right; margin: 10px;" />
|
|
|
|
<Pager Items="@Files">
|
|
<Header>
|
|
<th>Name</th>
|
|
<th> </th>
|
|
</Header>
|
|
<Row>
|
|
<td><a href="@(uri.Scheme + "://" + uri.Authority + "/" + PageState.Site.SiteRootPath + context)" target="_new">@context</a></td>
|
|
<td>
|
|
<button type="button" class="btn btn-danger" @onclick=@(async () => await DeleteFile(context))>Delete</button>
|
|
</td>
|
|
</Row>
|
|
</Pager>
|
|
}
|
|
|
|
@code {
|
|
public override SecurityAccessLevel SecurityAccessLevel { get { return SecurityAccessLevel.Admin; } }
|
|
|
|
List<string> Files;
|
|
Uri uri;
|
|
|
|
protected override async Task OnParametersSetAsync()
|
|
{
|
|
Files = await FileService.GetFilesAsync(PageState.Site.SiteRootPath);
|
|
uri = new Uri(NavigationManager.Uri);
|
|
}
|
|
|
|
private async Task DeleteFile(string filename)
|
|
{
|
|
await FileService.DeleteFileAsync(PageState.Site.SiteRootPath, filename);
|
|
Files = await FileService.GetFilesAsync(PageState.Site.SiteRootPath);
|
|
AddModuleMessage("File Deleted", MessageType.Success);
|
|
}
|
|
} |