dockscope 0.2.5 → 0.2.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/docker/client.d.ts +4 -2
- package/dist/docker/client.js +9 -0
- package/dist/server/routes.js +47 -1
- package/dist/types.d.ts +4 -0
- package/dist/web/assets/{index-CmgdeoHt.js → index-BkwzBX9M.js} +228 -228
- package/dist/web/assets/index-ChByk1Ol.css +1 -0
- package/dist/web/index.html +2 -2
- package/package.json +1 -1
- package/dist/web/assets/index-DUOQEliU.css +0 -1
package/dist/docker/client.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { GraphData, ContainerStats, ContainerInspect, SystemInfo, DockerEvent } from '../types.js';
|
|
1
|
+
import type { GraphData, ContainerStats, ContainerInspect, ContainerTopResult, SystemInfo, DockerEvent } from '../types.js';
|
|
2
2
|
export declare function checkConnection(): Promise<boolean>;
|
|
3
3
|
export declare function buildGraph(composeFile?: string): Promise<GraphData>;
|
|
4
4
|
export declare const getContainerStats: (id: string) => Promise<ContainerStats>;
|
|
@@ -12,7 +12,9 @@ export declare function listComposeProjects(): Promise<{
|
|
|
12
12
|
}[]>;
|
|
13
13
|
/** Run a docker compose action on a specific project */
|
|
14
14
|
export declare function composeAction(project: string, action: 'up' | 'down' | 'stop' | 'start' | 'restart'): Promise<string>;
|
|
15
|
-
export declare function containerAction(containerId: string, action: 'start' | 'stop' | 'restart'): Promise<void>;
|
|
15
|
+
export declare function containerAction(containerId: string, action: 'start' | 'stop' | 'restart' | 'pause' | 'unpause' | 'kill'): Promise<void>;
|
|
16
|
+
export declare function removeContainer(containerId: string, removeVolumes?: boolean): Promise<void>;
|
|
17
|
+
export declare function getContainerTop(containerId: string): Promise<ContainerTopResult>;
|
|
16
18
|
export declare function inspectContainer(containerId: string): Promise<ContainerInspect>;
|
|
17
19
|
export declare function getSystemInfo(): Promise<SystemInfo>;
|
|
18
20
|
export declare function watchEvents(callback: (event: DockerEvent) => void, onError?: (err: Error) => void): () => void;
|
package/dist/docker/client.js
CHANGED
|
@@ -177,6 +177,15 @@ export async function containerAction(containerId, action) {
|
|
|
177
177
|
const container = docker.getContainer(containerId);
|
|
178
178
|
await container[action]();
|
|
179
179
|
}
|
|
180
|
+
export async function removeContainer(containerId, removeVolumes = false) {
|
|
181
|
+
const container = docker.getContainer(containerId);
|
|
182
|
+
await container.remove({ force: true, v: removeVolumes });
|
|
183
|
+
}
|
|
184
|
+
export async function getContainerTop(containerId) {
|
|
185
|
+
const container = docker.getContainer(containerId);
|
|
186
|
+
const top = await container.top();
|
|
187
|
+
return { titles: top.Titles || [], processes: top.Processes || [] };
|
|
188
|
+
}
|
|
180
189
|
export async function inspectContainer(containerId) {
|
|
181
190
|
const container = docker.getContainer(containerId);
|
|
182
191
|
const info = await container.inspect();
|
package/dist/server/routes.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { buildGraph, checkConnection, composeAction, containerAction, getContainerLogs, getContainerStats, getSystemInfo, inspectContainer, listComposeProjects, } from '../docker/client.js';
|
|
1
|
+
import { buildGraph, checkConnection, composeAction, containerAction, getContainerLogs, getContainerStats, getContainerTop, getSystemInfo, inspectContainer, listComposeProjects, removeContainer, } from '../docker/client.js';
|
|
2
2
|
export function setupRoutes(app, opts, metricHistory) {
|
|
3
3
|
app.get('/api/graph', async (_req, res) => {
|
|
4
4
|
try {
|
|
@@ -59,6 +59,52 @@ export function setupRoutes(app, opts, metricHistory) {
|
|
|
59
59
|
res.status(500).json({ error: err.message });
|
|
60
60
|
}
|
|
61
61
|
});
|
|
62
|
+
app.post('/api/containers/:id/pause', async (req, res) => {
|
|
63
|
+
try {
|
|
64
|
+
await containerAction(req.params.id, 'pause');
|
|
65
|
+
res.json({ ok: true });
|
|
66
|
+
}
|
|
67
|
+
catch (err) {
|
|
68
|
+
res.status(500).json({ error: err.message });
|
|
69
|
+
}
|
|
70
|
+
});
|
|
71
|
+
app.post('/api/containers/:id/unpause', async (req, res) => {
|
|
72
|
+
try {
|
|
73
|
+
await containerAction(req.params.id, 'unpause');
|
|
74
|
+
res.json({ ok: true });
|
|
75
|
+
}
|
|
76
|
+
catch (err) {
|
|
77
|
+
res.status(500).json({ error: err.message });
|
|
78
|
+
}
|
|
79
|
+
});
|
|
80
|
+
app.post('/api/containers/:id/kill', async (req, res) => {
|
|
81
|
+
try {
|
|
82
|
+
await containerAction(req.params.id, 'kill');
|
|
83
|
+
res.json({ ok: true });
|
|
84
|
+
}
|
|
85
|
+
catch (err) {
|
|
86
|
+
res.status(500).json({ error: err.message });
|
|
87
|
+
}
|
|
88
|
+
});
|
|
89
|
+
app.delete('/api/containers/:id', async (req, res) => {
|
|
90
|
+
try {
|
|
91
|
+
const volumes = req.query.volumes === 'true';
|
|
92
|
+
await removeContainer(req.params.id, volumes);
|
|
93
|
+
res.json({ ok: true });
|
|
94
|
+
}
|
|
95
|
+
catch (err) {
|
|
96
|
+
res.status(500).json({ error: err.message });
|
|
97
|
+
}
|
|
98
|
+
});
|
|
99
|
+
app.get('/api/containers/:id/top', async (req, res) => {
|
|
100
|
+
try {
|
|
101
|
+
const top = await getContainerTop(req.params.id);
|
|
102
|
+
res.json(top);
|
|
103
|
+
}
|
|
104
|
+
catch (err) {
|
|
105
|
+
res.status(500).json({ error: err.message });
|
|
106
|
+
}
|
|
107
|
+
});
|
|
62
108
|
app.get('/api/containers/:id/inspect', async (req, res) => {
|
|
63
109
|
try {
|
|
64
110
|
const info = await inspectContainer(req.params.id);
|
package/dist/types.d.ts
CHANGED