reset admin
This commit is contained in:
		| @ -8,43 +8,39 @@ | ||||
|  | ||||
| @if (_folders != null) | ||||
| { | ||||
|     <form @ref="form" class="@(validated ? "was-validated" : "needs-validation")" novalidate> | ||||
|         <div class="container"> | ||||
|             <div class="row mb-1 align-items-center"> | ||||
|                 <Label Class="col-sm-3" For="name" HelpText="The name of the file" ResourceKey="Name">Name: </Label> | ||||
|                 <div class="col-sm-9"> | ||||
|                     <input id="name" class="form-control" @bind="@_name" maxlength="256" required /> | ||||
|                 </div> | ||||
|             </div> | ||||
|             <div class="row mb-1 align-items-center"> | ||||
|                 <Label Class="col-sm-3" For="parent" HelpText="The folder where the file is located" ResourceKey="Folder">Folder: </Label> | ||||
|                 <div class="col-sm-9"> | ||||
|                     <select id="parent" class="form-select" @bind="@_folderId"> | ||||
|                         @foreach (Folder folder in _folders) | ||||
|                         { | ||||
|                             <option value="@(folder.FolderId)">@(new string('-', folder.Level * 2))@(folder.Name)</option> | ||||
|                         } | ||||
|                     </select> | ||||
|                 </div> | ||||
|             </div> | ||||
|             <div class="row mb-1 align-items-center"> | ||||
|                 <Label Class="col-sm-3" For="size" HelpText="The size of the file (in bytes)" ResourceKey="Size">Size: </Label> | ||||
|                 <div class="col-sm-9"> | ||||
|                     <input id="size" class="form-control" @bind="@_size" readonly /> | ||||
|                 </div> | ||||
|             </div> | ||||
| <div class="container"> | ||||
|     <div class="row mb-1 align-items-center"> | ||||
|         <Label Class="col-sm-3" For="name" HelpText="The name of the file" ResourceKey="Name">Name: </Label> | ||||
|         <div class="col-sm-9"> | ||||
|             <input id="name" class="form-control" @bind="@_name" /> | ||||
|         </div> | ||||
|         <button type="button" class="btn btn-success" @onclick="SaveFile">@SharedLocalizer["Save"]</button> | ||||
|         <NavLink class="btn btn-secondary" href="@NavigateUrl()">@SharedLocalizer["Cancel"]</NavLink> | ||||
|         <br /> | ||||
|         <br /> | ||||
|         <AuditInfo CreatedBy="@_createdBy" CreatedOn="@_createdOn" ModifiedBy="@_modifiedBy" ModifiedOn="@_modifiedOn"></AuditInfo> | ||||
|     </form> | ||||
|     </div> | ||||
|     <div class="row mb-1 align-items-center"> | ||||
|         <Label Class="col-sm-3" For="parent" HelpText="The folder where the file is located" ResourceKey="Folder">Folder: </Label> | ||||
|         <div class="col-sm-9"> | ||||
|             <select id="parent" class="form-select" @bind="@_folderId"> | ||||
|                 @foreach (Folder folder in _folders) | ||||
|                 { | ||||
|                     <option value="@(folder.FolderId)">@(new string('-', folder.Level * 2))@(folder.Name)</option> | ||||
|                 } | ||||
|             </select> | ||||
|         </div> | ||||
|     </div> | ||||
|     <div class="row mb-1 align-items-center"> | ||||
|         <Label Class="col-sm-3" For="size" HelpText="The size of the file (in bytes)" ResourceKey="Size">Size: </Label> | ||||
|         <div class="col-sm-9"> | ||||
|             <input id="size" class="form-control" @bind="@_size" readonly /> | ||||
|         </div> | ||||
|     </div> | ||||
| </div> | ||||
|     <button type="button" class="btn btn-success" @onclick="SaveFile">@SharedLocalizer["Save"]</button> | ||||
|     <NavLink class="btn btn-secondary" href="@NavigateUrl()">@SharedLocalizer["Cancel"]</NavLink> | ||||
|     <br /> | ||||
|     <br /> | ||||
|     <AuditInfo CreatedBy="@_createdBy" CreatedOn="@_createdOn" ModifiedBy="@_modifiedBy" ModifiedOn="@_modifiedOn"></AuditInfo> | ||||
| } | ||||
|  | ||||
| @code { | ||||
|     private ElementReference form; | ||||
|     private bool validated = false; | ||||
|     private int _fileId = -1; | ||||
|     private string _name; | ||||
|     private List<Folder> _folders; | ||||
| @ -86,35 +82,26 @@ | ||||
|  | ||||
|     private async Task SaveFile() | ||||
|     { | ||||
|         validated = true; | ||||
|         var interop = new Interop(JSRuntime); | ||||
|         if (await interop.FormValid(form)) | ||||
|         try | ||||
|         { | ||||
|             try | ||||
|             if (_name.IsPathOrFileValid()) | ||||
|             { | ||||
|                 if (_name.IsPathOrFileValid()) | ||||
|                 { | ||||
|                     File file = await FileService.GetFileAsync(_fileId); | ||||
|                     file.Name = _name; | ||||
|                     file.FolderId = _folderId; | ||||
|                     file = await FileService.UpdateFileAsync(file); | ||||
|                     await logger.LogInformation("File Saved {File}", file); | ||||
|                     NavigationManager.NavigateTo(NavigateUrl()); | ||||
|                 } | ||||
|                 else | ||||
|                 { | ||||
|                     AddModuleMessage(Localizer["Message.File.InvalidName"], MessageType.Warning); | ||||
|                 } | ||||
|                 File file = await FileService.GetFileAsync(_fileId); | ||||
|                 file.Name = _name; | ||||
|                 file.FolderId = _folderId; | ||||
|                 file = await FileService.UpdateFileAsync(file); | ||||
|                 await logger.LogInformation("File Saved {File}", file); | ||||
|                 NavigationManager.NavigateTo(NavigateUrl()); | ||||
|             } | ||||
|             catch (Exception ex) | ||||
|             else | ||||
|             { | ||||
|                 await logger.LogError(ex, "Error Saving File {FileId} {Error}", _fileId, ex.Message); | ||||
|                 AddModuleMessage(Localizer["Error.File.Save"], MessageType.Error); | ||||
|                 AddModuleMessage(Localizer["Message.File.InvalidName"], MessageType.Warning); | ||||
|             } | ||||
|         } | ||||
|         else | ||||
|         catch (Exception ex) | ||||
|         { | ||||
|             AddModuleMessage(SharedLocalizer["Message.InfoRequired"], MessageType.Warning); | ||||
|             await logger.LogError(ex, "Error Saving File {FileId} {Error}", _fileId, ex.Message); | ||||
|             AddModuleMessage(Localizer["Error.File.Save"], MessageType.Error); | ||||
|         } | ||||
|     } | ||||
| } | ||||
|  | ||||
		Reference in New Issue
	
	Block a user
	 Grayson Walker
					Grayson Walker