diff --git a/admin.php b/admin.php index 82ba9b7..baacb98 100644 --- a/admin.php +++ b/admin.php @@ -2256,6 +2256,9 @@ document.addEventListener('DOMContentLoaded', function(){ if(!r.ok) throw new Error('status failed'); const data=await r.json(); const jobs=(data.jobs||[]).filter(function(job){ return job && (job.name || job.id); }); + if (Array.isArray(data.switches) && typeof applySwitchPayload === 'function') { + data.switches.forEach(function(payload){ applySwitchPayload(payload); }); + } const runningIds=new Set(jobs.map(function(job){ return String(job.id || ''); }).filter(function(v){ return v !== ''; })); const runningJobs=new Set(jobs.map(function(job){ return String(job.name || ''); }).filter(function(v){ return v !== ''; })); syncEditButtons(runningIds, runningJobs); diff --git a/job_status.php b/job_status.php index 4e55db7..fcc46c8 100644 --- a/job_status.php +++ b/job_status.php @@ -5,6 +5,7 @@ $config = require __DIR__ . '/config.php'; header('Content-Type: application/json; charset=UTF-8'); header('Cache-Control: no-store, no-cache, must-revalidate, max-age=0'); $jobs = []; +$switches = []; $dirs = glob($config['uploads_dir'] . '/*', GLOB_ONLYDIR) ?: []; foreach ($dirs as $dir) { $name = basename($dir); @@ -16,6 +17,12 @@ foreach ($dirs as $dir) { $articleId = is_array($state) ? strtolower((string)($state['article_id'] ?? '')) : ''; if ($articleId === '' && is_file($idFile)) $articleId = strtolower(trim((string)file_get_contents($idFile))); if (!preg_match('/^[0-9]{14}[a-f0-9]{16}$/', $articleId)) $articleId = ''; + $switches[] = [ + 'dir' => $name, + 'id' => $articleId, + 'enabled' => is_file($dir . '/.movmaker-enabled'), + 'preview' => is_file($dir . '/.movmaker-preview'), + ]; $locked = is_dir($lockDir); if ($locked || $status === 'processing') { $started = ''; @@ -29,4 +36,4 @@ foreach ($dirs as $dir) { ]; } } -echo json_encode(['jobs' => $jobs, 'checked_at' => date('c')], JSON_UNESCAPED_UNICODE); +echo json_encode(['jobs' => $jobs, 'switches' => $switches, 'checked_at' => date('c')], JSON_UNESCAPED_UNICODE);