Initial commit

This commit is contained in:
2026-07-13 09:25:40 +07:00
parent c08ff54676
commit bccfb156d7
1938 changed files with 641646 additions and 0 deletions

View File

@@ -0,0 +1,243 @@
@using RobotNet10.RobotApp.Shared.DockStation
@using RobotNet10.Shared.Enum
@using RobotNet10.Shared.Numbers
<MudDialog>
<TitleContent>
<MudText Typo="Typo.h6">@(IsEditMode ? "Edit" : "Create") Dock Station Config</MudText>
</TitleContent>
<DialogContent>
<MudGrid Spacing="2">
<MudItem xs="6">
<MudTextField @bind-Value="_stationId" Label="Station ID" Variant="Variant.Outlined" Required />
</MudItem>
<MudItem xs="6">
<MudTextField @bind-Value="_configName" Label="Config Name" Variant="Variant.Outlined" />
</MudItem>
<MudItem xs="12">
<MudTextField @bind-Value="_description" Label="Description" Variant="Variant.Outlined" Lines="2" />
</MudItem>
</MudGrid>
<MudText Typo="Typo.subtitle2" Class="mt-4 mb-2">Search Area</MudText>
<MudGrid Spacing="2">
<MudItem xs="4">
<MudNumericField @bind-Value="_x" Label="X (m)" Variant="Variant.Outlined" Step="0.1" />
</MudItem>
<MudItem xs="4">
<MudNumericField @bind-Value="_y" Label="Y (m)" Variant="Variant.Outlined" Step="0.1" />
</MudItem>
<MudItem xs="4">
<MudNumericField @bind-Value="_yaw" Label="Yaw (rad)" Variant="Variant.Outlined" Step="0.1" />
</MudItem>
<MudItem xs="6">
<MudNumericField @bind-Value="_width" Label="Width (m)" Variant="Variant.Outlined" Step="0.1" />
</MudItem>
<MudItem xs="6">
<MudNumericField @bind-Value="_length" Label="Length (m)" Variant="Variant.Outlined" Step="0.1" />
</MudItem>
</MudGrid>
<MudItem xs="12" Class="mt-2">
<MudSwitch @bind-Value="_isActive" Label="Active" Color="Color.Success" />
</MudItem>
<MudStack Row AlignItems="AlignItems.Center" Class="mt-4 mb-2">
<MudText Typo="Typo.subtitle1">Marker Entries</MudText>
<MudSpacer />
<MudIconButton Icon="@Icons.Material.Filled.Add" Color="Color.Primary" OnClick="AddMarkerEntry" />
</MudStack>
@for (int i = 0; i < _entries.Count; i++)
{
var index = i;
<MudPaper Class="pa-3 mb-2" Outlined>
<MudStack Row AlignItems="AlignItems.Center">
<MudText Typo="Typo.subtitle2">Marker @(index + 1)</MudText>
<MudSpacer />
<MudIconButton Icon="@Icons.Material.Filled.Delete" Color="Color.Error" Size="Size.Small"
OnClick="() => RemoveMarkerEntry(index)" />
</MudStack>
<MudGrid Spacing="2" Class="mt-1">
<MudItem xs="6">
<MudTextField @bind-Value="_entries[index].MarkerId" Label="Marker ID" Variant="Variant.Outlined" />
</MudItem>
<MudItem xs="6">
<MudSelect @bind-Value="_entries[index].Type" Label="Type" Variant="Variant.Outlined">
@foreach (var type in System.Enum.GetValues<MarkerType>())
{
<MudSelectItem Value="type">@type</MudSelectItem>
}
</MudSelect>
</MudItem>
<MudItem xs="4">
<MudNumericField @bind-Value="_entries[index].Priority" Label="Priority" Variant="Variant.Outlined" Min="1" />
</MudItem>
<MudItem xs="4">
<MudTextField @bind-Value="_entries[index].DeviceId" Label="Device ID" Variant="Variant.Outlined" />
</MudItem>
<MudItem xs="4">
<MudTextField @bind-Value="_entries[index].Code" Label="Code" Variant="Variant.Outlined" />
</MudItem>
</MudGrid>
<MudStack Row AlignItems="AlignItems.Center" Class="mt-2">
<MudText Typo="Typo.body2">Reference Points</MudText>
<MudSpacer />
<MudIconButton Icon="@Icons.Material.Filled.AddCircleOutline" Color="Color.Primary" Size="Size.Small"
OnClick="() => AddReferencePoint(index)" />
</MudStack>
@for (int j = 0; j < _entries[index].ReferencePoints.Count; j++)
{
var ptIndex = j;
<MudStack Row AlignItems="AlignItems.Center" Spacing="2" Class="mt-1">
<MudNumericField @bind-Value="_entries[index].ReferencePoints[ptIndex].X" Label="X" Variant="Variant.Outlined"
Step="0.01" Margin="Margin.Dense" />
<MudNumericField @bind-Value="_entries[index].ReferencePoints[ptIndex].Y" Label="Y" Variant="Variant.Outlined"
Step="0.01" Margin="Margin.Dense" />
<MudIconButton Icon="@Icons.Material.Filled.RemoveCircleOutline" Color="Color.Error" Size="Size.Small"
OnClick="() => RemoveReferencePoint(index, ptIndex)" />
</MudStack>
}
</MudPaper>
}
</DialogContent>
<DialogActions>
<MudButton OnClick="Cancel">Cancel</MudButton>
<MudButton Color="Color.Primary" Variant="Variant.Filled" OnClick="Submit"
Disabled="string.IsNullOrWhiteSpace(_stationId)">
@(IsEditMode ? "Update" : "Create")
</MudButton>
</DialogActions>
</MudDialog>
@code {
[CascadingParameter] IMudDialogInstance Dialog { get; set; } = null!;
[Parameter] public DockStationConfigDto? Config { get; set; }
private bool IsEditMode => Config is not null;
private string _stationId = string.Empty;
private string _configName = string.Empty;
private string _description = string.Empty;
private double _x;
private double _y;
private double _yaw;
private double _width;
private double _length;
private bool _isActive = true;
private readonly List<MarkerEntryModel> _entries = [];
protected override void OnInitialized()
{
if (Config is not null)
{
_stationId = Config.StationId;
_configName = Config.ConfigName ?? string.Empty;
_description = Config.Description ?? string.Empty;
_x = Config.X;
_y = Config.Y;
_yaw = Config.Yaw;
_width = Config.Width;
_length = Config.Length;
_isActive = Config.IsActive;
_entries.AddRange(Config.MarkerEntries.Select(e => new MarkerEntryModel
{
MarkerId = e.MarkerId,
Type = e.Type,
Priority = e.Priority,
DeviceId = e.DeviceId,
Code = e.Code,
ReferencePoints = e.ReferencePoints.Select(p => new Vector2Model { X = p.X, Y = p.Y }).ToList()
}));
}
}
private void AddMarkerEntry()
{
_entries.Add(new MarkerEntryModel { Priority = _entries.Count + 1 });
}
private void RemoveMarkerEntry(int index) => _entries.RemoveAt(index);
private void AddReferencePoint(int entryIndex)
{
_entries[entryIndex].ReferencePoints.Add(new Vector2Model());
}
private void RemoveReferencePoint(int entryIndex, int ptIndex)
{
_entries[entryIndex].ReferencePoints.RemoveAt(ptIndex);
}
private List<DockStationMarkerEntryDto> BuildMarkerEntries() =>
_entries.Select(e => new DockStationMarkerEntryDto
{
MarkerId = e.MarkerId ?? string.Empty,
Type = e.Type,
Priority = e.Priority,
DeviceId = e.DeviceId,
Code = e.Code,
ReferencePoints = e.ReferencePoints.Select(p => new Vector2 { X = p.X, Y = p.Y }).ToList()
}).ToList();
private void Submit()
{
if (IsEditMode)
{
var request = new UpdateDockStationConfigRequest
{
StationId = _stationId,
ConfigName = _configName,
Description = _description,
X = _x,
Y = _y,
Yaw = _yaw,
Width = _width,
Length = _length,
IsActive = _isActive,
MarkerEntries = BuildMarkerEntries()
};
Dialog.Close(DialogResult.Ok(request));
}
else
{
var request = new CreateDockStationConfigRequest
{
StationId = _stationId,
ConfigName = _configName,
Description = _description,
X = _x,
Y = _y,
Yaw = _yaw,
Width = _width,
Length = _length,
IsActive = _isActive,
MarkerEntries = BuildMarkerEntries()
};
Dialog.Close(DialogResult.Ok(request));
}
}
private void Cancel() => Dialog.Cancel();
private class MarkerEntryModel
{
public string? MarkerId { get; set; }
public MarkerType Type { get; set; }
public int Priority { get; set; } = 1;
public string? DeviceId { get; set; }
public string? Code { get; set; }
public List<Vector2Model> ReferencePoints { get; set; } = [];
}
private class Vector2Model
{
public double X { get; set; }
public double Y { get; set; }
}
}