Updating for the next

This commit is contained in:
Eugene ;) 2020-07-02 09:15:33 +02:00
parent 1d173f2467
commit 720ed56432
18 changed files with 174 additions and 84 deletions

View File

@ -1,6 +1,4 @@
using System; using System;
using System.Collections.Generic;
using System.Text;
namespace Seenginx.Models namespace Seenginx.Models
{ {

View File

@ -1,8 +1,4 @@
using System; namespace Seenginx.Models
using System.Collections.Generic;
using System.Text;
namespace Seenginx.Models
{ {
public class DmesgFilter public class DmesgFilter
{ {

View File

@ -1,6 +1,4 @@
using System; using System.Collections.Generic;
using System.Collections.Generic;
using System.Text;
namespace Seenginx.Models namespace Seenginx.Models
{ {

View File

@ -1,8 +1,4 @@
using System; namespace Seenginx.Models
using System.Collections.Generic;
using System.Text;
namespace Seenginx.Models
{ {
public class NginxFilter public class NginxFilter
{ {

View File

@ -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; }
}
}

View File

@ -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
}
}

View File

@ -1,6 +1,4 @@
using System; using System;
using System.Collections.Generic;
using System.Text;
namespace Seenginx.Models namespace Seenginx.Models
{ {

View File

@ -1,8 +1,4 @@
using System; namespace Seenginx.Models
using System.Collections.Generic;
using System.Text;
namespace Seenginx.Models
{ {
public class SystemDFilter public class SystemDFilter
{ {

View File

@ -1,8 +1,4 @@
using System; namespace Seenginx.Models
using System.Collections.Generic;
using System.Text;
namespace Seenginx.Models
{ {
public class SystemDLogsFilter public class SystemDLogsFilter
{ {

View File

@ -188,12 +188,14 @@ namespace Seenginx.Components
} }
[Parameter] [Parameter]
public EventCallback DeleteFileModal { get; set; } public GeneralNotificationModalBase DeleteFileModal { get; set; }
[Parameter] protected void OnDeleteDialog()
public Result<bool> DeleteResult { get; set; }
protected async Task OnDeleteDialog(MouseEventArgs eventArgs)
{ {
await DeleteFileModal.InvokeAsync(eventArgs); DeleteFileModal.Show(new NotificationSettings
{
PopupType = PopupType.YesNo,
Text = $"Do you want to delete '{SelectedFile.Name}' configuration file?"
});
} }

View File

@ -2,18 +2,104 @@
<Modal @ref="ModalReference"> <Modal @ref="ModalReference">
<ModalBackdrop /> <ModalBackdrop />
<ModalContent IsForm="false" IsCentered="true"> <ModalContent>
<ModalHeader>
<ModalTitle>
<span class="icon is-medium"><i class="mdi @NotificationSettings.TitleClass"></i></span>
<span>@NotificationSettings.Title</span>
</ModalTitle>
</ModalHeader>
<ModalBody> <ModalBody>
<p>@NotificationSettings.Text</p> <p>@NotificationSettings.Text</p>
</ModalBody> </ModalBody>
<ModalFooter> <ModalFooter>
<Blazorise.Bulma.Button Color="@NotificationSettings.ButtonColor" Clicked="@HideGeneralNotificationModal">Ok</Blazorise.Bulma.Button> <div class="level fullwidth">
@switch (NotificationSettings.PopupType)
{
case PopupType.Ok:
<div class="level-right">
<div class="level-item">
<Blazorise.Bulma.Button Clicked="Ok" Class="is-rounded neoBtnSmall is-small has-text-dark">
<span class="icon is-small has-text-success">
<i class="mdi mdi-check"></i>
</span>
<span>Ok</span>
</Blazorise.Bulma.Button>
</div>
</div>
break;
case PopupType.OkCancel:
<div class="level-left">
<div class="level-item">
<Blazorise.Bulma.Button Clicked="Cancel" Class="is-rounded neoBtnSmall is-small has-text-dark">
<span class="icon is-small">
<i class="mdi mdi-close"></i>
</span>
<span>Cancel</span>
</Blazorise.Bulma.Button>
</div>
</div>
<div class="level-right">
<div class="level-item">
<Blazorise.Bulma.Button Clicked="Ok" Class="is-rounded neoBtnSmall is-small has-text-dark" Type="ButtonType.Submit">
<span class="icon is-small has-text-success">
<i class="mdi mdi-check"></i>
</span>
<span>Ok</span>
</Blazorise.Bulma.Button>
</div>
</div>
break;
case PopupType.YesNo:
<div class="level-left">
<div class="level-item">
<Blazorise.Bulma.Button Clicked="No" Class="is-rounded neoBtnSmall is-small has-text-dark">
<span class="icon is-small has-text-danger">
<i class="mdi mdi-close"></i>
</span>
<span>No</span>
</Blazorise.Bulma.Button>
</div>
</div>
<div class="level-right">
<div class="level-item">
<Blazorise.Bulma.Button Clicked="Yes" Class="is-rounded neoBtnSmall is-small has-text-dark" Type="ButtonType.Submit">
<span class="icon is-small has-text-success">
<i class="mdi mdi-check"></i>
</span>
<span>Yes</span>
</Blazorise.Bulma.Button>
</div>
</div>
break;
case PopupType.YesNoCancel:
<div class="level-left">
<div class="level-item">
<Blazorise.Bulma.Button Clicked="Cancel" Class="is-rounded neoBtnSmall is-small has-text-dark">
<span class="icon is-small">
<i class="mdi mdi-close"></i>
</span>
<span>Cancel</span>
</Blazorise.Bulma.Button>
</div>
</div>
<div class="level-right">
<div class="level-item">
<Blazorise.Bulma.Button Clicked="No" Class="is-rounded neoBtnSmall is-small has-text-dark">
<span class="icon is-small has-text-danger">
<i class="mdi mdi-close"></i>
</span>
<span>No</span>
</Blazorise.Bulma.Button>
</div>
<div class="level-item">
<Blazorise.Bulma.Button Clicked="Yes" Class="is-rounded neoBtnSmall is-small has-text-dark" Type="ButtonType.Submit">
<span class="icon is-small has-text-success">
<i class="mdi mdi-check"></i>
</span>
<span>Yes</span>
</Blazorise.Bulma.Button>
</div>
</div>
break;
default:
break;
}
</div>
</ModalFooter> </ModalFooter>
</ModalContent> </ModalContent>
</Modal> </Modal>

View File

@ -1,5 +1,6 @@
using Blazorise; using Blazorise;
using Microsoft.AspNetCore.Components; using Microsoft.AspNetCore.Components;
using Seenginx.Models;
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq; using System.Linq;
@ -9,36 +10,20 @@ namespace Seenginx.Components
{ {
public class GeneralNotificationModalBase : ComponentBase public class GeneralNotificationModalBase : ComponentBase
{ {
public Modal ModalReference { get; set; } = new Modal();
public NotificationSettings NotificationSettings { get; set; }
[Parameter] [Parameter]
public Modal ModalReference { get; set; } public EventCallback<PopupAnswer> PopupCallback { get; set; }
[Parameter]
public GeneralNotificationSettings NotificationSettings { get; set; }
public void ShowGeneralNotificationModal(string titleClass, string title, string text, Color color) public void Show(NotificationSettings notificationSettings)
{ {
NotificationSettings.TitleClass = titleClass; NotificationSettings = notificationSettings;
NotificationSettings.Title = title;
NotificationSettings.Text = text;
NotificationSettings.ButtonColor = color;
ModalReference.Show(); ModalReference.Show();
} }
public void HideGeneralNotificationModal() public async Task Ok() => await PopupCallback.InvokeAsync(PopupAnswer.Ok);
{ public async Task Cancel() => await PopupCallback.InvokeAsync(PopupAnswer.Cancel);
ModalReference.Hide(); public async Task Yes() => await PopupCallback.InvokeAsync(PopupAnswer.Yes);
NotificationSettings.TitleClass = null; public async Task No() => await PopupCallback.InvokeAsync(PopupAnswer.No);
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; }
} }
} }

View File

@ -3,8 +3,7 @@
<FilesWithEditor CFile="ConfigFile" Filters="Filters" Files="ConfigFiles" FilterFolder="FilterFolder" <FilesWithEditor CFile="ConfigFile" Filters="Filters" Files="ConfigFiles" FilterFolder="FilterFolder"
SelectedFile="SelectedFile" SelectedFileChanged="SelectedFileChanged" SelectedFile="SelectedFile" SelectedFileChanged="SelectedFileChanged"
TestConfiguration="TestConfiguration" TestResult="TestResult" TestConfiguration="TestConfiguration" TestResult="TestResult"
DeleteFileModal="DeleteFile" DeleteResult="DeleteResult" DeleteFileModal="DeleteNotificationModal" AddFileModal="ShowAddFileModal">
AddFileModal="ShowAddFileModal">
</FilesWithEditor> </FilesWithEditor>
<Modal @ref="AddFileModal"> <Modal @ref="AddFileModal">
<ModalBackdrop /> <ModalBackdrop />
@ -71,4 +70,5 @@
</ModalFooter> </ModalFooter>
</ModalContent> </ModalContent>
</Modal> </Modal>
@*<GeneralNotificationModal ModalReference="GeneralNotificationModal" NotificationSettings="GeneralNotificationSettings"></GeneralNotificationModal>*@ <GeneralNotificationModal PopupCallback="DeleteFile"></GeneralNotificationModal>
@*<GeneralNotificationModal ></GeneralNotificationModal>*@

View File

@ -25,8 +25,7 @@ namespace Seenginx.Pages
public ConfigFile SelectedFile { get; set; } public ConfigFile SelectedFile { get; set; }
public List<string> Filters { get; set; } = new List<string>(); public List<string> Filters { get; set; } = new List<string>();
public List<int> FilteredOutFiles { get; set; } = new List<int>(); public List<int> FilteredOutFiles { get; set; } = new List<int>();
public Modal GeneralNotificationModal { get; set; } = new Modal(); public NotificationSettings GeneralNotificationSettings { get; set; } = null;
public GeneralNotificationSettings GeneralNotificationSettings { get; set; } = null;
public Dictionary<string, string> FilterFolder { get; set; } = new Dictionary<string, string>(); public Dictionary<string, string> FilterFolder { get; set; } = new Dictionary<string, string>();
@ -101,32 +100,32 @@ namespace Seenginx.Pages
} }
public Result<string> TestResult { get; set; } public Result<string> TestResult { get; set; }
public Modal TestNotificationModal { get; set; } = new Modal();
public async Task TestConfiguration() public async Task TestConfiguration()
{ {
TestResult = await NginxService.TestNginxConfigurations(SelectedFile); TestResult = await NginxService.TestNginxConfigurations(SelectedFile);
if (TestResult.AllOk) if (TestResult.AllOk)
GeneralNotificationSettings = new GeneralNotificationSettings GeneralNotificationSettings = new NotificationSettings
{ {
ButtonColor = Color.Success, Text = $"Test of config file '{SelectedFile.Name}' completed with success.",
TitleClass = "mdi-success", PopupType = PopupType.Ok
Title = "Success",
Text = $"Test of config file '{SelectedFile.Name}' completed with success."
}; };
else else
GeneralNotificationSettings = new GeneralNotificationSettings GeneralNotificationSettings = new NotificationSettings
{ {
ButtonColor = Color.Danger, Text = TestResult.ErrorMessage,
TitleClass = "mdi-error", PopupType = PopupType.Ok
Title = "Failure",
Text = TestResult.ErrorMessage
}; };
GeneralNotificationModal.Show(); TestNotificationModal.Show();
} }
public Result<bool> DeleteResult { get; set; } public GeneralNotificationModalBase DeleteNotificationModal { get; set; } = new GeneralNotificationModalBase();
public void DeleteFile() public void DeleteFile(PopupAnswer popupAnswer)
{ {
DeleteResult = FileService.DeleteFile(SelectedFile); if (popupAnswer == PopupAnswer.Yes)
{
var deleteResult = FileService.DeleteFile(SelectedFile);
}
} }
public void CloseModal(Modal modal) public void CloseModal(Modal modal)

View File

@ -15,6 +15,7 @@
<base href="~/" /> <base href="~/" />
<link href="_content/Blazorise/blazorise.css" rel="stylesheet" /> <link href="_content/Blazorise/blazorise.css" rel="stylesheet" />
<link href="_content/Blazorise.Bulma/blazorise.bulma.css" rel="stylesheet" /> <link href="_content/Blazorise.Bulma/blazorise.bulma.css" rel="stylesheet" />
<link href="_content/Blazored.Modal/blazored-modal.css" rel="stylesheet"/>
<environment include="Staging,Production"> <environment include="Staging,Production">
<link rel="stylesheet" href="~/css/materialdesignicons.min.css" asp-append-version="true" /> <link rel="stylesheet" href="~/css/materialdesignicons.min.css" asp-append-version="true" />
<link rel="stylesheet" href="~/css/bulma.min.css" asp-append-version="true" /> <link rel="stylesheet" href="~/css/bulma.min.css" asp-append-version="true" />

View File

@ -18,6 +18,7 @@
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<PackageReference Include="Blazored.Modal" Version="4.1.0" />
<PackageReference Include="Blazorise.Bulma" Version="0.9.1.1" /> <PackageReference Include="Blazorise.Bulma" Version="0.9.1.1" />
<PackageReference Include="Blazorise.Icons.FontAwesome" Version="0.9.1.1" /> <PackageReference Include="Blazorise.Icons.FontAwesome" Version="0.9.1.1" />
<PackageReference Include="Microsoft.AspNetCore.Mvc.Razor.RuntimeCompilation" Version="3.1.5" /> <PackageReference Include="Microsoft.AspNetCore.Mvc.Razor.RuntimeCompilation" Version="3.1.5" />

View File

@ -2,6 +2,7 @@ using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq; using System.Linq;
using System.Threading.Tasks; using System.Threading.Tasks;
using Blazored.Modal;
using Blazorise; using Blazorise;
using Blazorise.Bulma; using Blazorise.Bulma;
using Blazorise.Icons.FontAwesome; using Blazorise.Icons.FontAwesome;
@ -37,6 +38,7 @@ namespace Seenginx
{ {
options.ChangeTextOnKeyPress = true; // optional options.ChangeTextOnKeyPress = true; // optional
}).AddBulmaProviders(); }).AddBulmaProviders();
services.AddBlazoredModal();
var configPaths = new ConfigPaths(); var configPaths = new ConfigPaths();
configPaths.NginxPath = @"C:\nginx\"; configPaths.NginxPath = @"C:\nginx\";

View File

@ -11,4 +11,6 @@
@using Seenginx.Components @using Seenginx.Components
@using Blazorise @using Blazorise
@using Blazorise.Bulma @using Blazorise.Bulma
@using Blazored.Modal
@using Blazored.Modal.Services