Skip to content
This repository has been archived by the owner on Dec 13, 2022. It is now read-only.

enh(feature-switch): fully manage feature switch #10101

Merged
merged 4 commits into from
Sep 14, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions doc/API/centreon-api-v21.10.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -559,6 +559,10 @@ paths:
nullable: true
description: Locale of the current user
example: en_US
useDeprecatedPages:
type: boolean
description: Indicates if user wants to use deprecated monitoring pages
example: false
'403':
$ref: '#/components/responses/Forbidden'
'500':
Expand Down
11 changes: 10 additions & 1 deletion lang/fr_FR.UTF-8/LC_MESSAGES/help.po
Original file line number Diff line number Diff line change
Expand Up @@ -7238,4 +7238,13 @@ msgid ""
msgstr ""
"Non: Vous ne consentez pas à partager les informations de votre plateforme. Détails du Contact: Vous consentez"
"à partager les informations de votre plateforme, y compris votre alias et email. Anonymisé: Vous consentez à partager"
"les informations de votre plateforme, mais votre alias et votre email seront anonymisés."
"les informations de votre plateforme, mais votre alias et votre email seront anonymisés."

msgid ""
"If checked this option will restore the use of the deprecated pages."
"This includes display of the deprecated pages and internal redirections between pages"
"If not checked this option will enable the full use of the new Monitoring page Resource Status"
msgstr ""
"Si l'option est activée l'utilisation des pages dépréciées sera totalement rétablie"
"Cela inclu: l'affichage des pages mais également toutes les redirections entre pages dépréciées"
"Si l'option n'est pas activée l'utilisation de la nouvelle page de Monitoring Resource Status sera pleinement activée"
4 changes: 2 additions & 2 deletions lang/fr_FR.UTF-8/LC_MESSAGES/messages.po
Original file line number Diff line number Diff line change
Expand Up @@ -15868,8 +15868,8 @@ msgstr "Erreur lors de la recherche d'hôtes et de modèles de service liés"
msgid "deprecated"
msgstr "déprécié"

msgid "Show deprecated pages"
msgstr "Afficher les pages dépréciées"
msgid "Use deprecated pages"
msgstr "Utiliser les pages dépréciées"

msgid "Error when adding services to the host %d"
msgstr "Erreur lors de l'ajout de services à l'hôte %d"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -862,6 +862,31 @@ public function buildServiceUri(int $hostId, int $serviceId, string $tab = self:
]);
}

/**
* Build uri to access meta service panel
*
* @param integer $metaId
* @param string $tab tab name
* @return string
*/
public function buildMetaServiceDetailsUri(int $metaId, string $tab = self::TAB_DETAILS_NAME): string
adr-mo marked this conversation as resolved.
Show resolved Hide resolved
{
if (!in_array($tab, static::ALLOWED_TABS)) {
throw new ResourceException(sprintf(_('Cannot build uri to unknown tab : %s'), $tab));
}

return $this->buildListingUri([
'details' => json_encode([
'parentType' => null,
'parentId' => null,
'type' => ResourceEntity::TYPE_META,
'id' => $metaId,
'tab' => $tab,
'uuid' => 'm' . $metaId
]),
]);
}

/**
* Build uri to access listing page of resources with specific parameters
*
Expand Down
3 changes: 2 additions & 1 deletion src/Centreon/Application/Controller/UserController.php
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,8 @@ public function getUserParameters(): View
'alias' => $user->getAlias(),
'email' => $user->getEmail(),
'timezone' => $user->getTimezone()->getName(),
'locale' => $user->getLocale()
'locale' => $user->getLocale(),
'use_deprecated_pages' => $user->isUsingDeprecatedPages()
]);
}

Expand Down
28 changes: 28 additions & 0 deletions src/Centreon/Domain/Contact/Contact.php
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,13 @@ class Contact implements UserInterface, ContactInterface
*/
private $defaultPage;

/**
* Indicates if user uses deprecated pages
*
* @var bool
*/
private $useDeprecatedPages;

/**
* @return int
*/
Expand Down Expand Up @@ -574,4 +581,25 @@ public function getDefaultPage(): ?Page
{
return $this->defaultPage;
}

/**
* Indicates if user uses deprecated pages
*
* @return bool
*/
public function isUsingDeprecatedPages()
{
return $this->useDeprecatedPages;
}

/**
* @param bool $useDeprecatedPages Indicates if user uses deprecated pages
* @return self
*/
public function setUseDeprecatedPages(bool $useDeprecatedPages)
{
$this->useDeprecatedPages = $useDeprecatedPages;

return $this;
}
}
6 changes: 4 additions & 2 deletions src/Centreon/Infrastructure/Contact/ContactRepositoryRDB.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
<?php

