Skip to content

Commit

Permalink
Merge pull request #214 from Honny1/distinguish-cpe-al-and-oval
Browse files Browse the repository at this point in the history
  • Loading branch information
Honny1 authored Oct 5, 2023
2 parents 1c3e3ff + 15fbcff commit 3745f7f
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 19 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,9 @@
</p>
</div>
{%- else -%}
<tr role="row">
<th class="pf-m-fit-content" role="rowheader" scope="row"><h1 class="pf-c-title pf-m-xl">Applicability checks:</h1></th>
</tr>
{% for key, platforms in platforms_dict.items() %}
{% if platforms %}
{% if key == 'profile_platforms' -%}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,13 @@ function show_evaluation_characteristics(self) { // eslint-disable-line no-unuse
}

function show_rule_detail(self) { // eslint-disable-line no-unused-vars
var rule_id = self.parentNode.parentNode.parentNode.getAttribute("rule-id").asJqueryComplaintId();
generate_oval_tree(self, "oval_tree_of_rule_" + rule_id); // eslint-disable-line no-undef
generate_oval_tree(self, "cpe_tree_of_rule_" + rule_id); // eslint-disable-line no-undef
generate_cpe_al(self, "cpe_al_tree_of_rule_profile_platforms_" + rule_id); // eslint-disable-line no-undef
generate_cpe_al(self, "cpe_al_tree_of_rule_group_platforms_" + rule_id); // eslint-disable-line no-undef
generate_cpe_al(self, "cpe_al_tree_of_rule_rule_platforms_" + rule_id); // eslint-disable-line no-undef

self.classList.toggle('pf-m-expanded');
const element_to_show = get_child_of_element_with_selector(
self.parentNode.parentNode.parentNode,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -100,20 +100,6 @@ const I = document.createElement("i");

// OVAL graph generation methods

window.addEventListener('load', () => {
var selector = "table[id=rule-table] tbody[rule-id] button[id=show_hide_rule_detail_button]";
var rule_buttons = document.querySelectorAll(selector);

rule_buttons.forEach(async item => {
var rule_id = await item.parentNode.parentNode.parentNode.getAttribute("rule-id").asJqueryComplaintId();
generate_oval_tree(item, "oval_tree_of_rule_" + rule_id); // eslint-disable-line no-undef
generate_oval_tree(item, "cpe_tree_of_rule_" + rule_id); // eslint-disable-line no-undef
generate_cpe_al(item, "cpe_al_tree_of_rule_profile_platforms_" + rule_id); // eslint-disable-line no-undef
generate_cpe_al(item, "cpe_al_tree_of_rule_group_platforms_" + rule_id); // eslint-disable-line no-undef
generate_cpe_al(item, "cpe_al_tree_of_rule_rule_platforms_" + rule_id); // eslint-disable-line no-undef
});
});

function get_base_of_tree(div_with_tree) {
const data = div_with_tree.getAttribute("data");
const tree_data = JSON.parse(data);
Expand All @@ -138,7 +124,11 @@ function generate_cpe_al(self, div_id_with_data) { // eslint-disable-line no-unu
}
const { tree_data, fragment, ul } = get_base_of_tree(div_with_tree);
if (tree_data !== undefined) {
ul.appendChild(get_CPL_AL_tree_node(tree_data));
const CPE_AL_tree_node = get_CPE_AL_tree_node(tree_data);
ul.appendChild(CPE_AL_tree_node);
if (tree_data.value == "true") {
CPE_AL_tree_node.firstChild.firstChild.click();
}
div_with_tree.appendChild(fragment);
div_with_tree.setAttribute("is_rendered", 'true');
}
Expand All @@ -155,14 +145,18 @@ function generate_oval_tree(self, div_id_with_oval_graph_data) { // eslint-disab
}
const { tree_data, fragment, ul } = get_base_of_tree(div_with_tree);
if (tree_data !== undefined) {
ul.appendChild(get_OVAL_tree_node(tree_data));
const OVAL_tree_node = get_OVAL_tree_node(tree_data);
ul.appendChild(OVAL_tree_node);
if (div_id_with_oval_graph_data.startsWith("cpe_tree") && tree_data.value == "true") {
OVAL_tree_node.firstChild.firstChild.click();
}
div_with_tree.appendChild(fragment);
div_with_tree.setAttribute("is_rendered", 'true');
}
});
}

function get_CPL_AL_tree_node(root) {
function get_CPE_AL_tree_node(root) {
if (root.node_type == 'frac-ref') {
return undefined;
}
Expand All @@ -177,7 +171,7 @@ function get_CPL_AL_tree_node(root) {
if (child.node_type == "frac-ref") {
fragment.appendChild(render_CPE_frac_ref(child));
} else {
fragment.appendChild(get_CPL_AL_tree_node(child));
fragment.appendChild(get_CPE_AL_tree_node(child));
}
}
ul.appendChild(fragment);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
{# SPDX-License-Identifier: LGPL-2.1-or-later #}
{% if rule.oval_definition -%}
<tr role="row">
<th class="pf-m-fit-content" role="rowheader" scope="row"><b>OVAL definition:</b></th>
<th class="pf-m-fit-content" role="rowheader" scope="row"><h1 class="pf-c-title pf-m-xl">OVAL definition:</h1></th>
</tr>
<tr role="row">
<th class="pf-m-fit-content" role="rowheader" scope="row"><p class="pf-c-table__text"><b>Definition ID:</b></p></th>
Expand Down

0 comments on commit 3745f7f

Please sign in to comment.