generated from nventive/Template
-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
7bbf469
commit b8cc5cb
Showing
21 changed files
with
385 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
# Kill Switch | ||
|
||
The kill switch feature is for when you want to temporarily lock the user out of the app. | ||
This could be used for example when the server is down for some time, to avoid the user getting a ton of errors and getting reports from users. | ||
|
||
To trigger the kill switch, we suscribe to the `KillSwitchActivationChanged` `event` from the `KillSwitchService` in the [CoreStartup](../src/app/ApplicationTemplate.Presentation/CoreStartup.cs#L223). | ||
|
||
If the kill switch is activated, the user is brought to the `KillSwitchPage` where he can see a message that tells him the app is currently unavailable. If the kill switch is deactivated afterwards, the user is brought back to the initial navigation flow, which means he will be in the login page if he is not connected and to the home page if he is connected. |
17 changes: 17 additions & 0 deletions
17
src/app/ApplicationTemplate.Access/ApiClients/KillSwitch/IKillSwitchRepository.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
using System; | ||
|
||
namespace ApplicationTemplate.DataAccess; | ||
|
||
/// <summary> | ||
/// Interface for the repository that gets when the kill switch is activated. | ||
/// </summary> | ||
public interface IKillSwitchRepository | ||
{ | ||
/// <summary> | ||
/// Observes and reports the activation or deactivation of the kill switch. | ||
/// </summary> | ||
/// <returns> | ||
/// An <see cref="IObservable{Boolean}"/> that indicates whether the kill switch is activated or not. | ||
/// </returns> | ||
public IObservable<bool> ObserveKillSwitchActivation(); | ||
} |
33 changes: 33 additions & 0 deletions
33
src/app/ApplicationTemplate.Access/ApiClients/KillSwitch/KillSwitchRepositoryMock.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
using System; | ||
using System.Reactive.Subjects; | ||
using DynamicData; | ||
|
||
namespace ApplicationTemplate.DataAccess; | ||
|
||
/// <summary> | ||
/// Mock implementation of the kill switch repository. | ||
/// </summary> | ||
public sealed class KillSwitchRepositoryMock : IKillSwitchRepository, IDisposable | ||
{ | ||
private readonly Subject<bool> _killSwitchActivatedSubject = new(); | ||
private bool _killSwitchActivated = false; | ||
|
||
/// <inheritdoc/> | ||
public IObservable<bool> ObserveKillSwitchActivation() => _killSwitchActivatedSubject; | ||
|
||
/// <summary> | ||
/// Change the kill switch activation status. | ||
/// </summary> | ||
public void ChangeKillSwitchActivation() | ||
{ | ||
_killSwitchActivated = !_killSwitchActivated; | ||
|
||
_killSwitchActivatedSubject.OnNext(_killSwitchActivated); | ||
} | ||
|
||
/// <inheritdoc/> | ||
public void Dispose() | ||
{ | ||
_killSwitchActivatedSubject.Dispose(); | ||
} | ||
} |
17 changes: 17 additions & 0 deletions
17
src/app/ApplicationTemplate.Business/KillSwitch/IKillSwitchService.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
using System; | ||
|
||
namespace ApplicationTemplate.Business; | ||
|
||
/// <summary> | ||
/// Service that handles the kill switch. | ||
/// </summary> | ||
public interface IKillSwitchService | ||
{ | ||
/// <summary> | ||
/// Observes and reports the activation or deactivation of the kill switch. | ||
/// </summary> | ||
/// <returns> | ||
/// An <see cref="IObservable{Boolean}"/> that indicates whether the kill switch is activated or not. | ||
/// </returns> | ||
public IObservable<bool> ObserveKillSwitchActivation(); | ||
} |
25 changes: 25 additions & 0 deletions
25
src/app/ApplicationTemplate.Business/KillSwitch/KillSwitchService.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
using System; | ||
using System.Reactive.Linq; | ||
using ApplicationTemplate.DataAccess; | ||
|
||
namespace ApplicationTemplate.Business; | ||
|
||
/// <summary> | ||
/// Implementation of the IKillSwitchService. | ||
/// </summary> | ||
public class KillSwitchService : IKillSwitchService | ||
{ | ||
private readonly IKillSwitchRepository _killSwitchRepository; | ||
|
||
/// <summary> | ||
/// Initializes a new instance of the <see cref="KillSwitchService"/> class. | ||
/// </summary> | ||
/// <param name="killSwitchRepository">The <see cref="IKillSwitchRepository"/>.</param> | ||
public KillSwitchService(IKillSwitchRepository killSwitchRepository) | ||
{ | ||
_killSwitchRepository = killSwitchRepository; | ||
} | ||
|
||
/// <inheritdoc/> | ||
public IObservable<bool> ObserveKillSwitchActivation() => _killSwitchRepository.ObserveKillSwitchActivation(); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
8 changes: 8 additions & 0 deletions
8
src/app/ApplicationTemplate.Presentation/ViewModels/KillSwitchPageViewModel.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
namespace ApplicationTemplate.Presentation; | ||
|
||
/// <summary> | ||
/// ViewModel for the kill switch page. | ||
/// </summary> | ||
public sealed class KillSwitchPageViewModel : ViewModel | ||
{ | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
19 changes: 19 additions & 0 deletions
19
src/app/ApplicationTemplate.Shared.Views/Content/KillSwitch/KillSwitchPage.xaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
<Page x:Class="ApplicationTemplate.Views.Content.KillSwitchPage" | ||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" | ||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" | ||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008" | ||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" | ||
Background="{ThemeResource ApplicationPageBackgroundThemeBrush}" | ||
mc:Ignorable="d"> | ||
|
||
<Grid> | ||
|
||
<TextBlock x:Uid="KillSwitchMessage" | ||
HorizontalAlignment="Center" | ||
VerticalAlignment="Center" | ||
FontSize="24" | ||
Text="The app is not available at the moment, please come back later" | ||
Margin="24" /> | ||
|
||
</Grid> | ||
</Page> |
12 changes: 12 additions & 0 deletions
12
src/app/ApplicationTemplate.Shared.Views/Content/KillSwitch/KillSwitchPage.xaml.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
using Microsoft.UI.Xaml.Controls; | ||
|
||
namespace ApplicationTemplate.Views.Content | ||
{ | ||
public sealed partial class KillSwitchPage : Page | ||
{ | ||
public KillSwitchPage() | ||
{ | ||
this.InitializeComponent(); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.