git-svn-id: https://svn.coded.pt/svn/SIPRP@1864 bb69d46d-e84e-40c8-a05a-06db0d633741

lxbfYeaa
João Maurício 12 years ago
parent 69e2bd3dd9
commit e15731070f

@ -9,7 +9,7 @@
model: null, model: null,
actions: { actions: {
get: 'getFichaEAdmissaoInicial', get: 'getFichaEAdmissaoInicial',
upsert: 'upsertFichaEAdmissaoInicial',//TODO: ??? upsert: 'sendFichaEAdmissaoInicial',//TODO: ???
destroy: 'deleteFichaEAdmissaoInicial'//TODO: ??? destroy: 'deleteFichaEAdmissaoInicial'//TODO: ???
} }
}); });

@ -3714,10 +3714,6 @@
</div> </div>
</div> </div>
<br />
<br />
<br /> <br />
<div class="row"> <div class="row">

@ -2,25 +2,65 @@
{ {
$scope.globals = globals; $scope.globals = globals;
$scope.storeLogin = new globals.dataService.store({
model: null,
actions: {
upsert: 'doLogin'
}
});
$scope.storeLogin.broadcastEvents = false;
$scope.editing = {
user: 'admin',
pass: 'admin'
};
//login procedure ---> user clicks the Login button //login procedure ---> user clicks the Login button
$scope.login = function(arg) { $scope.login = function(arg) {
$scope.iaLoginMessages.message = 'Nome de Utilizador ou Palavra-Passe errados.'; $rootScope.$broadcast('loadingStatusActive');
$scope.iaLoginMessages.cssClass = 'bg-danger';
$scope.iaLoginMessages.show();
$timeout(function () { $scope.selected = {};
$scope.iaLoginMessages.hide();
$rootScope.$emit('onloginsuccessfull', {response: null}); $scope.iaLoginMessages.hide();
}, 0); $scope.storeLogin.upsert({}, $scope.editing, function(response, selected, editing, isNewRecord){
};
$scope.$on('afterrender', function(event, args){ $rootScope.$broadcast('loadingStatusInactive');
if(response.success)
{
if($scope.$parent.sessionTimeout)
{
//go to previous module before timeout...
var className = $scope.$parent.beforeSessionTimeoutModule.ClassName;
}); $scope.$parent.loadModule({Controller: className}, function(className, scope, isNewModule){
$scope.$parent.sessionTimeout = false;
$scope.$parent.beforeSessionTimeoutModule = null;
});
}
else
{
$rootScope.$emit('onloginsuccessfull', {response: response});
}
}
else
{
if(response.messages.length > 0)
{
var firstMessage = response.messages[0].messageData;
$scope.iaLoginMessages.message = firstMessage;
$scope.iaLoginMessages.cssClass = 'bg-danger';
$scope.iaLoginMessages.show();
}
}
});
};
$scope.$on('afterrender', function(event, args){
});
}); });

@ -21,11 +21,11 @@
<div class="form-group"> <div class="form-group">
<label class="control-label">Nome de Utilizador</label> <label class="control-label">Nome de Utilizador</label>
<input type="text" class="form-control"> <input ng-model="editing.user" type="text" class="form-control" />
</div> </div>
<div class="form-group"> <div class="form-group">
<label class="control-label">Palavra-Passe</label> <label class="control-label">Palavra-Passe</label>
<input type="text" class="form-control"> <input ng-model="editing.pass" type="text" class="form-control" />
</div> </div>
<div class="form-group"> <div class="form-group">

