[增添]添加了ManageDataSource管理页面
This commit is contained in:
129
management-panel/app/Filament/Pages/ManageDataSource.php
Normal file
129
management-panel/app/Filament/Pages/ManageDataSource.php
Normal file
@@ -0,0 +1,129 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Pages;
|
||||
|
||||
use App\Services\EtcdService;
|
||||
use App\Settings\DataSourceSettings;
|
||||
use Filament\Forms;
|
||||
use Filament\Forms\Form;
|
||||
use Filament\Pages\SettingsPage;
|
||||
use Filament\Forms\Components\TextInput;
|
||||
use Filament\Forms\Components\Select;
|
||||
use Filament\Forms\Components\Toggle;
|
||||
use Filament\Forms\Components\Textarea;
|
||||
use Filament\Forms\Components\Fieldset;
|
||||
|
||||
use Filament\Forms\Components\Actions\Action;
|
||||
|
||||
|
||||
class ManageDataSource extends SettingsPage
|
||||
{
|
||||
protected static ?string $navigationIcon = 'heroicon-o-cog-6-tooth';
|
||||
|
||||
protected static string $settings = DataSourceSettings::class;
|
||||
|
||||
public function form(Form $form): Form
|
||||
{
|
||||
return $form
|
||||
->schema([
|
||||
Select::make('data_source_type')
|
||||
->options([
|
||||
'opcua' => 'Opcua',
|
||||
])
|
||||
->default('opcua')
|
||||
->label('数据源类型')
|
||||
->columns(1)
|
||||
->required()
|
||||
->reactive(),
|
||||
|
||||
Fieldset::make()
|
||||
->schema([
|
||||
TextInput::make('name')
|
||||
->label('名称')
|
||||
->required(),
|
||||
|
||||
Textarea::make('description')
|
||||
->label('描述')
|
||||
->autosize()
|
||||
->nullable(),
|
||||
|
||||
TextInput::make('opcua_service_address')
|
||||
->label('opcua服务地址')
|
||||
->prefix('opc.tcp://')
|
||||
->required(),
|
||||
])
|
||||
->visible(fn($get) => in_array($get('data_source_type'), ['opcua'])),
|
||||
|
||||
Fieldset::make()
|
||||
->schema([
|
||||
Select::make('security_mode')
|
||||
->label('安全模式')
|
||||
->required()
|
||||
->options([
|
||||
'Anonymous' => '匿名模式',
|
||||
'UsernamePassword' => '用户名密码模式',
|
||||
'Certificate' => '证书/密钥模式',
|
||||
'CertificateAndUsernamePassword' => '证书/密码 + 用户名密码模式',
|
||||
'OpensslMbedtls' => 'Openssl/mbedtls模式',
|
||||
])
|
||||
->reactive(), // Triggers reactivity for the dependsOn method
|
||||
|
||||
TextInput::make('security_policy_address')
|
||||
->label('安全策略地址')
|
||||
->nullable(),
|
||||
|
||||
|
||||
// Certificate + UsernamePassword mode: Shows 'username', 'password', 'key_authentication_file', 'certificate_authentication_file', 'trusted_list'
|
||||
TextInput::make('username')
|
||||
->label('用户名')
|
||||
->nullable()
|
||||
->visible(fn($get) => in_array($get('security_mode'), ['UsernamePassword', 'CertificateAndUsernamePassword'])),
|
||||
|
||||
TextInput::make('password')
|
||||
->label('密码')
|
||||
->password()
|
||||
->revealable()
|
||||
->nullable()
|
||||
->visible(fn($get) => in_array($get('security_mode'), ['UsernamePassword', 'CertificateAndUsernamePassword'])),
|
||||
|
||||
TextInput::make('key_authentication_file')
|
||||
->label('密钥文件')
|
||||
->visible(fn($get) => in_array($get('security_mode'), ['Certificate', 'CertificateAndUsernamePassword'])),
|
||||
|
||||
TextInput::make('certificate_authentication_file')
|
||||
->label('证书文件')
|
||||
->visible(fn($get) => in_array($get('security_mode'), ['Certificate', 'CertificateAndUsernamePassword'])),
|
||||
|
||||
TextInput::make('trusted_list')
|
||||
->label('信任列表')
|
||||
->nullable()
|
||||
->visible(fn($get) => in_array($get('security_mode'), ['Certificate', 'CertificateAndUsernamePassword'])),
|
||||
|
||||
// Openssl/Mbedtls mode: Shows 'certificate_identity_file', 'key_identity_file'
|
||||
TextInput::make('certificate_identity_file')
|
||||
->label('证书身份验证文件')
|
||||
->visible(fn($get) => $get('security_mode') === 'OpensslMbedtls'),
|
||||
|
||||
TextInput::make('key_identity_file')
|
||||
->label('密钥身份验证文件')
|
||||
->visible(fn($get) => $get('security_mode') === 'OpensslMbedtls'),
|
||||
|
||||
// Anonymous mode: Shows 'measurement_point_address' and 'interface_address'
|
||||
TextInput::make('measurement_point_address')
|
||||
->label('测点地址')
|
||||
->required()
|
||||
->visible(fn($get) => in_array($get('security_mode'), ['Anonymous', 'Certificate', 'UsernamePassword', 'CertificateAndUsernamePassword', 'OpensslMbedtls'])),
|
||||
|
||||
TextInput::make('interface_address')
|
||||
->label('接口地址')
|
||||
->required()
|
||||
->visible(fn($get) => in_array($get('security_mode'), ['Anonymous', 'Certificate', 'UsernamePassword', 'CertificateAndUsernamePassword', 'OpensslMbedtls'])),
|
||||
|
||||
Toggle::make('state')
|
||||
->label('启用')
|
||||
->onColor('success'),
|
||||
])
|
||||
->visible(fn($get) => in_array($get('data_source_type'), ['opcua'])),
|
||||
]);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user