How to use admin-bro - 10 common examples

To help you get started, we’ve selected a few admin-bro examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github SoftwareBrothers / admin-bro-dev / example-typeorm / src / index.ts View on Github external
createConnection().then(async connection => {
  const app = express()
  const port = 3000
  

  const options: AdminBroOptions = {
    // databases: [connection],
    resources: [ Car, CarDealer ]
  }
  const adminBro = new AdminBro(options)
  const router = AdminBroExpress.buildRouter(adminBro)

  app.get('/', (req, res) => res.send('Hello World!'))
  app.use(adminBro.options.rootPath, router)

  app.listen(port, () => console.log(`Example app listening on port ${port}!`))

}).catch(error => console.log(error));
github SoftwareBrothers / admin-bro-dev / example-typeorm / src / index.ts View on Github external
import "reflect-metadata";
import {createConnection} from "typeorm";
import { Car } from "./entity/Car";
import { CarDealer } from "./entity/CarDealer";
import express from 'express'
import AdminBro, { AdminBroOptions } from 'admin-bro'
import * as AdminBroExpress from 'admin-bro-expressjs'
import { Database, Resource } from "admin-bro-typeorm";

import {validate} from 'class-validator'
Resource.validate = validate

AdminBro.registerAdapter({ Database, Resource })

