diff --git a/RobotApp.Client/Components/Mapping/MapView.razor b/RobotApp.Client/Components/Mapping/MapView.razor new file mode 100644 index 0000000..ba25d3c --- /dev/null +++ b/RobotApp.Client/Components/Mapping/MapView.razor @@ -0,0 +1,5 @@ +

MapView

+ +@code { + +} diff --git a/RobotApp.Client/Pages/MapsManager.razor b/RobotApp.Client/Pages/MapsManager.razor new file mode 100644 index 0000000..ebf6ea2 --- /dev/null +++ b/RobotApp.Client/Pages/MapsManager.razor @@ -0,0 +1,181 @@ +@page "/maps-manager" +@using MudBlazor +@using RobotApp.Common.Shares.Dtos + +@attribute [Authorize] +@inject HttpClient Http + +Map Manager + + + +
+
+
+ + + NEW + +
+
+ + + Nr + Name + Width (m) + Height (m) + Resolution (m/px) + OriginX + OriginY + + + + + @(Table?.CurrentPage * Table?.RowsPerPage + MapsShow.IndexOf(context) + 1) + + + @context.Name + + + @context.Width + + + @context.Height + + + @context.Resolution + + + @context.OriginX + + + @context.OriginY + + +
+ + Edit + Delete + +
+
+
+ +
+ +
+
+
+
+
+
+
+
+ +@code { + private string txtSearch = ""; + private bool IsLoading = false; + + private List Maps = []; + private List MapsShow = []; + + private int selectedRowNumber = -1; + private MapDto MapSelected = new(); + + private MudTable? Table; protected override async Task OnAfterRenderAsync(bool firstRender) + { + await base.OnAfterRenderAsync(firstRender); + if (!firstRender) return; + + await LoadMaps(); + } + + private async Task LoadMaps() + { + try + { + IsLoading = true; + Maps.Clear(); + StateHasChanged(); + + var maps = await Http.GetFromJsonAsync>($"api/MapsManager?txtSearch={txtSearch}"); + Maps.AddRange(maps ?? []); + + Table?.ReloadServerData(); + IsLoading = false; + StateHasChanged(); + } + catch + { + return; + } + } + + private void TextSearchChanged(string text) + { + txtSearch = text; + Table?.ReloadServerData(); + } + + private bool FilterFunc(MapDto map) + { + if (string.IsNullOrWhiteSpace(txtSearch)) + return true; + if (map.Name is not null && map.Name.Contains(txtSearch, StringComparison.OrdinalIgnoreCase)) + return true; + if ($"{map.Name}".Contains(txtSearch)) + return true; + return false; + } + + private Task> ReloadData(TableState state, CancellationToken _) + { + MapsShow.Clear(); + var tasks = new List(); + Maps.ForEach(map => + { + if (FilterFunc(map)) tasks.Add(map); + }); + MapsShow = tasks.Skip(state.Page * state.PageSize).Take(state.PageSize).ToList(); + return Task.FromResult(new TableData() { TotalItems = tasks.Count, Items = MapsShow }); + } + + private void RowClickEvent(TableRowClickEventArgs tableRowClickEventArgs) { } + + private string SelectedRowClassFunc(MapDto element, int rowNumber) + { + if (selectedRowNumber == rowNumber && Table?.SelectedItem != null && !Table.SelectedItem.Equals(element)) + { + return string.Empty; + } + else if (selectedRowNumber == rowNumber && Table?.SelectedItem != null && Table.SelectedItem.Equals(element)) + { + return "selected"; + } + else if (Table?.SelectedItem != null && Table.SelectedItem.Equals(element)) + { + selectedRowNumber = rowNumber; + MapSelected = element; + // NavigationMapPreviewRef.SetMapPreview(MapSelected); + return "selected"; + } + else + { + return string.Empty; + } + } +} diff --git a/RobotApp.Client/RobotApp.Client.csproj b/RobotApp.Client/RobotApp.Client.csproj index fff906b..92168bf 100644 --- a/RobotApp.Client/RobotApp.Client.csproj +++ b/RobotApp.Client/RobotApp.Client.csproj @@ -9,9 +9,13 @@ - - + + + + + + diff --git a/RobotApp.Client/_Imports.razor b/RobotApp.Client/_Imports.razor index f3b923f..53fa057 100644 --- a/RobotApp.Client/_Imports.razor +++ b/RobotApp.Client/_Imports.razor @@ -8,4 +8,5 @@ @using Microsoft.AspNetCore.Components.Web.Virtualization @using Microsoft.JSInterop @using RobotApp.Client +@using Microsoft.AspNetCore.Authorization @using MudBlazor diff --git a/RobotApp.Common.Shares/Dtos/MapDto.cs b/RobotApp.Common.Shares/Dtos/MapDto.cs new file mode 100644 index 0000000..0f61001 --- /dev/null +++ b/RobotApp.Common.Shares/Dtos/MapDto.cs @@ -0,0 +1,13 @@ +namespace RobotApp.Common.Shares.Dtos; + +public class MapDto +{ + public Guid Id { get; set; } + public string Name { get; set; } = string.Empty; + public string Description { get; set; } = string.Empty; + public double Width { get; set; } + public double Height { get; set; } + public double Resolution { get; set; } + public double OriginX { get; set; } + public double OriginY { get; set; } +} diff --git a/RobotApp.sln b/RobotApp.sln index c17bc5b..edd2672 100644 --- a/RobotApp.sln +++ b/RobotApp.sln @@ -1,7 +1,7 @@  Microsoft Visual Studio Solution File, Format Version 12.00 -# Visual Studio Version 17 -VisualStudioVersion = 17.12.35707.178 +# Visual Studio Version 18 +VisualStudioVersion = 18.0.11018.127 d18.0 MinimumVisualStudioVersion = 10.0.40219.1 Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "RobotApp", "RobotApp\RobotApp.csproj", "{BF0BB137-2EF9-4E1B-944E-9BF41C5284F7}" EndProject @@ -37,4 +37,7 @@ Global GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + SolutionGuid = {CCB0B2E5-3C19-4B2E-B229-08A74F6EF27D} + EndGlobalSection EndGlobal