diff --git a/client/app/telecom/pack/xdsl/modem/templates/pack-xdsl-modem-template.constant.js b/client/app/telecom/pack/xdsl/modem/templates/pack-xdsl-modem-template.constant.js new file mode 100644 index 000000000..815cd94aa --- /dev/null +++ b/client/app/telecom/pack/xdsl/modem/templates/pack-xdsl-modem-template.constant.js @@ -0,0 +1,6 @@ +angular.module('managerApp').constant('PACK_XDSL_MODEM_TEMPLATE', { + errors: { + duplicate: 'TemplateName', + invalid: 'Invalid', + }, +}); diff --git a/client/app/telecom/pack/xdsl/modem/templates/pack-xdsl-modem-templates.controller.js b/client/app/telecom/pack/xdsl/modem/templates/pack-xdsl-modem-templates.controller.js index 70926fbaf..47638b38b 100644 --- a/client/app/telecom/pack/xdsl/modem/templates/pack-xdsl-modem-templates.controller.js +++ b/client/app/telecom/pack/xdsl/modem/templates/pack-xdsl-modem-templates.controller.js @@ -1,7 +1,7 @@ angular.module('managerApp').controller('XdslModemTemplateCtrl', class XdslModemTemplateCtrl { /* @ngInject */ constructor($stateParams, $translate, $uibModal, OvhApiXdsl, TucPackXdslModemMediator, - TucToast) { + TucToast, PACK_XDSL_MODEM_TEMPLATE) { this.$stateParams = $stateParams; this.$translate = $translate; this.$uibModal = $uibModal; @@ -9,6 +9,7 @@ angular.module('managerApp').controller('XdslModemTemplateCtrl', class XdslModem this.OvhApiXdsl = OvhApiXdsl; this.templateName = null; this.TucToast = TucToast; + this.TEMPLATE_CONSTANT = PACK_XDSL_MODEM_TEMPLATE; } /*= ===================================== @@ -46,11 +47,17 @@ angular.module('managerApp').controller('XdslModemTemplateCtrl', class XdslModem this.templateName = null; this.getModemTemplates(); }).catch((err) => { + let errorMessage = ''; + if (err.data.message.includes(this.TEMPLATE_CONSTANT.errors.duplicate)) { + errorMessage = this.$translate.instant('xdsl_modem_template_name_already_exist', { templateName: this.templateName }); + } else if (err.data.message.includes(this.TEMPLATE_CONSTANT.errors.invalid)) { + errorMessage = this.$translate.instant('xdsl_modem_template_invalid_name', { templateName: this.templateName }); + } else { + errorMessage = this.$translate.instant('xdsl_modem_template_an_error_ocurred'); + } this.message = { type: 'error', - detail: err.data.message.includes('TemplateName') - ? this.$translate.instant('xdsl_modem_template_name_already_exist', { templateName: this.templateName }) - : this.$translate.instant('xdsl_modem_template_an_error_ocurred'), + detail: errorMessage, }; }); } diff --git a/client/app/telecom/pack/xdsl/modem/templates/translations/Messages_fr_FR.json b/client/app/telecom/pack/xdsl/modem/templates/translations/Messages_fr_FR.json index 40437d54d..9afdd89d0 100644 --- a/client/app/telecom/pack/xdsl/modem/templates/translations/Messages_fr_FR.json +++ b/client/app/telecom/pack/xdsl/modem/templates/translations/Messages_fr_FR.json @@ -9,5 +9,6 @@ "xdsl_modem_template_apply_doing": "Chargement de la configuration du modem en cours", "xdsl_modem_template_creation_doing": "Enregistrement de la configuration du modem en cours", "xdsl_modem_template_an_error_ocurred": "TEMPLATE : Une erreur est survenue !", - "xdsl_modem_template_name_already_exist": "{{templateName}} existe déjà dans votre liste de templates. Veuillez utiliser un autre nom." -} \ No newline at end of file + "xdsl_modem_template_name_already_exist": "{{templateName}} existe déjà dans votre liste de templates. Veuillez utiliser un autre nom.", + "xdsl_modem_template_invalid_name": "Le nom de template ({{templateName}}) est invalide. Veuillez utiliser un autre nom." +}