Giter Club home page Giter Club logo

rest-admin's Introduction

REST-ADMIN 中文文档

An Powerful Admin Dashboard based on Boostrap-Vue.

Demo: http://rest-admin.genyii.com/ admin admin

Please support me on https://afdian.net/@johnny if you like it. 如果觉得有用请在爱发电上赞助我:https://afdian.net/@johnny

Features

  • Bootswatch Themes
  • Powerful Data Table with sorting, pagination, searching, display images...
  • Powerful Edit Form Builder can display/edit any value of text, image, boolean...
  • Fully support for Resource-based CRUD option.
  • English based fully i18n support.
  • Highly Configurable site info. Such as: site name, logo, Menu and footer...
  • Production ready. It has been used in two projects in our company.

Screenshots

- -
Login Page Home page
Data Table for posts Data Form for post
Wechat Group (Search Wechat johnny77577 to join in) Free Videos

Quick Start

git clone [email protected]:wxs77577/rest-admin.git
cd rest-admin
code . # open with vscode [optional]
npm i # or cnpm i

# start with local test api server
npm run test-api # start test api server
npm run serve # start rest admin client

The default username and password of test-api is admin and admin

Build

API_URI=http://localhost:5555/admin/api/ npm run build

Then just copy /dist/admin folder to the anywhere.

There is a built-in restful api based on express for test.

Fields Definition

Used in listing tables and editing forms Default PRIMARY_KEY field is _id, feel free to change it in /src/config.json

Example:

{
  "_id": { "label": "ID" },
  "title": { "label": "Title" },
  "type": {
    "label": "Type",
    "type": "select",
    "options": [
      { "text": "Vue", "value": "vue" },
      { "text": "React", "value": "react" },
      { "text": "Angular", "value": "angular" }
    ]
  },
  "body": { "type": "html", "group": "Detail" },
  "steps": {
    "type": "array",
    "group": "Steps",
    "fields": {
      "name": { "label": "Name" },
      "date": { "label": "date" }
    }
  },

  "_actions": {
    // define table view, it's optional.
    "buttons": {
      // define buttons as `false` to hide in actions colum
      "delete": false,
      "edit": false
    },
    "toolbar": {
      // define actions in top toolbar table view
      "extra": [
        // add extra buttons
        { "to": "/form?uri=vouchers/generate", "label": "Generate Vouchers" } //properties of `<b-button>`
      ]
    }
  }
}

Field properties

  • label Title for display
  • cols column width, total is 12.
  • input_cols column width of input control.
  • group title for tabs in create/edit forms
  • type Field type, accepted values and additional properties for some fields.
    • select raw html <select> tag from b-select of bootstrap-vue
      • options e.g. [{ "text": "Label", "value": "1" }]
    • select2 vue-select, like select2 in jQuery
      • options e.g. [{ "text": "Label", "value": "1" }]
    • tree vue-treeselect
      • options use text and value instead label and id e.g. [{ "text": "Label", "value": "1", "children": [ { "text": "Item1", "value": "2" } ] }]
    • date vue2-datepicker supports date range
    • switch A iOS-liked switch component
    • html An WYSIWYG html editor from vue-html5-editor
    • array Array values
      • fields child fields defination
      • is_table display as a table ?
    • radiolist
      • options e.g. [{ "text": "Label", "value": "1" }]
    • checkboxlist
      • options e.g. [{ "text": "Label", "value": "1" }]
    • checkbox
    • file File uploader
      • limit define file limit options of size in byets, e.g. { size: 1000000 }
    • image Image file uploader with preview.
      • limit define file limit options of width height and size in byets, e.g. { "width": 320, "height": 180, size: 1000000 }
    • audio like image
      • limit define file limit options of size in byets, e.g. { size: 1000000 }
    • video like image
      • limit define file limit options of size in byets, e.g. { size: 1000000 }
    • textarea
    • number
    • text
  • required
  • Any other properties accepted in https://bootstrap-vue.js.org/docs/components/form-input, please notice that every kind of field component has it's own properties.

APIs

Tips: check /api/index.js :p

Example Base Api Url: http://localhost:8088/admin/api

