Admin Panel makes it easy to setup and maintain admin features for your Vapor project. Here's a list of some of the top feautures that comes out of the box with this package:
- UI Components: Admin Panel is built using AdminLTE, a highly battle-tested and maintained Control Panel Template. This means that you'll have access to features from AdminLTE through Leaf tags.
- User System: This package come with a (admin panel) user system with roles built-in. The package also handles welcome emails and reset-password flows.
- SSO Support: Built-in support for adding your own custom SSO provider.
- Activities: Need to broadcast certain updates to the admin panel users? No problem, Admin Panel gives you some convenient functionality to manage an activity log.
Update your Package.swift
file:
.Package(url: "https://github.com/nodes-vapor/admin-panel-provider.git", majorVersion: 0, minor: 3)
Next time you run e.g. vapor update
Admin Panel will be installed.
Move the Resources
and Public
folders from this repo into your project. Unfortunately there's no convenient to this at the moment, but one option is to download this repo as a zip and then move the folders into the root of your project. Remember to check that you're not overwriting any files in your project.
In your Config+Setup.swift
(or wherever you setup your providers), make sure to add the Admin Panel provider:
import AdminPanelProvider
// ...
private func setupProviders() throws {
// ...
try addProvider(AdminPanelProvider.Provider.self)
}
This package relies heavily on the Leaf view renderer. For Admin Panel to work, please make sure that you have added the LeafProvider
:
import LeafProvider
// ...
private func setupProviders() throws {
// ...
try addProvider(LeafProvider.Provider.self)
}
After adding the provider, please make sure that your project is using Leaf as the view renderer. To do that, please ensure that the view
key is set correctly in droplet.json
:
"//": "Choose which view renderer to use",
"//": "leaf: Vapor's Leaf renderer",
"view": "leaf"
If you haven't added a SSO provider, the next thing you need to do is to seed a user in order to be able to login into your new admin panel. To do this, first add the seeder command to your commands
array in your droplet.json
:
"//": "Choose which commands this application can run",
"//": "prepare: Supplied by the Fluent provider. Prepares the database (configure in fluent.json)",
"commands": [
"prepare",
"admin-panel:seeder"
],
Next run the seeder by doing:
vapor build; vapor run admin-panel:seeder
The user that will be created using the seeder will have the following credentials:
- Email: admin@admin.com
- Password: admin
It's highly recommended that you add the CORS middleware to your project.
Admin Panel can be configured by (adding or) modifying the adminpanel.json
config file. Below is a breakdown of the available keys.
Key | Example value | Required | Description |
---|---|---|---|
name |
My Tech Blog |
No | This will be the title inside of the admin panel. |
baseUrl |
http://mytechblog.com |
No | This will be used to generate urls for the admin panel (e.g. when resetting a password). |
skin |
green-light |
No | The skin to use for the admin panel. The options will correspond to the available skins supported by AdminLTE. Please omit the skin- prefix when specifying the skin. |
To support sending password reset emails, configure Mailgun using mailgun.json
. In addition to the values for key
and domain
, AdminPanelProvider requires a value for the key fromAddress
and fromName
which will be used as the sender for password reset emails.
Single sign-on can be a convenient way to offer users of your project to login into your admin panel.
This package is developed and maintained by the Vapor team at Nodes. The package owner for this project is Steffen.
This package is open-sourced software licensed under the MIT license