Swiftpack.co - Package - nodes-vapor/admin-panel

admin-panel

Login screen

Successful login

Manage users

Features

Confirm Modal

Admin Panel includes a generic confirmation modal for links, out of the box. Using HTML data attributes on <a>-tags the modal can be configured in different ways. Just add a data attribute to your link and you're all set.

Triggering the modal will append a HTML-element form to the DOM, containing title, text, confirm button and dismiss button.

By default confirm submits the form and dismiss will remove the HTML-element from the DOM

Basic usage

<a href="#" data-confirm="true">Open modal</a>

Data Attributes

|Attribute|Description|example| |---------|-----------|-------| |data-confirm|Initialize the modal|data-confirm="true"| |data-title|Sets the title of the modal|data-title="Please confirm"| |data-text|Sets the text of the modal|data-text="Are you sure you want to continue?"| |data-button|Sets bootstrap css selector for the confirm button|data-button="danger" [primary,secondary,success,danger,warning,info,light,dark]| |data-confirm-btn|Set the text label on the "confirm"-button|data-confirm-btn="Yes"| |data-dismiss-btn|Set the text label on the "dismiss"-button|data-confirm-btn="No"|

Override default behavior

// Override modal confirm action
modalConfirmation.actions.confirm = function(event) {
    alert("Confirmed");
}

// Overríde modal dismiss action
modalConfirmation.actions.dismiss = function(event) {
    alert("Dismissed");
}

Leaf tags

Admin panel comes with a variety of leaf tags for generating certain HTML/js elements

#adminPanel:avatarURL

Use user image or fallback to Adorable avatars

|Parameter|Type|Description| |---------|----|-----------| |email|String| user's email| |url|String|image url|

Example usage

<img src="#adminPanel:avatarURL(user.email, user.avatarURL)" alt="Profile picture" class="img-thumbnail" width="40">

#adminPanel:config

Convenience method to output configuration strings such as app or environment name or paths to certain templates

Supported input values and what they output

  • name: App name
  • baseURL: App base URL
  • sidebarMenuPath: Path to sidebar menu view template
  • dashboardPath: Path to dashboard view template
  • environment: Environment name

|Parameter|Type|Description| |---------|----|-----------| |configName|String| Config variable name|

Example usage

<!-- outputs app name ->
#adminPanel:config("name")

#adminPanel:user

Outputs a field on the current user object as a string

|Parameter|Type|Description| |---------|----|-----------| |fieldName|String| User field name|

Example usage

<!-- outputs user's name ->
#adminPanel:user("name")

#adminPanel:user:requireRole

Make sure user has required role to output element. If not throws an error.

|Parameter|Type|Description| |---------|----|-----------| |roleName|String| User role|

Example usage

#adminPanel:user:requireRole("superAdmin") {
    <div>I show if user is super admin</div>
}

#adminPanel:user:hasRequiredRole

Check if user has a required role

|Parameter|Type|Description| |---------|----|-----------| |roleName|String| User role|

Example usage

#if(adminPanel:user:hasRequiredRole("superAdmin")) {
    // Do something
} else {
    // Do something else
}

#adminPanel:sidebar:heading

Renders a header, styled in a certain way, for the navigation sidebar.

Example usage

#adminPanel:sidebar:heading() { Super Admin }

#adminPanel:sidebar:menuItem

Renders a sidebar menu item, styled in a certain way, for the navigation sidebar.

|Parameter|Type|Description| |---------|----|-----------| |url|String| Menu item link reference| |icon|String| Feather icon for menu item| |activeURLPatterns|String| URL pattern to determine active state|

Example usage

#adminPanel:sidebar:menuItem("/admin/dashboard", "home", "/admin/dashboard*") { Home }

Github

link
Stars: 64

Used By

Total: 0

Releases

2.0.0 - rc 7 - 2019-09-23 11:56:08

Fixed:

  • emails weren't checked for uniqueness when new users were created.

- 2019-09-16 20:19:10

Version 2.0.0 RC 6 - 2019-09-06 11:04:38

Fixed

  • Removed favicon reference to missing asset

Added

  • Added image examples of admin panel layout to readme docs
  • Added readme docs for leaf tags defined in package
  • Added leaf tag numberformat
  • Added user drop down menu

Changed

  • Jazzy docs updated

Version 2.0.0 RC 5 - 2019-05-07 11:19:47

Fixed

  • Fixed Swift 5 compiler warnings related to redundant access modifiers

Version 2.0.0 RC4 - 2019-04-16 13:49:41

Added

  • AdminPanelUserRole now conform to CaseIterable

Version 2.0.0 RC 3 - 2019-04-09 07:30:08

Fixed

  • Initializers for AdminPanelConfig are now public as expected.

Version 2.0.0 RC 2 - 2019-04-02 12:13:11

Changed

  • handleValidationError is now public (thanks @MrMage)

