diff --git a/packages/manager/apps/telecom/src/app/telecom/telephony/billingAccount/guides/index.js b/packages/manager/apps/telecom/src/app/telecom/telephony/billingAccount/guides/index.js new file mode 100644 index 000000000000..ca221d68fac5 --- /dev/null +++ b/packages/manager/apps/telecom/src/app/telecom/telephony/billingAccount/guides/index.js @@ -0,0 +1,11 @@ +import angular from 'angular'; + +import ovhManagerCore from '@ovh-ux/manager-core'; + +import routing from './telecom-telephony-guides.routing'; + +const moduleName = 'ovhManagerTelecomTelephonyBillingAccountGuides'; + +angular.module(moduleName, [ovhManagerCore]).config(routing); + +export default moduleName; diff --git a/packages/manager/apps/telecom/src/app/telecom/telephony/billingAccount/guides/telecom-telephony-guides.constants.js b/packages/manager/apps/telecom/src/app/telecom/telephony/billingAccount/guides/telecom-telephony-guides.constants.js new file mode 100644 index 000000000000..b06b36a1e40b --- /dev/null +++ b/packages/manager/apps/telecom/src/app/telecom/telephony/billingAccount/guides/telecom-telephony-guides.constants.js @@ -0,0 +1,111 @@ +export const GUIDES = { + sections: [ + { + label: 'telephony_guides_section_line', + guides: [ + { + label: 'telephony_guides_activate_services', + url: { + FR: + 'https://docs.ovh.com/fr/voip/activer-desactiver-services-depuis-telephone/', + }, + }, + { + label: 'telephony_guides_configure_call_forward', + url: { + FR: + 'https://docs.ovh.com/fr/voip/comment-configurer-les-renvois-d-appels/', + }, + }, + { + label: 'telephony_guides_configure_programmable_keys', + url: { + FR: + 'https://docs.ovh.com/fr/voip/configurer-touches-programmables/', + }, + }, + { + label: 'telephony_guides_configure_exceptionnal_closures', + url: { + FR: + 'https://docs.ovh.com/fr/voip/configurer-plages-horaires-fermetures-exceptionnelles-ligne/', + }, + }, + { + label: 'telephony_guides_configure_answering_machine', + url: { + FR: + 'https://docs.ovh.com/fr/voip/configurer-consulter-repondeur-ligne-ovh/', + }, + }, + { + label: 'telephony_guides_configure_click2call', + url: { + FR: 'https://docs.ovh.com/fr/voip/configurer-utiliser-click2call/', + }, + }, + { + label: 'telephony_guides_manage_abreviated_numbers', + url: { + FR: 'https://docs.ovh.com/fr/voip/gerer-numeros-abreges-ligne-sip/', + }, + }, + { + label: 'telephony_guides_manage_simultaneous_calling', + url: { + FR: + 'https://docs.ovh.com/fr/voip/gerer-utiliser-appels-simultanes/', + }, + }, + { + label: 'telephony_guides_manage_number_presentation', + url: { + FR: + 'https://docs.ovh.com/fr/voip/gerer-la-presentation-du-numero-sur-votre-ligne-sip/', + }, + }, + { + label: 'telephony_guides_import_phonebook', + url: { + FR: 'https://docs.ovh.com/fr/voip/importer_un_carnet_de_contacts/', + }, + }, + { + label: 'telephony_guides_intercom_mode', + url: { + FR: 'https://docs.ovh.com/fr/voip/mode-intercom/', + }, + }, + { + label: 'telephony_guides_update_sounds', + url: { + FR: + 'https://docs.ovh.com/fr/voip/modifier-musiques-sonneries-ligne/', + }, + }, + { + label: 'telephony_guides_restrict_sip_line', + url: { + FR: 'https://docs.ovh.com/fr/voip/restreindre-ligne-sip-par-ip/', + }, + }, + ], + }, + { + label: 'telephony_guides_section_phone_troubleshooting', + guides: [ + { + label: 'telephony_guides_phone_troubleshooting_pap', + url: { + FR: + 'https://docs.ovh.com/fr/voip/depannage-telephone-plug-and-phone/', + }, + }, + ], + }, + ], +}; + +export default { + GUIDES, +}; diff --git a/packages/manager/apps/telecom/src/app/telecom/telephony/billingAccount/guides/telecom-telephony-guides.controller.js b/packages/manager/apps/telecom/src/app/telecom/telephony/billingAccount/guides/telecom-telephony-guides.controller.js index b6aa00d50106..c060e7e1e8b7 100644 --- a/packages/manager/apps/telecom/src/app/telecom/telephony/billingAccount/guides/telecom-telephony-guides.controller.js +++ b/packages/manager/apps/telecom/src/app/telecom/telephony/billingAccount/guides/telecom-telephony-guides.controller.js @@ -1,43 +1,48 @@ -import flatten from 'lodash/flatten'; -import map from 'lodash/map'; +import { GUIDES } from './telecom-telephony-guides.constants'; -import { Environment } from '@ovh-ux/manager-config'; +export default class TelecomTelephonyGuidesCtrl { + /* @ngInject */ + constructor(SessionService) { + this.SessionService = SessionService; + } -angular.module('managerApp').controller( - 'TelecomTelephonyGuidesCtrl', - class TelecomTelephonyGuidesCtrl { - constructor(TELEPHONY_GUIDES) { - this.constant = { TELEPHONY_GUIDES }; - } + $onInit() { + this.loading = { + init: true, + }; + this.guides = { sections: [] }; - $onInit() { - this.loading = { - init: false, - }; - this.guides = null; - this.language = null; - this.count = null; + this.SessionService.getUser().then(({ ovhSubsidiary }) => { + this.language = ovhSubsidiary; + + this.guides = { + sections: GUIDES.sections.reduce((sections, section) => { + const filteredSection = { + ...section, + guides: section.guides + .filter((guide) => guide.url[ovhSubsidiary]) + .map((guide) => ({ + ...guide, + url: guide.url[ovhSubsidiary], + })), + }; - this.guides = this.constant.TELEPHONY_GUIDES; - this.language = Environment.getUserLanguage(); - this.countGuides(); - } + if (filteredSection.guides.length > 0) { + return [...sections, filteredSection]; + } + return sections; + }, []), + }; - /** - * Count guides. - */ - countGuides() { - this.count = flatten( - map(this.guides.sections, (section) => section.guides), - ).length; - } + this.loading.init = false; + }); + } - /** - * Has guides helper. - * @return {Boolean} - */ - hasGuides() { - return this.count > 0; - } - }, -); + /** + * Has guides helper. + * @return {Boolean} + */ + hasGuides() { + return this.guides.sections.length > 0; + } +} diff --git a/packages/manager/apps/telecom/src/app/telecom/telephony/billingAccount/guides/telecom-telephony-guides.html b/packages/manager/apps/telecom/src/app/telecom/telephony/billingAccount/guides/telecom-telephony-guides.html index 8dd19ce68faa..4c0ffcbf4478 100644 --- a/packages/manager/apps/telecom/src/app/telecom/telephony/billingAccount/guides/telecom-telephony-guides.html +++ b/packages/manager/apps/telecom/src/app/telecom/telephony/billingAccount/guides/telecom-telephony-guides.html @@ -3,51 +3,45 @@ -
-
- - - +
+ + + -
-
-

