diff --git a/Oqtane.Client/App.razor b/Oqtane.Client/App.razor index 91b327ce..0723e1e7 100644 --- a/Oqtane.Client/App.razor +++ b/Oqtane.Client/App.razor @@ -1,7 +1,4 @@ -@using Microsoft.AspNetCore.Components.Authorization -@using Oqtane.Shared -@using Oqtane.Services -@inject IInstallationService InstallationService +@inject IInstallationService InstallationService @if (Initialized) { diff --git a/Oqtane.Client/Modules/Admin/Dashboard/Index.razor b/Oqtane.Client/Modules/Admin/Dashboard/Index.razor index f2eb40b9..a0ad0257 100644 --- a/Oqtane.Client/Modules/Admin/Dashboard/Index.razor +++ b/Oqtane.Client/Modules/Admin/Dashboard/Index.razor @@ -1,37 +1,31 @@ -@using Microsoft.AspNetCore.Components.Web -@using Microsoft.AspNetCore.Components.Routing -@using Oqtane.Modules -@using Oqtane.Services -@using Oqtane.Models; -@using Oqtane.Security -@namespace Oqtane.Modules.Admin.Dashboard +@namespace Oqtane.Modules.Admin.Dashboard @inherits ModuleBase @inject IPageService PageService @inject IUserService UserService - -
-
+ @code { + public override SecurityAccessLevel SecurityAccessLevel { get { return SecurityAccessLevel.Admin; } } + List pages; protected override void OnInitialized() { - // display list of pages which are children of current page - pages = PageState.Pages.Where(item => item.ParentId == PageState.Page.PageId).ToList(); + Page admin = PageState.Pages.Where(item => item.Path == "admin").FirstOrDefault(); + pages = PageState.Pages.Where(item => item.ParentId == admin.PageId).ToList(); } -} \ No newline at end of file +} diff --git a/Oqtane.Client/Modules/Admin/Files/Add.razor b/Oqtane.Client/Modules/Admin/Files/Add.razor new file mode 100644 index 00000000..26feaf57 --- /dev/null +++ b/Oqtane.Client/Modules/Admin/Files/Add.razor @@ -0,0 +1,56 @@ +@namespace Oqtane.Modules.Admin.Files +@inherits ModuleBase +@inject NavigationManager NavigationManager +@inject IFileService FileService + + + + + + +
+ + + +
+ +Cancel + +@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 + { + ShowProgressIndicator(); + + string result = await FileService.UploadFilesAsync(PageState.Site.SiteRootPath, files, ""); + if (result == "") + { + await logger.LogInformation("Files Uploaded Successfully"); + AddModuleMessage("Files Uploaded Successfully", MessageType.Success); + } + else + { + await logger.LogError("Upload Failed For {Files}", result.Replace(",",", ")); + AddModuleMessage("Upload Failed For " + result.Replace(",",", ") + ". This Could Be Due To A Network Error Or Because A File Type Is Restricted.", MessageType.Error); + } + } + catch (Exception ex) + { + await logger.LogError(ex, "Upload Failed {Error}", ex.Message); + AddModuleMessage("Upload Failed. " + ex.Message, MessageType.Error); + } + } + else + { + AddModuleMessage("You Must Select Some Files To Upload", MessageType.Warning); + } + } +} diff --git a/Oqtane.Client/Modules/Admin/Files/Index.razor b/Oqtane.Client/Modules/Admin/Files/Index.razor new file mode 100644 index 00000000..35269a70 --- /dev/null +++ b/Oqtane.Client/Modules/Admin/Files/Index.razor @@ -0,0 +1,61 @@ +@namespace Oqtane.Modules.Admin.Files +@inherits ModuleBase +@inject NavigationManager NavigationManager +@inject IFileService FileService + +@if (Files == null) +{ +

Loading...

+} +else +{ + + + +
+   + Name +
+ + + @context + +
+} + +@code { + public override SecurityAccessLevel SecurityAccessLevel { get { return SecurityAccessLevel.Admin; } } + + List Files; + Uri uri; + + protected override async Task OnParametersSetAsync() + { + try + { + Files = await FileService.GetFilesAsync(PageState.Site.SiteRootPath); + uri = new Uri(NavigationManager.Uri); + } + catch (Exception ex) + { + await logger.LogError(ex, "Error Loading Files {Error}", ex.Message); + AddModuleMessage("Error Loading Files", MessageType.Error); + } + } + + private async Task DeleteFile(string filename) + { + try + { + await FileService.DeleteFileAsync(PageState.Site.SiteRootPath, filename); + Files = await FileService.GetFilesAsync(PageState.Site.SiteRootPath); + await logger.LogInformation("File Deleted {File}", filename); + AddModuleMessage("File " + filename + " Deleted", MessageType.Success); + } + catch (Exception ex) + { + await logger.LogError(ex, "Error Deleting File {File} {Error}", filename, ex.Message); + AddModuleMessage("Error Deleting File " + filename, MessageType.Error); + } + } +} \ No newline at end of file diff --git a/Oqtane.Client/Modules/Admin/Login/Index.razor b/Oqtane.Client/Modules/Admin/Login/Index.razor index b8a77ec6..4af77908 100644 --- a/Oqtane.Client/Modules/Admin/Login/Index.razor +++ b/Oqtane.Client/Modules/Admin/Login/Index.razor @@ -1,13 +1,4 @@ -@using Microsoft.AspNetCore.Components.Authorization -@using Microsoft.AspNetCore.Components.Web -@using Microsoft.AspNetCore.Components.Routing -@using Oqtane.Modules -@using Microsoft.JSInterop -@using Oqtane.Models -@using Oqtane.Services -@using Oqtane.Providers -@using Oqtane.Shared -@namespace Oqtane.Modules.Admin.Login +@namespace Oqtane.Modules.Admin.Login @inherits ModuleBase @inject NavigationManager NavigationManager @inject IJSRuntime jsRuntime @@ -23,7 +14,6 @@
- @((MarkupString)Message)
@@ -47,7 +37,6 @@ @code { public override SecurityAccessLevel SecurityAccessLevel { get { return SecurityAccessLevel.Anonymous; } } - public string Message { get; set; } = ""; public string Username { get; set; } = ""; public string Password { get; set; } = ""; public bool Remember { get; set; } = false; @@ -67,6 +56,7 @@ user = await UserService.LoginUserAsync(user, false, false); if (user.IsAuthenticated) { + await logger.LogInformation("Login Successful For Username {Username}", Username); // complete the login on the server so that the cookies are set correctly on SignalR var interop = new Interop(jsRuntime); string antiforgerytoken = await interop.GetElementByName("__RequestVerificationToken"); @@ -75,7 +65,8 @@ } else { - Message = "
Login Failed. Please Remember That Passwords Are Case Sensitive.
"; + await logger.LogInformation("Login Failed For Username {Username}", Username); + AddModuleMessage("Login Failed. Please Remember That Passwords Are Case Sensitive.", MessageType.Error); } } else @@ -88,13 +79,14 @@ user = await UserService.LoginUserAsync(user, true, Remember); if (user.IsAuthenticated) { + await logger.LogInformation("Login Successful For Username {Username}", Username); authstateprovider.NotifyAuthenticationChanged(); - PageState.Reload = Constants.ReloadSite; - NavigationManager.NavigateTo(NavigateUrl(ReturnUrl)); + NavigationManager.NavigateTo(NavigateUrl(ReturnUrl, Reload.Site)); } else { - Message = "
Login Failed. Please Remember That Passwords Are Case Sensitive.
"; + await logger.LogInformation("Login Failed For Username {Username}", Username); + AddModuleMessage("Login Failed. Please Remember That Passwords Are Case Sensitive.", MessageType.Error); } } } diff --git a/Oqtane.Client/Modules/Admin/Logs/Detail.razor b/Oqtane.Client/Modules/Admin/Logs/Detail.razor new file mode 100644 index 00000000..28aa59a8 --- /dev/null +++ b/Oqtane.Client/Modules/Admin/Logs/Detail.razor @@ -0,0 +1,207 @@ +@namespace Oqtane.Modules.Admin.Logs +@inherits ModuleBase +@inject NavigationManager NavigationManager +@inject ILogService LogService +@inject IPageService PageService +@inject IPageModuleService PageModuleService +@inject IUserService UserService + + + + + + + + + + + + + + + + + + + + + + + @if (pagename != "") + { + + + + + } + @if (moduletitle != "") + { + + + + + } + @if (username != "") + { + + + + + } + + + + + + + + + + +
+ + + +
+ + + +
+ + + +
+ + + +
+ + + +
+ + + +
+ + + +
+ + + +
+ + + +
+ + + +
+ + +