Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 9 additions & 9 deletions Client/wwwroot/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,10 @@
<link href="https://fonts.googleapis.com/css2?family=IBM+Plex+Mono:wght@400;500&family=IBM+Plex+Sans:wght@400;500;600&display=swap" rel="stylesheet" />
<!-- These files have no fingerprint in their names and the CDN in front of the site caches them for an hour,
so each link carries ?v=<release>. Bump it every release, here and in the scripts below. -->
<link href="_content/MudBlazor/MudBlazor.min.css?v=0.9.2505" rel="stylesheet" />
<link href="_content/UdapEd.Shared/css/app.css?v=0.9.2505" rel="stylesheet" />
<link href="_content/UdapEd.Shared/css/cds.css?v=0.9.2505" rel="stylesheet" />
<link href="css/monaco.css?v=0.9.2505" rel="stylesheet" />
<link href="_content/MudBlazor/MudBlazor.min.css?v=0.9.2506" rel="stylesheet" />
<link href="_content/UdapEd.Shared/css/app.css?v=0.9.2506" rel="stylesheet" />
<link href="_content/UdapEd.Shared/css/cds.css?v=0.9.2506" rel="stylesheet" />
<link href="css/monaco.css?v=0.9.2506" rel="stylesheet" />
<!-- <link href="UdapEd.Client.styles.css" rel="stylesheet" /> -->
</head>

Expand All @@ -44,12 +44,12 @@
<a class="dismiss">🗙</a>
</div>
<script src="_framework/blazor.webassembly.js"></script>
<script src="_content/MudBlazor/MudBlazor.min.js?v=0.9.2505"></script>
<script src="_content/UdapEd.Shared/scripts/AutoFocus.js?v=0.9.2505"></script>
<script src="_content/UdapEd.Shared/scripts/UdapEdUtility.js?v=0.9.2505"></script>
<script src="_content/UdapEd.Shared/scripts/EventHandlers.js?v=0.9.2505"></script>
<script src="_content/MudBlazor/MudBlazor.min.js?v=0.9.2506"></script>
<script src="_content/UdapEd.Shared/scripts/AutoFocus.js?v=0.9.2506"></script>
<script src="_content/UdapEd.Shared/scripts/UdapEdUtility.js?v=0.9.2506"></script>
<script src="_content/UdapEd.Shared/scripts/EventHandlers.js?v=0.9.2506"></script>

<script src="_content/BlazorMonaco/jsInterop.js?v=0.9.2505"></script>
<script src="_content/BlazorMonaco/jsInterop.js?v=0.9.2506"></script>
<!-- The Monaco editor (about 1.4 MB) loads on first use: see udapEdMonaco.ensureLoaded in UdapEdUtility.js. -->

<!-- todo package in RCL -->
Expand Down
55 changes: 43 additions & 12 deletions Shared/Components/CommunityScenarioPanel.razor
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,18 @@

@*
The communities a server offers, as test scenarios: what each one does, the anchor it needs and the outcome
to expect. "Try" fills the Community field, loads the anchor and runs the query. With a pre-packaged anchor
loaded, only the communities that use it are listed; the rest are a click away. Laid out to fit the narrow
column under the Query button.
to expect. Each row's Query button fills the Community field, loads the anchor and runs the query; it stands in
for the page's own Query button while the list is shown. With a pre-packaged anchor loaded, only the communities
that use it are listed; the rest are a click away.
*@

