Skip to content

Commit

Permalink
+
Browse files Browse the repository at this point in the history
  • Loading branch information
badhitman committed Aug 8, 2023
1 parent 98ca71a commit a039823
Show file tree
Hide file tree
Showing 42 changed files with 365 additions and 189 deletions.
3 changes: 2 additions & 1 deletion AbLogServer.Client/Pages/IndexPage.razor
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
@page "/"

@using RazorLib.Shared.settings
@using RazorLib.Shared

<PageTitle>Настройки</PageTitle>

Expand All @@ -21,6 +22,6 @@
<TelegramBotConfigComponent />
</MudTabPanel>
<MudTabPanel Text="About">

<AboutComponent />
</MudTabPanel>
</MudTabs>
4 changes: 4 additions & 0 deletions AbLogServer.Client/Program.cs
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
////////////////////////////////////////////////
// © https://github.com/badhitman
////////////////////////////////////////////////

using Microsoft.AspNetCore.Components.WebAssembly.Hosting;
using Microsoft.AspNetCore.Components.Web;
using MudBlazor.Services;
Expand Down
4 changes: 2 additions & 2 deletions AbLogServer.Client/Shared/MainLayout.razor
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@

<main>
<div class="top-row px-4 bg-body-tertiary" style="z-index:5;">
<a href="https://ab-log.ru" target="_blank">ab-log.ru</a>
<a title="Исходники C# .NET6" href="https://github.com/badhitman/AbLog" target="_blank">GitHub</a>
<a title="Официальный магазин оборудования" href="https://ab-log.ru" target="_blank">ab-log</a>
</div>

<article class="content px-4">
@Body
</article>
Expand Down
2 changes: 2 additions & 0 deletions AbLogServer.Server/Controllers/UsersController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@

namespace ABLog;



/// <summary>
/// Ïîëüçîâàòåëè
/// </summary>
Expand Down
4 changes: 4 additions & 0 deletions AbLogServer.Server/Program.cs
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
////////////////////////////////////////////////
// © https://github.com/badhitman
////////////////////////////////////////////////

using System.Text.Json.Serialization;
using System.Runtime.Versioning;
using Telegram.Bot.Services;
Expand Down
15 changes: 15 additions & 0 deletions RazorLib/Refit/AboutRefitService.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
////////////////////////////////////////////////
// © https://github.com/badhitman
////////////////////////////////////////////////

using SharedLib;

namespace RazorLib;

/// <summary>
/// О программе
/// </summary>
public class AboutRefitService : IAboutService
{

}
2 changes: 1 addition & 1 deletion RazorLib/Refit/ToolsRefitService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
////////////////////////////////////////////////

using BlazorLib;
using Refit;
using SharedLib;
using Refit;

namespace RazorLib;

Expand Down
2 changes: 1 addition & 1 deletion RazorLib/Refit/UsersRefitService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
namespace RazorLib;

