Skip to content

Commit

Permalink
fix(telephony.guides): display guides based on ovhSubsidiary (#3576)
Browse files Browse the repository at this point in the history
ref: MANAGER-5594

Signed-off-by: Cyrille Bourgois <[email protected]>
  • Loading branch information
Cyrille Bourgois authored and marie-j committed Sep 4, 2020
1 parent f1a7b88 commit b02aac2
Show file tree
Hide file tree
Showing 8 changed files with 212 additions and 200 deletions.
Original file line number Diff line number Diff line change
@@ -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;
Original file line number Diff line number Diff line change
@@ -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,
};
Original file line number Diff line number Diff line change
@@ -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;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,51 +3,45 @@
<oui-spinner></oui-spinner>
</div>

<div class="row" data-ng-if="!$ctrl.loading.init">
<div class="col-md-6">
<oui-message data-type="info" data-ng-if="!$ctrl.hasGuides()">
<span data-translate="telephony_guides_empty"></span>
</oui-message>
<div data-ng-if="!$ctrl.loading.init">
<oui-message data-type="info" data-ng-if="!$ctrl.hasGuides()">
<span data-translate="telephony_guides_empty"></span>
</oui-message>

<section
class="widget-presentation"
data-ng-if="$ctrl.hasGuides()"
data-ng-repeat="section in $ctrl.guides.sections track by section.label"
>
<header class="widget-presentation-header">
<h2
class="widget-presentation-title"
data-translate="{{:: section.label }}"
></h2>
</header>
<ul>
<li
data-ng-repeat="guide in section.guides track by guide.label"
<section
class="widget-presentation"
data-ng-if="$ctrl.hasGuides()"
data-ng-repeat="section in $ctrl.guides.sections track by section.label"
>
<header class="widget-presentation-header">
<h2
class="widget-presentation-title"
data-translate="{{:: section.label }}"
></h2>
</header>
<ul>
<li
data-ng-repeat="guide in section.guides track by guide.label"
>
<a
title="{{:: guide.label | translate }} ({{:: 'common_open_new_tab' | translate }})"
target="_blank"
rel="noopener"
data-ng-href="{{:: guide.url }}"
>
<a
title="{{ guide.label | translate }} ({{:: 'common_open_new_tab' | translate }})"
target="_blank"
rel="noopener"
data-ng-if="guide.url[$ctrl.language]"
data-ng-href="{{ guide.url[$ctrl.language] }}"
>
<span>{{:: guide.label | translate }}</span>
<span
class="oui-icon oui-icon-external-link"
aria-hidden="true"
></span>
<span
class="sr-only"
data-translate="common_open_new_tab"
aria-hidden="true"
></span>
</a>
</li>
</ul>
</section>
<!-- /.widget-presentation -->
</div>
<span>{{:: guide.label | translate }}</span>
<span
class="oui-icon oui-icon-external-link"
aria-hidden="true"
></span>
<span
class="sr-only"
data-translate="common_open_new_tab"
aria-hidden="true"
></span>
</a>
</li>
</ul>
</section>
</div>
<!-- /.row -->
</section>
<!-- /.telecom-telephony-guides -->
Original file line number Diff line number Diff line change
@@ -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: {
'[email protected]': {
templateUrl:
'app/telecom/telephony/billingAccount/guides/telecom-telephony-guides.html',
controller: 'TelecomTelephonyGuidesCtrl',
template,
controller,
controllerAs: '$ctrl',
},
},
translations: { value: ['.', '../guides'], format: 'json' },
});
});
};
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import angular from 'angular';

import guides from './guides';
import services from './services';

import routing from './billingAccount.routing';
Expand All @@ -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);

Expand Down
Loading

0 comments on commit b02aac2

Please sign in to comment.