# new AdminJS(options)
Parameters:
Name | Type | Description |
---|---|---|
options |
AdminJSOptions
|
Options passed to AdminJS |
Example
const AdminJS = require('adminjs')
const admin = new AdminJS(AdminJSOptions)
Classes
Members
ActionsMap
# static ACTIONS
list, edit, show, delete and bulkDelete you can do this here.
Example
const { ACTIONS } = require('adminjs')
ACTIONS.show.isAccessible = () => {...}
# ACTIONS
list, edit, show, delete and bulkDelete you can do this here.
Example
const { ACTIONS } = require('adminjs')
ACTIONS.show.isAccessible = () => {...}
Array.<BaseResource>
# resources
They can be fetched with the AdminJS#findResource method
Methods
# static bundle(src, componentNameopt) → {String}
It will be available under AdminJS.UserComponents[componentId].
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
src |
String
|
Path to a file containing react component. |
|
componentName |
OverridableComponent
|
<optional> |
name of the component which you want to override |
componentId - uniq id of a component
String
Examples
const adminJsOptions = {
dashboard: {
component: AdminJS.bundle('./path/to/component'),
}
}
// somewhere in the code
AdminJS.bundle('./path/to/new-sidebar/component', 'SidebarFooter')
# static registerAdapter(options) → {void}
Parameters:
Name | Type | Description |
---|---|---|
options |
Object
|
|
Database |
Class.<BaseDatabase>
|
subclass of BaseDatabase |
Resource |
Class.<BaseResource>
|
subclass of BaseResource |
void
Example
const AdminJS = require('adminjs')
const MongooseAdapter = require('adminjs-mongoose')
AdminJS.registerAdapter(MongooseAdapter)
# findResource(resourceId) → {BaseResource}
Parameters:
Name | Type | Description |
---|---|---|
resourceId |
String
|
ID of a resource defined under BaseResource#id |
When resource with given id cannot be found
Error
found resource
Example
const User = admin.findResource('users')
await User.findOne(userId)
# async initialize() → {Promise.<void>}
all external plugins.
Promise.<void>
# async renderLogin(options) → {Promise.<string>}
using Renderer.
Used by external plugins
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
options |
Object
|
||
action |
String
|
Login form action url - it could be '/admin/login' |
|
errorMessage |
String
|
<optional> |
Optional error message. When set, renderer will print this message in the form |
HTML of the rendered page
Promise.<string>
# resolveBabelConfigPath() → {void}
and load configuration to this.options.bundler.babelConfig.
void
# async watch() → {Promise.<never>}
It doesn't work on production environment.
Promise.<never>
Type Definitions
object
# CurrentAdmin
Usage with TypeScript
import { CurrentAdmin } from 'adminjs'
Properties:
Name | Type | Attributes | Description |
---|---|---|---|
email |
string
|
Admin has one required field which is an email |
|
title |
string
|
<optional> |
Optional title/role of an admin - this will be presented below the email |
avatarUrl |
string
|
<optional> |
Optional url for an avatar photo |
id |
string
|
<optional> |
Id of your admin user |
{...} |
any
|
Also you can put as many other fields to it as you like. |
Union
# OverridableComponent
components can be override:
- LoggedIn
- NoRecords
- Sidebar
- SidebarResourceSection
- SidebarFooter
- SidebarBranding
object
# UploadedFile
Properties:
Name | Type | Description |
---|---|---|
size |
number
|
The size of the uploaded file in bytes., this property says how many bytes of the file have been written to disk yet. |
path |
string
|
The path this file is being written to. |
type |
string
|
The mime type of this file, according to the uploading client. |
name |
string
|
null
|
The name this file had according to the uploading client. |