Agent code and restructuring
This commit is contained in:
@@ -0,0 +1,25 @@
|
||||
@implements IDisposable;
|
||||
|
||||
@inject IMyDialogService MyDialogService
|
||||
|
||||
<ConfirmationDialogComponent></ConfirmationDialogComponent>
|
||||
|
||||
@code {
|
||||
|
||||
protected override void OnInitialized()
|
||||
{
|
||||
base.OnInitialized();
|
||||
MyDialogService.Subscribe(OnUpdate);
|
||||
}
|
||||
|
||||
void IDisposable.Dispose()
|
||||
{
|
||||
MyDialogService.Unsubscribe(OnUpdate);
|
||||
}
|
||||
|
||||
void OnUpdate()
|
||||
{
|
||||
InvokeAsync(StateHasChanged);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,29 @@
|
||||
@implements IDisposable;
|
||||
|
||||
@inject IEntityDialogService entityDialogService
|
||||
|
||||
@if (entityDialogService.HasDialog())
|
||||
{
|
||||
<EntityDialogComponent></EntityDialogComponent>
|
||||
}
|
||||
|
||||
|
||||
@code {
|
||||
|
||||
protected override void OnInitialized()
|
||||
{
|
||||
base.OnInitialized();
|
||||
entityDialogService.Subscribe(OnUpdate);
|
||||
}
|
||||
|
||||
void IDisposable.Dispose()
|
||||
{
|
||||
entityDialogService.Unsubscribe(OnUpdate);
|
||||
}
|
||||
|
||||
void OnUpdate()
|
||||
{
|
||||
InvokeAsync(StateHasChanged);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,28 @@
|
||||
@implements IDisposable;
|
||||
|
||||
@inject IGlossaryDialogService glossaryDialogService
|
||||
|
||||
@if (glossaryDialogService.HasDialog())
|
||||
{
|
||||
<GlossaryDialogComponent></GlossaryDialogComponent>
|
||||
}
|
||||
|
||||
@code {
|
||||
|
||||
protected override void OnInitialized()
|
||||
{
|
||||
base.OnInitialized();
|
||||
glossaryDialogService.Subscribe(OnUpdate);
|
||||
}
|
||||
|
||||
void IDisposable.Dispose()
|
||||
{
|
||||
glossaryDialogService.Unsubscribe(OnUpdate);
|
||||
}
|
||||
|
||||
void OnUpdate()
|
||||
{
|
||||
InvokeAsync(StateHasChanged);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,60 @@
|
||||
@implements IDisposable;
|
||||
|
||||
@inject ISearchService searchService
|
||||
@inject IJSRuntime jsRuntime
|
||||
|
||||
<SearchDialogComponent></SearchDialogComponent>
|
||||
|
||||
@code {
|
||||
protected override void OnInitialized()
|
||||
{
|
||||
searchService.Subscribe(OnUpdate);
|
||||
}
|
||||
|
||||
protected override async Task OnInitializedAsync()
|
||||
{
|
||||
try
|
||||
{
|
||||
await searchService.Load();
|
||||
}
|
||||
catch
|
||||
{
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
await jsRuntime.InvokeVoidAsync("SetDotnetReference", DotNetObjectReference.Create(this));
|
||||
}
|
||||
catch
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public void Dispose()
|
||||
{
|
||||
searchService.Unsubscribe(OnUpdate);
|
||||
}
|
||||
|
||||
void OnUpdate()
|
||||
{
|
||||
StateHasChanged();
|
||||
}
|
||||
|
||||
[JSInvokable("OnKeyPress")]
|
||||
public async Task OnKeyPress(string code, bool ctrlKey, bool shiftKey, bool altKey, bool metaKey)
|
||||
{
|
||||
if (code.ToLower().Equals("/"))
|
||||
{
|
||||
if (searchService.IsVisible)
|
||||
{
|
||||
searchService.Hide();
|
||||
}
|
||||
else
|
||||
{
|
||||
searchService.Show();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,60 @@
|
||||
@implements IDisposable;
|
||||
|
||||
@inject IToastService toastService
|
||||
|
||||
@if (toastService.HasToasts())
|
||||
{
|
||||
<div class="toastsContainer">
|
||||
@foreach (var toast in Toasts)
|
||||
{
|
||||
<ToastComponent Toast="toast"/>
|
||||
}
|
||||
</div>
|
||||
}
|
||||
|
||||
<style>
|
||||
.toastsContainer {
|
||||
position: fixed;
|
||||
top: 64px;
|
||||
right: 64px;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 5px;
|
||||
}
|
||||
</style>
|
||||
|
||||
|
||||
@code {
|
||||
private List<ToastModel> Toasts => toastService.GetToasts();
|
||||
|
||||
private Timer ageTimer = null!;
|
||||
|
||||
protected override void OnInitialized()
|
||||
{
|
||||
base.OnInitialized();
|
||||
toastService.Subscribe(OnUpdate);
|
||||
|
||||
ageTimer = new Timer(10);
|
||||
ageTimer.Elapsed += OnAge!;
|
||||
ageTimer.Enabled = true;
|
||||
}
|
||||
|
||||
void IDisposable.Dispose()
|
||||
{
|
||||
toastService.Unsubscribe(OnUpdate);
|
||||
}
|
||||
|
||||
|
||||
void OnAge(object? sender, ElapsedEventArgs elapsedEventArgs)
|
||||
{
|
||||
toastService.AgeToasts();
|
||||
ageTimer.Enabled = true;
|
||||
}
|
||||
|
||||
|
||||
void OnUpdate()
|
||||
{
|
||||
InvokeAsync(StateHasChanged);
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user