[增添]增添了后缀下拉菜单组件,修正了时间单位模版设置

This commit is contained in:
makotocc0107
2024-09-11 16:47:26 +08:00
committed by Coding
parent c2794f29ee
commit b63aff4b91
5 changed files with 79 additions and 16 deletions

View File

@@ -8,6 +8,7 @@ use Filament\Forms\Components\Repeater;
use Filament\Forms\Components\TextInput;
use Filament\Forms\Form;
use Filament\Pages\SettingsPage;
use Marvinosswald\FilamentInputSelectAffix\TextInputSelectAffix;
class ManageTime extends SettingsPage
{
@@ -23,22 +24,72 @@ class ManageTime extends SettingsPage
{
return $form
->schema([
TextInput::make('global_scrape_interval')
TextInputSelectAffix::make('global_scrape_interval')
->label('默认拉取时间')
->numeric()
->required()
->suffix("s"),
TextInput::make('node_exporter_scrape_interval')
->select(fn() => Forms\Components\Select::make('global_scrape_interval_unit')
->extraAttributes([
'class' => 'w-[72px]' // if you want to constrain the selects size, depending on your usecase
])
->options([
'd' => '天',
'h' => '小时',
'm' => '分钟',
's' => '秒'
])
->required()
),
TextInputSelectAffix::make('node_exporter_scrape_interval')
->label('系统监控时间间隔')
->required()
->suffix("s"),
TextInput::make('opcua_scrape_interval')
->numeric()
->select(fn() => Forms\Components\Select::make('node_exporter_scrape_interval_unit')
->extraAttributes([
'class' => 'w-[72px]' // if you want to constrain the selects size, depending on your usecase
])
->options([
'd' => '天',
'h' => '小时',
'm' => '分钟',
's' => '秒'
])
->required()
),
TextInputSelectAffix::make('opcua_scrape_interval')
->label('opcua_exporter抓取间隔')
->required()
->suffix("s"),
TextInput::make('storage_interval')
->numeric()
->select(fn() => Forms\Components\Select::make('opcua_scrape_interval_unit')
->extraAttributes([
'class' => 'w-[72px]' // if you want to constrain the selects size, depending on your usecase
])
->options([
'd' => '天',
'h' => '小时',
'm' => '分钟',
's' => '秒'
])
->required()
),
TextInputSelectAffix::make('storage_interval')
->label('数据存储时间')
->required()
->suffix("h"),
->numeric()
->select(fn() => Forms\Components\Select::make('storage_interval_unit')
->extraAttributes([
'class' => 'w-[72px]' // if you want to constrain the selects size, depending on your usecase
])
->options([
'd' => '天',
'h' => '小时',
'm' => '分钟',
's' => '秒'
])
->required()
),
]);
}
}

View File

@@ -15,6 +15,13 @@ class TimeSettings extends Settings
// 数据存储时间
public ?string $storage_interval;
public ?string $global_scrape_interval_unit;
public ?string $node_exporter_scrape_interval_unit;
public ?string $opcua_scrape_interval_unit;
public ?string $storage_interval_unit;
public static function group(): string
{
return 'time';

View File

@@ -7,9 +7,14 @@ return new class extends SettingsMigration
{
public function up(): void
{
$this->migrator->add('time.global_scrape_interval', '');
$this->migrator->add('time.node_exporter_scrape_interval', '');
$this->migrator->add('time.opcua_scrape_interval', '');
$this->migrator->add('time.storage_interval', '');
$this->migrator->add('time.global_scrape_interval', '15');
$this->migrator->add('time.node_exporter_scrape_interval', '10');
$this->migrator->add('time.opcua_scrape_interval', '10');
$this->migrator->add('time.storage_interval', '1');
$this->migrator->add('time.global_scrape_interval_unit', 's');
$this->migrator->add('time.node_exporter_scrape_interval_unit', 's');
$this->migrator->add('time.opcua_scrape_interval_unit', 's');
$this->migrator->add('time.storage_interval_unit', 'd');
}
};