LANCommander/LANCommander.Server/UI/Pages/Settings/Integrations/SteamGridDb.razor

44 lines
1.4 KiB
Text

@page "/Settings/Integrations/SteamGridDB"
@using LANCommander.Server.Settings
@using Microsoft.Extensions.Options
@inject IOptions<Settings> Settings
@inject SettingsProvider<Settings> SettingsProvider
@inject IMessageService MessageService
@inject ILogger<SteamGridDb> Logger
@attribute [Authorize(Roles = RoleService.AdministratorRoleName)]
<PageHeader Title="SteamGridDB">
<PageHeaderExtra>
<Button OnClick="Save" Type="@ButtonType.Primary">Save</Button>
</PageHeaderExtra>
</PageHeader>
<PageContent>
<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>
<Form Model="Settings.Value" Layout="@FormLayout.Vertical">
<FormItem Label="API Key">
<InputPassword @bind-Value="context.Server.Media.SteamGridDbApiKey"/>
</FormItem>
</Form>
</PageContent>
@code {
void Save()
{
try
{
SettingsProvider.Update(s =>
{
s.Server.Media.SteamGridDbApiKey = Settings.Value.Server.Media.SteamGridDbApiKey;
});
MessageService.Success("Settings saved!");
}
catch (Exception ex)
{
MessageService.Error("An unknown error occurred.");
Logger.LogError(ex, "An unknown error occurred.");
}
}
}