Settings - Added account management

This commit is contained in:
RobertBeekman committed 2024-02-08 20:58:16 +01:00
1 parent 3952a268d1
commit a2fe5d5d08
42 files changed
+681 -30

No files matched your search

@@ -34,8 +34,8 @@
Name="UserMenu">
<Ellipse.ContextFlyout>
<Flyout>
<Grid ColumnDefinitions="Auto,*" RowDefinitions="*,*,*" MinWidth="300">
<Ellipse Grid.Column="0" Grid.RowSpan="3" Height="50" Width="50" Margin="0 0 8 0" VerticalAlignment="Top">
<Grid ColumnDefinitions="Auto,*" RowDefinitions="*,*,*,*" MinWidth="300">
<Ellipse Grid.Column="0" Grid.RowSpan="4" Height="50" Width="50" Margin="0 0 8 0" VerticalAlignment="Top">
<Ellipse.Fill>
<ImageBrush asyncImageLoader:ImageBrushLoader.Source="{CompiledBinding AvatarUrl}" />
</Ellipse.Fill>
@@ -46,10 +46,20 @@
IsVisible="{CompiledBinding AllowLogout}"
Grid.Column="1"
Grid.Row="2"
Margin="-8 4 0 0"
Padding="6 4"
Click="Signout_OnClick">
Sign out
</controls:HyperlinkButton>
<controls:HyperlinkButton
IsVisible="{CompiledBinding AllowLogout}"
Grid.Column="1"
Grid.Row="3"
Margin="-8 0 0 0"
Padding="6 4"
Click="Button_OnClick">
Sign out
Click="Manage_OnClick">
Manage account
</controls:HyperlinkButton>
</Grid>
</Flyout>
@@ -13,9 +13,15 @@ public partial class CurrentUserView : ReactiveUserControl<CurrentUserViewModel>
InitializeComponent();
}
private void Button_OnClick(object? sender, RoutedEventArgs e)
private void Signout_OnClick(object? sender, RoutedEventArgs e)
{
UserMenu.ContextFlyout?.Hide();
ViewModel?.Logout();
}
private void Manage_OnClick(object? sender, RoutedEventArgs e)
{
UserMenu.ContextFlyout?.Hide();
ViewModel?.ManageAccount();
}
}
@@ -6,6 +6,7 @@ using System.Reactive.Disposables;
using System.Threading;
using System.Threading.Tasks;
using Artemis.UI.Shared;
using Artemis.UI.Shared.Routing;
using Artemis.UI.Shared.Services;
using Artemis.WebClient.Workshop;
using Artemis.WebClient.Workshop.Services;
@@ -23,6 +24,7 @@ public partial class CurrentUserViewModel : ActivatableViewModelBase
private readonly ObservableAsPropertyHelper<bool> _isAnonymous;
private readonly ILogger _logger;
private readonly IWindowService _windowService;
private readonly IRouter _router;
[Notify] private bool _allowLogout = true;
[Notify(Setter.Private)] private Bitmap? _avatar;
[Notify(Setter.Private)] private string? _email;
@@ -31,11 +33,12 @@ public partial class CurrentUserViewModel : ActivatableViewModelBase
[Notify(Setter.Private)] private string? _userId;
[Notify(Setter.Private)] private string? _avatarUrl;
public CurrentUserViewModel(ILogger logger, IAuthenticationService authenticationService, IWindowService windowService)
public CurrentUserViewModel(ILogger logger, IAuthenticationService authenticationService, IWindowService windowService, IRouter router)
{
_logger = logger;
_authenticationService = authenticationService;
_windowService = windowService;
_router = router;
Login = ReactiveCommand.CreateFromTask(ExecuteLogin);
_isAnonymous = this.WhenAnyValue(vm => vm.Loading, vm => vm.Name, (l, n) => l || n == null).ToProperty(this, vm => vm.IsAnonymous);
@@ -92,4 +95,9 @@ public partial class CurrentUserViewModel : ActivatableViewModelBase
Email = _authenticationService.Claims.FirstOrDefault(c => c.Type == "email")?.Value;
AvatarUrl = $"{WorkshopConstants.AUTHORITY_URL}/user/avatar/{UserId}";
}
public void ManageAccount()
{
_router.Navigate("settings/account");
}
}