python v2 - added feartures 1 and 3 - no errors

This commit is contained in:
2025-08-08 14:32:16 -07:00
parent 9ed2f3720d
commit 4207ffe5aa
3 changed files with 101 additions and 6 deletions

View File

@@ -11,6 +11,7 @@ async function updateStatus() {
<p>Status: <span class="badge ${data.daemon.running ? 'badge-success' : 'badge-danger'}">
${data.daemon.running ? 'Running' : 'Stopped'}
</span></p>
<p>Last Run: ${data.daemon.last_run || 'Never'}</p>
<p>Next Run: ${data.daemon.next_run || 'Not scheduled'}</p>
<p>Schedule: ${data.daemon.schedule || 'Not configured'}</p>
`;
@@ -23,6 +24,7 @@ async function updateStatus() {
${log.status}
</span>
${log.operation}: ${log.message || ''}
${log.activities_downloaded > 0 ? `Downloaded ${log.activities_downloaded} activities` : ''}
</div>
`).join('');
@@ -43,10 +45,54 @@ async function triggerSync() {
}
}
async function toggleDaemon() {
try {
const statusResponse = await fetch('/api/status');
const statusData = await statusResponse.json();
const isRunning = statusData.daemon.running;
if (isRunning) {
await fetch('/api/daemon/stop', { method: 'POST' });
alert('Daemon stopped successfully');
} else {
await fetch('/api/daemon/start', { method: 'POST' });
alert('Daemon started successfully');
}
updateStatus();
} catch (error) {
alert('Failed to toggle daemon: ' + error.message);
}
}
// Schedule form handling
document.getElementById('schedule-form')?.addEventListener('submit', async function(e) {
e.preventDefault();
const enabled = document.getElementById('schedule-enabled').checked;
const cronSchedule = document.getElementById('cron-schedule').value;
try {
const response = await fetch('/api/schedule', {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({
enabled: enabled,
cron_schedule: cronSchedule
})
});
if (response.ok) {
alert('Schedule updated successfully');
updateStatus();
} else {
const error = await response.json();
alert(`Error: ${error.detail}`);
}
} catch (error) {
alert('Failed to update schedule: ' + error.message);
}
});
// Initialize on page load
document.addEventListener('DOMContentLoaded', updateStatus);
async function toggleDaemon() {
// TODO: Implement daemon toggle functionality
alert('Daemon toggle functionality not yet implemented');
}