-
Notifications
You must be signed in to change notification settings - Fork 35
Installing the ISBX CMS
This package is intended to be used as a Node Module. You should install the package with the command:
npm ssh://https://github.com/ISBX/isbx-loopback-cms.git
You can include it in your package.json using
{
"isbx-loopback-cms":
"git+https://github.com/ISBX/isbx-loopback-cms.git"
}
To run the CMS in the context of your current Loopback App/API you can need to setup a boot script in your loopback /server/boot/
folder. From the root of your loopback project you can copy over the example boot script provided by the CMS.
cp node_modules/isbx-loopback-cms/boot-cms.example.js server/boot/boot-cms.js
The boot-cms.js
setups the CMS URL route and path to the config.json
needed to configure the CMS Navigation. See below for further instructions.
In order for the CMS to authenticate and pull user Role and RoleMapping permissions you will need to modify /server/model-config.json
and make sure to make Role and RoleMapping public by adding the following lines.
"RoleMapping": {
"dataSource": "db",
"public": true
},
"Role": {
"dataSource": "db",
"public": true
}
Make sure to set the dataSource appropriately. The above uses an in-memory table for Role and RoleMapping. What we recommend is to create the Role and RoleMapping tables in your database so you can persist the Role and RoleMapping data.
The last step before you can run the CMS the boot-cms.js references /CMS/config.json
, which is needed to setup your CMS navigation. The following config.json
will use the built-in Loopback User
Model for authentication. If no user record exists the system will create a default [email protected]
account with password password
and also create a SuperAdmin
role. To override and provide your own Model for authentication replace references to User/Users
below.
If you already have your own User
Model, you can follow the instructions for setting up roles in the CMS.
You can easily override built-in CMS files like CSS, HTML, and Javascript files via the private.src
property in the config.json
. This path maps over the CMS exposed public path so you can add static files like images, etc.
You can include a custom css URI path to provide your own CMS styling in the public.css
property.
If you'd like to include additional CSS and JavaScript files you can use the public.customModules
property. See the Custom Modules section for more details.
{
"private": {
"logging": {
"format": "dev",
"immediate": true
},
"api": {
"target": "http://localhost:3005/api"
},
"src": "/client/cms",
"aws": {
"accessKeyId": "",
"secretAccessKey": "",
"region": "Oregon",
"s3": {
"bucket": "",
"path": {}
}
}
},
"public": {
"address": "0.0.0.0",
"port": 3005,
"title": "ISBX CMS",
"css": "/css/custom.css",
"authModel": "Users",
"profileModel": "User",
"profileKey": "id",
"defaultNav": {
"route": "list",
"params": {
"model": "users"
}
},
"customModules": [],
"nav": [
{
"label": "Users",
"path": "users",
"icon": "fa-user",
"roles": ["SuperAdmin"],
"subnav": [
{
"label": "Add",
"route": "edit",
"roles": ["SuperAdmin"],
"options": {
"model": "User",
"key": "id"
}
},
{
"label": "All Users",
"route": "list",
"roles": ["SuperAdmin"],
"options": {
"model": "User",
"key": "id",
"showFilter": true,
"pageSize": 500,
"params": {
},
"columns": [
{
"field": "email",
"displayName": "E-mail"
},
{
"field": "username",
"displayName": "Username"
},
{
"field": "created",
"displayName": "Created",
"headerClass": "center",
"cellClass": "center",
"cellFilter": "date:'yyyy-MM-dd'"
}
]
}
},
{
"label": "Manage Roles",
"route": "list",
"roles": ["SuperAdmin"],
"options": {
"model": "Role",
"key": "id",
"params": {},
"enableRowSelection": false,
"pageSize": 100,
"columns": [
{
"field": "description",
"displayName": "Role"
},
{
"field": "id",
"displayName": "Manage Users",
"headerClass": "center",
"cellClass": "center",
"width": 160,
"cellTemplate": "<a href=\"{{ $state.href('dashboard.model.action.list', { model: section.path, action:'Manage User Roles' }) }}?roleId={{ row.entity.id }}&filterDescription={{ row.entity.description }}\">Manage Users</a>"
}
]
}
},
{
"label": "Manage User Roles",
"route": "list",
"roles": ["SuperAdmin"],
"hidden": true,
"options": {
"api": "Roles/{roleId}/RoleMappings",
"model": "RoleMapping",
"key": "id",
"params": {
"filter[include][User]": 1
},
"enableRowSelection": false,
"showFilter": true,
"pageSize": 500,
"columns": [
{
"field": "User.email",
"displayName": "E-mail",
"cellTemplate": "<a ui-sref=\"dashboard.model.action.edit({ model: section.path, action: 'All Users', id: row.entity.User.id })\">{{row.entity.User.email}}</a>"
},
{
"field": "User.username",
"displayName": "Username"
},
{
"field": "id",
"displayName": "Remove",
"sortable": false,
"headerClass": "center",
"cellClass": "center",
"width": 90,
"cellTemplate": "<button class=\"btn btn-default link delete\" ng-click=\"deleteRow(row)\"><i class=\"fa fa-times\"></i></button>"
}
]
}
}
],
"defaultSubNavIndex": 1
}
]
}
}
To contribute to the ISBX CMS Node Module you can clone the repo and then link it to your project:
git clone https://github.com/ISBX/isbx-loopback-cms.git [cms path]
cd [project path]
npm link [cms path]
for example:
git clone https://github.com/ISBX/isbx-loopback-cms.git /projects/nodejs/npm-isbx-loopback-cms
cd /projects/websites/my_cms
npm link /projects/nodejs/npm-isbx-loopback-cms
Now any changes made in the npm-isbx-loopback-cms
source folder will be applied to your my_cms
project.
When contributing to the ISBX CMS please create a feature branch and issue a pull request.