Get config data of site

  • Returns
    {
      "name": "Site Name",
      "logo": "http://.../logo.png",
      "locale": "en-US", //or zh-CN
      "locale_switcher": false, //hide locale switcher
      "menu": [
        {
          "name": "Home",
          "url": "/",
          "icon": "fa fa-home"
          // for home page
        },
        {
          "name": "Content",
          "title": true
          // display as a delimiter
        },
        {
          "name": "Posts",
          "url": "/rest/posts",
          "icon": "fa fa-list"
          // url format of resource list: /rest/:resourceName
        },
        {
          "name": "Config",
          "url": "/form?uri=site/settings",
          "icon": "fa fa-cogs"
          // a custom form.
        },
        {
          "name": "Logout",
          "url": "/login",
          "icon": "fa fa-lock"
          // for logout
        }
      ]
    }

POST /login

For admin user login

  • POST DATA
    {
      "username": "admin",
      "password": "admin"
    }
  • Returns
    {
      "user": {
        "username": "admin",
        ...
      },
      "token": "1o2u3h4oi2u3h4jkashdflsda"
    }
    or with validation errors

    must response 422 http status.

    {
      "name": "HttpException",
      "message": [{ "field": "password", "message": "Incorrect password." }]
    }

GET /:resource

Fetch all records of a resource. :resource means any resource name. e.g. /users, /posts...

  • Returns IMPORTANT
    {
      "total": 80,
      "perPage": 10,
      "page": 1,
      "data": [
        {...},
        {...},
        {...},
      ]
    }

GET /:resource/grid

Fetch grid view config of a resource. :resource means any resource name. e.g. /users/grid, /posts/grid...

  • Returns IMPORTANT
    {
      "searchModel": {},
      "searchFields": {
        render a searching form
        ...see Fields Definition...
      },
      "fields": {
        render a table view
        ...see Fields Definition...
      }
    }

GET /:resource/form

Fetch editing form config of a resource. :resource means any resource name. e.g. /users/form, /posts/form...

  • Returns IMPORTANT
    {
      "model": {},
      "fields": {
        render a editing form
        ...see Fields Definition...
      }
    }

POST /:resource

create a resource

  • POST DATA
    {
      "_id": "12341234",
      "title": "The New Title",
      ...
    }
  • Returns
    {
      "_id": "12341234",
      "title": "The New Title",
      ...
    }

PUT /:resource/:id

update a resource

  • POST DATA (Request Payload)
    {
      "_id": "12341234",
      "title": "The New Title",
      ...
    }
  • Returns
    {
      "_id": "12341234",
      "title": "The New Title",
      ...
    }

DELETE /:resource/:id

delete a resource

  • Returns
    {
      "success": true
    }

DELETE /:resource

delete all

  • Returns
    {
      "success": true
    }

Custom Form ?

To render a custom form, you need to define a menu item in /site api, or add an extra button of toolbar in /:resource/grid.

There are two apis for a custom form:

  1. Get form definition
  • GET /site/settings
  • Returns
    {
      "title": "Form Title",
      "fields": {
        ...see Fields Definition...
      }
    }
    
  1. Handle submission
  • POST /site/settings
  • Returns
    {
      "success": true,
      "message": "Well done!", //[optional] will show after form submited.
      "redirect": "/" //[optional] auto redirect after form submited, default is back to the last page.
    }

i18n

Check vu-i18n for detailed documentation.

REST-ADMIN gives built-in support for en-US and zh-CN, you can change translation files in /src/i18n/*.json.

Thanks to

rest-admin's People

Contributors

alant avatar ecaramba avatar lucy1990 avatar maohuangyan avatar wxs77577 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

rest-admin's Issues

radiolist

In FormField.vue file, in the secction of radiolist types, i thing there is necesary this: :options="options"

Proper use of addon tag in DataTable.vue

May I ask some help how can use the addon tag in DataTable?
Following example is working for me:

                 "_actions": { 
                       "toolbar": {
                          "create": False,
                          "delete_all": False
                       },
                       "buttons": { 
                          "show": False,
                           "delete": False,
                      },
                      "addon": {
	                      "button": {
	                          "label": "testlabel",
	                          "href": "/ddd/",
	                       },
                      }
                   },

How can I get to append the selected line _id's to the url? Is there any way for it?

Incorrect git clone command in README

git clone [email protected]:wxs77577/rest-admin.git command not working as expected, error is throwed:
Permission denied (publickey). fatal: Could not read from remote repository.

But this is working ok:
git clone https://github.com/wxs77577/rest-admin.git

Please update README.

ID naming strategy

Dear @wxs77577 ,

I´m struggling to deal with my ID naming strategy within rest-admin.

Your strategy waiits for _id as table id, and my models are all with 'id' without underscore.
The underscore I adopt as FK like user: {id: 1, category_id: 1}, and for this is working.

What could I do instead of chaging all my models?

Thanks once again

Layout Feature from configs

Dear,

I´ve noticed a layout props expected at formbuilder.

Can you provide more info or example on its usage.

I would like to know its 'usage' level as well, if youcan provide please.

As far as I could get, it awaits a layout info from resource/form api response.

Blank Page

I ran the build command and copied the dist folder but now have a blank page. Could you go into more detail on how to set the API_URI? I have json-server running on port 3005 and would like to use that

https://geekhd.tk/sharex/zodj3.png

Build for production error: Unexpected token: name (code) [./node_modules/vue-snotify/vue-snotify.esm.js:104

Build for production with npm run-script build got error

`
ERROR in static/js/vendor.js from UglifyJs
Unexpected token: name (code) [./node_modules/vue-snotify/vue-snotify.esm.js:104,0][static/js/vendor.js:27544,12]

Build failed with errors.

npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! [email protected] build: node build/build.js
npm ERR! Exit status 1
`

I did try around this: artemsky/vue-snotify#14 but not work at all.

My environment:

  • nodejs v9.5.0
  • npm v5.10.0
  • Windows 10

Anyone face or any solution?

hello

is there is any update in this time

Flight Todo List

  1. translation
  2. better polling & snack bar for data loading
  3. airline logos
  4. airport dropdown
  5. payment
  6. filter and sort - $on
  7. styling...

Assigned to... me...

No default login credentials or ability to sign up

I may be overlooking something, but it doesn't appear that default login credentials have been supplied, nor does it look like a sign up has been implemented. Am I missing something or has this simply not been implemented yet?

npm run local cause error

1、npm run local,it cause error , but run dev success(change the config)

2、detail

package.js :  "local": "API_URI=http://localhost:8088/admin/api/ npm run dev",

dev.env.js.js : API_URI: `"${process.env.API_URI || 'http://192.168.50.57:5555/admin/api/'}"`

when npm run local, process.env.API_URI cannot get the value of API_URI

Table component

Dear Fellows,

I couldnt use the table component, it renders the table header, but with neighter action buttons (for add) nor data row.

Could you provide some working example?

Thanks

列表数据绑定报错

v-bind without argument expects an Object or Array value
CustomTable.vue页面报错,前端新手请教下,这个是什么问题?
img

Vuex-router-sync question

Dear friend,

What is the importance if the package vuex-router-sync? Is it really matter?

Im trying to run the solution at browser without webpack, and im finding some trouble with it. First because this package doesnt have a module that works woth browser only.

Just wondering what it does. Ive managed to run many things already but some mutations seems not to work without this package.

Buttons actions doesn’t happens , but i dont know for sure why

nodemon missing from package.json

Pretty self explanatory... nodemon is missing from the package.json so I needed to install it before being able to run the test api. Didn't feel this was enough to open a PR but I can if desired. Below line fixes the problem:

npm install nodemon --save

_actions addon tag vs Envelope Improve

Dear @wxs77577 ,

Just wondering, why using addons tags (underscored) at Fields description, instead of aggregating new patterns on the Envelop?

I think it would be a cleaner way to do like:
{
 data: [],
 fields: {
...
},
actions: {}
}

Or something like that, perhaps there is a standard or more widely use pattern?!

What do you think?

Thanks

Reordering in models

Hi

There's a sorting feature of listing tables, but it's only a view which does not affect models.
What I need is drag-n-drop or clickable ordering that would change some field inside data model (e.g. sort_order field), so that when I access data from my DB I could do simple ORDER BY sort_order DESC and be sure that it's the same ordering as I set it in rest-admin page.

Can you add it?

SSR - Nuxt.JS

Dear fellows,

Is it possible to change this project for rendering at server side?
How hard would that be?
Would it worth?

Is it done by using Nuxtjs?

Thanks

CustomTable Concepts

Dear @wxs77577 ,

Would you explain a little bit of CustomTable vs DataTable components?

Why their code seems to be very different, and what it enables against DataTable?

Thank you very much

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.