-
Notifications
You must be signed in to change notification settings - Fork 84
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
8 changed files
with
428 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
"use client"; | ||
import { MySQLIcon } from "@/components/icons/outerbase-icon"; | ||
import { useRouter } from "next/navigation"; | ||
|
||
export default function MySQLPlaygroundButton() { | ||
const router = useRouter(); | ||
|
||
return ( | ||
<button | ||
className={ | ||
"text-left bg-primary text-primary-foreground p-3 px-4 rounded-lg text-sm gap-2 flex flex-col hover:bg-gray-300 w-[200px]" | ||
} | ||
onClick={() => { | ||
// Random 8 character alphabeth string | ||
const roomName = new Array(8) | ||
.fill("a") | ||
.map( | ||
() => "abcdefghijklmnopqrstuvwxyz"[Math.floor(Math.random() * 26)] | ||
) | ||
.join(""); | ||
|
||
router.push(`/playground/mysql/${roomName}`); | ||
}} | ||
> | ||
<div className="flex gap-2"> | ||
<MySQLIcon className="w-10 h-10" /> | ||
<div className="flex flex-col justify-center"> | ||
<div className="font-bold text-md">MySQL</div> | ||
<div className="text-xs">Playground</div> | ||
</div> | ||
</div> | ||
|
||
<p className="text-xs text-gray-500">Spin up a cloud MySQL sandbox.</p> | ||
</button> | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
55 changes: 55 additions & 0 deletions
55
src/app/(theme)/playground/mysql/[roomName]/page-client.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
"use client"; | ||
import { Studio } from "@/components/gui/studio"; | ||
import ServerLoadingAnimation from "@/components/icons/server-loading"; | ||
import MySQLPlaygroundDriver from "@/drivers/mysql/mysql-playground-driver"; | ||
import { useSearchParams } from "next/navigation"; | ||
import { useEffect, useMemo, useState } from "react"; | ||
|
||
export default function MySQLPlaygroundPageClient({ | ||
roomName, | ||
}: { | ||
roomName: string; | ||
}) { | ||
const searchParams = useSearchParams(); | ||
const [isReady, setReady] = useState(false); | ||
|
||
const driver = useMemo(() => { | ||
if (typeof window === "undefined") return null; | ||
|
||
return new MySQLPlaygroundDriver(roomName, { | ||
onReady: () => setReady(true), | ||
}); | ||
}, [setReady, roomName]); | ||
|
||
// Create ping useeffect | ||
useEffect(() => { | ||
if (!driver) return; | ||
|
||
const interval = setInterval(() => { | ||
driver.ping(); | ||
}, 5000); | ||
|
||
return () => clearInterval(interval); | ||
}, [driver]); | ||
|
||
if (!isReady) { | ||
return ( | ||
<div className="w-screen h-screen flex items-center justify-center flex-col gap-4"> | ||
<ServerLoadingAnimation /> | ||
<div>Setting up your database</div> | ||
</div> | ||
); | ||
} | ||
|
||
if (!driver) { | ||
return <div>Server-side rendering is not supported</div>; | ||
} | ||
|
||
return ( | ||
<Studio | ||
driver={driver} | ||
name={searchParams.get("name") || "Unnamed Connection"} | ||
color={searchParams.get("color") || "gray"} | ||
/> | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
import { Metadata } from "next"; | ||
import ThemeLayout from "../../../theme_layout"; | ||
import MySQLPlaygroundPageClient from "./page-client"; | ||
|
||
export const metadata: Metadata = { | ||
title: | ||
"SQLite Online Playground - Powerful and lightweight editor on your browser", | ||
description: | ||
"Explore the powerful SQLite Playground in your browser – no downloads or registration needed. Effortlessly load your SQLite files or start with a blank database, then save your work with ease. Enjoy a robust data editor, advanced query capabilities, table creation, and much more.", | ||
keywords: [ | ||
"sqlite", | ||
"libsql", | ||
"browser", | ||
"client", | ||
"gui", | ||
"playground", | ||
"sandbox", | ||
"explorer", | ||
"studio", | ||
], | ||
robots: { | ||
index: true, | ||
follow: true, | ||
}, | ||
}; | ||
|
||
export default async function MySQLPlaygroundEditor({ | ||
params: { roomName }, | ||
}: { | ||
params: { roomName: string }; | ||
}) { | ||
return ( | ||
<ThemeLayout> | ||
<MySQLPlaygroundPageClient roomName={roomName} /> | ||
</ThemeLayout> | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
import ServerLoadingAnimation from "@/components/icons/server-loading"; | ||
|
||
export default function ServerLoadingStorybook() { | ||
return ( | ||
<div className="p-4"> | ||
<ServerLoadingAnimation /> | ||
</div> | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.