Skip to content

eden-js/admin

Repository files navigation

EdenJS - Admin

TravisCI Issues License Awesome Discord

Administrator base logic component for EdenJS

@edenjs/admin creates all the base administrator logic that any normal system should require. This module also creates configuratble dashboards.

Setup

Install

npm i --save @edenjs/admin

Configure

No configuration is required for this module

Models

Dashboard Usage

Dashboard model consists of a single configurable dashboard instance. These are created in the frontend through the api.

Example

// load model
const Dashboard = model('dashboard');

// get first dashboard
const dashboard = await Dashboard.findOne();

// dashboard used in frontend
const data = await dashboard.sanitise();

Hooks

No hooks created in this module

Views

<dashboard> Usage

The dashboard view creates an instance of a dashboard container, this provides a fully configurable dashboard area.

Example

In the controller Usage

// require helper
const blockHelper = helper('cms/block');

// get dashboards
const dashboards = await Dashboard.find();

// sanitise data
const data = await Promise.all(dashboards.map(dash => dash.sanitise()));

// render dashboard/home.tag view
res.render('dashboard/home', {
  blocks     : blockHelper.renderBlocks('admin'), // render blocks can be namespaced
  dashboards : data,
});

In the view dashboard/home.tag Usage

<dashboard-home-page>
  <dashboard dashboards={ opts.dashboards } blocks={ opts.blocks } type="my.dashboard" name="My Dashboard" />
</dashboard-home-page>

<admin-header> Usage

The admin header view creates a common admin header component for use in admin layout pages.

Example

In the view

<admin-header title="Admin Header Title" />