mirror of
https://github.com/allankoechke/mantisbase-admin.git
synced 2026-12-01 01:15:36 +00:00
Compare commits
6 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 71f539a4af | |||
| 15264a65cd | |||
| 2e43450b5a | |||
| 7b20a7ca91 | |||
| dfe21d4163 | |||
| f9a6c77259 |
189
README.md
189
README.md
@@ -1,5 +1,186 @@
|
||||
# Mantis Admin Dashboard
|
||||
This is the admin dashboard for [mantis](https://github.com/allankoechke/mantis), a BaaS written in C++.
|
||||
> Still in development, some features may be broken!
|
||||
# MantisBase Admin Dashboard
|
||||
|
||||

|
||||
A modern, web-based admin dashboard for managing your MantisBase backend. This dashboard provides an intuitive interface for managing entities, admins, settings, and more.
|
||||
|
||||

|
||||
|
||||
## 📋 Table of Contents
|
||||
|
||||
- [About](#about)
|
||||
- [Getting Started](#getting-started)
|
||||
- [Development](#development)
|
||||
- [Building for Production](#building-for-production)
|
||||
- [Integration with MantisBase](#integration-with-mantisbase)
|
||||
- [Features](#features)
|
||||
- [Links](#links)
|
||||
|
||||
## 🎯 About
|
||||
|
||||
MantisBase Admin Dashboard is the official administrative interface for [MantisBase](https://github.com/allankoechke/mantisbase), a lightweight Backend-as-a-Service (BaaS) written in C++. This dashboard allows you to:
|
||||
|
||||
- Manage database entities and their schemas
|
||||
- Configure access rules and permissions
|
||||
- Manage admin users
|
||||
- View application logs
|
||||
- Configure application settings
|
||||
- And much more!
|
||||
|
||||
## 🚀 Getting Started
|
||||
|
||||
### Prerequisites
|
||||
|
||||
Before you begin, ensure you have the following installed:
|
||||
|
||||
- **Node.js** (version 20 or higher)
|
||||
- **npm** (comes with Node.js)
|
||||
- A running **MantisBase** server instance
|
||||
|
||||
### Installation
|
||||
|
||||
1. **Clone the repository**
|
||||
```bash
|
||||
git clone https://github.com/allankoechke/mantisbase-admin.git
|
||||
cd mantis-admin
|
||||
```
|
||||
|
||||
2. **Install dependencies**
|
||||
```bash
|
||||
npm install
|
||||
```
|
||||
|
||||
3. **Start the development server**
|
||||
```bash
|
||||
npm run dev
|
||||
```
|
||||
|
||||
4. **Open your browser**
|
||||
Navigate to `http://localhost:3000` (or the port shown in your terminal)
|
||||
|
||||
### First Login
|
||||
|
||||
1. If this is your first time setting up MantisBase, you'll need to create an admin account:
|
||||
- Navigate to `/mb/setup?token=YOUR_SETUP_TOKEN`
|
||||
- Enter your email and password
|
||||
- You'll be redirected to the login page
|
||||
|
||||
2. Log in with your admin credentials at `/mb/login`
|
||||
|
||||
## 💻 Development
|
||||
|
||||
### Available Scripts
|
||||
|
||||
- `npm run dev` - Start the development server with hot-reload
|
||||
- `npm run build` - Build the application for production
|
||||
- `npm run lint` - Run ESLint to check code quality
|
||||
- `npm start` - Start the production server (requires build first)
|
||||
|
||||
### Development Mode
|
||||
|
||||
In development mode, the dashboard will:
|
||||
- Connect to `http://localhost:7070` by default (or the port specified in `MANTIS_PORT` environment variable)
|
||||
- Enable hot module replacement for faster development
|
||||
- Show detailed error messages
|
||||
|
||||
### Environment Variables
|
||||
|
||||
You can customize the development setup using environment variables:
|
||||
|
||||
- `MANTIS_PORT` - Port for the MantisBase API (default: 7070)
|
||||
- `NEXT_PUBLIC_BASE_PATH` - Base path for the application (default: `/mb` in production)
|
||||
|
||||
## 🏗️ Building for Production
|
||||
|
||||
To build the dashboard for production:
|
||||
|
||||
```bash
|
||||
npm run build
|
||||
```
|
||||
|
||||
The built static files will be in the `out/` directory. These files can be served by any static file server.
|
||||
|
||||
### Static Export
|
||||
|
||||
The dashboard is configured for static export, making it easy to deploy to:
|
||||
- GitHub Pages
|
||||
- Netlify
|
||||
- Vercel
|
||||
- Any static hosting service
|
||||
|
||||
## 🔗 Integration with MantisBase
|
||||
|
||||
### The `mb-admins` Branch
|
||||
|
||||
This repository includes a special branch called `mb-admins` that is automatically integrated with the main [MantisBase project](https://github.com/allankoechke/mantisbase) via CMake.
|
||||
|
||||
**Important Notes:**
|
||||
|
||||
- The `mb-admins` branch contains the built static files of the admin dashboard
|
||||
- This branch is **automatically updated** on every release
|
||||
- The MantisBase CMake build system uses this branch to include the admin interface
|
||||
- When you build MantisBase, it automatically fetches the latest admin dashboard from this branch
|
||||
|
||||
### How It Works
|
||||
|
||||
1. When a new version is released (tagged with `v*`), a GitHub Action automatically:
|
||||
- Builds the admin dashboard
|
||||
- Updates the `mb-admins` branch with the latest static files
|
||||
- Creates a GitHub release with downloadable assets
|
||||
|
||||
2. The MantisBase CMake configuration:
|
||||
- Clones or updates the `mb-admins` branch during build
|
||||
- Includes the admin dashboard files in the MantisBase build
|
||||
- Serves the admin interface at `/mb/*` when MantisBase is running
|
||||
|
||||
This integration ensures that MantisBase always includes the latest stable version of the admin dashboard without requiring manual updates.
|
||||
|
||||
## ✨ Features
|
||||
|
||||
### Entity Management
|
||||
- Create, read, update, and delete database entities
|
||||
- Configure entity schemas with custom fields
|
||||
- Set up access rules (list, get, add, update, delete)
|
||||
- View and manage entity records
|
||||
|
||||
### Admin Management
|
||||
- Create and manage admin user accounts
|
||||
- Change admin passwords
|
||||
- View admin activity
|
||||
|
||||
### Settings
|
||||
- Configure application settings
|
||||
- Manage file upload limits
|
||||
- Configure session timeouts
|
||||
- Enable/disable features
|
||||
|
||||
### Logs
|
||||
- View application logs
|
||||
- Filter and search logs
|
||||
- Monitor system activity
|
||||
|
||||
### Modern UI
|
||||
- Dark/light theme support
|
||||
- Responsive design
|
||||
- Intuitive navigation
|
||||
- Real-time updates
|
||||
|
||||
## 🔗 Links
|
||||
|
||||
- **Main MantisBase Project**: [https://github.com/allankoechke/mantisbase](https://github.com/allankoechke/mantisbase)
|
||||
- **Documentation**: [https://docs.mantisbase.com](https://docs.mantisbase.com)
|
||||
- **This Repository**: [https://github.com/allankoechke/mantisbase-admin](https://github.com/allankoechke/mantisbase-admin)
|
||||
|
||||
## 📝 Notes
|
||||
|
||||
> **Note**: This project is still in active development. Some features may be incomplete or subject to change.
|
||||
|
||||
## 🤝 Contributing
|
||||
|
||||
Contributions are welcome! Please feel free to submit a Pull Request.
|
||||
|
||||
## 📄 License
|
||||
|
||||
This project is part of the MantisBase ecosystem. Please refer to the main MantisBase repository for license information.
|
||||
|
||||
---
|
||||
|
||||
**Made with ❤️ for the MantisBase community**
|
||||
|
||||
@@ -81,7 +81,7 @@ export function TableConfigDrawer({ table, apiClient, open, onClose, onTableUpda
|
||||
const [activeTab, setActiveTab] = React.useState("schema")
|
||||
const [hasUnsavedChanges, setHasUnsavedChanges] = React.useState(false)
|
||||
const [expandedFields, setExpandedFields] = React.useState<Set<string>>(new Set())
|
||||
const [deletedColumns, setDeletedColumns] = React.useState<string[]>([]) // Track deleted field names
|
||||
const [deletedColumns, setDeletedColumns] = React.useState<string[]>([]) // Track deleted field IDs
|
||||
const [deleteDialogOpen, setDeleteDialogOpen] = React.useState(false)
|
||||
const [isDeleting, setIsDeleting] = React.useState(false)
|
||||
const { toast } = useToast()
|
||||
@@ -169,12 +169,15 @@ export function TableConfigDrawer({ table, apiClient, open, onClose, onTableUpda
|
||||
|
||||
if (!(columns.length > 1 && !isSystemColumn))
|
||||
return
|
||||
const col_name = column.name
|
||||
|
||||
// Ensure the field we are deleting existed/exists in the table already
|
||||
if (!deletedColumns.includes(col_name) && isAnExistingField(index)) {
|
||||
// Add the column to the delete array
|
||||
setDeletedColumns([...deletedColumns, col_name]);
|
||||
if (isAnExistingField(index)) {
|
||||
// Find the original field from the table schema to get its ID
|
||||
const originalField = table.schema.fields.find((f: any) => f.name === column.old_name || f.name === column.name)
|
||||
if (originalField?.id && !deletedColumns.includes(originalField.id)) {
|
||||
// Add the field ID to the delete array
|
||||
setDeletedColumns([...deletedColumns, originalField.id]);
|
||||
}
|
||||
}
|
||||
setColumns(columns.filter((_, i) => i !== index))
|
||||
}
|
||||
@@ -226,7 +229,16 @@ export function TableConfigDrawer({ table, apiClient, open, onClose, onTableUpda
|
||||
...(col.old_name && { old_name: col.old_name }),
|
||||
}))
|
||||
|
||||
const body = { fields: transformedFields, deletedFields: deletedColumns };
|
||||
// Add deleted fields to the fields array with op: "delete"
|
||||
const deletedFields = deletedColumns.map((fieldId: string) => ({
|
||||
id: fieldId,
|
||||
op: "delete"
|
||||
}))
|
||||
|
||||
// Combine regular fields and deleted fields in the fields array
|
||||
const allFields = [...transformedFields, ...deletedFields]
|
||||
|
||||
const body = { fields: allFields };
|
||||
console.log(body)
|
||||
// return
|
||||
const updatedTable = await apiClient.call<TableMetadata>(`/api/v1/schemas/${table.schema.name}`, {
|
||||
|
||||
@@ -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
|
||||
|
||||
BIN
mantisbase-admin.png
Normal file
BIN
mantisbase-admin.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 179 KiB |
@@ -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,
|
||||
},
|
||||
|
||||
8
package-lock.json
generated
8
package-lock.json
generated
@@ -1,12 +1,12 @@
|
||||
{
|
||||
"name": "mantis-admin",
|
||||
"version": "0.3.0",
|
||||
"name": "mantisbase-admin",
|
||||
"version": "0.3.5",
|
||||
"lockfileVersion": 3,
|
||||
"requires": true,
|
||||
"packages": {
|
||||
"": {
|
||||
"name": "mantis-admin",
|
||||
"version": "0.3.0",
|
||||
"name": "mantisbase-admin",
|
||||
"version": "0.3.5",
|
||||
"dependencies": {
|
||||
"@hookform/resolvers": "^3.9.1",
|
||||
"@radix-ui/react-accordion": "1.2.2",
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "mantis-admin",
|
||||
"version": "0.3.0",
|
||||
"name": "mantisbase-admin",
|
||||
"version": "0.3.5",
|
||||
"private": true,
|
||||
"scripts": {
|
||||
"export": "next build && next export",
|
||||
|
||||
BIN
screenshot.png
BIN
screenshot.png
Binary file not shown.
|
Before Width: | Height: | Size: 123 KiB |
Reference in New Issue
Block a user