147 lines
6.4 KiB
PHP
147 lines
6.4 KiB
PHP
<?php
|
|
|
|
namespace App\Filament\Pages;
|
|
|
|
use App\Settings\RemoteWriteSettings;
|
|
use Filament\Forms;
|
|
use Filament\Forms\Form;
|
|
use Filament\Pages\SettingsPage;
|
|
|
|
class ManageRemoteWrite extends SettingsPage
|
|
{
|
|
protected static ?string $navigationIcon = 'heroicon-o-cog-6-tooth';
|
|
|
|
protected static string $settings = RemoteWriteSettings::class;
|
|
|
|
public function form(Form $form): Form
|
|
{
|
|
return $form
|
|
->schema([
|
|
// 启用切换开关
|
|
Forms\Components\Toggle::make('state')
|
|
->label("启用")
|
|
->required()
|
|
->reactive(),
|
|
|
|
Forms\Components\Fieldset::make()
|
|
->schema([
|
|
// 远程存储的URL
|
|
Forms\Components\TextInput::make('url')
|
|
->label("远程存储URL")
|
|
->required()
|
|
->url()
|
|
->placeholder("http://remote-storage.example.com/api/v1/write"),
|
|
|
|
// 数据源名陈
|
|
Forms\Components\TextInput::make('data_source_label')
|
|
->label("数据源名称")
|
|
->required(),
|
|
|
|
// 每个分片的最大队列容量
|
|
Forms\Components\TextInput::make('queue_config_capacity')
|
|
->label("队列容量")
|
|
->required()
|
|
->numeric(),
|
|
|
|
// 每次发送的最大样本数
|
|
Forms\Components\TextInput::make('queue_config_max_samples_per_send')
|
|
->label("每次发送样本数")
|
|
->required()
|
|
->numeric(),
|
|
|
|
// 每次发送批次的最大等待时间
|
|
Forms\Components\TextInput::make('queue_config_batch_send_deadline')
|
|
->label("批次发送截止时间")
|
|
->required()
|
|
->placeholder("5s"),
|
|
|
|
// 最大分片数
|
|
Forms\Components\TextInput::make('queue_config_max_shards')
|
|
->label("最大分片数")
|
|
->required()
|
|
->numeric(),
|
|
|
|
// 最小分片数
|
|
Forms\Components\TextInput::make('queue_config_min_shards')
|
|
->label("最小分片数")
|
|
->required()
|
|
->numeric(),
|
|
|
|
// 最小重试等待时间
|
|
Forms\Components\TextInput::make('queue_config_min_backoff')
|
|
->label("最小重试等待时间")
|
|
->required()
|
|
->placeholder("100ms"),
|
|
|
|
// 最大重试等待时间
|
|
Forms\Components\TextInput::make('queue_config_max_backoff')
|
|
->label("最大重试等待时间")
|
|
->required()
|
|
->placeholder("5m"),
|
|
])
|
|
->visible(fn($get) => in_array($get('state'), [true])),
|
|
|
|
Forms\Components\Fieldset::make()
|
|
->schema([
|
|
// 认证模式选择
|
|
Forms\Components\Select::make('auth_mode')
|
|
->label("认证模式")
|
|
->options([
|
|
'anonymous' => '匿名模式',
|
|
'certificate' => '证书模式',
|
|
'basic_auth' => '用户名密码模式',
|
|
])
|
|
->required()
|
|
->reactive(),
|
|
|
|
// CA证书文件路径
|
|
Forms\Components\TextInput::make('tls_config_ca_file')
|
|
->label("CA证书文件")
|
|
->nullable()
|
|
->placeholder("/path/to/ca.crt")
|
|
->visible(fn($get) => $get('auth_mode') === 'certificate'),
|
|
|
|
// 客户端证书文件路径
|
|
Forms\Components\TextInput::make('tls_config_cert_file')
|
|
->label("客户端证书文件")
|
|
->nullable()
|
|
->placeholder("/path/to/client.crt")
|
|
->visible(fn($get) => $get('auth_mode') === 'certificate'),
|
|
|
|
// 客户端私钥文件路径
|
|
Forms\Components\TextInput::make('tls_config_key_file')
|
|
->label("客户端私钥文件")
|
|
->nullable()
|
|
->placeholder("/path/to/client.key")
|
|
->visible(fn($get) => $get('auth_mode') === 'certificate'),
|
|
|
|
// 是否跳过TLS验证
|
|
Forms\Components\Toggle::make('tls_config_insecure_skip_verify')
|
|
->label("跳过TLS验证")
|
|
->visible(fn($get) => $get('auth_mode') === 'certificate'),
|
|
|
|
// 基础认证用户名
|
|
Forms\Components\TextInput::make('basic_auth_username')
|
|
->label("基础认证用户名")
|
|
->nullable()
|
|
->visible(fn($get) => $get('auth_mode') === 'basic_auth'),
|
|
|
|
// 基础认证密码
|
|
Forms\Components\TextInput::make('basic_auth_password')
|
|
->label("基础认证密码")
|
|
->nullable()
|
|
->password()
|
|
->visible(fn($get) => $get('auth_mode') === 'basic_auth'),
|
|
|
|
// Bearer令牌
|
|
Forms\Components\TextInput::make('bearer_token')
|
|
->label("Bearer令牌")
|
|
->nullable()
|
|
->visible(fn($get) => $get('auth_mode') === 'basic_auth'),
|
|
|
|
])
|
|
->visible(fn($get) => in_array($get('state'), [true])),
|
|
]);
|
|
}
|
|
}
|