diff --git a/src/PSLauncher.App/ViewModels/MainViewModel.cs b/src/PSLauncher.App/ViewModels/MainViewModel.cs index 5582cf2..425fbb6 100644 --- a/src/PSLauncher.App/ViewModels/MainViewModel.cs +++ b/src/PSLauncher.App/ViewModels/MainViewModel.cs @@ -69,15 +69,68 @@ public sealed partial class MainViewModel : ObservableObject { get { - if (_license is null) return "License : non configurée"; + if (_license is null) return "Aucune license"; if (_license.Status == "valid") - return $"License : {_license.OwnerName} • exp. {_license.DownloadEntitlementUntil:dd/MM/yyyy}"; + { + var until = _license.DownloadEntitlementUntil; + if (until is { } u && (u - DateTime.UtcNow).TotalDays < 30) + return $"{_license.OwnerName} • exp. {u:dd/MM/yyyy}"; + return $"{_license.OwnerName} • exp. {until:dd/MM/yyyy}"; + } if (_license.Status == "expired") - return $"License expirée le {_license.DownloadEntitlementUntil:dd/MM/yyyy}"; - return $"License : {_license.Status}"; + return $"Expirée le {_license.DownloadEntitlementUntil:dd/MM/yyyy}"; + if (_license.Status == "revoked") + return "Révoquée"; + return _license.Status; } } + public string LicenseIcon + { + get + { + if (_license is null) return "🔒"; + return _license.Status switch + { + "valid" when IsLicenseExpiringSoon() => "⏰", + "valid" => "✓", + "expired" => "⚠", + "revoked" => "🚫", + _ => "❓", + }; + } + } + + /// + /// Catégorie utilisée par la UI pour piloter la couleur du badge license. + /// + public string LicenseSeverity + { + get + { + if (_license is null) return "Error"; + return _license.Status switch + { + "valid" when IsLicenseExpiringSoon() => "Warning", + "valid" => "Ok", + _ => "Error", + }; + } + } + + private bool IsLicenseExpiringSoon() + { + if (_license?.DownloadEntitlementUntil is not { } until) return false; + return (until - DateTime.UtcNow).TotalDays < 30; + } + + private void NotifyLicenseChanged() + { + OnPropertyChanged(nameof(LicenseSummary)); + OnPropertyChanged(nameof(LicenseIcon)); + OnPropertyChanged(nameof(LicenseSeverity)); + } + public string EmptyHint => "Aucune version locale ni distante.\n" + "Clique « Vérifier les mises à jour » pour récupérer le catalogue depuis le serveur, " + @@ -257,7 +310,7 @@ public sealed partial class MainViewModel : ObservableObject { // Au retour, l'URL serveur ou l'installRoot ont pu changer → refresh _license = _licenseService.GetCached(); - OnPropertyChanged(nameof(LicenseSummary)); + NotifyLicenseChanged(); RebuildList(); } } @@ -270,7 +323,7 @@ public sealed partial class MainViewModel : ObservableObject if (dialog.LicenseActivated) { _license = _licenseService.GetCached(); - OnPropertyChanged(nameof(LicenseSummary)); + NotifyLicenseChanged(); RebuildList(); } await Task.CompletedTask; diff --git a/src/PSLauncher.App/Views/MainWindow.xaml b/src/PSLauncher.App/Views/MainWindow.xaml index 4813ff5..de95954 100644 --- a/src/PSLauncher.App/Views/MainWindow.xaml +++ b/src/PSLauncher.App/Views/MainWindow.xaml @@ -170,9 +170,69 @@ Content="📁 Dossier" Command="{Binding OpenInstallRootCommand}" Margin="0,0,12,0" /> - + + + + + + + + + + + + + + + + + +