This commit is contained in:
2024-09-10 16:23:09 +00:00
parent ba6e5605c9
commit 2dfff9f9d6
6 changed files with 88 additions and 51 deletions

View File

@@ -1,14 +1,30 @@
"use client"; "use client";
import React from "react"; import React, { useCallback } from "react";
import { useSearchParams } from "next/navigation"; import { useSearchParams } from "next/navigation";
import TextEditor from "@/components/TextEditor";
import BreadCrumbs from "@/components/FilesEditor/BreadCrumbs";
function Page() { function Page() {
const searchParams = useSearchParams(); const searchParams = useSearchParams();
const serverId = searchParams.get("serverid"); const serverId = searchParams.get("serverid") || "";
const path = searchParams.get("path") || "";
return <div>{serverId}</div>; const changeDirectory = useCallback((path: string) => {
console.log("changeDirectory", path);
}, []);
return (
<>
<BreadCrumbs
changeDirectory={changeDirectory}
serverId={serverId}
path={path}
/>
<TextEditor />;
</>
);
} }
export default Page; export default Page;

View File

@@ -3,9 +3,7 @@ import FilesEdit from "@/components/FilesEditor";
export default function Files() { export default function Files() {
return ( return (
<> <>
<section className="container mx-auto"> <FilesEdit />
<FilesEdit />
</section>
</> </>
); );
} }

View File

@@ -1,7 +1,6 @@
import type { Metadata } from "next"; import type { Metadata } from "next";
import { Inter } from "next/font/google"; import { Inter } from "next/font/google";
import "./globals.css"; import "./globals.css";
import { Console } from "console";
import ConsoleNavigation from "@/components/ConsoleNavigation"; import ConsoleNavigation from "@/components/ConsoleNavigation";
const inter = Inter({ subsets: ["latin"] }); const inter = Inter({ subsets: ["latin"] });
@@ -24,7 +23,9 @@ export default function RootLayout({
</header> </header>
<div id="container"> <div id="container">
<ConsoleNavigation /> <ConsoleNavigation />
{children} <section id="content" className="container mx-auto gap-4">
{children}
</section>
</div> </div>
</body> </body>
</html> </html>

View File

@@ -0,0 +1,16 @@
"use client";
import React, { Children } from "react";
import { useParams } from "next/navigation";
interface Props {
children: React.ReactNode;
}
const BreadCrumbs = ({ children }: Props) => {
const { serverid, path } = useParams();
return <div>{children}</div>;
};
export default BreadCrumbs;

View File

@@ -10,6 +10,7 @@ import RenamePopup from "./ContextMenu/rename";
import Pterodactyl from "@/components/Pterodactyl"; import Pterodactyl from "@/components/Pterodactyl";
import BreadCrumbs from "./BreadCrumbs"; import BreadCrumbs from "./BreadCrumbs";
import { useSearchParams } from "next/navigation"; import { useSearchParams } from "next/navigation";
import Link from "next/link";
interface FileAttributes { interface FileAttributes {
name: string; name: string;
@@ -58,6 +59,7 @@ const Index = () => {
const [path, setPath] = useState<string>("/"); const [path, setPath] = useState<string>("/");
const urlParams = useSearchParams(); const urlParams = useSearchParams();
const serverId = urlParams.get("serverid"); const serverId = urlParams.get("serverid");
const pathParam = urlParams.get("path");
const setCredentials = useCallback(() => { const setCredentials = useCallback(() => {
setApiKey("ptlc_N77A2hEczFmSwGXm4cEXh4Gw3ZP0Ygr5NaBkGlE7pjU"); setApiKey("ptlc_N77A2hEczFmSwGXm4cEXh4Gw3ZP0Ygr5NaBkGlE7pjU");
@@ -116,7 +118,11 @@ const Index = () => {
await setCredentials(); await setCredentials();
if (apiKey && serverId) { if (apiKey && serverId) {
const pteroInstance = new Pterodactyl(serverId, apiKey); const pteroInstance = new Pterodactyl(serverId, apiKey);
pteroInstance.helpers.setWorkingDirectory(path); if (!pathParam) {
pteroInstance.helpers.setWorkingDirectory(path);
} else {
pteroInstance.helpers.setWorkingDirectory(pathParam);
}
setPtero(pteroInstance); setPtero(pteroInstance);
await fetchFiles(pteroInstance); await fetchFiles(pteroInstance);
} }
@@ -166,7 +172,9 @@ const Index = () => {
</div> </div>
<div className="w-64 text-left"> <div className="w-64 text-left">
{file.attributes.is_file ? ( {file.attributes.is_file ? (
<a href="#">{file.attributes.name}</a> <Link href={`/files/edit?serverid=${serverId}&path=${path}`}>
{file.attributes.name}
</Link>
) : ( ) : (
<a <a
onClick={() => onClick={() =>

View File

@@ -156,54 +156,52 @@ const Console = () => {
return ( return (
<> <>
<section className="container mx-auto"> <div className="flex flex-col gap-4">
<div className="flex flex-col gap-4"> <div className="flex gap-4">
<div className="flex gap-4"> <div className="w-4/5 flex justify-self-auto justify-between items-center">
<div className="w-4/5 flex justify-self-auto justify-between items-center"> <ServerName serverName="asdf " />
<ServerName serverName="asdf " /> <ServerStatus serverStatus={serverStatus} />
<ServerStatus serverStatus={serverStatus} />
</div>
<div className="w-1/5 flex justify-between">
<ServerControl websocketRef={websocketRef} />
</div>
</div> </div>
<div className="w-1/5 flex justify-between">
<ServerControl websocketRef={websocketRef} />
</div>
</div>
<div className="flex gap-4"> <div className="flex gap-4">
<div className="w-4/5"> <div className="w-4/5">
<div> <div>
<textarea <textarea
className="textarea textarea-bordered text-yellow-200 w-full" className="textarea textarea-bordered text-yellow-200 w-full"
ref={textareaRef} ref={textareaRef}
cols={110} cols={110}
rows={20} rows={20}
value={output.join("\n")} value={output.join("\n")}
readOnly readOnly
/> />
</div>
<div>
<input
className="input input-bordered w-full text-yellow-200"
type="text"
value={input}
onChange={(e) => setInput(e.target.value)}
onKeyPress={handleKeyPress}
/>
</div>
</div> </div>
<div className="w-1/5"> <div>
<Stats <input
cpu={cpuStat} className="input input-bordered w-full text-yellow-200"
ramUsage={ramStat} type="text"
ramTotal={ramTotal} value={input}
diskUsage={diskUsage} onChange={(e) => setInput(e.target.value)}
diskTotal={diskTotal} onKeyPress={handleKeyPress}
network={network}
uptime={uptime}
/> />
</div> </div>
</div> </div>
<div className="w-1/5">
<Stats
cpu={cpuStat}
ramUsage={ramStat}
ramTotal={ramTotal}
diskUsage={diskUsage}
diskTotal={diskTotal}
network={network}
uptime={uptime}
/>
</div>
</div> </div>
</section> </div>
</> </>
); );
}; };