Enhance event occurrence parsing with detailed issue reporting and location configuration

This commit introduces a new structure for handling parsing issues in the EventOccurrenceParser, allowing for detailed reporting of parsing problems such as unmatched lines, missing event definitions, and parsing failures for time, date, and location. A new ParsingIssue class has been added to encapsulate these details. Additionally, a LocationParsingConfiguration class has been implemented to support customizable location patterns, enhancing the flexibility of the parser. The EventOccurrenceParserService has been updated to utilize this configuration, and new tests have been added to ensure robust issue detection and reporting. Furthermore, the UI has been updated to display parsing issues, improving user feedback during the import process.
This commit is contained in:
2026-01-06 23:08:42 -05:00
parent c73fdbfba4
commit 2d3b29176f
12 changed files with 1189 additions and 40 deletions
@@ -10,6 +10,7 @@
@inject AppDbContext Context
@inject NavigationManager NavigationManager
@inject ISnackbar Snackbar
@inject IDialogService DialogService
<PageHeader
Title="Import Event Occurrences"
@@ -20,7 +21,17 @@
<MudGrid>
<MudItem xs="12" md="6">
<MudPaper Elevation="2" Class="pa-3 pa-md-6">
<MudText Typo="Typo.h5" Class="mb-4">Paste Event Occurrence Data</MudText>
<MudStack Row="true" AlignItems="AlignItems.Center" Justify="Justify.SpaceBetween" Class="mb-4">
<MudText Typo="Typo.h5">Paste Event Occurrence Data</MudText>
<MudButton
Variant="Variant.Text"
Color="Color.Secondary"
Size="Size.Small"
StartIcon="@Icons.Material.Filled.Settings"
OnClick="OpenLocationSettings">
Location Settings
</MudButton>
</MudStack>
<MudStack Spacing="3">
<MudTextField
T="string"
@@ -28,7 +39,7 @@
@bind-Value="_inputText"
Variant="Variant.Outlined"
Lines="15"
MultiLine="true"
multiline="true"
Placeholder="Paste event occurrence text here..."
HelperText="Paste the event schedule text in the format expected by the parser" />
@@ -86,6 +97,37 @@
}
}
@* Detailed Parsing Issues *@
@if (_parseResult.Issues.Any())
{
<MudExpansionPanels Elevation="0" Class="mt-2">
<MudExpansionPanel Text="@($"Parsing Issues ({_parseResult.Issues.Count} found on {_parseResult.Issues.Select(i => i.LineNumber).Distinct().Count()} line(s))")"
Icon="@Icons.Material.Filled.Warning"
iconcolor="Color.Warning">
<MudTable Items="@_parseResult.Issues" Dense="true" Hover="true" Striped="true" sortmode="SortMode.Multiple">
<HeaderContent>
<MudTh>Line</MudTh>
<MudTh>Type</MudTh>
<MudTh>Content</MudTh>
<MudTh>Message</MudTh>
</HeaderContent>
<RowTemplate>
<MudTd DataLabel="Line">@context.LineNumber</MudTd>
<MudTd DataLabel="Type">
<MudChip T="string" Size="Size.Small" Color="@GetIssueTypeColor(context.IssueType)">
@context.IssueType
</MudChip>
</MudTd>
<MudTd DataLabel="Content">
<code style="font-size: 0.85em; max-width: 200px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; display: block;" title="@context.LineContent">@context.LineContent</code>
</MudTd>
<MudTd DataLabel="Message">@context.Message</MudTd>
</RowTemplate>
</MudTable>
</MudExpansionPanel>
</MudExpansionPanels>
}
@* Summary *@
@if (_parseResult.IsSuccess && _parseResult.TotalParsed > 0)
{
@@ -249,5 +291,24 @@
return "Social Gathering";
return eventDefinition.Name;
}
private Color GetIssueTypeColor(ParsingIssueType issueType)
{
return issueType switch
{
ParsingIssueType.UnmatchedLine => Color.Info,
ParsingIssueType.MissingEventDefinition => Color.Warning,
ParsingIssueType.TimeParseFailure => Color.Error,
ParsingIssueType.DateParseFailure => Color.Error,
ParsingIssueType.LocationParseFailure => Color.Warning,
ParsingIssueType.InvalidFormat => Color.Error,
_ => Color.Default
};
}
private void OpenLocationSettings()
{
NavigationManager.NavigateTo("/calendar/event-occurrences/import/settings");
}
}