Skip to content

Commit

Permalink
Merge branch 'feat/network-security-dashboard' into UXCT-503-network-…
Browse files Browse the repository at this point in the history
…security-dashboard-feedback

Signed-off-by: Stephanie Moallic <[email protected]>
  • Loading branch information
Steffy29 authored and Stephanie Moallic committed Dec 6, 2023
2 parents 0e1b194 + 70dee84 commit a542bdb
Show file tree
Hide file tree
Showing 21 changed files with 268 additions and 39 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
export const ALLOWED_LANGUAGES = {
en: {
isDefault: true,
},
fr: {
isDefault: false,
},
};

export const BASE_URL_SURVEY = 'https://survey.ovh.com/index.php/116651?lang=';

export default { ALLOWED_LANGUAGES, BASE_URL_SURVEY };
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,19 @@ export const IP_MITIGATION_RULE_PROTOCOL_PORT = {
trackmaniaShootmania: { from: 2350, to: 2450 },
};

export const ALLOWED_LANGUAGES = {
en: {
isDefault: true,
},
fr: {
isDefault: false,
},
};

export const BASE_URL_SURVEY = 'https://survey.ovh.com/index.php/187648?lang=';

export default {
IP_MITIGATION_RULE_PROTOCOL_PORT,
ALLOWED_LANGUAGES,
BASE_URL_SURVEY,
};
Original file line number Diff line number Diff line change
@@ -1,8 +1,13 @@
import isObject from 'lodash/isObject';
import findIndex from 'lodash/findIndex';
import remove from 'lodash/remove';
import startCase from 'lodash/startCase';

import { IP_MITIGATION_RULE_PROTOCOL_PORT } from './ip-ip-firewall-game.constants';
import {
IP_MITIGATION_RULE_PROTOCOL_PORT,
ALLOWED_LANGUAGES,
BASE_URL_SURVEY,
} from './ip-ip-firewall-game.constants';

