diff --git a/setup.php b/setup.php index 9505e77f..e90dc20a 100644 --- a/setup.php +++ b/setup.php @@ -196,6 +196,7 @@ function plugin_version_carbon() 'author' => 'Teclib\'', 'license' => 'GPLv3', 'homepage' => '', + 'csp_compliant' => true, 'requirements' => [ 'glpi' => [ 'min' => PLUGIN_CARBON_MIN_GLPI_VERSION, diff --git a/src/Config.php b/src/Config.php index 043657e8..63bd1a98 100644 --- a/src/Config.php +++ b/src/Config.php @@ -45,7 +45,6 @@ use GlpiPlugin\Carbon\DataSource\Lca\ClientFactory as LcaClientFactory; use GlpiPlugin\Carbon\Impact\Embodied\Engine; use GuzzleHttp\Client; -use Html; use Monitor as GlpiMonitor; use NetworkEquipment as GlpiNetworkEquipment; use Override; @@ -132,8 +131,8 @@ public function showForm($ID, $options = []) '_glpi_csrf_token' => Session::getNewCSRFToken(), 'reset_all' => '', ]); - $usage_impact_action_url = 'submitGetLink("' . $CFG_GLPI['root_doc'] . '/plugins/carbon/front/usageimpact.form.php", ' . $reset_args . ')'; - $embodied_impact_action_url = 'submitGetLink("' . $CFG_GLPI['root_doc'] . '/plugins/carbon/front/embodiedimpact.form.php", ' . $reset_args . ')'; + $usage_impact_action_url = $CFG_GLPI['root_doc'] . '/plugins/carbon/front/usageimpact.form.php'; + $embodied_impact_action_url = $CFG_GLPI['root_doc'] . '/plugins/carbon/front/embodiedimpact.form.php'; $renderer = TemplateRenderer::getInstance(); $environment = $renderer->getEnvironment(); @@ -147,8 +146,10 @@ public function showForm($ID, $options = []) 'impact_engines' => Engine::getAvailableBackends(), 'include_configs' => $include_configs, 'action' => (isset($options['plugin_config']) ? Config::getFormURL() : GlpiConfig::getFormURL()), - 'usage_impact_action_url' => Html::getConfirmationOnActionScript($confirm_message, $usage_impact_action_url), - 'embodied_impact_action_url' => Html::getConfirmationOnActionScript($confirm_message, $embodied_impact_action_url), + 'confirm_message' => $confirm_message, + 'reset_args' => $reset_args, + 'usage_impact_action_url' => $usage_impact_action_url, + 'embodied_impact_action_url' => $embodied_impact_action_url, ]); return true; diff --git a/src/Source_Zone.php b/src/Source_Zone.php index a3d7fd07..dbe20eba 100644 --- a/src/Source_Zone.php +++ b/src/Source_Zone.php @@ -211,6 +211,11 @@ public static function showForSource(CommonDBTM $item) reloadTab(); }); }; + document.querySelectorAll("[data-carbon-toggle-zone]").forEach(function (button) { + button.addEventListener("click", function () { + plugin_carbon_toggleZone(button.dataset.carbonToggleZone); + }); + }); '); } } @@ -314,6 +319,11 @@ public static function showForZone(CommonDBTM $item) reloadTab(); }); }; + document.querySelectorAll("[data-carbon-toggle-zone]").forEach(function (button) { + button.addEventListener("click", function () { + plugin_carbon_toggleZone(button.dataset.carbonToggleZone); + }); + }); '); } } @@ -428,7 +438,7 @@ public function getFallbackFromDB(Source_Zone $source_zone): bool protected static function getToggleLink(int $zone_id, ?string $state): string { $state = $state == 0 ? __('No') : __('Yes'); - $link = '' . $state . ''; + $link = ''; return $link; } diff --git a/templates/config.html.twig b/templates/config.html.twig index 3f688a71..bb5124a7 100644 --- a/templates/config.html.twig +++ b/templates/config.html.twig @@ -79,8 +79,10 @@