nxus-admin
v4.1.0-3
Published
Administration components for Nxus applications
Downloads
249
Readme
nxus-admin
Admin
Extends NxusModule
The Base Admin class provides a web interface for managing Nxus applications and data.
getAdminUrl
Returns String the root Url where the admin interface is available.
page
Registers a page with the admin interface. Pages can be defined two different ways.
Template Partials
admin.page('/route', 'partial-name')
Route Handlers
admin.page('/route', () => { // return a response to be rendered within admin template })
admin.page({route: '/route', directHandler: true}, (req, res) => {...})
Options
The first argument can either be a string or an options hash. If an options hash, it
must include a route
attribute.
Other options include:
route
: Required. The route to the page.method
: the HTTP method to use for the route.label
: the nav label to use. Defaults to a title version of the route.nav
: set tofalse
to skip creating a nav item: useful for routes with no display.directHandler
: if true, the handler is a full route handler. Otherwise, wrapped to send reponseorder
: the order of the nav menu.icon
: the icon class to use for the page in the nav and other places.
Parameters
opts
(String | Object) The route or options for the pageresponder
(String | Function) The string partial name or handler function for the route
help
Registers help text for the admin interface.
Parameters
section
String The nav sectionwelcome
String The template partial name to render as welcome and helpdetail
String? An additional partial to render on the help detail
addNav
Register an admin nav menu item, wraps web-nav for relative URls and menu name
Parameters
label
String Label for nav itemroute
String Either a relative (joined with adminUrl) or absolute URL to link toopts
Object nav menu options for web-nav, e.g. icon, order (optional, default{}
)
manage
Create an AdminController for a given model. Takes either the model identity, or an object to pass to the constructor of AdminController with at least {model: 'identity'}
Parameters
AdminController
Extends EditController
A base class for admin model controllers. Overrides the EditController options defaults to provide admin prefixes for routes ("/admin/model-identity") and templates ("model-identity-admin"), and by default wraps templates in 'admin-page' rather than 'page'.
Parameters (in addition to EditController parameters)
icon
- [deprecated] icon class for nav - defaults to fa-files-oorder
- optional ordering for navuploadType
- dataManager import type (e.g. csv, json), if set an Import action is available.uploadOptions
- options to pass to dataManager parserdownloadType
- dataManager download type. If set, a Download action is available.
Parameters
opts
addNav
Register an admin nav menu item under this model
Parameters
label
String Label for nav itemroute
String Either a relative (joined with adminUrl) or absolute URL to link toopts
Object nav menu options for web-nav, e.g. icon, order (optional, default{}
)
addAction
Register an admin action item for this model, wrapping web-actions
Parameters
page
String Template suffix: 'list', 'edit', 'create', 'detail'label
String Label for actionroute
String Sub-route for actionopts
Object options for web-actions, e.g. icon, template (optional, default{}
)
addInstanceAction
Register an admin instance action item for this model's list page, wrapping web-actions
Parameters
label
String Label for actionroute
String Sub-route for actionopts
Object options for web-actions, e.g. icon, template (optional, default{}
)
_formatDownloadRecord
Override in subclass to do additional formatting of records for download
Parameters
record
Objectattrs
Returns Object formatted record