/*
* Copyright 2005 - 2019 Centreon (https://www.centreon.com/)
* Copyright 2005 - 2021 Centreon (https://www.centreon.com/)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -349,7 +350,8 @@ private function createContact(array $contact): Contact
->setAccessToApiConfiguration($contact['reach_api'] === '1')
->setTimezone(new \DateTimeZone($contactTimezoneName))
->setLocale($contactLocale)
->setDefaultPage($page);
->setDefaultPage($page)
->setUseDeprecatedPages($contact['show_deprecated_pages'] === '1');
}

/**
Expand Down
3 changes: 2 additions & 1 deletion www/include/Administration/myAccount/formMyAccount.ihtml
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@
</td>
</tr>
<tr class="list_two"><td class="FormRowField">{$form.default_page.label}</td><td class="FormRowValue">{$form.default_page.html}</td></tr>
<tr class="list_one"><td class="FormRowField">{$form.show_deprecated_pages.label}</td><td class="FormRowValue">{$form.show_deprecated_pages.html}</td></tr>
<tr class="list_one"><td class="FormRowField"><img class="helpTooltip" name="show_deprecated_pages">{$form.show_deprecated_pages.label}</td><td class="FormRowValue">{$form.show_deprecated_pages.html}</td></tr>
<tr class="list_two"><td class="FormRowField">{$form.contact_js_effects.label}</td><td class="FormRowValue">{$form.contact_js_effects.html}</td></tr>
<tr class="list_one"><td class="FormRowField"><img class="helpTooltip" name="contact_platform_data_sending">{$form.contact_platform_data_sending.label}</td><td class="FormRowValue">{$form.contact_platform_data_sending.html}</td></tr>
<tr class="list_lvl_1">
Expand Down Expand Up @@ -118,4 +118,5 @@
</div>
{$form.hidden}
</form>
{$helptext}

12 changes: 11 additions & 1 deletion www/include/Administration/myAccount/formMyAccount.php
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@
array('onclick' => 'generatePassword("aKey");', 'class' => 'btc bt_info')
);
$form->addElement('select', 'contact_lang', _("Language"), $langs);
$form->addElement('checkbox', 'show_deprecated_pages', _("Show deprecated pages"), null, $attrsText);
$form->addElement('checkbox', 'show_deprecated_pages', _("Use deprecated pages"), null, $attrsText);
$form->addElement('checkbox', 'contact_js_effects', _("Animation effects"), null, $attrsText);

$platformDataSendingRadios = [
Expand Down Expand Up @@ -466,6 +466,16 @@ function myReplace()
$tpl->assign('cct', $cct);
$tpl->assign('o', $o);
$tpl->assign('featuresFlipping', (count($features) > 0));

/*
* prepare help texts
*/
$helptext = "";
include_once("help.php");
foreach ($help as $key => $text) {
$helptext .= '<span style="display:none" id="help:' . $key . '">' . $text . '</span>' . "\n";
}
$tpl->assign("helptext", $helptext);
$tpl->display("formMyAccount.ihtml");
?>
<script type='text/javascript' src='./include/common/javascript/keygen.js'></script>
Expand Down
17 changes: 17 additions & 0 deletions www/include/Administration/myAccount/help.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<?php

$help = array();

$help["contact_platform_data_sending"] = dgettext(
"help",
"No: You don't consent to share your platform data. " .
"Contact Details: You consent to share your platform data including your alias and email. " .
"Anonymized: You consent to share your platform data, but your alias and email will be anonymized."
);

$help["show_deprecated_pages"] = dgettext(
"help",
"If checked this option will restore the use of the deprecated pages." .
"This includes display of the deprecated pages and internal redirection between pages" .
"If not checked this option will enable the full use of the new Monitoring page Resource Status"
);
29 changes: 23 additions & 6 deletions www/include/eventLogs/xml/data.php
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?php

/*
* Copyright 2005-2020 Centreon
* Copyright 2005-2021 Centreon
* Centreon is developed by : Julien Mathis and Romain Le Merlus under
* GPL Licence 2.0.
*
Expand Down Expand Up @@ -58,6 +58,12 @@
*/
$centreon = $_SESSION["centreon"];

/**
* true: URIs will correspond to deprecated pages
* false: URIs will correspond to new page (Resource Status)
*/
$useDeprecatedPages = $centreon->user->doesShowDeprecatedPages();

/**
* Language informations init
*/
Expand Down Expand Up @@ -887,19 +893,30 @@
}
$buffer->writeElement("service_description", $log["service_description"], false);
$buffer->writeElement("real_service_name", $log["service_description"], false);
$buffer->writeElement(
"s_timeline_uri",
$resourceController->buildServiceUri(

$serviceTimelineRedirectionUri = $useDeprecatedPages
? 'main.php?p=20201&amp;o=svcd&amp;host_name=' . $log['host_name'] . '&amp;service_description='
. $log['service_description']
: $resourceController->buildServiceUri(
$log['host_id'],
$log['service_id'],
$resourceController::TAB_TIMELINE_NAME
)
);

$buffer->writeElement(
"s_timeline_uri",
$serviceTimelineRedirectionUri
);
}
$buffer->writeElement("real_name", $log["host_name"], false);

