AdminJS

The Backend-Agnostic Administration Framework

Built with Ember.js and EPF

Installation

AdminJS is a self-contained Ember.js application. The two main files are adminjs.js and adminjs.css. Both of these files need to be included in the page along with Ember.js and EPF:

<html>
  <head>
    <link href="adminjs.css" media="screen" rel="stylesheet" type="text/css" />
    <script src="ember.js" type="text/javascript"></script>
    <script src="epf.js" type="text/javascript"></script>
    <script src="adminjs.js" type="text/javascript"></script>
  </head>
  <body>
  </body>
</html>

Creating an Application

All AdminJS applications require a subclass of AJS.Application to be created:

window.App = AJS.Application.create();

Defining Models

AdminJS uses EPF. All models within Epf are subclasses of Ep.Model. For example:

App.Post = Ep.Model.extend({
  title: Ep.attr('string'),
  body: Ep.attr('string'),

  comments: Ep.hasMany(App.Comment),
  user: Ep.belongsTo(App.User)
});

Consult the EPF website for further documentation.

Configuration

Once a model has been defined, AdminJS must be told to manage it:

App.configure(function() {
  this.manage('post');
});

Summary

Bringing this all together, a simple AdminJS application would look like the following:

<html>
  <head>
    <link href="adminjs.css" media="screen" rel="stylesheet" type="text/css" />
    <script src="ember.js" type="text/javascript"></script>
    <script src="epf.js" type="text/javascript"></script>
    <script src="adminjs.js" type="text/javascript"></script>
    <script>
App = AJS.Application.create();

App.Post = Ep.Model.extend({
  title: Ep.attr('string'),
  body: Ep.attr('string'),

  comments: Ep.hasMany(App.Comment),
  user: Ep.belongsTo(App.User)
});

App.configure(function() {
  this.manage('post');
});
    </script>
  </head>
  <body>

  </body>
</html>

Backend

AdminJS will work out of the box with any backend that supports EPF. Please consult the documentation for more information.