feat: move test buttons to right panel, add user auth dialog for reports
Move Start/Stop/Report buttons from the middle panel to the top of TestPanelView (automated tests section), matching the old application layout. Remove inline Operator/Client text fields — operator identity now comes from a UserCheckDialog (username/password) shown before the existing ReportDialog. Add credential storage to ConfigurationService. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -9,6 +9,8 @@ using CommunityToolkit.Mvvm.ComponentModel;
|
||||
using CommunityToolkit.Mvvm.Input;
|
||||
using HC_APTBS.Models;
|
||||
using HC_APTBS.Services;
|
||||
using HC_APTBS.ViewModels.Dialogs;
|
||||
using HC_APTBS.Views.Dialogs;
|
||||
|
||||
namespace HC_APTBS.ViewModels
|
||||
{
|
||||
@@ -43,6 +45,9 @@ namespace HC_APTBS.ViewModels
|
||||
|
||||
private CancellationTokenSource? _testCts;
|
||||
|
||||
/// <summary>Remembers the last authenticated username to pre-fill the next auth dialog.</summary>
|
||||
private string _lastAuthenticatedUser = string.Empty;
|
||||
|
||||
// ── Child ViewModels ──────────────────────────────────────────────────────
|
||||
|
||||
/// <summary>ViewModel for pump selection and K-Line ECU identification.</summary>
|
||||
@@ -331,14 +336,6 @@ namespace HC_APTBS.ViewModels
|
||||
/// <summary>Verbose status message from bench/test operations.</summary>
|
||||
[ObservableProperty] private string _verboseStatus = string.Empty;
|
||||
|
||||
// ── Operator / client info ────────────────────────────────────────────────
|
||||
|
||||
/// <summary>Operator name for report generation.</summary>
|
||||
[ObservableProperty] private string _operatorName = string.Empty;
|
||||
|
||||
/// <summary>Client name for report generation.</summary>
|
||||
[ObservableProperty] private string _clientName = string.Empty;
|
||||
|
||||
// ── Test saved state ──────────────────────────────────────────────────────
|
||||
|
||||
/// <summary>True when the current test results have been saved to a report.</summary>
|
||||
@@ -407,14 +404,28 @@ namespace HC_APTBS.ViewModels
|
||||
private void GenerateReport()
|
||||
{
|
||||
if (CurrentPump == null) return;
|
||||
|
||||
// Step 1: Authenticate operator.
|
||||
var authVm = new UserCheckViewModel(_config, _lastAuthenticatedUser);
|
||||
var authDlg = new UserCheckDialog(authVm) { Owner = Application.Current.MainWindow };
|
||||
authDlg.ShowDialog();
|
||||
if (!authVm.Accepted) return;
|
||||
_lastAuthenticatedUser = authVm.AuthenticatedUser;
|
||||
|
||||
// Step 2: Collect report details (client, company, observations).
|
||||
var reportVm = new ReportViewModel(_config) { OperatorName = authVm.AuthenticatedUser };
|
||||
var reportDlg = new ReportDialog(reportVm) { Owner = Application.Current.MainWindow };
|
||||
reportDlg.ShowDialog();
|
||||
if (!reportVm.Accepted) return;
|
||||
|
||||
try
|
||||
{
|
||||
string desktop = Environment.GetFolderPath(Environment.SpecialFolder.Desktop);
|
||||
string path = _pdf.GenerateReport(CurrentPump, OperatorName, ClientName, desktop);
|
||||
string path = _pdf.GenerateReport(
|
||||
CurrentPump, reportVm.OperatorName, reportVm.SelectedClientName, desktop);
|
||||
_log.Info(LogId, $"Report saved: {path}");
|
||||
IsTestSaved = true;
|
||||
|
||||
// Open the generated PDF with the default viewer.
|
||||
System.Diagnostics.Process.Start(new System.Diagnostics.ProcessStartInfo(path)
|
||||
{ UseShellExecute = true });
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user