Errores en spinner
This commit is contained in:
parent
519a55fac7
commit
e03d257930
|
@ -7,6 +7,10 @@ import {module} from '../module';
|
|||
* @property {Snackbar} snackbar The main object to show messages.
|
||||
*/
|
||||
export default class App {
|
||||
constructor($rootScope) {
|
||||
this.loaderStatus = 0;
|
||||
this.$rootScope = $rootScope;
|
||||
}
|
||||
show(message) {
|
||||
if (this.snackbar) this.snackbar.show({message: message});
|
||||
}
|
||||
|
@ -16,5 +20,17 @@ export default class App {
|
|||
showError(message) {
|
||||
this.show(`Error: ${message}`);
|
||||
}
|
||||
pushLoader() {
|
||||
this.loaderStatus++;
|
||||
if (this.loaderStatus === 1)
|
||||
this.$rootScope.loading = true;
|
||||
}
|
||||
popLoader() {
|
||||
this.loaderStatus--;
|
||||
if (this.loaderStatus === 0)
|
||||
this.$rootScope.loading = false;
|
||||
}
|
||||
}
|
||||
App.$inject = ['$rootScope']
|
||||
|
||||
module.service('vnApp', App);
|
||||
|
|
|
@ -1,11 +1,10 @@
|
|||
import {module} from '../module';
|
||||
|
||||
interceptor.$inject = ['$q', '$rootScope', '$window', 'vnApp', '$translate', '$cookies'];
|
||||
function interceptor($q, $rootScope, $window, vnApp, $translate, $cookies) {
|
||||
$rootScope.loading = false;
|
||||
interceptor.$inject = ['$q', '$window', 'vnApp', '$translate', '$cookies'];
|
||||
function interceptor($q, $window, vnApp, $translate, $cookies) {
|
||||
return {
|
||||
request: function(config) {
|
||||
$rootScope.loading = true;
|
||||
vnApp.pushLoader();
|
||||
let token = $cookies.get('vnToken');
|
||||
|
||||
if (token)
|
||||
|
@ -23,11 +22,11 @@ function interceptor($q, $rootScope, $window, vnApp, $translate, $cookies) {
|
|||
case 'PATCH':
|
||||
vnApp.showMessage($translate.instant('Data saved!'));
|
||||
}
|
||||
$rootScope.loading = false;
|
||||
vnApp.popLoader();
|
||||
return response;
|
||||
},
|
||||
responseError: function(rejection) {
|
||||
$rootScope.loading = false;
|
||||
vnApp.popLoader();
|
||||
let data = rejection.data;
|
||||
let error;
|
||||
|
||||
|
|
|
@ -11,7 +11,7 @@ module.exports = function(Self) {
|
|||
let app = require('../../server/server');
|
||||
let Employee = app.models.Employee;
|
||||
Employee.findOne({where: {userFk: userId}}, function (err, user){
|
||||
if (user){
|
||||
if (user) {
|
||||
ctx.instance.employeeFk = user.id;
|
||||
next();
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue