Add snippets path input to settings

This commit is contained in:
Pat Hartl 2026-03-04 23:49:57 -06:00
parent f318348438
commit 2a604eec74

View file

@ -16,12 +16,15 @@
<PageContent>
<Form Model="Settings.Value" Layout="@FormLayout.Vertical">
<FormItem Label="Storage Path">
<FilePicker Root="@RootPath" EntrySelectable="x => x is FileManagerDirectory" @bind-Value="@context.Server.Scripts.Snippets.StoragePath" OkText="Select Path" Title="Choose Path" OnSelected="OnPathSelected" />
</FormItem>
<FormItem Label="Automatically Repackage">
<Switch @bind-Checked="context.Server.Scripts.EnableAutomaticRepackaging" />
<Switch @bind-Checked="context.Server.Scripts.EnableAutomaticRepackaging"/>
</FormItem>
<FormItem Label="Repackage Every">
<Flex Direction="FlexDirection.Horizontal" Gap="FlexGap.Small" Align="FlexAlign.Center">
<AntDesign.InputNumber @bind-Value="context.Server.Scripts.RepackageEvery" Min="1" DefaultValue="24" />
<AntDesign.InputNumber @bind-Value="context.Server.Scripts.RepackageEvery" Min="1" DefaultValue="24"/>
<Text>Hours</Text>
</Flex>
</FormItem>
@ -33,6 +36,8 @@
</PageContent>
@code {
string RootPath = Path.GetPathRoot(Directory.GetCurrentDirectory());
void Save()
{
try
@ -50,4 +55,14 @@
Logger.LogError(ex, "An unknown error occurred.");
}
}
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.Value.Server.Scripts.Snippets.StoragePath = path;
}
}