Skip to content

Commit

Permalink
Add logout button
Browse files Browse the repository at this point in the history
  • Loading branch information
frederikstonge committed Feb 10, 2023
1 parent 9e85dcc commit f23d2cb
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/PuppetMaster.Client.UI/PuppetMaster.Client.UI.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<OutputType>WinExe</OutputType>
<TargetFramework>net7.0-windows</TargetFramework>
<RuntimeIdentifier>win-x86</RuntimeIdentifier>
<Version>1.0.1</Version>
<Version>1.0.2</Version>
<CodeAnalysisRuleSet>../../stylecop.ruleset</CodeAnalysisRuleSet>
<Nullable>enable</Nullable>
<UseWPF>true</UseWPF>
Expand Down
9 changes: 9 additions & 0 deletions src/PuppetMaster.Client.UI/ViewModels/UpdateUserViewModel.cs
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
using System.ComponentModel.DataAnnotations;
using System.Threading;
using System.Threading.Tasks;
using System.Windows;
using PuppetMaster.Client.UI.Facades;
using PuppetMaster.Client.UI.Models.Requests;
using PuppetMaster.Client.UI.Properties;

namespace PuppetMaster.Client.UI.ViewModels
{
Expand Down Expand Up @@ -72,6 +74,13 @@ public string? LastName

public bool CanUpdateUser => !HasErrors && !IsLoading;

public void Logout()
{
Settings.Default.BackendTokenResponse = null;
Settings.Default.Save();
Application.Current.Shutdown();
}

public async Task UpdateUser()
{
SuccessMessage = null;
Expand Down
2 changes: 2 additions & 0 deletions src/PuppetMaster.Client.UI/Views/UpdateUserView.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -29,13 +29,15 @@
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition></ColumnDefinition>
<ColumnDefinition></ColumnDefinition>
</Grid.ColumnDefinitions>
<Button Name="UpdateUser" Margin="4" Grid.Column="0">
<StackPanel>
<TextBlock mah:VisibilityHelper.IsCollapsed="{Binding IsLoading}">Update user</TextBlock>
<mah:ProgressRing mah:VisibilityHelper.IsVisible="{Binding IsLoading}" Height="16" Width="16" Foreground="{DynamicResource AccentColorBrush}" IsActive="True" />
</StackPanel>
</Button>
<Button Name="Logout" Margin="4" Grid.Column="1">Logout and Exit</Button>
</Grid>
</StackPanel>
</UserControl>

0 comments on commit f23d2cb

Please sign in to comment.