feat: add headless agent management to CLI and both desktop clients
This commit is contained in:
1 parent
e91fa0235c
commit
6916dd54fb
50 files changed
+4837
-148
No files matched your search
@@ -0,0 +1,19 @@
|
||||
using Avalonia.Controls;
|
||||
using Avalonia.Interactivity;
|
||||
using Avalonia.Platform.Storage;
|
||||
namespace Ads.Desktop;
|
||||
public partial class AgentManagementView : UserControl
|
||||
{
|
||||
public AgentManagementView()=>InitializeComponent();
|
||||
private async Task Import(bool enrollment)
|
||||
{
|
||||
if(DataContext is not AgentManagementViewModel vm)return;
|
||||
try {
|
||||
var top=TopLevel.GetTopLevel(this);if(top==null)return;
|
||||
var files=await top.StorageProvider.OpenFilePickerAsync(new FilePickerOpenOptions{Title=enrollment?"选择 agent.env":"选择 admin.env",AllowMultiple=false,FileTypeFilter=[new FilePickerFileType("环境配置"){Patterns=["*.env"]}]});
|
||||
if(files.FirstOrDefault()?.TryGetLocalPath() is {} path){if(enrollment)vm.ImportEnrollment(path);else vm.ImportAdmin(path);}
|
||||
}catch(Exception error){vm.Notice=error.Message;}
|
||||
}
|
||||
private async void ImportAdminClick(object? sender,RoutedEventArgs e)=>await Import(false);
|
||||
private async void ImportEnrollmentClick(object? sender,RoutedEventArgs e)=>await Import(true);
|
||||
}
|
||||
Reference in new issue
Block a user