export default /* @ngInject */ function IpGameFirewallCtrl(
$location,
Expand All @@ -15,6 +20,7 @@ export default /* @ngInject */ function IpGameFirewallCtrl(
IpGameFirewall,
Alerter,
$q,
coreConfig,
) {
const self = this;
const alert = 'ip_game_firewall_alert';
Expand Down Expand Up @@ -84,6 +90,25 @@ export default /* @ngInject */ function IpGameFirewallCtrl(

self.loading = false;

function initializeUrlSurvey() {
// Get default language
const defaultLanguage = Object.keys(ALLOWED_LANGUAGES).find(
(key) => ALLOWED_LANGUAGES[key].isDefault,
);
const userLanguage = coreConfig.getUserLanguage();

const languageToUse = isObject(ALLOWED_LANGUAGES[userLanguage])
? userLanguage
: defaultLanguage;

// Get user
const user = coreConfig.getUser();

// Build url for survey link
const surveyUrl = `${BASE_URL_SURVEY}${languageToUse}&nic=${user.nichandle}`;
return surveyUrl;
}

self.getProtocoleText = function getProtocoleText(protocol) {
return startCase(protocol);
};
Expand Down Expand Up @@ -183,6 +208,8 @@ export default /* @ngInject */ function IpGameFirewallCtrl(
}

function init(params) {
self.surveyUrl = initializeUrlSurvey();

if (params) {
self.datas.selectedBlock = params.ipBlock.ipBlock;
self.datas.selectedIp = params.ip.ip;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,19 @@

<div data-ovh-alert="ip_game_firewall_alert"></div>

<div class="d-flex justify-content-end">
<a
class="btn btn-link"
target="_blank"
data-ng-href="{{ IpGameFirewallCtrl.surveyUrl }}"
data-oui-tooltip="{{:: 'ip_game_mitigation_like_this_tooltip' | translate }}"
data-oui-tooltip-placement="top"
>
<i class="oui-icon oui-icon-smiley-happy_concept mr-1"></i>
<span data-translate="ip_game_mitigation_like_this"></span>
</a>
</div>

<div class="d-flex justify-content-between">
<button
type="button"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
import get from 'lodash/get';
import isEmpty from 'lodash/isEmpty';
import isObject from 'lodash/isObject';
import set from 'lodash/set';
import transform from 'lodash/transform';
import union from 'lodash/union';

import { ALLOWED_LANGUAGES, BASE_URL_SURVEY } from './firewall.constant';
import { TRACKING_PREFIX } from '../list.constant';

export default /* @ngInject */ function IpFirewallCtrl(
Expand All @@ -21,6 +23,7 @@ export default /* @ngInject */ function IpFirewallCtrl(
Ip,
IpFirewall,
Validator,
coreConfig,
) {
const self = this;

Expand Down Expand Up @@ -58,6 +61,25 @@ export default /* @ngInject */ function IpFirewallCtrl(
self.denyMessage = null;
self.firewallStatus = null;

function initializeUrlSurvey() {
// Get default language
const defaultLanguage = Object.keys(ALLOWED_LANGUAGES).find(
(key) => ALLOWED_LANGUAGES[key].isDefault,
);
const userLanguage = coreConfig.getUserLanguage();

const languageToUse = isObject(ALLOWED_LANGUAGES[userLanguage])
? userLanguage
: defaultLanguage;

// Get user
const user = coreConfig.getUser();

// Build url for survey link
const surveyUrl = `${BASE_URL_SURVEY}${languageToUse}&nic=${user.nichandle}`;
return surveyUrl;
}

function paginate(pageSize, offset) {
self.rulesTable = self.rules.list.results.slice(
offset - 1,
Expand Down Expand Up @@ -117,6 +139,9 @@ export default /* @ngInject */ function IpFirewallCtrl(
function init(params) {
self.rulesLoadingError = null;
self.rules = null;

self.surveyUrl = initializeUrlSurvey();

if (params) {
self.selectedBlock = params.ipBlock.ipBlock;
self.selectedIp = params.ip.ip;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,19 @@
<span data-translate="ip_firewall_deny_part_2"></span>
</oui-message>

<div class="d-flex justify-content-end">
<a
class="btn btn-link"
target="_blank"
data-ng-href="{{ IpFirewallCtrl.surveyUrl }}"
data-oui-tooltip="{{:: 'ip_firewall_like_this_tooltip' | translate }}"
data-oui-tooltip-placement="top"
>
<i class="oui-icon oui-icon-smiley-happy_concept mr-1"></i>
<span data-translate="ip_firewall_like_this"></span>
</a>
</div>

<div class="d-flex justify-content-between">
<button
type="button"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -354,6 +354,8 @@
"ip_game_mitigation_back_link_title": "Gérer les IPs",
"ip_game_mitigation_rule_apply": "Valider",
"ip_game_mitigation_rule_cancel": "Annuler",
"ip_game_mitigation_like_this": "Vous aimez ?",
"ip_game_mitigation_like_this_tooltip": "Vous aimez cette page ? Faites nous part de vos remarques !",
"ip_firewall_fail": "Une erreur est survenue lors du chargement des informations du firewall",
"ip_firewall_edit_rule": "Modifier la règle",
"ip_firewall_remove_rule": "Supprimer la règle",
Expand Down Expand Up @@ -392,6 +394,8 @@
"ip_firewall_add_rule_fail": "Une erreur est survenue lors de l'ajout de la règle.",
"ip_firewall_close_message": "Fermer",
"ip_firewall_add_rule_confirm_button_text": "Ajouter",
"ip_firewall_like_this": "Vous aimez ?",
"ip_firewall_like_this_tooltip": "Vous aimez cette page ? Faites nous part de vos remarques !",
"ip_firewall_rule_apply": "Valider",
"ip_firewall_rule_cancel": "Annuler",
"ip_firewall_modify_title": "Modifier une règle",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { ListLayoutHelper } from '@ovh-ux/manager-ng-layout-helpers';
import controller from './network-security.controller';
import template from './network-security.html';

export default {
Expand All @@ -10,5 +11,6 @@ export default {
isTrafficActive: '<',
goTo: '<',
},
controller,
template,
};
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,21 @@ export const ENTITY = {
EVENT: 'event',
};

export default { API_PATH, PAGE_SIZE, ENTITY };
export const ALLOWED_LANGUAGES = {
en: {
isDefault: true,
},
fr: {
isDefault: false,
},
};

export const BASE_URL_SURVEY = 'https://survey.ovh.com/index.php/558299?lang=';

export default {
API_PATH,
PAGE_SIZE,
ENTITY,
ALLOWED_LANGUAGES,
BASE_URL_SURVEY,
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
import isObject from 'lodash/isObject';
import {
ALLOWED_LANGUAGES,
BASE_URL_SURVEY,
} from './network-security.constant';

export default class NetworkSecurityController {
/* @ngInject */
constructor(coreConfig, networkSecurityService) {
this.coreConfig = coreConfig;
this.networkSecurityService = networkSecurityService;
this.ALLOWED_LANGUAGES = ALLOWED_LANGUAGES;
this.BASE_URL_SURVEY = BASE_URL_SURVEY;
}

$onInit() {
// Get default language
const defaultLanguage = Object.keys(this.ALLOWED_LANGUAGES).find(
(key) => this.ALLOWED_LANGUAGES[key].isDefault,
);
const userLanguage = this.coreConfig.getUserLanguage();

const languageToUse = isObject(this.ALLOWED_LANGUAGES[userLanguage])
? userLanguage
: defaultLanguage;

// Get user
const user = this.coreConfig.getUser();

// Build url for survey link
this.surveyUrl = `${this.BASE_URL_SURVEY}${languageToUse}&nic=${user.nichandle}`;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,19 @@

<div data-ovh-alert="network_security_dashboard_alert"></div>

<div class="d-flex justify-content-end">
<a
class="btn btn-link"
target="_blank"
data-ng-href="{{ $ctrl.surveyUrl }}"
data-oui-tooltip="{{:: 'network_security_dashboard_like_this_tooltip' | translate }}"
data-oui-tooltip-placement="top"
>
<i class="oui-icon oui-icon-smiley-happy_concept mr-1"></i>
<span data-translate="network_security_dashboard_like_this"></span>
</a>
</div>

<oui-header-tabs>
<oui-header-tabs-item
active="$ctrl.isScrubbingCenterActive()"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import angular from 'angular';
import '@ovh-ux/ng-at-internet';
import '@ovh-ux/ng-ui-router-breadcrumb';
import '@ovh-ux/ui-kit';
import ovhManagerCore from '@ovh-ux/manager-core';

import { ListLayoutHelper } from '@ovh-ux/manager-ng-layout-helpers';
import { ApiV2ListHelper } from '@ovh-ux/manager-ng-apiv2-helper';
Expand All @@ -23,6 +24,7 @@ angular
scrubbingCenter,
traffic,
ApiV2ListHelper.moduleName,
ovhManagerCore,
])
.config(routing)
.component('networkSecurity', component)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,15 @@ export default class NetworkSecurityService {
this.PAGE_SIZE = PAGE_SIZE;
}

getTraffic(params) {
return this.Apiv2Service.httpApiv2({
method: 'get',
url: `/engine/api/v2${this.API_PATH}/traffic`,
params,
getAllTraffic({ cursor, params, pageSize }) {
return this.Apiv2Service.httpApiv2List(
{
url: `/engine/api/v2${this.API_PATH}/traffic`,
params,
},
{ cursor, size: pageSize },
).then((response) => {
return { ...response, data: response.data };
});
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ export default class ScrubbingCenterController extends AbstractCursorDatagridCon

selectService() {
this.selectedIp = null;
this.isEmpty = false;
this.isListEmpty = false;
this.isServiceSelected = false;
this.model = null;
if (this.service) {
Expand All @@ -111,7 +111,7 @@ export default class ScrubbingCenterController extends AbstractCursorDatagridCon
)
.then((data) => {
this.ipsList = data.map(({ ipBlock }) => ipBlock);
this.isEmpty = !this.ipsList.length;
this.isListEmpty = !this.ipsList.length;
this.selectedIp = this.ipsList;
this.getAllEvents();
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,13 +62,13 @@
</div>

<div
data-ng-if="$ctrl.isEmpty"
data-ng-if="$ctrl.isListEmpty"
class="text-center m-3"
data-translate="network_security_dashboard_empty_table"
></div>

<oui-datagrid
data-ng-if="!$ctrl.isEmpty"
data-ng-if="!$ctrl.isListEmpty"
id="{{ $ctrl.datagridId }}"
data-empty-placeholder="{{:: 'network_security_dashboard_empty_datagrid' | translate }}"
data-rows-loader="$ctrl.getItems($config)"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ export default /* @ngInject */ ($stateProvider) => {
},
resolve: {
breadcrumb: /* @ngInject */ ($translate) =>
$translate.instant('network_security_dashboard_title'),
$translate.instant('network_security_dashboard_breadcrumb'),
cursors: /* @ngInject */ ($transition$) => $transition$.params().cursors,
showStats: /* @ngInject */ (goTo) => (row) =>
goTo({
Expand Down
Loading

0 comments on commit a542bdb

Please sign in to comment.