-
-
- -
+ {{:: guide.label | translate }} + + + + + +
- - diff --git a/packages/manager/apps/telecom/src/app/telecom/telephony/billingAccount/guides/telecom-telephony-guides.js b/packages/manager/apps/telecom/src/app/telecom/telephony/billingAccount/guides/telecom-telephony-guides.routing.js similarity index 55% rename from packages/manager/apps/telecom/src/app/telecom/telephony/billingAccount/guides/telecom-telephony-guides.js rename to packages/manager/apps/telecom/src/app/telecom/telephony/billingAccount/guides/telecom-telephony-guides.routing.js index 19d3aee439e4..07d1f1a1175d 100644 --- a/packages/manager/apps/telecom/src/app/telecom/telephony/billingAccount/guides/telecom-telephony-guides.js +++ b/packages/manager/apps/telecom/src/app/telecom/telephony/billingAccount/guides/telecom-telephony-guides.routing.js @@ -1,14 +1,16 @@ -angular.module('managerApp').config(($stateProvider) => { +import controller from './telecom-telephony-guides.controller'; +import template from './telecom-telephony-guides.html'; + +export default /* @ngInject */ ($stateProvider) => { $stateProvider.state('telecom.telephony.billingAccount.guides', { url: '/guides', views: { 'groupInnerView@telecom.telephony.billingAccount': { - templateUrl: - 'app/telecom/telephony/billingAccount/guides/telecom-telephony-guides.html', - controller: 'TelecomTelephonyGuidesCtrl', + template, + controller, controllerAs: '$ctrl', }, }, translations: { value: ['.', '../guides'], format: 'json' }, }); -}); +}; diff --git a/packages/manager/apps/telecom/src/app/telecom/telephony/billingAccount/index.js b/packages/manager/apps/telecom/src/app/telecom/telephony/billingAccount/index.js index ff321802bdd7..8d77ee8a41d5 100644 --- a/packages/manager/apps/telecom/src/app/telecom/telephony/billingAccount/index.js +++ b/packages/manager/apps/telecom/src/app/telecom/telephony/billingAccount/index.js @@ -1,5 +1,6 @@ import angular from 'angular'; +import guides from './guides'; import services from './services'; import routing from './billingAccount.routing'; @@ -8,7 +9,7 @@ import service from './billingAccount.service'; const moduleName = 'ovhManagerTelecomTelephonyBillingAccount'; angular - .module(moduleName, [services]) + .module(moduleName, [guides, services]) .config(routing) .service('telecomBillingAccount', service); diff --git a/packages/manager/apps/telecom/src/app/telecom/telephony/telecom-telephony.constant.js b/packages/manager/apps/telecom/src/app/telecom/telephony/telecom-telephony.constant.js index 184641327707..505d7bd5a4a8 100644 --- a/packages/manager/apps/telecom/src/app/telecom/telephony/telecom-telephony.constant.js +++ b/packages/manager/apps/telecom/src/app/telecom/telephony/telecom-telephony.constant.js @@ -245,117 +245,7 @@ angular digits: [0, 1, 2, 3, 4, 5, 6, 7, 8, 9], }, }) - .constant('TELEPHONY_ALIAS_OBSOLETE_FEATURE_TYPES', ['easyPabx', 'miniPabx']) - .constant('TELEPHONY_GUIDES', { - sections: [ - { - label: 'telephony_guides_section_line', - guides: [ - { - label: 'telephony_guides_activate_services', - url: { - fr: - 'https://docs.ovh.com/fr/voip/activer-desactiver-services-depuis-telephone/', - }, - }, - { - label: 'telephony_guides_configure_call_forward', - url: { - fr: - 'https://docs.ovh.com/fr/voip/comment-configurer-les-renvois-d-appels/', - }, - }, - { - label: 'telephony_guides_configure_programmable_keys', - url: { - fr: - 'https://docs.ovh.com/fr/voip/configurer-touches-programmables/', - }, - }, - { - label: 'telephony_guides_configure_exceptionnal_closures', - url: { - fr: - 'https://docs.ovh.com/fr/voip/configurer-plages-horaires-fermetures-exceptionnelles-ligne/', - }, - }, - { - label: 'telephony_guides_configure_answering_machine', - url: { - fr: - 'https://docs.ovh.com/fr/voip/configurer-consulter-repondeur-ligne-ovh/', - }, - }, - { - label: 'telephony_guides_configure_click2call', - url: { - fr: - 'https://docs.ovh.com/fr/voip/configurer-utiliser-click2call/', - }, - }, - { - label: 'telephony_guides_manage_abreviated_numbers', - url: { - fr: - 'https://docs.ovh.com/fr/voip/gerer-numeros-abreges-ligne-sip/', - }, - }, - { - label: 'telephony_guides_manage_simultaneous_calling', - url: { - fr: - 'https://docs.ovh.com/fr/voip/gerer-utiliser-appels-simultanes/', - }, - }, - { - label: 'telephony_guides_manage_number_presentation', - url: { - fr: - 'https://docs.ovh.com/fr/voip/gerer-la-presentation-du-numero-sur-votre-ligne-sip/', - }, - }, - { - label: 'telephony_guides_import_phonebook', - url: { - fr: - 'https://docs.ovh.com/fr/voip/importer_un_carnet_de_contacts/', - }, - }, - { - label: 'telephony_guides_intercom_mode', - url: { - fr: 'https://docs.ovh.com/fr/voip/mode-intercom/', - }, - }, - { - label: 'telephony_guides_update_sounds', - url: { - fr: - 'https://docs.ovh.com/fr/voip/modifier-musiques-sonneries-ligne/', - }, - }, - { - label: 'telephony_guides_restrict_sip_line', - url: { - fr: 'https://docs.ovh.com/fr/voip/restreindre-ligne-sip-par-ip/', - }, - }, - ], - }, - { - label: 'telephony_guides_section_phone_troubleshooting', - guides: [ - { - label: 'telephony_guides_phone_troubleshooting_pap', - url: { - fr: - 'https://docs.ovh.com/fr/voip/depannage-telephone-plug-and-phone/', - }, - }, - ], - }, - ], - }); + .constant('TELEPHONY_ALIAS_OBSOLETE_FEATURE_TYPES', ['easyPabx', 'miniPabx']); export default { TELEPHONY_AVAILABILITY, diff --git a/packages/manager/apps/telecom/src/app/telecom/telephony/telephony.bundle.js b/packages/manager/apps/telecom/src/app/telecom/telephony/telephony.bundle.js index 8e72dd29bb0a..0b9587be528e 100644 --- a/packages/manager/apps/telecom/src/app/telecom/telephony/telephony.bundle.js +++ b/packages/manager/apps/telecom/src/app/telecom/telephony/telephony.bundle.js @@ -140,8 +140,6 @@ import './billingAccount/billingAccount.routing'; import './billingAccount/billingAccount.service'; import './billingAccount/dashboard/telecom-telephony-billing-account-dashboard.controller'; import './billingAccount/dashboard/telecom-telephony-billing-account-dashboard'; -import './billingAccount/guides/telecom-telephony-guides.controller'; -import './billingAccount/guides/telecom-telephony-guides'; import './billingAccount/index'; import './billingAccount/manageContacts/telecom-telephony-billing-account-manageContacts.controller'; import './billingAccount/manageContacts/telecom-telephony-billing-account-manageContacts';