diff --git a/.idea/workspace.xml b/.idea/workspace.xml
index 5edb009..77bbbe2 100644
--- a/.idea/workspace.xml
+++ b/.idea/workspace.xml
@@ -4,7 +4,7 @@
-
+
@@ -26,6 +26,9 @@
+
+
+
@@ -351,7 +354,7 @@
-
+
@@ -393,7 +396,15 @@
1724726078488
-
+
+
+ 1724726680511
+
+
+
+ 1724726680511
+
+
@@ -414,6 +425,7 @@
-
+
+
\ No newline at end of file
diff --git a/management-panel/app/Filament/Resources/MetricResource.php b/management-panel/app/Filament/Resources/MetricResource.php
new file mode 100644
index 0000000..f983beb
--- /dev/null
+++ b/management-panel/app/Filament/Resources/MetricResource.php
@@ -0,0 +1,128 @@
+schema([
+ TextInput::make('name')
+ ->required()
+ ->maxLength(255),
+ TextInput::make('help')
+ ->maxLength(255),
+
+ Section::make('Node ID')
+ ->description('节点设置必须唯一')
+ ->columns([
+ 'default' => 3
+ ])
+ ->schema([
+ // 1 = Numeric, 2 = String, 3 = GUID
+ Select::make('identifier_type')
+ ->options([
+ 1 => 'Numeric',
+ 2 => 'String',
+ 3 => 'GUID',
+ ])
+ ->default(1)
+ ->label('Identifier Type')
+ ->required()
+ ->reactive(), // 确保当选择的值变化时触发其他字段的重新渲染
+
+ TextInput::make('namespace_index')
+ ->label('Namespace')
+ ->required(),
+
+ // 数值型标识符字段
+ TextInput::make('numeric_id')
+ ->label('Numeric ID')
+ ->required()
+ ->visible(fn($get) => $get('identifier_type') == Metric::TYPE_NUMERIC),
+
+ // 字符串型标识符字段
+ TextInput::make('string_id')
+ ->label('String ID')
+ ->required()
+ ->visible(fn($get) => $get('identifier_type') == Metric::TYPE_STRING),
+
+ // GUID 型标识符字段
+ TextInput::make('guid_id')
+ ->label('GUID ID')
+ ->required()
+ ->visible(fn($get) => $get('identifier_type') == Metric::TYPE_GUID),
+ ]),
+ ]);
+ }
+
+ public static function table(Table $table): Table
+ {
+ return $table
+ ->columns([
+ TextColumn::make('name'),
+ TextColumn::make('nodeid')
+ ->label('Node ID')
+ ->state(function ($record) {
+ switch ($record->identifier_type) {
+ case 1: // Numeric
+ return 'ns=' . $record->namespace_index . ';i=' . $record->numeric_id;
+ case 2: // String
+ return 'ns=' . $record->namespace_index . ';s=' . $record->string_id;
+ case 3: // GUID
+ return 'ns=' . $record->namespace_index . ';g=' . $record->guid_id;
+ default:
+ return 'Unknown Type';
+ }
+ }),
+ TextColumn::make('help')
+ ])
+ ->filters([
+ //
+ ])
+ ->actions([
+ Tables\Actions\EditAction::make(),
+ ])
+ ->bulkActions([
+ Tables\Actions\BulkActionGroup::make([
+ Tables\Actions\DeleteBulkAction::make(),
+ ]),
+ ]);
+ }
+
+ public static function getRelations(): array
+ {
+ return [
+ //
+ ];
+ }
+
+ public static function getPages(): array
+ {
+ return [
+ 'index' => Pages\ListMetrics::route('/'),
+ 'create' => Pages\CreateMetric::route('/create'),
+ 'edit' => Pages\EditMetric::route('/{record}/edit'),
+ ];
+ }
+}
diff --git a/management-panel/app/Filament/Resources/MetricResource/Pages/CreateMetric.php b/management-panel/app/Filament/Resources/MetricResource/Pages/CreateMetric.php
new file mode 100644
index 0000000..89c6dd7
--- /dev/null
+++ b/management-panel/app/Filament/Resources/MetricResource/Pages/CreateMetric.php
@@ -0,0 +1,12 @@
+id();
+ $table->string('name');
+
+ // 命名空间索引
+ $table->integer('namespace_index');
+
+ // 标识符类型,存储为整数
+ // 1 = Numeric, 2 = String, 3 = GUID
+ $table->Integer('identifier_type');
+
+ // 数值型标识符
+ $table->integer('numeric_id')->nullable();
+
+ // 字符串型标识符
+ $table->string('string_id')->nullable();
+
+ // GUID 型标识符
+ $table->char('guid_id', 36)->nullable();
+
+ $table->string('help')->nullable();
+ $table->timestamps();
+
+ // 在同一命名空间中,确保唯一标识符唯一
+ $table->unique(['namespace_index', 'numeric_id']);
+ $table->unique(['namespace_index', 'string_id']);
+ $table->unique(['namespace_index', 'guid_id']);
+ });
+ }
+
+ /**
+ * Reverse the migrations.
+ */
+ public function down(): void
+ {
+ Schema::dropIfExists('metrics');
+ }
+};