Files
HC_APTBS/Views/Pages/DashboardPage.xaml
LucianoDev 0280a2fad1 feat: page-based navigation shell + Tests page wizard
Replace the monolithic MainWindow with a SelectedPage-driven shell
(Dashboard / Pump / Bench / Tests / Results / Settings). The Tests
page gets the Plan -> Preconditions -> Running -> Done wizard from
ui-structure.md \u00a74, backed by a 7-item precondition gate and
shared sub-views (PhaseCardView / TestSectionView / GraphicIndicatorView)
extracted from the now-deleted monolithic TestPanelView.

New VMs / views:
- Tests wizard: TestPreconditions, PhaseCard, GraphicIndicator,
  TestSection, TestPlan, TestRunning, TestDone
- Dashboard panels: DashboardConnection, DashboardReadings,
  DashboardAlarms, InterlockBanner, ResultHistory
- Pump / bench panels: PumpIdentificationPanel, PumpLiveData,
  UnlockPanel, BenchDriveControl, BenchReadings, RelayBank,
  TemperatureControl, DtcList, AuthGate
- Dialogs: generic ConfirmDialog, UserManageDialog, UserPromptDialog

Supporting changes:
- IsOilPumpOn exposed on MainViewModel for precondition evaluation
- RequiresAuth added to TestDefinition (XML round-trip)
- BipStatusDefinition + CompletedTestRun models
- ~35 new Test.* localization keys (en + es)
- Settings moved from modal dialog to full page
- Pause / Retry / Skip stubs in TestRunningView; full spec in
  docs/gap-test-running-controls.md for follow-up implementation
- docs/ui-structure.md captures the wizard design

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-04-18 13:11:34 +02:00

242 lines
14 KiB
XML