@ -2,6 +2,15 @@
{ {
var me = this; var me = this;
$scope.storeUserSession = new globals.dataService.store({
model: null,
actions: {
get: 'checkLogin',
destroy: 'doLogout'
}
});
$scope.storeUserSession.broadcastEvents = true;
//will contain all the application HTML //will contain all the application HTML
$scope.viewCache = null; $scope.viewCache = null;
@ -20,6 +29,10 @@
$scope.menuItems = []; $scope.menuItems = [];
//if true, indicates a session timeout
$scope.sessionTimeout = false;
$scope.beforeSessionTimeoutModule = null;
//this div will contain all modules currently not in view //this div will contain all modules currently not in view
var divTemp = $('<div></div>'); var divTemp = $('<div></div>');
@ -28,52 +41,47 @@
$scope.divMainPanel = $('body #main-panel'); $scope.divMainPanel = $('body #main-panel');
$scope.renderModule('body #main-panel', 'Login', null, true, function(className, scope){ $scope.storeUserSession.get(function(response, status, headers, config, items){
$timeout(function() { if(response.success)
{
//TODO: repeated code ???
$('#main-panel').show(); $('#main-panel').show();
//globals.plugins.setDefaults(); //globals.plugins.setDefaults();
//globals.plugins.setBootstrap(); //globals.plugins.setBootstrap();
$rootScope.$broadcast('loadingStatusInactive'); $rootScope.$broadcast('loadingStatusInactive');
});
});
//$scope.buildTopMenu();
$rootScope.$emit('onloginsuccessfull', {response: response});
}
else
{
$scope.renderModule('body #main-panel', 'Login', null, true, function(className, scope){
}; $timeout(function() {
$rootScope.$on('onloginsuccessfull', function(event, args){ //TODO: repeated code ???
$('#main-panel').show();
$scope.loadModule({Controller: 'Search'}, function(className, scope, isNewModule){
}); //globals.plugins.setDefaults();
//globals.plugins.setBootstrap();
//$scope.renderModule('body #main-panel', 'Search', null, true, function(className, scope){
// $timeout(function() {
// });
//});
//var form1 = $scope.getModule('Form1'); $rootScope.$broadcast('loadingStatusInactive');
});
});
}
});
////load default module: Form1
//$scope.renderModule('body #main-panel', 'Form1', null, true, function(className, scope){
// $timeout(function() { };
// //$('#main-panel').show(); $rootScope.$on('onloginsuccessfull', function(event, args){
// //globals.plugins.setDefaults();
// //globals.plugins.setBootstrap();
// //$rootScope.$broadcast('loadingStatusInactive'); // go to the default module and/or landing page
// }); $scope.loadModule({Controller: 'Search'}, function(className, scope, isNewModule){
//});
});
}); });
//creates/renders a new controller+view into the given placeholder //creates/renders a new controller+view into the given placeholder
@ -307,7 +315,7 @@
} }
} }
$scope.currentModuleName = subModule.Name; $scope.currentModuleName = subModule.Controller;
}); });
}; };
@ -365,6 +373,7 @@
} }
}; };
// executes a logout from the application and perfomrs cleanup operations
$scope.logout = function(){ $scope.logout = function(){
globals.message.confirm({ globals.message.confirm({
@ -373,9 +382,25 @@
if(result) if(result)
{ {
$scope.loadModule({Controller: 'Login'}, function(className, scope, isNewModule){ $scope.storeUserSession.broadcastEvents = false;
$scope.storeUserSession.destroy(null, function(response){
}); $scope.storeUserSession.broadcastEvents = true;
if(response.success)
{
//TODO: cleanup the whole application ???
$scope.loadModule({Controller: 'Login'}, function(className, scope, isNewModule){
});
}
else
{
}
});
} }
} }
}); });
@ -405,9 +430,25 @@
$scope.notification = null; $scope.notification = null;
$scope.defaultExceptionMessage = {
success: false,
data: null,
messages: [
{
type: 'ERROR',
messageData: 'Ocorreu um erro de sistema.'
}
]
};
$rootScope.$on('response', function(event, args){ $rootScope.$on('response', function(event, args){
var response = args.response; var response = args.response, msgCss = 'default';
if(response.data == undefined || response.messages == undefined)
{
response = $scope.defaultExceptionMessage;
}
if(response != undefined && response != null && response.messages.length > 0) if(response != undefined && response != null && response.messages.length > 0)
{ {
@ -415,7 +456,7 @@
$scope.FirstMessage = response.messages[0]; $scope.FirstMessage = response.messages[0];
$scope.FirstMessage.type = globals.utils.getMessageTypeCSS($scope.FirstMessage.type); msgCss = globals.utils.getMessageTypeCSS($scope.FirstMessage.type);
$scope.MessageCount = response.messages.length; $scope.MessageCount = response.messages.length;
} }
@ -430,7 +471,7 @@
text: $scope.FirstMessage.messageData, text: $scope.FirstMessage.messageData,
maxVisible: 1, maxVisible: 1,
template: template:
'<div ng-click="viewServerResponse()" class="bg-' + $scope.FirstMessage.type + ' noty_message">' + '<div ng-click="viewServerResponse()" class="bg-' + msgCss + ' noty_message">' +
'<span ng-show="MessageCount > 1" class="label label-default pull-left noty-label">+{{MessageCount-1}}</span>' + '<span ng-show="MessageCount > 1" class="label label-default pull-left noty-label">+{{MessageCount-1}}</span>' +
'<span class="noty_text"></span>' + '<span class="noty_text"></span>' +
'<div class="noty_close"></div>' + '<div class="noty_close"></div>' +
@ -462,6 +503,18 @@
//$scope.windowViewServerResponse.viewController.list($scope.ServerResponse); //$scope.windowViewServerResponse.viewController.list($scope.ServerResponse);
}; };
$rootScope.$on('onsessiontimeout', function(event, args){
var eee = args.response;
$scope.sessionTimeout = true;
$scope.beforeSessionTimeoutModule = $scope.currentModule;
$scope.loadModule({Controller: 'Login'}, function(className, scope, isNewModule){
});
});
//$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$ //$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$
//fires whenever a new module is rendered, if broadcastCreation is true on method renderModule //fires whenever a new module is rendered, if broadcastCreation is true on method renderModule

@ -66,8 +66,8 @@
$scope.onEmpresaChange = function(selectedValue, selectedRecord){ $scope.onEmpresaChange = function(selectedValue, selectedRecord){
$scope.comboEstabelecimentos.store.extraParams = { $scope.comboEstabelecimentos.store.extraParams = {
empresaID: selectedRecord.id, id: selectedRecord.id,
filter: 'sede' filter: selectedRecord.designacao_social
}; };
$scope.comboEstabelecimentos.loadStore(function(response, status, headers, config, items){ $scope.comboEstabelecimentos.loadStore(function(response, status, headers, config, items){

@ -46,7 +46,7 @@
store-model="" store-model=""
store-actions-get="getEstabelecimentos" store-actions-get="getEstabelecimentos"
value-field="id" value-field="id"
display-field="designacao_social" display-field="nome"
add-empty-option="false" add-empty-option="false"
on-change="onEstabelecimentoChange(selectedValue, selectedRecord)"> on-change="onEstabelecimentoChange(selectedValue, selectedRecord)">
</custom-combo> </custom-combo>
@ -63,7 +63,7 @@
store-model="" store-model=""
store-actions-get="getTrabalhadores" store-actions-get="getTrabalhadores"
value-field="id" value-field="id"
display-field="designacao_social" display-field="nome"
add-empty-option="false" add-empty-option="false"
on-change="onTrabalhadorChange(selectedValue, selectedRecord)"> on-change="onTrabalhadorChange(selectedValue, selectedRecord)">
</custom-combo> </custom-combo>

@ -33,6 +33,8 @@
this.convertToModel = true; this.convertToModel = true;
this.broadcastEvents = true; this.broadcastEvents = true;
$http.defaults.withCredentials = true;
this.get = function(){ this.get = function(){
var callbackFn = arguments[0]; var callbackFn = arguments[0];
@ -82,6 +84,11 @@
}). }).
error(function(response, status, headers, config) { error(function(response, status, headers, config) {
if(me.broadcastEvents)
{
$rootScope.$broadcast('response', {response: response});
}
callback(callbackFn, [response, status, headers, config]); callback(callbackFn, [response, status, headers, config]);
}); });
@ -114,45 +121,40 @@
}). }).
success(function(response, status, headers, config) { success(function(response, status, headers, config) {
$rootScope.$broadcast('response', {response: response}); if(me.broadcastEvents)
{
$rootScope.$broadcast('response', {response: response});
}
if(response.success) if(response.success)
{ {
// var idPropertyValue = editing[modelInstance.idProperty], // var idPropertyValue = editing[modelInstance.idProperty],
// isNewRecord = (idPropertyValue == 0 || idPropertyValue == null || idPropertyValue == undefined); // isNewRecord = (idPropertyValue == 0 || idPropertyValue == null || idPropertyValue == undefined);
// if(response.data != null) // if(response.data != null)
// { // {
// if(angular.isArray(response.data)) // if(angular.isArray(response.data))
// { // {
// response.data = modelService.toModel(me.model, response.data[0], null); // response.data = modelService.toModel(me.model, response.data[0], null);
// } // }
// else // else
// { // {
// response.data = modelService.toModel(me.model, response.data, null); // response.data = modelService.toModel(me.model, response.data, null);
// } // }
// angular.copy(response.data, editing); // angular.copy(response.data, editing);
// angular.copy(response.data, selected); // angular.copy(response.data, selected);
// } // }
} }
callback(callbackFn, [response, selected, editing, isNewRecord]); callback(callbackFn, [response, selected, editing, isNewRecord]);
}). }).
error(function(response, status, headers, config) { error(function(response, status, headers, config) {
var res = { if(me.broadcastEvents)
success: false, {
data: null, $rootScope.$broadcast('response', {response: response});
messages: [ }
{
type: 'ERROR',
messageData: 'Ocorreu um erro de sistema.'
}
]
};
$rootScope.$broadcast('response', {response: res});
callback(callbackFn, [response, selected, editing, isNewRecord]); callback(callbackFn, [response, selected, editing, isNewRecord]);
}); });
@ -182,12 +184,20 @@
}). }).
success(function(response, status, headers, config) { success(function(response, status, headers, config) {
$rootScope.$broadcast('response', {response: response}); if(me.broadcastEvents)
{
$rootScope.$broadcast('response', {response: response});
}
callback(callbackFn, [response]); callback(callbackFn, [response]);
}). }).
error(function(response, status, headers, config) { error(function(response, status, headers, config) {
if(me.broadcastEvents)
{
$rootScope.$broadcast('response', {response: response});
}
callback(callbackFn, [response]); callback(callbackFn, [response]);
}); });
}; };

