This project is an open-source admin panel that you can use for your projects easily. Everything has been prepared for you, so you just define models (JSON files) for each entity and everything will be ready out of the box.
Find the running demo here:
http://demo.onmiz.net
Username : admin
Password : 123
- Multilingual
- Multi-Direction (LTR / RTL)
- Multi-Calendar support (Gregorian / Jalali)
After cloning, create a .env
file from the .env.sample
and fill it by appropriate values, then run
npm install
and
npm start
That's it!
A model is a JSON file in src/models directory and consists of these parts:
{base, list, item}
base
provides basic information and fields and types of the model.list
provides fields and operations to show on the list page of that model.item
provides fields of the model to show on the add or edit page.
let's dive into the features.
In the "base.model" you define fields and can provide the type of each field that can be:
- Without type: provides a simple value on list page and an input box on item page
image
: shows the image thumbnail on the list page that you can click on to see the full size and provide an image cropper on the item page.images
: like the image field but shows and accepts more than one imageselect
: shows the corresponding value on the list page and a drop-down list on the item pagedate
: converts the value to the specified locale date system in the list page and provides a date picker on the item pagetime
: shows the time part of the valuetimeago
: shows the relative time from nowformatted_number
: formats the number value by grouping every 3 digits by commacheckbox
: show a checkmark if the value is true on the list page and a checkbox on the item pagepassword
: provides a password field on the item page
These types can be used in the "list.fields" array:
multiple
: you can show more than one field in a cell by this typenested
: show the value of a multilevel JSON (eg: user.name)function
: you can write a custom function and pass some values to show anything you want in the cellstatic
: a static valuesocial
: get the username and show the icon and link to that social account
These types can be used in the "item.fields" array:
textarea
: provides a textarea instead of a text inputhidden
: provides a hidden inputmap
: provides a Google map to select a positionpicker
: provides a button to pick an entity from the list
You can set some attributes other than the type for a field.
max_length
: crops the long texts on the list pagestyle
: write custom extra style for the fieldrows
: rows for the textarea fieldwidth
&height
: attributes for the image fields
You can provide a search by different fields on your list page. To do so you may just add search to the list part of the model.
Simple usage of a search field is {name: "title"}
: search by title (wildcard)
A search field may have search_type
with the following values:
exact
: search the exact phraseregex
: search values that contain the phrase, you can addregex_type: "start"
to search for the values starting by the phrasegte
: search for greater or equal valueslte
: search for lower or equal values
A search field may also have field_type
with the following values:
between
: search for values between two phrasesbetween_dates
: search for values between two datesselect
: search by drop-down listselect_search
: search by autocompleting drop-down listcheckbox
: search by true or false checkboxpicker
: search by value picked from an entity picker
Some entities should be confirmed or rejected on the list page. You can specify these fields in the base part of the model:
confirm_field
: specifies the name of confirming field that should be true or falseconfirm_extra_fields
: fields that should be changed to true or false beside the confirm fieldconfirm_other_fields
: fields that should pass to the API with their value
After specifying confirm field, you should add confirm
to the operations of the list:
operations: ["add", "edit", "remove", "confirm"]
You can add an Export button and export current showing data to an Excel file by adding export_fields
to the list part. It's an array of fields like list.fields that specifies fields to export.
You can add custom operation buttons by custom_operations
array in list part. Each custom operation has the following properties:
custom_operations: {
className: 'primary', // primary / default / danger / info / warning
caption: 'Custom' // simple text or icon ({icon: "MailIcon"})
click: {
func: props.function.TestFunc,
params: ['id', 'title']
}
}
Each entity can be used as a picker. For example, you can make a User Picker, to do so you may just add a picker
field to the base part of the users model.
It consists of these fields:
params
: An array of fields to retrievecaption
: caption of picker after picking one rowfields
: An array of fields to show in the picker modal
Take a look at the src/models directory and you can find usage of these features in action.
Alireza Nasseh