Compare commits

...
52 changed files with 374 additions and 218 deletions

View file

@ -0,0 +1,22 @@
<UserControl xmlns="https://github.com/avaloniaui"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:vm="using:PostIt.ViewModels"
x:Class="PostIt.Controls.StatusBar"
x:DataType="vm:StatusNotice">
<Border Background="{Binding Background}"
BorderBrush="{Binding BorderBrush}"
BorderThickness="1"
CornerRadius="6"
Padding="8">
<StackPanel Orientation="Horizontal" Spacing="8">
<TextBlock Text="{Binding Glyph}"
FontWeight="Bold"
Foreground="{Binding Foreground}"
VerticalAlignment="Top"/>
<TextBlock Text="{Binding Message}"
Foreground="{Binding Foreground}"
TextWrapping="Wrap"
VerticalAlignment="Center"/>
</StackPanel>
</Border>
</UserControl>

View file

@ -0,0 +1,11 @@
using Avalonia.Controls;
namespace PostIt.Controls;
public partial class StatusBar : UserControl
{
public StatusBar()
{
InitializeComponent();
}
}

View file

@ -0,0 +1,32 @@
namespace PostIt.ViewModels;
public interface IActionStatusViewModel
{
string StatusMessage { get; set; }
StatusNotice ActionStatus { get; set; }
}
public static class ActionStatusViewModelExtensions
{
public static void SetInfoStatus(this IActionStatusViewModel viewModel, string message)
=> viewModel.SetStatus(message, StatusSeverity.Info);
public static void SetWarningStatus(this IActionStatusViewModel viewModel, string message)
=> viewModel.SetStatus(message, StatusSeverity.Warning);
public static void SetErrorStatus(this IActionStatusViewModel viewModel, string message)
=> viewModel.SetStatus(message, StatusSeverity.Error);
public static void SetStatus(this IActionStatusViewModel viewModel, string message, StatusSeverity severity)
{
var normalizedMessage = string.IsNullOrWhiteSpace(message) ? "Pret." : message.Trim();
viewModel.StatusMessage = normalizedMessage;
viewModel.ActionStatus = severity switch
{
StatusSeverity.Error => StatusNotice.Error(normalizedMessage),
StatusSeverity.Warning => StatusNotice.Warning(normalizedMessage),
_ => StatusNotice.Info(normalizedMessage),
};
}
}

View file