@if (Scenarios.Count > 0)
{
var matching = CommunityScenarios.ForAnchor(Scenarios, AnchorName);
var shown = _showAll ? Scenarios : matching;
var hidden = Scenarios.Count - matching.Count;
<MudPaper Outlined="true" Class="pa-2 mt-3 udaped-scenarios" data-testid="community-scenarios">
@* mt-2 matches the anchor box (UdapAnchorCertificate Split), so the two boxes' tops line up on Discovery. *@
<MudPaper Outlined="true" Class="pa-2 mt-2 udaped-scenarios" data-testid="community-scenarios">
<MudStack Row="true" AlignItems="AlignItems.Center" Spacing="1">
<MudIconButton Icon="@(_expanded ? Icons.Material.Filled.ExpandLess : Icons.Material.Filled.ExpandMore)"
Size="Size.Small"
Expand All @@ -27,7 +28,7 @@
@if (_expanded)
{
<MudText Typo="Typo.caption" Class="mud-text-secondary d-block px-1">
Optional. Each one tests something; Try fills the Community field, loads its anchor and queries.
Each one tests something; Query fills the Community field, loads its anchor and queries.
</MudText>
@if (hidden > 0)
{
Expand All @@ -38,18 +39,21 @@
</MudButton>
}

@* After a Query the list folds to the queried row, so the results move up the page. *@
var selectedRows = shown.Where(IsSelected).ToList();
var compact = _compact && selectedRows.Count > 0;
<div class="udaped-scenario-list">
@foreach (var scenario in shown)
@foreach (var scenario in compact ? selectedRows : shown)
{
var selected = string.Equals(scenario.Community, Current ?? string.Empty, StringComparison.Ordinal);
var selected = IsSelected(scenario);
<div class="udaped-scenario @(selected ? "udaped-scenario-selected" : null)" data-community="@scenario.Community">
<MudButton Size="Size.Small"
Variant="@(selected ? Variant.Filled : Variant.Outlined)"
Color="Color.Primary"
Disabled="Busy"
StartIcon="@Icons.Material.Filled.PlayArrow"
OnClick="@(() => OnTry.InvokeAsync(scenario))"
data-testid="community-scenario-try">Try</MudButton>
OnClick="@(() => Query(scenario))"
data-testid="community-scenario-query">Query</MudButton>
<div class="udaped-scenario-body">
<div class="udaped-scenario-title">
<MudText Typo="Typo.body2"><b>@scenario.Title</b></MudText>
Expand All @@ -72,9 +76,17 @@
<MudText Typo="Typo.caption" Class="d-block">@scenario.Description</MudText>
@if (scenario.AnchorEntry is { } anchor)
{
@if (anchor.Name != AnchorName)
@if (anchor.Name == AnchorName)
{
<MudText Typo="Typo.caption" Class="d-block mud-text-secondary">Anchor: @anchor.Name</MudText>
<MudText Typo="Typo.caption" Color="Color.Success" Class="d-block" data-testid="community-scenario-anchor">
✓ @anchor.Name loaded
</MudText>
}
else
{
<MudText Typo="Typo.caption" Class="d-block mud-text-secondary" data-testid="community-scenario-anchor">
Query loads the @anchor.Name anchor
</MudText>
}
}
else if (scenario.AnchorHint != null)
Expand All @@ -85,6 +97,15 @@
</div>
}
</div>
@if (compact)
{
<MudButton Size="Size.Small" Variant="Variant.Text" Color="Color.Primary" Class="px-1"
StartIcon="@Icons.Material.Filled.UnfoldMore"
OnClick="@(() => _compact = false)"
data-testid="community-scenarios-unfold">
Show all @shown.Count communities
</MudButton>
}
}
</MudPaper>
}
Expand All @@ -102,12 +123,22 @@

[Parameter] public bool Busy { get; set; }

[Parameter] public EventCallback<CommunityScenario> OnTry { get; set; }
[Parameter] public EventCallback<CommunityScenario> OnQuery { get; set; }

private bool _expanded = true;
private bool _showAll;
private bool _compact;
private string? _anchorShown;

private bool IsSelected(CommunityScenario scenario) =>
string.Equals(scenario.Community, Current ?? string.Empty, StringComparison.Ordinal);

private async Task Query(CommunityScenario scenario)
{
_compact = true;
await OnQuery.InvokeAsync(scenario);
}

