< Summary

Information
Class: Chronicis.Client.Pages.ExternalLinksDev
Assembly: Chronicis.Client
File(s): /home/runner/work/chronicis/chronicis/src/Chronicis.Client/Pages/ExternalLinksDev.razor
Line coverage
0%
Covered lines: 0
Uncovered lines: 22
Coverable lines: 22
Total lines: 89
Line coverage: 0%
Branch coverage
0%
Covered branches: 0
Total branches: 10
Branch coverage: 0%
Method coverage

Feature is only available for sponsors

Upgrade to PRO version

Metrics

MethodBranch coverage Crap Score Cyclomatic complexity Line coverage
.ctor()100%210%
LoadSuggestionsAsync()100%210%
LoadContentAsync()100%210%

File(s)

/home/runner/work/chronicis/chronicis/src/Chronicis.Client/Pages/ExternalLinksDev.razor

#LineLine coverage
 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>
 019        @if (_isLoadingSuggestions)
 20        {
 21            <MudProgressLinear Indeterminate="true" Class="my-2" />
 22        }
 023        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">
 030                @foreach (var suggestion in _suggestions)
 31                {
 32                    <MudListItem T="ExternalLinkSuggestionDto">
 033                        <MudText Typo="Typo.body1">@suggestion.Title</MudText>
 034                        <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>
 050        @if (_isLoadingContent)
 51        {
 52            <MudProgressLinear Indeterminate="true" Class="my-2" />
 53        }
 054        else if (_content is null)
 55        {
 56            <MudText Typo="Typo.body2" Color="Color.Secondary">No content loaded.</MudText>
 57        }
 58        else
 59        {
 060            <MudText Typo="Typo.h6">@_content.Title</MudText>
 061            <MudText Typo="Typo.caption">@_content.Kind</MudText>
 062            <MudText Typo="Typo.body2" Class="mt-2">@_content.Markdown</MudText>
 63        }
 64    </MudPaper>
 65</MudContainer>
 66
 67@code {
 068    private string _source = "srd";
 069    private string _query = "fireball";
 070    private string _contentId = "spells/srd_fireball";
 71    private bool _isLoadingSuggestions;
 72    private bool _isLoadingContent;
 073    private List<ExternalLinkSuggestionDto> _suggestions = new();
 74    private ExternalLinkContentDto? _content;
 75
 76    private async Task LoadSuggestionsAsync()
 77    {
 078        _isLoadingSuggestions = true;
 079        _suggestions = await ExternalLinks.GetSuggestionsAsync(null, _source, _query, CancellationToken.None);
 080        _isLoadingSuggestions = false;
 081    }
 82
 83    private async Task LoadContentAsync()
 84    {
 085        _isLoadingContent = true;
 086        _content = await ExternalLinks.GetContentAsync(_source, _contentId, CancellationToken.None);
 087        _isLoadingContent = false;
 088    }
 89}