feat: add Docker events tab to docker dashboard

Adds a new Events tab to /dashboard/docker showing Docker daemon
events (equivalent to `docker events`), polled via docker.getEvents
with a time-range selector and refresh button.

Also fixes a stale isCloud redirect that forced the Networks tab
back to Containers even though it is now shown in cloud.
This commit is contained in:
Mauricio Siu
2026-08-12 04:07:59 -06:00
parent a60b0af419
commit daba2d7fbc
4 changed files with 327 additions and 10 deletions
+54
View File
@@ -871,3 +871,57 @@ export const deleteContainerFile = async (
throw error;
}
};
export interface DockerEvent {
Type?: string;
Action?: string;
Actor?: {
ID?: string;
Attributes?: Record<string, string>;
};
time?: number;
}
export const getDockerEvents = async (
serverId?: string | null,
minutes = 15,
) => {
const until = new Date();
const since = new Date(until.getTime() - minutes * 60 * 1000);
const command = `docker events --since ${quote([since.toISOString()])} --until ${quote([until.toISOString()])} --format '{{json .}}'`;
let stdout = "";
let stderr = "";
if (serverId) {
const result = await execAsyncRemote(serverId, command);
stdout = result.stdout;
stderr = result.stderr;
} else {
const result = await execAsync(command);
stdout = result.stdout;
stderr = result.stderr;
}
if (stderr) {
console.error(`Error: ${stderr}`);
}
const events: DockerEvent[] = stdout
.trim()
.split("\n")
.filter(Boolean)
.map((line) => {
try {
return JSON.parse(line) as DockerEvent;
} catch {
return null;
}
})
.filter((event): event is DockerEvent => event !== null)
.reverse();
return {
events,
fetchedAt: until.toISOString(),
};
};