true, 'config' => $config]); break; case 'save_scheduler_task': $taskData = json_decode($_POST['task'] ?? '{}', true); if (empty($taskData['name']) || empty($taskData['type'])) { throw new Exception('Task name and type are required'); } if (empty($taskData['id'])) { // New task $taskData['id'] = 'task_' . uniqid(); $taskData['created_at'] = date('c'); $taskData['last_run'] = null; $taskData['next_run'] = null; $taskData['last_result'] = null; $config['tasks'][] = $taskData; } else { // Update existing foreach ($config['tasks'] as &$t) { if ($t['id'] === $taskData['id']) { $t['name'] = $taskData['name']; $t['type'] = $taskData['type']; $t['schedule'] = $taskData['schedule']; $t['enabled'] = $taskData['enabled'] ?? true; $t['schedule_hour'] = $taskData['schedule_hour'] ?? 0; $t['schedule_minute'] = $taskData['schedule_minute'] ?? 0; break; } } unset($t); } file_put_contents(SCHEDULER_CONFIG, json_encode($config, JSON_PRETTY_PRINT), LOCK_EX); echo json_encode(['success' => true, 'message' => 'Task saved', 'task_id' => $taskData['id']]); break; case 'delete_scheduler_task': $taskId = $_POST['task_id'] ?? ''; $config['tasks'] = array_values(array_filter($config['tasks'], function($t) use ($taskId) { return ($t['id'] ?? '') !== $taskId; })); file_put_contents(SCHEDULER_CONFIG, json_encode($config, JSON_PRETTY_PRINT), LOCK_EX); echo json_encode(['success' => true, 'message' => 'Task deleted']); break; case 'toggle_scheduler_task': $taskId = $_POST['task_id'] ?? ''; $enabled = ($_POST['enabled'] ?? '1') === '1'; foreach ($config['tasks'] as &$t) { if (($t['id'] ?? '') === $taskId) { $t['enabled'] = $enabled; break; } } unset($t); file_put_contents(SCHEDULER_CONFIG, json_encode($config, JSON_PRETTY_PRINT), LOCK_EX); echo json_encode(['success' => true, 'message' => $enabled ? 'Task enabled' : 'Task disabled']); break; case 'run_scheduler_task_now': $taskId = $_POST['task_id'] ?? ''; $scriptPath = __DIR__ . '/scripts/runScheduler.php'; $logPath = __DIR__ . '/logs/scheduler-run.log'; exec("php " . escapeshellarg($scriptPath) . " " . escapeshellarg($taskId) . " > " . escapeshellarg($logPath) . " 2>&1 &"); echo json_encode(['success' => true, 'message' => 'Task execution started']); break; case 'save_alerts': $alerts = json_decode($_POST['alerts'] ?? '{}', true); $config['alerts'] = $alerts; file_put_contents(SCHEDULER_CONFIG, json_encode($config, JSON_PRETTY_PRINT), LOCK_EX); echo json_encode(['success' => true, 'message' => 'Alerts saved']); break; default: echo json_encode(['success' => false, 'error' => 'Invalid action']); } } catch (Exception $e) { echo json_encode(['success' => false, 'error' => $e->getMessage()]); } exit; } // Load config for initial render $config = ['tasks' => [], 'alerts' => [], 'history' => []]; if (file_exists(SCHEDULER_CONFIG)) { $config = json_decode(file_get_contents(SCHEDULER_CONFIG), true) ?: $config; } $tasks = $config['tasks'] ?? []; $history = array_slice($config['history'] ?? [], 0, 20); $alerts = $config['alerts'] ?? []; $taskTypeNames = [ 'governance_scan' => 'Governance Scan', 'cache_refresh' => 'Cache Refresh', 'stats_collection' => 'Statistics Collection', 'audit_cleanup' => 'Audit Log Cleanup' ]; $scheduleNames = [ 'hourly' => 'Every Hour', 'daily' => 'Daily', 'weekly' => 'Weekly', 'monthly' => 'Monthly' ]; ?> Scheduler - Space Manager

Scheduled Operations

Back to Spaces

Scheduled Tasks

task(s)

No Scheduled Tasks

Click "Add Task" to create a scheduled operation.

· · Last:

Execution History

No execution history yet.

Timestamp Task Type Status Duration Message
s

Alert Configuration

Critical Governance Issues
Alert when critical violations exceed threshold
Inactive Spaces
Alert when spaces are inactive beyond threshold
days