/// <summary>
///
/// Пользователи
/// </summary>
public class UsersRefitService : IUsersService
{
Expand Down
21 changes: 21 additions & 0 deletions RazorLib/Refit/connect/IRefitAboutService.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
////////////////////////////////////////////////
// © https://github.com/badhitman
////////////////////////////////////////////////

using SharedLib;
using Refit;

namespace RazorLib;

/// <summary>
/// О программе
/// </summary>
[Headers("Content-Type: application/json")]
public interface IRefitAboutService
{
/// <summary>
/// Получить все доступные камеры
/// </summary>
[Get($"/api/{GlobalStatic.Routes.About}/{GlobalStatic.Routes.GET}")]
public Task<ApiResponse<EntriesSortingResponseModel>> About();
}
24 changes: 24 additions & 0 deletions RazorLib/Shared/AboutComponent.razor
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
@using MudBlazor;
@using SharedLib;

@inject ISnackbar _snackbar;
@inject IAboutService _about;

@inherits BlazorBusyComponentBaseModel

@if (IsBusyProgress)
{
<div class="text-center">
<div class="spinner-border" role="status">
<span class="visually-hidden">Загрузка...</span>
</div>
</div>
}
else
{

}

@code {

}
35 changes: 19 additions & 16 deletions RazorLib/Shared/BlazorBusyComponentBaseModel.cs
Original file line number Diff line number Diff line change
@@ -1,22 +1,25 @@
using Microsoft.AspNetCore.Components;
////////////////////////////////////////////////
// © https://github.com/badhitman
////////////////////////////////////////////////

namespace RazorLib
using Microsoft.AspNetCore.Components;

namespace RazorLib;

/// <summary>
/// Базовый компонент с поддержкой состояния "занят". Компоненты, которые выполняют запросы
/// на время обработки переходят в состояние "IsBusyProgress" с целью обеспечения визуализации смены этого изменения
/// </summary>
public abstract class BlazorBusyComponentBaseModel : ComponentBase
{
/// <summary>
/// Базовый компонент с поддержкой состояния "занят". Компоненты, которые выполняют запросы
/// на время обработки переходят в состояние "IsBusyProgress" с целью обеспечения визуализации смены этого изменения
/// Компонент занят отправкой REST запроса и обработки ответа
/// </summary>
public abstract class BlazorBusyComponentBaseModel : ComponentBase
{
/// <summary>
/// Компонент занят отправкой REST запроса и обработки ответа
/// </summary>
public bool IsBusyProgress { get; protected set; } = false;
public bool IsBusyProgress { get; protected set; } = false;

/// <summary>
/// Уведомляет компонент об изменении его состояния.
/// Когда применимо, это вызовет повторную визуализацию компонента.
/// </summary>
public virtual void StateHasChangedCall() => StateHasChanged();
}
/// <summary>
/// Уведомляет компонент об изменении его состояния.
/// Когда применимо, это вызовет повторную визуализацию компонента.
/// </summary>
public virtual void StateHasChangedCall() => StateHasChanged();
}
165 changes: 84 additions & 81 deletions RazorLib/Shared/ReloadPageComponentBaseModel.cs
Original file line number Diff line number Diff line change
@@ -1,110 +1,113 @@
using Microsoft.AspNetCore.Components;
////////////////////////////////////////////////
// © https://github.com/badhitman
////////////////////////////////////////////////

using Microsoft.AspNetCore.Components;
using RazorLib.Shared.hardwares;
using RazorLib.Shared;
using SharedLib;
using MudBlazor;

namespace RazorLib
namespace RazorLib;

/// <summary>
///
/// </summary>
public abstract class ReloadPageComponentBaseModel : BlazorBusyComponentBaseModel
{
/// <summary>
///
/// </summary>
public abstract class ReloadPageComponentBaseModel : BlazorBusyComponentBaseModel
{
/// <summary>
///
/// </summary>
[Inject]
protected IHardwaresService _hardwares { get; set; } = default!;
[Inject]
protected IHardwaresService _hardwares { get; set; } = default!;

/// <summary>
///
/// </summary>
[Inject]
protected ISnackbar _snackbar { get; set; } = default!;
/// <summary>
///
/// </summary>
[Inject]
protected ISnackbar _snackbar { get; set; } = default!;

/// <summary>
///
/// </summary>
[CascadingParameter, EditorRequired]
public int Id { get; set; }
/// <summary>
///
/// </summary>
[CascadingParameter, EditorRequired]
public int Id { get; set; }

/// <summary>
///
/// </summary>
[Parameter]
public string PagePath { get; set; } = default!;
/// <summary>
///
/// </summary>
[Parameter]
public string PagePath { get; set; } = default!;

/// <summary>
///
/// </summary>
protected ShowMessagesComponent? showMessages;
/// <summary>
///
/// </summary>
protected ShowMessagesComponent? showMessages;

/// <summary>
///
/// </summary>
protected HardwaresNavPillsComponent? refHtmlRoot;
/// <summary>
///
/// </summary>
protected HardwaresNavPillsComponent? refHtmlRoot;

/// <summary>
///
/// </summary>
protected string? HtmlSource;
/// <summary>
///
/// </summary>
protected string? HtmlSource;

/// <summary>
///
/// </summary>
protected void ReloadPage()
{
InvokeAsync(async () => await GetData());
}
/// <summary>
///
/// </summary>
protected void ReloadPage()
{
InvokeAsync(async () => await GetData());
}

bool IsUpdated = false;
bool IsUpdated = false;

/// <summary>
///
/// </summary>
protected async Task GetData()
{
if (Id <= 0)
return;
IsUpdated = false;
IsBusyProgress = true;
StateHasChanged();
HttpResponseModel rest = await _hardwares.GetHardwareHtmlPage(new HardwareGetHttpRequestModel() { HardwareId = Id, Path = PagePath });
/// <summary>
///
/// </summary>
protected async Task GetData()
{
if (Id <= 0)
return;
IsUpdated = false;
IsBusyProgress = true;
StateHasChanged();
HttpResponseModel rest = await _hardwares.GetHardwareHtmlPage(new HardwareGetHttpRequestModel() { HardwareId = Id, Path = PagePath });

if (!rest.IsSuccess)
if (!rest.IsSuccess)
{
if (showMessages is null)
{
if (showMessages is null)
Severity _style;
foreach (ResultMessage m in rest.Messages)
{
Severity _style;
foreach (ResultMessage m in rest.Messages)
_style = m.TypeMessage switch
{
_style = m.TypeMessage switch
{
ResultTypeEnum.Success => Severity.Success,
ResultTypeEnum.Info => Severity.Info,
ResultTypeEnum.Warning => Severity.Warning,
ResultTypeEnum.Error => Severity.Error,
_ => Severity.Normal
};
_snackbar.Add(m.Text, _style, opt => opt.DuplicatesBehavior = SnackbarDuplicatesBehavior.Allow);
}
ResultTypeEnum.Success => Severity.Success,
ResultTypeEnum.Info => Severity.Info,
ResultTypeEnum.Warning => Severity.Warning,
ResultTypeEnum.Error => Severity.Error,
_ => Severity.Normal
};
_snackbar.Add(m.Text, _style, opt => opt.DuplicatesBehavior = SnackbarDuplicatesBehavior.Allow);
}
else
showMessages?.ShowMessages(rest.Messages);
IsBusyProgress = false;
StateHasChanged();
return;
}

HtmlSource = rest.TextPayload;
else
showMessages?.ShowMessages(rest.Messages);
IsBusyProgress = false;
StateHasChanged();
if (!IsUpdated && refHtmlRoot?.refHtmlRoot is not null)
{
IsUpdated = true;
refHtmlRoot.refHtmlRoot.StateHasChangedCall(HtmlSource);
}
return;
}

HtmlSource = rest.TextPayload;
IsBusyProgress = false;
StateHasChanged();
if (!IsUpdated && refHtmlRoot?.refHtmlRoot is not null)
{
IsUpdated = true;
refHtmlRoot.refHtmlRoot.StateHasChangedCall(HtmlSource);
}
}
}
Loading

0 comments on commit a039823

Please sign in to comment.