@ -13,7 +13,7 @@ using Yavsc.Api.Client;
namespace PostIt.ViewModels;
public partial class ActivitiesPageViewModel : ViewModelBase
public partial class ActivitiesPageViewModel : ViewModelBase, IActionStatusViewModel
{
private readonly ActivityApiClient _client;
private readonly BillingApiClient _billingClient;
@ -43,6 +43,9 @@ public partial class ActivitiesPageViewModel : ViewModelBase
[ObservableProperty]
public partial string StatusMessage { get; set; } = "Choisissez une activité.";
[ObservableProperty]
public partial StatusNotice ActionStatus { get; set; } = StatusNotice.Info("Choisissez une activité.");
public ActivityInfo? CurrentActivity => SelectedSpecialization ?? SelectedActivity;
public string SelectedActivityLabel => SelectedActivity?.Name ?? "(aucune activité)";
public string CurrentActivityLabel => CurrentActivity?.Name ?? "(aucune)";
@ -86,11 +89,11 @@ public partial class ActivitiesPageViewModel : ViewModelBase
}
catch (HttpRequestException ex) when (ex.StatusCode is HttpStatusCode.Unauthorized or HttpStatusCode.Forbidden)
{
StatusMessage = "Accès refusé pour les activités (scope 'api'). Déconnectez puis reconnectez-vous.";
this.SetWarningStatus("Accès refusé pour les activités (scope 'api'). Déconnectez puis reconnectez-vous.");
}
catch (Exception ex)
{
StatusMessage = $"Erreur: {ex.Message}";
this.SetErrorStatus($"Erreur: {ex.Message}");
}
}
@ -102,11 +105,11 @@ public partial class ActivitiesPageViewModel : ViewModelBase
}
catch (HttpRequestException ex) when (ex.StatusCode is HttpStatusCode.Unauthorized or HttpStatusCode.Forbidden)
{
StatusMessage = "Accès refusé pour les activités (scope 'api'). Déconnectez puis reconnectez-vous.";
this.SetWarningStatus("Accès refusé pour les activités (scope 'api'). Déconnectez puis reconnectez-vous.");
}
catch (Exception ex)
{
StatusMessage = $"Erreur: {ex.Message}";
this.SetErrorStatus($"Erreur: {ex.Message}");
}
}
@ -123,7 +126,7 @@ public partial class ActivitiesPageViewModel : ViewModelBase
await ShowActivityAsync(first);
if (first is null)
{
StatusMessage = "Aucune activité disponible.";
this.SetInfoStatus("Aucune activité disponible.");
}
}
catch (HttpRequestException ex) when (ex.StatusCode is HttpStatusCode.Unauthorized or HttpStatusCode.Forbidden)
@ -131,14 +134,14 @@ public partial class ActivitiesPageViewModel : ViewModelBase
Activities = new ObservableCollection<ActivityInfo>();
Specializations = new ObservableCollection<ActivityInfo>();
Performers = new ObservableCollection<ActivityUserDisplayItem>();
StatusMessage = "Accès refusé pour les activités (scope 'api'). Déconnectez puis reconnectez-vous.";
this.SetWarningStatus("Accès refusé pour les activités (scope 'api'). Déconnectez puis reconnectez-vous.");
}
catch (Exception ex)
{
Activities = new ObservableCollection<ActivityInfo>();
Specializations = new ObservableCollection<ActivityInfo>();
Performers = new ObservableCollection<ActivityUserDisplayItem>();
StatusMessage = $"Erreur: {ex.Message}";
this.SetErrorStatus($"Erreur: {ex.Message}");
}
finally
{
@ -230,19 +233,19 @@ public partial class ActivitiesPageViewModel : ViewModelBase
Performers = new ObservableCollection<ActivityUserDisplayItem>(items);
SelectedPerformer = null;
StatusMessage = $"{activity.Name} · {Performers.Count} utilisateur(s)";
this.SetInfoStatus($"{activity.Name} · {Performers.Count} utilisateur(s)");
}
catch (HttpRequestException ex) when (ex.StatusCode is HttpStatusCode.Unauthorized or HttpStatusCode.Forbidden)
{
Performers = new ObservableCollection<ActivityUserDisplayItem>();
SelectedPerformer = null;
StatusMessage = "Accès refusé pour les activités (scope 'api'). Déconnectez puis reconnectez-vous.";
this.SetWarningStatus("Accès refusé pour les activités (scope 'api'). Déconnectez puis reconnectez-vous.");
}
catch (Exception ex)
{
Performers = new ObservableCollection<ActivityUserDisplayItem>();
SelectedPerformer = null;
StatusMessage = $"Erreur: {ex.Message}";
this.SetErrorStatus($"Erreur: {ex.Message}");
}
finally
{
@ -259,7 +262,7 @@ public partial class ActivitiesPageViewModel : ViewModelBase
{
if (SelectedPerformer is null || CurrentActivity is null)
{
StatusMessage = "Sélectionnez un utilisateur et une activité avec formulaire.";
this.SetWarningStatus("Sélectionnez un utilisateur et une activité avec formulaire.");
return;
}

View file

@ -29,7 +29,7 @@ namespace PostIt.ViewModels;
/// <c>CirclesPage</c> then calls
/// <see cref="CircleApiClient.AddMemberAsync"/>.</para>
/// </summary>
public partial class AddCircleMemberDialogViewModel : ViewModelBase
public partial class AddCircleMemberDialogViewModel : ViewModelBase, IActionStatusViewModel
{
private readonly IUserDirectory _directory;
@ -46,7 +46,10 @@ public partial class AddCircleMemberDialogViewModel : ViewModelBase
public partial bool IsBusy { get; set; }
[ObservableProperty]
public partial string StatusMessage { get; set; } = string.Empty;
public partial string StatusMessage { get; set; } = "Pret.";
[ObservableProperty]
public partial StatusNotice ActionStatus { get; set; } = StatusNotice.Info("Pret.");
/// <summary>
/// Raised when the user confirms a selection. The hosting
@ -79,7 +82,7 @@ public partial class AddCircleMemberDialogViewModel : ViewModelBase
if (string.IsNullOrWhiteSpace(SearchQuery))
{
Results.Clear();
StatusMessage = "Tapez un nom ou un email";
this.SetWarningStatus("Tapez un nom ou un email");
return;
}
@ -88,11 +91,11 @@ public partial class AddCircleMemberDialogViewModel : ViewModelBase
{
var hits = await _directory.SearchAsync(SearchQuery, CancellationToken.None).ConfigureAwait(true);
Results = new ObservableCollection<UserSummary>(hits ?? Array.Empty<UserSummary>());
StatusMessage = $"{Results.Count} résultat(s)";
this.SetInfoStatus($"{Results.Count} résultat(s)");
}
catch (Exception ex)
{
StatusMessage = $"Erreur: {ex.Message}";
this.SetErrorStatus($"Erreur: {ex.Message}");
}
finally
{
@ -110,18 +113,20 @@ public partial class AddCircleMemberDialogViewModel : ViewModelBase
{
if (Selected is null)
{
StatusMessage = "Sélectionnez un utilisateur";
this.SetWarningStatus("Sélectionnez un utilisateur");
return;
}
Confirmed?.Invoke(this, Selected);
var app = App.Current as App;
var app = App.Current as App
?? throw new InvalidOperationException("Application PostIt indisponible.");
await app.GoBackAsync();
}
[RelayCommand]
public async Task CloseAsync()
{
var app = App.Current as App;
var app = App.Current as App
?? throw new InvalidOperationException("Application PostIt indisponible.");
await app.GoBackAsync();
}
}

View file

@ -14,7 +14,7 @@ using Yavsc.Abstract.Workflow;
namespace PostIt.ViewModels;
public partial class BillingQueriesPageViewModel : ViewModelBase
public partial class BillingQueriesPageViewModel : ViewModelBase, IActionStatusViewModel
{
private readonly BillingApiClient _billingClient;
@ -36,6 +36,9 @@ public partial class BillingQueriesPageViewModel : ViewModelBase
[ObservableProperty]
public partial string StatusMessage { get; set; } = "Chargement des commandes...";
[ObservableProperty]
public partial StatusNotice ActionStatus { get; set; } = StatusNotice.Info("Chargement des commandes...");
public string Title => IsReadOnly
? $"Demandes en cours ({Form.Title})"
: $"Commandes {Form.Title}";
@ -90,17 +93,17 @@ public partial class BillingQueriesPageViewModel : ViewModelBase
.ToList();
Queries = new ObservableCollection<BillingQueryDisplayItem>(filtered);
StatusMessage = BuildLoadedStatusMessage(filtered.Count);
this.SetInfoStatus(BuildLoadedStatusMessage(filtered.Count));
}
catch (HttpRequestException ex) when (ex.StatusCode is HttpStatusCode.Unauthorized or HttpStatusCode.Forbidden)
{
Queries = new ObservableCollection<BillingQueryDisplayItem>();
StatusMessage = "Accès refusé au billing (scope 'api'). Déconnectez puis reconnectez-vous.";
this.SetWarningStatus("Accès refusé au billing (scope 'api'). Déconnectez puis reconnectez-vous.");
}
catch (Exception ex)
{
Queries = new ObservableCollection<BillingQueryDisplayItem>();
StatusMessage = $"Erreur: {ex.Message}";
this.SetErrorStatus($"Erreur: {ex.Message}");
}
finally
{
@ -113,13 +116,13 @@ public partial class BillingQueriesPageViewModel : ViewModelBase
{
if (IsReadOnly)
{
StatusMessage = "Mode lecture seule: l'ouverture en modification est désactivée.";
this.SetWarningStatus("Mode lecture seule: l'ouverture en modification est désactivée.");
return;
}
if (SelectedQuery is null)
{
StatusMessage = "Sélectionnez une commande.";
this.SetWarningStatus("Sélectionnez une commande.");
return;
}
@ -139,11 +142,11 @@ public partial class BillingQueriesPageViewModel : ViewModelBase
}
catch (HttpRequestException ex) when (ex.StatusCode is HttpStatusCode.Unauthorized or HttpStatusCode.Forbidden)
{
StatusMessage = "Accès refusé au billing (scope 'api'). Déconnectez puis reconnectez-vous.";
this.SetWarningStatus("Accès refusé au billing (scope 'api'). Déconnectez puis reconnectez-vous.");
}
catch (Exception ex)
{
StatusMessage = $"Erreur lors de l'ouverture: {ex.Message}";
this.SetErrorStatus($"Erreur lors de l'ouverture: {ex.Message}");
}
finally
{

View file

@ -34,7 +34,7 @@ namespace PostIt.ViewModels;
/// <see cref="OnAddMemberConfirmedAsync"/>. The "remove"
/// command is per-row and runs inline.</para>
/// </summary>
public partial class CirclesPageViewModel : ViewModelBase
public partial class CirclesPageViewModel : ViewModelBase, IActionStatusViewModel
{
private readonly CircleApiClient _client;
@ -63,8 +63,10 @@ public partial class CirclesPageViewModel : ViewModelBase
public partial bool IsBusy { get; set; }
[ObservableProperty]
public partial string StatusMessage { get; set; } = string.Empty;
public partial string StatusMessage { get; set; } = "Pret.";
[ObservableProperty]
public partial StatusNotice ActionStatus { get; set; } = StatusNotice.Info("Pret.");
public CirclesPageViewModel(CircleApiClient client)
{
@ -100,11 +102,11 @@ public partial class CirclesPageViewModel : ViewModelBase
{
var list = await _client.GetMyCirclesAsync();
Circles = new ObservableCollection<CircleDto>(list ?? new());
StatusMessage = $"{Circles.Count} cercle(s)";
this.SetInfoStatus($"{Circles.Count} cercle(s)");
}
catch (Exception ex)
{
StatusMessage = $"Erreur: {ex.Message}";
this.SetErrorStatus($"Erreur: {ex.Message}");
}
finally
{
@ -115,8 +117,10 @@ public partial class CirclesPageViewModel : ViewModelBase
[RelayCommand]
internal async Task OpenAddMemberAsync()
{
var app = Application.Current as App;
var services = app?.ServiceProvider;
var app = Application.Current as App
?? throw new InvalidOperationException("Application PostIt indisponible.");
var services = app.ServiceProvider
?? throw new InvalidOperationException("ServiceProvider PostIt indisponible.");
var directory = services.GetRequiredService<IUserDirectory>();
AddCircleMemberDialogViewModel model =
new AddCircleMemberDialogViewModel(directory);
@ -147,11 +151,11 @@ public partial class CirclesPageViewModel : ViewModelBase
{
var list = await _client.GetMembersAsync(circleId);
Members = new ObservableCollection<CircleMemberDto>(list ?? new());
StatusMessage = $"{Members.Count} membre(s)";
this.SetInfoStatus($"{Members.Count} membre(s)");
}
catch (Exception ex)
{
StatusMessage = $"Erreur: {ex.Message}";
this.SetErrorStatus($"Erreur: {ex.Message}");
Members = new ObservableCollection<CircleMemberDto>();
}
finally
@ -166,7 +170,7 @@ public partial class CirclesPageViewModel : ViewModelBase
SelectedCircle = null;
DraftName = string.Empty;
DraftPublic = false;
StatusMessage = "Nouveau cercle";
this.SetInfoStatus("Nouveau cercle");
}
[RelayCommand]
@ -176,7 +180,7 @@ public partial class CirclesPageViewModel : ViewModelBase
SelectedCircle = circle;
DraftName = circle.Name;
DraftPublic = circle.Public;
StatusMessage = $"Édition de « {circle.Name} »";
this.SetInfoStatus($"Édition de « {circle.Name} »");
}
[RelayCommand]
@ -184,7 +188,7 @@ public partial class CirclesPageViewModel : ViewModelBase
{
if (string.IsNullOrWhiteSpace(DraftName))
{
StatusMessage = "Le nom est obligatoire";
this.SetWarningStatus("Le nom est obligatoire");
return;
}
@ -198,22 +202,22 @@ public partial class CirclesPageViewModel : ViewModelBase
Name = DraftName.Trim(),
Public = DraftPublic,
});
StatusMessage = created is null
? "Création échouée"
: $"Cercle « {created.Name} » créé";
this.SetStatus(
created is null ? "Création échouée" : $"Cercle « {created.Name} » créé",
created is null ? StatusSeverity.Warning : StatusSeverity.Info);
}
else
{
SelectedCircle.Name = DraftName.Trim();
SelectedCircle.Public = DraftPublic;
await _client.UpdateCircleAsync(SelectedCircle.Id, SelectedCircle);
StatusMessage = $"Cercle « {SelectedCircle.Name} » mis à jour";
this.SetInfoStatus($"Cercle « {SelectedCircle.Name} » mis à jour");
}
await RefreshAsync();
}
catch (Exception ex)
{
StatusMessage = $"Erreur: {ex.Message}";
this.SetErrorStatus($"Erreur: {ex.Message}");
}
finally
{
@ -229,7 +233,7 @@ public partial class CirclesPageViewModel : ViewModelBase
try
{
await _client.DeleteCircleAsync(circle.Id);
StatusMessage = $"Cercle « {circle.Name} » supprimé";
this.SetInfoStatus($"Cercle « {circle.Name} » supprimé");
// If the deleted circle was the selected one,
// clear the selection so the Members view goes
// empty too (the partial setter on
@ -240,7 +244,7 @@ public partial class CirclesPageViewModel : ViewModelBase
}
catch (Exception ex)
{
StatusMessage = $"Erreur: {ex.Message}";
this.SetErrorStatus($"Erreur: {ex.Message}");
}
finally
{
@ -261,7 +265,7 @@ public partial class CirclesPageViewModel : ViewModelBase
try
{
await _client.AddMemberAsync(SelectedCircle.Id, picked.Id);
StatusMessage = $"« {picked.DisplayName} » ajouté au cercle";
this.SetInfoStatus($"« {picked.DisplayName} » ajouté au cercle");
await LoadMembersAsync(SelectedCircle.Id);
}
catch (Exception ex)
@ -276,7 +280,7 @@ public partial class CirclesPageViewModel : ViewModelBase
var msg = ex.Message.Contains("409") || ex.Message.Contains("Conflict")
? "Déjà membre du cercle"
: $"Erreur: {ex.Message}";
StatusMessage = msg;
this.SetStatus(msg, msg == "Déjà membre du cercle" ? StatusSeverity.Warning : StatusSeverity.Error);
}
finally
{
@ -297,11 +301,11 @@ public partial class CirclesPageViewModel : ViewModelBase
{
await _client.RemoveMemberAsync(SelectedCircle.Id, member.Id);
Members.Remove(member);
StatusMessage = $"« {member.UserName} » retiré du cercle";
this.SetInfoStatus($"« {member.UserName} » retiré du cercle");
}
catch (Exception ex)
{
StatusMessage = $"Erreur: {ex.Message}";
this.SetErrorStatus($"Erreur: {ex.Message}");
}
finally
{

View file

@ -11,7 +11,7 @@ using Yavsc.Api.Client;
namespace PostIt.ViewModels;
public partial class CommandFormsPageViewModel : ViewModelBase
public partial class CommandFormsPageViewModel : ViewModelBase, IActionStatusViewModel
{
private readonly BillingApiClient _billingClient;
@ -25,7 +25,10 @@ public partial class CommandFormsPageViewModel : ViewModelBase
public partial CommandFormSummary? SelectedForm { get; set; }
[ObservableProperty]
public partial string StatusMessage { get; set; }
public partial string StatusMessage { get; set; } = "Pret.";
[ObservableProperty]
public partial StatusNotice ActionStatus { get; set; } = StatusNotice.Info("Pret.");
public string Title => $"Formulaires pour {Performer.UserName}";
public string ContextLabel => $"{Activity.Name} · {Forms.Count} formulaire(s)";
@ -55,9 +58,11 @@ public partial class CommandFormsPageViewModel : ViewModelBase
.OrderBy(f => f.Title)
.ThenBy(f => f.ActionName));
SelectedForm = Forms.FirstOrDefault();
StatusMessage = Forms.Count == 0
? "Aucun formulaire n'est disponible pour cette activité."
: "Choisissez le formulaire à utiliser.";
this.SetStatus(
Forms.Count == 0
? "Aucun formulaire n'est disponible pour cette activité."
: "Choisissez le formulaire à utiliser.",
Forms.Count == 0 ? StatusSeverity.Warning : StatusSeverity.Info);
}
private bool CanOpenSelectedForm() => SelectedForm is not null;
@ -71,7 +76,7 @@ public partial class CommandFormsPageViewModel : ViewModelBase
{
if (SelectedForm is null)
{
StatusMessage = "Sélectionnez un formulaire.";
this.SetWarningStatus("Sélectionnez un formulaire.");
return;
}
@ -92,7 +97,7 @@ public partial class CommandFormsPageViewModel : ViewModelBase
{
if (SelectedForm is null)
{
StatusMessage = "Sélectionnez un formulaire.";
this.SetWarningStatus("Sélectionnez un formulaire.");
return;
}
@ -112,7 +117,7 @@ public partial class CommandFormsPageViewModel : ViewModelBase
{
if (SelectedForm is null)
{
StatusMessage = "Sélectionnez un formulaire.";
this.SetWarningStatus("Sélectionnez un formulaire.");
return;
}

View file

@ -9,7 +9,7 @@ using Yavsc.Models.Billing;
namespace PostIt.ViewModels;
public abstract partial class BillingCommandPageViewModel : RemoteViewModelBase
public abstract partial class BillingCommandPageViewModel : RemoteViewModelBase, IActionStatusViewModel
{
protected readonly BillingApiClient _billingClient;
@ -21,7 +21,10 @@ public abstract partial class BillingCommandPageViewModel : RemoteViewModelBase
public partial bool IsBusy { get; set; }
[ObservableProperty]
public partial string StatusMessage { get; set; }
public partial string StatusMessage { get; set; } = "Pret.";
[ObservableProperty]
public partial StatusNotice ActionStatus { get; set; } = StatusNotice.Info("Pret.");
[ObservableProperty]
public partial string Reason { get; set; } = string.Empty;
@ -75,7 +78,7 @@ public abstract partial class BillingCommandPageViewModel : RemoteViewModelBase
Form = form ?? throw new ArgumentNullException(nameof(form));
_billingClient = billingClient ?? throw new ArgumentNullException(nameof(billingClient));
StatusMessage = SupportMessage;
this.SetInfoStatus(SupportMessage);
}
partial void OnExistingQueryIdChanged(long? value)

View file

@ -58,18 +58,20 @@ public partial class BrushViewModel : RdvViewModel
SelectedPrestation = AvailablePrestations.FirstOrDefault();
}
StatusMessage = AvailablePrestations.Count == 0
? "Aucune prestation coiffure disponible."
: SupportMessage;
this.SetStatus(
AvailablePrestations.Count == 0
? "Aucune prestation coiffure disponible."
: SupportMessage,
AvailablePrestations.Count == 0 ? StatusSeverity.Warning : StatusSeverity.Info);
}
catch (HttpRequestException ex)
when (ex.StatusCode is HttpStatusCode.Unauthorized or HttpStatusCode.Forbidden)
{
StatusMessage = "Accès refusé au catalogue de prestations (scope 'api'). Déconnectez puis reconnectez-vous.";
this.SetWarningStatus("Accès refusé au catalogue de prestations (scope 'api'). Déconnectez puis reconnectez-vous.");
}
catch (Exception ex)
{
StatusMessage = $"Erreur lors du chargement des prestations: {ex.Message}";
this.SetErrorStatus($"Erreur lors du chargement des prestations: {ex.Message}");
}
finally
{
@ -81,19 +83,19 @@ public partial class BrushViewModel : RdvViewModel
{
if (!Consent)
{
StatusMessage = "Le consentement est requis pour poster la commande.";
this.SetWarningStatus("Le consentement est requis pour poster la commande.");
return;
}
if (string.IsNullOrWhiteSpace(Address))
{
StatusMessage = "L'adresse du rendez-vous est requise.";
this.SetWarningStatus("L'adresse du rendez-vous est requise.");
return;
}
if (SelectedPrestation is null)
{
StatusMessage = "Sélectionnez une prestation coiffure.";
this.SetWarningStatus("Sélectionnez une prestation coiffure.");
return;
}
@ -143,18 +145,18 @@ public partial class BrushViewModel : RdvViewModel
}).ConfigureAwait(true);
}
StatusMessage = IsEditingExisting
this.SetInfoStatus(IsEditingExisting
? $"Commande #{ExistingQueryId} mise à jour sur {BillingRoute} pour {Performer.UserName}."
: $"Commande transmise sur {BillingRoute} pour {Performer.UserName}.";
: $"Commande transmise sur {BillingRoute} pour {Performer.UserName}.");
}
catch (HttpRequestException ex)
when (ex.StatusCode is HttpStatusCode.Unauthorized or HttpStatusCode.Forbidden)
{
StatusMessage = "Accès refusé au billing (scope 'api'). Déconnectez puis reconnectez-vous.";
this.SetWarningStatus("Accès refusé au billing (scope 'api'). Déconnectez puis reconnectez-vous.");
}
catch (Exception ex)
{
StatusMessage = $"Erreur lors de l'envoi de la commande: {ex.Message}";
this.SetErrorStatus($"Erreur lors de l'envoi de la commande: {ex.Message}");
}
finally
{

View file

@ -49,20 +49,20 @@ public partial class MBrushViewModel : BrushViewModel
{
if (!Consent)
{
StatusMessage = "Le consentement est requis pour poster la commande.";
this.SetWarningStatus("Le consentement est requis pour poster la commande.");
return;
}
if (string.IsNullOrWhiteSpace(Address))
{
StatusMessage = "L'adresse du rendez-vous est requise.";
this.SetWarningStatus("L'adresse du rendez-vous est requise.");
return;
}
var selectedPrestations = MultiPrestations.Where(x => x.IsSelected).ToList();
if (selectedPrestations.Count == 0)
{
StatusMessage = "Sélectionnez au moins une prestation coiffure.";
this.SetWarningStatus("Sélectionnez au moins une prestation coiffure.");
return;
}
@ -109,18 +109,18 @@ public partial class MBrushViewModel : BrushViewModel
}).ConfigureAwait(true);
}
StatusMessage = IsEditingExisting
this.SetInfoStatus(IsEditingExisting
? $"Commande #{ExistingQueryId} mise à jour sur {BillingRoute} pour {Performer.UserName}."
: $"Commande transmise sur {BillingRoute} pour {Performer.UserName}.";
: $"Commande transmise sur {BillingRoute} pour {Performer.UserName}.");
}
catch (HttpRequestException ex)
when (ex.StatusCode is HttpStatusCode.Unauthorized or HttpStatusCode.Forbidden)
{
StatusMessage = "Accès refusé au billing (scope 'api'). Déconnectez puis reconnectez-vous.";
this.SetWarningStatus("Accès refusé au billing (scope 'api'). Déconnectez puis reconnectez-vous.");
}
catch (Exception ex)
{
StatusMessage = $"Erreur lors de l'envoi de la commande: {ex.Message}";
this.SetErrorStatus($"Erreur lors de l'envoi de la commande: {ex.Message}");
}
finally
{

View file

@ -54,7 +54,7 @@ public partial class RdvViewModel : BillingCommandPageViewModel
Longitude = existingQuery.Location.Longitude;
}
StatusMessage = $"Commande #{existingQuery.Id} chargée.";
this.SetInfoStatus($"Commande #{existingQuery.Id} chargée.");
}
[RelayCommand(CanExecute = nameof(CanUseCurrentLocation))]
@ -71,23 +71,23 @@ public partial class RdvViewModel : BillingCommandPageViewModel
var result = await Platform.TryGetCurrentLocationAsync(default).ConfigureAwait(true);
if (!result.IsSuccess || !result.Latitude.HasValue || !result.Longitude.HasValue)
{
StatusMessage = result.Message;
this.SetWarningStatus(result.Message);
return;
}
Latitude = result.Latitude.Value;
Longitude = result.Longitude.Value;
StatusMessage = string.IsNullOrWhiteSpace(Address)
this.SetInfoStatus(string.IsNullOrWhiteSpace(Address)
? "Position récupérée. Complétez l'adresse puis envoyez la commande."
: result.Message;
: result.Message);
}
catch (OperationCanceledException)
{
StatusMessage = "La récupération de la position a été annulée.";
this.SetWarningStatus("La récupération de la position a été annulée.");
}
catch (Exception ex)
{
StatusMessage = $"Impossible de récupérer la position: {ex.Message}";
this.SetErrorStatus($"Impossible de récupérer la position: {ex.Message}");
}
finally
{
@ -118,26 +118,26 @@ public partial class RdvViewModel : BillingCommandPageViewModel
{
if (!IsSupported)
{
StatusMessage = SupportMessage;
this.SetWarningStatus(SupportMessage);
return;
}
if (!Consent)
{
StatusMessage = "Le consentement est requis pour poster la commande.";
this.SetWarningStatus("Le consentement est requis pour poster la commande.");
return;
}
if (string.IsNullOrWhiteSpace(Address))
{
StatusMessage = "L'adresse du rendez-vous est requise.";
this.SetWarningStatus("L'adresse du rendez-vous est requise.");
return;
}
if (string.IsNullOrWhiteSpace(Reason))
{
StatusMessage = "Le motif du rendez-vous est requis.";
this.SetWarningStatus("Le motif du rendez-vous est requis.");
return;
}
@ -186,17 +186,17 @@ public partial class RdvViewModel : BillingCommandPageViewModel
}).ConfigureAwait(true);
}
StatusMessage = IsEditingExisting
this.SetInfoStatus(IsEditingExisting
? $"Commande #{ExistingQueryId} mise à jour sur {BillingRoute} pour {Performer.UserName}."
: $"Commande transmise sur {BillingRoute} pour {Performer.UserName}.";
: $"Commande transmise sur {BillingRoute} pour {Performer.UserName}.");
}
catch (HttpRequestException ex) when (ex.StatusCode is HttpStatusCode.Unauthorized or HttpStatusCode.Forbidden)
{
StatusMessage = "Accès refusé au billing (scope 'api'). Déconnectez puis reconnectez-vous.";
this.SetWarningStatus("Accès refusé au billing (scope 'api'). Déconnectez puis reconnectez-vous.");
}
catch (Exception ex)
{
StatusMessage = $"Erreur lors de l'envoi: {ex.Message}";
this.SetErrorStatus($"Erreur lors de l'envoi: {ex.Message}");
}
finally
{

View file

@ -12,7 +12,7 @@ using PostIt.Helpers;
namespace PostIt.ViewModels;
public partial class MainViewModel : ViewModelBase
public partial class MainViewModel : ViewModelBase, IActionStatusViewModel
{
/// <summary>Window/tab title. Cosmetic — bound by
/// <c>MainPage.axaml</c> if at all. Not the post title.</summary>
@ -54,6 +54,9 @@ public partial class MainViewModel : ViewModelBase
[ObservableProperty]
public partial string StatusMessage { get; set; }
[ObservableProperty]
public partial StatusNotice ActionStatus { get; set; } = StatusNotice.Info("Pret.");
[ObservableProperty]
public partial string SearchText { get; set; }
@ -84,7 +87,7 @@ public partial class MainViewModel : ViewModelBase
Posts.Add(post);
}
ApplyFilter();
StatusMessage = $"Loaded {Posts.Count} posts.";
this.SetInfoStatus($"{Posts.Count} billet(s) chargé(s).");
});
}
@ -104,7 +107,7 @@ public partial class MainViewModel : ViewModelBase
// than to send a request the server will reject.
if (string.IsNullOrWhiteSpace(DraftTitle))
{
StatusMessage = "Title is required.";
this.SetWarningStatus("Le titre est obligatoire.");
return;
}
@ -134,7 +137,7 @@ public partial class MainViewModel : ViewModelBase
if (created is not null)
{
SelectedPost = created;
StatusMessage = $"Created post {created.Id}.";
this.SetInfoStatus($"Billet {created.Id} créé.");
}
}
else
@ -150,7 +153,7 @@ public partial class MainViewModel : ViewModelBase
DateModified = DateTime.UtcNow,
};
await BlogClient!.UpdatePostAsync(SelectedPost.Id, update);
StatusMessage = $"Saved post {SelectedPost.Id}.";
this.SetInfoStatus($"Billet {SelectedPost.Id} enregistré.");
}
await RefreshPostsAsync();
@ -162,14 +165,14 @@ public partial class MainViewModel : ViewModelBase
{
if (SelectedPost is null || SelectedPost.Id == 0)
{
StatusMessage = "Select an existing post before deleting.";
this.SetWarningStatus("Sélectionnez un billet existant avant suppression.");
return;
}
await ExecuteAsync(async () =>
{
await BlogClient!.DeletePostAsync(SelectedPost.Id);
StatusMessage = $"Deleted post {SelectedPost.Id}.";
this.SetInfoStatus($"Billet {SelectedPost.Id} supprimé.");
SelectedPost = null;
await RefreshPostsAsync();
});
@ -194,7 +197,7 @@ public partial class MainViewModel : ViewModelBase
{
if (SelectedPost is null || SelectedPost.Id == 0)
{
StatusMessage = "Sélectionnez un billet existant pour changer sa publication.";
this.SetWarningStatus("Sélectionnez un billet existant pour changer sa publication.");
return;
}
@ -211,9 +214,9 @@ public partial class MainViewModel : ViewModelBase
// locally flipped state until the round-trip
// re-hydrates it.
SelectedPost.IsPublished = publish;
StatusMessage = publish
this.SetInfoStatus(publish
? $"Billet {SelectedPost.Id} publié."
: $"Billet {SelectedPost.Id} remis en brouillon.";
: $"Billet {SelectedPost.Id} remis en brouillon.");
});
}
@ -247,7 +250,7 @@ public partial class MainViewModel : ViewModelBase
{
if (SelectedPost is null)
{
StatusMessage = "Select an existing post before managing ACL.";
this.SetWarningStatus("Sélectionnez un billet existant avant de gérer l'ACL.");
return;
}
@ -346,7 +349,7 @@ public partial class MainViewModel : ViewModelBase
FilteredPosts = new ObservableCollection<BlogPostDto>();
SelectedPost = null;
IsBusy = false;
StatusMessage = "Ready";
this.SetInfoStatus("Prêt.");
Settings = settings ?? new Settings();
SearchText = Settings.SearchText;
WindowTitle = "PostIt";
@ -476,12 +479,12 @@ public partial class MainViewModel : ViewModelBase
try
{
IsBusy = true;
StatusMessage = "Working...";
this.SetInfoStatus("Traitement en cours...");
await action();
}
catch (Exception ex)
{
StatusMessage = $"Error: {ex.Message}";
this.SetErrorStatus($"Erreur: {ex.Message}");
}
finally
{

View file

@ -37,7 +37,7 @@ public sealed class PostAclEntry
/// any 403 / 404 will surface as an exception caught by the
/// command and routed to <see cref="StatusMessage"/>.</para>
/// </summary>
public partial class PostAclDialogViewModel : ViewModelBase
public partial class PostAclDialogViewModel : ViewModelBase, IActionStatusViewModel
{
private readonly BlogAclApiClient _aclClient;
private readonly CircleApiClient _circleClient;
@ -61,7 +61,10 @@ public partial class PostAclDialogViewModel : ViewModelBase
public partial bool IsBusy { get; set; }
[ObservableProperty]
public partial string StatusMessage { get; set; } = string.Empty;
public partial string StatusMessage { get; set; } = "Pret.";
[ObservableProperty]
public partial StatusNotice ActionStatus { get; set; } = StatusNotice.Info("Pret.");
/// <summary>
/// Idempotency gate for <see cref="LoadAsync"/>: the dialog
@ -115,12 +118,12 @@ public partial class PostAclDialogViewModel : ViewModelBase
AclEntries = new ObservableCollection<PostAclEntry>(AclEntries.Select(a => ToAclEntry(a.CircleId)));
StatusMessage = $"{AclEntries.Count} autorisation(s)";
this.SetInfoStatus($"{AclEntries.Count} autorisation(s)");
_loaded = true;
}
catch (Exception ex)
{
StatusMessage = $"Erreur: {ex.Message}";
this.SetErrorStatus($"Erreur: {ex.Message}");
}
finally
{
@ -133,7 +136,7 @@ public partial class PostAclDialogViewModel : ViewModelBase
{
if (SelectedCircleToAdd is null)
{
StatusMessage = "Sélectionnez un cercle à ajouter";
this.SetWarningStatus("Sélectionnez un cercle à ajouter");
return;
}
@ -142,7 +145,7 @@ public partial class PostAclDialogViewModel : ViewModelBase
{
if (AclEntries.Any(a => a.CircleId == SelectedCircleToAdd.Id))
{
StatusMessage = $"Cercle « {SelectedCircleToAdd.Name} » déjà autorisé";
this.SetWarningStatus($"Cercle « {SelectedCircleToAdd.Name} » déjà autorisé");
return;
}
@ -154,11 +157,11 @@ public partial class PostAclDialogViewModel : ViewModelBase
if (created is not null)
{
AclEntries.Add(ToAclEntry(created.CircleId));
StatusMessage = $"Cercle « {SelectedCircleToAdd.Name} » autorisé";
this.SetInfoStatus($"Cercle « {SelectedCircleToAdd.Name} » autorisé");
}
else
{
StatusMessage = "Autorisation refusée par le serveur";
this.SetWarningStatus("Autorisation refusée par le serveur");
}
}
catch (HttpRequestException ex) when (ex.StatusCode == HttpStatusCode.Conflict)
@ -166,11 +169,11 @@ public partial class PostAclDialogViewModel : ViewModelBase
// Conflict means the link already exists in backend. Resync
// from the dedicated ACL API so the UI reflects server truth.
await ReloadAclEntriesFromServerAsync();
StatusMessage = $"Cercle « {SelectedCircleToAdd.Name} » déjà autorisé";
this.SetWarningStatus($"Cercle « {SelectedCircleToAdd.Name} » déjà autorisé");
}
catch (Exception ex)
{
StatusMessage = $"Erreur: {ex.Message}";
this.SetErrorStatus($"Erreur: {ex.Message}");
}
finally
{
@ -189,11 +192,11 @@ public partial class PostAclDialogViewModel : ViewModelBase
var existing = AclEntries.FirstOrDefault(e => e.CircleId == acl.CircleId);
if (existing is not null)
AclEntries.Remove(existing);
StatusMessage = "Autorisation révoquée";
this.SetInfoStatus("Autorisation révoquée");
}
catch (Exception ex)
{
StatusMessage = $"Erreur: {ex.Message}";
this.SetErrorStatus($"Erreur: {ex.Message}");
}
finally
{

View file

@ -31,6 +31,19 @@ public partial class Settings : ViewModelBase
[ObservableProperty]
public partial string SearchText { get; set; } = string.Empty;
[ObservableProperty]
public partial StatusNotice ActionStatus { get; set; } = StatusNotice.Info("Pret.");
public void SetActionStatus(string message, StatusSeverity severity = StatusSeverity.Info)
{
ActionStatus = severity switch
{
StatusSeverity.Error => StatusNotice.Error(message),
StatusSeverity.Warning => StatusNotice.Warning(message),
_ => StatusNotice.Info(message),
};
}
/// <summary>
/// Catch top-level mutations: the four ObservableProperty
/// setters above all funnel through here, and we flip
@ -406,6 +419,8 @@ public partial class Settings : ViewModelBase
[RelayCommand(CanExecute = nameof(CanSave))]
public void Save()
{
SetActionStatus("Enregistrement des parametres...", StatusSeverity.Info);
var configDir = Path.Combine(
Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData),
"PostIt");
@ -425,10 +440,13 @@ public partial class Settings : ViewModelBase
File.SetUnixFileMode(configPath,
UnixFileMode.UserRead | UnixFileMode.UserWrite);
IsDirty = false;
SetActionStatus("Parametres sauvegardes.", StatusSeverity.Info);
Console.WriteLine($"💾 Settings saved to {configPath}");
}
catch (Exception ex)
{
SetActionStatus($"Echec sauvegarde parametres: {ex.Message}", StatusSeverity.Error);
Console.Error.WriteLine($"🩎 Error saving settings to {configPath}: {ex.Message}");
throw;
}

View file

@ -30,7 +30,7 @@ namespace PostIt.ViewModels;
/// until the Yavsc.Org endpoint exists; the contract there will
/// be <c>POST /api/signature/{devisId}</c> with this same payload.
/// </summary>
public partial class SignaturePageViewModel : ViewModelBase
public partial class SignaturePageViewModel : ViewModelBase, IActionStatusViewModel
{
/// <summary>
/// Default capture surface, in DIPs. 3:1 ratio matches a
@ -42,6 +42,9 @@ public partial class SignaturePageViewModel : ViewModelBase
[ObservableProperty]
public partial string StatusMessage { get; set; } = "Prêt.";
[ObservableProperty]
public partial StatusNotice ActionStatus { get; set; } = StatusNotice.Info("Prêt.");
[ObservableProperty]
public partial int StrokeCount { get; set; }
@ -107,7 +110,7 @@ public partial class SignaturePageViewModel : ViewModelBase
private void OnStrokeCompleted(object? sender, SignaturePadData data)
{
StatusMessage = $"Trait terminé. {data.StrokeCount} trait(s).";
this.SetInfoStatus($"Trait terminé. {data.StrokeCount} trait(s).");
RefreshCounts();
}
@ -125,7 +128,7 @@ public partial class SignaturePageViewModel : ViewModelBase
public void Clear()
{
_control?.Clear();
StatusMessage = "Effacé.";
this.SetInfoStatus("Effacé.");
RefreshCounts();
}
@ -134,14 +137,14 @@ public partial class SignaturePageViewModel : ViewModelBase
{
if (_control is null)
{
StatusMessage = "Contrôle non attaché.";
this.SetWarningStatus("Contrôle non attaché.");
return;
}
var data = _control.Snapshot();
if (data.IsEmpty)
{
StatusMessage = "Rien à capturer.";
this.SetWarningStatus("Rien à capturer.");
return;
}
@ -149,11 +152,11 @@ public partial class SignaturePageViewModel : ViewModelBase
{
var path = WriteCapture(data);
LastCapturedPath = path;
StatusMessage = $"Capture enregistrée: {path}";
this.SetInfoStatus($"Capture enregistrée: {path}");
}
catch (Exception ex)
{
StatusMessage = $"Erreur: {ex.Message}";
this.SetErrorStatus($"Erreur: {ex.Message}");
}
await Task.CompletedTask;
}

View file

@ -0,0 +1,35 @@
namespace PostIt.ViewModels;
public enum StatusSeverity
{
Info,
Warning,
Error
}
public sealed class StatusNotice
{
public string Message { get; }
public StatusSeverity Severity { get; }
public string Glyph { get; }
public string Background { get; }
public string BorderBrush { get; }
public string Foreground { get; }
private StatusNotice(string message, StatusSeverity severity)
{
Message = string.IsNullOrWhiteSpace(message) ? "Pret." : message;
Severity = severity;
(Glyph, Background, BorderBrush, Foreground) = severity switch
{
StatusSeverity.Error => ("!", "#FDECEA", "#C62828", "#7F1D1D"),
StatusSeverity.Warning => ("~", "#FFF8E1", "#E6A700", "#7C4A03"),
_ => ("i", "#E8F0FE", "#5B8DEF", "#1E3A8A"),
};
}
public static StatusNotice Info(string message) => new(message, StatusSeverity.Info);
public static StatusNotice Warning(string message) => new(message, StatusSeverity.Warning);
public static StatusNotice Error(string message) => new(message, StatusSeverity.Error);
}

View file

@ -1,6 +1,7 @@
<ContentPage xmlns="https://github.com/avaloniaui"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:vm="using:PostIt.ViewModels"
xmlns:postitControls="using:PostIt.Controls"
xmlns:wf="using:Yavsc.Abstract.Workflow"
x:Class="PostIt.Views.ActivitiesPage"
x:DataType="vm:ActivitiesPageViewModel"
@ -131,16 +132,8 @@
</Grid>
<Grid Grid.Row="2" ColumnDefinitions="*,Auto">
<TextBox Grid.Column="0"
Text="{Binding StatusMessage}"
IsReadOnly="True"
AcceptsReturn="True"
TextWrapping="Wrap"
BorderThickness="0"
BorderBrush="Transparent"
Padding="0"
Background="Transparent"
VerticalAlignment="Center" />
<postitControls:StatusBar Grid.Column="0"
DataContext="{Binding ActionStatus}" />
<ProgressBar Grid.Column="1" Width="120" IsIndeterminate="True" IsVisible="{Binding IsBusy}" />
</Grid>
</Grid>

View file

@ -3,6 +3,7 @@
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
x:Class="PostIt.Views.AddCircleMemberDialog"
xmlns:vm="using:PostIt.ViewModels"
xmlns:postitControls="using:PostIt.Controls"
xmlns:services="using:PostIt.Services"
x:DataType="vm:AddCircleMemberDialogViewModel"
>
@ -47,8 +48,8 @@
<!-- Action buttons -->
<Grid Grid.Row="3" ColumnDefinitions="*,Auto,Auto" Margin="0,8,0,0">
<TextBlock Grid.Column="0" Text="{Binding StatusMessage}"
VerticalAlignment="Center"/>
<postitControls:StatusBar Grid.Column="0"
DataContext="{Binding ActionStatus}" />
<Button Grid.Column="1" Content="Ajouter"
x:Name="AddButton"
Command="{Binding AddAsync}"

View file

@ -1,10 +1,8 @@
using Avalonia.Markup.Xaml;
using Avalonia.Interactivity;
using Avalonia.VisualTree;
using PostIt.Services;
using PostIt.ViewModels;
using System.Threading.Tasks;
namespace PostIt.Views;
@ -41,10 +39,4 @@ public partial class AddCircleMemberDialog : Avalonia.Controls.ContentPage
/// </summary>
public AddCircleMemberDialogViewModel? ViewModel
=> DataContext as AddCircleMemberDialogViewModel;
private async Task OnCloseClicked(object? sender, RoutedEventArgs e)
{
App app = App.Current! as App;
await app!.GoBackAsync();
}
}

View file

@ -1,6 +1,7 @@
<ContentPage xmlns="https://github.com/avaloniaui"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:vm="using:PostIt.ViewModels"
xmlns:postitControls="using:PostIt.Controls"
x:Class="PostIt.Views.BillingQueriesPage"
x:DataType="vm:BillingQueriesPageViewModel"
Header="Commandes billing">
@ -36,16 +37,8 @@
</ListBox>
<Grid Grid.Row="3" ColumnDefinitions="*,Auto" Margin="0,12,0,0">
<TextBox Grid.Column="0"
Text="{Binding StatusMessage}"
IsReadOnly="True"
AcceptsReturn="True"
TextWrapping="Wrap"
BorderThickness="0"
BorderBrush="Transparent"
Padding="0"
Background="Transparent"
VerticalAlignment="Center" />
<postitControls:StatusBar Grid.Column="0"
DataContext="{Binding ActionStatus}" />
<ProgressBar Grid.Column="1" Width="120" IsIndeterminate="True" IsVisible="{Binding IsBusy}" />
</Grid>
</Grid>

View file

@ -1,6 +1,7 @@
<ContentPage
xmlns="https://github.com/avaloniaui"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:postitControls="using:PostIt.Controls"
x:Class="PostIt.Views.CirclesPage"
xmlns:vm="using:PostIt.ViewModels"
xmlns:dtos="using:Yavsc.Api.Client.Dtos"
@ -101,8 +102,8 @@
<!-- Status bar -->
<Grid Grid.Row="2" ColumnDefinitions="*,Auto" Margin="12,0,12,12">
<TextBlock Grid.Column="0" Text="{Binding StatusMessage}"
VerticalAlignment="Center"/>
<postitControls:StatusBar Grid.Column="0"
DataContext="{Binding ActionStatus}" />
<ProgressBar Grid.Column="1" IsIndeterminate="True"
IsVisible="{Binding IsBusy}"
Width="120"/>

View file

@ -1,6 +1,7 @@
<ContentPage xmlns="https://github.com/avaloniaui"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:vm="using:PostIt.ViewModels"
xmlns:postitControls="using:PostIt.Controls"
xmlns:wf="using:Yavsc.Abstract.Workflow"
x:Class="PostIt.Views.CommandFormsPage"
x:DataType="vm:CommandFormsPageViewModel"
@ -41,16 +42,8 @@
<Button Grid.Column="4"
Content="Demandes en cours (lecture seule)"
Command="{Binding OpenOngoingQueriesCommand}" />
<TextBox Grid.Column="6"
Text="{Binding StatusMessage}"
IsReadOnly="True"
AcceptsReturn="True"
TextWrapping="Wrap"
BorderThickness="0"
BorderBrush="Transparent"
Padding="0"
Background="Transparent"
VerticalAlignment="Center" />
<postitControls:StatusBar Grid.Column="6"
DataContext="{Binding ActionStatus}" />
</Grid>
</Grid>
</ContentPage>

View file

@ -3,6 +3,7 @@
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:cvm="using:PostIt.ViewModels.Commands"
xmlns:postitControls="using:PostIt.Controls"
mc:Ignorable="d" d:DesignWidth="800" d:DesignHeight="450"
x:Class="PostIt.Views.Commands.BrushPage"
@ -93,16 +94,8 @@
Content="{Binding SubmitLabel}"
Command="{Binding SubmitCommand}"
IsEnabled="{Binding IsSupported}" />
<TextBox Grid.Column="2"
Text="{Binding StatusMessage}"
IsReadOnly="True"
AcceptsReturn="True"
TextWrapping="Wrap"
BorderThickness="0"
BorderBrush="Transparent"
Padding="0"
Background="Transparent"
VerticalAlignment="Center" />
<postitControls:StatusBar Grid.Column="2"
DataContext="{Binding ActionStatus}" />
<ProgressBar Grid.Column="3"
Width="120"
IsIndeterminate="True"

View file

@ -1,6 +1,7 @@
<ContentPage xmlns="https://github.com/avaloniaui"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:cvm="using:PostIt.ViewModels.Commands"
xmlns:postitControls="using:PostIt.Controls"
x:Class="PostIt.Views.Commands.RdvPage"
x:DataType="cvm:RdvViewModel"
Header="Commande billing">
@ -71,16 +72,8 @@
Content="{Binding SubmitLabel}"
Command="{Binding SubmitCommand}"
IsEnabled="{Binding IsSupported}" />
<TextBox Grid.Column="2"
Text="{Binding StatusMessage}"
IsReadOnly="True"
AcceptsReturn="True"
TextWrapping="Wrap"
BorderThickness="0"
BorderBrush="Transparent"
Padding="0"
Background="Transparent"
VerticalAlignment="Center" />
<postitControls:StatusBar Grid.Column="2"
DataContext="{Binding ActionStatus}" />
<ProgressBar Grid.Column="3"
Width="120"
IsIndeterminate="True"

View file

@ -3,6 +3,7 @@
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:vm="using:PostIt.ViewModels"
xmlns:postitControls="using:PostIt.Controls"
xmlns:models="using:Yavsc.Blogspot"
xmlns:views="using:PostIt.Views"
xmlns:AvaloniaEdit="clr-namespace:AvaloniaEdit;assembly=AvaloniaEdit"
@ -104,7 +105,8 @@
VerticalAlignment="Stretch">
</TextBox>
<TextBlock Grid.Row="3" Text="{Binding StatusMessage}" Foreground="Gray" />
<postitControls:StatusBar Grid.Row="3"
DataContext="{Binding ActionStatus}" />
</Grid>
</Border>

View file

@ -3,6 +3,7 @@
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
x:Class="PostIt.Views.PostAclDialog"
xmlns:vm="using:PostIt.ViewModels"
xmlns:postitControls="using:PostIt.Controls"
xmlns:dtos="using:Yavsc.Api.Client.Dtos"
x:DataType="vm:PostAclDialogViewModel"
>
@ -53,8 +54,8 @@
<!-- Status bar -->
<Grid Grid.Row="3" ColumnDefinitions="*,Auto">
<TextBlock Grid.Column="0" Text="{Binding StatusMessage}"
VerticalAlignment="Center"/>
<postitControls:StatusBar Grid.Column="0"
DataContext="{Binding ActionStatus}" />
<ProgressBar Grid.Column="1" IsIndeterminate="True"
IsVisible="{Binding IsBusy}"
Width="120"/>

View file

@ -2,6 +2,7 @@
xmlns="https://github.com/avaloniaui"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:controls="cl:avalonia.Controls"
xmlns:postitControls="using:PostIt.Controls"
x:Class="PostIt.Views.SettingsPage"
xmlns:vm="using:PostIt.ViewModels"
x:DataType="vm:Settings"
@ -51,9 +52,7 @@
Opacity="0.8"
TextWrapping="Wrap" />
<TextBlock x:Name="AvatarUploadStatusText"
Text=""
TextWrapping="Wrap" />
<postitControls:StatusBar DataContext="{Binding ActionStatus}"/>
<StackPanel Orientation="Horizontal" HorizontalAlignment="Right">
<Button x:Name="ChooseAvatarButton"

View file

@ -6,10 +6,10 @@ using System.Linq;
using System.Threading;
using System.Threading.Tasks;
using Avalonia.Controls;
using Avalonia.Media;
using Avalonia.Platform.Storage;
using Microsoft.Extensions.DependencyInjection;
using PostIt.Services;
using PostIt.ViewModels;
namespace PostIt.Views;
public partial class SettingsPage: ContentPage
@ -28,12 +28,12 @@ public partial class SettingsPage: ContentPage
{
var statusVersion = Interlocked.Increment(ref _avatarStatusVersion);
ChooseAvatarButton.IsEnabled = false;
SetAvatarStatus("Sélection d'un fichier avatar...", Brushes.Gray);
SetAvatarStatus("Selection d'un fichier avatar...", StatusSeverity.Info);
var topLevel = TopLevel.GetTopLevel(this);
if (topLevel is null)
{
SetAvatarStatus("Impossible d'accéder à la fenêtre active.", Brushes.IndianRed);
SetAvatarStatus("Impossible d'acceder a la fenetre active.", StatusSeverity.Error);
ChooseAvatarButton.IsEnabled = true;
return;
}
@ -54,27 +54,28 @@ public partial class SettingsPage: ContentPage
var file = files.FirstOrDefault();
if (file is null)
{
SetAvatarStatus("Upload annulé.", Brushes.Gray);
SetAvatarStatus("Upload annule.", StatusSeverity.Warning);
ChooseAvatarButton.IsEnabled = true;
return;
}
try
{
SetAvatarStatus("Upload avatar en cours...", Brushes.Gray);
SetAvatarStatus("Upload avatar en cours...", StatusSeverity.Info);
await using var stream = await file.OpenReadAsync();
var api = ((App)App.Current!).ServiceProvider!.GetRequiredService<YavscApiClient>();
var message = await api.SetAvatarAsync(stream, file.Name, GetMimeType(file.Name));
SetAvatarStatus(string.IsNullOrWhiteSpace(message)
? "Avatar mis à jour."
: message, Brushes.ForestGreen);
? "Avatar mis a jour."
: message,
StatusSeverity.Info);
_ = ClearSuccessStatusLaterAsync(statusVersion);
}
catch (Exception ex)
{
SetAvatarStatus($"Échec upload avatar: {ex.Message}", Brushes.IndianRed);
SetAvatarStatus($"Echec upload avatar: {ex.Message}", StatusSeverity.Error);
Console.Error.WriteLine($"🩎 Avatar upload failed: {ex.Message}");
}
finally
@ -89,16 +90,15 @@ public partial class SettingsPage: ContentPage
if (statusVersion != _avatarStatusVersion)
return;
if (AvatarUploadStatusText.Foreground == Brushes.ForestGreen)
{
SetAvatarStatus($"Avatar prêt. Formats supportés: {AcceptedAvatarFormats}. Taille max: {MaxAvatarSizeMegabytes} MB.", Brushes.Gray);
}
SetAvatarStatus($"Avatar pret. Formats supportes: {AcceptedAvatarFormats}. Taille max: {MaxAvatarSizeMegabytes} MB.", StatusSeverity.Info);
}
private void SetAvatarStatus(string message, IBrush color)
private void SetAvatarStatus(string message, StatusSeverity severity)
{
AvatarUploadStatusText.Foreground = color;
AvatarUploadStatusText.Text = message;
if (DataContext is Settings settings)
{
settings.SetActionStatus(message, severity);
}
}
private static string GetMimeType(string fileName)

View file

@ -3,6 +3,7 @@
xmlns:d="http://github.com/avaloniaui/avalonia"
xmlns:vm="using:PostIt.ViewModels"
xmlns:controls="using:PostIt.Controls"
xmlns:postitControls="using:PostIt.Controls"
x:Class="PostIt.Views.SignaturePage"
x:DataType="vm:SignaturePageViewModel"
HorizontalAlignment="Stretch"
@ -59,10 +60,8 @@
<Button Content="Capturer" Command="{Binding CaptureAsync}" />
</StackPanel>
<TextBlock Grid.Row="3"
Text="{Binding StatusMessage}"
Foreground="Gray"
TextWrapping="Wrap" />
<postitControls:StatusBar Grid.Row="3"
DataContext="{Binding ActionStatus}" />
<TextBlock Grid.Row="4"
FontSize="11"

View file

@ -1,3 +1,5 @@
#nullable enable annotations
using Yavsc.Services;
namespace Yavsc.Billing

View file

@ -1,3 +1,5 @@
#nullable enable annotations
namespace Yavsc.Blogspot;
/// <summary>

View file

@ -1,3 +1,5 @@
#nullable enable annotations
using Yavsc.Abstract.Identity.Security;
using System.Text.Json.Serialization;

View file

@ -1,3 +1,5 @@
#nullable enable annotations

View file

@ -1,3 +1,5 @@
#nullable enable annotations
namespace Yavsc.Abstract.Chat
{
public static class ChatHubConstants

View file

@ -1,3 +1,5 @@
#nullable enable annotations
using System.ComponentModel.DataAnnotations;
namespace Yavsc.Abstract.Chat

View file

@ -1,4 +1,6 @@
using System.Text;
#nullable enable annotations
using System.Text;
using Yavsc.ViewModels.UserFiles;
namespace Yavsc.Server.Helpers

View file

@ -1,3 +1,5 @@
#nullable enable annotations
namespace Yavsc.Abstract.Helpers
{
public enum ErrorCode {

View file

@ -1,3 +1,5 @@
#nullable enable annotations
using Yavsc.Server.Helpers;
namespace Yavsc.ViewModels.UserFiles

View file

@ -1,3 +1,5 @@
#nullable enable annotations
//
// GDate.cs
//

View file

@ -1,3 +1,5 @@
#nullable enable annotations
//
// MessageWithPayloadResponse.cs
//

View file

@ -1,3 +1,5 @@
#nullable enable annotations
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
using Yavsc.Attributes.Validation;

View file

@ -1,4 +1,6 @@
namespace Yavsc.Abstract.Identity
#nullable enable annotations
namespace Yavsc.Abstract.Identity
{
public interface IApplicationUser
{

View file

@ -1,3 +1,5 @@
#nullable enable annotations
namespace Yavsc.Abstract.Identity
{
/// <summary>

View file

@ -1,4 +1,6 @@
using Yavsc.Abstract.Identity;
#nullable enable annotations
using Yavsc.Abstract.Identity;
namespace Yavsc.Interfaces
{

View file

@ -1,3 +1,5 @@
#nullable enable annotations
using Yavsc.Interfaces;

View file

@ -1,3 +1,5 @@
#nullable enable annotations
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;

View file

@ -1,3 +1,5 @@
#nullable enable annotations
//
// BookQueryEvent.cs
//

View file

@ -1,3 +1,5 @@
#nullable enable annotations
using Yavsc.Abstract.Identity;
using Yavsc.Models.Relationship;

View file

@ -1,4 +1,6 @@
// Copyright (C) 2016 Paul Schneider
#nullable enable annotations
// Copyright (C) 2016 Paul Schneider
//
// This file is part of yavsc.
//

View file

@ -1,3 +1,5 @@
#nullable enable annotations
namespace Yavsc.Workflow
{
public interface IPerformerProfile

View file

@ -1,3 +1,5 @@
#nullable enable annotations
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;