Auto populate server working directory based on executable path

dhcp-server
Pat Hartl 2023-09-11 20:21:40 -05:00
parent d869a5a763
commit 9a55dac778
2 changed files with 10 additions and 1 deletions

View File

@ -24,6 +24,7 @@
@code {
[Parameter] public string Value { get; set; }
[Parameter] public EventCallback<string> ValueChanged { get; set; }
[Parameter] public EventCallback<string> OnSelected { get; set; }
[Parameter] public Guid ArchiveId { get; set; }
[Parameter] public string Title { get; set; } = "Choose File";
[Parameter] public string OkText { get; set; } = "Select File";
@ -75,6 +76,9 @@
if (ValueChanged.HasDelegate)
await ValueChanged.InvokeAsync(Value);
if (OnSelected.HasDelegate)
await OnSelected.InvokeAsync(Value);
StateHasChanged();
};
}

View File

@ -73,7 +73,7 @@
</Select>
</FormItem>
<FormItem Label="Path">
<FilePicker Root="@RootPath" EntrySelectable="x => x is FileManagerFile" @bind-Value="@context.Path" />
<FilePicker Root="@RootPath" EntrySelectable="x => x is FileManagerFile" @bind-Value="@context.Path" OnSelected="OnPathSelected" />
</FormItem>
<FormItem Label="Arguments">
<Input @bind-Value="@context.Arguments" />
@ -193,6 +193,11 @@
}
}
private void OnPathSelected(string path)
{
Server.WorkingDirectory = Path.GetDirectoryName(path);
}
private void NotifyServerAdded(object? sender, LocationChangedEventArgs e)
{
NavigationManager.LocationChanged -= NotifyServerAdded;