/**
 * Mock Data Service for Bacula Interface
 * Simulates API calls to the Bacula Backend
 */

const MOCK_JOBS = [
    { id: 10423, name: 'Weekly-Server-Full', client: 'db-prod-01', level: 'Full', files: 45201, bytes: 48500000000, status: 'Success', startTime: '2025-10-24 02:00:00', duration: '1h 12m' },
    { id: 10424, name: 'Daily-Web-Inc', client: 'web-front-01', level: 'Incremental', files: 1205, bytes: 540000000, status: 'Success', startTime: '2025-10-24 03:30:00', duration: '15m' },
    { id: 10425, name: 'Daily-Web-Inc', client: 'web-front-02', level: 'Incremental', files: 1150, bytes: 520000000, status: 'Warning', startTime: '2025-10-24 03:45:00', duration: '14m' },
    { id: 10426, name: 'Log-Archive', client: 'log-svr-01', level: 'Differential', files: 8500, bytes: 12000000000, status: 'Running', startTime: '2025-10-24 04:00:00', duration: 'Running' },
    { id: 10427, name: 'User-Home-Backup', client: 'file-svr-01', level: 'Full', files: 0, bytes: 0, status: 'Error', startTime: '2025-10-24 01:00:00', duration: '2m' },
];

const MOCK_STATS = {
    totalJobs: 1250,
    successRate: 98.5,
    totalBytes: 85400000000000, // 85.4 TB
    activeClients: 42,
    storageUsage: 76 // Percent
};

export class MockApi {
    static async getDashboardStats() {
        return new Promise(resolve => {
            setTimeout(() => resolve(MOCK_STATS), 600); // Simulate network latency
        });
    }

    static async getRecentJobs() {
        return new Promise(resolve => {
            setTimeout(() => resolve(MOCK_JOBS), 800);
        });
    }

    static async getClients() {
        return new Promise(resolve => {
            setTimeout(() => resolve([
                { name: 'db-prod-01', os: 'Linux (Debian 12)', lastBackup: '2025-10-24 02:00:00', status: 'Online' },
                { name: 'web-front-01', os: 'Linux (Ubuntu 24.04)', lastBackup: '2025-10-24 03:30:00', status: 'Online' },
                { name: 'win-office-01', os: 'Windows Server 2022', lastBackup: '2025-10-23 20:00:00', status: 'Offline' }
            ]), 500);
        });
    }
}
