- Delete kuma_client.py and all Kuma-related code - Remove /infrastructure/monitors endpoints - Update service start/stop to use Portainer only - Simplify service control widget to show container status - Remove Kuma config and credentials - Delete stale memory tests (moved to core-ai service) - Add test infrastructure with pytest - Add tests for service_groups, config, and health endpoints - Bump version to 1.1.0 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
382 lines
12 KiB
HTML
382 lines
12 KiB
HTML
<!DOCTYPE html>
|
|
<html>
|
|
<head>
|
|
<meta charset="UTF-8">
|
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
<title>Service Control</title>
|
|
<style>
|
|
* {
|
|
margin: 0;
|
|
padding: 0;
|
|
box-sizing: border-box;
|
|
}
|
|
|
|
body {
|
|
font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
|
|
background: transparent;
|
|
color: #e0e0e0;
|
|
padding: 15px;
|
|
}
|
|
|
|
.container {
|
|
max-width: 100%;
|
|
}
|
|
|
|
.section {
|
|
margin-bottom: 30px;
|
|
}
|
|
|
|
.section-header {
|
|
color: #fff;
|
|
font-size: 18px;
|
|
font-weight: 600;
|
|
margin-bottom: 12px;
|
|
padding-bottom: 8px;
|
|
border-bottom: 2px solid rgba(255, 255, 255, 0.1);
|
|
}
|
|
|
|
.service-list {
|
|
display: flex;
|
|
flex-direction: column;
|
|
gap: 8px;
|
|
}
|
|
|
|
.service-row {
|
|
background: rgba(40, 40, 40, 0.95);
|
|
border: 1px solid rgba(255, 255, 255, 0.1);
|
|
border-radius: 6px;
|
|
padding: 12px 16px;
|
|
display: flex;
|
|
align-items: center;
|
|
justify-content: space-between;
|
|
transition: all 0.2s ease;
|
|
gap: 15px;
|
|
}
|
|
|
|
.service-row:hover {
|
|
border-color: rgba(66, 153, 225, 0.4);
|
|
background: rgba(45, 45, 45, 0.95);
|
|
}
|
|
|
|
.service-left {
|
|
display: flex;
|
|
align-items: center;
|
|
gap: 15px;
|
|
flex: 1;
|
|
min-width: 0;
|
|
}
|
|
|
|
.service-name {
|
|
font-size: 15px;
|
|
font-weight: 600;
|
|
color: #fff;
|
|
text-transform: capitalize;
|
|
min-width: 200px;
|
|
}
|
|
|
|
.service-status {
|
|
display: flex;
|
|
align-items: center;
|
|
gap: 8px;
|
|
min-width: 180px;
|
|
}
|
|
|
|
.status-indicator {
|
|
width: 8px;
|
|
height: 8px;
|
|
border-radius: 50%;
|
|
flex-shrink: 0;
|
|
}
|
|
|
|
.status-indicator.running {
|
|
background: #48bb78;
|
|
box-shadow: 0 0 8px rgba(72, 187, 120, 0.6);
|
|
}
|
|
|
|
.status-indicator.stopped {
|
|
background: #f56565;
|
|
box-shadow: 0 0 8px rgba(245, 101, 101, 0.6);
|
|
}
|
|
|
|
.status-text {
|
|
font-size: 13px;
|
|
color: #a0a0a0;
|
|
}
|
|
|
|
.service-right {
|
|
display: flex;
|
|
align-items: center;
|
|
gap: 8px;
|
|
}
|
|
|
|
.btn {
|
|
padding: 6px 16px;
|
|
border: none;
|
|
border-radius: 4px;
|
|
font-size: 12px;
|
|
font-weight: 600;
|
|
cursor: pointer;
|
|
transition: all 0.2s ease;
|
|
text-transform: uppercase;
|
|
letter-spacing: 0.5px;
|
|
min-width: 70px;
|
|
}
|
|
|
|
.btn:disabled {
|
|
opacity: 0.3;
|
|
cursor: not-allowed;
|
|
}
|
|
|
|
.btn-start {
|
|
background: linear-gradient(135deg, #48bb78 0%, #38a169 100%);
|
|
color: white;
|
|
}
|
|
|
|
.btn-start:hover:not(:disabled) {
|
|
background: linear-gradient(135deg, #38a169 0%, #2f855a 100%);
|
|
transform: translateY(-1px);
|
|
box-shadow: 0 2px 8px rgba(72, 187, 120, 0.3);
|
|
}
|
|
|
|
.btn-stop {
|
|
background: linear-gradient(135deg, #f56565 0%, #e53e3e 100%);
|
|
color: white;
|
|
}
|
|
|
|
.btn-stop:hover:not(:disabled) {
|
|
background: linear-gradient(135deg, #e53e3e 0%, #c53030 100%);
|
|
transform: translateY(-1px);
|
|
box-shadow: 0 2px 8px rgba(245, 101, 101, 0.3);
|
|
}
|
|
|
|
.loading {
|
|
text-align: center;
|
|
padding: 30px;
|
|
color: #a0a0a0;
|
|
}
|
|
|
|
.error {
|
|
background: rgba(245, 101, 101, 0.1);
|
|
border: 1px solid rgba(245, 101, 101, 0.4);
|
|
color: #f56565;
|
|
padding: 12px;
|
|
border-radius: 6px;
|
|
margin-bottom: 15px;
|
|
}
|
|
|
|
.always-on-badge {
|
|
font-size: 10px;
|
|
color: #4299e1;
|
|
background: rgba(66, 153, 225, 0.15);
|
|
padding: 2px 6px;
|
|
border-radius: 3px;
|
|
margin-left: 8px;
|
|
text-transform: uppercase;
|
|
font-weight: 600;
|
|
}
|
|
|
|
@keyframes spin {
|
|
to { transform: rotate(360deg); }
|
|
}
|
|
|
|
.spinner {
|
|
display: inline-block;
|
|
width: 12px;
|
|
height: 12px;
|
|
border: 2px solid rgba(255, 255, 255, 0.3);
|
|
border-top-color: #fff;
|
|
border-radius: 50%;
|
|
animation: spin 0.6s linear infinite;
|
|
margin-right: 6px;
|
|
}
|
|
|
|
/* Responsive design */
|
|
@media (max-width: 768px) {
|
|
.service-row {
|
|
flex-wrap: wrap;
|
|
}
|
|
|
|
.service-name {
|
|
min-width: 100px;
|
|
}
|
|
|
|
.service-right {
|
|
width: 100%;
|
|
justify-content: flex-end;
|
|
}
|
|
}
|
|
</style>
|
|
</head>
|
|
<body>
|
|
<div class="container">
|
|
<div id="error-container"></div>
|
|
|
|
<div class="section">
|
|
<div class="section-header">Stoppable Services</div>
|
|
<div id="stoppable-container" class="loading">Loading services...</div>
|
|
</div>
|
|
|
|
<div class="section">
|
|
<div class="section-header">Always-On Infrastructure</div>
|
|
<div id="always-on-container" class="loading">Loading infrastructure...</div>
|
|
</div>
|
|
</div>
|
|
|
|
<script>
|
|
// Use relative URL to work in any context (iframe, direct access, etc.)
|
|
const API_BASE = '';
|
|
|
|
let services = [];
|
|
let alwaysOnServices = [];
|
|
|
|
async function fetchData() {
|
|
try {
|
|
// Single API call to get all data
|
|
const response = await fetch(`${API_BASE}/infrastructure/widget-data`);
|
|
|
|
if (!response.ok) {
|
|
throw new Error(`HTTP ${response.status}: ${response.statusText}`);
|
|
}
|
|
|
|
const data = await response.json();
|
|
|
|
if (!data.success) {
|
|
throw new Error('API returned unsuccessful response');
|
|
}
|
|
|
|
// Update services
|
|
services = data.services || [];
|
|
|
|
// Update always-on services list
|
|
if (data.service_groups && data.service_groups.always_on) {
|
|
alwaysOnServices = data.service_groups.always_on;
|
|
}
|
|
|
|
renderServices();
|
|
document.getElementById('error-container').innerHTML = '';
|
|
|
|
} catch (error) {
|
|
console.error('Error fetching data:', error);
|
|
document.getElementById('error-container').innerHTML =
|
|
`<div class="error">Failed to connect to API: ${error.message}</div>`;
|
|
}
|
|
}
|
|
|
|
function isAlwaysOn(serviceName) {
|
|
return alwaysOnServices.includes(serviceName.toLowerCase());
|
|
}
|
|
|
|
function renderServiceRow(service) {
|
|
const isRunning = service.containers_running > 0;
|
|
const alwaysOn = isAlwaysOn(service.name);
|
|
|
|
return `
|
|
<div class="service-row" data-service="${service.name}">
|
|
<div class="service-left">
|
|
<div class="service-name">
|
|
${service.name}
|
|
${alwaysOn ? '<span class="always-on-badge">Protected</span>' : ''}
|
|
</div>
|
|
<div class="service-status">
|
|
<div class="status-indicator ${isRunning ? 'running' : 'stopped'}"></div>
|
|
<span class="status-text">
|
|
${isRunning ? `Running (${service.containers_running}/${service.containers_total})` : 'Stopped'}
|
|
</span>
|
|
</div>
|
|
</div>
|
|
<div class="service-right">
|
|
<button class="btn btn-start"
|
|
onclick="controlService('${service.name}', 'start')"
|
|
${isRunning || alwaysOn ? 'disabled' : ''}>
|
|
Start
|
|
</button>
|
|
<button class="btn btn-stop"
|
|
onclick="controlService('${service.name}', 'stop')"
|
|
${!isRunning || alwaysOn ? 'disabled' : ''}>
|
|
Stop
|
|
</button>
|
|
</div>
|
|
</div>
|
|
`;
|
|
}
|
|
|
|
function renderServices() {
|
|
const stoppableContainer = document.getElementById('stoppable-container');
|
|
const alwaysOnContainer = document.getElementById('always-on-container');
|
|
|
|
// Stoppable services
|
|
const stoppableServices = services.filter(s => !isAlwaysOn(s.name));
|
|
|
|
if (stoppableServices.length === 0) {
|
|
stoppableContainer.innerHTML = '<div class="loading">No stoppable services found</div>';
|
|
} else {
|
|
stoppableContainer.className = 'service-list';
|
|
stoppableContainer.innerHTML = stoppableServices
|
|
.sort((a, b) => a.name.localeCompare(b.name))
|
|
.map(service => renderServiceRow(service))
|
|
.join('');
|
|
}
|
|
|
|
// Always-on services
|
|
const alwaysOnServicesList = services.filter(s => isAlwaysOn(s.name));
|
|
|
|
if (alwaysOnServicesList.length === 0) {
|
|
alwaysOnContainer.innerHTML = '<div class="loading">No infrastructure services found</div>';
|
|
} else {
|
|
alwaysOnContainer.className = 'service-list';
|
|
alwaysOnContainer.innerHTML = alwaysOnServicesList
|
|
.sort((a, b) => a.name.localeCompare(b.name))
|
|
.map(service => renderServiceRow(service))
|
|
.join('');
|
|
}
|
|
}
|
|
|
|
async function controlService(serviceName, action) {
|
|
const row = document.querySelector(`[data-service="${serviceName}"]`);
|
|
const buttons = row.querySelectorAll('button');
|
|
|
|
// Disable all buttons and show loading
|
|
buttons.forEach(btn => {
|
|
btn.disabled = true;
|
|
if (btn.textContent.toLowerCase().includes(action)) {
|
|
btn.innerHTML = `<span class="spinner"></span>${action}`;
|
|
}
|
|
});
|
|
|
|
try {
|
|
const response = await fetch(`${API_BASE}/infrastructure/services/${serviceName}/${action}`, {
|
|
method: 'POST'
|
|
});
|
|
|
|
const result = await response.json();
|
|
|
|
if (!response.ok || !result.success) {
|
|
throw new Error(result.message || result.detail || 'Operation failed');
|
|
}
|
|
|
|
console.log(`${action} ${serviceName}:`, result);
|
|
|
|
// Wait for containers to start/stop
|
|
await new Promise(resolve => setTimeout(resolve, 2000));
|
|
|
|
// Refresh service list
|
|
await fetchData();
|
|
|
|
} catch (error) {
|
|
console.error(`Error ${action}ing ${serviceName}:`, error);
|
|
alert(`Failed to ${action} ${serviceName}: ${error.message}`);
|
|
|
|
// Re-enable buttons on error
|
|
await fetchData();
|
|
}
|
|
}
|
|
|
|
// Auto-refresh every 10 seconds
|
|
setInterval(fetchData, 10000);
|
|
|
|
// Initial load
|
|
fetchData();
|
|
</script>
|
|
</body>
|
|
</html>
|