Skip to content

Instantly share code, notes, and snippets.

@yogiben
Last active January 14, 2016 15:30
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save yogiben/0096e50d5c87bb221b99 to your computer and use it in GitHub Desktop.
Save yogiben/0096e50d5c87bb221b99 to your computer and use it in GitHub Desktop.

Admin

Package Structure

  1. Add mfactory:admin-base
  2. Add mfactory:admin-blaze or mfactory:admin-react
  3. Add mfactory:iron-router or mfactory:admin-flow-router

Quick start

Go to /admin and there's your admin dashboard!

Configure

Zero config

Admin will automatically configure itself with the default settings. It's designed to work straight out of the box.

By default, it will:

  • Set up an admin route on /admin
  • Allow the first user to visit /admin to declare themselves as admin
  • Set up CRUD routes for all of your collections

If you're using Collection2, admin will use your schemas to generate the forms.

If not, admin will try and guess the schemas based on the data structure of your mongo docs.

Configuring manually

Defaults are shown

Admin.config({
  homeRoute: '/admin',
  ...
})

Default Admin packages

Crud

CRUD (Create, Read, Update, Delete) will let you manage your collection docs.

Add-on Admin packages

Admin Settings

A global key value storage that's can be managed by an admin and used anywhere.

.... more packages to come

Examples

#### Add a collection with admin crud

Admin.crud.addCollection(Posts)

or with options

Admin.crud.addCollection Posts,
  sidebarItem:
    icon: 'fa-book'

#### Add a single crud route

Admin.crud.addView Posts,
  type: 'view' # ['view', 'create', 'update', 'delete']
  label: "View all posts"
  sidebarItem:
    icon: 'fa-book'
  template: 'adminViewPosts'
  
  # Specific to view
  pagination: true
  subscription: ->
    # Must return an array of cursors
  data: ->
    docs: Posts.find({}, {sort: createdAt: -1}})

Sidebar items

A custom external link

Admin.sidebar.addItem
  label: 'Zendesk'
  name: 'zendesk-link
  icon: 'fa-plus'
  href: "http://zendesk.com"

Nested items

Admin.sidebar.addItem
  label: 'Parent'
  icon: 'fa-plus'
  name: 'parent'

then...

Admin.sidebar.addItem
  label: 'Child'
  icon: 'fa-plus'
  name: 'child'
  parent: 'parent'

Creating a custom view:

Admin.routes.addRoute
  name: 'my-route'
  template: 'my-template'
  sidebarItem:
    icon: 'fa-books'
  subscriptions: ->
    # return cursor or array of cursors
  data: ->
    # return object
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment