This commit is contained in:
Benjamin Toby 2026-03-11 04:44:11 +00:00
parent 2e0009e3ca
commit 78adca7091
14 changed files with 94 additions and 36 deletions

View File

@ -5,9 +5,9 @@
"": {
"name": "turboci-admin",
"dependencies": {
"@moduletrace/bun-sqlite": "^1.0.9",
"@moduletrace/bun-sqlite": "^1.0.10",
"@moduletrace/datasquirel": "^5.7.57",
"@moduletrace/nsqlite": "^1.0.9",
"@moduletrace/nsqlite": "^1.0.10",
"better-sqlite3": "^12.6.2",
"bun": "^1.3.10",
"dayjs": "^1.11.19",
@ -162,11 +162,11 @@
"@mdx-js/react": ["@mdx-js/react@3.1.1", "", { "dependencies": { "@types/mdx": "^2.0.0" }, "peerDependencies": { "@types/react": ">=16", "react": ">=16" } }, "sha512-f++rKLQgUVYDAtECQ6fn/is15GkEH9+nZPM3MS0RcxVqoTfawHvDlSCH7JbMhAM6uJ32v3eXLvLmLvjGu7PTQw=="],
"@moduletrace/bun-sqlite": ["@moduletrace/bun-sqlite@1.0.9", "https://git.tben.me/api/packages/Moduletrace/npm/%40moduletrace%2Fbun-sqlite/-/1.0.9/bun-sqlite-1.0.9.tgz", { "dependencies": { "@inquirer/prompts": "^8.3.0", "chalk": "^5.6.2", "commander": "^14.0.3", "inquirer": "^13.3.0", "lodash": "^4.17.23", "mysql": "^2.18.1", "sqlite-vec": "^0.1.7-alpha.2" }, "peerDependencies": { "typescript": "^5" }, "bin": { "bun-sqlite": "dist/commands/index.js" } }, "sha512-fZiXGTmxKPHEAGNSWm04dRoUdb1gehTYRZXyfIEH2rSTa56dXoFVw2B+AvXydbM2XcaykVaOLLL1sqMEhsZZUw=="],
"@moduletrace/bun-sqlite": ["@moduletrace/bun-sqlite@1.0.10", "https://git.tben.me/api/packages/Moduletrace/npm/%40moduletrace%2Fbun-sqlite/-/1.0.10/bun-sqlite-1.0.10.tgz", { "dependencies": { "@inquirer/prompts": "^8.3.0", "chalk": "^5.6.2", "commander": "^14.0.3", "inquirer": "^13.3.0", "lodash": "^4.17.23", "mysql": "^2.18.1", "sqlite-vec": "^0.1.7-alpha.2" }, "peerDependencies": { "typescript": "^5" }, "bin": { "bun-sqlite": "dist/commands/index.js" } }, "sha512-CbbWekNvCnSLPomXIoHgJp+6Kb2Rfyt3YhovqOBLk/mPOKUsS0jFSNE6tVokUIEiCu3i4b23HbE2auMHTbZQqA=="],
"@moduletrace/datasquirel": ["@moduletrace/datasquirel@5.7.57", "https://git.tben.me/api/packages/Moduletrace/npm/%40moduletrace%2Fdatasquirel/-/5.7.57/datasquirel-5.7.57.tgz", { "dependencies": { "@types/ace": "^0.0.52", "@types/lodash": "^4.17.13", "@types/next": "^9.0.0", "@types/node": "^22.7.5", "@types/nodemailer": "^6.4.17", "@types/react": "^18.2.21", "@types/react-dom": "^19.0.0", "@types/tinymce": "^4.6.9", "dotenv": "^16.3.1", "generate-password": "^1.7.1", "google-auth-library": "^9.15.0", "inquirer": "^12.5.2", "lodash": "^4.17.21", "mariadb": "^3.4.4", "nodemailer": "^6.9.14", "sanitize-html": "^2.13.1", "sql-formatter": "^15.6.10" }, "bin": { "dsql-dump": "dist/engine/dump.js", "dsql-schema-to-typedef": "dist/engine/schema-to-typedef.js", "dsql-watch": "dist/engine/dsql.js" } }, "sha512-tPNfhMIwdptKjmraVqxj/qZ5yrO4QUZ/QxwZE+jIFj37UnUCXZOfF6yVWFClsqn2fNAjU2NDqrwC9w65ZzsmKg=="],
"@moduletrace/nsqlite": ["@moduletrace/nsqlite@1.0.9", "https://git.tben.me/api/packages/Moduletrace/npm/%40moduletrace%2Fnsqlite/-/1.0.9/nsqlite-1.0.9.tgz", { "dependencies": { "@inquirer/prompts": "^8.3.0", "better-sqlite3": "^12.6.2", "chalk": "^5.6.2", "commander": "^14.0.3", "inquirer": "^13.3.0", "lodash": "^4.17.23", "mysql": "^2.18.1", "sqlite-vec": "^0.1.7-alpha.2" }, "peerDependencies": { "typescript": "^5" }, "bin": { "nsqlite": "dist/commands/index.js" } }, "sha512-+iAQUgcMTvQnlTzzKoLkms2KA0zsZ1TsjeLSS5f+pLFEfkJKbYkgf4JIqq6Jgi5p1d5GYeLqc6qjR3onLorOWQ=="],
"@moduletrace/nsqlite": ["@moduletrace/nsqlite@1.0.10", "https://git.tben.me/api/packages/Moduletrace/npm/%40moduletrace%2Fnsqlite/-/1.0.10/nsqlite-1.0.10.tgz", { "dependencies": { "@inquirer/prompts": "^8.3.0", "better-sqlite3": "^12.6.2", "chalk": "^5.6.2", "commander": "^14.0.3", "inquirer": "^13.3.0", "lodash": "^4.17.23", "mysql": "^2.18.1", "sqlite-vec": "^0.1.7-alpha.2" }, "peerDependencies": { "typescript": "^5" }, "bin": { "nsqlite": "dist/commands/index.js" } }, "sha512-WrY4bvV8kt0TkQdwh4m3rME12MXW1IEModyzia47srw+LtpORSvqI1AYFtsMM/XNCfBqrTc/UnzxFGmxp6FoKg=="],
"@next/env": ["@next/env@14.2.35", "", {}, "sha512-DuhvCtj4t9Gwrx80dmz2F4t/zKQ4ktN8WrMwOuVzkJfBilwAwGr6v16M5eI8yCuZ63H9TTuEU09Iu2HqkzFPVQ=="],

View File

@ -20,9 +20,9 @@
"build": "next build"
},
"dependencies": {
"@moduletrace/bun-sqlite": "^1.0.9",
"@moduletrace/bun-sqlite": "^1.0.10",
"@moduletrace/datasquirel": "^5.7.57",
"@moduletrace/nsqlite": "^1.0.9",
"@moduletrace/nsqlite": "^1.0.10",
"better-sqlite3": "^12.6.2",
"bun": "^1.3.10",
"dayjs": "^1.11.19",

View File

@ -57,10 +57,10 @@ export default function LoginForm() {
placeholder="Password"
title="Password"
type="password"
changeHandler={(v) => {
onChange={(e) => {
setLoginData((prev) => ({
...prev,
password: v,
password: e.target.value,
}));
}}
validity={

View File

@ -4,7 +4,6 @@
* @type {import("@moduletrace/nsqlite/dist/types").NSQLITE_DatabaseSchemaType}
*/
const schema = {
dbName: "test-db",
tables: [
{
tableName: "users",

View File

@ -3,7 +3,7 @@ export const NSQLiteTables = [
"users_ports",
] as const
export type NSQLITE_TEST_DB_USERS = {
export type NSQLITE_TURBOCI_ADMIN_USERS = {
/**
* The unique identifier of the record.
*/
@ -26,7 +26,7 @@ export type NSQLITE_TEST_DB_USERS = {
all_deployment_access?: number;
}
export type NSQLITE_TEST_DB_USERS_PORTS = {
export type NSQLITE_TURBOCI_ADMIN_USERS_PORTS = {
/**
* The unique identifier of the record.
*/
@ -43,4 +43,4 @@ export type NSQLITE_TEST_DB_USERS_PORTS = {
port?: number;
}
export type NSQLITE_TEST_DB_ALL_TYPEDEFS = NSQLITE_TEST_DB_USERS & NSQLITE_TEST_DB_USERS_PORTS
export type NSQLITE_TURBOCI_ADMIN_ALL_TYPEDEFS = NSQLITE_TURBOCI_ADMIN_USERS & NSQLITE_TURBOCI_ADMIN_USERS_PORTS

View File

@ -1,7 +1,7 @@
import { NextApiResponse } from "next";
import { ServerResponse } from "http";
import NSQLite from "@moduletrace/nsqlite";
import { NSQLITE_TEST_DB_USERS, NSQLiteTables } from "../../db/types";
import { NSQLITE_TURBOCI_ADMIN_USERS, NSQLiteTables } from "../../db/types";
import { User } from "../../types";
import { setCookie } from "../../utils/cookies-actions";
import { EJSON } from "../../exports/client-exports";
@ -24,11 +24,11 @@ export default async function loginUser({
password,
email_or_username,
}: Params): Promise<APIResponseObject> {
let fetched_user: NSQLITE_TEST_DB_USERS | undefined;
let fetched_user: NSQLITE_TURBOCI_ADMIN_USERS | undefined;
if (user_id) {
const user_res = await NSQLite.select<
NSQLITE_TEST_DB_USERS,
NSQLITE_TURBOCI_ADMIN_USERS,
(typeof NSQLiteTables)[number]
>({
table: "users",
@ -44,7 +44,7 @@ export default async function loginUser({
if (email_or_username) {
const user_res = await NSQLite.select<
NSQLITE_TEST_DB_USERS,
NSQLITE_TURBOCI_ADMIN_USERS,
(typeof NSQLiteTables)[number]
>({
table: "users",

View File

@ -1,4 +1,7 @@
import { NSQLITE_TEST_DB_USERS_PORTS, NSQLiteTables } from "@/src/db/types";
import {
NSQLITE_TURBOCI_ADMIN_USERS_PORTS,
NSQLiteTables,
} from "@/src/db/types";
import {
NormalizedServerObject,
ParsedDeploymentServiceConfig,
@ -74,7 +77,7 @@ export default async function grabTtydServerInfo({
const connected_user_data = grabConnectedWebsocketUserdata({ user });
await BunSQLite.insert<
NSQLITE_TEST_DB_USERS_PORTS,
NSQLITE_TURBOCI_ADMIN_USERS_PORTS,
(typeof NSQLiteTables)[number]
>({
data: [{ user_id: user.id, port: available_port }],

View File

@ -2,31 +2,67 @@ import { AppContext } from "@/src/pages/_app";
import Dropdown from "@/twui/components/elements/Dropdown";
import LinkList from "@/twui/components/elements/LinkList";
import LucideIcon from "@/twui/components/elements/lucide-icon";
import Paper from "@/twui/components/elements/Paper";
import Divider from "@/twui/components/layout/Divider";
import Img from "@/twui/components/layout/Img";
import Row from "@/twui/components/layout/Row";
import Span from "@/twui/components/layout/Span";
import { useContext } from "react";
import { twMerge } from "tailwind-merge";
export default function HeaderUser() {
const { pageProps } = useContext(AppContext);
const { user } = pageProps;
const ICON_SIZE = 35;
return (
<Dropdown
target={
<Row>
<Img
circle
size={25}
src={user.image_thumbnail}
alt={`${user.first_name} Image`}
/>
<Row className="-my-2">
{user.image_thumbnail ? (
<Img
circle
size={ICON_SIZE}
src={user.image_thumbnail}
alt={`${user.first_name} Image`}
/>
) : (
<div
className={twMerge(
`bg-slate-100 dark:bg-white/10 rounded-full w-[35px] h-[35px]`,
``,
)}
/>
)}
<Span>{user.first_name}</Span>
<LucideIcon name="ChevronDown" size={17} />
</Row>
}
position="bottom-right"
>
<LinkList />
<Paper className="mt-3 min-w-[200px]">
<LinkList
links={[
{
title: `Dashboard`,
url: `/admin`,
},
{
title: `Settings`,
url: `/admin/settings`,
},
{
component: <Divider />,
},
{
title: `Logout`,
url: `/auth/logout`,
},
]}
className="flex-col items-stretch w-full"
/>
</Paper>
</Dropdown>
);
}

View File

@ -1,6 +1,7 @@
import Logo from "@/src/components/general/logo";
import Row from "@/twui/components/layout/Row";
import { PropsWithChildren } from "react";
import HeaderUser from "./(partials)/header-user";
type Props = PropsWithChildren & {};
@ -15,7 +16,11 @@ export default function Header({ children }: Props) {
{/* <Divider vertical className="-mr-[7px]" /> */}
</Row>
<Row className="grid-cell col-span-4 hidden xl:block"></Row>
<Row className="grid-cell col-span-3 xl:col-span-1"></Row>
<Row className="grid-cell col-span-3 xl:col-span-1">
<Row className="p-4 w-full justify-end">
<HeaderUser />
</Row>
</Row>
</Row>
</header>
);

View File

@ -1,6 +1,8 @@
import Main from "@/src/components/pages/admin/users";
import { NSQLITE_TURBOCI_ADMIN_USERS } from "@/src/db/types";
import defaultAdminProps from "@/src/functions/pages/admin/default-admin-props";
import Layout from "@/src/layouts/admin";
import NSQLite from "@moduletrace/nsqlite";
import { GetServerSideProps } from "next";
export default function AdminDashboard() {
@ -19,7 +21,15 @@ export const getServerSideProps: GetServerSideProps = async (ctx) => {
return `/admin`;
}
return {};
const users_res = await NSQLite.select<NSQLITE_TURBOCI_ADMIN_USERS>(
{
table: "users",
},
);
return {
deployment_users: users_res.payload,
};
},
});
};

View File

@ -1,4 +1,4 @@
import { NSQLITE_TEST_DB_USERS, NSQLiteTables } from "@/src/db/types";
import { NSQLITE_TURBOCI_ADMIN_USERS, NSQLiteTables } from "@/src/db/types";
import { APIReqObject } from "@/src/types";
import loginUser from "@/src/functions/auth/login-user";
import hashPassword from "@moduletrace/datasquirel/dist/package-shared/functions/dsql/hashPassword";
@ -29,7 +29,7 @@ export default async function handler(
}
const existing_users_res = await NSQLite.select<
NSQLITE_TEST_DB_USERS,
NSQLITE_TURBOCI_ADMIN_USERS,
(typeof NSQLiteTables)[number]
>({
table: "users",
@ -47,7 +47,7 @@ export default async function handler(
const new_user_password = hashPassword({ password });
const new_user_insert_res = await NSQLite.insert<
NSQLITE_TEST_DB_USERS,
NSQLITE_TURBOCI_ADMIN_USERS,
(typeof NSQLiteTables)[number]
>({
data: [
@ -71,7 +71,7 @@ export default async function handler(
}
const newly_inserted_user_res = await NSQLite.select<
NSQLITE_TEST_DB_USERS,
NSQLITE_TURBOCI_ADMIN_USERS,
(typeof NSQLiteTables)[number]
>({
table: "users",

View File

@ -16,7 +16,7 @@ export const getServerSideProps: GetServerSideProps = async (ctx) => {
return {
redirect: {
destination: `/login`,
destination: `/auth/login`,
statusCode: 307,
},
};

View File

@ -3,6 +3,7 @@ import { DATASQUIREL_LoggedInUser } from "@moduletrace/datasquirel/dist/package-
import useAppInit from "../hooks/use-app-init";
import { ServerWebSocket } from "bun";
import { ChildProcess } from "child_process";
import { NSQLITE_TURBOCI_ADMIN_USERS } from "../db/types";
export type User = DATASQUIREL_LoggedInUser & {
super_admin?: 0 | 1;
@ -196,6 +197,7 @@ export type PagePropsType = {
children_services?: ParsedDeploymentServiceConfig[] | null;
ws_url?: string | null;
host?: string | null;
deployment_users?: NSQLITE_TURBOCI_ADMIN_USERS[] | null;
};
export type APIReqObject = {

View File

@ -1,5 +1,8 @@
import { AppData } from "@/src/data/app-data";
import { NSQLITE_TEST_DB_USERS_PORTS, NSQLiteTables } from "@/src/db/types";
import {
NSQLITE_TURBOCI_ADMIN_USERS_PORTS,
NSQLiteTables,
} from "@/src/db/types";
import { User } from "@/src/types";
import BunSQLite from "@moduletrace/bun-sqlite";
import { execSync, ExecSyncOptions } from "child_process";
@ -11,7 +14,7 @@ type Params = {
export default async function killAllTtydPorts({ user }: Params) {
const user_ports_res = await BunSQLite.select<
NSQLITE_TEST_DB_USERS_PORTS,
NSQLITE_TURBOCI_ADMIN_USERS_PORTS,
(typeof NSQLiteTables)[number]
>({
table: "users_ports",
@ -28,7 +31,7 @@ export default async function killAllTtydPorts({ user }: Params) {
await killPort({ port: user_port.port });
await BunSQLite.delete<
NSQLITE_TEST_DB_USERS_PORTS,
NSQLITE_TURBOCI_ADMIN_USERS_PORTS,
(typeof NSQLiteTables)[number]
>({
table: "users_ports",