diff --git a/src/Agent/Insight.Agent/Insight.Agent.csproj b/src/Agent/Insight.Agent/Insight.Agent.csproj index 79aa1d5..52dabcf 100644 --- a/src/Agent/Insight.Agent/Insight.Agent.csproj +++ b/src/Agent/Insight.Agent/Insight.Agent.csproj @@ -6,7 +6,7 @@ Insight.Agent Insight agent - 2023.11.17.0 + 2023.12.14.0 enable enable @@ -23,10 +23,10 @@ + - diff --git a/src/Api/Insight.Api/Insight.Api.csproj b/src/Api/Insight.Api/Insight.Api.csproj index c1656c2..2d4f1d9 100644 --- a/src/Api/Insight.Api/Insight.Api.csproj +++ b/src/Api/Insight.Api/Insight.Api.csproj @@ -4,7 +4,7 @@ net7.0 Insight api - 2023.11.17.0 + 2023.12.14.0 Insight.Api enable enable diff --git a/src/Core/Insight.Domain/Insight.Domain.csproj b/src/Core/Insight.Domain/Insight.Domain.csproj index 135a8e4..88c6256 100644 --- a/src/Core/Insight.Domain/Insight.Domain.csproj +++ b/src/Core/Insight.Domain/Insight.Domain.csproj @@ -6,11 +6,12 @@ enable Insight.Domain Insight - 2023.11.17.0 + 2023.12.14.0 - + + diff --git a/src/Core/Insight.Infrastructure/Entities/Scheduler/Job.cs b/src/Core/Insight.Infrastructure/Entities/Scheduler/Job.cs new file mode 100644 index 0000000..e0f0c30 --- /dev/null +++ b/src/Core/Insight.Infrastructure/Entities/Scheduler/Job.cs @@ -0,0 +1,43 @@ +using MongoDB.Bson; +using MongoDB.Bson.Serialization.Attributes; +using MongoDB.Driver; +using System.Text.Json.Serialization; +using Vaitr.Scheduler; + +namespace Insight.Infrastructure.Entities; + +public static partial class MongoDatabaseExtensions +{ + public static IMongoCollection Job(this IMongoDatabase database) => database.GetCollection("job"); +} + +[BsonIgnoreExtraElements] +public class JobEntity +{ + [BsonId, BsonRepresentation(BsonType.ObjectId), JsonPropertyName("id")] + public string? Id { get; set; } + + [BsonElement("insert")] + public DateTime? Insert { get; set; } + + [BsonElement("update")] + public DateTime? Update { get; set; } + + [BsonElement("name")] + public string? Name { get; set; } + + [BsonElement("description")] + public string? Description { get; set; } + + [BsonElement("state"), BsonRepresentation(BsonType.String)] + public TaskState State { get; set; } + + [BsonElement("timeout")] + public TimeSpan Timeout { get; set; } + + [BsonElement("executed")] + public DateTime Executed { get; set; } + + [BsonElement("disabled")] + public bool Disabled { get; set; } +} \ No newline at end of file diff --git a/src/Core/Insight.Infrastructure/Entities/Scheduler/JobLog.cs b/src/Core/Insight.Infrastructure/Entities/Scheduler/JobLog.cs new file mode 100644 index 0000000..5ae9db1 --- /dev/null +++ b/src/Core/Insight.Infrastructure/Entities/Scheduler/JobLog.cs @@ -0,0 +1,38 @@ +using MongoDB.Bson; +using MongoDB.Bson.Serialization.Attributes; +using MongoDB.Driver; +using System.Text.Json.Serialization; +using Vaitr.Scheduler; +using static Insight.Infrastructure.Entities.TriggerEntity; + +namespace Insight.Infrastructure.Entities; + +public static partial class MongoDatabaseExtensions +{ + public static IMongoCollection JobLog(this IMongoDatabase database) => database.GetCollection("job_log"); +} + +[BsonIgnoreExtraElements] +public class JobLogEntity +{ + [BsonId, BsonRepresentation(BsonType.ObjectId), JsonPropertyName("id")] + public string? Id { get; set; } + + [BsonElement("_job"), BsonRepresentation(BsonType.ObjectId), JsonPropertyName("job")] + public string? Job { get; set; } + + [BsonElement("insert")] + public DateTime? Insert { get; set; } + + [BsonElement("timestamp")] + public DateTime? Timestamp { get; set; } + + [BsonElement("status"), BsonRepresentation(BsonType.String)] + public TaskState? Status { get; set; } + + [BsonElement("mode"), BsonRepresentation(BsonType.String)] + public ScheduleMode? Mode { get; set; } + + [BsonElement("message")] + public string? Message { get; set; } +} \ No newline at end of file diff --git a/src/Core/Insight.Infrastructure/Entities/Scheduler/JobTask.cs b/src/Core/Insight.Infrastructure/Entities/Scheduler/JobTask.cs new file mode 100644 index 0000000..a6c7fa1 --- /dev/null +++ b/src/Core/Insight.Infrastructure/Entities/Scheduler/JobTask.cs @@ -0,0 +1,30 @@ +using MongoDB.Bson; +using MongoDB.Bson.Serialization.Attributes; +using MongoDB.Driver; +using System.Text.Json.Serialization; + +namespace Insight.Infrastructure.Entities; + +public static partial class MongoDatabaseExtensions +{ + public static IMongoCollection JobTask(this IMongoDatabase database) => database.GetCollection("job_task"); +} + +[BsonIgnoreExtraElements] +public class JobTaskEntity +{ + [BsonId, BsonRepresentation(BsonType.ObjectId), JsonPropertyName("id")] + public string? Id { get; set; } + + [BsonElement("_job"), BsonRepresentation(BsonType.ObjectId), JsonPropertyName("job")] + public string? Job { get; set; } + + [BsonElement("_task"), BsonRepresentation(BsonType.ObjectId), JsonPropertyName("task")] + public string? Task { get; set; } + + [BsonElement("insert")] + public DateTime? Insert { get; set; } + + [BsonElement("update")] + public DateTime? Update { get; set; } +} \ No newline at end of file diff --git a/src/Core/Insight.Infrastructure/Entities/Scheduler/JobTrigger.cs b/src/Core/Insight.Infrastructure/Entities/Scheduler/JobTrigger.cs new file mode 100644 index 0000000..6c99dc6 --- /dev/null +++ b/src/Core/Insight.Infrastructure/Entities/Scheduler/JobTrigger.cs @@ -0,0 +1,30 @@ +using MongoDB.Bson; +using MongoDB.Bson.Serialization.Attributes; +using MongoDB.Driver; +using System.Text.Json.Serialization; + +namespace Insight.Infrastructure.Entities; + +public static partial class MongoDatabaseExtensions +{ + public static IMongoCollection JobTrigger(this IMongoDatabase database) => database.GetCollection("job_trigger"); +} + +[BsonIgnoreExtraElements] +public class JobTriggerEntity +{ + [BsonId, BsonRepresentation(BsonType.ObjectId), JsonPropertyName("id")] + public string? Id { get; set; } + + [BsonElement("_job"), BsonRepresentation(BsonType.ObjectId), JsonPropertyName("job")] + public string? Job { get; set; } + + [BsonElement("_trigger"), BsonRepresentation(BsonType.ObjectId), JsonPropertyName("trigger")] + public string? Trigger { get; set; } + + [BsonElement("insert")] + public DateTime? Insert { get; set; } + + [BsonElement("update")] + public DateTime? Update { get; set; } +} \ No newline at end of file diff --git a/src/Core/Insight.Infrastructure/Entities/Scheduler/TaskEntity.cs b/src/Core/Insight.Infrastructure/Entities/Scheduler/TaskEntity.cs new file mode 100644 index 0000000..8811d08 --- /dev/null +++ b/src/Core/Insight.Infrastructure/Entities/Scheduler/TaskEntity.cs @@ -0,0 +1,33 @@ +using MongoDB.Bson; +using MongoDB.Bson.Serialization.Attributes; +using MongoDB.Driver; +using System.Text.Json.Serialization; + +namespace Insight.Infrastructure.Entities; + +public static partial class MongoDatabaseExtensions +{ + public static IMongoCollection Task(this IMongoDatabase database) => database.GetCollection("task"); +} + +[BsonIgnoreExtraElements] +public class TaskEntity +{ + [BsonId, BsonRepresentation(BsonType.ObjectId), JsonPropertyName("id")] + public string? Id { get; set; } + + [BsonElement("insert")] + public DateTime? Insert { get; set; } + + [BsonElement("update")] + public DateTime? Update { get; set; } + + [BsonElement("name")] + public string? Name { get; set; } + + [BsonElement("description")] + public string? Description { get; set; } + + [BsonIgnore] + public Func? Action { get; set; } +} \ No newline at end of file diff --git a/src/Core/Insight.Infrastructure/Entities/Scheduler/TriggerEntity.cs b/src/Core/Insight.Infrastructure/Entities/Scheduler/TriggerEntity.cs new file mode 100644 index 0000000..95e5381 --- /dev/null +++ b/src/Core/Insight.Infrastructure/Entities/Scheduler/TriggerEntity.cs @@ -0,0 +1,46 @@ +using MongoDB.Bson; +using MongoDB.Bson.Serialization.Attributes; +using MongoDB.Driver; +using System.Text.Json.Serialization; + +namespace Insight.Infrastructure.Entities; + +public static partial class MongoDatabaseExtensions +{ + public static IMongoCollection Trigger(this IMongoDatabase database) => database.GetCollection("trigger"); +} + +public class TriggerEntity +{ + [BsonId, BsonRepresentation(BsonType.ObjectId), JsonPropertyName("id")] + public string? Id { get; set; } + + [BsonElement("insert")] + public DateTime? Insert { get; set; } + + [BsonElement("update")] + public DateTime? Update { get; set; } + + [BsonElement("name")] + public string? Name { get; set; } + + [BsonElement("description")] + public string? Description { get; set; } + + [BsonElement("mode")] + public ScheduleMode Mode { get; set; } + + [BsonElement("date_start")] + public DateTime StartTime { get; set; } + + [BsonElement("date_end")] + public DateTime? EndTime { get; set; } + + [BsonElement("interval")] + public TimeSpan? Interval { get; set; } + + public enum ScheduleMode + { + Single, Loop + } +} \ No newline at end of file diff --git a/src/Core/Insight.Infrastructure/Insight.Infrastructure.csproj b/src/Core/Insight.Infrastructure/Insight.Infrastructure.csproj index 3da34a0..0b326b6 100644 --- a/src/Core/Insight.Infrastructure/Insight.Infrastructure.csproj +++ b/src/Core/Insight.Infrastructure/Insight.Infrastructure.csproj @@ -4,7 +4,7 @@ net7.0 Insight.Infrastructure Insight - 2023.11.17.0 + 2023.12.14.0 true enable @@ -19,9 +19,10 @@ - + + diff --git a/src/Remote/Insight.Remote.Shared/Insight.Remote.Shared.csproj b/src/Remote/Insight.Remote.Shared/Insight.Remote.Shared.csproj index abfa5b1..e36fbc0 100644 --- a/src/Remote/Insight.Remote.Shared/Insight.Remote.Shared.csproj +++ b/src/Remote/Insight.Remote.Shared/Insight.Remote.Shared.csproj @@ -5,7 +5,7 @@ Insight.Remote.Shared Insight Insight.Remote.Shared - 2023.11.17.0 + 2023.12.14.0 enable enable True @@ -13,10 +13,9 @@ - + - diff --git a/src/Remote/Insight.Remote.Windows/Insight.Remote.Windows.csproj b/src/Remote/Insight.Remote.Windows/Insight.Remote.Windows.csproj index 2c6eb46..3ec6630 100644 --- a/src/Remote/Insight.Remote.Windows/Insight.Remote.Windows.csproj +++ b/src/Remote/Insight.Remote.Windows/Insight.Remote.Windows.csproj @@ -7,7 +7,7 @@ true Remote Control remote - 2023.11.17.0 + 2023.12.14.0 Insight.Remote.Windows enable enable diff --git a/src/Server/Insight.Server/Insight.Server.csproj b/src/Server/Insight.Server/Insight.Server.csproj index df5a67e..8d4b992 100644 --- a/src/Server/Insight.Server/Insight.Server.csproj +++ b/src/Server/Insight.Server/Insight.Server.csproj @@ -5,7 +5,7 @@ net7.0 Insight server - 2023.11.17.0 + 2023.12.14.0 Insight.Server enable enable @@ -42,7 +42,6 @@ - diff --git a/src/Server/Insight.Server/Services/JobService.cs b/src/Server/Insight.Server/Services/JobService.cs index 471128f..1619007 100644 --- a/src/Server/Insight.Server/Services/JobService.cs +++ b/src/Server/Insight.Server/Services/JobService.cs @@ -31,7 +31,7 @@ internal class JobService : BackgroundService var jobs = new List { RunInventoryAsync(cancellationToken), - RunCustomsAsync(cancellationToken) + //RunCustomsAsync(cancellationToken) }; try diff --git a/src/Setup/Insight.Setup.Windows/Insight.Setup.Windows.csproj b/src/Setup/Insight.Setup.Windows/Insight.Setup.Windows.csproj index 7cd4052..377172e 100644 --- a/src/Setup/Insight.Setup.Windows/Insight.Setup.Windows.csproj +++ b/src/Setup/Insight.Setup.Windows/Insight.Setup.Windows.csproj @@ -8,7 +8,7 @@ setup Insight.Setup Insight - 2023.11.17.0 + 2023.12.14.0 diff --git a/src/Updater/Insight.Updater/Insight.Updater.csproj b/src/Updater/Insight.Updater/Insight.Updater.csproj index 9c3d355..c4d2f53 100644 --- a/src/Updater/Insight.Updater/Insight.Updater.csproj +++ b/src/Updater/Insight.Updater/Insight.Updater.csproj @@ -6,7 +6,7 @@ Insight Insight.Updater updater - 2023.11.17.0 + 2023.12.14.0 enable enable diff --git a/src/Web/Insight.Web/Components/Cards/InfoCard.razor b/src/Web/Insight.Web/Components/Cards/InfoCard.razor index 207c6c9..9b0c1d9 100644 --- a/src/Web/Insight.Web/Components/Cards/InfoCard.razor +++ b/src/Web/Insight.Web/Components/Cards/InfoCard.razor @@ -1,4 +1,7 @@ - +@inherits ComponentBase +@implements IDisposable + + @@ -21,27 +24,35 @@ @code { - [Parameter] - public string? Href { get; set; } + [Parameter] public string? Href { get; set; } + [Parameter] public EventCallback OnClick { get; set; } + [Parameter] public string? Icon { get; set; } + [Parameter] public Color? IconColor { get; set; } + [Parameter] public string? Key { get; set; } + [Parameter] public Color? KeyColor { get; set; } + [Parameter] public string? Text { get; set; } + [Parameter] public int Lines { get; set; } = 1; - [Parameter] - public EventCallback OnClick { get; set; } + private bool _disposed; - [Parameter] - public string? Icon { get; set; } + public void Dispose() + { + Dispose(true); + GC.SuppressFinalize(this); + } - [Parameter] - public Color? IconColor { get; set; } + private void Dispose(bool disposing) + { + if (_disposed is false) return; + if (disposing is false) return; - [Parameter] - public string? Key { get; set; } + try + { - [Parameter] - public Color? KeyColor { get; set; } - - [Parameter] - public string? Text { get; set; } - - [Parameter] - public int Lines { get; set; } = 1; + } + finally + { + _disposed = true; + } + } } \ No newline at end of file diff --git a/src/Web/Insight.Web/Components/Cards/KeyValueCard.razor b/src/Web/Insight.Web/Components/Cards/KeyValueCard.razor index 01a4527..70e4120 100644 --- a/src/Web/Insight.Web/Components/Cards/KeyValueCard.razor +++ b/src/Web/Insight.Web/Components/Cards/KeyValueCard.razor @@ -1,5 +1,8 @@ @typeparam T +@inherits ComponentBase +@implements IDisposable + @@ -31,27 +34,35 @@ @code{ - [Parameter] - public string? Href { get; set; } + [Parameter] public string? Href { get; set; } + [Parameter] public EventCallback OnClick { get; set; } + [Parameter] public string? Icon { get; set; } + [Parameter] public Color? IconColor { get; set; } + [Parameter] public string? Key { get; set; } + [Parameter] public Color? KeyColor { get; set; } + [Parameter] public T? Value { get; set; } + [Parameter] public Color? ValueColor { get; set; } - [Parameter] - public EventCallback OnClick { get; set; } + private bool _disposed; - [Parameter] - public string? Icon { get; set; } + public void Dispose() + { + Dispose(true); + GC.SuppressFinalize(this); + } - [Parameter] - public Color? IconColor { get; set; } + private void Dispose(bool disposing) + { + if (_disposed is false) return; + if (disposing is false) return; - [Parameter] - public string? Key { get; set; } + try + { - [Parameter] - public Color? KeyColor { get; set; } - - [Parameter] - public T? Value { get; set; } - - [Parameter] - public Color? ValueColor { get; set; } + } + finally + { + _disposed = true; + } + } } \ No newline at end of file diff --git a/src/Web/Insight.Web/Components/Containers/BaseContainer.razor b/src/Web/Insight.Web/Components/Containers/BaseContainer.razor index 5d504ad..eb4a679 100644 --- a/src/Web/Insight.Web/Components/Containers/BaseContainer.razor +++ b/src/Web/Insight.Web/Components/Containers/BaseContainer.razor @@ -1,28 +1,11 @@ -@Title +@inherits ComponentBase +@implements IDisposable -@*@if (Loading) -{ - +@Title -
- -
- - return; -}*@ - -
-
+
+
-@* - - - - @item.Text - - - - *@ @@ -43,9 +26,75 @@
-
+
@if (Content is not null) { @Content } -
\ No newline at end of file +
+ +@code{ + [Parameter] public string Title { get; set; } = Global.Name; + [Parameter] public List? Breadcrumbs { get; set; } + [Parameter] public RenderFragment? BreadcrumbAction { get; set; } + [Parameter] public RenderFragment? Content { get; set; } + [Parameter] public Func? LoadData { get; set; } + [Parameter] public bool DisableReload { get; set; } + + private bool _disposed; + + private bool _loading; + private bool Loading + { + get => _loading; + set + { + if (value != _loading) + { + _loading = value; + StateHasChanged(); + } + } + } + + protected override async Task OnAfterRenderAsync(bool firstRender) + { + if (firstRender) await OnRefreshAsync(); + } + + private async Task OnRefreshAsync() + { + if (LoadData is null || Loading) return; + + try + { + Loading = true; + await LoadData(); + } + finally + { + Loading = false; + } + } + + public void Dispose() + { + Dispose(true); + GC.SuppressFinalize(this); + } + + private void Dispose(bool disposing) + { + if (_disposed is false) return; + if (disposing is false) return; + + try + { + + } + finally + { + _disposed = true; + } + } +} \ No newline at end of file diff --git a/src/Web/Insight.Web/Components/Containers/BaseContainer.razor.cs b/src/Web/Insight.Web/Components/Containers/BaseContainer.razor.cs deleted file mode 100644 index 8f5ab44..0000000 --- a/src/Web/Insight.Web/Components/Containers/BaseContainer.razor.cs +++ /dev/null @@ -1,74 +0,0 @@ -using Insight.Web.Constants; -using Microsoft.AspNetCore.Components; -using MudBlazor; - -namespace Insight.Web.Components.Containers; - -public partial class BaseContainer -{ - [Parameter] - public string Title { get; set; } = Global.Name; - - [Parameter] - public List? Breadcrumbs { get; set; } - - [Parameter] - public RenderFragment? BreadcrumbAction { get; set; } - - [Parameter] - public RenderFragment? Content { get; set; } - - [Parameter] - public Func? LoadData { get; set; } - - [Parameter] - public bool DisableReload { get; set; } - - - private bool _loading; - private bool Loading - { - get - { - return _loading; - } - set - { - if (value != _loading) - { - _loading = value; - StateHasChanged(); - } - } - } - - protected override async Task OnAfterRenderAsync(bool firstRender) - { - if (firstRender) - { - await OnRefreshAsync(); - } - } - - private async Task OnRefreshAsync() - { - if (LoadData is null || Loading) return; - - Loading = true; - StateHasChanged(); - - //var start = Stopwatch.GetTimestamp(); - - await LoadData(); - - //var time = Stopwatch.GetElapsedTime(start); - - //if (time <= TimeSpan.FromSeconds(1)) - //{ - // await Task.Delay(TimeSpan.FromSeconds(1).Subtract(time)); - //} - - Loading = false; - StateHasChanged(); - } -} \ No newline at end of file diff --git a/src/Web/Insight.Web/Components/Containers/TableContainer.razor b/src/Web/Insight.Web/Components/Containers/TableContainer.razor index a7d06ff..faed0f2 100644 --- a/src/Web/Insight.Web/Components/Containers/TableContainer.razor +++ b/src/Web/Insight.Web/Components/Containers/TableContainer.razor @@ -1,17 +1,24 @@ -@typeparam T +@using Insight.Web.Extensions + +@typeparam T + +@inherits ComponentBase +@implements IDisposable + +@inject NavigationManager NavigationManager @Title -
+
@if (OnAdd.HasDelegate) { - @if (AddBreadcrumbs is not null) + @if (_optionalBreadcrumbs is not null) { - + } @@ -25,7 +32,7 @@
- + @if (Header is not null) { @@ -36,7 +43,7 @@ Filter - + Refresh @@ -63,4 +70,137 @@ - \ No newline at end of file + + +@code{ + [Parameter] public string Title { get; set; } = Global.Name; + [Parameter] public List? Breadcrumbs { get; set; } + [Parameter] public Func>>? Data { get; set; } + [Parameter] public RenderFragment? Header { get; set; } + [Parameter] public RenderFragment? RowTemplate { get; set; } + [Parameter] public RenderFragment? ActionTemplate { get; set; } + [Parameter] public bool DisableAction { get; set; } + [Parameter] public bool DisableRefresh { get; set; } + [Parameter] public string? Search + { + get => _search; + set + { + if (_search == value) return; + _search = value; + + SearchChanged.InvokeAsync(value); + } + } + [Parameter] public bool Filtered { get; set; } + [Parameter] public EventCallback SearchChanged { get; set; } + [Parameter] public EventCallback OnFilter { get; set; } + [Parameter] public EventCallback OnAdd { get; set; } + + private List? _optionalBreadcrumbs; + private MudTable? _table; + private string? _search; + private bool _loading; + private bool _disposed; + + private bool Loading + { + get => _loading; + set + { + if (value != _loading) + { + _loading = value; + StateHasChanged(); + } + } + } + + protected override void OnInitialized() + { + if (OnAdd.HasDelegate) + { + _optionalBreadcrumbs = new List() + { + new("", "#", true), + new("", "#", true) + }; + } + + if (NavigationManager.GetQueryString().TryGetValue("search", out var search)) + { + Search = search.ToString(); + } + } + + private async Task> OnLoadDataAsync(TableState state) + { + if (Data is null) throw new MissingMethodException(nameof(Data)); + + try + { + Loading = true; + return await Data(state); + } + finally + { + Loading = false; + } + } + + public async Task RefreshAsync() + { + if (Loading || _table is null) return; + + try + { + Loading = true; + await _table.ReloadServerData(); + } + finally + { + Loading = false; + } + } + + private async Task SearchAsync(string? text) + { + Search = text; + + if (Loading) return; + await RefreshAsync(); + } + + private void OnSearchReleased() => NavigationManager.ChangeQueryStringValue("search", Search); + + private async Task OnFilterClick() + { + if (OnFilter.HasDelegate) await OnFilter.InvokeAsync(this); + } + + private async Task OnAddClick() + { + if (OnAdd.HasDelegate) await OnAdd.InvokeAsync(this); + } + + public void Dispose() + { + Dispose(true); + GC.SuppressFinalize(this); + } + + private void Dispose(bool disposing) + { + if (_disposed is false) return; + if (disposing is false) return; + + try + { + + } + finally + { + _disposed = true; + } + } +} \ No newline at end of file diff --git a/src/Web/Insight.Web/Components/Containers/TableContainer.razor.cs b/src/Web/Insight.Web/Components/Containers/TableContainer.razor.cs deleted file mode 100644 index bf75e8f..0000000 --- a/src/Web/Insight.Web/Components/Containers/TableContainer.razor.cs +++ /dev/null @@ -1,194 +0,0 @@ -using Insight.Web.Constants; -using Insight.Web.Extensions; -using Microsoft.AspNetCore.Components; -using MudBlazor; - -namespace Insight.Web.Components.Containers; - -public partial class TableContainer -{ - [Inject] private NavigationManager NavigationManager { get; init; } = default!; - - - [Parameter] - public string Title { get; set; } = Global.Name; - - [Parameter] - public List? Breadcrumbs { get; set; } - - [Parameter] - public Func>>? Data { get; set; } - - [Parameter] - public RenderFragment? Header { get; set; } - - [Parameter] - public RenderFragment? RowTemplate { get; set; } - - [Parameter] - public RenderFragment? ActionTemplate { get; set; } - - [Parameter] - public bool DisableAction { get; set; } - - - private List? AddBreadcrumbs { get; set; } - private MudTable? Table { get; set; } - private bool Loading { get; set; } - - private int CurrentPage { get; set; } - private int CurrentSize { get; set; } - - protected override void OnInitialized() - { - if (OnAdd.HasDelegate) - { - AddBreadcrumbs = new List() - { - new BreadcrumbItem("", "#", true), - new BreadcrumbItem("", "#", true) - }; - } - - if (NavigationManager.GetQueryString().TryGetValue("search", out var search)) - { - Search = search.ToString(); - } - - //if (NavigationManager.GetQueryString().TryGetValue("page", out var pageRaw)) - //{ - // if (int.TryParse(pageRaw, out var page)) - // { - // CurrentPage = page; - // } - //} - - //if (NavigationManager.GetQueryString().TryGetValue("size", out var sizeRaw)) - //{ - // if (int.TryParse(sizeRaw, out var size)) - // { - // CurrentSize = size == 0 ? 100 : size; - // } - //} - } - - private async Task> OnLoadDataAsync(TableState state) - { - if (Data is null) - { - throw new MissingMethodException(nameof(Data)); - } - - try - { - Loading = true; - - //state.Page = CurrentPage; - //Table.SetRowsPerPage(CurrentSize); - - var data = await Data(state); - - //CurrentPage = state.Page; - //CurrentSize = state.PageSize; - - //NavigationManager.ChangeQueryStringValue("page", state.Page.ToString()); - //NavigationManager.ChangeQueryStringValue("size", state.PageSize.ToString()); - - //if (state.SortLabel is not null) NavigationManager.ChangeQueryStringValue("sort", state.SortLabel.ToString()); - //if (state.SortDirection) NavigationManager.ChangeQueryStringValue("direction", state.SortDirection.ToString()); - - return data; - } - finally - { - Loading = false; - } - } - - // - - [Parameter] - public bool DisableRefresh { get; set; } - - private string? _search; - - [Parameter] - public string? Search - { - get => _search; - set - { - if (_search == value) return; - _search = value; - - SearchChanged.InvokeAsync(value); - } - } - - [Parameter] - public EventCallback SearchChanged { get; set; } - - private async Task SearchAsync(string? text) - { - Search = text; - - if (Loading) return; - await RefreshAsync(); - } - - public async Task RefreshAsync() - { - if (Loading || Table is null) return; - - Loading = true; - StateHasChanged(); - - //var start = Stopwatch.GetTimestamp(); - - await Table.ReloadServerData(); - - //var time = Stopwatch.GetElapsedTime(start); - - //if (time <= TimeSpan.FromSeconds(1)) - //{ - // await Task.Delay(TimeSpan.FromSeconds(1).Subtract(time)); - //} - - Loading = false; - StateHasChanged(); - } - - private void OnSearchReleased() - { - NavigationManager.ChangeQueryStringValue("search", Search); - } - - // - - [Parameter] public EventCallback OnFilter { get; set; } - - - [Parameter] - public bool Filtered { get; set; } - - private async Task OnFilterClick() - { - if (OnFilter.HasDelegate) - { - await OnFilter.InvokeAsync(this); - } - } - - // - - [Parameter] - public EventCallback OnAdd { get; set; } - - private async Task OnAddClick() - { - if (OnAdd.HasDelegate) - { - await OnAdd.InvokeAsync(this); - } - } -} \ No newline at end of file diff --git a/src/Web/Insight.Web/Components/Dialogs/ActionDialog.razor b/src/Web/Insight.Web/Components/Dialogs/ActionDialog.razor index 660fea5..773d039 100644 --- a/src/Web/Insight.Web/Components/Dialogs/ActionDialog.razor +++ b/src/Web/Insight.Web/Components/Dialogs/ActionDialog.razor @@ -1,4 +1,7 @@ -@if (@Actions is not null) +@inherits ComponentBase +@implements IDisposable + +@if (@Actions is not null) { @@ -15,11 +18,59 @@ } else { - + @Content +} + +@code{ + [CascadingParameter] public MudDialogInstance MudDialog { get; set; } = default!; + + [Parameter] public bool Visible + { + get => _visible; + set + { + if (_visible == value) return; + _visible = value; + + VisibleChanged.InvokeAsync(value); + } + } + [Parameter] public EventCallback VisibleChanged { get; set; } + [Parameter] public RenderFragment? Content { get; set; } + [Parameter] public RenderFragment? Actions { get; set; } + + private bool _visible; + private bool _disposed; + + protected override void OnAfterRender(bool firstRender) + { + if (firstRender is false) return; + } + + public void Dispose() + { + Dispose(true); + GC.SuppressFinalize(this); + } + + private void Dispose(bool disposing) + { + if (_disposed is false) return; + if (disposing is false) return; + + try + { + + } + finally + { + _disposed = true; + } + } } \ No newline at end of file diff --git a/src/Web/Insight.Web/Components/Dialogs/ActionDialog.razor.cs b/src/Web/Insight.Web/Components/Dialogs/ActionDialog.razor.cs deleted file mode 100644 index f4734ab..0000000 --- a/src/Web/Insight.Web/Components/Dialogs/ActionDialog.razor.cs +++ /dev/null @@ -1,30 +0,0 @@ -using Microsoft.AspNetCore.Components; - -namespace Insight.Web.Components.Dialogs; - -public partial class ActionDialog -{ - private bool _visible; - - [Parameter] - public bool Visible - { - get => _visible; - set - { - if (_visible == value) return; - _visible = value; - - VisibleChanged.InvokeAsync(value); - } - } - - [Parameter] - public EventCallback VisibleChanged { get; set; } - - [Parameter] - public RenderFragment? Content { get; set; } - - [Parameter] - public RenderFragment? Actions { get; set; } -} \ No newline at end of file diff --git a/src/Web/Insight.Web/Components/Dialogs/ChatDialog.razor b/src/Web/Insight.Web/Components/Dialogs/ChatDialog.razor index 5aeab56..b974ab4 100644 --- a/src/Web/Insight.Web/Components/Dialogs/ChatDialog.razor +++ b/src/Web/Insight.Web/Components/Dialogs/ChatDialog.razor @@ -11,11 +11,6 @@ - @* - # - contacts - *@ - @foreach (var user in ChatService.Users.Keys.Where(p => p.Uid != SessionHandler.State.Uid).OrderByDescending(p => p.Online)) diff --git a/src/Web/Insight.Web/Components/Dialogs/ChatDialog.razor.cs b/src/Web/Insight.Web/Components/Dialogs/ChatDialog.razor.cs index 57a2a86..c336369 100644 --- a/src/Web/Insight.Web/Components/Dialogs/ChatDialog.razor.cs +++ b/src/Web/Insight.Web/Components/Dialogs/ChatDialog.razor.cs @@ -13,7 +13,7 @@ using static Insight.Web.Constants.Events.Chat; namespace Insight.Web.Components.Dialogs; -public partial class ChatDialog +public partial class ChatDialog : IDisposable { [Inject] private Bus Bus { get; init; } = default!; [Inject] private ChatService ChatService { get; init; } = default!; @@ -45,10 +45,10 @@ public partial class ChatDialog private enum Content { Contacts, Chat } private Content _content = Content.Contacts; - private ChatUser? _currentUser; private ChatSession? _currentSession; private string? _currentMessage; + private bool _disposed; private readonly List _subscriptions = new(); @@ -194,4 +194,25 @@ public partial class ChatDialog await InvokeAsync(StateHasChanged); } + + public void Dispose() + { + Dispose(true); + GC.SuppressFinalize(this); + } + + private void Dispose(bool disposing) + { + if (_disposed is false) return; + if (disposing is false) return; + + try + { + + } + finally + { + _disposed = true; + } + } } \ No newline at end of file diff --git a/src/Web/Insight.Web/Components/Layouts/LoginLayout.razor b/src/Web/Insight.Web/Components/Layouts/LoginLayout.razor index 4f71777..35f1c0b 100644 --- a/src/Web/Insight.Web/Components/Layouts/LoginLayout.razor +++ b/src/Web/Insight.Web/Components/Layouts/LoginLayout.razor @@ -1,8 +1,34 @@ @inherits LayoutComponentBase +@implements IDisposable + - @Body - \ No newline at end of file + + +@code{ + private bool _disposed; + + public void Dispose() + { + Dispose(true); + GC.SuppressFinalize(this); + } + + private void Dispose(bool disposing) + { + if (_disposed is false) return; + if (disposing is false) return; + + try + { + + } + finally + { + _disposed = true; + } + } +} \ No newline at end of file diff --git a/src/Web/Insight.Web/Components/Layouts/MainLayout.razor b/src/Web/Insight.Web/Components/Layouts/MainLayout.razor index 672f8c4..ea2781f 100644 --- a/src/Web/Insight.Web/Components/Layouts/MainLayout.razor +++ b/src/Web/Insight.Web/Components/Layouts/MainLayout.razor @@ -1,10 +1,19 @@ @using Vaitr.Bus; +@using Blazored.LocalStorage; +@using Microsoft.AspNetCore.Identity; +@using MongoDB.Driver; +@using Insight.Infrastructure @inherits LayoutComponentBase @implements IDisposable +@inject AuthenticationStateProvider AuthenticationStateProvider +@inject IServiceScopeFactory ServiceScopeFactory +@inject ILocalStorageService LocalStorageService +@inject IMongoDatabase Database @inject Bus Bus + @@ -19,8 +28,11 @@ + @if (_darkModeSwitch is false) + { + + } - @@ -40,7 +52,10 @@ @code{ public IReadOnlyDictionary? RouteValues { get; set; } + private MudTheme _currentTheme = Themes.Default(); private DrawerProvider? _drawer; + private bool _darkMode; + private bool _darkModeSwitch; private bool _disposed; protected override void OnParametersSet() @@ -50,6 +65,11 @@ base.OnParametersSet(); } + protected override async Task OnInitializedAsync() + { + await LoadDarkModeAsync(); + } + protected override async Task OnAfterRenderAsync(bool firstRender) { if (firstRender) @@ -60,22 +80,85 @@ await Bus.PublishAsync(Events.Layout.Rendered).ConfigureAwait(false); } + private async Task LoadDarkModeAsync() + { + // local storage + var storageDarkMode = await LocalStorageService.GetItemAsync("darkmode"); + if (storageDarkMode is bool darkmodeValue) _darkMode = darkmodeValue; + + // database override + var state = await AuthenticationStateProvider.GetAuthenticationStateAsync(); + + if (state?.User.Identity is not null && state.User.Identity.IsAuthenticated) + { + using var scope = ServiceScopeFactory.CreateScope(); + var userManager = scope.ServiceProvider.GetRequiredService>(); + + if (await userManager.FindByNameAsync(state.User.Identity.Name) is not InsightUser user) return; + + var userPrefs = await Database.UserPreference() + .Find(p => p.User == user.Id.ToString()) + .FirstOrDefaultAsync(); + + if (userPrefs is null) return; + + _darkMode = userPrefs.DarkMode; + + await LocalStorageService.SetItemAsync("darkmode", _darkMode); + } + } + + private async Task OnDarkModeToggleAsync() + { + // update current + _darkMode = !_darkMode; + + // update local storage + await LocalStorageService.SetItemAsync("darkmode", _darkMode); + + // update database + var state = await AuthenticationStateProvider.GetAuthenticationStateAsync(); + + if (state?.User.Identity is not null && state.User.Identity.IsAuthenticated) + { + using var scope = ServiceScopeFactory.CreateScope(); + var userManager = scope.ServiceProvider.GetRequiredService>(); + + if (await userManager.FindByNameAsync(state.User.Identity.Name) is not InsightUser user) return; + + var date = DateTime.Now; + + var userPrefs = await Database.UserPreference() + .UpdateOneAsync(p => p.User == user.Id.ToString(), Builders.Update + .SetOnInsert(p => p.User, user.Id.ToString()) + .SetOnInsert(p => p.Insert, date) + .Set(p => p.Update, date) + .Set(p => p.DarkMode, _darkMode), new UpdateOptions + { + IsUpsert = true + }); + } + + await InvokeAsync(StateHasChanged); + } + public void Dispose() { - Dispose(disposing: true); + Dispose(true); GC.SuppressFinalize(this); } - protected virtual void Dispose(bool disposing) + private void Dispose(bool disposing) { - // auto disposed when starved circuit timeouts (disconnects) - if (_disposed is false) + if (_disposed is false) return; + if (disposing is false) return; + + try { - if (disposing) - { - - } + } + finally + { _disposed = true; } } diff --git a/src/Web/Insight.Web/Components/Navbars/Account.razor b/src/Web/Insight.Web/Components/Navbars/Account.razor index 088bc59..92fca5e 100644 --- a/src/Web/Insight.Web/Components/Navbars/Account.razor +++ b/src/Web/Insight.Web/Components/Navbars/Account.razor @@ -1,7 +1,36 @@ @inherits ComponentBase +@implements IDisposable Account -Profile \ No newline at end of file +Profile + +@code{ + [CascadingParameter] public IReadOnlyDictionary? RouteValues { get; set; } + + private string _title = "Account"; + private bool _disposed; + + public void Dispose() + { + Dispose(true); + GC.SuppressFinalize(this); + } + + private void Dispose(bool disposing) + { + if (_disposed is false) return; + if (disposing is false) return; + + try + { + + } + finally + { + _disposed = true; + } + } +} \ No newline at end of file diff --git a/src/Web/Insight.Web/Components/Navbars/Account.razor.cs b/src/Web/Insight.Web/Components/Navbars/Account.razor.cs deleted file mode 100644 index 0a34573..0000000 --- a/src/Web/Insight.Web/Components/Navbars/Account.razor.cs +++ /dev/null @@ -1,28 +0,0 @@ -using Microsoft.AspNetCore.Components; -using Microsoft.AspNetCore.Components.Authorization; - -namespace Insight.Web.Components.Navbars; - -public partial class Account -{ - [CascadingParameter] public IReadOnlyDictionary? RouteValues { get; set; } - - [Inject] private NavigationManager NavigationManager { get; init; } = default!; - [Inject] private AuthenticationStateProvider AuthenticationStateProvider { get; init; } = default!; - - private string Uri { get; set; } = string.Empty; - private string Title { get; set; } = "Account"; - - protected override async Task OnInitializedAsync() - { - var cp = (await AuthenticationStateProvider.GetAuthenticationStateAsync()).User; - //Title = $"Account: {cp?.Identity?.Name}"; - - Uri = NavigationManager.ToBaseRelativePath(NavigationManager.Uri); - } - - protected override void OnAfterRender(bool firstRender) - { - Uri = NavigationManager.ToBaseRelativePath(NavigationManager.Uri); - } -} \ No newline at end of file diff --git a/src/Web/Insight.Web/Components/Navbars/Customer.razor b/src/Web/Insight.Web/Components/Navbars/Customer.razor index 5e1ece7..37a6525 100644 --- a/src/Web/Insight.Web/Components/Navbars/Customer.razor +++ b/src/Web/Insight.Web/Components/Navbars/Customer.razor @@ -1,13 +1,70 @@ -@inherits ComponentBase +@using MongoDB.Driver +@using Vaitr.Bus -@* - @Title -*@ +@inherits ComponentBase +@implements IDisposable - - @Title +@inject IMongoDatabase Database +@inject Bus Bus + + + @_title
- Hosts -
\ No newline at end of file + Hosts +
+ +@code{ + [CascadingParameter] public IReadOnlyDictionary? RouteValues { get; set; } + + private string? _id; + private string _title = "Customer"; + private IDisposable? _token; + private bool _disposed; + + protected override void OnInitialized() + { + _token = Bus.Subscribe(OnRefresh, p => p == Events.Layout.Rendered); + } + + protected override async Task OnAfterRenderAsync(bool firstRender) + { + if (RouteValues is not null && _id is null) + { + if (RouteValues.TryGetValue("customerId", out object? rawId) == false) return; + _id = rawId?.ToString(); + + var entity = await Database.Customer() + .Find(p => p.Id == _id) + .FirstOrDefaultAsync(default); + + _title = $"{entity?.Name}"; + + await InvokeAsync(() => StateHasChanged()); + } + } + + public void OnRefresh(string? message) => InvokeAsync(StateHasChanged); + + public void Dispose() + { + Dispose(true); + GC.SuppressFinalize(this); + } + + private void Dispose(bool disposing) + { + if (_disposed) return; + if (disposing is false) return; + + try + { + _token?.Dispose(); + } + finally + { + _disposed = true; + } + } +} \ No newline at end of file diff --git a/src/Web/Insight.Web/Components/Navbars/Customer.razor.cs b/src/Web/Insight.Web/Components/Navbars/Customer.razor.cs deleted file mode 100644 index 87a89ae..0000000 --- a/src/Web/Insight.Web/Components/Navbars/Customer.razor.cs +++ /dev/null @@ -1,62 +0,0 @@ -using Insight.Infrastructure.Entities; -using Insight.Web.Constants; -using Microsoft.AspNetCore.Components; -using MongoDB.Driver; -using Vaitr.Bus; - -namespace Insight.Web.Components.Navbars; - -public partial class Customer -{ - [CascadingParameter] public IReadOnlyDictionary? RouteValues { get; set; } - - [Inject] private IMongoDatabase Database { get; set; } = default!; - [Inject] private Bus Bus { get; init; } = default!; - - private string Title { get; set; } = "Customer"; - private string? Id { get; set; } - - private IDisposable? Token { get; set; } - public bool Disposed { get; set; } = false; - - protected override void OnInitialized() - { - Token = Bus.Subscribe(OnRefresh, p => p == Events.Layout.Rendered); - } - - protected override async Task OnAfterRenderAsync(bool firstRender) - { - if (RouteValues is not null && Id is null) - { - if (RouteValues.TryGetValue("customerId", out object? rawId) == false) return; - Id = rawId?.ToString(); - - var entity = await Database.Customer() - .Find(p => p.Id == Id) - .FirstOrDefaultAsync(default); - - Title = $"{entity?.Name}"; - - await InvokeAsync(() => StateHasChanged()); - } - } - - public void OnRefresh(string? message) - { - InvokeAsync(() => StateHasChanged()); - } - - public void Dispose() - { - Dispose(true); - GC.SuppressFinalize(this); - } - - private void Dispose(bool disposing) - { - if (Disposed) return; - if (disposing is false) return; - - Token?.Dispose(); - } -} \ No newline at end of file diff --git a/src/Web/Insight.Web/Components/Navbars/Host.razor b/src/Web/Insight.Web/Components/Navbars/Host.razor index 5c394d7..bdf3950 100644 --- a/src/Web/Insight.Web/Components/Navbars/Host.razor +++ b/src/Web/Insight.Web/Components/Navbars/Host.razor @@ -1,60 +1,127 @@ -@inherits ComponentBase +@using MongoDB.Driver +@using Vaitr.Bus -@*@if (CustomerEntity is not null) +@inherits ComponentBase +@implements IDisposable + +@inject IMongoDatabase Database +@inject Bus Bus + +@*@if (_customer is not null) { - @CustomerEntity.Name + @_customer.Name }*@ -@if (HostEntity is not null) +@if (_host is not null) { - - @HostEntity.Name + + @_host.Name }
- Console + Console
- Os + Os - Installed - Pending + Installed + Pending - Sessions - Software - Services - Printers - Volumes - Users - Groups - Storage Pools - Virtual Maschines + Sessions + Software + Services + Printers + Volumes + Users + Groups + Storage Pools + Virtual Maschines - Interfaces - Addresses - Nameservers - Gateways - Routes + Interfaces + Addresses + Nameservers + Gateways + Routes - Mainboard - Processors - Memory - Drives - Videocards + Mainboard + Processors + Memory + Drives + Videocards
- Logs -
\ No newline at end of file + Logs +
+ +@code{ + [CascadingParameter] public IReadOnlyDictionary? RouteValues { get; set; } + + private string? _id; + private CustomerEntity? _customer; + private HostEntity? _host; + private IDisposable? _token; + private bool _disposed; + + protected override void OnInitialized() + { + _token = Bus?.Subscribe(OnRefresh, p => p == Events.Layout.Rendered); + } + + protected override async Task OnAfterRenderAsync(bool firstRender) + { + if (RouteValues is not null && _id is null) + { + if (RouteValues.TryGetValue("hostId", out object? rawId) == false) return; + _id = rawId?.ToString(); + + _host = await Database.Host() + .Find(p => p.Id == _id) + .FirstOrDefaultAsync(default); + + if (_host is not null) + { + _customer = await Database.Customer() + .Find(p => p.Id == _host.Customer) + .FirstOrDefaultAsync(default); + } + + await InvokeAsync(() => StateHasChanged()); + } + } + + public void OnRefresh(string? message) => InvokeAsync(StateHasChanged); + + public void Dispose() + { + Dispose(true); + GC.SuppressFinalize(this); + } + + private void Dispose(bool disposing) + { + if (_disposed) return; + if (disposing is false) return; + + try + { + _token?.Dispose(); + } + finally + { + _disposed = true; + } + } +} \ No newline at end of file diff --git a/src/Web/Insight.Web/Components/Navbars/Host.razor.cs b/src/Web/Insight.Web/Components/Navbars/Host.razor.cs deleted file mode 100644 index 719b30a..0000000 --- a/src/Web/Insight.Web/Components/Navbars/Host.razor.cs +++ /dev/null @@ -1,68 +0,0 @@ -using Insight.Infrastructure.Entities; -using Insight.Web.Constants; -using Microsoft.AspNetCore.Components; -using MongoDB.Driver; -using Vaitr.Bus; - -namespace Insight.Web.Components.Navbars; - -public partial class Host : IDisposable -{ - [CascadingParameter] public IReadOnlyDictionary? RouteValues { get; set; } - - [Inject] private IMongoDatabase Database { get; init; } = default!; - [Inject] private Bus Bus { get; init; } = default!; - - private CustomerEntity? CustomerEntity { get; set; } - private HostEntity HostEntity { get; set; } - private string? Id { get; set; } - - private IDisposable? Token { get; set; } - public bool Disposed { get; set; } = false; - - protected override void OnInitialized() - { - Token = Bus?.Subscribe(OnRefresh, p => p == Events.Layout.Rendered); - } - - protected override async Task OnAfterRenderAsync(bool firstRender) - { - if (RouteValues is not null && Id is null) - { - if (RouteValues.TryGetValue("hostId", out object? rawId) == false) return; - Id = rawId?.ToString(); - - HostEntity = await Database.Host() - .Find(p => p.Id == Id) - .FirstOrDefaultAsync(default); - - if (HostEntity is not null) - { - CustomerEntity = await Database.Customer() - .Find(p => p.Id == HostEntity.Customer) - .FirstOrDefaultAsync(default); - } - - await InvokeAsync(() => StateHasChanged()); - } - } - - public void OnRefresh(string? message) - { - InvokeAsync(() => StateHasChanged()); - } - - public void Dispose() - { - Dispose(true); - GC.SuppressFinalize(this); - } - - private void Dispose(bool disposing) - { - if (Disposed) return; - if (disposing is false) return; - - Token?.Dispose(); - } -} diff --git a/src/Web/Insight.Web/Components/Navbars/Main.razor b/src/Web/Insight.Web/Components/Navbars/Main.razor index 66261b4..7281e33 100644 --- a/src/Web/Insight.Web/Components/Navbars/Main.razor +++ b/src/Web/Insight.Web/Components/Navbars/Main.razor @@ -1,6 +1,14 @@ -@inherits ComponentBase +@using MongoDB.Driver +@using Vaitr.Bus - +@inherits ComponentBase +@implements IDisposable + +@inject NavigationManager NavigationManager +@inject IMongoDatabase Database +@inject Bus Bus + + @* Dashboard *@ @@ -12,7 +20,7 @@ *@ - + Os @@ -84,10 +92,7 @@ - - - Overview - + Accounts @@ -103,10 +108,52 @@ Agents + + Scheduler + -@* - - Chat - -*@ \ No newline at end of file +@code{ + private bool ExpandMonitoring => _uri.StartsWith(Navigation.Monitoring.Index); + private bool ExpandManagement => _uri.StartsWith(Navigation.Management.Index); + private bool ExpandInventory => _uri.StartsWith(Navigation.Inventory.Index); + private bool ExpandInventorySystem => _uri.StartsWith(Navigation.Inventory.Systems.Index); + private bool ExpandInventoryNetwork => _uri.StartsWith(Navigation.Inventory.Network.Index); + private bool ExpandInventoryHardware => _uri.StartsWith(Navigation.Inventory.Hardware.Index); + private string _uri = string.Empty; + private IDisposable? _token; + private bool _disposed; + + protected override void OnInitialized() + { + _token = Bus?.Subscribe(OnRefresh, p => p == Events.Layout.Rendered); + OnRefresh(); + } + + public void OnRefresh(string? message = null) + { + _uri = NavigationManager.ToBaseRelativePath(NavigationManager.Uri); + InvokeAsync(() => StateHasChanged()); + } + + public void Dispose() + { + Dispose(true); + GC.SuppressFinalize(this); + } + + private void Dispose(bool disposing) + { + if (_disposed is false) return; + if (disposing is false) return; + + try + { + _token?.Dispose(); + } + finally + { + _disposed = true; + } + } +} \ No newline at end of file diff --git a/src/Web/Insight.Web/Components/Navbars/Main.razor.cs b/src/Web/Insight.Web/Components/Navbars/Main.razor.cs deleted file mode 100644 index f7e3af5..0000000 --- a/src/Web/Insight.Web/Components/Navbars/Main.razor.cs +++ /dev/null @@ -1,136 +0,0 @@ -using Insight.Web.Constants; -using Microsoft.AspNetCore.Components; -using Vaitr.Bus; - -namespace Insight.Web.Components.Navbars; - -public partial class Main : IDisposable -{ - [Inject] private Bus Bus { get; init; } = default!; - [Inject] private NavigationManager NavigationManager { get; init; } = default!; - - private string Uri { get; set; } = string.Empty; - private IDisposable? Token { get; set; } - public bool Disposed { get; set; } = false; - - protected override void OnInitialized() - { - Token = Bus?.Subscribe(OnRefresh, p => p == Events.Layout.Rendered); - OnRefresh(); - } - - public void OnRefresh(string? message = null) - { - Uri = NavigationManager.ToBaseRelativePath(NavigationManager.Uri); - InvokeAsync(() => StateHasChanged()); - } - - private bool ExpandMonitoringGroup - { - get - { - if (Uri.StartsWith(Navigation.Monitoring.Index)) return true; - return false; - } - } - - private bool ExpandManagementGroup - { - get - { - if (Uri.StartsWith(Navigation.Management.Overview.Index)) return true; - if (Uri.StartsWith(Navigation.Management.Accounts.Index)) return true; - if (Uri.StartsWith(Navigation.Management.Customers.Index)) return true; - if (Uri.StartsWith(Navigation.Management.Hosts.Index)) return true; - if (Uri.StartsWith(Navigation.Management.HostGroups.Index)) return true; - if (Uri.StartsWith(Navigation.Management.Agents.Index)) return true; - return false; - } - } - - private bool ExpandInventoryGroup - { - get - { - if (ExpandInventorySystem) return true; - if (ExpandInventoryNetwork) return true; - if (ExpandInventoryHardware) return true; - return false; - } - } - - private bool ExpandInventorySystem - { - get - { - if (Uri.StartsWith(Navigation.Inventory.Systems.Os.Index)) return true; - if (Uri.StartsWith(Navigation.Inventory.Systems.Os.Hosts)) return true; - if (Uri.StartsWith(Navigation.Inventory.Systems.Os.Guests)) return true; - if (Uri.StartsWith(Navigation.Inventory.Systems.Updates.Index)) return true; - if (Uri.StartsWith(Navigation.Inventory.Systems.Updates.Hosts)) return true; - if (Uri.StartsWith(Navigation.Inventory.Systems.Software.Index)) return true; - if (Uri.StartsWith(Navigation.Inventory.Systems.Software.Hosts)) return true; - if (Uri.StartsWith(Navigation.Inventory.Systems.Services.Index)) return true; - if (Uri.StartsWith(Navigation.Inventory.Systems.Services.Hosts)) return true; - if (Uri.StartsWith(Navigation.Inventory.Systems.Sessions.Index)) return true; - if (Uri.StartsWith(Navigation.Inventory.Systems.Printers.Index)) return true; - if (Uri.StartsWith(Navigation.Inventory.Systems.Volumes.Index)) return true; - if (Uri.StartsWith(Navigation.Inventory.Systems.Users.Index)) return true; - if (Uri.StartsWith(Navigation.Inventory.Systems.Users.Hosts)) return true; - if (Uri.StartsWith(Navigation.Inventory.Systems.Groups.Index)) return true; - if (Uri.StartsWith(Navigation.Inventory.Systems.Groups.Hosts)) return true; - if (Uri.StartsWith(Navigation.Inventory.Systems.StoragePools.Index)) return true; - if (Uri.StartsWith(Navigation.Inventory.Systems.VirtualMaschines.Index)) return true; - return false; - } - } - - private bool ExpandInventoryNetwork - { - get - { - if (Uri.StartsWith(Navigation.Inventory.Network.Interfaces.Index)) return true; - if (Uri.StartsWith(Navigation.Inventory.Network.Addresses.Index)) return true; - if (Uri.StartsWith(Navigation.Inventory.Network.Addresses.Hosts)) return true; - if (Uri.StartsWith(Navigation.Inventory.Network.Nameservers.Index)) return true; - if (Uri.StartsWith(Navigation.Inventory.Network.Nameservers.Hosts)) return true; - if (Uri.StartsWith(Navigation.Inventory.Network.Gateways.Index)) return true; - if (Uri.StartsWith(Navigation.Inventory.Network.Gateways.Hosts)) return true; - if (Uri.StartsWith(Navigation.Inventory.Network.Routes.Index)) return true; - if (Uri.StartsWith(Navigation.Inventory.Network.Routes.Hosts)) return true; - return false; - } - } - - private bool ExpandInventoryHardware - { - get - { - if (Uri.StartsWith(Navigation.Inventory.Hardware.Mainboards.Index)) return true; - if (Uri.StartsWith(Navigation.Inventory.Hardware.Mainboards.Hosts)) return true; - if (Uri.StartsWith(Navigation.Inventory.Hardware.Processors.Index)) return true; - if (Uri.StartsWith(Navigation.Inventory.Hardware.Processors.Hosts)) return true; - if (Uri.StartsWith(Navigation.Inventory.Hardware.Memory.Index)) return true; - if (Uri.StartsWith(Navigation.Inventory.Hardware.Memory.Hosts)) return true; - if (Uri.StartsWith(Navigation.Inventory.Hardware.Drives.Index)) return true; - if (Uri.StartsWith(Navigation.Inventory.Hardware.Drives.Hosts)) return true; - if (Uri.StartsWith(Navigation.Inventory.Hardware.Videocards.Index)) return true; - if (Uri.StartsWith(Navigation.Inventory.Hardware.Videocards.Hosts)) return true; - return false; - } - } - - public void Dispose() - { - Dispose(true); - GC.SuppressFinalize(this); - } - - private void Dispose(bool disposing) - { - if (Disposed) return; - if (disposing is false) return; - - Token?.Dispose(); - } -} \ No newline at end of file diff --git a/src/Web/Insight.Web/Components/Navbars/NavSwitch.razor b/src/Web/Insight.Web/Components/Navbars/NavSwitch.razor deleted file mode 100644 index 9eb23b4..0000000 --- a/src/Web/Insight.Web/Components/Navbars/NavSwitch.razor +++ /dev/null @@ -1,29 +0,0 @@ -@using System.Reflection; -@inherits ComponentBase - -
- - - @if (_content == Content.Account) - { - - } - else if (_content == Content.Host) - { - - } - else if (_content == Content.Customer) - { - - } - else - { -
- } - - -
- - - @(Assembly.GetEntryAssembly()?.GetName().Version) - \ No newline at end of file diff --git a/src/Web/Insight.Web/Components/Navbars/NavSwitch.razor.cs b/src/Web/Insight.Web/Components/Navbars/NavSwitch.razor.cs deleted file mode 100644 index 2af5b32..0000000 --- a/src/Web/Insight.Web/Components/Navbars/NavSwitch.razor.cs +++ /dev/null @@ -1,59 +0,0 @@ -using Insight.Web.Constants; -using Microsoft.AspNetCore.Components; -using Vaitr.Bus; - -namespace Insight.Web.Components.Navbars; - -public partial class NavSwitch : IDisposable -{ - [CascadingParameter] public IReadOnlyDictionary? RouteValues { get; set; } - - [Inject] private NavigationManager NavigationManager { get; init; } = default!; - [Inject] private Bus Bus { get; init; } = default!; - - public string Url { get; set; } = string.Empty; - private IDisposable? Token { get; set; } - public bool Disposed { get; set; } = false; - - private enum Content { Main, Account, Customer, Host } - private Content _content = Content.Main; - - protected override void OnInitialized() - { - Token = Bus?.SubscribeAsync(OnRefreshAsync, p => p == Events.Layout.Rendered); - } - - protected override async Task OnAfterRenderAsync(bool firstRender) - { - if (firstRender) - { - await OnRefreshAsync().ConfigureAwait(false); - } - } - - public async ValueTask OnRefreshAsync(string? message = null, CancellationToken cancellationToken = default) - { - Url = NavigationManager.ToBaseRelativePath(NavigationManager.Uri); - - if (Url is null) return; - - if (Url.StartsWith($"{Navigation.Account.Index}/")) _content = Content.Account; - else if (Url.StartsWith($"{Navigation.Management.Customers.Index}/")) _content = Content.Customer; - else if (Url.StartsWith($"{Navigation.Management.Hosts.Index}/")) _content = Content.Host; - else _content = Content.Main; - - await InvokeAsync(StateHasChanged).ConfigureAwait(false); - } - - public void Dispose() - { - Dispose(true); - GC.SuppressFinalize(this); - } - - private void Dispose(bool disposing) - { - if (Disposed) return; - Token?.Dispose(); - } -} \ No newline at end of file diff --git a/src/Web/Insight.Web/Components/Navbars/Scheduler.razor b/src/Web/Insight.Web/Components/Navbars/Scheduler.razor new file mode 100644 index 0000000..024e016 --- /dev/null +++ b/src/Web/Insight.Web/Components/Navbars/Scheduler.razor @@ -0,0 +1,37 @@ +@inherits ComponentBase +@implements IDisposable + +@inject NavigationManager NavigationManager + + + Scheduler + + +Jobs +Tasks +Triggers + +@code{ + private bool _disposed; + + public void Dispose() + { + Dispose(true); + GC.SuppressFinalize(this); + } + + private void Dispose(bool disposing) + { + if (_disposed is false) return; + if (disposing is false) return; + + try + { + + } + finally + { + _disposed = true; + } + } +} \ No newline at end of file diff --git a/src/Web/Insight.Web/Components/Providers/ChatProvider.razor b/src/Web/Insight.Web/Components/Providers/ChatProvider.razor index 0ba0c57..c6f231a 100644 --- a/src/Web/Insight.Web/Components/Providers/ChatProvider.razor +++ b/src/Web/Insight.Web/Components/Providers/ChatProvider.razor @@ -2,11 +2,12 @@ @using Vaitr.Bus; @using static Insight.Web.Constants.Events.Chat; +@inherits ComponentBase +@implements IDisposable + @inject Bus Bus @inject SessionHandler SessionHandler -@implements IDisposable - @@ -20,7 +21,7 @@ private readonly ConcurrentBag _subscriptions = new(); - protected override async Task OnInitializedAsync() + protected override void OnInitialized() { _subscriptions.Add(Bus.SubscribeAsync(async (x, c) => await InvokeAsync(StateHasChanged), p => p == Events.Sessions.Changed)); _subscriptions.Add(Bus.SubscribeAsync(async (x, c) => await InvokeAsync(StateHasChanged), p => p.Message.SenderId != SessionHandler.State.Uid)); @@ -28,21 +29,24 @@ public void Dispose() { - Dispose(disposing: true); + Dispose(true); GC.SuppressFinalize(this); } - protected virtual void Dispose(bool disposing) + private void Dispose(bool disposing) { // auto disposed when starved circuit timeouts (disconnects) - if (_disposed is false) - { - if (disposing) - { - foreach (var sub in _subscriptions) sub.Dispose(); - _subscriptions.Clear(); - } + if (_disposed is false) return; + if (disposing is false) return; + + try + { + foreach (var sub in _subscriptions) sub.Dispose(); + _subscriptions.Clear(); + } + finally + { _disposed = true; } } diff --git a/src/Web/Insight.Web/Components/Providers/DrawerProvider.razor b/src/Web/Insight.Web/Components/Providers/DrawerProvider.razor index 22dbe6e..117178d 100644 --- a/src/Web/Insight.Web/Components/Providers/DrawerProvider.razor +++ b/src/Web/Insight.Web/Components/Providers/DrawerProvider.razor @@ -1,8 +1,47 @@ - +@using System.Reflection; +@using MongoDB.Driver +@using Vaitr.Bus + +@inherits ComponentBase +@implements IDisposable + +@inject NavigationManager NavigationManager +@inject IMongoDatabase Database +@inject Bus Bus + + - +
+ + + @if (_content == Content.Account) + { + + } + else if (_content == Content.Customer) + { + + } + else if (_content == Content.Host) + { + + } + else if (_content == Content.Scheduler) + { + + } + else + { +
+ } + + +
+ + @(Assembly.GetEntryAssembly()?.GetName().Version) +
@@ -11,6 +50,57 @@ @code { [CascadingParameter] public IReadOnlyDictionary? RouteValues { get; set; } + private string _uri = string.Empty; + private enum Content { Main, Account, Customer, Host, Scheduler } + private Content _content = Content.Main; + private IDisposable? _token; private bool _open = true; + private bool _disposed; + + protected override void OnInitialized() + { + _token = Bus?.SubscribeAsync(OnRefreshAsync, p => p == Events.Layout.Rendered); + } + + protected override async Task OnAfterRenderAsync(bool firstRender) + { + if (firstRender) await OnRefreshAsync(); + } + public void Toggle() => _open = !_open; + + public async ValueTask OnRefreshAsync(string? message = null, CancellationToken cancellationToken = default) + { + _uri = NavigationManager.ToBaseRelativePath(NavigationManager.Uri); + if (_uri is null) return; + + if (_uri.StartsWith($"{Navigation.Account.Index}/")) _content = Content.Account; + else if (_uri.StartsWith($"{Navigation.Management.Customers.Index}/")) _content = Content.Customer; + else if (_uri.StartsWith($"{Navigation.Management.Hosts.Index}/")) _content = Content.Host; + else if (_uri.StartsWith($"{Navigation.Management.Scheduler.Index}/")) _content = Content.Scheduler; + else _content = Content.Main; + + await InvokeAsync(StateHasChanged); + } + + public void Dispose() + { + Dispose(true); + GC.SuppressFinalize(this); + } + + private void Dispose(bool disposing) + { + if (_disposed is false) return; + if (disposing is false) return; + + try + { + _token?.Dispose(); + } + finally + { + _disposed = true; + } + } } \ No newline at end of file diff --git a/src/Web/Insight.Web/Components/Providers/ProfileProvider.razor b/src/Web/Insight.Web/Components/Providers/ProfileProvider.razor index 2208e1e..5cf99d6 100644 --- a/src/Web/Insight.Web/Components/Providers/ProfileProvider.razor +++ b/src/Web/Insight.Web/Components/Providers/ProfileProvider.razor @@ -1,4 +1,7 @@ -@inject NavigationManager NavigationManager +@inherits ComponentBase +@implements IDisposable + +@inject NavigationManager NavigationManager @@ -49,6 +52,7 @@ @code{ private MudMenu? _menu; + private bool _disposed; private void OnLogin() { @@ -67,4 +71,25 @@ _menu?.CloseMenu(); NavigationManager.NavigateTo(Navigation.Account.Profile, false); } + + public void Dispose() + { + Dispose(true); + GC.SuppressFinalize(this); + } + + private void Dispose(bool disposing) + { + if (_disposed is false) return; + if (disposing is false) return; + + try + { + + } + finally + { + _disposed = true; + } + } } \ No newline at end of file diff --git a/src/Web/Insight.Web/Components/Providers/SessionProvider.razor b/src/Web/Insight.Web/Components/Providers/SessionProvider.razor index b5910f5..7cdbfd5 100644 --- a/src/Web/Insight.Web/Components/Providers/SessionProvider.razor +++ b/src/Web/Insight.Web/Components/Providers/SessionProvider.razor @@ -1,14 +1,37 @@ @using Vaitr.Bus; +@inherits ComponentBase +@implements IDisposable + @inject SessionHandler SessionHandler @inject Bus Bus @code { + private bool _disposed; + protected override async Task OnAfterRenderAsync(bool firstRender) { - if (firstRender) + if (firstRender) await SessionHandler.UpdateStateAsync(default); + } + + public void Dispose() + { + Dispose(true); + GC.SuppressFinalize(this); + } + + private void Dispose(bool disposing) + { + if (_disposed is false) return; + if (disposing is false) return; + + try { - await SessionHandler.UpdateStateAsync(default); + + } + finally + { + _disposed = true; } } } \ No newline at end of file diff --git a/src/Web/Insight.Web/Components/Providers/ThemeProvider.razor b/src/Web/Insight.Web/Components/Providers/ThemeProvider.razor deleted file mode 100644 index f3549d7..0000000 --- a/src/Web/Insight.Web/Components/Providers/ThemeProvider.razor +++ /dev/null @@ -1,90 +0,0 @@ -@using Blazored.LocalStorage; -@using Microsoft.AspNetCore.Identity; -@using MongoDB.Driver; -@using Insight.Infrastructure - -@inject IServiceScopeFactory ServiceScopeFactory -@inject ILocalStorageService LocalStorageService -@inject IMongoDatabase Database -@inject AuthenticationStateProvider AuthenticationStateProvider - - - -@if (DisableIcon is false) -{ - -} - -@code { - [Parameter] public bool DisableIcon { get; set; } - - private MudTheme CurrentTheme { get; } = Themes.Default(); - private bool DarkMode { get; set; } - - protected override async Task OnInitializedAsync() - { - await LoadDarkModeAsync(); - } - - public async Task LoadDarkModeAsync() - { - // local storage - var storageDarkMode = await LocalStorageService.GetItemAsync("darkmode"); - if (storageDarkMode is bool darkmodeValue) DarkMode = darkmodeValue; - - // database override - var state = await AuthenticationStateProvider.GetAuthenticationStateAsync(); - - if (state?.User.Identity is not null && state.User.Identity.IsAuthenticated) - { - using var scope = ServiceScopeFactory.CreateScope(); - var userManager = scope.ServiceProvider.GetRequiredService>(); - - if (await userManager.FindByNameAsync(state.User.Identity.Name) is not InsightUser user) return; - - var userPrefs = await Database.UserPreference() - .Find(p => p.User == user.Id.ToString()) - .FirstOrDefaultAsync(); - - if (userPrefs is null) return; - - DarkMode = userPrefs.DarkMode; - - await LocalStorageService.SetItemAsync("darkmode", DarkMode); - } - } - - private async Task OnDarkModeToggleAsync() - { - // update current - DarkMode = !DarkMode; - - // update local storage - await LocalStorageService.SetItemAsync("darkmode", DarkMode); - - // update database - var state = await AuthenticationStateProvider.GetAuthenticationStateAsync(); - - if (state?.User.Identity is not null && state.User.Identity.IsAuthenticated) - { - using var scope = ServiceScopeFactory.CreateScope(); - var userManager = scope.ServiceProvider.GetRequiredService>(); - - if (await userManager.FindByNameAsync(state.User.Identity.Name) is not InsightUser user) return; - - var date = DateTime.Now; - - var userPrefs = await Database.UserPreference() - .UpdateOneAsync(p => p.User == user.Id.ToString(), Builders.Update - .SetOnInsert(p => p.User, user.Id.ToString()) - .SetOnInsert(p => p.Insert, date) - .Set(p => p.Update, date) - .Set(p => p.DarkMode, DarkMode), new UpdateOptions - { - IsUpsert = true - }); - } - - await InvokeAsync(StateHasChanged); - } -} \ No newline at end of file diff --git a/src/Web/Insight.Web/Constants/Navigation.cs b/src/Web/Insight.Web/Constants/Navigation.cs index cc2209a..3fcdfd6 100644 --- a/src/Web/Insight.Web/Constants/Navigation.cs +++ b/src/Web/Insight.Web/Constants/Navigation.cs @@ -1,4 +1,6 @@ -namespace Insight.Web.Constants; +using static Insight.Web.Constants.Navigation.Monitoring; + +namespace Insight.Web.Constants; public static class Navigation { @@ -13,44 +15,22 @@ public static class Navigation public static class Account { public const string Index = "account"; - public const string Login = "account/login"; - public const string LoginTFA = "account/login/{key:guid}"; - public const string SignIn = "account/signin"; - public const string SignInTFA = "account/signin/2fa"; - public const string Logout = "account/logout"; - public const string Lockout = "account/lockout"; - public const string Profile = "account/profile"; - public const string ChangePassword = "account/changepassword"; + public const string Login = Index + "/login"; + public const string LoginTFA = Login + "/{key:guid}"; + public const string SignIn = Index + "/signin"; + public const string SignInTFA = SignIn + "/2fa"; + public const string Logout = Index + "/logout"; + public const string Lockout = Index + "/lockout"; + public const string Profile = Index + "/profile"; + public const string ChangePassword = Index + "/changepassword"; - public static string LoginHref(string redirect) - { - if (string.IsNullOrWhiteSpace(redirect)) - { - return Login; - } + public static string LoginHref(string redirect) => string.IsNullOrWhiteSpace(redirect) ? Login : $"{Login}?redirect={redirect}"; + public static string LoginTFAHref(Guid key) => LoginTFA.Replace("{key:guid}", key.ToString()); - return $"{Login}?redirect={redirect}"; - } + public static string SignInHref(Guid key) => $"{SignIn}?key={key}"; + public static string SignInTFAHref(Guid key) => $"{SignInTFA}?key={key}"; - public static string LoginTFAHref(Guid key) - { - return LoginTFA.Replace("{key:guid}", key.ToString()); - } - - public static string SignInHref(Guid key) - { - return $"{SignIn}?key={key}"; - } - - public static string SignInTFAHref(Guid key) - { - return $"{SignInTFA}?key={key}"; - } - - public static string ChangePasswordHref(Guid key) - { - return $"{ChangePassword}?key={key}"; - } + public static string ChangePasswordHref(Guid key) => $"{ChangePassword}?key={key}"; } public static class Monitoring @@ -59,36 +39,36 @@ public static class Navigation public static class Maintenance { - public const string Index = "monitoring/maintenance"; + public const string Index = Monitoring.Index + "/maintenance"; public static class Drives { - public const string Index = "monitoring/maintenance/drives"; + public const string Index = Monitoring.Index + "/drives"; } public static class StoragePools { - public const string Index = "monitoring/maintenance/storagepools"; + public const string Index = Monitoring.Index + "/storagepools"; } public static class Volumes { - public const string Index = "monitoring/maintenance/volumes"; + public const string Index = Monitoring.Index + "/volumes"; } public static class Guests { - public const string Index = "monitoring/maintenance/guests"; + public const string Index = Monitoring.Index + "/guests"; } public static class Snapshots { - public const string Index = "monitoring/maintenance/snapshots"; + public const string Index = Monitoring.Index + "/snapshots"; } public static class Updates { - public const string Index = "monitoring/maintenance/updates"; + public const string Index = Monitoring.Index + "/updates"; } } } @@ -97,106 +77,58 @@ public static class Navigation { public const string Index = "management"; - public static class Overview - { - public const string Index = "management/overview"; - } - public static class Accounts { - public const string Index = "management/accounts"; - public const string Details = "management/accounts/{accountId}"; + public const string Index = Management.Index + "/accounts"; + public const string Details = Index + "/{accountId}"; - public static string DetailsHref(string? accountId) - { - return Details.Replace("{accountId}", accountId); - } + public static string DetailsHref(string? accountId) => Details.Replace("{accountId}", accountId); } public static class Customers { - public const string Index = "management/customers"; - public const string Details = "management/customers/{customerId}"; - public const string Hosts = "management/customers/{customerId}/hosts"; - public const string HostsAssign = "management/customers/{customerId}/hosts/assign"; + public const string Index = Management.Index + "/customers"; + public const string Details = Index + "/{customerId}"; + public const string Hosts = Details + "/hosts"; + public const string HostsAssign = Hosts + "/assign"; - public static string DetailsHref(string? customerId) - { - return Details.Replace("{customerId}", customerId); - } - - public static string HostsHref(string? customerId) - { - return Hosts.Replace("{customerId}", customerId); - } - - public static string HostsAssignHref(string? customerId) - { - return HostsAssign.Replace("{customerId}", customerId); - } + public static string DetailsHref(string? customerId) => Details.Replace("{customerId}", customerId); + public static string HostsHref(string? customerId) => Hosts.Replace("{customerId}", customerId); + public static string HostsAssignHref(string? customerId) => HostsAssign.Replace("{customerId}", customerId); } public static class Agents { - public const string Index = "management/agents"; - public const string Details = "management/agents/{agentId}"; - public const string Logs = "management/agents/{agentId}/logs"; - public const string HostAssign = "management/agents/{agentId}/assign"; + public const string Index = Management.Index + "/agents"; + public const string Details = Index + "/{agentId}"; + public const string Logs = Details + "/logs"; + public const string HostAssign = Details + "/assign"; - public static string DetailsHref(string? agentId) - { - return Details.Replace("{agentId}", agentId); - } - - public static string LogsHref(string? agentId) - { - return Logs.Replace("{agentId}", agentId); - } - - public static string HostAssingHref(string? agentId) - { - return HostAssign.Replace("{agentId}", agentId); - } + public static string DetailsHref(string? agentId) => Details.Replace("{agentId}", agentId); + public static string LogsHref(string? agentId) => Logs.Replace("{agentId}", agentId); + public static string HostAssingHref(string? agentId) => HostAssign.Replace("{agentId}", agentId); } public static class Hosts { - public const string Index = "management/hosts"; - public const string Details = "management/hosts/{hostId}"; - public const string Logs = "management/hosts/{hostId}/logs"; - public const string CustomerAssign = "management/hosts/{hostId}/customer/assign"; - public const string AgentAssign = "management/hosts/{hostId}/agent/assign"; + public const string Index = Management.Index + "/hosts"; + public const string Details = Index + "/{hostId}"; + public const string Logs = Details + "/logs"; + public const string CustomerAssign = Details + "/customer/assign"; + public const string AgentAssign = Details + "/agent/assign"; - public static string DetailsHref(string? hostId) - { - return Details.Replace("{hostId}", hostId); - } - - public static string LogsHref(string? hostId) - { - return Logs.Replace("{hostId}", hostId); - } - - public static string CustomerAssingHref(string? hostId) - { - return CustomerAssign.Replace("{hostId}", hostId); - } - - public static string AgentAssingHref(string? hostId) - { - return AgentAssign.Replace("{hostId}", hostId); - } + public static string DetailsHref(string? hostId) => Details.Replace("{hostId}", hostId); + public static string LogsHref(string? hostId) => Logs.Replace("{hostId}", hostId); + public static string CustomerAssingHref(string? hostId) => CustomerAssign.Replace("{hostId}", hostId); + public static string AgentAssingHref(string? hostId) => AgentAssign.Replace("{hostId}", hostId); public static class Actions { public static class Console { - public const string Index = "management/hosts/{hostId}/console"; + public const string Index = Hosts.Details + "/console"; - public static string IndexHref(string? hostId) - { - return Index.Replace("{hostId}", hostId); - } + public static string IndexHref(string? hostId) => Index.Replace("{hostId}", hostId); } } @@ -204,190 +136,121 @@ public static class Navigation { public static class Os { - public const string Details = "management/hosts/{hostId}/os"; + public const string Details = Hosts.Details + "/os"; - public static string DetailsHref(string? hostId) - { - return Details.Replace("{hostId}", hostId); - } + public static string DetailsHref(string? hostId) => Details.Replace("{hostId}", hostId); } public static class Updates { public static class Installed { - public const string Index = "management/hosts/{hostId}/updates/installed"; + public const string Index = Hosts.Details + "/updates/installed"; - public static string IndexHref(string? hostId) - { - return Index.Replace("{hostId}", hostId); - } + public static string IndexHref(string? hostId) => Index.Replace("{hostId}", hostId); } public static class Pending { - public const string Index = "management/hosts/{hostId}/updates/pending"; + public const string Index = Hosts.Details + "/updates/pending"; - public static string IndexHref(string? hostId) - { - return Index.Replace("{hostId}", hostId); - } + public static string IndexHref(string? hostId) => Index.Replace("{hostId}", hostId); } } public static class Sessions { - public const string Index = "management/hosts/{hostId}/sessions"; + public const string Index = Hosts.Details + "/sessions"; - public static string IndexHref(string? hostId) - { - return Index.Replace("{hostId}", hostId); - } + public static string IndexHref(string? hostId) => Index.Replace("{hostId}", hostId); } public static class Software { - public const string Index = "management/hosts/{hostId}/software"; + public const string Index = Hosts.Details + "/software"; - public static string IndexHref(string? hostId) - { - return Index.Replace("{hostId}", hostId); - } + public static string IndexHref(string? hostId) => Index.Replace("{hostId}", hostId); } public static class Services { - public const string Index = "management/hosts/{hostId}/services"; + public const string Index = Hosts.Details + "/services"; - public static string IndexHref(string? hostId) - { - return Index.Replace("{hostId}", hostId); - } + public static string IndexHref(string? hostId) => Index.Replace("{hostId}", hostId); } public static class Printers { - public const string Index = "management/hosts/{hostId}/printers"; + public const string Index = Hosts.Details + "/printers"; - public static string IndexHref(string? hostId) - { - return Index.Replace("{hostId}", hostId); - } + public static string IndexHref(string? hostId) => Index.Replace("{hostId}", hostId); } public static class Volumes { - public const string Index = "management/hosts/{hostId}/volumes"; - public const string Details = "management/hosts/{hostId}/volumes/{volumeId}"; + public const string Index = Hosts.Details + "/volumes"; + public const string Details = Index + "/{volumeId}"; - public static string IndexHref(string? hostId) - { - return Index.Replace("{hostId}", hostId); - } - - public static string DetailsHref(string? hostId, string? volumeId) - { - return Details.Replace("{hostId}", hostId).Replace("{volumeId}", volumeId); - } + public static string IndexHref(string? hostId) => Index.Replace("{hostId}", hostId); + public static string DetailsHref(string? hostId, string? volumeId) => Details.Replace("{hostId}", hostId).Replace("{volumeId}", volumeId); } public static class Users { - public const string Index = "management/hosts/{hostId}/users"; - public const string Details = "management/hosts/{hostId}/users/{userId}"; + public const string Index = Hosts.Details + "/users"; + public const string Details = Index + "/{userId}"; - public static string IndexHref(string? hostId) - { - return Index.Replace("{hostId}", hostId); - } - - public static string DetailsHref(string? hostId, string? userId) - { - return Details.Replace("{hostId}", hostId).Replace("{userId}", userId); - } + public static string IndexHref(string? hostId) => Index.Replace("{hostId}", hostId); + public static string DetailsHref(string? hostId, string? userId) => Details.Replace("{hostId}", hostId).Replace("{userId}", userId); } public static class Groups { - public const string Index = "management/hosts/{hostId}/groups"; + public const string Index = Hosts.Details + "/groups"; - public static string IndexHref(string? hostId) - { - return Index.Replace("{hostId}", hostId); - } + public static string IndexHref(string? hostId) => Index.Replace("{hostId}", hostId); } public static class StoragePools { - public const string Index = "management/hosts/{hostId}/storagepools"; - public const string Details = "management/hosts/{hostId}/storagepools/{storagePoolId}"; + public const string Index = Hosts.Details + "/storagepools"; + public const string Details = Index + "/{storagePoolId}"; - public static string IndexHref(string? hostId) - { - return Index.Replace("{hostId}", hostId); - } - - public static string DetailsHref(string? hostId, string? storagePoolId) - { - return Details.Replace("{hostId}", hostId).Replace("{storagePoolId}", storagePoolId); - } + public static string IndexHref(string? hostId) => Index.Replace("{hostId}", hostId); + public static string DetailsHref(string? hostId, string? storagePoolId) => Details.Replace("{hostId}", hostId).Replace("{storagePoolId}", storagePoolId); public static class VirtualDisks { - public const string Index = "management/hosts/{hostId}/storagepools/{storagePoolId}/virtualdisks"; - public const string Details = "management/hosts/{hostId}/storagepools/{storagePoolId}/virtualdisks/{virtualDiskId}"; + public const string Index = StoragePools.Details + "/virtualdisks"; + public const string Details = Index + "/{virtualDiskId}"; - public static string IndexHref(string? hostId, string? storagePoolId) - { - return Index.Replace("{hostId}", hostId).Replace("{storagePoolId}", storagePoolId); - } - - public static string DetailsHref(string? hostId, string? storagePoolId, string? virtualDiskId) - { - return Details.Replace("{hostId}", hostId).Replace("{storagePoolId}", storagePoolId).Replace("{virtualDiskId}", virtualDiskId); - } + public static string IndexHref(string? hostId, string? storagePoolId) => Index.Replace("{hostId}", hostId).Replace("{storagePoolId}", storagePoolId); + public static string DetailsHref(string? hostId, string? storagePoolId, string? virtualDiskId) => Details.Replace("{hostId}", hostId).Replace("{storagePoolId}", storagePoolId).Replace("{virtualDiskId}", virtualDiskId); } public static class PhysicalDisks { - public const string Index = "management/hosts/{hostId}/storagepools/{storagePoolId}/physicaldisks"; - public const string Details = "management/hosts/{hostId}/storagepools/{storagePoolId}/physicaldisks/{physicalDiskId}"; + public const string Index = StoragePools.Details + "/physicaldisks"; + public const string Details = Index + "/{physicalDiskId}"; - public static string IndexHref(string? hostId, string? storagePoolId) - { - return Index.Replace("{hostId}", hostId).Replace("{storagePoolId}", storagePoolId); - } - - public static string DetailsHref(string? hostId, string? storagePoolId, string? physicalDiskId) - { - return Details.Replace("{hostId}", hostId).Replace("{storagePoolId}", storagePoolId).Replace("{physicalDiskId}", physicalDiskId); - } + public static string IndexHref(string? hostId, string? storagePoolId) => Index.Replace("{hostId}", hostId).Replace("{storagePoolId}", storagePoolId); + public static string DetailsHref(string? hostId, string? storagePoolId, string? physicalDiskId) => Details.Replace("{hostId}", hostId).Replace("{storagePoolId}", storagePoolId).Replace("{physicalDiskId}", physicalDiskId); } } public static class VirtualMaschines { - public const string Index = "management/hosts/{hostId}/virtualmaschines"; - public const string Details = "management/hosts/{hostId}/virtualmaschines/{virtualMaschineId}"; + public const string Index = Hosts.Details + "/virtualmaschines"; + public const string Details = Index + "/{virtualMaschineId}"; - public static string IndexHref(string? hostId) - { - return Index.Replace("{hostId}", hostId); - } - - public static string DetailsHref(string? hostId, string? virtualMaschineId) - { - return Details.Replace("{hostId}", hostId).Replace("{virtualMaschineId}", virtualMaschineId); - } + public static string IndexHref(string? hostId) => Index.Replace("{hostId}", hostId); + public static string DetailsHref(string? hostId, string? virtualMaschineId) => Details.Replace("{hostId}", hostId).Replace("{virtualMaschineId}", virtualMaschineId); public static class Snapshots { - public const string Details = "management/hosts/{hostId}/virtualmaschines/{virtualMaschineId}/snapshots/{snapshotId}"; + public const string Details = VirtualMaschines.Details + "/snapshots/{snapshotId}"; - public static string DetailsHref(string? hostId, string? virtualMaschineId, string? snapshotId) - { - return Details.Replace("{hostId}", hostId).Replace("{virtualMaschineId}", virtualMaschineId).Replace("{snapshotId}", snapshotId); - } + public static string DetailsHref(string? hostId, string? virtualMaschineId, string? snapshotId) => Details.Replace("{hostId}", hostId).Replace("{virtualMaschineId}", virtualMaschineId).Replace("{snapshotId}", snapshotId); } } } @@ -396,63 +259,44 @@ public static class Navigation { public static class Interfaces { - public const string Index = "management/hosts/{hostId}/interfaces"; - public const string Details = "management/hosts/{hostId}/interfaces/{interfaceId}"; + public const string Index = Hosts.Details + "/interfaces"; + public const string Details = Index + "/{interfaceId}"; - public const string Addresses = "management/hosts/{hostId}/interfaces/{interfaceId}/addresses"; - public const string Nameservers = "management/hosts/{hostId}/interfaces/{interfaceId}/nameservers"; - public const string Gateways = "management/hosts/{hostId}/interfaces/{interfaceId}/gateways"; - public const string Routes = "management/hosts/{hostId}/interfaces/{interfaceId}/routes"; + public const string Addresses = Details + "/addresses"; + public const string Nameservers = Details + "/nameservers"; + public const string Gateways = Details + "/gateways"; + public const string Routes = Details + "/routes"; - public static string IndexHref(string? hostId) - { - return Index.Replace("{hostId}", hostId); - } - - public static string DetailsHref(string? hostId, string? interfaceId) - { - return Details.Replace("{hostId}", hostId).Replace("{interfaceId}", interfaceId); - } + public static string IndexHref(string? hostId) => Index.Replace("{hostId}", hostId); + public static string DetailsHref(string? hostId, string? interfaceId) => Details.Replace("{hostId}", hostId).Replace("{interfaceId}", interfaceId); } public static class Addresses { - public const string Index = "management/hosts/{hostId}/addresses"; + public const string Index = Hosts.Details + "/addresses"; - public static string IndexHref(string? hostId) - { - return Index.Replace("{hostId}", hostId); - } + public static string IndexHref(string? hostId) => Index.Replace("{hostId}", hostId); } public static class Gateways { - public const string Index = "management/hosts/{hostId}/gateways"; + public const string Index = Details + "/gateways"; - public static string IndexHref(string? hostId) - { - return Index.Replace("{hostId}", hostId); - } + public static string IndexHref(string? hostId) => Index.Replace("{hostId}", hostId); } public static class Nameservers { - public const string Index = "management/hosts/{hostId}/nameservers"; + public const string Index = Hosts.Details + "/nameservers"; - public static string IndexHref(string? hostId) - { - return Index.Replace("{hostId}", hostId); - } + public static string IndexHref(string? hostId) => Index.Replace("{hostId}", hostId); } public static class Routes { - public const string Index = "management/hosts/{hostId}/routes"; + public const string Index = Hosts.Details + "/routes"; - public static string IndexHref(string? hostId) - { - return Index.Replace("{hostId}", hostId); - } + public static string IndexHref(string? hostId) => Index.Replace("{hostId}", hostId); } } @@ -460,300 +304,264 @@ public static class Navigation { public static class Mainboard { - public const string Details = "management/hosts/{hostId}/mainboard"; + public const string Details = Hosts.Details + "/mainboard"; - public static string DetailsHref(string? hostId) - { - return Details.Replace("{hostId}", hostId); - } + public static string DetailsHref(string? hostId) => Details.Replace("{hostId}", hostId); } public static class Processors { - public const string Details = "management/hosts/{hostId}/processors"; + public const string Details = Hosts.Details + "/processors"; - public static string DetailsHref(string? hostId) - { - return Details.Replace("{hostId}", hostId); - } + public static string DetailsHref(string? hostId) => Details.Replace("{hostId}", hostId); } public static class Memory { - public const string Index = "management/hosts/{hostId}/memory"; + public const string Index = Hosts.Details + "/memory"; - public static string IndexHref(string? hostId) - { - return Index.Replace("{hostId}", hostId); - } + public static string IndexHref(string? hostId) => Index.Replace("{hostId}", hostId); } public static class Drives { - public const string Index = "management/hosts/{hostId}/drives"; + public const string Index = Hosts.Details + "/drives"; - public static string IndexHref(string? hostId) - { - return Index.Replace("{hostId}", hostId); - } + public static string IndexHref(string? hostId) => Index.Replace("{hostId}", hostId); } public static class Videocards { - public const string Index = "management/hosts/{hostId}/videocards"; + public const string Index = Hosts.Details + "/videocards"; - public static string IndexHref(string? hostId) - { - return Index.Replace("{hostId}", hostId); - } + public static string IndexHref(string? hostId) => Index.Replace("{hostId}", hostId); } } } public static class HostGroups { - public const string Index = "management/hostgroups"; - public const string Details = "management/hostgroups/{groupId}"; - public const string Hosts = "management/hostgroups/{groupId}/hosts"; - public const string HostsAssign = "management/hostgroups/{groupId}/hosts/assign"; + public const string Index = Management.Index + "/hostgroups"; + public const string Details = Index + "/{groupId}"; + public const string Hosts = Details + "/hosts"; + public const string HostsAssign = Details + "/assign"; - public static string DetailsHref(string? groupId) + public static string DetailsHref(string? groupId) => Details.Replace("{groupId}", groupId); + public static string HostsHref(string? groupId) => Hosts.Replace("{groupId}", groupId); + public static string HostsAssignHref(string? groupId) => HostsAssign.Replace("{groupId}", groupId); + } + + public static class Scheduler + { + public const string Index = Management.Index + "/scheduler"; + + public static class Jobs { - return Details.Replace("{groupId}", groupId); + public const string Index = Scheduler.Index + "/jobs"; + public const string Details = Index + "/{jobId}"; + public const string Tasks = Details + "/tasks"; + public const string TasksAssign = Tasks + "/assign"; + public const string Triggers = Details + "/triggers"; + public const string TriggersAssign = Triggers + "/assign"; + + public static string DetailsHref(string? jobId) => Details.Replace("{jobId}", jobId); + public static string TasksHref(string? jobId) => Tasks.Replace("{jobId}", jobId); + public static string TasksAssignHref(string? jobId) => TasksAssign.Replace("{jobId}", jobId); + public static string TriggersHref(string? jobId) => Triggers.Replace("{jobId}", jobId); + public static string TriggersAssignHref(string? jobId) => TriggersAssign.Replace("{jobId}", jobId); } - public static string HostsHref(string? groupId) + public static class Tasks { - return Hosts.Replace("{groupId}", groupId); + public const string Index = Scheduler.Index + "/tasks"; + public const string Details = Index + "/{taskId}"; + public const string Jobs = Details + "/jobs"; + + public static string DetailsHref(string? taskId) => Details.Replace("{taskId}", taskId); + public static string JobsHref(string? taskId) => Jobs.Replace("{taskId}", taskId); } - public static string HostsAssignHref(string? groupId) + public static class Triggers { - return HostsAssign.Replace("{groupId}", groupId); + public const string Index = Scheduler.Index + "/triggers"; + public const string Details = Index + "/{triggerId}"; + public const string Jobs = Details + "/jobs"; + + public static string DetailsHref(string? triggerId) => Details.Replace("{triggerId}", triggerId); + public static string JobsHref(string? triggerId) => Jobs.Replace("{triggerId}", triggerId); } } } public static class Inventory { + public const string Index = "inventory"; + public static class Systems { + public const string Index = Inventory.Index + "/system"; + public static class Os { - public const string Index = "inventory/os"; - public const string Hosts = "inventory/os/{osName}/hosts"; - public const string Guests = "inventory/os/{osName}/guests"; + public const string Index = Systems.Index + "/os"; + public const string Hosts = Index + "/{osName}/hosts"; + public const string Guests = Index + "/{osName}/guests"; - public static string HostsHref(string? osName) - { - return Hosts.Replace("{osName}", osName); - } - - public static string GuestsHref(string? osName) - { - return Guests.Replace("{osName}", osName); - } + public static string HostsHref(string? osName) => Hosts.Replace("{osName}", osName); + public static string GuestsHref(string? osName) => Guests.Replace("{osName}", osName); } public static class Updates { - public const string Index = "inventory/updates"; - public const string Hosts = "inventory/updates/{updateName}/hosts"; + public const string Index = Systems.Index + "/updates"; + public const string Hosts = Index + "/{updateName}/hosts"; - public static string HostsHref(string? updateName) - { - return Hosts.Replace("{updateName}", updateName); - } + public static string HostsHref(string? updateName) => Hosts.Replace("{updateName}", updateName); } public static class Software { - public const string Index = "inventory/software"; - public const string Hosts = "inventory/software/{softwareName}/hosts"; + public const string Index = Systems.Index + "/software"; + public const string Hosts = Index + "/{softwareName}/hosts"; - public static string HostsHref(string? software) - { - return Hosts.Replace("{softwareName}", software); - } + public static string HostsHref(string? software) => Hosts.Replace("{softwareName}", software); } public static class Services { - public const string Index = "inventory/services"; - public const string Hosts = "inventory/services/{serviceName}/hosts"; + public const string Index = Systems.Index + "/services"; + public const string Hosts = Index + "/{serviceName}/hosts"; - public static string HostsHref(string? serviceName) - { - return Hosts.Replace("{serviceName}", serviceName); - } + public static string HostsHref(string? serviceName) => Hosts.Replace("{serviceName}", serviceName); } public static class Sessions { - public const string Index = "inventory/sessions"; + public const string Index = Systems.Index + "/sessions"; } public static class Printers { - public const string Index = "inventory/printers"; + public const string Index = Systems.Index + "/printers"; } public static class Volumes { - public const string Index = "inventory/volumes"; + public const string Index = Systems.Index + "/volumes"; } public static class Users { - public const string Index = "inventory/users"; - public const string Hosts = "inventory/users/{userName}/hosts"; + public const string Index = Systems.Index + "/users"; + public const string Hosts = Index + "/{userName}/hosts"; - public static string HostsHref(string? userName) - { - return Hosts.Replace("{userName}", userName); - } + public static string HostsHref(string? userName) => Hosts.Replace("{userName}", userName); } public static class Groups { - public const string Index = "inventory/groups"; - public const string Hosts = "inventory/groups/{groupName}/hosts"; + public const string Index = Systems.Index + "/groups"; + public const string Hosts = Index + "/{groupName}/hosts"; - public static string HostsHref(string? groupName) - { - return Hosts.Replace("{groupName}", groupName); - } + public static string HostsHref(string? groupName) => Hosts.Replace("{groupName}", groupName); } public static class StoragePools { - public const string Index = "inventory/storagepools"; + public const string Index = Systems.Index + "/storagepools"; } public static class VirtualMaschines { - public const string Index = "inventory/virtualmaschines"; + public const string Index = Systems.Index + "/virtualmaschines"; } } public static class Network { + public const string Index = Inventory.Index + "/network"; + public static class Interfaces { - public const string Index = "inventory/interfaces"; + public const string Index = Network.Index + "/interfaces"; } public static class Addresses { - public const string Index = "inventory/addresses"; - public const string Hosts = "inventory/addresses/{address}/hosts"; + public const string Index = Network.Index + "/addresses"; + public const string Hosts = Index + "/{address}/hosts"; - public static string HostsHref(string? address) - { - return Hosts.Replace("{address}", address); - } + public static string HostsHref(string? address) => Hosts.Replace("{address}", address); } public static class Nameservers { - public const string Index = "inventory/nameservers"; - public const string Hosts = "inventory/nameservers/{nameserverAddress}/hosts"; + public const string Index = Network.Index + "/nameservers"; + public const string Hosts = Index + "/{nameserverAddress}/hosts"; - public static string HostsHref(string? nameserverAddress) - { - return Hosts.Replace("{nameserverAddress}", nameserverAddress); - } + public static string HostsHref(string? nameserverAddress) => Hosts.Replace("{nameserverAddress}", nameserverAddress); } public static class Gateways { - public const string Index = "inventory/gateways"; - public const string Hosts = "inventory/gateways/{gatewayAddress}/hosts"; + public const string Index = Network.Index + "/gateways"; + public const string Hosts = Index + "/{gatewayAddress}/hosts"; - public static string HostsHref(string? gatewayAddress) - { - return Hosts.Replace("{gatewayAddress}", gatewayAddress); - } + public static string HostsHref(string? gatewayAddress) => Hosts.Replace("{gatewayAddress}", gatewayAddress); } public static class Routes { - public const string Index = "inventory/routes"; - public const string Hosts = "inventory/routes/{routeAddress}/hosts"; + public const string Index = Network.Index + "/routes"; + public const string Hosts = Index + "/{routeAddress}/hosts"; - public static string HostsHref(string? routeAddress) - { - return Hosts.Replace("{routeAddress}", routeAddress); - } + public static string HostsHref(string? routeAddress) => Hosts.Replace("{routeAddress}", routeAddress); } } public static class Hardware { + public const string Index = Inventory.Index + "/hardware"; + public static class Mainboards { - public const string Index = "inventory/mainboards"; - public const string Hosts = "inventory/mainboards/{mainboardName}/hosts"; + public const string Index = Hardware.Index + "/mainboards"; + public const string Hosts = Index + "/{mainboardName}/hosts"; - public static string HostsHref(string? mainboardName) - { - return Hosts.Replace("{mainboardName}", mainboardName); - } + public static string HostsHref(string? mainboardName) => Hosts.Replace("{mainboardName}", mainboardName); } public static class Processors { - public const string Index = "inventory/processors"; - public const string Hosts = "inventory/processors/{processorName}/hosts"; + public const string Index = Hardware.Index + "/processors"; + public const string Hosts = Index + "/{processorName}/hosts"; - public static string HostsHref(string? processorName) - { - return Hosts.Replace("{processorName}", processorName); - } + public static string HostsHref(string? processorName) => Hosts.Replace("{processorName}", processorName); } public static class Memory { - public const string Index = "inventory/memory"; - public const string Hosts = "inventory/memory/{memoryName}/hosts"; + public const string Index = Hardware.Index + "/memory"; + public const string Hosts = Index + "/{memoryName}/hosts"; - public static string HostsHref(string? memoryName) - { - return Hosts.Replace("{memoryName}", memoryName); - } + public static string HostsHref(string? memoryName) => Hosts.Replace("{memoryName}", memoryName); } public static class Drives { - public const string Index = "inventory/drives"; - public const string Hosts = "inventory/drives/{driveName}/hosts"; + public const string Index = Hardware.Index + "/drives"; + public const string Hosts = Index + "/{driveName}/hosts"; - public static string HostsHref(string? driveName) - { - return Hosts.Replace("{driveName}", driveName); - } + public static string HostsHref(string? driveName) => Hosts.Replace("{driveName}", driveName); } public static class Videocards { - public const string Index = "inventory/videocards"; - public const string Hosts = "inventory/videocards/{videocardName}/hosts"; + public const string Index = Hardware.Index + "/videocards"; + public const string Hosts = Index + "/{videocardName}/hosts"; - public static string HostsHref(string? videocardName) - { - return Hosts.Replace("{videocardName}", videocardName); - } + public static string HostsHref(string? videocardName) => Hosts.Replace("{videocardName}", videocardName); } } } - - public static class Communication - { - public const string Index = "communication"; - - public static class Chat - { - public const string Index = "communication/chat"; - } - } } \ No newline at end of file diff --git a/src/Web/Insight.Web/Insight.Web.csproj b/src/Web/Insight.Web/Insight.Web.csproj index 3f387e8..b5226cd 100644 --- a/src/Web/Insight.Web/Insight.Web.csproj +++ b/src/Web/Insight.Web/Insight.Web.csproj @@ -4,7 +4,7 @@ net7.0 Insight web - 2023.11.17.0 + 2023.12.14.0 Insight.Web enable enable @@ -29,8 +29,7 @@ - - + diff --git a/src/Web/Insight.Web/Pages/Account/ProfileTwoFactorDialog.razor b/src/Web/Insight.Web/Pages/Account/ProfileTwoFactorDialog.razor index 5aced2c..a4a26ae 100644 --- a/src/Web/Insight.Web/Pages/Account/ProfileTwoFactorDialog.razor +++ b/src/Web/Insight.Web/Pages/Account/ProfileTwoFactorDialog.razor @@ -9,17 +9,11 @@