mirror of
https://github.com/MrSleeps/jellyfin-scene-search.git
synced 2026-11-17 23:41:28 +00:00
Use one stateful caption control in web dashboard
This commit is contained in:
+24
-16
@@ -111,7 +111,6 @@
|
||||
<div id="captionDetail" class="muted"></div>
|
||||
<div class="row" style="margin-top:14px">
|
||||
<button id="captionNow" type="button">Start / resume captioning</button>
|
||||
<button id="captionPause" type="button" class="secondary" disabled>Pause</button>
|
||||
<label><input id="forceCaption" type="checkbox"> Force recaption</label>
|
||||
</div>
|
||||
</section>
|
||||
@@ -362,11 +361,12 @@
|
||||
$('captionFrames').textContent = (s.frames_completed || 0) + ' / ' + (s.frames_total || 0) + ' frames';
|
||||
|
||||
if (s.running) {
|
||||
$('captionNow').disabled = true;
|
||||
$('captionPause').disabled = s.stage === 'syncing' || s.stage === 'sync';
|
||||
$('captionPause').textContent = s.paused
|
||||
? 'Resume'
|
||||
: (s.pause_requested ? 'Cancel pause' : 'Pause');
|
||||
const syncing = s.stage === 'syncing' || s.stage === 'sync';
|
||||
$('captionNow').disabled = syncing;
|
||||
$('captionNow').textContent = syncing
|
||||
? 'Finishing...'
|
||||
: ((s.paused || s.pause_requested) ? 'Resume' : 'Pause');
|
||||
$('forceCaption').disabled = true;
|
||||
$('captionStatus').className = 'status';
|
||||
if (s.paused) {
|
||||
$('captionStatus').textContent = 'Captioning paused';
|
||||
@@ -394,15 +394,15 @@
|
||||
}
|
||||
} else if (s.stage === 'failed') {
|
||||
$('captionNow').disabled = false;
|
||||
$('captionPause').disabled = true;
|
||||
$('captionPause').textContent = 'Pause';
|
||||
$('captionNow').textContent = 'Start / resume captioning';
|
||||
$('forceCaption').disabled = false;
|
||||
$('captionStatus').className = 'status error';
|
||||
$('captionStatus').textContent = 'Failed: ' + (s.error || 'unknown error');
|
||||
$('captionDetail').textContent = '';
|
||||
} else if (s.stage === 'complete') {
|
||||
$('captionNow').disabled = false;
|
||||
$('captionPause').disabled = true;
|
||||
$('captionPause').textContent = 'Pause';
|
||||
$('captionNow').textContent = 'Start / resume captioning';
|
||||
$('forceCaption').disabled = false;
|
||||
$('captionStatus').className = 'status ok';
|
||||
$('captionStatus').textContent =
|
||||
'Complete: ' + (s.frames_completed || 0) + ' saved, ' + (s.failed || 0) + ' failed';
|
||||
@@ -410,8 +410,8 @@
|
||||
(s.retained || 0) + ' existing captions retained';
|
||||
} else {
|
||||
$('captionNow').disabled = false;
|
||||
$('captionPause').disabled = true;
|
||||
$('captionPause').textContent = 'Pause';
|
||||
$('captionNow').textContent = 'Start / resume captioning';
|
||||
$('forceCaption').disabled = false;
|
||||
$('captionStatus').className = 'status muted';
|
||||
$('captionStatus').textContent = 'Idle';
|
||||
$('captionDetail').textContent = '';
|
||||
@@ -456,14 +456,23 @@
|
||||
}
|
||||
}
|
||||
|
||||
async function toggleCaptionPause() {
|
||||
if (!captionLastStatus || !captionLastStatus.running) return;
|
||||
async function captionAction() {
|
||||
if (!captionLastStatus || !captionLastStatus.running) {
|
||||
await startCaption();
|
||||
return;
|
||||
}
|
||||
|
||||
if (captionLastStatus.stage === 'syncing' || captionLastStatus.stage === 'sync') {
|
||||
return;
|
||||
}
|
||||
|
||||
const resume = captionLastStatus.paused || captionLastStatus.pause_requested;
|
||||
try {
|
||||
const s = await api(resume ? '/api/caption/resume' : '/api/caption/pause', {
|
||||
method:'POST'
|
||||
});
|
||||
renderCaptionStatus(s);
|
||||
lastCaptionRunning = !!s.running;
|
||||
} catch (e) {
|
||||
$('captionStatus').className = 'status error';
|
||||
$('captionStatus').textContent = e.message;
|
||||
@@ -532,8 +541,7 @@
|
||||
$('selectAll').onclick = () => document.querySelectorAll('.libraryCheck').forEach(x => x.checked = true);
|
||||
$('applyLibraries').onclick = applyLibrarySelection;
|
||||
$('indexNow').onclick = startIndex;
|
||||
$('captionNow').onclick = startCaption;
|
||||
$('captionPause').onclick = toggleCaptionPause;
|
||||
$('captionNow').onclick = captionAction;
|
||||
$('reportFailed').onclick = () => loadIndexReport('failed');
|
||||
$('reportRemoved').onclick = () => loadIndexReport('removed');
|
||||
$('reportIndexed').onclick = () => loadIndexReport('indexed');
|
||||
|
||||
Reference in New Issue
Block a user