Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

icerockdev-admin-toolkit

Package Overview
Dependencies
Maintainers
1
Versions
151
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

icerockdev-admin-toolkit

This is a tool for building admin panels, that can be installed as npm dependency. [DEMO](https://icerockdev.github.io/admin-toolkit/ "DEMO")

  • 0.1.1
  • npm
  • Socket score

Version published
Weekly downloads
15
increased by150%
Maintainers
1
Weekly downloads
 
Created
Source

Admin Toolkit

This is a tool for building admin panels, that can be installed as npm dependency. DEMO

Installation

yarn add icerockdev/admin-toolkit#master or npm i -S icerockdev/admin-toolkit#master

Usage

import React from "react";
import {  Application } from "admin-toolkit";
import config from "./config";

export const App = () => (
  <div>
    <Application config={config} />
  </div>
);

Config

The app is built on extendable classes. You can write your own autherntification by extending AuthProvider class. Creating complex pages should be made by extending Page class.

var config = new Config({
  logo: "",
  auth: new AuthProvider(authProviderOptions),
  pages: [
    new Page(pageOptions),
    new Entity(entityOptions)
  ]
});

AuthProvider

AuthProvider is extendable class. You can override its metods for your needs. The app decides user authentication status by checking its token field, but you can override this behaviour in your own class.

Basic options are:

new AuthProvider({
    authRequestFn: (email, password) => Promise.resolve({
        user: {
          email: 'user@example.com',
          username: 'username',
          token: "SAMPLE_TOKEN",
          role: "user"
        },
        error: ""
      }),
  })

Page

Page class is for rendering pages inside the app. You can extend it to create more complex pages, like this done in Entity class.

Base config for Page is:

    new Page({
      title: "Sample page",
      menu: {
        enabled: true,
        url: "/test",
        label: "Sample page"
      }
    });

Entity

Entity is used to display list of some database entities, view their details and edit them. The Entity class extends Page one.

Basic options for Entity:

new Entity({
      title: "Sample entity",
      editable: true,
      viewable: true,
      api: {
        list: { url: "/list", method: "get" },
        update: { url: "/update", method: "patch" },
        create: { url: "/create", method: "post" }
      },
      menu: {
        enabled: true,
        label: "Sample entity",
        url: "/entity"
      },
      filters: {
        current: "",
        value: "",
        fields: [
          {
            name: "type",
            label: "Тип",
            type: ENTITY_FILTER_TYPES.SELECT,
            variants: [
              { value: "news", label: "Новость" },
              { value: "article", label: "Статья" }
            ]
          }
        ]
      },
      fields: [
        {
          name: "type",
          label: "Тип",
          sortable: true,
          type: "string"
        },
      ],
      fetchItemsFn: () => new Promise((resolve) => {
          setTimeout(resolve, 500, {
            data: {
              list: [
                {
                  id: 1,
                  type: "text"
                }
              ],
              totalItems: 1
            }
          });
        });
      },
      updateItemsFn: ({ data }) => (
	  	Promise.resolve({ error: "", data });
      ),
      createItemsFn: ({ data }) => (
        Promise.resolve({ error: "", data: props.data })
      )
    });

License

Copyright 2020 IceRock MAG Inc.

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

   http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.

FAQs

Package last updated on 01 Apr 2020

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc