npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

khaos-admin

v2.0.20

Published

A frontend framework containing of tools for fast development of dashboard, panel, etc.

Downloads

2

Readme

Khaos-Admin

A frontend framework containing of tools for fast development of dashboard, panel, etc.

Tools We Provide

  • Fast Development: We handle data flow in components using props, you won't need to use state managers or even requesting data manually.
  • Authentication: Built-in token-based authentication.
  • Customization: You will have a full control over your components(although we use antd and recommend using it for faster development)

Installation

Build a react app with create-react-app or whatever then you can install Khaos Admin using:

npm install khaos-admin
#or
yarn add khaos-admin

Implementation

API Configuration

In order to make khaos work with your backend API, we expect you to follow certain rules. Add your API route to appConfig with root key. You can also set your app configurations such as logo, theme, etc., inside appConfig prop. The URL structure you need to implement consists of root URL which you should set inside the appConfig prop for each entity. entityName will be used to request data for that entity. For example if you have an API for your users you should use users for entityName prop of the resource and we will use YourRootURL/users to get the data for that compoenent.

Authentication

For Authentication you will need two parts.

  1. Login page : import Login form from khaos-admin and make your customized login page and you. Or you can create your custom login page and pass it as props to login, but you should import authenticate() from khaos-admin. For authentication you should pass access token and referesh token and expiration (optional) as parameter to authenticate() function.

  2. Providing authentication tokens : You need to implement a function returning access token and refresh token with this format.

{ access_token:your_access_token,refresh_token:your_refresh_token }

If you implement this successfully you will see access token and refresh token as a cookie in your browser. We will add token to header of all requests with this format: Bearer Your_access_token On unauthorized request we will request new access using the refresh request function that you provided.

import React from 'react';
import { Khaos, Resource } from 'khaos-admin';

const App: React.FC = () => {
  return (
    <Khaos
      login={<Login />}
      loginRequest={loginRequest}
      refreshRequest={renewAccessToken}
      appConfig={{ root: 'https://jsonplaceholder.typicode.com' }}
    ></Khaos>
  );
};

export default App;
Note:

If you want right to left body (rtl), you should follow tow steps:

1)

In your app code add:

import { ConfigProvider } from 'antd';

<ConfigProvider direction="rtl">
  <Khaos {...props}>
</ConfigProvider>`
2)

In your css code add:

body {
  direction: rtl;
}

Login Customization

We provided a default form for login page. as we told before, you can create custom login form or you can import <LoginForm> from khaos-admin and customize it via some props as following:

| Props Name | Description | | ------------- | ------------------------------------------------------------------ | | defaultRoute | navigate to custom route after submiting login (default = '/') | | cardClassName | custom classname for form in login page | | userNameProps | custom props for userName input | | passwordProps | custom props for password input | | buttonProps | custom props for submit button (useSimpleButtonProps from khaos) |

Custom Props

For userNameProps and passwordProps you can pass these props(optional): | Props Name | Description | | ----------- | ----------- | | name | optional props for name of fields | | rules | custom rules for validation | | placholder | custom placeholder for fields | | label | custom label for fields | | className | custom classname for styling fields |

passwordProps has another props more: | Props Name | Description | | ----------- | ----------- | | iconrender | to rendering custom icon for password field (e.g: visibility) |

Adding Features

To add features to your dashboard you will need to add their entity using resources. Each resource needs the following props: | Props Name | Description | | ----------- | ----------- | | label | to show on the sidebar | | sidebarLink | default link(will be used on sidebar to show your landing component for that feature) | | entityName |will be used for API requests | | components | an array of components which are features of your entity |

Components props are like this: | Props Name | Description | | ----------- | ----------- | | component | the feature for example shows list or edit or etc... | | path | your custom link for the feature | | button | button that is showed on navigator bar(uses SimpleButton from Khaos) |

The components you send to resource will have access to these methods and objects for handling data: | Props Name | Description | props | | ----------- | ----------- | ----------- | | list | list of data for example list of users | | get | function for requesting data | | selectedItem | selected item from list | item you selected in the list | remove | remove an item | | selectedId | selected id | | selectId | select an id | | update | update item | | create | create item | | navigate | navigate between features |

For example the example below is a resource that you can use to show a list of users.

import { Resource } from 'khaos-admin';

<Resource
  label="feature name"
  sidebarLink="list"
  entityName="users"
  components={[
    {
      component: UserList,
      path: 'list',
      button: { name: 'User List', type: 'info', className: 'mx-1 d-flex align-items-center' },
    },
  ]}
/>;
Note:

sidebarLink is the default feature for this entity. e.g: in most cases you will show your list of that entity. For this feature to work, you need to set same path for both sidebarLink and path prop for your listing component.

for list request we expect you to return list of data, for example users and the total results with the key totalResults. And the UserList component will be like this:

const UserList = ({ list }) => {
  console.log('here you have access to list of whatever entity you are in', list);
  return <div>List of users </div>;
};

Features Roadmap

  • [x] Authentication
  • [x] Routing
  • [ ] Translation
  • [ ] Full test Coverage