| | | 1 | | @page "/dev/external-links" |
| | | 2 | | @using Chronicis.Shared.DTOs |
| | | 3 | | @inject IExternalLinkApiService ExternalLinks |
| | | 4 | | |
| | | 5 | | <MudContainer MaxWidth="MaxWidth.Medium" Class="mt-6"> |
| | | 6 | | <MudPaper Class="pa-6"> |
| | | 7 | | <MudText Typo="Typo.h4">External Links Dev</MudText> |
| | | 8 | | <MudText Typo="Typo.body2" Class="mb-4">Manual check for external link endpoints.</MudText> |
| | | 9 | | |
| | | 10 | | <MudTextField Label="Source" @bind-Value="_source" Immediate="true" /> |
| | | 11 | | <MudTextField Label="Query" @bind-Value="_query" Immediate="true" /> |
| | | 12 | | <MudButton Variant="Variant.Filled" Color="Color.Primary" Class="mt-2" OnClick="LoadSuggestionsAsync"> |
| | | 13 | | Fetch Suggestions |
| | | 14 | | </MudButton> |
| | | 15 | | |
| | | 16 | | <MudDivider Class="my-4" /> |
| | | 17 | | |
| | | 18 | | <MudText Typo="Typo.subtitle1">Suggestions</MudText> |
| | 0 | 19 | | @if (_isLoadingSuggestions) |
| | | 20 | | { |
| | | 21 | | <MudProgressLinear Indeterminate="true" Class="my-2" /> |
| | | 22 | | } |
| | 0 | 23 | | else if (_suggestions.Count == 0) |
| | | 24 | | { |
| | | 25 | | <MudText Typo="Typo.body2" Color="Color.Secondary">No suggestions loaded.</MudText> |
| | | 26 | | } |
| | | 27 | | else |
| | | 28 | | { |
| | | 29 | | <MudList T="ExternalLinkSuggestionDto" Dense="true"> |
| | 0 | 30 | | @foreach (var suggestion in _suggestions) |
| | | 31 | | { |
| | | 32 | | <MudListItem T="ExternalLinkSuggestionDto"> |
| | 0 | 33 | | <MudText Typo="Typo.body1">@suggestion.Title</MudText> |
| | 0 | 34 | | <MudText Typo="Typo.caption">@suggestion.Id</MudText> |
| | | 35 | | </MudListItem> |
| | | 36 | | } |
| | | 37 | | </MudList> |
| | | 38 | | } |
| | | 39 | | |
| | | 40 | | <MudDivider Class="my-4" /> |
| | | 41 | | |
| | | 42 | | <MudTextField Label="Content Id" @bind-Value="_contentId" Immediate="true" /> |
| | | 43 | | <MudButton Variant="Variant.Filled" Color="Color.Primary" Class="mt-2" OnClick="LoadContentAsync"> |
| | | 44 | | Fetch Content |
| | | 45 | | </MudButton> |
| | | 46 | | |
| | | 47 | | <MudDivider Class="my-4" /> |
| | | 48 | | |
| | | 49 | | <MudText Typo="Typo.subtitle1">Content</MudText> |
| | 0 | 50 | | @if (_isLoadingContent) |
| | | 51 | | { |
| | | 52 | | <MudProgressLinear Indeterminate="true" Class="my-2" /> |
| | | 53 | | } |
| | 0 | 54 | | else if (_content is null) |
| | | 55 | | { |
| | | 56 | | <MudText Typo="Typo.body2" Color="Color.Secondary">No content loaded.</MudText> |
| | | 57 | | } |
| | | 58 | | else |
| | | 59 | | { |
| | 0 | 60 | | <MudText Typo="Typo.h6">@_content.Title</MudText> |
| | 0 | 61 | | <MudText Typo="Typo.caption">@_content.Kind</MudText> |
| | 0 | 62 | | <MudText Typo="Typo.body2" Class="mt-2">@_content.Markdown</MudText> |
| | | 63 | | } |
| | | 64 | | </MudPaper> |
| | | 65 | | </MudContainer> |
| | | 66 | | |
| | | 67 | | @code { |
| | 0 | 68 | | private string _source = "srd"; |
| | 0 | 69 | | private string _query = "fireball"; |
| | 0 | 70 | | private string _contentId = "spells/srd_fireball"; |
| | | 71 | | private bool _isLoadingSuggestions; |
| | | 72 | | private bool _isLoadingContent; |
| | 0 | 73 | | private List<ExternalLinkSuggestionDto> _suggestions = new(); |
| | | 74 | | private ExternalLinkContentDto? _content; |
| | | 75 | | |
| | | 76 | | private async Task LoadSuggestionsAsync() |
| | | 77 | | { |
| | 0 | 78 | | _isLoadingSuggestions = true; |
| | 0 | 79 | | _suggestions = await ExternalLinks.GetSuggestionsAsync(null, _source, _query, CancellationToken.None); |
| | 0 | 80 | | _isLoadingSuggestions = false; |
| | 0 | 81 | | } |
| | | 82 | | |
| | | 83 | | private async Task LoadContentAsync() |
| | | 84 | | { |
| | 0 | 85 | | _isLoadingContent = true; |
| | 0 | 86 | | _content = await ExternalLinks.GetContentAsync(_source, _contentId, CancellationToken.None); |
| | 0 | 87 | | _isLoadingContent = false; |
| | 0 | 88 | | } |
| | | 89 | | } |