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 />
<section id="content" className="container mx-auto gap-4">
{children} {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);
if (!pathParam) {
pteroInstance.helpers.setWorkingDirectory(path); 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,7 +156,6 @@ 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">
@@ -203,7 +202,6 @@ const Console = () => {
</div> </div>
</div> </div>
</div> </div>
</section>
</> </>
); );
}; };