Node management
This commit is contained in:
@@ -2,9 +2,12 @@ import { NextRequest, NextResponse } from "next/server";
|
||||
import { version } from "@/../package.json";
|
||||
import testAuth from "../auth";
|
||||
import { StatusCodes } from "http-status-codes";
|
||||
import { read } from "@/app/api/file";
|
||||
import { NodeJsonTemplate } from "../types";
|
||||
import osName from "os-name";
|
||||
|
||||
export async function GET(req: NextRequest): Promise<NextResponse> {
|
||||
const auth = testAuth(req);
|
||||
const auth = await testAuth(req);
|
||||
|
||||
if (auth) {
|
||||
return NextResponse.json(
|
||||
@@ -13,9 +16,13 @@ export async function GET(req: NextRequest): Promise<NextResponse> {
|
||||
);
|
||||
}
|
||||
|
||||
const { node_id } = await read(NodeJsonTemplate, "data", "node.json");
|
||||
|
||||
return NextResponse.json({
|
||||
message: "ok",
|
||||
app: "dockship",
|
||||
version,
|
||||
node_id,
|
||||
os: osName(),
|
||||
});
|
||||
}
|
||||
|
||||
@@ -1,10 +1,6 @@
|
||||
import { NextRequest, NextResponse } from "next/server";
|
||||
import { version } from "@/../package.json";
|
||||
import { read } from "@/app/api/file";
|
||||
import { NodeJsonTemplate } from "@/app/api/types";
|
||||
|
||||
export async function GET(req: NextRequest): Promise<NextResponse> {
|
||||
const { node_id } = await read(NodeJsonTemplate, "data", "node.json");
|
||||
|
||||
return NextResponse.json({ app: "dockship", version, node_id });
|
||||
return NextResponse.json({ app: "dockship", version });
|
||||
}
|
||||
|
||||
@@ -26,8 +26,6 @@ export async function GET(req: NextRequest): Promise<NextResponse> {
|
||||
|
||||
const root = disks.find((d) => d.mount === "/" || d.fs.includes("disk3"));
|
||||
|
||||
console.log(mem.available, mem.total);
|
||||
|
||||
return NextResponse.json({
|
||||
message: "ok",
|
||||
liveData: {
|
||||
|
||||
+17
-5
@@ -10,6 +10,8 @@ import { Docker, Node, NodeLiveData } from "@/lib/types";
|
||||
import { useEffect, useState } from "react";
|
||||
import { getDockerNode, getLiveNodes } from "@/core/client/node";
|
||||
import { formatBytes } from "@/lib/format";
|
||||
import { setNodes as updateNodes } from "@/core/client/node";
|
||||
import AddNode from "@/components/dialogs/AddNode";
|
||||
|
||||
function DiskUsage({ liveData }: NodeLiveData) {
|
||||
const usage = (liveData.disk.used / liveData.disk.size) * 100;
|
||||
@@ -56,14 +58,16 @@ export default function NodesPage() {
|
||||
{/* {nodes.filter((n) => n.status === "running").length} online */}
|
||||
</Badge>
|
||||
</div>
|
||||
<Button size="sm" className="gap-2">
|
||||
<Plus className="w-4 h-4" /> Add Node
|
||||
</Button>
|
||||
<AddNode>
|
||||
<Button size="sm" className="gap-2">
|
||||
<Plus className="w-4 h-4" /> Add Node
|
||||
</Button>
|
||||
</AddNode>
|
||||
</div>
|
||||
|
||||
<div className="flex flex-col gap-4">
|
||||
{nodes.map((node, i) => (
|
||||
<Card key={node.node_id}>
|
||||
<Card key={i}>
|
||||
<CardHeader className="flex flex-col sm:flex-row sm:items-start sm:justify-between pb-2 gap-2 sm:gap-0">
|
||||
<div className="flex flex-col sm:flex-row sm:items-center gap-3">
|
||||
<div className="w-10 h-10 bg-secondary flex items-center justify-center">
|
||||
@@ -88,7 +92,15 @@ export default function NodesPage() {
|
||||
<Button variant="ghost" size="icon-sm">
|
||||
<Settings className="w-4 h-4" />
|
||||
</Button>
|
||||
<Button variant="ghost" size="icon-sm">
|
||||
<Button
|
||||
variant="ghost"
|
||||
size="icon-sm"
|
||||
onClick={async () => {
|
||||
const newNodes = nodes.filter((_, index) => index !== i);
|
||||
setNodes(newNodes);
|
||||
await updateNodes(newNodes);
|
||||
}}
|
||||
>
|
||||
<Trash2 className="w-4 h-4" />
|
||||
</Button>
|
||||
</div>
|
||||
|
||||
@@ -227,11 +227,8 @@ export default function OverviewPage() {
|
||||
</CardHeader>
|
||||
<CardContent className="overflow-x-auto">
|
||||
<div className="grid grid-cols-1 md:grid-cols-3 gap-4 min-w-75">
|
||||
{nodes.map((node) => (
|
||||
<div
|
||||
key={node.name}
|
||||
className="border border-border p-4 bg-secondary/30"
|
||||
>
|
||||
{nodes.map((node, i) => (
|
||||
<div key={i} className="border border-border p-4 bg-secondary/30">
|
||||
<div className="flex flex-col sm:flex-row sm:items-center sm:justify-between mb-3 gap-2">
|
||||
<div className="flex items-center gap-2">
|
||||
<StatusIndicator status={"running"} />
|
||||
|
||||
+1
-13
@@ -1,17 +1,5 @@
|
||||
"use client";
|
||||
|
||||
import { getDocker } from "@/core/client/docker";
|
||||
|
||||
export default function Home() {
|
||||
return (
|
||||
<div>
|
||||
<button
|
||||
onClick={async () => {
|
||||
console.log(await getDocker("localhost", "oD7tMrnkxIvuFrR+b6QZh66E4PU="));
|
||||
}}
|
||||
>
|
||||
Get docker
|
||||
</button>
|
||||
</div>
|
||||
);
|
||||
return "ok";
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user