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

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