feat(network): Add traffic stats endpoint and dashboard UI; enhance platform services and certificate health reporting
This commit is contained in:
@@ -219,12 +219,51 @@ export class Onebox {
|
||||
const runningServices = services.filter((s) => s.status === 'running').length;
|
||||
const totalServices = services.length;
|
||||
|
||||
// Get platform services status
|
||||
// Get platform services status with resource counts
|
||||
const platformServices = this.platformServices.getAllPlatformServices();
|
||||
const platformServicesStatus = platformServices.map((ps) => ({
|
||||
type: ps.type,
|
||||
status: ps.status,
|
||||
}));
|
||||
const providers = this.platformServices.getAllProviders();
|
||||
const platformServicesStatus = providers.map((provider) => {
|
||||
const service = platformServices.find((s) => s.type === provider.type);
|
||||
// For Caddy, check actual runtime status since it starts without a DB record
|
||||
let status = service?.status || 'not-deployed';
|
||||
if (provider.type === 'caddy') {
|
||||
status = proxyStatus.http.running ? 'running' : 'stopped';
|
||||
}
|
||||
// Count resources for this platform service
|
||||
const resourceCount = service?.id
|
||||
? this.database.getPlatformResourcesByPlatformService(service.id).length
|
||||
: 0;
|
||||
return {
|
||||
type: provider.type,
|
||||
displayName: provider.displayName,
|
||||
status,
|
||||
resourceCount,
|
||||
};
|
||||
});
|
||||
|
||||
// Get certificate health summary
|
||||
const certificates = this.ssl.listCertificates();
|
||||
const now = Date.now();
|
||||
const thirtyDaysMs = 30 * 24 * 60 * 60 * 1000;
|
||||
let validCount = 0;
|
||||
let expiringCount = 0;
|
||||
let expiredCount = 0;
|
||||
const expiringDomains: { domain: string; daysRemaining: number }[] = [];
|
||||
|
||||
for (const cert of certificates) {
|
||||
if (cert.expiryDate <= now) {
|
||||
expiredCount++;
|
||||
} else if (cert.expiryDate <= now + thirtyDaysMs) {
|
||||
expiringCount++;
|
||||
const daysRemaining = Math.floor((cert.expiryDate - now) / (24 * 60 * 60 * 1000));
|
||||
expiringDomains.push({ domain: cert.domain, daysRemaining });
|
||||
} else {
|
||||
validCount++;
|
||||
}
|
||||
}
|
||||
|
||||
// Sort expiring domains by days remaining (ascending)
|
||||
expiringDomains.sort((a, b) => a.daysRemaining - b.daysRemaining);
|
||||
|
||||
return {
|
||||
docker: {
|
||||
@@ -245,6 +284,12 @@ export class Onebox {
|
||||
stopped: totalServices - runningServices,
|
||||
},
|
||||
platformServices: platformServicesStatus,
|
||||
certificateHealth: {
|
||||
valid: validCount,
|
||||
expiringSoon: expiringCount,
|
||||
expired: expiredCount,
|
||||
expiringDomains: expiringDomains.slice(0, 5), // Top 5 expiring
|
||||
},
|
||||
};
|
||||
} catch (error) {
|
||||
logger.error(`Failed to get system status: ${getErrorMessage(error)}`);
|
||||
|
||||
Reference in New Issue
Block a user