asdasd
This commit is contained in:
@@ -416,6 +416,25 @@ if ($_SERVER['REQUEST_METHOD'] === 'POST') {
|
|||||||
$isSchedulerAutosave = isset($_POST['scheduler_autosave']) && (string) $_POST['scheduler_autosave'] === '1';
|
$isSchedulerAutosave = isset($_POST['scheduler_autosave']) && (string) $_POST['scheduler_autosave'] === '1';
|
||||||
$payload = [];
|
$payload = [];
|
||||||
|
|
||||||
|
if ($isSchedulerAutosave) {
|
||||||
|
if ($cronTaskDefinitions !== []) {
|
||||||
|
$postedSchedulerJobs = is_array($_POST['scheduler_jobs'] ?? null) ? $_POST['scheduler_jobs'] : [];
|
||||||
|
$current['scheduler_jobs'] = $extractSchedulerJobs($postedSchedulerJobs, $cronTaskDefinitions, $current);
|
||||||
|
}
|
||||||
|
modules()->saveSettings($moduleName, $current);
|
||||||
|
$current = modules()->settings($moduleName);
|
||||||
|
$refreshSchedulerState();
|
||||||
|
|
||||||
|
header('Content-Type: application/json; charset=utf-8');
|
||||||
|
echo json_encode([
|
||||||
|
'ok' => true,
|
||||||
|
'message' => 'Scheduler gespeichert.',
|
||||||
|
'scheduler_jobs' => $current['scheduler_jobs'] ?? [],
|
||||||
|
'statuses' => $cronTaskStatuses,
|
||||||
|
], JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES);
|
||||||
|
exit;
|
||||||
|
}
|
||||||
|
|
||||||
foreach ($fields as $field) {
|
foreach ($fields as $field) {
|
||||||
$name = (string)($field['name'] ?? '');
|
$name = (string)($field['name'] ?? '');
|
||||||
if ($name === '') {
|
if ($name === '') {
|
||||||
@@ -462,21 +481,6 @@ if ($_SERVER['REQUEST_METHOD'] === 'POST') {
|
|||||||
$current['scheduler_jobs'] = $schedulerJobs;
|
$current['scheduler_jobs'] = $schedulerJobs;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($isSchedulerAutosave) {
|
|
||||||
modules()->saveSettings($moduleName, $current);
|
|
||||||
$current = modules()->settings($moduleName);
|
|
||||||
$refreshSchedulerState();
|
|
||||||
|
|
||||||
header('Content-Type: application/json; charset=utf-8');
|
|
||||||
echo json_encode([
|
|
||||||
'ok' => true,
|
|
||||||
'message' => 'Scheduler gespeichert.',
|
|
||||||
'scheduler_jobs' => $current['scheduler_jobs'] ?? [],
|
|
||||||
'statuses' => $cronTaskStatuses,
|
|
||||||
], JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES);
|
|
||||||
exit;
|
|
||||||
}
|
|
||||||
|
|
||||||
$postedTestGroup = (string)($_POST['test_db'] ?? '');
|
$postedTestGroup = (string)($_POST['test_db'] ?? '');
|
||||||
$postedResetGroup = (string)($_POST['reset_db'] ?? '');
|
$postedResetGroup = (string)($_POST['reset_db'] ?? '');
|
||||||
$postedSetupAction = trim((string)($_POST['module_setup_action'] ?? ''));
|
$postedSetupAction = trim((string)($_POST['module_setup_action'] ?? ''));
|
||||||
@@ -1568,6 +1572,7 @@ $activeDbGroup = $testGroup !== null && array_key_exists($testGroup, $dbGroups)
|
|||||||
expression: modal.querySelector('[data-modal-expression]'),
|
expression: modal.querySelector('[data-modal-expression]'),
|
||||||
summary: modal.querySelector('[data-modal-summary]'),
|
summary: modal.querySelector('[data-modal-summary]'),
|
||||||
code: modal.querySelector('[data-modal-code]'),
|
code: modal.querySelector('[data-modal-code]'),
|
||||||
|
saveButton: modal.querySelector('[data-scheduler-save]'),
|
||||||
tabs: Array.from(modal.querySelectorAll('[data-builder-tab]')),
|
tabs: Array.from(modal.querySelectorAll('[data-builder-tab]')),
|
||||||
panels: Array.from(modal.querySelectorAll('[data-builder-panel]')),
|
panels: Array.from(modal.querySelectorAll('[data-builder-panel]')),
|
||||||
};
|
};
|
||||||
@@ -1743,13 +1748,20 @@ $activeDbGroup = $testGroup !== null && array_key_exists($testGroup, $dbGroups)
|
|||||||
method: 'POST',
|
method: 'POST',
|
||||||
body: collectSchedulerPayload(),
|
body: collectSchedulerPayload(),
|
||||||
headers: {
|
headers: {
|
||||||
|
'Accept': 'application/json',
|
||||||
'X-Requested-With': 'XMLHttpRequest',
|
'X-Requested-With': 'XMLHttpRequest',
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
if (!response.ok) {
|
if (!response.ok) {
|
||||||
throw new Error(`Scheduler konnte nicht gespeichert werden (${response.status}).`);
|
throw new Error(`Scheduler konnte nicht gespeichert werden (${response.status}).`);
|
||||||
}
|
}
|
||||||
const data = await response.json();
|
const raw = await response.text();
|
||||||
|
let data = null;
|
||||||
|
try {
|
||||||
|
data = JSON.parse(raw);
|
||||||
|
} catch (error) {
|
||||||
|
throw new Error(`Scheduler-Antwort war kein JSON: ${raw.slice(0, 160)}`);
|
||||||
|
}
|
||||||
if (!data || data.ok !== true) {
|
if (!data || data.ok !== true) {
|
||||||
throw new Error(data?.message || 'Scheduler konnte nicht gespeichert werden.');
|
throw new Error(data?.message || 'Scheduler konnte nicht gespeichert werden.');
|
||||||
}
|
}
|
||||||
@@ -1908,11 +1920,21 @@ $activeDbGroup = $testGroup !== null && array_key_exists($testGroup, $dbGroups)
|
|||||||
}
|
}
|
||||||
|
|
||||||
updateEntrySummary(entry);
|
updateEntrySummary(entry);
|
||||||
|
const originalLabel = modalFields.saveButton?.textContent || 'Uebernehmen';
|
||||||
|
if (modalFields.saveButton) {
|
||||||
|
modalFields.saveButton.disabled = true;
|
||||||
|
modalFields.saveButton.textContent = 'Speichert...';
|
||||||
|
}
|
||||||
try {
|
try {
|
||||||
await persistScheduler();
|
await persistScheduler();
|
||||||
closeModal();
|
closeModal();
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
alert(error instanceof Error ? error.message : 'Scheduler konnte nicht gespeichert werden.');
|
alert(error instanceof Error ? error.message : 'Scheduler konnte nicht gespeichert werden.');
|
||||||
|
} finally {
|
||||||
|
if (modalFields.saveButton) {
|
||||||
|
modalFields.saveButton.disabled = false;
|
||||||
|
modalFields.saveButton.textContent = originalLabel;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user