Version 2.0.0 RC 1 - 2019-03-06 15:35:00

Changed:

  • updated to latest packages
  • AdminPanelProvider now accepts a config factory to support async middleware and signers
  • allow specifying reset endpoints
  • registers bootstrap tags automatically

Fixed:

  • hash password when seeding

Version 2.0.0 Beta 15 - 2018-12-11 15:37:31

Changed

  • Correctly specified 4.1 as the minimum required Swift version.

Removed

  • This package no longer uses the MutableLeafTagConfig. Please use useAdminPanelLeafTags() for registering this package's Leaf tags (see readme for more info).

Version 2.0.0 Beta 14 - 2018-11-30 12:20:14

Changed

  • Aligned with Reset updates.
  • Simplified the config in regards to the signer used for Reset.

Version 2.0.0 Beta 13 - 2018-11-12 11:29:33

Added

  • WYSIWYG Leaf tag (#79)
  • Strong password validator (#51)

Changed

  • Bumped to Swift 4.2
  • Aligns with community guidelines (how to register routes)

Fixed

  • Added Leaf tag Paginator (#106)
  • Signer for reset password flow can now be configured (#94)
  • Respects SwiftLint rules

Version 2.0.0 Beta 12 - 2018-09-05 12:15:09

Fixed

  • Wrong references to Reset config (baseUrl vs baseURL)

Version 2.0.0 Beta 11 - 2018-09-04 10:36:52

Changed

  • Environment label is now vertically aligned.
  • Updated names including the word URL to consistently capitalize the word.
  • Paths for the different endpoints can now be overwritten.

⚠️ This is a breaking change.

Version 2.0.0 Beta 10 - 2018-09-03 10:27:38

Added

  • ConfirmModal now has two new data attributes for setting custom text labels on the confirm- and dismiss-button
  • ConfirmModal now has options for overriding default behaviour of confirm- and dismiss-button
  • Documentation on how to integrate the ConfirmModal

Version 2.0.0 Beta 9 - 2018-08-29 17:48:09

Added

  • Leaf tag for WYSIWYG editor which uses Quill.

Changed

  • Renamed leaf tag roleAllows to hasRequiredRole
  • All leaf tags are now named using camelCase - please remember to go through your project's leaf file.

⚠️ This is a breaking release.

Version 2.0.0 Beta 8 - 2018-08-27 11:26:43

Added

  • adminpanel:user:roleAllows("rolename") leaf tag for boolean evaluation of user's role

Changed

  • adminpanel:user now operates on generic AdminPanelUserType instead of AdminPanelUser given by default.

⚠️This has breaking changes - Requires the user to conform to TemplateDataRepresentable

Version 2.0.0 Beta 7 - 2018-08-27 08:11:48

Fixes

  • Aligns return type in AdminPanelUser controller methods

Added

  • Environment label on non-prod envs

⚠️This has breaking changes - Remember to pass env to config

Version 2.0.0 Beta 6 - 2018-08-24 11:22:48

Added

  • requireRole Leaf tag

Usage

#adminpanel:user:requireRole("admin") {
    Role requirements met
}

Changed

  • role is now optional on the AdminPanelUser

Removed

  • .unknown AdminPanelRoleType

⚠️This has breaking changes - Remember to update your admin panel user in the database for nullable role field

Version 2.0.0 Beta 5 - 2018-08-23 18:17:50

Changed

  • Temporary fix for Leaf issue (vapor/template-kit#17) removed as it's not needed anymore.

Removed

  • Removed dashboardPath from AdminPanelConfig. Use AdminPanelViews instead to set this path.

⚠️ This is a breaking change.

Version 2.0.0 Beta 4 - 2018-08-23 13:47:32

Changed

  • Reset is now pinned against a version instead of pointing to a branch.

Version 2.0.0 Beta 3 - 2018-08-23 11:18:13

Fixed

  • Sidebar menu path are now read from a generic SidebarMenuPathGenerator type

Version 2.0.0 Beta 2 - 2018-08-20 12:04:51

Changed

  • Sidebar menu now supports being dynamic based on the role of the user.

This is a breaking change.

Version 2.0.0 Beta 1 (Vapor 3) - 2018-08-20 12:03:06

Changed

  • Rewritten to support Vapor 3 🎉

Please note that this is still work in progress and things might break in future releases.

Version 1.0.2 - 2017-09-13 14:52:47

  • Remove the need for adding BackendUserPasswordResetToken to Node.fuzzy

Version 1.0.1 - 2017-08-17 08:50:35

Added

  • Convenience to init the provider using SSO and a Config

Vapor 2 release - 2017-08-03 14:30:29

1.0.0 Beta IX - 2017-07-18 11:37:26

1.0.0 Beta XIV - 2017-07-18 11:07:31

1.0.0 Beta XII - 2017-07-18 10:00:20

1.0.0 Beta X - 2017-07-07 10:27:04