The OpsPortal is a Single Page Application Widget that is served up by a Sails server. So in order to develop an OpsPortal Tool, we'll need to
- setup Sails,
- install our OpsPortal plugin
- create a web page to hold the widget
$ cd your/development/directory
$ appdev install sails
# you will be asked numerous configuration questions.
# In many cases you can simply [enter] to accept the default
# options:
# mysql : setup according to typical MAMP settings
# SSL : no
# auth : localNote: you did know you can use the --develop parameter to skip all these step, right? Go here and reclaim your sanity.
$ cd sails
$ npm install --save appdevdesigns/appdev-opsportalNote: if you would like to install the #develop version you can do:
$ npm install --save appdevdesigns/appdev-opsportal#developSince you're a developer, it is probably a good idea to do that.
In order to see the OpsPortal with some additional Tools installed, you can do:
$ npm install --save appdevdesigns/opstool-hrisAdminObjects#develop
$ npm install --save appdevdesigns/opstool-hrisUserProfile#developIn a development environment, you will want to allow SailsJS to modify the DB tables based upon the changes you make in your models. So set the config/models.js settings to:
$ vi config/models.js
# change migrate:'safe' to migrate:'alter'So far so good, now let's boot up sails to make sure everything works.
Note: if you are in development mode, this will allow sails to create all the DB tables
$ sails liftYou should see a response like:
info: Starting app...
info:
info:
info: Sails <|
info: v0.12.3 |\
info: /|.\
info: / || \
info: ,' |' \
info: .-'.-==|/_--'
info: `--'-------'
info: __---___--___---___--___---___--___
info: ____---___--___---___--___---___--___-__
info:
info: Server lifted in `/path/to/your/dir/sails`
info: To see your app, visit http://localhost:1337
info: To shut down Sails, press <CTRL> + C at any time.
debug: --------------------------------------------------------
debug: :: Fri Feb 13 2015 17:24:55 GMT+0700 (ICT)
debug: Environment : development
debug: Port : 1337
debug: --------------------------------------------------------If you see this display, then everything is going great so far. Now press [control]-[c] to exit.
Now run our permission installer:
$ cd node_modules/appdev-opsportal/setup/install/
$ node install.js
# Answer questions about which admin account to use. (defaults are usually fine)
# Be sure to specify that you are setting up a dev install
$ cd ../../../..
# return to the sails directoryThe default OpsPortal config setup includes many of our existing OpsTools. You will need to edit the config/opsportal.js to remove those.
$ vi config/opsportal.js
# comment out the uninstalled OpsToolsFor this tutorial the OpsPortal config should look like:
module.exports.opsportal = {
areas: [
{
// Define the Administration Area
icon:'fa-cogs',
key:'PortalAdmin',
label:'opp.areaAdministration',
context:'opsportal',
tools:[{
// Roles and Permissions
controller:'RBAC',
label:'opp.toolPermissions',
context:'opsportal',
isDefault: true,
permissions:[
'adcore.admin',
'adcore.developer'
]
}
// User management Interface here...
]
},
{
// User Profile Tool
icon:'fa-user',
key:'profile',
label:'opp.areaProfile',
context:'opsportal',
isDefault:false,
tools:[{
// Hris User Profile Tool
controller:'HrisUserProfile',
label:'opp.toolProfile',
context:'opsportal',
isDefault: true,
permissions:[
'hris.profile',
'adcore.developer'
]
},
{
// Hris Admin Objects
controller:'HrisAdminObjects',
label:'opp.toolObjectBuilder',
context:'opsportal',
isDefault: false,
permissions:[
'hrisadmin.objects',
'adcore.developer'
]
}
]
}
]
};
Now the OpsPortal is a javascript widget that sits on a web page. So we need to create a default web page to place our OpsPortal widget on:
$ appdev page opsportalThis default page has created a views/page/opsportal.ejs template and will be available to Sails with the url: page/opsportal
We need to edit this template to show our OpsPortal widget:
$ vi views/page/opsportal.ejsRemove the final:
<script type='text/javascript' src='../steal/steal.js?pages/opsportal/router.js' ></script>and replace with:
<div id='portal'></div>
<script type='text/javascript' src='../steal/steal<%- sails.config.environment == 'development'? '': '.production' %>.js?OpsPortal'></script>Finally, we need to make sure that people attempting to load this page are authenticated:
$ vi config/policies.jsAdd this to the policy definition:
PageController:{
opsportal:['sessionAuth']
}Now test this out:
$ sails liftYou should see a response like:
info: Starting app...
info:
info:
info: Sails <|
info: v0.12.3 |\
info: /|.\
info: / || \
info: ,' |' \
info: .-'.-==|/_--'
info: `--'-------'
info: __---___--___---___--___---___--___
info: ____---___--___---___--___---___--___-__
info:
info: Server lifted in `/path/to/your/dir/sails`
info: To see your app, visit http://localhost:1337
info: To shut down Sails, press <CTRL> + C at any time.
debug: --------------------------------------------------------
debug: :: Fri Feb 13 2015 17:24:55 GMT+0700 (ICT)
debug: Environment : development
debug: Port : 1337
debug: --------------------------------------------------------Open a web browser and enter the path: localhost:1337/page/opsportal
You should see a spiffy web page with a bar across the bottom for the Opsportal. Clicking on the bar will cause the OpsPortal to take over the whole screen. Clicking on the menu icon will allow you to switch between the installed OpsTools.
If you successfully got here, then you are ready to create your first OpsTool Plugin.
< Setup
Next: Create a Plugin >