Skip to content

wi2/auto-admin

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

30 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Auto Admin

Fast and automatic administration maker.

Developped for sailsjs and use reactjs(ES6)

Installation

$ npm install auto-admin --save

Example

sails-isomorphic-react-admin-example

Usage

app.js

import React from 'react';
import Router, {HistoryLocation} from 'react-router';
import {Routes} from 'auto-admin';

Router.run(Routes(), HistoryLocation, Root => {
  React.render(<Root {...window.__ReactInitState__} />, document.body);
  delete window.__ReactInitState__;
});

Overwrite routes

routes.js

"use strict";

import React from 'react'
import {RouteHandler, Route} from 'react-router'
import {Home, List, Create, Update} from 'auto-admin'

module.exports = (
  <Route handler={RouteHandler}>
    <Route name="home" path="/admin" handler={Home} />
    <Route name="list" path="/admin/:identity" handler={List} />
    <Route name="create" path="/admin/:identity/new" handler={Create} />
    <Route name="update" path="/admin/:identity/:id" handler={Update} />
  </Route>
);

Personalize your form with newforms-bootstrap

form.js

"use strict";

import React from 'react'
import {Container, Row, Field} from 'newforms-bootstrap'

export const comment = (
  <Container autoColumns="md">
    <h1>Comments</h1>
    <hr />
    <p className="text-right">
      <button className="btn btn-default">Save</button>
    </p>
    <Row>
      <Field name="name" md="8"/>
      <Field name="post"/>
    </Row>
    <Row>
      <Field name="message"/>
    </Row>
  </Container>
);

app.js

import React from 'react';
import Router, {HistoryLocation} from 'react-router';
import {Routes} from 'auto-admin'
import * as modelsForm from './forms'

Router.run(Routes(), HistoryLocation, Root => {
  React.render(<Root {...window.__ReactInitState__} models={modelsForm} />, document.body);
  delete window.__ReactInitState__;
});

Change your Layout

layout.js

"use strict";

import React from 'react'

export default class {
  render() {
    return (
      <div>
        {this.props.children}
      </div>
    )
  }
}

app.js

import React from 'react';
import Router, {HistoryLocation} from 'react-router';
import {Routes} from 'auto-admin'
import Layout from './layout';

Router.run(Routes(), HistoryLocation, Root => {
  React.render(<Root {...window.__ReactInitState__} layout={Layout} />, document.body);
  delete window.__ReactInitState__;
});

License

MIT © 2015 contributors

About

Automatic Administrator for sails.js in react

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published