add file manager
This commit is contained in:
51
Oqtane.Client/Modules/Admin/Files/Add.razor
Normal file
51
Oqtane.Client/Modules/Admin/Files/Add.razor
Normal file
@ -0,0 +1,51 @@
|
||||
@namespace Oqtane.Modules.Admin.Files
|
||||
@inherits ModuleBase
|
||||
@inject NavigationManager NavigationManager
|
||||
@inject IFileService FileService
|
||||
|
||||
<table class="table table-borderless">
|
||||
<tr>
|
||||
<td>
|
||||
<label for="Name" class="control-label">Files: </label>
|
||||
</td>
|
||||
<td>
|
||||
<FileUpload Multiple="true" @ref="fileupload"></FileUpload>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
<button type="button" class="btn btn-primary" @onclick="UploadFile">Upload</button>
|
||||
<NavLink class="btn btn-secondary" href="@NavigateUrl()">Cancel</NavLink>
|
||||
|
||||
|
||||
@code {
|
||||
public override SecurityAccessLevel SecurityAccessLevel { get { return SecurityAccessLevel.Admin; } }
|
||||
|
||||
FileUpload fileupload;
|
||||
|
||||
private async Task UploadFile()
|
||||
{
|
||||
string[] files = await fileupload.GetFiles();
|
||||
if (files.Length > 0)
|
||||
{
|
||||
try
|
||||
{
|
||||
if (await FileService.UploadFilesAsync(PageState.Site.SiteRootPath, files, ""))
|
||||
{
|
||||
ModuleInstance.AddModuleMessage("Files Uploaded Successfully", MessageType.Success);
|
||||
}
|
||||
else
|
||||
{
|
||||
ModuleInstance.AddModuleMessage("Upload Failed", MessageType.Error);
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
ModuleInstance.AddModuleMessage("Upload Failed. " + ex.Message, MessageType.Error);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
ModuleInstance.AddModuleMessage("You Must Select Some Files To Upload", MessageType.Warning);
|
||||
}
|
||||
}
|
||||
}
|
44
Oqtane.Client/Modules/Admin/Files/Index.razor
Normal file
44
Oqtane.Client/Modules/Admin/Files/Index.razor
Normal file
@ -0,0 +1,44 @@
|
||||
@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>@context</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;
|
||||
|
||||
protected override async Task OnParametersSetAsync()
|
||||
{
|
||||
Files = await FileService.GetFilesAsync(PageState.Site.SiteRootPath);
|
||||
}
|
||||
|
||||
private async Task DeleteFile(string filename)
|
||||
{
|
||||
await FileService.DeleteFileAsync(PageState.Site.SiteRootPath, filename);
|
||||
Files = await FileService.GetFilesAsync(PageState.Site.SiteRootPath);
|
||||
ModuleInstance.AddModuleMessage("File Deleted", MessageType.Success);
|
||||
}
|
||||
}
|
@ -58,7 +58,6 @@
|
||||
string username = "";
|
||||
string email = "";
|
||||
string displayname = "";
|
||||
string category = "";
|
||||
string createdby;
|
||||
DateTime createdon;
|
||||
string modifiedby;
|
||||
|
Reference in New Issue
Block a user