2 tipos de inicializar o projeto com angular
// pure angular
(function() {
var initInjector = angular.injector(['ng', 'requestFromAPIService', 'config', 'ngCookies']);
var $http = initInjector.get('$http');
var requestFromAPI = initInjector.get('requestFromAPI');
var ENV = initInjector.get('ENV');
var $cookies = initInjector.get('$cookies');
if (!ENV.disable_auth) {
if ($cookies.get('wrsso') === '' || !$cookies.get('wrsso')) {
console.log('initialize redirecionando para o auth');
window.location.href = '/auth/webradar';
return false;
}
requestFromAPI.request(ENV.rocketAppUrl + 'capabilities', '', {}, 'clearance').then(function(resp){
if(!resp || !resp.data || !resp.data.roles || resp.data.roles.length === 0){
console.log('falha na resposta do initialize rule - redirecionando para o auth');
window.location.href = '/auth/webradar';
return false;
}
angular.module('APP_CONFIG', []).constant('APP_CONFIG', resp.data);
angular.element(document).ready(function() {
angular.bootstrap(document, ['rocketUI']);
});
}, function(err){
window.location.href = '/auth/webradar';
});
}else{
angular.module('APP_CONFIG', []).constant('APP_CONFIG', {roles: ['manager']});
angular.element(document).ready(function() {
angular.bootstrap(document, ['rocketUI']);
});
}
})();
// deferredBootstrapper-lib
// deferredBootstrapper.bootstrap({
// element: document.body,
// module: 'rocketUI',
// injectorModules: ['requestFromAPIService', 'config'],
// resolve: {
// APP_CONFIG: ['requestFromAPI', 'ENV', function (requestFromAPI, ENV) {
// return requestFromAPI.request(ENV.rocketAppUrl + 'capabilities', '', {}, 'clearance');
// }]
// }
// });