mirror of
https://github.com/allankoechke/mantisbase-admin.git
synced 2026-12-01 01:15:36 +00:00
Compare commits
8 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| dfe21d4163 | |||
| f9a6c77259 | |||
| b53c098364 | |||
| f3821ab557 | |||
| 592657e0dc | |||
| 2ab08e32b9 | |||
| a397f39233 | |||
| 5800ef9c67 |
@@ -1,5 +1,5 @@
|
||||
# Mantis Admin Dashboard
|
||||
This is the admin dashboard for [mantis](https://github.com/allankoechke/mantis), a BaaS written in C++.
|
||||
# MantisBase Admin Dashboard
|
||||
This is the admin dashboard for [mantis](https://github.com/allankoechke/mantisbase), a BaaS written in C++.
|
||||
> Still in development, some features may be broken!
|
||||
|
||||

|
||||
@@ -14,7 +14,8 @@ export default function RootLayout({
|
||||
return (
|
||||
<html lang="en">
|
||||
<head>
|
||||
<link rel="icon" href="/favicon.ico" />
|
||||
<link rel="icon" href="/mantisbase.svg" type="image/svg+xml" />
|
||||
<link rel="alternate icon" href="/favicon.ico" />
|
||||
</head>
|
||||
<body>{children}</body>
|
||||
</html>
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
|
||||
import * as React from "react"
|
||||
import { Table, Settings, Shield, LogOut, FileText, RefreshCw, ExternalLink, AlertTriangle } from "lucide-react"
|
||||
import { Logo } from "./logo"
|
||||
import {
|
||||
Sidebar,
|
||||
SidebarContent,
|
||||
@@ -278,7 +279,7 @@ export function AdminDashboard({ token, onLogout }: AdminDashboardProps) {
|
||||
<SidebarHeader className="border-b p-0 w-full">
|
||||
<div className="flex h-16 w-full items-center justify-center">
|
||||
<div className="flex h-10 w-10 items-center justify-center rounded-lg bg-primary text-primary-foreground">
|
||||
<Shield className="h-6 w-6" />
|
||||
<Logo className="h-6 w-6" size={24} />
|
||||
</div>
|
||||
</div>
|
||||
</SidebarHeader>
|
||||
|
||||
@@ -26,7 +26,6 @@ import type { ApiClient, TableMetadata, TableField } from "@/lib/api"
|
||||
import { dataTypes } from "@/lib/constants"
|
||||
import { useToast } from "@/hooks/use-toast"
|
||||
import { cn } from "@/lib/utils"
|
||||
import { hash } from "crypto"
|
||||
import { fi } from "date-fns/locale"
|
||||
|
||||
interface AddTableDialogProps {
|
||||
@@ -65,7 +64,6 @@ export function AddTableDialog({ apiClient, onTablesUpdate, children }: AddTable
|
||||
|
||||
// Get unique key for field (use id if exists, otherwise generate one)
|
||||
const getFieldKey = (field: Field, index: number) => field.id || `temp-${index}`
|
||||
const genFieldBaseId = (name: string) => `mbf-${hash(name, "sha256").toString()}`
|
||||
|
||||
// When drawer opens, reset and add base fields
|
||||
React.useEffect(() => {
|
||||
@@ -86,7 +84,7 @@ export function AddTableDialog({ apiClient, onTablesUpdate, children }: AddTable
|
||||
// Add base fields
|
||||
setFields([
|
||||
{
|
||||
id: genFieldBaseId("id"),
|
||||
id: "mbf_14258576900392064537",
|
||||
name: "id",
|
||||
type: "string",
|
||||
primary_key: true,
|
||||
@@ -102,7 +100,7 @@ export function AddTableDialog({ apiClient, onTablesUpdate, children }: AddTable
|
||||
}
|
||||
},
|
||||
{
|
||||
id: genFieldBaseId("created"),
|
||||
id: "mbf_13735287961322938256",
|
||||
name: "created",
|
||||
type: "date",
|
||||
primary_key: false,
|
||||
@@ -118,7 +116,7 @@ export function AddTableDialog({ apiClient, onTablesUpdate, children }: AddTable
|
||||
}
|
||||
},
|
||||
{
|
||||
id: genFieldBaseId("updated"),
|
||||
id: "mbf_9124719522053273721",
|
||||
name: "updated",
|
||||
type: "date",
|
||||
primary_key: false,
|
||||
@@ -140,7 +138,7 @@ export function AddTableDialog({ apiClient, onTablesUpdate, children }: AddTable
|
||||
setFields([
|
||||
...fields,
|
||||
{
|
||||
id: genFieldBaseId("name"),
|
||||
id: "mbf_10420554295983197538",
|
||||
name: "name",
|
||||
type: "string",
|
||||
primary_key: false,
|
||||
@@ -156,7 +154,7 @@ export function AddTableDialog({ apiClient, onTablesUpdate, children }: AddTable
|
||||
}
|
||||
},
|
||||
{
|
||||
id: genFieldBaseId("email"),
|
||||
id: "mbf_16339674465020246541",
|
||||
name: "email",
|
||||
type: "string",
|
||||
primary_key: false,
|
||||
@@ -172,7 +170,7 @@ export function AddTableDialog({ apiClient, onTablesUpdate, children }: AddTable
|
||||
}
|
||||
},
|
||||
{
|
||||
id: genFieldBaseId("password"),
|
||||
id: "mbf_6072375419398818283",
|
||||
name: "password",
|
||||
type: "string",
|
||||
primary_key: false,
|
||||
@@ -308,79 +306,96 @@ export function AddTableDialog({ apiClient, onTablesUpdate, children }: AddTable
|
||||
return
|
||||
}
|
||||
|
||||
// For base and auth types, require at least one user field with a name
|
||||
// For base and auth types, validate that any non-system fields have valid name and type
|
||||
if (tableType !== "view") {
|
||||
const userFields = fields.filter((f) => !f.system && f.name.trim())
|
||||
if (userFields.length === 0) {
|
||||
toast({
|
||||
variant: "destructive",
|
||||
title: "Error",
|
||||
description: "Please add at least one field with a name to the entity.",
|
||||
})
|
||||
setIsLoading(false)
|
||||
return
|
||||
const nonSystemFields = fields.filter((f) => !f.system)
|
||||
for (const field of nonSystemFields) {
|
||||
if (!field.name.trim()) {
|
||||
toast({
|
||||
variant: "destructive",
|
||||
title: "Error",
|
||||
description: "All non-system fields must have a valid name.",
|
||||
})
|
||||
setIsLoading(false)
|
||||
return
|
||||
}
|
||||
if (!field.type || !field.type.trim()) {
|
||||
toast({
|
||||
variant: "destructive",
|
||||
title: "Error",
|
||||
description: `Field "${field.name || 'unnamed'}" must have a valid type selected.`,
|
||||
})
|
||||
setIsLoading(false)
|
||||
return
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Include all fields in order (system + user) for base/auth types
|
||||
// Include all fields in order (system + valid user fields) for base/auth types
|
||||
// For view types, fields are typically empty or derived from SQL
|
||||
// Filter out non-system fields that don't have valid name and type
|
||||
const allFields = tableType === "view"
|
||||
? []
|
||||
: fields.map(
|
||||
(field): TableField => {
|
||||
const fieldData: any = {
|
||||
name: field.name,
|
||||
type: field.type,
|
||||
primary_key: field.primary_key,
|
||||
required: field.required || !field.nullable,
|
||||
unique: field.unique || false,
|
||||
system: field.system || false,
|
||||
constraints: field.constraints,
|
||||
}
|
||||
// Only include id if it exists (for existing fields being updated)
|
||||
if (field.id) {
|
||||
fieldData.id = field.id
|
||||
}
|
||||
return fieldData
|
||||
},
|
||||
)
|
||||
: fields
|
||||
.filter((field) => {
|
||||
// Keep all system fields
|
||||
if (field.system) return true
|
||||
// For non-system fields, only keep those with valid name and type
|
||||
return field.name.trim() && field.type && field.type.trim()
|
||||
})
|
||||
.map(
|
||||
(field): TableField => {
|
||||
const fieldData: any = {
|
||||
name: field.name,
|
||||
type: field.type,
|
||||
primary_key: field.primary_key,
|
||||
required: field.required,
|
||||
unique: field.unique || false,
|
||||
system: field.system || false,
|
||||
constraints: field.constraints,
|
||||
}
|
||||
// Only include id if it exists (for existing fields being updated)
|
||||
if (field.id && field.id.startsWith("mbf_")) {
|
||||
fieldData.id = field.id
|
||||
}
|
||||
|
||||
return fieldData
|
||||
},
|
||||
)
|
||||
|
||||
const tableData: any = {
|
||||
name: tableName,
|
||||
has_api: true,
|
||||
system: false,
|
||||
type: tableType,
|
||||
schema: {
|
||||
id: "", // Will be generated by the API
|
||||
name: tableName,
|
||||
has_api: true,
|
||||
system: false,
|
||||
type: tableType,
|
||||
fields: allFields,
|
||||
rules: {
|
||||
add: {
|
||||
expr: "",
|
||||
mode: "auth"
|
||||
},
|
||||
delete: {
|
||||
expr: "",
|
||||
mode: "auth"
|
||||
},
|
||||
get: {
|
||||
expr: "",
|
||||
mode: "auth"
|
||||
},
|
||||
list: {
|
||||
expr: "",
|
||||
mode: "auth"
|
||||
},
|
||||
update: {
|
||||
expr: "",
|
||||
mode: "auth"
|
||||
}
|
||||
fields: allFields,
|
||||
rules: {
|
||||
add: {
|
||||
expr: "",
|
||||
mode: ""
|
||||
},
|
||||
...(tableType === "view" && { sql: sqlQuery.trim() }),
|
||||
delete: {
|
||||
expr: "",
|
||||
mode: ""
|
||||
},
|
||||
get: {
|
||||
expr: "",
|
||||
mode: ""
|
||||
},
|
||||
list: {
|
||||
expr: "",
|
||||
mode: ""
|
||||
},
|
||||
update: {
|
||||
expr: "",
|
||||
mode: ""
|
||||
}
|
||||
},
|
||||
...(tableType === "view" && { sql: sqlQuery.trim() }),
|
||||
}
|
||||
|
||||
console.log(tableData)
|
||||
|
||||
const res: any = await apiClient.call("/api/v1/schemas", {
|
||||
method: "POST",
|
||||
body: JSON.stringify(tableData),
|
||||
@@ -710,9 +725,7 @@ export function AddTableDialog({ apiClient, onTablesUpdate, children }: AddTable
|
||||
disabled={
|
||||
isLoading ||
|
||||
!tableName.trim() ||
|
||||
(tableType === "view"
|
||||
? !sqlQuery.trim()
|
||||
: fields.filter((f) => !f.system).length === 0)
|
||||
(tableType === "view" ? !sqlQuery.trim() : false)
|
||||
}
|
||||
>
|
||||
{isLoading ? "Creating..." : "Create Entity"}
|
||||
|
||||
@@ -234,6 +234,7 @@ export function DatabaseSection({ apiClient, tables, onTablesUpdate }: DatabaseS
|
||||
const updatedTables = tables.map((t) => (t.id === updatedTable.id ? updatedTable : t))
|
||||
onTablesUpdate(updatedTables)
|
||||
}}
|
||||
onTablesUpdate={onTablesUpdate}
|
||||
/>
|
||||
) : (
|
||||
<div className="flex items-center justify-center h-full">
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -22,9 +22,10 @@ interface TableDetailViewProps {
|
||||
onBack?: () => void
|
||||
apiClient: ApiClient
|
||||
onTableUpdate: (table: TableMetadata) => void
|
||||
onTablesUpdate?: (tables: TableMetadata[]) => void
|
||||
}
|
||||
|
||||
export function TableDetailView({ table, onBack, apiClient, onTableUpdate }: TableDetailViewProps) {
|
||||
export function TableDetailView({ table, onBack, apiClient, onTableUpdate, onTablesUpdate }: TableDetailViewProps) {
|
||||
const [tableData, setTableData] = React.useState<any[]>([])
|
||||
const [currentPage, setCurrentPage] = React.useState(1)
|
||||
const [totalPages, setTotalPages] = React.useState(1)
|
||||
@@ -467,6 +468,7 @@ export function TableDetailView({ table, onBack, apiClient, onTableUpdate }: Tab
|
||||
open={configOpen}
|
||||
onClose={() => setConfigOpen(false)}
|
||||
onTableUpdate={onTableUpdate}
|
||||
onTablesUpdate={onTablesUpdate}
|
||||
/>
|
||||
|
||||
<TableRecordDocsDrawer table={table} open={docsOpen} onClose={() => setDocsOpen(false)} />
|
||||
|
||||
@@ -1,7 +1,8 @@
|
||||
"use client"
|
||||
|
||||
import * as React from "react"
|
||||
import { Eye, EyeOff, Shield } from "lucide-react"
|
||||
import { Eye, EyeOff } from "lucide-react"
|
||||
import { Logo } from "./logo"
|
||||
|
||||
import { Button } from "@/components/ui/button"
|
||||
import { Card, CardContent, CardDescription, CardHeader, CardTitle } from "@/components/ui/card"
|
||||
@@ -42,7 +43,7 @@ export function LoginForm({ onLogin }: LoginFormProps) {
|
||||
<Card className="w-full max-w-md">
|
||||
<CardHeader className="text-center">
|
||||
<div className="flex justify-center mb-4">
|
||||
<Shield className="h-12 w-12 text-primary" />
|
||||
<Logo className="h-12 w-12 text-primary" size={48} />
|
||||
</div>
|
||||
<CardTitle className="text-2xl">Mantis Admin</CardTitle>
|
||||
<CardDescription>Sign in to access the admin dashboard</CardDescription>
|
||||
|
||||
49
components/logo.tsx
Normal file
49
components/logo.tsx
Normal file
@@ -0,0 +1,49 @@
|
||||
"use client"
|
||||
|
||||
import * as React from "react"
|
||||
import { cn } from "@/lib/utils"
|
||||
|
||||
interface LogoProps {
|
||||
className?: string
|
||||
size?: number
|
||||
}
|
||||
|
||||
export function Logo({ className, size = 40 }: LogoProps) {
|
||||
|
||||
return (
|
||||
<svg
|
||||
width={size}
|
||||
height={size}
|
||||
viewBox="0 0 40.018326 43.557034"
|
||||
className={cn("transition-colors", className)}
|
||||
fill="currentColor"
|
||||
xmlns="http://www.w3.org/2000/svg"
|
||||
>
|
||||
<g transform="translate(-76.752395,-70.247194)">
|
||||
<g transform="matrix(0.35277778,0,0,0.35277778,27.80232,86.453883)">
|
||||
<g
|
||||
clipPath="url(#5346413700)"
|
||||
transform="translate(138.6038,-57.494913)"
|
||||
style={{ fill: "currentColor" }}
|
||||
>
|
||||
<path
|
||||
d="m 106.50391,11.554688 c -6.05469,0.04297 -14.179691,10.277343 -21.875004,27.5625 -1.28125,2.878906 -2.332031,5.316406 -2.332031,5.414062 0,0.542969 0.507813,-0.109375 2.09375,-2.699219 2.585937,-4.226562 9.738281,-11.082031 15.195313,-14.558593 10.179692,-6.492188 11.945312,-7.71875 12.808592,-8.90625 0.80469,-1.101563 0.83594,-1.398438 0.29297,-2.710938 -0.75,-1.804688 -4.23047,-4.117188 -6.18359,-4.101562 z m -99.199222,0.09375 c -0.417969,-0.01172 -0.824219,0.01953 -1.222657,0.09375 -2.214843,0.414062 -5.316406,3.375 -5.316406,5.074218 0,1.722656 1.6875,3.203125 8.199219,7.195313 2.964844,1.820312 6.773437,4.328125 8.460937,5.570312 4.101563,3.019531 10.363281,9.683594 12.359375,13.152344 0.886719,1.539063 1.6875,2.730469 1.773438,2.648437 0.08984,-0.08203 -0.914063,-2.601562 -2.230469,-5.59375 C 21.503906,21.996094 13.535156,11.859375 7.304688,11.648438 Z m 9.121093,34.699218 C 12.449219,46.324219 11.773438,46.453125 9,47.769531 2.671875,50.765625 0.144531,54.5625 0.152344,61.0625 c 0.019531,11.21875 8.820312,22.660156 20.476562,26.621094 0.476563,0.160156 0.867188,1.039062 1.074219,2.414062 1.042969,6.945313 4.808594,14.824224 9.351563,19.542974 l 3.339843,3.47265 -0.757812,3.1211 c -1.0625,4.3789 -0.671875,9.55078 0.96875,12.83984 1.136719,2.27344 4.152343,5.91797 4.898437,5.91797 0.175782,0 0.113282,-0.87891 -0.132812,-1.95703 -0.742188,-3.23047 -0.277344,-10.46094 0.796875,-12.29688 0.5,-0.85937 1.128906,-1.63672 1.394531,-1.72265 0.265625,-0.0898 0.933594,0.64062 1.484375,1.625 1.378906,2.44921 4.738281,5.44531 7.609375,6.78125 2.859375,1.33203 8.238281,1.53906 11.367188,0.43359 2.898437,-1.02344 6.117187,-3.58984 8.085937,-6.44531 0.960937,-1.39844 1.933594,-2.53907 2.15625,-2.53907 0.226563,0 0.859375,0.98438 1.40625,2.1875 1.070313,2.34766 1.386719,8.00782 0.671875,11.99219 l -0.351562,1.97266 1.082031,-0.70703 c 1.464843,-0.96094 3.859375,-4.36719 4.769531,-6.78516 0.972656,-2.58984 0.964844,-9.46094 -0.01172,-12.54687 -0.703125,-2.21875 -0.695312,-2.28907 0.296875,-2.95313 4.992188,-3.34375 10.484375,-13.671875 12.097656,-22.753906 0.179688,-1.019532 0.570313,-1.730469 0.945313,-1.730469 1.3125,0 6.492187,-2.796875 9.152346,-4.941406 11.87109,-9.570313 15.03906,-26.179688 6.23047,-32.671875 -3.58203,-2.636719 -6.55078,-3.554688 -11.515629,-3.554688 -4.9375,0 -7.9375,0.910156 -11.984374,3.632813 l -2.300782,1.546875 -2.875,-1.292969 c -6.164062,-2.773437 -8.011718,-3.011719 -23.144531,-3.019531 -12.996094,0 -14.035156,0.05859 -17.417969,1.039062 -1.976562,0.574219 -4.617187,1.558594 -5.859375,2.191406 L 31.191406,51.625 28.574219,49.949219 C 24.332031,47.234375 21.4375,46.375 16.425781,46.347656 Z m 81.507813,3.996094 c 4.492186,0.02734 9.109376,1.824219 10.648436,4.3125 3.35938,5.441406 0.0195,16.671875 -7.08984,23.820312 -4.656252,4.683594 -10.949221,7.691407 -16.089846,7.691407 -1.558594,0 -1.621094,-0.07031 -2.320313,-2.648438 -2.726562,-10.050781 -2.640625,-18.355469 0.25,-24.683593 2.289063,-5.003907 6.328125,-7.675782 12.691407,-8.394532 0.628906,-0.07031 1.269531,-0.101562 1.910156,-0.09766 z m -81.160156,0.0625 c 0.675781,0.03516 1.34375,0.109375 2.003906,0.226562 4.390625,0.769532 8.398437,2.910157 10.113281,5.398438 2.839844,4.128906 3.402344,6.542969 3.367187,14.472656 -0.02734,6.003906 -0.210937,7.800782 -1.136718,11.285156 L 30.015625,85.9375 28.175781,86.03125 C 27.160156,86.085938 25.21875,85.824219 23.855469,85.449219 15.117188,83.0625 7.386719,75.117188 4.675781,65.734375 3.597656,62 3.855469,56.324219 5.1875,54.53125 c 2.007812,-2.710938 6.871094,-4.371094 11.585938,-4.125 z m 40.390624,1.222656 c 13.476563,0.0078 18.050782,0.535156 19.800782,2.285156 1.011718,1.011719 0.953125,1.398438 -1.082032,7.011719 -0.898437,2.484375 -0.914062,2.800781 -0.269531,5.859375 0.65625,3.136719 0.558594,5.371094 -0.320312,7.085938 -0.234375,0.457031 -2.089844,2.632812 -4.121094,4.835937 C 64.328125,86.121094 60.019531,92.335938 57.070312,99.0625 56.71875,99.867188 56.554688,99.976562 56.535156,99.429688 56.476562,98.03125 52.625,91.058594 49.953125,87.527344 48.527344,85.640625 45.28125,81.761719 42.738281,78.914062 37.785156,73.355469 37.222656,72.171875 37.816406,68.519531 38.675781,63.203125 38.65625,62.386719 37.621094,60.09375 37.0625,58.855469 36.421875,57.242188 36.203125,56.511719 35.015625,52.5625 39.082031,51.617188 57.164062,51.628906 Z M 47.023438,107.79297 c 0.847656,-0.0312 2.066406,0.66797 3.304687,1.98047 3.746094,3.96875 3.710937,4.27734 -0.273437,2.21484 -2.8125,-1.45312 -4.394532,-2.93359 -3.933594,-3.68359 0.203125,-0.32813 0.515625,-0.4961 0.902344,-0.51172 z m 19.289062,0.0234 c 2.121094,0 1.578125,1.55859 -1.125,3.22265 -2.78125,1.71094 -4.539062,2.44141 -4.539062,1.88672 0,-0.21875 0.996093,-1.45703 2.210937,-2.7539 1.601563,-1.70704 2.554687,-2.35547 3.453125,-2.35547 z m 0,0"
|
||||
fill="currentColor"
|
||||
fillOpacity="1"
|
||||
fillRule="nonzero"
|
||||
/>
|
||||
</g>
|
||||
</g>
|
||||
</g>
|
||||
<defs>
|
||||
<clipPath id="5346413700">
|
||||
<path
|
||||
d="M 0.0742188,11.554688 H 113.92578 V 135.14062 H 0.0742188 Z m 0,0"
|
||||
clipRule="nonzero"
|
||||
/>
|
||||
</clipPath>
|
||||
</defs>
|
||||
</svg>
|
||||
)
|
||||
}
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
"use client"
|
||||
|
||||
import * as React from "react"
|
||||
import { AlertTriangle } from "lucide-react"
|
||||
import { LoginForm } from "@/components/login-form"
|
||||
import { SetupForm } from "@/components/setup-form"
|
||||
import { AdminDashboard } from "@/components/admin-dashboard"
|
||||
@@ -8,6 +9,9 @@ import { Toaster } from "@/components/ui/toaster"
|
||||
import { ThemeProvider } from "@/components/theme-provider"
|
||||
import { AppStateProvider } from "@/lib/app-state"
|
||||
import { useRouter } from "@/lib/router"
|
||||
import { Card, CardContent, CardDescription, CardHeader, CardTitle } from "@/components/ui/card"
|
||||
import { Alert, AlertDescription, AlertTitle } from "@/components/ui/alert"
|
||||
import { Logo } from "./logo"
|
||||
|
||||
export default function MainPage() {
|
||||
const [token, setToken] = React.useState<string | null>(null)
|
||||
@@ -91,6 +95,38 @@ export default function MainPage() {
|
||||
const isSetupRoute = route.path === "/setup"
|
||||
const setupToken = route.queryParams.token
|
||||
|
||||
// Show error if on setup route but no token provided
|
||||
if (isSetupRoute && !setupToken) {
|
||||
return (
|
||||
<ThemeProvider attribute="class" defaultTheme="dark" enableSystem storageKey="mantis-admin-theme" disableTransitionOnChange>
|
||||
<AppStateProvider>
|
||||
<div className="min-h-screen flex items-center justify-center bg-background">
|
||||
<Card className="w-full max-w-md">
|
||||
<CardHeader className="text-center">
|
||||
<div className="flex justify-center mb-4">
|
||||
<Logo className="h-12 w-12 text-primary" size={48} />
|
||||
</div>
|
||||
<CardTitle className="text-2xl">Setup Access Required</CardTitle>
|
||||
<CardDescription>An access token is required to access the setup page</CardDescription>
|
||||
</CardHeader>
|
||||
<CardContent>
|
||||
<Alert variant="destructive">
|
||||
<AlertTriangle className="h-4 w-4" />
|
||||
<AlertTitle>Missing Access Token</AlertTitle>
|
||||
<AlertDescription>
|
||||
This page requires an access token to be provided via the query parameter.
|
||||
Please ensure you have a valid setup token in the URL (e.g., /setup?token=your-token-here).
|
||||
</AlertDescription>
|
||||
</Alert>
|
||||
</CardContent>
|
||||
</Card>
|
||||
</div>
|
||||
<Toaster />
|
||||
</AppStateProvider>
|
||||
</ThemeProvider>
|
||||
)
|
||||
}
|
||||
|
||||
return (
|
||||
<ThemeProvider attribute="class" defaultTheme="dark" enableSystem storageKey="mantis-admin-theme" disableTransitionOnChange>
|
||||
<AppStateProvider>
|
||||
|
||||
@@ -1,7 +1,8 @@
|
||||
"use client"
|
||||
|
||||
import * as React from "react"
|
||||
import { Eye, EyeOff, Shield, CheckCircle2 } from "lucide-react"
|
||||
import { Eye, EyeOff, CheckCircle2 } from "lucide-react"
|
||||
import { Logo } from "./logo"
|
||||
|
||||
import { Button } from "@/components/ui/button"
|
||||
import { Card, CardContent, CardDescription, CardHeader, CardTitle } from "@/components/ui/card"
|
||||
@@ -56,7 +57,7 @@ export function SetupForm({ token, onSetupComplete }: SetupFormProps) {
|
||||
|
||||
try {
|
||||
// Create admin account using the setup token
|
||||
const response: any = await apiClient.call("/api/v1/entities/mb_admins", {
|
||||
const response: any = await apiClient.call("/api/v1/auth/setup/admin", {
|
||||
method: "POST",
|
||||
body: JSON.stringify({
|
||||
email,
|
||||
@@ -64,10 +65,12 @@ export function SetupForm({ token, onSetupComplete }: SetupFormProps) {
|
||||
}),
|
||||
})
|
||||
|
||||
if (response?.error?.length > 0) {
|
||||
// Check if response has an error field (ApiClient may return error in catch block)
|
||||
if (response?.error && response.error.length > 0) {
|
||||
throw new Error(response.error)
|
||||
}
|
||||
|
||||
// If we get here, the account was created successfully
|
||||
setSuccess(true)
|
||||
toast({
|
||||
title: "Account Created",
|
||||
@@ -79,7 +82,10 @@ export function SetupForm({ token, onSetupComplete }: SetupFormProps) {
|
||||
onSetupComplete()
|
||||
}, 2000)
|
||||
} catch (err: any) {
|
||||
setError(err.message || "Failed to create admin account")
|
||||
// Handle API errors - ApiClient throws errors for failed requests
|
||||
const errorMessage = err.message || "Failed to create admin account"
|
||||
setError(errorMessage)
|
||||
console.error("Setup error:", err)
|
||||
} finally {
|
||||
setIsLoading(false)
|
||||
}
|
||||
@@ -90,7 +96,7 @@ export function SetupForm({ token, onSetupComplete }: SetupFormProps) {
|
||||
<Card className="w-full max-w-md">
|
||||
<CardHeader className="text-center">
|
||||
<div className="flex justify-center mb-4">
|
||||
<Shield className="h-12 w-12 text-primary" />
|
||||
<Logo className="h-12 w-12 text-primary" size={48} />
|
||||
</div>
|
||||
<CardTitle className="text-2xl">Setup Admin Account</CardTitle>
|
||||
<CardDescription>Create your first admin account to get started</CardDescription>
|
||||
|
||||
@@ -18,24 +18,24 @@ const ROUTE_CHANGE_EVENT = "custom-route-change"
|
||||
let currentRoute: ParsedRoute = { path: "/entities", pathParams: {}, queryParams: {} }
|
||||
|
||||
// Get the base path for the application
|
||||
// In production, this should be '/mb-admin', in development it might be empty
|
||||
// In production, this should be '/mb', in development it might be empty
|
||||
export function getBasePath(): string {
|
||||
if (typeof window === "undefined") {
|
||||
// Server-side: use env var or default to /mb-admin for production
|
||||
return process.env.NEXT_PUBLIC_BASE_PATH || (process.env.NODE_ENV === 'production' ? '/mb-admin' : '')
|
||||
// Server-side: use env var or default to /mb for production
|
||||
return process.env.NEXT_PUBLIC_BASE_PATH || (process.env.NODE_ENV === 'production' ? '/mb' : '')
|
||||
}
|
||||
|
||||
// Client-side: try to detect base path from current location
|
||||
// If we're at /mb-admin/*, the base path is /mb-admin
|
||||
// If we're at /mb/* or exactly /mb, the base path is /mb
|
||||
const pathname = window.location.pathname
|
||||
if (pathname.startsWith("/mb-admin")) {
|
||||
return "/mb-admin"
|
||||
if (pathname === "/mb" || pathname.startsWith("/mb/")) {
|
||||
return "/mb"
|
||||
}
|
||||
|
||||
// Fallback: check if we're in production mode
|
||||
// In development, base path might be empty
|
||||
if (process.env.NODE_ENV === 'production') {
|
||||
return process.env.NEXT_PUBLIC_BASE_PATH || "/mb-admin"
|
||||
return process.env.NEXT_PUBLIC_BASE_PATH || "/mb"
|
||||
}
|
||||
|
||||
// Development: no base path
|
||||
|
||||
@@ -5,7 +5,7 @@ const { version } = require('./package.json');
|
||||
/** @type {import('next').NextConfig} */
|
||||
const nextConfig = {
|
||||
// Use basePath in production, or if explicitly set via env var
|
||||
basePath: process.env.NEXT_PUBLIC_BASE_PATH || (process.env.NODE_ENV === 'production' ? '/mb-admin' : ''),
|
||||
basePath: process.env.NEXT_PUBLIC_BASE_PATH || (process.env.NODE_ENV === 'production' ? '/mb' : ''),
|
||||
env: {
|
||||
MANTIS_ADMIN_VERSION: version,
|
||||
},
|
||||
|
||||
4
package-lock.json
generated
4
package-lock.json
generated
@@ -1,12 +1,12 @@
|
||||
{
|
||||
"name": "mantis-admin",
|
||||
"version": "0.3.0",
|
||||
"version": "0.3.3",
|
||||
"lockfileVersion": 3,
|
||||
"requires": true,
|
||||
"packages": {
|
||||
"": {
|
||||
"name": "mantis-admin",
|
||||
"version": "0.3.0",
|
||||
"version": "0.3.3",
|
||||
"dependencies": {
|
||||
"@hookform/resolvers": "^3.9.1",
|
||||
"@radix-ui/react-accordion": "1.2.2",
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "mantis-admin",
|
||||
"version": "0.3.0",
|
||||
"version": "0.3.4",
|
||||
"private": true,
|
||||
"scripts": {
|
||||
"export": "next build && next export",
|
||||
|
||||
51
public/mantisbase.svg
Normal file
51
public/mantisbase.svg
Normal file
@@ -0,0 +1,51 @@
|
||||
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||
<!-- Created with Inkscape (http://www.inkscape.org/) -->
|
||||
|
||||
<svg
|
||||
width="40.018326mm"
|
||||
height="43.557034mm"
|
||||
viewBox="0 0 40.018326 43.557034"
|
||||
version="1.1"
|
||||
id="svg1"
|
||||
xml:space="preserve"
|
||||
xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
|
||||
xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
|
||||
xmlns="http://www.w3.org/2000/svg"
|
||||
xmlns:svg="http://www.w3.org/2000/svg"><sodipodi:namedview
|
||||
id="namedview1"
|
||||
pagecolor="#ffffff"
|
||||
bordercolor="#000000"
|
||||
borderopacity="0.25"
|
||||
inkscape:showpageshadow="2"
|
||||
inkscape:pageopacity="0.0"
|
||||
inkscape:pagecheckerboard="0"
|
||||
inkscape:deskcolor="#d1d1d1"
|
||||
inkscape:document-units="mm"><inkscape:page
|
||||
x="0"
|
||||
y="0"
|
||||
width="40.018326"
|
||||
height="43.557034"
|
||||
id="page2"
|
||||
margin="0"
|
||||
bleed="0" /></sodipodi:namedview><defs
|
||||
id="defs1"><clipPath
|
||||
id="5346413700"><path
|
||||
d="M 0.0742188,11.554688 H 113.92578 V 135.14062 H 0.0742188 Z m 0,0"
|
||||
clip-rule="nonzero"
|
||||
id="path2" /></clipPath></defs><g
|
||||
inkscape:label="Layer 1"
|
||||
inkscape:groupmode="layer"
|
||||
id="layer1"
|
||||
transform="translate(-76.752395,-70.247194)"><g
|
||||
id="g2"
|
||||
transform="matrix(0.35277778,0,0,0.35277778,27.80232,86.453883)"><g
|
||||
clip-path="url(#5346413700)"
|
||||
id="g4"
|
||||
style="fill:#000000"
|
||||
transform="translate(138.6038,-57.494913)"><path
|
||||
fill="#ffffff"
|
||||
d="m 106.50391,11.554688 c -6.05469,0.04297 -14.179691,10.277343 -21.875004,27.5625 -1.28125,2.878906 -2.332031,5.316406 -2.332031,5.414062 0,0.542969 0.507813,-0.109375 2.09375,-2.699219 2.585937,-4.226562 9.738281,-11.082031 15.195313,-14.558593 10.179692,-6.492188 11.945312,-7.71875 12.808592,-8.90625 0.80469,-1.101563 0.83594,-1.398438 0.29297,-2.710938 -0.75,-1.804688 -4.23047,-4.117188 -6.18359,-4.101562 z m -99.199222,0.09375 c -0.417969,-0.01172 -0.824219,0.01953 -1.222657,0.09375 -2.214843,0.414062 -5.316406,3.375 -5.316406,5.074218 0,1.722656 1.6875,3.203125 8.199219,7.195313 2.964844,1.820312 6.773437,4.328125 8.460937,5.570312 4.101563,3.019531 10.363281,9.683594 12.359375,13.152344 0.886719,1.539063 1.6875,2.730469 1.773438,2.648437 0.08984,-0.08203 -0.914063,-2.601562 -2.230469,-5.59375 C 21.503906,21.996094 13.535156,11.859375 7.304688,11.648438 Z m 9.121093,34.699218 C 12.449219,46.324219 11.773438,46.453125 9,47.769531 2.671875,50.765625 0.144531,54.5625 0.152344,61.0625 c 0.019531,11.21875 8.820312,22.660156 20.476562,26.621094 0.476563,0.160156 0.867188,1.039062 1.074219,2.414062 1.042969,6.945313 4.808594,14.824224 9.351563,19.542974 l 3.339843,3.47265 -0.757812,3.1211 c -1.0625,4.3789 -0.671875,9.55078 0.96875,12.83984 1.136719,2.27344 4.152343,5.91797 4.898437,5.91797 0.175782,0 0.113282,-0.87891 -0.132812,-1.95703 -0.742188,-3.23047 -0.277344,-10.46094 0.796875,-12.29688 0.5,-0.85937 1.128906,-1.63672 1.394531,-1.72265 0.265625,-0.0898 0.933594,0.64062 1.484375,1.625 1.378906,2.44921 4.738281,5.44531 7.609375,6.78125 2.859375,1.33203 8.238281,1.53906 11.367188,0.43359 2.898437,-1.02344 6.117187,-3.58984 8.085937,-6.44531 0.960937,-1.39844 1.933594,-2.53907 2.15625,-2.53907 0.226563,0 0.859375,0.98438 1.40625,2.1875 1.070313,2.34766 1.386719,8.00782 0.671875,11.99219 l -0.351562,1.97266 1.082031,-0.70703 c 1.464843,-0.96094 3.859375,-4.36719 4.769531,-6.78516 0.972656,-2.58984 0.964844,-9.46094 -0.01172,-12.54687 -0.703125,-2.21875 -0.695312,-2.28907 0.296875,-2.95313 4.992188,-3.34375 10.484375,-13.671875 12.097656,-22.753906 0.179688,-1.019532 0.570313,-1.730469 0.945313,-1.730469 1.3125,0 6.492187,-2.796875 9.152346,-4.941406 11.87109,-9.570313 15.03906,-26.179688 6.23047,-32.671875 -3.58203,-2.636719 -6.55078,-3.554688 -11.515629,-3.554688 -4.9375,0 -7.9375,0.910156 -11.984374,3.632813 l -2.300782,1.546875 -2.875,-1.292969 c -6.164062,-2.773437 -8.011718,-3.011719 -23.144531,-3.019531 -12.996094,0 -14.035156,0.05859 -17.417969,1.039062 -1.976562,0.574219 -4.617187,1.558594 -5.859375,2.191406 L 31.191406,51.625 28.574219,49.949219 C 24.332031,47.234375 21.4375,46.375 16.425781,46.347656 Z m 81.507813,3.996094 c 4.492186,0.02734 9.109376,1.824219 10.648436,4.3125 3.35938,5.441406 0.0195,16.671875 -7.08984,23.820312 -4.656252,4.683594 -10.949221,7.691407 -16.089846,7.691407 -1.558594,0 -1.621094,-0.07031 -2.320313,-2.648438 -2.726562,-10.050781 -2.640625,-18.355469 0.25,-24.683593 2.289063,-5.003907 6.328125,-7.675782 12.691407,-8.394532 0.628906,-0.07031 1.269531,-0.101562 1.910156,-0.09766 z m -81.160156,0.0625 c 0.675781,0.03516 1.34375,0.109375 2.003906,0.226562 4.390625,0.769532 8.398437,2.910157 10.113281,5.398438 2.839844,4.128906 3.402344,6.542969 3.367187,14.472656 -0.02734,6.003906 -0.210937,7.800782 -1.136718,11.285156 L 30.015625,85.9375 28.175781,86.03125 C 27.160156,86.085938 25.21875,85.824219 23.855469,85.449219 15.117188,83.0625 7.386719,75.117188 4.675781,65.734375 3.597656,62 3.855469,56.324219 5.1875,54.53125 c 2.007812,-2.710938 6.871094,-4.371094 11.585938,-4.125 z m 40.390624,1.222656 c 13.476563,0.0078 18.050782,0.535156 19.800782,2.285156 1.011718,1.011719 0.953125,1.398438 -1.082032,7.011719 -0.898437,2.484375 -0.914062,2.800781 -0.269531,5.859375 0.65625,3.136719 0.558594,5.371094 -0.320312,7.085938 -0.234375,0.457031 -2.089844,2.632812 -4.121094,4.835937 C 64.328125,86.121094 60.019531,92.335938 57.070312,99.0625 56.71875,99.867188 56.554688,99.976562 56.535156,99.429688 56.476562,98.03125 52.625,91.058594 49.953125,87.527344 48.527344,85.640625 45.28125,81.761719 42.738281,78.914062 37.785156,73.355469 37.222656,72.171875 37.816406,68.519531 38.675781,63.203125 38.65625,62.386719 37.621094,60.09375 37.0625,58.855469 36.421875,57.242188 36.203125,56.511719 35.015625,52.5625 39.082031,51.617188 57.164062,51.628906 Z M 47.023438,107.79297 c 0.847656,-0.0312 2.066406,0.66797 3.304687,1.98047 3.746094,3.96875 3.710937,4.27734 -0.273437,2.21484 -2.8125,-1.45312 -4.394532,-2.93359 -3.933594,-3.68359 0.203125,-0.32813 0.515625,-0.4961 0.902344,-0.51172 z m 19.289062,0.0234 c 2.121094,0 1.578125,1.55859 -1.125,3.22265 -2.78125,1.71094 -4.539062,2.44141 -4.539062,1.88672 0,-0.21875 0.996093,-1.45703 2.210937,-2.7539 1.601563,-1.70704 2.554687,-2.35547 3.453125,-2.35547 z m 0,0"
|
||||
fill-opacity="1"
|
||||
fill-rule="nonzero"
|
||||
id="path4"
|
||||
style="fill:#000000" /></g></g></g></svg>
|
||||
|
After Width: | Height: | Size: 6.3 KiB |
Reference in New Issue
Block a user