$hostTimelineRedirectionUri = $useDeprecatedPages
? 'main.php?p=20202&amp;o=hd&amp;host_name=' . $log['host_name']
: $resourceController->buildHostUri($log['host_id'], $resourceController::TAB_TIMELINE_NAME);

$buffer->writeElement(
"h_timeline_uri",
$resourceController->buildHostUri($log['host_id'], $resourceController::TAB_TIMELINE_NAME)
$hostTimelineRedirectionUri
);
$buffer->writeElement("class", $tab_class[$cpts % 2]);
$buffer->writeElement("poller", $log["instance_name"]);
Expand Down
25 changes: 20 additions & 5 deletions www/include/monitoring/comments/listComment.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<?php

/*
* Copyright 2005-2020 Centreon
* Centreon is developed by : Julien Mathis and Romain Le Merlus under
Expand Down Expand Up @@ -81,6 +82,12 @@
$centreonGMT = new CentreonGMT($pearDB);
$centreonGMT->getMyGMTFromSession(session_id(), $pearDB);

/**
* true: URIs will correspond to deprecated pages
* false: URIs will correspond to new page (Resource Status)
*/
$useDeprecatedPages = $centreon->user->doesShowDeprecatedPages();

/*
* Smarty template Init
*/
Expand Down Expand Up @@ -155,12 +162,20 @@
$tab_comments_svc[$i]['data'],
['a', 'br', 'hr']
);
$tab_comments_svc[$i]['h_details_uri'] = $resourceController->buildHostDetailsUri($data['host_id']);
$tab_comments_svc[$i]['h_details_uri'] = $useDeprecatedPages
? 'main.php?p=20202&o=hd&host_name=' . $data['host_name']
: $resourceController->buildHostDetailsUri($data['host_id']);

if ($data['service_description'] != '') {
$tab_comments_svc[$i]['s_details_uri'] = $resourceController->buildServiceDetailsUri(
$data['host_id'],
$data['service_id']
);
$tab_comments_svc[$i]['s_details_uri'] = $useDeprecatedPages
? 'main.php?p=202&o=svcd&host_name='
. $data['host_name']
. '&service_description='
. $data['service_description']
: $resourceController->buildServiceDetailsUri(
$data['host_id'],
$data['service_id']
);
$tab_comments_svc[$i]['service_description'] = htmlentities($data['service_description'], ENT_QUOTES, 'UTF-8');
$tab_comments_svc[$i]['comment_type'] = 'SVC';
} else {
Expand Down
22 changes: 18 additions & 4 deletions www/include/monitoring/downtime/listDowntime.php
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
<?php

/*
* Copyright 2005-2019 Centreon
* Centreon is developped by : Julien Mathis and Romain Le Merlus under
* Copyright 2005-2021 Centreon
* Centreon is developed by : Julien Mathis and Romain Le Merlus under
* GPL Licence 2.0.
*
* This program is free software; you can redistribute it and/or modify it under
Expand Down Expand Up @@ -90,6 +91,12 @@
$centreonGMT = new CentreonGMT($pearDB);
$centreonGMT->getMyGMTFromSession(session_id(), $pearDB);

/**
* true: URIs will correspond to deprecated pages
* false: URIs will correspond to new page (Resource Status)
*/
$useDeprecatedPages = $centreon->user->doesShowDeprecatedPages();

include_once "./class/centreonDB.class.php";

$kernel = \App\Kernel::createForWeb();
Expand Down Expand Up @@ -223,9 +230,16 @@
}
} else {
$tab_downtime_svc[$i]['host_name'] = $data['host_name'];
$tab_downtime_svc[$i]['h_details_uri'] = $resourceController->buildHostDetailsUri($data['host_id']);
$tab_downtime_svc[$i]['h_details_uri'] = $useDeprecatedPages
? './main.php?p=20202&o=hd&host_name=' . $data['host_name']
: $resourceController->buildHostDetailsUri($data['host_id']);
if ($data['service_description'] !== '') {
$tab_downtime_svc[$i]['s_details_uri'] = $resourceController->buildServiceDetailsUri(
$tab_downtime_svc[$i]['s_details_uri'] = $useDeprecatedPages
? './main.php?p=202&o=svcd&host_name='
. $data['host_name']
. '&service_description='
. $data['service_description']
: $resourceController->buildServiceDetailsUri(
$data['host_id'],
$data['service_id']
);
Expand Down
Loading