createConnection().then(async connection => {
  const app = express()
  const port = 3000
  

  const options: AdminBroOptions = {
    // databases: [connection],
    resources: [ Car, CarDealer ]
  }
  const adminBro = new AdminBro(options)
  const router = AdminBroExpress.buildRouter(adminBro)

  app.get('/', (req, res) => res.send('Hello World!'))
  app.use(adminBro.options.rootPath, router)
github SoftwareBrothers / admin-bro-example-app / admin / index.js View on Github external
const AdminBro = require('admin-bro')
const AdminBroMongoose = require('admin-bro-mongoose')
const AdminBroSequelizejs = require('admin-bro-sequelizejs')
const sequelize = require('sequelize')
AdminBro.registerAdapter(AdminBroMongoose)
AdminBro.registerAdapter(AdminBroSequelizejs)

const SequelizeDb = require('../sequelize/models')

const menu = {
  mongoose: { name: 'Mongoose Resources', icon: 'icon-mongodb' },
  sequelize: { name: 'Sequelize Resources', icon: 'icon-postgres' },
  customized: { name: 'Customized Resources', icon: 'fas fa-marker' }
}

const user = require('./resources/user')
const page = require('./resources/page')
const blogPost = require('./resources/blog-post')
const article = require('./resources/article')
const complicated = require('./resources/complicated')
const comment = require('./resources/comment')
// const uploads = require('./resources/uploads')
github AztecProtocol / AZTEC / packages / admin-panel / app.js View on Github external
ids.forEach(networkId => {
        const networkConfig = getNetworkConfig(networkId);
        const sequelize = connection.getConnection(networkId);
        const db = models(sequelize);
        const options = getBroOptions(db, networkConfig);
        const {
            Users,
        } = db;

        AdminBro.registerAdapter(AdminBroSequelize)
        const rootPath = `/${networkConfig.networkName}`;
        const loginPath = `${rootPath}/admin`;
        const logoutPath = `${rootPath}/admin`;
        const adminBro = new AdminBro({
            ...options,
            databases: [db],
            rootPath,
            loginPath,
            logoutPath,
        });

        // Build and use a router which will handle all AdminBro routes
        const router = AdminBroExpressjs.buildAuthenticatedRouter(adminBro, {
            authenticate: async (email, password) => {
                const user = await Users.findOne({ where: {
                    email: {
github SoftwareBrothers / admin-bro-example-app / admin / resources / user.js View on Github external
actions: {
    detailedStats: {
      actionType: 'resource',
      icon: 'fas fa-signal',
      label: 'Resource statistics',
      component: AdminBro.require('../components/detailed-stats'),
      handler: async (request, response, data) => {
        return {true: 'ueas'}
      },
    },
    dontTouchThis: {
      actionType: 'record',
      label: 'don\'t touch this!!!',
      icon: 'fas fa-exclamation',
      guard: 'You can setup guards before an action - just in case.',
      component: AdminBro.require('../components/dont-touch-this-action'),
      handler: async (request, response, data) => {
        return {
          record: data.record.toJSON()
        }
      }
    }
  }
}

// 'user-ninja'
github SoftwareBrothers / admin-bro-example-app / admin / index.js View on Github external
branding: {
    companyName: 'Some demo',
  },
  pages: {
    customPage: {
      label: "Custom page",
      handler: async (request, response, context) => {
        return {
          text: 'I am fetched from the backend',
        }
      },
      component: AdminBro.bundle('./components/some-stats'),
    },
    anotherPage: {
      label: "TypeScript page",
      component: AdminBro.bundle('./components/test-component'),
    },
  },
  dashboard: {
    handler: async (request, response, data) => {
      const categories = await CategoryModel.find({}).limit(5)
      return {
        usersCount: await UserModel.countDocuments(),
        pagesCount: await PageModel.countDocuments(),
        categories: await Promise.all(categories.map(async c => {
          const comments = await CommentModel.countDocuments({ category: c._id })
          return {
            title: c.title,
            comments,
            _id: c._id,
          }
        }))
github SoftwareBrothers / admin-bro-example-app / admin / index.js View on Github external
],
  version: {
    admin: true,
  },
  branding: {
    companyName: 'Some demo',
  },
  pages: {
    customPage: {
      label: "Custom page",
      handler: async (request, response, context) => {
        return {
          text: 'I am fetched from the backend',
        }
      },
      component: AdminBro.bundle('./components/some-stats'),
    },
    anotherPage: {
      label: "TypeScript page",
      component: AdminBro.bundle('./components/test-component'),
    },
  },
  dashboard: {
    handler: async (request, response, data) => {
      const categories = await CategoryModel.find({}).limit(5)
      return {
        usersCount: await UserModel.countDocuments(),
        pagesCount: await PageModel.countDocuments(),
        categories: await Promise.all(categories.map(async c => {
          const comments = await CommentModel.countDocuments({ category: c._id })
          return {
            title: c.title,
github SoftwareBrothers / admin-bro-example-app / admin / index.js View on Github external
handler: async (request, response, data) => {
      const categories = await CategoryModel.find({}).limit(5)
      return {
        usersCount: await UserModel.countDocuments(),
        pagesCount: await PageModel.countDocuments(),
        categories: await Promise.all(categories.map(async c => {
          const comments = await CommentModel.countDocuments({ category: c._id })
          return {
            title: c.title,
            comments,
            _id: c._id,
          }
        }))
      }
    },
    component: AdminBro.bundle('./components/dashboard'),
  },
}
github SoftwareBrothers / admin-bro-example-app / admin / resources / article.js View on Github external
const AdminBro = require('admin-bro')
const { sort, timestamps } = require('./sort')

module.exports = {
  name: 'Article (customize field)',
  sort,
  properties: {
    ...timestamps,
    _id: { isVisible: false },
    content: {
      type: 'richtext',
    },
    published: {
      label: 'Published (custom render)',
      components: {
        list: AdminBro.bundle('../components/article-in-list')
      }
    },
  }
}
github AztecProtocol / AZTEC / packages / admin-panel / helpers / getBroOptions.js View on Github external
},
                        edit: { isAccessible: isAdmin },
                        delete: { isAccessible: isAdmin },
                    },
                },
            },
        ],
        branding: {
            logo: '/static/images/logo.svg',
            companyName: 'AZTEC',
            softwareBrothers: false,
        },
        dashboard: {
            handler: async () => {
            },
            component: AdminBro.bundle('../components/dashboard'),
        },
    };
};