LANCommander/LANCommander.Server/UI/Pages/FirstTimeSetup/Metadata.razor
2026-05-07 01:11:41 -05:00

94 lines
3.5 KiB
Text

@page "/FirstTimeSetup/Metadata"
@using LANCommander.Server.Settings
@using Microsoft.Extensions.Options
@layout FirstTimeSetupLayout
@inject SetupService SetupService
@inject SettingsProvider<Settings> SettingsProvider
@inject IOptions<Settings> Settings
@inject NavigationManager NavigationManager
@inject ILogger<Index> Logger
<PageTitle>Metadata Connections - First Time Setup</PageTitle>
<Form Model="@Settings.Value" Loading="Loading" OnFinish="ValidateMetadataConnections" Layout="FormLayout.Vertical">
<FormItem>
LANCommander has the ability to pull metadata and media from external sources. Required credentials can be added here, or can be set later in Settings.
</FormItem>
<Divider Text="LANCommander HQ (Recommended)" />
<p>
<Text Type="TextElementType.Secondary">LANCommander HQ provides access to multiple metadata and media providers through a single connection. Connect your account in <a href="/Settings/Integrations/HQ">Settings &gt; Integrations &gt; LANCommander HQ</a> after setup.</Text>
</p>
<Divider Text="IGDB Credentials" />
<p>
<Text Type="TextElementType.Secondary">In order to use IGDB metadata, you need a Twitch developer account. <a href="https://api-docs.igdb.com/#account-creation" target="_blank">Click here</a> for more details.</Text>
</p>
<FormItem Label="Client ID">
<Input @bind-Value="context.Server.IGDB.ClientId" />
</FormItem>
<FormItem Label="Client Secret">
<InputPassword @bind-Value="context.Server.IGDB.ClientSecret" AutoComplete="false" />
</FormItem>
<Divider Text="SteamGridDB Credentials" />
<p>
<Text Type="TextElementType.Secondary">In order to automatically search SteamGridDB for media, you need an API key. <a href="https://www.steamgriddb.com/profile/preferences/api" target="_blank">Click here</a> to get your key.</Text>
</p>
<FormItem Label="API Key">
<InputPassword @bind-Value="context.Server.Media.SteamGridDbApiKey" AutoComplete="false" />
</FormItem>
<FormItem>
<GridRow Justify="RowJustify.End" Style="margin-top: 16px;">
<GridCol>
<Button Type="ButtonType.Primary" HtmlType="submit">
Save
</Button>
</GridCol>
</GridRow>
</FormItem>
</Form>
@code {
[CascadingParameter]
FirstTimeSetupLayout Layout { get; set; }
bool Loading = false;
protected override async Task OnInitializedAsync()
{
var isSetupInitialized = await SetupService.IsSetupInitialized();
if (isSetupInitialized)
{
NavigationManager.NavigateTo("/");
return;
}
await Layout.ChangeCurrentStep(FirstTimeSetupStep.Metadata);
SettingsProvider.Update(s =>
{
s.Server.IGDB.ClientId = Settings.Value.Server.IGDB.ClientId;
s.Server.IGDB.ClientSecret = Settings.Value.Server.IGDB.ClientSecret;
s.Server.Media.SteamGridDbApiKey = Settings.Value.Server.Media.SteamGridDbApiKey;
});
}
async Task ValidateMetadataConnections()
{
SettingsProvider.Update(s =>
{
s.Server.IGDB.ClientId = Settings.Value.Server.IGDB.ClientId;
s.Server.IGDB.ClientSecret = Settings.Value.Server.IGDB.ClientSecret;
s.Server.Media.SteamGridDbApiKey = Settings.Value.Server.Media.SteamGridDbApiKey;
});
NavigationManager.NavigateTo("/FirstTimeSetup/Administrator");
}
}