<UserControl x:Class="HC_APTBS.Views.Pages.DashboardPage"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:uc="clr-namespace:HC_APTBS.Views.UserControls"
mc:Ignorable="d"
d:DesignHeight="700" d:DesignWidth="980">
<!--
Dashboard — operator "at a glance" landing page.
DataContext: DashboardPageViewModel. Read-first. Only Start / Stop / E-Stop are interactive.
-->
<UserControl.Resources>
<BooleanToVisibilityConverter x:Key="BoolToVis"/>
<!-- Section card style -->
<Style x:Key="DashCard" TargetType="Border">
<Setter Property="Background" Value="#FAFAFA"/>
<Setter Property="BorderBrush" Value="#DDD"/>
<Setter Property="BorderThickness" Value="1"/>
<Setter Property="CornerRadius" Value="4"/>
<Setter Property="Padding" Value="10"/>
<Setter Property="Margin" Value="4"/>
</Style>
<Style x:Key="DashHeader" TargetType="TextBlock">
<Setter Property="FontSize" Value="13"/>
<Setter Property="FontWeight" Value="SemiBold"/>
<Setter Property="Foreground" Value="#333"/>
<Setter Property="Margin" Value="0,0,0,6"/>
</Style>
</UserControl.Resources>
<Grid Margin="6">
<Grid.RowDefinitions>
<RowDefinition Height="*"/>
<RowDefinition Height="Auto"/> <!-- footer: quick actions -->
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="340"/>
<ColumnDefinition Width="*"/>
</Grid.ColumnDefinitions>
<!-- ── Left column: readings ───────────────────────────────────────── -->
<Border Grid.Row="0" Grid.Column="0" Style="{StaticResource DashCard}">
<StackPanel>
<TextBlock Text="{DynamicResource Dashboard.Readings}" Style="{StaticResource DashHeader}"/>
<uc:DashboardReadingsView/>
</StackPanel>
</Border>
<!-- ── Right column: connections + test summary + alarms ───────────── -->
<Grid Grid.Row="0" Grid.Column="1">
<Grid.RowDefinitions>
<RowDefinition Height="Auto"/>
<RowDefinition Height="*"/>
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*"/>
<ColumnDefinition Width="*"/>
</Grid.ColumnDefinitions>
<!-- Connections -->
<Border Grid.Row="0" Grid.Column="0" Style="{StaticResource DashCard}">
<uc:DashboardConnectionView/>
</Border>
<!-- Test summary -->
<Border Grid.Row="0" Grid.Column="1" Style="{StaticResource DashCard}">
<StackPanel>
<TextBlock Text="{DynamicResource Dashboard.TestSummary}" Style="{StaticResource DashHeader}"/>
<!-- Active test view (when running) -->
<StackPanel Visibility="{Binding Root.IsTestRunning, Converter={StaticResource BoolToVis}}">
<Grid Margin="0,2">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="80"/>
<ColumnDefinition Width="*"/>
</Grid.ColumnDefinitions>
<TextBlock Text="{DynamicResource Dashboard.TestActive}" Foreground="#555" FontSize="12"/>
<TextBlock Grid.Column="1" Text="{Binding Root.TestPanel.TestName}"
FontWeight="SemiBold" FontSize="13" TextTrimming="CharacterEllipsis"/>
</Grid>
<Grid Margin="0,2">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="80"/>
<ColumnDefinition Width="*"/>
</Grid.ColumnDefinitions>
<TextBlock Text="{DynamicResource Dashboard.TestPhase}" Foreground="#555" FontSize="12"/>
<TextBlock Grid.Column="1" Text="{Binding Root.CurrentPhaseName}"
FontFamily="Consolas" FontSize="13" TextTrimming="CharacterEllipsis"/>
</Grid>
<TextBlock Text="{Binding Root.VerboseStatus}" FontStyle="Italic"
Foreground="#666" FontSize="11" Margin="0,6,0,0"
TextWrapping="Wrap"/>
</StackPanel>
<!-- Idle view (last result or "no test run") -->
<StackPanel>
<StackPanel.Style>
<Style TargetType="StackPanel">
<Setter Property="Visibility" Value="Visible"/>
<Style.Triggers>
<DataTrigger Binding="{Binding Root.IsTestRunning}" Value="True">
<Setter Property="Visibility" Value="Collapsed"/>
</DataTrigger>
</Style.Triggers>
</Style>
</StackPanel.Style>
<TextBlock Text="{DynamicResource Dashboard.NoTestRunning}"
Foreground="#888" FontStyle="Italic" FontSize="12"/>
<Border Margin="0,8,0,0" Padding="8,4" CornerRadius="3"
HorizontalAlignment="Left">
<Border.Style>
<Style TargetType="Border">
<Setter Property="Background" Value="#D62828"/>
<Setter Property="Visibility" Value="Collapsed"/>
<Style.Triggers>
<MultiDataTrigger>
<MultiDataTrigger.Conditions>
<Condition Binding="{Binding Root.IsTestSaved}" Value="False"/>
</MultiDataTrigger.Conditions>
<Setter Property="Visibility" Value="Visible"/>
</MultiDataTrigger>
<DataTrigger Binding="{Binding Root.LastTestSuccess}" Value="True">
<Setter Property="Background" Value="#26C200"/>
</DataTrigger>
</Style.Triggers>
</Style>
</Border.Style>
<TextBlock Foreground="White" FontWeight="Bold" FontSize="12">
<TextBlock.Style>
<Style TargetType="TextBlock">
<Setter Property="Text" Value="{DynamicResource Dashboard.LastTestFail}"/>
<Style.Triggers>
<DataTrigger Binding="{Binding Root.LastTestSuccess}" Value="True">
<Setter Property="Text" Value="{DynamicResource Dashboard.LastTestPass}"/>
</DataTrigger>
</Style.Triggers>
</Style>
</TextBlock.Style>
</TextBlock>
</Border>
</StackPanel>
</StackPanel>
</Border>
<!-- Alarms (spans both columns of the right grid) -->
<Border Grid.Row="1" Grid.Column="0" Grid.ColumnSpan="2" Style="{StaticResource DashCard}">
<DockPanel>
<TextBlock DockPanel.Dock="Top" Text="{DynamicResource Dashboard.Alarms}"
Style="{StaticResource DashHeader}"/>
<!-- "System OK" banner when no alarms -->
<Border Background="#26C200" CornerRadius="3" Padding="10,6"
HorizontalAlignment="Left" VerticalAlignment="Top"
Visibility="{Binding Alarms.IsClear, Converter={StaticResource BoolToVis}}">
<TextBlock Text="{DynamicResource Dashboard.AlarmsNone}"
Foreground="White" FontWeight="Bold" FontSize="12"/>
</Border>
<!-- Active alarm list -->
<ItemsControl ItemsSource="{Binding Alarms.ActiveAlarms}">
<ItemsControl.Style>
<Style TargetType="ItemsControl">
<Setter Property="Visibility" Value="Visible"/>
<Style.Triggers>
<DataTrigger Binding="{Binding Alarms.IsClear}" Value="True">
<Setter Property="Visibility" Value="Collapsed"/>
</DataTrigger>
</Style.Triggers>
</Style>
</ItemsControl.Style>
<ItemsControl.ItemTemplate>
<DataTemplate>
<Border Margin="0,2" Padding="8,4" CornerRadius="3">
<Border.Style>
<Style TargetType="Border">
<Setter Property="Background" Value="#FFB020"/> <!-- warning -->
<Style.Triggers>
<DataTrigger Binding="{Binding IsCritical}" Value="True">
<Setter Property="Background" Value="#D62828"/> <!-- critical -->
</DataTrigger>
</Style.Triggers>
</Style>
</Border.Style>
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="Auto"/>
<ColumnDefinition Width="*"/>
<ColumnDefinition Width="Auto"/>
</Grid.ColumnDefinitions>
<TextBlock Text="●" Foreground="White" FontSize="14" VerticalAlignment="Center" Margin="0,0,6,0"/>
<TextBlock Grid.Column="1" Text="{Binding Description}"
Foreground="White" FontWeight="SemiBold" FontSize="12"
VerticalAlignment="Center" TextWrapping="Wrap"/>
<TextBlock Grid.Column="2" Foreground="#FFF" FontSize="11" FontFamily="Consolas"
VerticalAlignment="Center" Margin="6,0,0,0">
<Run Text="bit "/><Run Text="{Binding Bit, Mode=OneWay}"/>
</TextBlock>
</Grid>
</Border>
</DataTemplate>
</ItemsControl.ItemTemplate>
</ItemsControl>
</DockPanel>
</Border>
</Grid>
<!-- ── Footer: quick actions ───────────────────────────────────────── -->
<Border Grid.Row="1" Grid.Column="0" Grid.ColumnSpan="2"
Background="#F0F0F0" BorderBrush="#CCC" BorderThickness="0,1,0,0"
Padding="8" Margin="4,4,4,4">
<DockPanel LastChildFill="False">
<Button DockPanel.Dock="Left"
Content="{DynamicResource Dashboard.Action.StartTest}"
Command="{Binding Root.StartTestCommand}"
Height="44" MinWidth="140" FontSize="13" FontWeight="Bold"
Foreground="DarkGreen" Margin="0,0,6,0"
ToolTipService.ShowOnDisabled="True"
ToolTip="{DynamicResource Dashboard.Action.StartTest.Tip}"/>
<Button DockPanel.Dock="Left"
Content="{DynamicResource Dashboard.Action.Stop}"
Command="{Binding Root.StopTestCommand}"
Height="44" MinWidth="120" FontSize="13" FontWeight="Bold"
Foreground="DarkRed" Margin="0,0,6,0"/>
<!-- E-Stop pinned right, red, always visible -->
<Button DockPanel.Dock="Right"
Content="{DynamicResource Dashboard.Action.EmergencyStop}"
Command="{Binding Root.EmergencyStopCommand}"
Height="44" MinWidth="200" FontSize="14" FontWeight="Bold"
Foreground="White" Background="#D62828" BorderBrush="#8B0000"
BorderThickness="2"/>
</DockPanel>
</Border>
</Grid>
</UserControl>