Add settings page for media

save-path-regex v0.2.1
Pat Hartl 2023-11-03 01:49:43 -05:00
parent 1689cab3b3
commit 540e76968b
2 changed files with 68 additions and 0 deletions

View File

@ -0,0 +1,67 @@
@page "/Settings/Media"
@using LANCommander.Components.FileManagerComponents;
@using LANCommander.Models;
@layout SettingsLayout
@inject SettingService SettingService
@inject IMessageService MessageService
@attribute [Authorize(Roles = "Administrator")]
<PageHeader Title="Media" />
<div style="padding: 0 24px;">
<Form Model="Settings" Layout="@FormLayout.Vertical">
<FormItem Label="Storage Path">
<FilePicker Root="@RootPath" EntrySelectable="x => x is FileManagerDirectory" @bind-Value="@context.Media.StoragePath" OkText="Select Path" Title="Choose Path" OnSelected="OnPathSelected" />
</FormItem>
<FormItem Label="Max Size (MB)">
<AntDesign.InputNumber @bind-Value="context.Media.MaxSize" Min="1" DefaultValue="25" />
</FormItem>
<Divider Text="SteamGridDB Credentials" />
<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>
<FormItem Label="API Key">
<InputPassword @bind-Value="context.Media.SteamGridDbApiKey" />
</FormItem>
<FormItem>
<Button OnClick="Save" Type="@ButtonType.Primary">Save</Button>
</FormItem>
</Form>
</div>
@code {
LANCommanderSettings Settings;
string RootPath = Path.GetPathRoot(Directory.GetCurrentDirectory());
protected override async Task OnInitializedAsync()
{
Settings = SettingService.GetSettings();
}
private void Save()
{
try
{
SettingService.SaveSettings(Settings);
MessageService.Success("Settings saved!");
}
catch
{
MessageService.Error("An unknown error occurred.");
}
}
private void OnPathSelected(string path)
{
var appPath = Directory.GetCurrentDirectory();
if (path != null && path.StartsWith(appPath))
path = path.Substring(appPath.Length).TrimStart(Path.DirectorySeparatorChar).TrimEnd(Path.DirectorySeparatorChar);
Settings.Archives.StoragePath = path;
}
}

View File

@ -10,6 +10,7 @@
<MenuItem RouterLink="/Settings/Authentication">Authentication</MenuItem>
<MenuItem RouterLink="/Settings/UserSaves">User Saves</MenuItem>
<MenuItem RouterLink="/Settings/Archives">Archives</MenuItem>
<MenuItem RouterLink="/Settings/Media">Media</MenuItem>
<MenuItem RouterLink="/Settings/IPXRelay">IPX Relay</MenuItem>
<MenuItem RouterLink="/Settings/Beacon">Beacon</MenuItem>
<MenuItem RouterLink="/Settings/Tools" RouterMatch="@NavLinkMatch.Prefix">Tools</MenuItem>