mirror of
https://github.com/yyhuni/xingrin.git
synced 2026-02-18 20:33:17 +08:00
- Add mock data modules for auth, engines, notifications, scheduled-scans, and workers - Implement mock authentication data with user profiles and login/logout responses - Create mock scan engine configurations with multiple predefined scanning profiles - Add mock notification system with various severity levels and categories - Implement mock scheduled scan data with cron expressions and run history - Add mock worker node data with status and performance metrics - Update service layer to integrate with new mock data infrastructure - Provide helper functions for filtering and paginating mock data - Enable frontend development and testing without backend API dependency
79 lines
1.7 KiB
TypeScript
79 lines
1.7 KiB
TypeScript
import type { WorkerNode, WorkersResponse } from '@/types/worker.types'
|
|
|
|
export const mockWorkers: WorkerNode[] = [
|
|
{
|
|
id: 1,
|
|
name: 'local-worker',
|
|
ipAddress: '127.0.0.1',
|
|
sshPort: 22,
|
|
username: 'root',
|
|
status: 'online',
|
|
isLocal: true,
|
|
createdAt: '2024-01-01T00:00:00Z',
|
|
updatedAt: '2024-12-29T10:00:00Z',
|
|
info: {
|
|
cpuPercent: 23.5,
|
|
memoryPercent: 45.2,
|
|
},
|
|
},
|
|
{
|
|
id: 2,
|
|
name: 'worker-01',
|
|
ipAddress: '192.168.1.101',
|
|
sshPort: 22,
|
|
username: 'scanner',
|
|
status: 'online',
|
|
isLocal: false,
|
|
createdAt: '2024-06-15T08:00:00Z',
|
|
updatedAt: '2024-12-29T09:30:00Z',
|
|
info: {
|
|
cpuPercent: 56.8,
|
|
memoryPercent: 72.1,
|
|
},
|
|
},
|
|
{
|
|
id: 3,
|
|
name: 'worker-02',
|
|
ipAddress: '192.168.1.102',
|
|
sshPort: 22,
|
|
username: 'scanner',
|
|
status: 'online',
|
|
isLocal: false,
|
|
createdAt: '2024-07-20T10:00:00Z',
|
|
updatedAt: '2024-12-29T09:45:00Z',
|
|
info: {
|
|
cpuPercent: 34.2,
|
|
memoryPercent: 58.9,
|
|
},
|
|
},
|
|
{
|
|
id: 4,
|
|
name: 'worker-03',
|
|
ipAddress: '192.168.1.103',
|
|
sshPort: 22,
|
|
username: 'scanner',
|
|
status: 'offline',
|
|
isLocal: false,
|
|
createdAt: '2024-08-10T14:00:00Z',
|
|
updatedAt: '2024-12-28T16:00:00Z',
|
|
},
|
|
]
|
|
|
|
export function getMockWorkers(page = 1, pageSize = 10): WorkersResponse {
|
|
const total = mockWorkers.length
|
|
const totalPages = Math.ceil(total / pageSize)
|
|
const start = (page - 1) * pageSize
|
|
const results = mockWorkers.slice(start, start + pageSize)
|
|
|
|
return {
|
|
results,
|
|
total,
|
|
page,
|
|
pageSize,
|
|
}
|
|
}
|
|
|
|
export function getMockWorkerById(id: number): WorkerNode | undefined {
|
|
return mockWorkers.find(w => w.id === id)
|
|
}
|