async function restartContainer(id) {
    try {
        const response = await fetch(`/api/containers/${id}/restart`, {
            method: 'POST'
        });
        if (!response.ok) throw new Error('Failed to restart container');
        location.reload();
    } catch (error) {
        console.error('Error:', error);
        alert('Failed to restart container');
    }
}

async function stopContainer(id) {
    try {
        const response = await fetch(`/api/containers/${id}/stop`, {
            method: 'POST'
        });
        if (!response.ok) throw new Error('Failed to stop container');
        location.reload();
    } catch (error) {
        console.error('Error:', error);
        alert('Failed to stop container');
    }
}

// Auto-refresh the page every 30 seconds
setInterval(() => {
    location.reload();
}, 30000); 