Files
AndroidDeviceStreaming/desktop/Ads.Desktop/AgentManagementView.axaml
T

31 lines
6.9 KiB
XML

<UserControl xmlns="https://github.com/avaloniaui" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" x:Class="Ads.Desktop.AgentManagementView">
<Grid RowDefinitions="Auto,*,Auto" Margin="0,14,0,0">
<StackPanel>
<WrapPanel><CheckBox x:Name="LocalAgentMode" Content="管理本机 Agent" IsChecked="{Binding LocalMode}" IsEnabled="{Binding !IsBusy}" Margin="0,0,20,8"/><CheckBox Content="自动刷新" IsChecked="{Binding AutoRefresh}"/><Button x:Name="RefreshAgentsButton" Content="刷新 Agent" Command="{Binding RefreshAgentsCommand}" IsEnabled="{Binding !IsBusy}" Margin="20,0,0,10"/></WrapPanel>
<StackPanel IsVisible="{Binding !LocalMode}"><TextBlock Text="远程管理使用工作台的控制中心地址,需要独立的管理员凭据。" TextWrapping="Wrap"/><TextBlock Text="{Binding AdminPath}" TextWrapping="Wrap"/><Grid ColumnDefinitions="*,Auto"><TextBox x:Name="AdminTokenBox" Text="{Binding AdminToken}" PasswordChar="●" Watermark="ADS_ADMIN_TOKEN"/><Button Grid.Column="1" Content="导入 admin.env" Click="ImportAdminClick" Margin="12,4,0,10"/></Grid></StackPanel>
<StackPanel IsVisible="{Binding LocalMode}"><TextBlock Text="本机配置路径"/><Grid ColumnDefinitions="*,Auto"><TextBox Text="{Binding ConfigPath}"/><Button Grid.Column="1" Content="选择" Click="ChooseConfigClick"/></Grid><WrapPanel><Button Content="启动后台 Agent" Command="{Binding StartLocalCommand}"/><Button Content="安装开机服务" Command="{Binding InstallServiceCommand}"/></WrapPanel></StackPanel>
</StackPanel>
<Grid Grid.Row="1" ColumnDefinitions="300,*">
<Border Classes="agentCard" Margin="0,0,14,0"><Grid RowDefinitions="Auto,*"><TextBlock Text="Agent / 被控电脑" FontSize="18" FontWeight="SemiBold"/><ListBox x:Name="AgentList" Grid.Row="1" ItemsSource="{Binding Agents}" SelectedItem="{Binding SelectedAgent}" Margin="0,10,0,0"><ListBox.ItemTemplate><DataTemplate><StackPanel Spacing="5" Margin="4,8"><TextBlock Text="{Binding Id}" FontSize="16"/><TextBlock Text="{Binding Description}" TextWrapping="Wrap" Foreground="{DynamicResource SemiColorText2}"/></StackPanel></DataTemplate></ListBox.ItemTemplate></ListBox></Grid></Border>
<ScrollViewer Grid.Column="1"><StackPanel Spacing="14">
<Border Classes="agentCard"><StackPanel Spacing="10"><TextBlock Text="{Binding SelectedAgentDetails}" TextWrapping="Wrap" Foreground="{DynamicResource SemiColorPrimary}"/><WrapPanel><Button x:Name="LoadAgentConfigButton" Content="读取配置" Command="{Binding LoadConfigCommand}"/><Button Content="开启 USB 自动注册" Command="{Binding EnableAutoUsbCommand}"/><Button Content="关闭 USB 自动注册" Command="{Binding DisableAutoUsbCommand}"/><Button Content="取消所选发现设备的忽略" Command="{Binding UnignoreUsbCommand}"/><Button Content="重启 Agent" Command="{Binding RestartAgentCommand}"/></WrapPanel><TextBlock Text="USB 自动注册默认关闭,仅支持 Windows/Linux 真实 USB。删除后记为忽略,停用不会自动恢复;当前开关和忽略列表可读取配置查看。重启会短暂中断设备连接。" FontSize="12" Foreground="{DynamicResource SemiColorText2}"/></StackPanel></Border>
<Border Classes="agentCard"><StackPanel Spacing="8">
<Button Content="发现 ADB 设备" Command="{Binding DiscoverDevicesCommand}" HorizontalAlignment="Left"/>
<ListBox ItemsSource="{Binding DiscoveredDevices}" SelectedItem="{Binding SelectedDiscoveredDevice}" MaxHeight="160"><ListBox.ItemTemplate><DataTemplate><TextBlock Text="{Binding Description}" TextWrapping="Wrap"/></DataTemplate></ListBox.ItemTemplate></ListBox>
<TextBlock Text="手机管理" FontSize="18" FontWeight="SemiBold"/>
<ListBox x:Name="ManagedDevicesList" ItemsSource="{Binding AgentDevices}" SelectedItem="{Binding SelectedManagedDevice}" MinHeight="70" MaxHeight="180"><ListBox.ItemTemplate><DataTemplate><TextBlock Text="{Binding Description}" TextWrapping="Wrap" Margin="3,7"/></DataTemplate></ListBox.ItemTemplate></ListBox>
<WrapPanel><Button Content="启用" Command="{Binding EnableDeviceCommand}"/><Button Content="停用" Command="{Binding DisableDeviceCommand}"/><Button Content="移除配置" Command="{Binding RemoveDeviceCommand}"/></WrapPanel>
<Grid ColumnDefinitions="*,*"><StackPanel><TextBlock Text="设备 ID"/><TextBox Text="{Binding DeviceId}" Watermark="home-phone"/></StackPanel><StackPanel Grid.Column="1" Margin="12,0,0,0"><TextBlock Text="手机 adbd 地址"/><TextBox Text="{Binding Target}" Watermark="192.168.1.10:5555"/></StackPanel></Grid>
<Expander Header="通过已有 ADB server 接入"><StackPanel><TextBlock Text="ADB 序列号(与手机地址二选一)"/><TextBox Text="{Binding AdbSerial}"/><TextBlock Text="ADB server 地址(留空使用 Agent 默认值)"/><TextBox Text="{Binding AdbServer}" Watermark="127.0.0.1:5037"/><TextBlock Text="此模式仍要求手机启用 TCP adbd。" Foreground="{DynamicResource SemiColorText2}"/></StackPanel></Expander>
<Button x:Name="AddManagedDeviceButton" Content="添加手机" Command="{Binding AddDeviceCommand}" HorizontalAlignment="Left"/>
</StackPanel></Border>
<Border Classes="agentCard"><StackPanel Spacing="8"><TextBlock Text="Agent 配置" FontSize="18" FontWeight="SemiBold"/><TextBlock Text="修改设备或地址会重建受影响的连接;Agent ID 保持固定。" Foreground="{DynamicResource SemiColorText2}" TextWrapping="Wrap"/><TextBox x:Name="AgentConfigBox" Text="{Binding ConfigJson}" AcceptsReturn="True" FontFamily="Cascadia Mono,Consolas,Microsoft YaHei UI,Noto Sans CJK SC" FontSize="12" MinHeight="200" MaxHeight="380" ScrollViewer.VerticalScrollBarVisibility="Auto"/><Button Content="保存并应用配置" Command="{Binding SaveConfigCommand}" HorizontalAlignment="Left"/>
<StackPanel IsVisible="{Binding LocalMode}"><TextBlock Text="首次设置:填写上方配置及设备端凭据后初始化,再启动后台 Agent。" TextWrapping="Wrap"/><TextBlock Text="{Binding EnrollmentPath}" TextWrapping="Wrap"/><TextBox Text="{Binding EnrollmentToken}" PasswordChar="●" Watermark="ADS_AGENT_TOKEN"/><WrapPanel><Button Content="导入 agent.env" Click="ImportEnrollmentClick"/><Button Content="初始化本机配置" Command="{Binding InitializeLocalCommand}"/></WrapPanel></StackPanel>
</StackPanel></Border>
<Border Classes="agentCard"><StackPanel Spacing="8"><WrapPanel><Button Content="读取日志" Command="{Binding ReadLogsCommand}"/><CheckBox Content="持续跟随日志" IsChecked="{Binding FollowLogs}"/></WrapPanel><TextBox x:Name="AgentLogsBox" Text="{Binding RemoteLogText}" IsReadOnly="True" AcceptsReturn="True" FontFamily="Cascadia Mono,Consolas,Microsoft YaHei UI,Noto Sans CJK SC" FontSize="12" Height="200" ScrollViewer.VerticalScrollBarVisibility="Auto"/></StackPanel></Border>
</StackPanel></ScrollViewer>
</Grid>
<TextBlock Grid.Row="2" x:Name="AgentNotice" Text="{Binding Notice}" TextWrapping="Wrap" Foreground="{DynamicResource SemiColorText2}" Margin="0,12,0,0"/>
</Grid>
</UserControl>