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.Collections.Generic;
using System.Text;
namespace Seenginx.Models
{

View File

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

View File

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

View File

@ -1,8 +1,4 @@
using System;
using System.Collections.Generic;
using System.Text;
namespace Seenginx.Models
namespace Seenginx.Models
{
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.Collections.Generic;
using System.Text;
namespace Seenginx.Models
{

View File

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

View File

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

View File

@ -188,12 +188,14 @@ namespace Seenginx.Components
}
[Parameter]
public EventCallback DeleteFileModal { get; set; }
[Parameter]
public Result<bool> 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?"
});
}

View File

@ -2,18 +2,104 @@
<Modal @ref="ModalReference">
<ModalBackdrop />
<ModalContent IsForm="false" IsCentered="true">
<ModalHeader>
<ModalTitle>
<span class="icon is-medium"><i class="mdi @NotificationSettings.TitleClass"></i></span>
<span>@NotificationSettings.Title</span>
</ModalTitle>
</ModalHeader>
<ModalContent>
<ModalBody>
<p>@NotificationSettings.Text</p>
</ModalBody>
<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>
</ModalContent>
</Modal>

View File

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

View File

@ -3,8 +3,7 @@
<FilesWithEditor CFile="ConfigFile" Filters="Filters" Files="ConfigFiles" FilterFolder="FilterFolder"
SelectedFile="SelectedFile" SelectedFileChanged="SelectedFileChanged"
TestConfiguration="TestConfiguration" TestResult="TestResult"
DeleteFileModal="DeleteFile" DeleteResult="DeleteResult"
AddFileModal="ShowAddFileModal">
DeleteFileModal="DeleteNotificationModal" AddFileModal="ShowAddFileModal">
</FilesWithEditor>
<Modal @ref="AddFileModal">
<ModalBackdrop />
@ -71,4 +70,5 @@
</ModalFooter>
</ModalContent>
</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 List<string> Filters { get; set; } = new List<string>();
public List<int> FilteredOutFiles { get; set; } = new List<int>();
public Modal GeneralNotificationModal { get; set; } = new Modal();
public GeneralNotificationSettings GeneralNotificationSettings { get; set; } = null;
public NotificationSettings GeneralNotificationSettings { get; set; } = null;
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 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<bool> 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)

View File

@ -15,6 +15,7 @@
<base href="~/" />
<link href="_content/Blazorise/blazorise.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">
<link rel="stylesheet" href="~/css/materialdesignicons.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>
<PackageReference Include="Blazored.Modal" Version="4.1.0" />
<PackageReference Include="Blazorise.Bulma" 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" />

View File

@ -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\";

View File

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