-
Notifications
You must be signed in to change notification settings - Fork 31
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #261 from xaun/mnoe-dev-toolkit
Mnoe dev toolkit
- Loading branch information
Showing
25 changed files
with
910 additions
and
256 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,133 @@ | ||
// IMPAC! WORKSPACE | ||
//-------------------------------------------------------- | ||
// PLEASE DO NOT COMMIT CHANGES TO THIS FILE. | ||
// You can use `git add -p ./` to selectively add files to your git index. | ||
// ------------------------------------------------------- | ||
var module = angular.module('impacWorkspace', [ | ||
'maestrano.impac', | ||
'toastr', | ||
'Devise', | ||
'ui.router', | ||
'ngCookies' | ||
]); | ||
|
||
// -- | ||
// The Developer Toolkit Workspace States. | ||
// ------------------------------------------------------- | ||
module.config(function ($stateProvider, $urlRouterProvider) { | ||
|
||
$urlRouterProvider.otherwise('/login'); | ||
|
||
$stateProvider | ||
.state('workspace', { | ||
abstract: true, | ||
templateUrl: 'app/views/workspace/workspace.html', | ||
controller: 'WorkspaceController', | ||
controllerAs: 'main' | ||
}) | ||
.state('workspace.login', { | ||
url: '/login', | ||
templateUrl: 'app/views/workspace/login/login.html', | ||
controller: 'LoginController', | ||
controllerAs: 'vm' | ||
}) | ||
.state('workspace.impac', { | ||
url: '/impac', | ||
templateUrl: 'app/views/workspace/impac/impac.html', | ||
controller: 'ImpacController', | ||
controllerAs: 'vm' | ||
}) | ||
.state('workspace.settings', { | ||
url: '/settings', | ||
templateUrl: 'app/views/workspace/settings/settings.html', | ||
controller: 'SettingsController', | ||
controllerAs: 'vm' | ||
}); | ||
|
||
}); | ||
|
||
// -- | ||
// Configure Angular Devise paths for mno-enterprise. | ||
// ------------------------------------------------------- | ||
module.config(function (AuthProvider, DevSettingsProvider) { | ||
var mnoeHostUrl = DevSettingsProvider.$get().defaults().mnoeUrl.host; | ||
// Customize login | ||
AuthProvider.loginMethod('POST'); | ||
AuthProvider.loginPath(mnoeHostUrl + '/mnoe/auth/users/sign_in.json'); | ||
|
||
// Customize logout | ||
AuthProvider.logoutMethod('DELETE'); | ||
AuthProvider.logoutPath(mnoeHostUrl + '/mnoe/auth/users/sign_out.json'); | ||
|
||
// Customize register | ||
AuthProvider.registerMethod('POST'); | ||
AuthProvider.registerPath(mnoeHostUrl + '/mnoe/auth/users'); | ||
}); | ||
|
||
// -- | ||
// Configure Angular $http to apply XSRF Token headers to CORS requests. | ||
// ------------------------------------------------------- | ||
module.constant('CSRF', { | ||
"headerTokenKey": 'X-XSRF-TOKEN', | ||
"cookieTokenKey": 'XSRF-TOKEN' | ||
}); | ||
module.config(function($httpProvider) { | ||
// Allow "credentialed" requests that are aware of HTTP cookies and HTTP | ||
// Authentication information. | ||
$httpProvider.defaults.withCredentials = true; | ||
}); | ||
module.run(function($http, DevSession) { | ||
DevSession.create(); | ||
}); | ||
|
||
// -- | ||
// Impac! Angular Provider Service Configurations. | ||
// ------------------------------------------------------- | ||
module.run(function (ImpacLinking, ImpacAssets, ImpacRoutes, ImpacTheming, ImpacDeveloper, DevUser, DevSettings) { | ||
|
||
var defaults = DevSettings.defaults(); | ||
|
||
// Configure ImpacRoutes | ||
// ------------------------------------------------------- | ||
ImpacRoutes.configureRoutes(DevSettings.buildRoutesConfig(defaults.mnoeUrl, defaults.impacUrl, defaults.multipleWatchableMode)); | ||
|
||
|
||
// Configure ImpacTheming - aesthetic and feature customisations across the app | ||
// ------------------------------------------------------- | ||
ImpacTheming.configure({ | ||
dhbKpisConfig: { | ||
enableKpis: true | ||
}, | ||
alertsConfig: { | ||
enableAlerts: true | ||
}, | ||
dhbConfig: { | ||
showDhbHeading: true, | ||
dhbHeadingText: 'Your business at a glance, in real-time' | ||
}, | ||
dhbSelectorConfig: { | ||
selectorType: 'dropdown', | ||
pdfModeEnabled: true | ||
}, | ||
dhbSettings: { | ||
syncApps: { | ||
show: function() { return false; } | ||
} | ||
} | ||
}); | ||
|
||
// Configure ImpacAssets - app asset file configurations | ||
// ------------------------------------------------------- | ||
ImpacAssets.configure({ | ||
defaultImagesPath: '/dist/images', | ||
}) | ||
|
||
// Configure ImpacDeveloper - developer toolkit specifc customisations | ||
// ------------------------------------------------------- | ||
ImpacDeveloper.configure(DevSettings.buildDeveloperConfig(defaults.widgetsTemplates)); | ||
|
||
// Configure ImpacLinking - Links core callbacks required for impac-angular lib to run. | ||
// ------------------------------------------------------- | ||
ImpacLinking.linkData(DevSettings.buildLinkingConfig(defaults.orgUid, defaults.mnoeUrl)); | ||
|
||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
// ------------------------------------------------------- | ||
// Impac! Angular DevSession Service | ||
// -------- | ||
// Providing CSRF Support for Impac! Workspace. | ||
// ------------------------------------------------------- | ||
angular.module('impacWorkspace').service('DevSession', function ($log, $http, $cookies, CSRF, DevSettings) { | ||
var _self = this; | ||
|
||
// Create a session and xsrf token - ping mnoe api so we get a valid XSRF cookie. | ||
this.create = function () { | ||
return $http.get(DevSettings.defaults().mnoeUrl.host + '/mnoe/auth/users/sign_in.json') | ||
.success(function() { | ||
_self.setCsrfHttpHeader(); | ||
}); | ||
}; | ||
|
||
// Angular Devise methods (e.g `Auth.currentUser()`) generate new sessions, this keeps the | ||
// default http headers up to date, ensuring the session is maintained. | ||
this.update = function () { | ||
this.setCsrfHttpHeader(); | ||
}; | ||
|
||
// Set stored XSRF cookie as $http headers common. | ||
this.setCsrfHttpHeader = function () { | ||
$http.defaults.headers.common[CSRF.headerTokenKey] = $cookies.get(CSRF.cookieTokenKey); | ||
}; | ||
|
||
return this; | ||
}); |
Oops, something went wrong.