refactor: remove syncing
This commit is contained in:
@@ -3,7 +3,6 @@
|
||||
namespace App\Filament\Resources;
|
||||
|
||||
use App\Filament\Resources\TerminalResource\Pages;
|
||||
use App\Filament\Actions\SyncConfigAction;
|
||||
use App\Models\Terminal;
|
||||
use Filament\Forms;
|
||||
use Filament\Forms\Form;
|
||||
@@ -86,50 +85,34 @@ class TerminalResource extends Resource
|
||||
])
|
||||
->columns(2),
|
||||
|
||||
Forms\Components\Section::make('组态图配置')
|
||||
Forms\Components\Section::make('组态配置')
|
||||
->schema([
|
||||
Forms\Components\TextInput::make('diagram_url')
|
||||
->label('组态图URL')
|
||||
->label('组态界面地址')
|
||||
->url()
|
||||
->maxLength(500)
|
||||
->placeholder('https://example.com/diagram.png')
|
||||
->helperText('组态图的访问地址'),
|
||||
->helperText('组态界面的访问地址'),
|
||||
]),
|
||||
|
||||
Forms\Components\Section::make('SCADA网关配置')
|
||||
Forms\Components\Section::make('网关配置')
|
||||
->schema([
|
||||
Forms\Components\TextInput::make('scada_data_url')
|
||||
->label('SCADA数据查询URL')
|
||||
->label('数据查询URL')
|
||||
->url()
|
||||
->maxLength(500)
|
||||
->placeholder('http://gateway:8080/api/data')
|
||||
->helperText('OPC UA HTTP网关的数据查询地址'),
|
||||
->helperText('网关的数据查询地址'),
|
||||
|
||||
Forms\Components\TextInput::make('scada_tags_url')
|
||||
->label('SCADA点位定义URL')
|
||||
->label('点位定义URL')
|
||||
->url()
|
||||
->maxLength(500)
|
||||
->placeholder('http://gateway:8080/api/tags')
|
||||
->helperText('OPC UA HTTP网关的点位定义查询地址'),
|
||||
->helperText('网关的点位定义查询地址'),
|
||||
])
|
||||
->columns(2),
|
||||
|
||||
Forms\Components\Section::make('显示配置')
|
||||
->schema([
|
||||
Forms\Components\KeyValue::make('display_config')
|
||||
->label('显示参数')
|
||||
->keyLabel('参数名称')
|
||||
->valueLabel('参数值')
|
||||
->addActionLabel('添加参数')
|
||||
->helperText('配置终端的显示参数,如分辨率、刷新率等')
|
||||
->default([
|
||||
'resolution' => '1920x1080',
|
||||
'refresh_rate' => '60',
|
||||
'orientation' => 'landscape',
|
||||
'brightness' => '80',
|
||||
]),
|
||||
]),
|
||||
|
||||
Forms\Components\Section::make('知识库关联')
|
||||
->schema([
|
||||
Forms\Components\Repeater::make('knowledgeBaseAssociations')
|
||||
@@ -158,7 +141,8 @@ class TerminalResource extends Resource
|
||||
->reorderableWithButtons()
|
||||
->addActionLabel('添加知识库')
|
||||
->reorderableWithDragAndDrop(false)
|
||||
->itemLabel(fn (array $state): ?string =>
|
||||
->itemLabel(
|
||||
fn(array $state): ?string =>
|
||||
\App\Models\KnowledgeBase::find($state['id'])?->name ?? '未选择'
|
||||
)
|
||||
->collapsed()
|
||||
@@ -195,7 +179,8 @@ class TerminalResource extends Resource
|
||||
->reorderableWithButtons()
|
||||
->addActionLabel('添加指引')
|
||||
->reorderableWithDragAndDrop(false)
|
||||
->itemLabel(fn (array $state): ?string =>
|
||||
->itemLabel(
|
||||
fn(array $state): ?string =>
|
||||
\App\Models\Guide::find($state['id'])?->name ?? '未选择'
|
||||
)
|
||||
->collapsed()
|
||||
@@ -216,16 +201,16 @@ class TerminalResource extends Resource
|
||||
->placeholderText('请输入AI提示词模板...')
|
||||
->disablePreview()
|
||||
->columnSpan(2),
|
||||
|
||||
|
||||
Forms\Components\Grid::make(1)
|
||||
->schema([
|
||||
Forms\Components\Placeholder::make('template_selector')
|
||||
->label('模板库')
|
||||
->content(fn () => view('filament.components.prompt-template-selector')),
|
||||
|
||||
->content(fn() => view('filament.components.prompt-template-selector')),
|
||||
|
||||
Forms\Components\Placeholder::make('variable_helper')
|
||||
->label('变量参考')
|
||||
->content(fn () => view('filament.components.prompt-variable-helper')),
|
||||
->content(fn() => view('filament.components.prompt-variable-helper')),
|
||||
])
|
||||
->columnSpan(1),
|
||||
]),
|
||||
@@ -296,33 +281,6 @@ class TerminalResource extends Resource
|
||||
->falseColor('danger')
|
||||
->sortable(),
|
||||
|
||||
Tables\Columns\TextColumn::make('latestSyncLog.status')
|
||||
->label('同步状态')
|
||||
->badge()
|
||||
->formatStateUsing(fn (string $state): string => match ($state) {
|
||||
'pending' => '待同步',
|
||||
'syncing' => '同步中',
|
||||
'synced' => '已同步',
|
||||
'failed' => '失败',
|
||||
default => '未知',
|
||||
})
|
||||
->color(fn (string $state): string => match ($state) {
|
||||
'pending' => 'warning',
|
||||
'syncing' => 'info',
|
||||
'synced' => 'success',
|
||||
'failed' => 'danger',
|
||||
default => 'gray',
|
||||
})
|
||||
->icon(fn (string $state): string => match ($state) {
|
||||
'pending' => 'heroicon-o-clock',
|
||||
'syncing' => 'heroicon-o-arrow-path',
|
||||
'synced' => 'heroicon-o-check-circle',
|
||||
'failed' => 'heroicon-o-x-circle',
|
||||
default => 'heroicon-o-question-mark-circle',
|
||||
})
|
||||
->placeholder('从未同步')
|
||||
->sortable(),
|
||||
|
||||
Tables\Columns\TextColumn::make('last_online_at')
|
||||
->label('最后在线时间')
|
||||
->dateTime('Y-m-d H:i:s')
|
||||
@@ -348,17 +306,8 @@ class TerminalResource extends Resource
|
||||
->placeholder('全部')
|
||||
->trueLabel('在线')
|
||||
->falseLabel('离线'),
|
||||
|
||||
Tables\Filters\Filter::make('station_id')
|
||||
->label('已绑定线站')
|
||||
->query(fn (Builder $query): Builder => $query->whereNotNull('station_id')),
|
||||
|
||||
Tables\Filters\Filter::make('has_diagram')
|
||||
->label('已配置组态图')
|
||||
->query(fn (Builder $query): Builder => $query->whereNotNull('diagram_url')),
|
||||
])
|
||||
->actions([
|
||||
SyncConfigAction::make(),
|
||||
Tables\Actions\ViewAction::make()
|
||||
->label('查看'),
|
||||
Tables\Actions\EditAction::make()
|
||||
@@ -368,7 +317,6 @@ class TerminalResource extends Resource
|
||||
])
|
||||
->bulkActions([
|
||||
Tables\Actions\BulkActionGroup::make([
|
||||
SyncConfigAction::makeBulk(),
|
||||
Tables\Actions\DeleteBulkAction::make()
|
||||
->label('批量删除'),
|
||||
]),
|
||||
@@ -380,7 +328,7 @@ class TerminalResource extends Resource
|
||||
->collapsible(),
|
||||
Tables\Grouping\Group::make('is_online')
|
||||
->label('按在线状态分组')
|
||||
->getTitleFromRecordUsing(fn (Terminal $record): string => $record->is_online ? '在线' : '离线')
|
||||
->getTitleFromRecordUsing(fn(Terminal $record): string => $record->is_online ? '在线' : '离线')
|
||||
->collapsible(),
|
||||
]);
|
||||
}
|
||||
|
||||
@@ -43,24 +43,16 @@ class ViewTerminal extends ViewRecord
|
||||
])
|
||||
->columns(2),
|
||||
|
||||
Infolists\Components\Section::make('组态图配置')
|
||||
Infolists\Components\Section::make('组态配置')
|
||||
->schema([
|
||||
Infolists\Components\TextEntry::make('diagram_url')
|
||||
->label('组态图URL')
|
||||
->label('组态界面地址')
|
||||
->copyable()
|
||||
->placeholder('未设置')
|
||||
->url(fn ($state) => $state)
|
||||
->url(fn($state) => $state)
|
||||
->openUrlInNewTab(),
|
||||
]),
|
||||
|
||||
Infolists\Components\Section::make('显示配置')
|
||||
->schema([
|
||||
Infolists\Components\KeyValueEntry::make('display_config')
|
||||
->label('显示参数')
|
||||
->keyLabel('参数名称')
|
||||
->valueLabel('参数值'),
|
||||
]),
|
||||
|
||||
Infolists\Components\Section::make('知识库关联')
|
||||
->schema([
|
||||
Infolists\Components\RepeatableEntry::make('knowledgeBases')
|
||||
@@ -103,49 +95,6 @@ class ViewTerminal extends ViewRecord
|
||||
])
|
||||
->columns(2),
|
||||
|
||||
Infolists\Components\Section::make('同步历史')
|
||||
->schema([
|
||||
Infolists\Components\RepeatableEntry::make('syncLogs')
|
||||
->label('同步记录')
|
||||
->schema([
|
||||
Infolists\Components\TextEntry::make('status')
|
||||
->label('状态')
|
||||
->badge()
|
||||
->formatStateUsing(fn (string $state): string => match ($state) {
|
||||
'pending' => '待同步',
|
||||
'syncing' => '同步中',
|
||||
'synced' => '已同步',
|
||||
'failed' => '失败',
|
||||
default => '未知',
|
||||
})
|
||||
->color(fn (string $state): string => match ($state) {
|
||||
'pending' => 'warning',
|
||||
'syncing' => 'info',
|
||||
'synced' => 'success',
|
||||
'failed' => 'danger',
|
||||
default => 'gray',
|
||||
}),
|
||||
Infolists\Components\TextEntry::make('created_at')
|
||||
->label('创建时间')
|
||||
->dateTime('Y-m-d H:i:s'),
|
||||
Infolists\Components\TextEntry::make('synced_at')
|
||||
->label('同步完成时间')
|
||||
->dateTime('Y-m-d H:i:s')
|
||||
->placeholder('未完成'),
|
||||
Infolists\Components\TextEntry::make('error_message')
|
||||
->label('错误信息')
|
||||
->placeholder('无')
|
||||
->color('danger')
|
||||
->columnSpanFull(),
|
||||
])
|
||||
->columns(3)
|
||||
->placeholder('暂无同步记录')
|
||||
->contained(false),
|
||||
])
|
||||
->description('显示最近的配置同步记录,按时间倒序排列')
|
||||
->collapsible()
|
||||
->collapsed(),
|
||||
|
||||
Infolists\Components\Section::make('时间信息')
|
||||
->schema([
|
||||
Infolists\Components\TextEntry::make('created_at')
|
||||
|
||||
Reference in New Issue
Block a user