@ -17,19 +17,19 @@ evoapp.factory('httpInterceptor', function ($rootScope, $q){
var ended = function(response){ var ended = function(response){
//intercept SECURITYEXCEPTION responses //intercept exceptions
//if(!response.data.success && response.data.response) if(response.data.success != undefined)
//{ {
// if(response.data.response.ServerResponse.length > 0) if(response.data.messages.length > 0)
// { {
// var sr = response.data.response.ServerResponse[0]; var firstMessage = response.data.messages[0];
// if(sr.MessageType == 'SECURITYEXCEPTION') if(firstMessage.type == 'SESSIONTIMEOUT')
// { {
// $rootScope.$broadcast('response', {response: response.data}); $rootScope.$broadcast('onsessiontimeout', {response: response.data});
// } }
// } }
//} }
activeRequests--; activeRequests--;

@ -0,0 +1,16 @@
 evoapp.factory('staticData', function($rootScope) {
//exceptions
var exceptions = {
ERROR: 'ERROR',
SECURITYEXCEPTION: 'SECURITYEXCEPTION',
SESSIONTIMEOUT: 'SESSIONTIMEOUT',
INFO: 'INFO',
QUESTION: 'QUESTION',
WARNING: 'WARNING'
};
return {
exceptions: exceptions
};
});

@ -15,6 +15,7 @@
{ {
case 'ERROR': case 'ERROR':
case 'SECURITYEXCEPTION': case 'SECURITYEXCEPTION':
case 'SESSIONTIMEOUT':
messageType = 'danger'; messageType = 'danger';
break; break;

@ -258,4 +258,8 @@ body.modal-open {
overflow: auto; overflow: auto;
} }
.modal-backdrop, .modal-backdrop.fade.in {
opacity: 0.7;
filter: alpha(opacity=70);
background: transparent!important;
}

@ -109,7 +109,7 @@
<div id="main-panel" class="container"> <div id="main-panel" class="container">
</div> </div>
<div id="footer"> <div id="footer">

File diff suppressed because one or more lines are too long
Loading…
Cancel
Save