diff --git a/Seenginx.Models/ConfigFile.cs b/Seenginx.Models/ConfigFile.cs index 0a6a5ac..079d052 100644 --- a/Seenginx.Models/ConfigFile.cs +++ b/Seenginx.Models/ConfigFile.cs @@ -1,6 +1,4 @@ using System; -using System.Collections.Generic; -using System.Text; namespace Seenginx.Models { diff --git a/Seenginx.Models/DmesgFilter.cs b/Seenginx.Models/DmesgFilter.cs index 824e175..6f5e103 100644 --- a/Seenginx.Models/DmesgFilter.cs +++ b/Seenginx.Models/DmesgFilter.cs @@ -1,8 +1,4 @@ -using System; -using System.Collections.Generic; -using System.Text; - -namespace Seenginx.Models +namespace Seenginx.Models { public class DmesgFilter { diff --git a/Seenginx.Models/NewFileForm.cs b/Seenginx.Models/NewFileForm.cs index 883d57a..d63b14f 100644 --- a/Seenginx.Models/NewFileForm.cs +++ b/Seenginx.Models/NewFileForm.cs @@ -1,6 +1,4 @@ -using System; -using System.Collections.Generic; -using System.Text; +using System.Collections.Generic; namespace Seenginx.Models { diff --git a/Seenginx.Models/NginxFilter.cs b/Seenginx.Models/NginxFilter.cs index 06ddc87..360baaf 100644 --- a/Seenginx.Models/NginxFilter.cs +++ b/Seenginx.Models/NginxFilter.cs @@ -1,8 +1,4 @@ -using System; -using System.Collections.Generic; -using System.Text; - -namespace Seenginx.Models +namespace Seenginx.Models { public class NginxFilter { diff --git a/Seenginx.Models/NotificationSettings.cs b/Seenginx.Models/NotificationSettings.cs new file mode 100644 index 0000000..ed553d0 --- /dev/null +++ b/Seenginx.Models/NotificationSettings.cs @@ -0,0 +1,12 @@ +using System; +using System.Collections.Generic; +using System.Text; + +namespace Seenginx.Models +{ + public class NotificationSettings + { + public string Text { get; set; } + public PopupType PopupType { get; set; } + } +} diff --git a/Seenginx.Models/PopupEnums.cs b/Seenginx.Models/PopupEnums.cs new file mode 100644 index 0000000..ea3f4d9 --- /dev/null +++ b/Seenginx.Models/PopupEnums.cs @@ -0,0 +1,22 @@ +using System; +using System.Collections.Generic; +using System.Text; + +namespace Seenginx.Models +{ + public enum PopupType + { + Ok, + OkCancel, + YesNo, + YesNoCancel + } + + public enum PopupAnswer + { + Ok, + Cancel, + Yes, + No + } +} diff --git a/Seenginx.Models/Result.cs b/Seenginx.Models/Result.cs index b722a90..6c984c2 100644 --- a/Seenginx.Models/Result.cs +++ b/Seenginx.Models/Result.cs @@ -1,6 +1,4 @@ using System; -using System.Collections.Generic; -using System.Text; namespace Seenginx.Models { diff --git a/Seenginx.Models/SystemDFilter.cs b/Seenginx.Models/SystemDFilter.cs index 2852c2e..ab66762 100644 --- a/Seenginx.Models/SystemDFilter.cs +++ b/Seenginx.Models/SystemDFilter.cs @@ -1,8 +1,4 @@ -using System; -using System.Collections.Generic; -using System.Text; - -namespace Seenginx.Models +namespace Seenginx.Models { public class SystemDFilter { diff --git a/Seenginx.Models/SystemDLogsFilter.cs b/Seenginx.Models/SystemDLogsFilter.cs index 41a778d..0985f1e 100644 --- a/Seenginx.Models/SystemDLogsFilter.cs +++ b/Seenginx.Models/SystemDLogsFilter.cs @@ -1,8 +1,4 @@ -using System; -using System.Collections.Generic; -using System.Text; - -namespace Seenginx.Models +namespace Seenginx.Models { public class SystemDLogsFilter { diff --git a/Seenginx/Components/FilesWithEditor.razor.cs b/Seenginx/Components/FilesWithEditor.razor.cs index 6c9eee9..975d10f 100644 --- a/Seenginx/Components/FilesWithEditor.razor.cs +++ b/Seenginx/Components/FilesWithEditor.razor.cs @@ -188,12 +188,14 @@ namespace Seenginx.Components } [Parameter] - public EventCallback DeleteFileModal { get; set; } - [Parameter] - public Result DeleteResult { get; set; } - protected async Task OnDeleteDialog(MouseEventArgs eventArgs) + public GeneralNotificationModalBase DeleteFileModal { get; set; } + protected void OnDeleteDialog() { - await DeleteFileModal.InvokeAsync(eventArgs); + DeleteFileModal.Show(new NotificationSettings + { + PopupType = PopupType.YesNo, + Text = $"Do you want to delete '{SelectedFile.Name}' configuration file?" + }); } diff --git a/Seenginx/Components/GeneralNotificationModal.razor b/Seenginx/Components/GeneralNotificationModal.razor index e66d742..b68e328 100644 --- a/Seenginx/Components/GeneralNotificationModal.razor +++ b/Seenginx/Components/GeneralNotificationModal.razor @@ -2,18 +2,104 @@ - - - - - @NotificationSettings.Title - - +

@NotificationSettings.Text

- Ok +
+ @switch (NotificationSettings.PopupType) + { + case PopupType.Ok: +
+
+ + + + + Ok + +
+
+ break; + case PopupType.OkCancel: +
+
+ + + + + Cancel + +
+
+
+
+ + + + + Ok + +
+
+ break; + case PopupType.YesNo: +
+
+ + + + + No + +
+
+
+
+ + + + + Yes + +
+
+ break; + case PopupType.YesNoCancel: +
+
+ + + + + Cancel + +
+
+
+
+ + + + + No + +
+
+ + + + + Yes + +
+
+ break; + default: + break; + } +
\ No newline at end of file diff --git a/Seenginx/Components/GeneralNotificationModal.razor.cs b/Seenginx/Components/GeneralNotificationModal.razor.cs index e6571ba..c4ae659 100644 --- a/Seenginx/Components/GeneralNotificationModal.razor.cs +++ b/Seenginx/Components/GeneralNotificationModal.razor.cs @@ -1,5 +1,6 @@ using Blazorise; using Microsoft.AspNetCore.Components; +using Seenginx.Models; using System; using System.Collections.Generic; using System.Linq; @@ -9,36 +10,20 @@ namespace Seenginx.Components { public class GeneralNotificationModalBase : ComponentBase { + public Modal ModalReference { get; set; } = new Modal(); + public NotificationSettings NotificationSettings { get; set; } [Parameter] - public Modal ModalReference { get; set; } - [Parameter] - public GeneralNotificationSettings NotificationSettings { get; set; } + public EventCallback PopupCallback { get; set; } - public void ShowGeneralNotificationModal(string titleClass, string title, string text, Color color) + public void Show(NotificationSettings notificationSettings) { - NotificationSettings.TitleClass = titleClass; - NotificationSettings.Title = title; - NotificationSettings.Text = text; - NotificationSettings.ButtonColor = color; + NotificationSettings = notificationSettings; ModalReference.Show(); } - public void HideGeneralNotificationModal() - { - ModalReference.Hide(); - NotificationSettings.TitleClass = null; - NotificationSettings.Title = null; - NotificationSettings.Text = null; - NotificationSettings.ButtonColor = Color.None; - } - - } - - public class GeneralNotificationSettings - { - public string TitleClass { get; set; } - public string Title { get; set; } - public string Text { get; set; } - public Color ButtonColor { get; set; } + public async Task Ok() => await PopupCallback.InvokeAsync(PopupAnswer.Ok); + public async Task Cancel() => await PopupCallback.InvokeAsync(PopupAnswer.Cancel); + public async Task Yes() => await PopupCallback.InvokeAsync(PopupAnswer.Yes); + public async Task No() => await PopupCallback.InvokeAsync(PopupAnswer.No); } } diff --git a/Seenginx/Pages/Nginx.razor b/Seenginx/Pages/Nginx.razor index 932b3d7..63509c0 100644 --- a/Seenginx/Pages/Nginx.razor +++ b/Seenginx/Pages/Nginx.razor @@ -3,8 +3,7 @@ + DeleteFileModal="DeleteNotificationModal" AddFileModal="ShowAddFileModal"> @@ -71,4 +70,5 @@ -@**@ + +@**@ diff --git a/Seenginx/Pages/Nginx.razor.cs b/Seenginx/Pages/Nginx.razor.cs index fadf8bd..675b8d7 100644 --- a/Seenginx/Pages/Nginx.razor.cs +++ b/Seenginx/Pages/Nginx.razor.cs @@ -25,8 +25,7 @@ namespace Seenginx.Pages public ConfigFile SelectedFile { get; set; } public List Filters { get; set; } = new List(); public List FilteredOutFiles { get; set; } = new List(); - public Modal GeneralNotificationModal { get; set; } = new Modal(); - public GeneralNotificationSettings GeneralNotificationSettings { get; set; } = null; + public NotificationSettings GeneralNotificationSettings { get; set; } = null; public Dictionary FilterFolder { get; set; } = new Dictionary(); @@ -101,32 +100,32 @@ namespace Seenginx.Pages } public Result TestResult { get; set; } + public Modal TestNotificationModal { get; set; } = new Modal(); public async Task TestConfiguration() { TestResult = await NginxService.TestNginxConfigurations(SelectedFile); if (TestResult.AllOk) - GeneralNotificationSettings = new GeneralNotificationSettings + GeneralNotificationSettings = new NotificationSettings { - ButtonColor = Color.Success, - TitleClass = "mdi-success", - Title = "Success", - Text = $"Test of config file '{SelectedFile.Name}' completed with success." + Text = $"Test of config file '{SelectedFile.Name}' completed with success.", + PopupType = PopupType.Ok }; else - GeneralNotificationSettings = new GeneralNotificationSettings + GeneralNotificationSettings = new NotificationSettings { - ButtonColor = Color.Danger, - TitleClass = "mdi-error", - Title = "Failure", - Text = TestResult.ErrorMessage + Text = TestResult.ErrorMessage, + PopupType = PopupType.Ok }; - GeneralNotificationModal.Show(); + TestNotificationModal.Show(); } - public Result DeleteResult { get; set; } - public void DeleteFile() + public GeneralNotificationModalBase DeleteNotificationModal { get; set; } = new GeneralNotificationModalBase(); + public void DeleteFile(PopupAnswer popupAnswer) { - DeleteResult = FileService.DeleteFile(SelectedFile); + if (popupAnswer == PopupAnswer.Yes) + { + var deleteResult = FileService.DeleteFile(SelectedFile); + } } public void CloseModal(Modal modal) diff --git a/Seenginx/Pages/_Host.cshtml b/Seenginx/Pages/_Host.cshtml index a81cd99..fd064f1 100644 --- a/Seenginx/Pages/_Host.cshtml +++ b/Seenginx/Pages/_Host.cshtml @@ -15,6 +15,7 @@ + diff --git a/Seenginx/Seenginx.csproj b/Seenginx/Seenginx.csproj index 1118c60..614f4c4 100644 --- a/Seenginx/Seenginx.csproj +++ b/Seenginx/Seenginx.csproj @@ -18,6 +18,7 @@ + diff --git a/Seenginx/Startup.cs b/Seenginx/Startup.cs index 1fbd905..0a3a327 100644 --- a/Seenginx/Startup.cs +++ b/Seenginx/Startup.cs @@ -2,6 +2,7 @@ using System; using System.Collections.Generic; using System.Linq; using System.Threading.Tasks; +using Blazored.Modal; using Blazorise; using Blazorise.Bulma; using Blazorise.Icons.FontAwesome; @@ -37,6 +38,7 @@ namespace Seenginx { options.ChangeTextOnKeyPress = true; // optional }).AddBulmaProviders(); + services.AddBlazoredModal(); var configPaths = new ConfigPaths(); configPaths.NginxPath = @"C:\nginx\"; diff --git a/Seenginx/_Imports.razor b/Seenginx/_Imports.razor index 48194b5..2b44271 100644 --- a/Seenginx/_Imports.razor +++ b/Seenginx/_Imports.razor @@ -11,4 +11,6 @@ @using Seenginx.Components @using Blazorise @using Blazorise.Bulma +@using Blazored.Modal +@using Blazored.Modal.Services