I am currently fighting with some modules and making them “Enable strict content security policy” compatible.
since script tags are not allowed and the CSP header also has no nonce for that. I did a little workaround providing the javascript by using a controller action:
public function kickstartAction()
{
$script = <<<EOD
var interval = setInterval(function () {
if (typeof icinga == 'undefined') return;
clearInterval(interval);
var modulname = "mapDatatype";
if (icinga.isLoadedModule(modulname)) {
icinga.modules.mapDatatype.initialize();
} else {
icinga.loadModule(modulname)
}
}, 10);
EOD;
ob_get_clean();
header("Content-type: application/javascript");
header('Pragma: public');
ob_clean();
flush();
echo $script;
exit;
}
}
I don’t know how the director implements data type hooks, but your form elements should be in a container with data-icinga-module set to mapDatatype.
Though, it’s currently set to map and the container resides somewhere where it shouldn’t, probably? Why is #col1 inside a dd tag? Looks like a nested column with a duplicate id to me.
with that change and the removal of the col1 the js code is no longer necessary, which is great, but the module.js → initialize is still not loaded again on ajax refresh.
Is there any javascript reattaching magic for icingaweb2?
I left the module-map in order to still use the css from the map module