2.3.0 • Published 8 years ago

@nxus/admin v2.3.0

Weekly downloads
2
License
MIT
Repository
github
Last release
8 years ago

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 to false 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 reponse
  • order: 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 page
  • responder (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 section
  • welcome String The template partial name to render as welcome and help
  • detail 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 item
  • route String Either a relative (joined with adminUrl) or absolute URL to link to
  • opts 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

  • opts (String | Object) The model identity or options object. (optional, default {})

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-o
  • order - optional ordering for nav
  • uploadType - dataManager import type (e.g. csv, json), if set an Import action is available.
  • uploadOptions - options to pass to dataManager parser

Parameters

  • opts

addNav

Register an admin nav menu item under this model

Parameters

  • label String Label for nav item
  • route String Either a relative (joined with adminUrl) or absolute URL to link to
  • opts 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 action
  • route String Sub-route for action
  • opts 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 action
  • route String Sub-route for action
  • opts Object options for web-actions, e.g. icon, template (optional, default {})

_formatDownloadRecord

Override in subclass to do additional formatting of records for download

Parameters

Returns Object formatted record

2.3.0

8 years ago

2.0.2

8 years ago

2.0.1

8 years ago

2.0.0

8 years ago