opendocker 0.1.0 → 0.1.1
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/highlights-eq9cgrbb.scm +604 -0
- package/dist/highlights-ghv9g403.scm +205 -0
- package/dist/highlights-r812a2qc.scm +150 -0
- package/dist/highlights-x6tmsnaa.scm +115 -0
- package/dist/injections-73j83es3.scm +27 -0
- package/dist/main.js +235 -0
- package/dist/tree-sitter-javascript-nd0q4pe9.wasm +0 -0
- package/dist/tree-sitter-markdown-411r6y9b.wasm +0 -0
- package/dist/tree-sitter-markdown_inline-j5349f42.wasm +0 -0
- package/dist/tree-sitter-typescript-zxjzwt75.wasm +0 -0
- package/package.json +7 -6
- package/AGENTS.md +0 -22
- package/TODO.md +0 -53
- package/docker-compose.yml +0 -24
- package/src/assets/images/banner.jpg +0 -0
- package/src/components/Border.tsx +0 -19
- package/src/components/ContainersPane.tsx +0 -142
- package/src/components/ImagesPane.tsx +0 -83
- package/src/components/LogsPane.tsx +0 -128
- package/src/components/Pane.tsx +0 -34
- package/src/components/VolumesPanes.tsx +0 -84
- package/src/layouts/BaseLayout.tsx +0 -60
- package/src/lib/docker.ts +0 -68
- package/src/main.tsx +0 -40
- package/src/stores/application.ts +0 -11
- package/src/stores/containers.ts +0 -22
- package/src/stores/images.ts +0 -11
- package/src/stores/volumes.ts +0 -11
- package/src/utils/styling.ts +0 -198
- package/tsconfig.json +0 -15
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
package/package.json
CHANGED
|
@@ -1,16 +1,17 @@
|
|
|
1
1
|
{
|
|
2
|
+
"$schema": "https://json.schemastore.org/package.json",
|
|
3
|
+
"version": "0.1.1",
|
|
2
4
|
"name": "opendocker",
|
|
3
|
-
"version": "0.1.0",
|
|
4
|
-
"module": "index.ts",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"private": false,
|
|
7
7
|
"bin": {
|
|
8
|
-
"opendocker": "./
|
|
8
|
+
"opendocker": "./dist/main.js"
|
|
9
9
|
},
|
|
10
|
-
"
|
|
10
|
+
"files": ["dist/", "package.json", "README.md"],
|
|
11
11
|
"scripts": {
|
|
12
|
-
"start": "bun run
|
|
13
|
-
"dev": "bun --watch run src/main.tsx"
|
|
12
|
+
"start": "bun run dist/main.js",
|
|
13
|
+
"dev": "bun --watch run src/main.tsx",
|
|
14
|
+
"build": "bun build ./src/main.tsx --outdir ./dist --target bun --minify"
|
|
14
15
|
},
|
|
15
16
|
"devDependencies": {
|
|
16
17
|
"@types/bun": "latest"
|
package/AGENTS.md
DELETED
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
# Agent Development Guide
|
|
2
|
-
|
|
3
|
-
## Commands
|
|
4
|
-
- **Run**: `bun run src/main.tsx`
|
|
5
|
-
- **Dev**: `bun --watch run src/main.tsx`
|
|
6
|
-
- **Test**: `bun test` (uses `bun:test` imports)
|
|
7
|
-
- **Install**: `bun install`
|
|
8
|
-
|
|
9
|
-
## Code Style
|
|
10
|
-
- **Framework**: React with @opentui/react for terminal UI
|
|
11
|
-
- **Imports**: Use path aliases `@/*` for src/ and `@tui/*` for src/cli/cmd/tui/
|
|
12
|
-
- **Components**: Default exports, PascalCase naming
|
|
13
|
-
- **Keyboard**: Vim-style navigation (j/k for up/down, q to quit)
|
|
14
|
-
- **Colors**: Use centralized colors from `src/utils/colors.ts`
|
|
15
|
-
- **Error Handling**: Try-catch with state-based error handling
|
|
16
|
-
- **Shell Commands**: Use `Bun.$` for shell execution
|
|
17
|
-
|
|
18
|
-
## Key Patterns
|
|
19
|
-
- Use `useKeyboard()` hook for terminal input handling
|
|
20
|
-
- Components use flexbox layout with terminal dimensions
|
|
21
|
-
- State management with React hooks (useState, useEffect)
|
|
22
|
-
- Terminal UI elements: `<box>`, `<text>` with styling props
|
package/TODO.md
DELETED
|
@@ -1,53 +0,0 @@
|
|
|
1
|
-
# OpenDocker TODO List
|
|
2
|
-
|
|
3
|
-
## Code Quality Improvements
|
|
4
|
-
|
|
5
|
-
### High Priority
|
|
6
|
-
- [ ] Fix inconsistent component naming (`VolumesPanes.tsx` → `VolumesPane.tsx`)
|
|
7
|
-
- [ ] Add comprehensive error handling and error boundaries
|
|
8
|
-
- [ ] Implement proper null safety checks (especially for `activeContainer`)
|
|
9
|
-
- [ ] Add TypeScript interfaces for Docker API responses
|
|
10
|
-
- [ ] Standardize state management across all components
|
|
11
|
-
|
|
12
|
-
### Medium Priority
|
|
13
|
-
- [ ] Add loading states to Images and Volumes panes
|
|
14
|
-
- [ ] Implement proper cleanup for processes and event listeners
|
|
15
|
-
- [ ] Add prop type documentation to components
|
|
16
|
-
- [ ] Standardize error message formatting
|
|
17
|
-
|
|
18
|
-
## Performance & Architecture
|
|
19
|
-
|
|
20
|
-
### High Priority
|
|
21
|
-
- [ ] Create centralized Docker service layer (abstract CLI calls)
|
|
22
|
-
- [ ] Implement debouncing/throttling for Docker commands
|
|
23
|
-
- [ ] Add process cleanup to prevent memory leaks
|
|
24
|
-
- [ ] Implement data caching mechanism
|
|
25
|
-
|
|
26
|
-
### Medium Priority
|
|
27
|
-
- [ ] Separate data fetching logic from UI components
|
|
28
|
-
- [ ] Add configuration management (environment variables)
|
|
29
|
-
- [ ] Implement proper logging system
|
|
30
|
-
|
|
31
|
-
## Testing & Documentation
|
|
32
|
-
|
|
33
|
-
## Features & UX
|
|
34
|
-
|
|
35
|
-
### High Priority
|
|
36
|
-
- [ ] Implement filter logs input
|
|
37
|
-
- [ ] Add real-time updates with proper polling mechanism
|
|
38
|
-
- [ ] Create help screen with keyboard shortcuts
|
|
39
|
-
- [ ] Add visual feedback for user actions
|
|
40
|
-
|
|
41
|
-
### Medium Priority
|
|
42
|
-
- [ ] Implement container management actions (start/stop/remove)
|
|
43
|
-
- [ ] Add confirmation dialogs for destructive operations
|
|
44
|
-
- [ ] Create settings/configuration screen
|
|
45
|
-
- [ ] Add export/import functionality for logs
|
|
46
|
-
|
|
47
|
-
## Infrastructure
|
|
48
|
-
|
|
49
|
-
### Medium Priority
|
|
50
|
-
- [ ] Add Docker health checks and connection validation
|
|
51
|
-
- [ ] Implement proper error recovery mechanisms
|
|
52
|
-
- [ ] Add performance monitoring
|
|
53
|
-
- [ ] Create build/development optimization
|
package/docker-compose.yml
DELETED
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
version: '3.8'
|
|
2
|
-
|
|
3
|
-
services:
|
|
4
|
-
logger1:
|
|
5
|
-
image: alpine:latest
|
|
6
|
-
container_name: logger1
|
|
7
|
-
command: >
|
|
8
|
-
sh -c '
|
|
9
|
-
while true; do
|
|
10
|
-
echo "[$$(date +%Y-%m-%d\ %H:%M:%S)] Container1: $$(openssl rand -hex 8)"
|
|
11
|
-
sleep 1
|
|
12
|
-
done'
|
|
13
|
-
restart: unless-stopped
|
|
14
|
-
|
|
15
|
-
logger2:
|
|
16
|
-
image: alpine:latest
|
|
17
|
-
container_name: logger2
|
|
18
|
-
command: >
|
|
19
|
-
sh -c '
|
|
20
|
-
while true; do
|
|
21
|
-
echo "[$$(date +%Y-%m-%d\ %H:%M:%S)] Container2: $$(openssl rand -hex 8)"
|
|
22
|
-
sleep 1
|
|
23
|
-
done'
|
|
24
|
-
restart: unless-stopped
|
|
Binary file
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
import { colors } from "../utils/styling";
|
|
2
|
-
|
|
3
|
-
export const SplitBorder = {
|
|
4
|
-
border: ["left" as const],
|
|
5
|
-
borderColor: colors.border,
|
|
6
|
-
customBorderChars: {
|
|
7
|
-
topLeft: "",
|
|
8
|
-
bottomLeft: "",
|
|
9
|
-
vertical: "┃",
|
|
10
|
-
topRight: "",
|
|
11
|
-
bottomRight: "",
|
|
12
|
-
horizontal: "",
|
|
13
|
-
bottomT: "",
|
|
14
|
-
topT: "",
|
|
15
|
-
cross: "",
|
|
16
|
-
leftT: "",
|
|
17
|
-
rightT: "",
|
|
18
|
-
},
|
|
19
|
-
}
|
|
@@ -1,142 +0,0 @@
|
|
|
1
|
-
import { useState, useEffect, useRef } from "react";
|
|
2
|
-
import { useKeyboard } from "@opentui/react";
|
|
3
|
-
import { colors, termColors } from "../utils/styling";
|
|
4
|
-
import Pane from "./Pane";
|
|
5
|
-
import { useContainerStore } from "../stores/containers";
|
|
6
|
-
import { useApplicationStore } from "../stores/application";
|
|
7
|
-
import type { ScrollBoxRenderable } from "@opentui/core";
|
|
8
|
-
import { Docker } from "../lib/docker";
|
|
9
|
-
import { TextAttributes } from "@opentui/core";
|
|
10
|
-
|
|
11
|
-
export default function ContainersPane() {
|
|
12
|
-
const { activePane, setActivePane } = useApplicationStore((state) => state);
|
|
13
|
-
const { containers, setContainers, activeContainer, setActiveContainer } = useContainerStore((state) => state);
|
|
14
|
-
const [selectedIndex, setSelectedIndex] = useState(0);
|
|
15
|
-
const paneActive = activePane === "containers";
|
|
16
|
-
const scrollBoxRef = useRef<ScrollBoxRenderable>(null);
|
|
17
|
-
|
|
18
|
-
useEffect(() => {
|
|
19
|
-
if (!paneActive) return;
|
|
20
|
-
|
|
21
|
-
const docker = new Docker();
|
|
22
|
-
|
|
23
|
-
docker.watch((dockerContainers) => {
|
|
24
|
-
console.log(dockerContainers[0]);
|
|
25
|
-
const transformed = dockerContainers.map(container => ({
|
|
26
|
-
name: container.Names[0].replace("/", ""),
|
|
27
|
-
status: container.Status,
|
|
28
|
-
state: container.State,
|
|
29
|
-
health: container.Health,
|
|
30
|
-
}));
|
|
31
|
-
|
|
32
|
-
setContainers(transformed);
|
|
33
|
-
|
|
34
|
-
// Get the CURRENT active container from store, not from stale closure
|
|
35
|
-
const currentActive = useContainerStore.getState().activeContainer;
|
|
36
|
-
|
|
37
|
-
if (currentActive) {
|
|
38
|
-
const stillExists = transformed.find((c) => c.name === currentActive.name);
|
|
39
|
-
if (stillExists) {
|
|
40
|
-
return;
|
|
41
|
-
}
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
if (transformed.length > 0) {
|
|
45
|
-
setActiveContainer(transformed[0]);
|
|
46
|
-
}
|
|
47
|
-
});
|
|
48
|
-
}, [paneActive]);
|
|
49
|
-
|
|
50
|
-
useKeyboard((key) => {
|
|
51
|
-
if (!paneActive) {
|
|
52
|
-
return;
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
if (key.name === "left") {
|
|
56
|
-
setActivePane("volumes");
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
if (key.name === "right" || key.name === "tab") {
|
|
60
|
-
setActivePane("images");
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
if (key.name === 'j' || key.name === 'down') {
|
|
64
|
-
const index = Math.min(selectedIndex + 1, containers.length - 1);
|
|
65
|
-
setSelectedIndex(index);
|
|
66
|
-
setActiveContainer(containers[index]);
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
if (key.name === 'k' || key.name === 'up') {
|
|
70
|
-
const index = Math.max(selectedIndex - 1, 0);
|
|
71
|
-
setActiveContainer(containers[index]);
|
|
72
|
-
setSelectedIndex(index);
|
|
73
|
-
}
|
|
74
|
-
});
|
|
75
|
-
|
|
76
|
-
return (
|
|
77
|
-
<Pane
|
|
78
|
-
title="Containers"
|
|
79
|
-
flexDirection="column"
|
|
80
|
-
width="100%"
|
|
81
|
-
active={paneActive}
|
|
82
|
-
>
|
|
83
|
-
<scrollbox
|
|
84
|
-
ref={scrollBoxRef}
|
|
85
|
-
scrollY={true}
|
|
86
|
-
stickyScroll={true}
|
|
87
|
-
stickyStart="bottom"
|
|
88
|
-
viewportOptions={{
|
|
89
|
-
flexGrow: 1
|
|
90
|
-
}}
|
|
91
|
-
>
|
|
92
|
-
{containers.map((item, index) => {
|
|
93
|
-
function getStateColor() {
|
|
94
|
-
if (paneActive && activeContainer?.name === item.name) {
|
|
95
|
-
return colors.backgroundPanel;
|
|
96
|
-
}
|
|
97
|
-
|
|
98
|
-
if (item?.state === "running") {
|
|
99
|
-
if (item.status.includes("starting")) {
|
|
100
|
-
return termColors.orange11;
|
|
101
|
-
}
|
|
102
|
-
|
|
103
|
-
if (item.status.includes("unhealthy")) {
|
|
104
|
-
return termColors.red11;
|
|
105
|
-
}
|
|
106
|
-
|
|
107
|
-
return termColors.green11;
|
|
108
|
-
}
|
|
109
|
-
|
|
110
|
-
if (item?.state === "exited") {
|
|
111
|
-
return termColors.red11;
|
|
112
|
-
}
|
|
113
|
-
|
|
114
|
-
return termColors.blue11;
|
|
115
|
-
}
|
|
116
|
-
|
|
117
|
-
return (
|
|
118
|
-
<box
|
|
119
|
-
key={index}
|
|
120
|
-
backgroundColor={paneActive && activeContainer?.name === item.name ? colors.primary : undefined}
|
|
121
|
-
flexDirection="row"
|
|
122
|
-
justifyContent="space-between"
|
|
123
|
-
paddingLeft={1}
|
|
124
|
-
paddingRight={1}
|
|
125
|
-
>
|
|
126
|
-
<text
|
|
127
|
-
content={item.name}
|
|
128
|
-
fg={paneActive && activeContainer?.name === item.name ? colors.backgroundPanel : colors.textMuted}
|
|
129
|
-
attributes={paneActive && activeContainer?.name === item.name && TextAttributes.BOLD}
|
|
130
|
-
/>
|
|
131
|
-
<text
|
|
132
|
-
content={item.state}
|
|
133
|
-
fg={getStateColor()}
|
|
134
|
-
/>
|
|
135
|
-
</box>
|
|
136
|
-
)
|
|
137
|
-
})}
|
|
138
|
-
{containers.length < 1 && <text fg={colors.textMuted}>No Containers</text>}
|
|
139
|
-
</scrollbox>
|
|
140
|
-
</Pane>
|
|
141
|
-
)
|
|
142
|
-
}
|
|
@@ -1,83 +0,0 @@
|
|
|
1
|
-
import { useEffect, useRef } from "react";
|
|
2
|
-
import { useKeyboard } from "@opentui/react";
|
|
3
|
-
import Pane from "./Pane";
|
|
4
|
-
import { colors } from "../utils/styling";
|
|
5
|
-
import { useImageStore } from "../stores/images";
|
|
6
|
-
import { useApplicationStore } from "../stores/application";
|
|
7
|
-
import type { ScrollBoxRenderable } from "@opentui/core";
|
|
8
|
-
|
|
9
|
-
export default function ImagesPane() {
|
|
10
|
-
const { activePane, setActivePane } = useApplicationStore((state) => state);
|
|
11
|
-
const { images, setImages } = useImageStore();
|
|
12
|
-
const scrollBoxRef = useRef<ScrollBoxRenderable>(null);
|
|
13
|
-
|
|
14
|
-
useEffect(() => {
|
|
15
|
-
const process = Bun.spawn(
|
|
16
|
-
["docker", "images", "--format", "{{.Repository}}"],
|
|
17
|
-
{stdout: "pipe", stderr: "pipe"},
|
|
18
|
-
);
|
|
19
|
-
|
|
20
|
-
async function read() {
|
|
21
|
-
try {
|
|
22
|
-
const reader = process.stdout.getReader();
|
|
23
|
-
|
|
24
|
-
while (true) {
|
|
25
|
-
const { done, value } = await reader.read();
|
|
26
|
-
if (done) break;
|
|
27
|
-
const decodedValues = new TextDecoder().decode(value);
|
|
28
|
-
const lines = decodedValues.split("\n").filter(Boolean);
|
|
29
|
-
setImages(lines);
|
|
30
|
-
}
|
|
31
|
-
} catch (error) {
|
|
32
|
-
console.error(error);
|
|
33
|
-
}
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
read();
|
|
37
|
-
|
|
38
|
-
return () => process.kill();
|
|
39
|
-
}, []);
|
|
40
|
-
|
|
41
|
-
useKeyboard((key) => {
|
|
42
|
-
if (activePane !== "images") {
|
|
43
|
-
return;
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
if (key.name === "left") {
|
|
47
|
-
setActivePane("containers");
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
if (key.name === "right" || key.name === "tab") {
|
|
51
|
-
setActivePane("volumes");
|
|
52
|
-
}
|
|
53
|
-
});
|
|
54
|
-
|
|
55
|
-
return (
|
|
56
|
-
<Pane
|
|
57
|
-
title="Images"
|
|
58
|
-
width="100%"
|
|
59
|
-
active={activePane === "images"}
|
|
60
|
-
flexDirection="column"
|
|
61
|
-
>
|
|
62
|
-
<scrollbox
|
|
63
|
-
ref={scrollBoxRef}
|
|
64
|
-
scrollY={true}
|
|
65
|
-
stickyScroll={true}
|
|
66
|
-
stickyStart="top"
|
|
67
|
-
>
|
|
68
|
-
{images.map((item: string, index: number) => {
|
|
69
|
-
return (
|
|
70
|
-
<box key={index}>
|
|
71
|
-
<text
|
|
72
|
-
key={index}
|
|
73
|
-
content={item}
|
|
74
|
-
fg={colors.textMuted}
|
|
75
|
-
/>
|
|
76
|
-
</box>
|
|
77
|
-
)
|
|
78
|
-
})}
|
|
79
|
-
{images.length < 1 && <text fg={colors.textMuted}>No Images</text>}
|
|
80
|
-
</scrollbox>
|
|
81
|
-
</Pane>
|
|
82
|
-
)
|
|
83
|
-
}
|
|
@@ -1,128 +0,0 @@
|
|
|
1
|
-
import { useState, useEffect, useRef, useMemo } from "react";
|
|
2
|
-
import { colors, termColors } from "../utils/styling";
|
|
3
|
-
import { TextAttributes, type ScrollBoxRenderable } from "@opentui/core";
|
|
4
|
-
import Pane from "./Pane";
|
|
5
|
-
import { useContainerStore } from "../stores/containers";
|
|
6
|
-
import { useApplicationStore } from "../stores/application";
|
|
7
|
-
|
|
8
|
-
type LogEntry = {
|
|
9
|
-
text: string;
|
|
10
|
-
type: 'stdout' | 'stderr';
|
|
11
|
-
};
|
|
12
|
-
|
|
13
|
-
export default function LogsPane() {
|
|
14
|
-
const { activePane } = useApplicationStore((state) => state);
|
|
15
|
-
const { activeContainer } = useContainerStore((state) => state);
|
|
16
|
-
const [logs, setLogs] = useState<LogEntry[]>([]);
|
|
17
|
-
const scrollBoxRef = useRef<ScrollBoxRenderable>(null);
|
|
18
|
-
|
|
19
|
-
useEffect(() => {
|
|
20
|
-
if (!activeContainer || activePane !== "containers") {
|
|
21
|
-
cleanup();
|
|
22
|
-
return;
|
|
23
|
-
};
|
|
24
|
-
|
|
25
|
-
setLogs([]);
|
|
26
|
-
const process = Bun.spawn([
|
|
27
|
-
"docker",
|
|
28
|
-
"logs",
|
|
29
|
-
"--follow",
|
|
30
|
-
"--tail",
|
|
31
|
-
"100",
|
|
32
|
-
activeContainer.name,
|
|
33
|
-
], {
|
|
34
|
-
stdout: "pipe",
|
|
35
|
-
stderr: "pipe",
|
|
36
|
-
});
|
|
37
|
-
|
|
38
|
-
async function readStream(stream: ReadableStream, type: 'stdout' | 'stderr') {
|
|
39
|
-
const decoder = new TextDecoder();
|
|
40
|
-
const reader = stream.getReader();
|
|
41
|
-
|
|
42
|
-
try {
|
|
43
|
-
while (true) {
|
|
44
|
-
const { done, value } = await reader.read();
|
|
45
|
-
if (done) break;
|
|
46
|
-
|
|
47
|
-
const text = decoder.decode(value, { stream: true });
|
|
48
|
-
// Split by newlines and filter out empty lines
|
|
49
|
-
const lines = text.split('\n').filter(line => line.trim().length > 0);
|
|
50
|
-
|
|
51
|
-
if (lines.length > 0) {
|
|
52
|
-
setLogs(prev => {
|
|
53
|
-
const newEntries = lines.map(line => ({
|
|
54
|
-
text: line,
|
|
55
|
-
type
|
|
56
|
-
}));
|
|
57
|
-
return [...prev, ...newEntries];
|
|
58
|
-
});
|
|
59
|
-
}
|
|
60
|
-
}
|
|
61
|
-
} catch (error) {}
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
readStream(process.stdout, 'stdout');
|
|
65
|
-
readStream(process.stderr, 'stderr');
|
|
66
|
-
|
|
67
|
-
return () => {
|
|
68
|
-
process.kill();
|
|
69
|
-
cleanup();
|
|
70
|
-
}
|
|
71
|
-
}, [activePane, activeContainer]);
|
|
72
|
-
|
|
73
|
-
useEffect(() => {
|
|
74
|
-
if (scrollBoxRef.current && logs.length > 0) {
|
|
75
|
-
scrollBoxRef.current.scrollTo({ x: 0, y: scrollBoxRef.current.scrollHeight });
|
|
76
|
-
}
|
|
77
|
-
}, [logs]);
|
|
78
|
-
|
|
79
|
-
function cleanup() {
|
|
80
|
-
setLogs([]);
|
|
81
|
-
}
|
|
82
|
-
|
|
83
|
-
const output = useMemo(() => {
|
|
84
|
-
if (logs.length === 0) {
|
|
85
|
-
return <text fg={colors.textMuted}>No logs available</text>;
|
|
86
|
-
}
|
|
87
|
-
|
|
88
|
-
return logs.map(log => (
|
|
89
|
-
<text
|
|
90
|
-
fg={log.type === 'stderr' ? termColors.red11 : colors.textMuted}
|
|
91
|
-
>
|
|
92
|
-
{log.text}
|
|
93
|
-
</text>
|
|
94
|
-
));
|
|
95
|
-
}, [logs]);
|
|
96
|
-
|
|
97
|
-
return (
|
|
98
|
-
<Pane
|
|
99
|
-
title="Logs"
|
|
100
|
-
flexDirection="column"
|
|
101
|
-
width="70%"
|
|
102
|
-
>
|
|
103
|
-
<box flexDirection="column" gap={1} height="100%">
|
|
104
|
-
<box flexDirection="row" gap={2} height="auto">
|
|
105
|
-
<box flexDirection="column" gap={1}>
|
|
106
|
-
<text fg={termColors.purple11} attributes={TextAttributes.BOLD}>Container</text>
|
|
107
|
-
<text>{activeContainer?.name}</text>
|
|
108
|
-
</box>
|
|
109
|
-
<box flexDirection="column">
|
|
110
|
-
<text fg={termColors.purple11} attributes={TextAttributes.BOLD}>Status</text>
|
|
111
|
-
<text>{activeContainer?.status || "None"}</text>
|
|
112
|
-
</box>
|
|
113
|
-
</box>
|
|
114
|
-
<scrollbox
|
|
115
|
-
ref={scrollBoxRef}
|
|
116
|
-
scrollY={true}
|
|
117
|
-
stickyScroll={true}
|
|
118
|
-
stickyStart="bottom"
|
|
119
|
-
height="100%"
|
|
120
|
-
>
|
|
121
|
-
<box flexDirection="column" height="auto">
|
|
122
|
-
{output}
|
|
123
|
-
</box>
|
|
124
|
-
</scrollbox>
|
|
125
|
-
</box>
|
|
126
|
-
</Pane>
|
|
127
|
-
)
|
|
128
|
-
}
|
package/src/components/Pane.tsx
DELETED
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
import { SplitBorder } from "./Border";
|
|
2
|
-
import type { BoxProps } from "@opentui/react";
|
|
3
|
-
import { padding, colors, termColors } from "../utils/styling";
|
|
4
|
-
import { TextAttributes } from "@opentui/core";
|
|
5
|
-
|
|
6
|
-
interface PaneProps extends BoxProps {
|
|
7
|
-
title: string;
|
|
8
|
-
active?: boolean;
|
|
9
|
-
children: React.ReactNode;
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
export default function Pane({
|
|
13
|
-
title,
|
|
14
|
-
active = false,
|
|
15
|
-
children,
|
|
16
|
-
...props
|
|
17
|
-
}: PaneProps) {
|
|
18
|
-
return (
|
|
19
|
-
<box
|
|
20
|
-
{...SplitBorder}
|
|
21
|
-
{...props}
|
|
22
|
-
borderColor={active ? termColors.purple11 : colors.backgroundPanel}
|
|
23
|
-
>
|
|
24
|
-
<box
|
|
25
|
-
flexGrow={1}
|
|
26
|
-
backgroundColor={colors.backgroundPanel}
|
|
27
|
-
{...padding}
|
|
28
|
-
>
|
|
29
|
-
<text marginBottom={1} attributes={TextAttributes.BOLD}>{title}</text>
|
|
30
|
-
{children}
|
|
31
|
-
</box>
|
|
32
|
-
</box>
|
|
33
|
-
)
|
|
34
|
-
}
|
|
@@ -1,84 +0,0 @@
|
|
|
1
|
-
import { useEffect, useRef } from "react";
|
|
2
|
-
import { useKeyboard } from "@opentui/react";
|
|
3
|
-
import Pane from "./Pane";
|
|
4
|
-
import { colors } from "../utils/styling";
|
|
5
|
-
import { useVolumeStore } from "../stores/volumes";
|
|
6
|
-
import { useApplicationStore } from "../stores/application";
|
|
7
|
-
import type { ScrollBoxRenderable } from "@opentui/core";
|
|
8
|
-
|
|
9
|
-
export default function ImagesPane() {
|
|
10
|
-
const { activePane, setActivePane } = useApplicationStore((state) => state);
|
|
11
|
-
const { volumes, setVolumes } = useVolumeStore();
|
|
12
|
-
const scrollBoxRef = useRef<ScrollBoxRenderable>(null);
|
|
13
|
-
|
|
14
|
-
useEffect(() => {
|
|
15
|
-
const process = Bun.spawn(
|
|
16
|
-
["docker", "volume", "ls", "--format", "{{.Name}}"],
|
|
17
|
-
{stdout: "pipe", stderr: "pipe"},
|
|
18
|
-
);
|
|
19
|
-
|
|
20
|
-
async function read() {
|
|
21
|
-
try {
|
|
22
|
-
const reader = process.stdout.getReader();
|
|
23
|
-
|
|
24
|
-
while (true) {
|
|
25
|
-
const { done, value } = await reader.read();
|
|
26
|
-
if (done) break;
|
|
27
|
-
const decodedValues = new TextDecoder().decode(value);
|
|
28
|
-
const lines = decodedValues.split("\n").filter(Boolean);
|
|
29
|
-
setVolumes(lines);
|
|
30
|
-
}
|
|
31
|
-
} catch (error) {
|
|
32
|
-
console.error(error);
|
|
33
|
-
}
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
read();
|
|
37
|
-
|
|
38
|
-
return () => process.kill();
|
|
39
|
-
}, []);
|
|
40
|
-
|
|
41
|
-
useKeyboard((key) => {
|
|
42
|
-
if (activePane !== "volumes") {
|
|
43
|
-
return;
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
if (key.name === "left") {
|
|
47
|
-
setActivePane("images");
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
if (key.name === "right" || key.name === "tab") {
|
|
51
|
-
setActivePane("containers");
|
|
52
|
-
}
|
|
53
|
-
});
|
|
54
|
-
|
|
55
|
-
return (
|
|
56
|
-
<Pane
|
|
57
|
-
title="Volumes"
|
|
58
|
-
active={activePane === "volumes"}
|
|
59
|
-
width="100%"
|
|
60
|
-
flexDirection="column"
|
|
61
|
-
>
|
|
62
|
-
<scrollbox
|
|
63
|
-
ref={scrollBoxRef}
|
|
64
|
-
scrollY={true}
|
|
65
|
-
stickyScroll={true}
|
|
66
|
-
stickyStart="bottom"
|
|
67
|
-
viewportOptions={{
|
|
68
|
-
flexGrow: 1
|
|
69
|
-
}}
|
|
70
|
-
>
|
|
71
|
-
{volumes.map((item, index) => {
|
|
72
|
-
return <box>
|
|
73
|
-
<text
|
|
74
|
-
key={index}
|
|
75
|
-
content={`[*] ${item}`}
|
|
76
|
-
fg={colors.textMuted}
|
|
77
|
-
/>
|
|
78
|
-
</box>
|
|
79
|
-
})}
|
|
80
|
-
{volumes.length < 1 && <text fg={colors.textMuted}>No Volumes</text>}
|
|
81
|
-
</scrollbox>
|
|
82
|
-
</Pane>
|
|
83
|
-
)
|
|
84
|
-
}
|