70 lines
3.2 KiB
Plaintext
70 lines
3.2 KiB
Plaintext
@using BTCPayApp.Core.Auth
|
|
@using BTCPayApp.Core.BTCPayServer
|
|
@using BTCPayApp.Core.Contracts
|
|
@using BTCPayApp.Core.Wallet
|
|
@using BTCPayApp.UI.Features
|
|
@inject IState<RootState> State
|
|
@inject IAccountManager AccountManager
|
|
@inject NavigationManager NavigationManager
|
|
@inherits Fluxor.Blazor.Web.Components.FluxorComponent
|
|
|
|
<div @attributes="InputAttributes" class="@CssClass">
|
|
@if (SetupStateOverall() == SetupState.Undetermined)
|
|
{
|
|
<LoadingIndicator />
|
|
}
|
|
else
|
|
{
|
|
<a href="@Routes.Settings">
|
|
<span class="btcpay-status btcpay-status--@(SetupStateOverall() == SetupState.Completed ? "enabled" : (SetupStateOverall() == SetupState.Failed ? "disabled" : "pending"))"></span>
|
|
</a>
|
|
}
|
|
</div>
|
|
|
|
@code {
|
|
[Parameter(CaptureUnmatchedValues = true)]
|
|
public Dictionary<string, object>? InputAttributes { get; set; }
|
|
|
|
public SetupState SetupStateConnection() {
|
|
return State.Value.ConnectionState switch
|
|
{
|
|
BTCPayConnectionState.Init => SetupState.Pending,
|
|
BTCPayConnectionState.WaitingForAuth => SetupState.Pending,
|
|
BTCPayConnectionState.Connecting => SetupState.Pending,
|
|
BTCPayConnectionState.Syncing => SetupState.Pending,
|
|
BTCPayConnectionState.ConnectedFinishedInitialSync => SetupState.Pending,
|
|
BTCPayConnectionState.ConnectedAsPrimary => SetupState.Completed,
|
|
BTCPayConnectionState.ConnectedAsSecondary => SetupState.Completed,
|
|
BTCPayConnectionState.Disconnected => SetupState.Failed,
|
|
_ => SetupState.Undetermined
|
|
};
|
|
}
|
|
|
|
public SetupState SetupStateOverall() {
|
|
if (SetupStateOnchain() == SetupState.Undetermined || SetupStateLightning() == SetupState.Undetermined) return SetupState.Undetermined;
|
|
if (SetupStateOnchain() == SetupState.Failed || SetupStateLightning() == SetupState.Failed) return SetupState.Failed;
|
|
return SetupStateOnchain() == SetupState.Completed && SetupStateLightning() == SetupState.Completed && SetupStateAccount() == SetupState.Completed
|
|
? SetupState.Completed
|
|
: SetupState.Pending;
|
|
}
|
|
|
|
public SetupState SetupStateAccount() {
|
|
return string.IsNullOrEmpty(AccountManager.CurrentStore?.Id) ? SetupState.Pending : SetupState.Completed;
|
|
}
|
|
|
|
public SetupState SetupStateOnchain() {
|
|
if (SetupStateConnection() != SetupState.Completed ||
|
|
State.Value.OnchainWalletState is OnChainWalletState.Loading) return SetupState.Undetermined;
|
|
return State.Value.OnchainWalletState == OnChainWalletState.Loaded ? SetupState.Completed : SetupState.Pending;
|
|
}
|
|
|
|
public SetupState SetupStateLightning() {
|
|
if (SetupStateConnection() != SetupState.Completed ||
|
|
State.Value.LightningNodeState is LightningNodeState.Loading) return SetupState.Undetermined;
|
|
if (State.Value.LightningNodeState is LightningNodeState.Error or LightningNodeState.Stopped) return SetupState.Failed;
|
|
return State.Value.LightningNodeState == LightningNodeState.Loaded ? SetupState.Completed : SetupState.Pending;
|
|
}
|
|
|
|
private string CssClass => $"status {(InputAttributes?.ContainsKey("class") is true ? InputAttributes["class"] : "")}".Trim();
|
|
}
|