graph TD
A[用户浏览器] --> B[React前端应用]
B --> C[Redux状态管理]
B --> D[Ant Design组件库]
B --> E[API服务层]
E --> F[NAS管理后端]
F --> G[存储设备API]
F --> H[系统监控服务]
subgraph "前端层"
B
C
D
end
subgraph "服务层"
E
F
end
subgraph "设备层"
G
H
end
| 路由路径 | 页面组件 | 功能描述 |
|---|---|---|
| /storage | StorageDashboard | 存储概览页面,显示总体统计 |
| /storage/disks | DiskManagement | 盘位管理,硬盘列表和状态 |
| /storage/pools | PoolManagement | 存储池列表和管理 |
| /storage/pools/create | PoolCreateWizard | RAID创建向导 |
| /storage/pools/ | PoolDetail | 存储池详情页面 |
| /storage/monitoring | CapacityMonitoring | 容量监控和告警设置 |
GET /api/storage/disks
请求参数:
| 参数名 | 类型 | 必需 | 描述 |
|---|---|---|---|
| page | number | 否 | 页码,默认1 |
| size | number | 否 | 每页数量,默认20 |
| status | string | 否 | 过滤状态:healthy/warning/error |
响应示例:
json{
"code": 0,
"message": "success",
"data": {
"total": 8,
"items": [
{
"disk_id": "disk_001",
"model": "ST4000VN008",
"capacity": 4000787030016,
"health_status": "healthy",
"smart_status": "passed",
"temperature": 42,
"power_on_hours": 8760,
"pool_id": "pool_001",
"filesystem": "ext4"
}
]
}
}
GET /api/storage/disks/{disk_id}/smart
POST /api/storage/pools
请求体:
json{
"pool_name": "数据存储池",
"raid_level": "raid5",
"disk_ids": ["disk_001", "disk_002", "disk_003"],
"stripe_size": 64
}
POST /api/storage/pools/{pool_id}/expand
GET /api/storage/capacity
POST /api/storage/alerts/rules
erDiagram
DISK ||--o{ POOL : belongs_to
POOL ||--o{ VOLUME : contains
POOL ||--o{ ALERT : triggers
DISK {
string disk_id PK
string model
bigint capacity
string health_status
string smart_status
int temperature
int power_on_hours
string pool_id FK
timestamp created_at
}
POOL {
string pool_id PK
string pool_name
string raid_level
bigint total_capacity
bigint used_capacity
string status
timestamp created_at
timestamp updated_at
}
VOLUME {
string volume_id PK
string pool_id FK
string volume_name
bigint capacity
string filesystem
string mount_point
}
ALERT {
string alert_id PK
string pool_id FK
string alert_type
string severity
decimal threshold
boolean is_enabled
timestamp created_at
}
sqlCREATE TABLE disks (
disk_id VARCHAR(50) PRIMARY KEY,
model VARCHAR(100) NOT NULL,
capacity BIGINT NOT NULL,
health_status VARCHAR(20) DEFAULT 'healthy',
smart_status VARCHAR(20) DEFAULT 'unknown',
temperature INTEGER DEFAULT 0,
power_on_hours INTEGER DEFAULT 0,
pool_id VARCHAR(50),
filesystem VARCHAR(20),
created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
updated_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP
);
CREATE INDEX idx_disks_pool_id ON disks(pool_id);
CREATE INDEX idx_disks_health ON disks(health_status);
sqlCREATE TABLE storage_pools (
pool_id VARCHAR(50) PRIMARY KEY,
pool_name VARCHAR(100) NOT NULL UNIQUE,
raid_level VARCHAR(20) NOT NULL,
total_capacity BIGINT NOT NULL,
used_capacity BIGINT DEFAULT 0,
status VARCHAR(20) DEFAULT 'active',
created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
updated_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP
);
src/ ├── features/ │ └── nas/ │ ├── components/ # 组件 │ │ ├── DiskCard/ │ │ ├── PoolList/ │ │ ├── RaidWizard/ │ │ └── CapacityChart/ │ ├── hooks/ # 自定义Hook │ │ ├── useDiskStatus.ts │ │ ├── usePoolActions.ts │ │ └── useCapacityAlert.ts │ ├── services/ # API服务 │ │ ├── diskService.ts │ │ ├── poolService.ts │ │ └── monitorService.ts │ ├── types/ # TypeScript类型 │ │ ├── disk.types.ts │ │ ├── pool.types.ts │ │ └── api.types.ts │ └── store/ # Redux Store │ ├── diskSlice.ts │ ├── poolSlice.ts │ └── index.ts ├── shared/ │ ├── components/ # 通用组件 │ ├── utils/ # 工具函数 │ └── constants/ # 常量定义 └── app/ ├── App.tsx └── store.ts
graph TD
A[React Components] --> B[Redux Store]
B --> C[diskSlice]
B --> D[poolSlice]
B --> E[alertSlice]
C --> F[Disk API]
D --> G[Pool API]
E --> H[Monitor API]
F --> I[Backend Service]
G --> I
H --> I
typescript// 硬盘状态组件测试
describe('DiskCard Component', () => {
it('should display disk information correctly', () => {
const disk = {
disk_id: 'disk_001',
model: 'ST4000VN008',
capacity: 4000787030016,
health_status: 'healthy'
};
render(<DiskCard disk={disk} />);
expect(screen.getByText('ST4000VN008')).toBeInTheDocument();
expect(screen.getByText('4.0 TB')).toBeInTheDocument();
expect(screen.getByText('健康')).toBeInTheDocument();
});
});
npm run builddist/本文作者:oyph
本文链接:
版权声明:本博客所有文章除特别声明外,均采用 BY-NC-SA 许可协议。转载请注明出处!