reservation-admin-engine-addon
v0.0.35
Published
The default blueprint for ember-cli addons.
Downloads
13
Readme
reservation-admin-engine-addon
This README outlines the details of collaborating on this Ember addon.
This addon must be worked on with the following ember addon found on npm: admin-engine-addon which is relied on for the styles and other addons that are already bundled inside admin-engine-addon.
This addon is to be also used with the sails.js generator found on npm as admin.rest.ember.generator. Please visit the npm page to install it and run it on your sails js server.
Before proceeding with this engine installation, please visit the ember-engine github page on this link: https://github.com/dgeb/ember-engines/tree/v0.3 and ember install [email protected]
Then set up the app.js file as follows:
import Ember from 'ember';
import Resolver from 'ember-engines/resolver';
import loadInitializers from 'ember-load-initializers';
import config from './config/environment';
let App;
Ember.MODEL_FACTORY_INJECTIONS = true;
App = Ember.Application.extend({
modulePrefix: config.modulePrefix,
podModulePrefix: config.podModulePrefix,
Resolver,
engines: {
adminEngineAddon: {
dependencies: {
services: [
'session', 'store', 'current-user', 'app-config', 'permission-check', 'country-list'
]
}
},
reservationAdminEngineAddon: {
dependencies: {
services: [
'session', 'store', 'current-user', 'app-config', 'permission-check', 'country-list'
],
externalRoutes: {
login: 'security.' + config['ember-simple-auth'].authenticationRoute
}
}
}
}
});
loadInitializers(App, config.modulePrefix);
export default App;
Then go to the terminal and install reservation-admin-engine-addon like so:
ember install reservation-admin-engine-addon
Then go ahead and copy into the root the .env file, or create it and copy the following content:
ZURU_API_URL='http://localhost:1337/api/v1'
SERVER_TOKEN_ENDPOINT='http://localhost:1337/api/v1/auths/login?type=local'
SERVER_TOKEN_REFRESH_ENDPOINT='http://localhost:1337/api/v1/users/jwt'
ENABLE_AUTH_PROXY=true
Then set up the app config file with the following addition configurations add override the setting as necessary. Take note that a bundled addon 'admin-lte-app-shares' already has the same settings:
ENV['zuru'] = {
apiUrl: process.env.ZURU_API_URL,
enableAuthProxy: process.env.ENABLE_AUTH_PROXY
}
ENV['ember-simple-auth-token'] = {
refreshAccessTokens: true,
tokenExpireName: 'exp',
timeFactor: 1,
refreshLeeway: 300, //Refresh the token 5 minutes (300s) before it expires
identificationField: 'email',
tokenPropertyName: 'access_token',
serverTokenEndpoint: process.env.SERVER_TOKEN_ENDPOINT,
serverTokenRefreshEndpoint: process.env.SERVER_TOKEN_REFRESH_ENDPOINT
};
ENV['ember-simple-auth'] = {
authenticationRoute: 'admin.access.login',
routeAfterAuthentication: 'security.admin.tasks', //Note that it starts with security route as this is executed by parent app/engine at the application route
routeIfAlreadyAuthenticated: 'admin.tasks'
};
And then go to the router.js file and set up the following mount:
import Ember from 'ember';
import config from './config/environment';
const Router = Ember.Router.extend({
location: config.locationType,
rootURL: config.rootURL
});
Router.map(function() {
this.mount('admin-engine-addon', { as: 'security' });
this.mount('reservation-admin-engine-addon', { as: 'internal' });
});
export default Router;
Notice that inside the mount the alias used by default for this is 'security'. If you change it, be sure to go back into the config and change the default access login paths with new alias.
Also, added the ember-can authorisation library. Please visit the ember-can github page on this link: https://github.com/minutebase/ember-can
To work with this in the engines, you would have to open their source files in an editor. To limit the view within the templates, use the following format:
{{#if (can 'view resource' (hash permission='canSee' resource='Resources' ))}}
{{/if}}
The first part '(can 'view resource') is for finding the ability class of 'resource' and calling the computed property 'can view' camel cased. The second part of '(hash permission='canSee' resource='Resources' )' is the model that will be passed on to the ability class. They are used to filter the permissions collection on the server by the resource model name and permission field on the permission object.
Installation
git clone <repository-url>
this repositorycd admin.engine.addon
npm install
bower install
Running
ember serve
- Visit your app at http://localhost:4200.
Running Tests
npm test
(Runsember try:each
to test your addon against multiple Ember versions)ember test
ember test --server
Building
ember build
For more information on using ember-cli, visit http://ember-cli.com/.