Add target FPS slider to Capture Settings and remove unused HACS workflow
- Add Target FPS slider (range 10-90) to Capture Settings dialog - Fix settings PUT to merge with current values instead of resetting defaults - Update FPS validation range to 10-90 in schema and config - Remove irrelevant .github/workflows/validate.yml (HACS leftover) Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -871,11 +871,12 @@ let captureSettingsInitialValues = {};
|
||||
|
||||
async function showCaptureSettings(deviceId) {
|
||||
try {
|
||||
// Fetch device data, displays, and templates in parallel
|
||||
const [deviceResponse, displaysResponse, templatesResponse] = await Promise.all([
|
||||
// Fetch device data, displays, templates, and settings in parallel
|
||||
const [deviceResponse, displaysResponse, templatesResponse, settingsResponse] = await Promise.all([
|
||||
fetch(`${API_BASE}/devices/${deviceId}`, { headers: getHeaders() }),
|
||||
fetch(`${API_BASE}/config/displays`, { headers: getHeaders() }),
|
||||
fetchWithAuth('/capture-templates'),
|
||||
fetch(`${API_BASE}/devices/${deviceId}/settings`, { headers: getHeaders() }),
|
||||
]);
|
||||
|
||||
if (deviceResponse.status === 401) {
|
||||
@@ -889,6 +890,7 @@ async function showCaptureSettings(deviceId) {
|
||||
}
|
||||
|
||||
const device = await deviceResponse.json();
|
||||
const currentSettings = settingsResponse.ok ? await settingsResponse.json() : {};
|
||||
|
||||
// Populate display index select
|
||||
const displaySelect = document.getElementById('capture-settings-display-index');
|
||||
@@ -910,6 +912,11 @@ async function showCaptureSettings(deviceId) {
|
||||
}
|
||||
displaySelect.value = String(device.settings.display_index ?? 0);
|
||||
|
||||
// Populate FPS slider
|
||||
const fpsValue = Math.max(10, Math.min(90, currentSettings.fps ?? 30));
|
||||
document.getElementById('capture-settings-fps').value = fpsValue;
|
||||
document.getElementById('capture-settings-fps-value').textContent = fpsValue;
|
||||
|
||||
// Populate capture template select
|
||||
const templateSelect = document.getElementById('capture-settings-template');
|
||||
templateSelect.innerHTML = '';
|
||||
@@ -931,11 +938,13 @@ async function showCaptureSettings(deviceId) {
|
||||
}
|
||||
templateSelect.value = device.capture_template_id || 'tpl_mss_default';
|
||||
|
||||
// Store device ID and snapshot initial values
|
||||
// Store device ID, current settings snapshot, and initial values for dirty check
|
||||
document.getElementById('capture-settings-device-id').value = device.id;
|
||||
captureSettingsInitialValues = {
|
||||
display_index: String(device.settings.display_index ?? 0),
|
||||
fps: String(currentSettings.fps ?? 30),
|
||||
capture_template_id: device.capture_template_id || 'tpl_mss_default',
|
||||
_currentSettings: currentSettings,
|
||||
};
|
||||
|
||||
// Show modal
|
||||
@@ -952,6 +961,7 @@ async function showCaptureSettings(deviceId) {
|
||||
function isCaptureSettingsDirty() {
|
||||
return (
|
||||
document.getElementById('capture-settings-display-index').value !== captureSettingsInitialValues.display_index ||
|
||||
document.getElementById('capture-settings-fps').value !== captureSettingsInitialValues.fps ||
|
||||
document.getElementById('capture-settings-template').value !== captureSettingsInitialValues.capture_template_id
|
||||
);
|
||||
}
|
||||
@@ -976,6 +986,7 @@ async function closeCaptureSettingsModal() {
|
||||
async function saveCaptureSettings() {
|
||||
const deviceId = document.getElementById('capture-settings-device-id').value;
|
||||
const display_index = parseInt(document.getElementById('capture-settings-display-index').value) || 0;
|
||||
const fps = parseInt(document.getElementById('capture-settings-fps').value) || 30;
|
||||
const capture_template_id = document.getElementById('capture-settings-template').value;
|
||||
const error = document.getElementById('capture-settings-error');
|
||||
|
||||
@@ -999,11 +1010,18 @@ async function saveCaptureSettings() {
|
||||
return;
|
||||
}
|
||||
|
||||
// Update display index in settings
|
||||
// Merge changed fields with current settings to avoid resetting other values
|
||||
const mergedSettings = {
|
||||
...(captureSettingsInitialValues._currentSettings || {}),
|
||||
display_index,
|
||||
fps,
|
||||
};
|
||||
|
||||
// Update settings
|
||||
const settingsResponse = await fetch(`${API_BASE}/devices/${deviceId}/settings`, {
|
||||
method: 'PUT',
|
||||
headers: getHeaders(),
|
||||
body: JSON.stringify({ display_index })
|
||||
body: JSON.stringify(mergedSettings)
|
||||
});
|
||||
|
||||
if (settingsResponse.status === 401) {
|
||||
|
||||
Reference in New Issue
Block a user