protected override void OnParametersSet()
{
// A different anchor narrows the list again.
Expand Down
115 changes: 83 additions & 32 deletions Shared/Components/UdapAnchorCertificate.razor
Original file line number Diff line number Diff line change
Expand Up @@ -2,46 +2,97 @@

<InputFile id="anchorFileInput" OnChange="UploadFilesAsync" hidden/>

<MudCard Class="pa-2 ma-2" Elevation="0">
<MudCardHeader>
<CardHeaderContent>
<MudText Align="Align.End">Choose Trust Anchor Certificate.</MudText>
</CardHeaderContent>
</MudCardHeader>
<MudCardActions>
<MudStack Row="true" Justify="Justify.FlexEnd" AlignItems="AlignItems.Center" Wrap="Wrap.Wrap" Style="width: 100%">
<MudFab HtmlTag="label"
Size="Size.Small"
Color="@AnchorLoadedColor"
StartIcon="@AppState.CertificateIcon"
Label="Upload"
title="Upload Anchor Certificate"
IconSize="Size.Small"
for="anchorFileInput"/>
@if (Split)
{
@*
Page layout (Discovery): a title and buttons like the page's own, then the certificate in an outlined box,
so this column mirrors the one beside it.
*@
<div data-testid="anchor-certificate">
<MudText Typo="Typo.h4">Trust Anchor</MudText>
<MudStack Row="true" Wrap="Wrap.Wrap" AlignItems="AlignItems.Center" Class="mt-3 udaped-column-actions">
<MudButton HtmlTag="label"
Variant="Variant.Filled"
Color="@AnchorLoadedColor"
StartIcon="@AppState.CertificateIcon"
title="Upload Anchor Certificate"
for="anchorFileInput">Upload</MudButton>
<MudMenu Label="Load Pre-packaged Anchor"
StartIcon="@AppState.CertificateIcon"
Color="@PrePackagedAnchorLoadedColor"
Size="Size.Small"
Variant="Variant.Filled">
@foreach (var anchor in _prePackagedAnchors)
{
<MudMenuItem OnClick="@(() => LoadPrePackagedAnchor(anchor))" title="@anchor.Description">@anchor.Name</MudMenuItem>
}
</MudMenu>
</MudStack>
</MudCardActions>
<MudCardContent>
@if (!string.IsNullOrEmpty(AppState.UdapAnchorCertificateInfo?.DistinguishedName) ||
!string.IsNullOrEmpty(AppState.UdapAnchorCertificateInfo?.Thumbprint))
{
<MudItem xs="12">
<MudText Typo="Typo.body2">@AppState.UdapAnchorCertificateInfo?.DistinguishedName</MudText>
</MudItem>
<MudPaper Outlined="true" Class="pa-2 mt-2">
@if (HasAnchor)
{
@AnchorDetails
}
else
{
<MudText Typo="Typo.body2" Class="mud-text-secondary">
No trust anchor loaded. Without one, metadata is shown but not validated.
</MudText>
}
</MudPaper>
</div>
}
else
{
<MudCard Class="pa-2 ma-2" Elevation="0">
<MudCardHeader>
<CardHeaderContent>
<MudText Align="Align.End">Choose Trust Anchor Certificate.</MudText>
</CardHeaderContent>
</MudCardHeader>
<MudCardActions>
<MudStack Row="true" Justify="Justify.FlexEnd" AlignItems="AlignItems.Center" Wrap="Wrap.Wrap" Style="width: 100%">
<MudFab HtmlTag="label"
Size="Size.Small"
Color="@AnchorLoadedColor"
StartIcon="@AppState.CertificateIcon"
Label="Upload"
title="Upload Anchor Certificate"
IconSize="Size.Small"
for="anchorFileInput"/>
<MudMenu Label="Load Pre-packaged Anchor"
StartIcon="@AppState.CertificateIcon"
Color="@PrePackagedAnchorLoadedColor"
Size="Size.Small"
Variant="Variant.Filled">
@foreach (var anchor in _prePackagedAnchors)
{
<MudMenuItem OnClick="@(() => LoadPrePackagedAnchor(anchor))" title="@anchor.Description">@anchor.Name</MudMenuItem>
}
</MudMenu>
</MudStack>
</MudCardActions>
<MudCardContent>
@if (HasAnchor)
{
@AnchorDetails
}
</MudCardContent>
</MudCard>
}

<MudItem xs="12">
<MudText Typo="Typo.caption"> Thumbprint (sha1) </MudText>
<MudText Typo="Typo.body2">@AppState.UdapAnchorCertificateInfo?.Thumbprint </MudText>
</MudItem>
}
</MudCardContent>
</MudCard>
@code {
/// <summary>
/// Lay out as a page column (title, buttons, then the certificate in an outlined box) instead of a card.
/// </summary>
[Parameter] public bool Split { get; set; }

private bool HasAnchor =>
!string.IsNullOrEmpty(AppState.UdapAnchorCertificateInfo?.DistinguishedName) ||
!string.IsNullOrEmpty(AppState.UdapAnchorCertificateInfo?.Thumbprint);

private RenderFragment AnchorDetails => @<text>
<MudText Typo="Typo.body2">@AppState.UdapAnchorCertificateInfo?.DistinguishedName</MudText>
<MudText Typo="Typo.caption" Class="d-block mt-1">Thumbprint (sha1)</MudText>
<MudText Typo="Typo.body2">@AppState.UdapAnchorCertificateInfo?.Thumbprint</MudText>
</text>;
}
19 changes: 16 additions & 3 deletions Shared/Conformance/ConformancePanel.razor
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,15 @@
{
<MudStack Row="true" AlignItems="AlignItems.Center" Justify="Justify.SpaceBetween" Class="mb-2">
<MudStack Row="true" Spacing="1" AlignItems="AlignItems.Center">
<MudChip T="string" Size="Size.Small" Color="Color.Success" Variant="Variant.Text" Icon="@Icons.Material.Filled.CheckCircle">@Count(CheckOutcome.Pass) met</MudChip>
<MudChip T="string" Size="Size.Small" Color="Color.Error" Variant="Variant.Text" Icon="@Icons.Material.Filled.Cancel">@Count(CheckOutcome.Fail) not met</MudChip>
<MudChip T="string" Size="Size.Small" Color="Color.Warning" Variant="Variant.Text" Icon="@Icons.Material.Filled.Warning">@Count(CheckOutcome.Warning) to review</MudChip>
@* A count of zero is greyed: red or amber only when there is something to look at. *@
@foreach (var (outcome, label) in Summary)
{
var count = Count(outcome);
<MudChip T="string" Size="Size.Small" Variant="Variant.Text"
Color="@(count == 0 ? Color.Default : OutcomeColor(outcome))"
Class="@(count == 0 ? "udaped-chip-none" : null)"
Icon="@Icon(outcome)">@count @label</MudChip>
}
</MudStack>
<MudSwitch T="bool" @bind-Value="_onlyProblems" Label="Only problems" Color="Color.Primary" Size="Size.Small" />
</MudStack>
Expand Down Expand Up @@ -50,6 +56,13 @@

private bool _onlyProblems;

private static readonly (CheckOutcome Outcome, string Label)[] Summary =
[
(CheckOutcome.Pass, "met"),
(CheckOutcome.Fail, "not met"),
(CheckOutcome.Warning, "to review")
];

private IEnumerable<ConformanceCheck> Visible => _onlyProblems
? Checks!.Where(c => c.Outcome is CheckOutcome.Fail or CheckOutcome.Warning)
: Checks!;
Expand Down
Loading
Loading