diff --git a/assets/js/app/house/house.controller.js b/assets/js/app/house/house.controller.js index f8bc29264b..166be6a0c4 100644 --- a/assets/js/app/house/house.controller.js +++ b/assets/js/app/house/house.controller.js @@ -14,9 +14,9 @@ .module('gladys') .controller('HouseCtrl', HouseCtrl); - HouseCtrl.$inject = ['houseService', 'roomService']; + HouseCtrl.$inject = ['houseService', 'roomService', 'notificationService']; - function HouseCtrl(houseService, roomService) { + function HouseCtrl(houseService, roomService, notificationService) { /* jshint validthis: true */ var vm = this; @@ -45,6 +45,13 @@ .then(function(data){ getHouses(); resetNewHouseFields(); + }) + .catch(err => { + if(err.data && err.data.code && err.data.code == 'E_VALIDATION') { + notificationService.errorNotificationTranslated('VALIDATION.ERROR'); + } else { + notificationService.errorNotificationTranslated('DEFAULT.ERROR'); + } }); } @@ -53,6 +60,13 @@ .then(function(data){ getRooms(); resetNewRoomFields(); + }) + .catch(err => { + if(err.data && err.data.code && err.data.code == 'E_VALIDATION') { + notificationService.errorNotificationTranslated('VALIDATION.ERROR'); + } else { + notificationService.errorNotificationTranslated('DEFAULT.ERROR'); + } }); } diff --git a/assets/js/app/translate/translate.config.js b/assets/js/app/translate/translate.config.js index 89b9604efe..c11c8b4ca2 100644 --- a/assets/js/app/translate/translate.config.js +++ b/assets/js/app/translate/translate.config.js @@ -30,6 +30,12 @@ var translationsEN = { CHAT: { TEXT_BOX_PLACEHOLDER: 'Write your message', TYPING: 'Typing' + }, + VALIDATION: { + ERROR: 'Some fields are invalid !' + }, + DEFAULT: { + ERROR: 'Something bad happened :/ Check Gladys logs for more informations.' } }; @@ -65,7 +71,13 @@ var translationsFR = { CHAT: { TEXT_BOX_PLACEHOLDER: 'Tapez votre message', TYPING: 'En train d\'écrire' - } + }, + VALIDATION: { + ERROR: 'Certains champs sont invalides !' + }, + DEFAULT: { + ERROR: 'Une erreur inconnue est arrivée :/ Regardez les logs Gladys pour plus d\'informations.' + } };