Skip to content

Commit

Permalink
fixup! Fixes #24829: Replace compliance chart with Score chart and an…
Browse files Browse the repository at this point in the history
…d new details score charts

Fixes #24829: Replace compliance chart with Score chart and and new details score charts
  • Loading branch information
VinceMacBuche committed May 7, 2024
1 parent a646b03 commit 2547044
Show file tree
Hide file tree
Showing 2 changed files with 65 additions and 31 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -192,11 +192,11 @@ function homePage (
$("#scoreBreakdown .node-charts").append(
`<div class="node-chart">
<h4 class="text-center">${score.name}</h4>
<canvas id="score${score.scoreId}" > </canvas>
<div id="score${score.scoreId}-legend"></div>
<canvas id="score-${score.scoreId}" > </canvas>
<div id="score-${score.scoreId}-legend"></div>
</div>`)
var complianceHColors = score.data.colors.map(x => complianceHoverColors[x]);
doughnutChart('score'+ score.scoreId, score.data, score.count, score.data.colors, complianceHColors);
doughnutChart('score-'+ score.scoreId, score.data, score.count, score.data.colors, complianceHColors);
})

initBsTooltips();
Expand Down Expand Up @@ -325,20 +325,18 @@ function doughnutChart (id,data,count,colors,hoverColors) {
}];
break;
case 'nodeCompliance':
var compliance = {
"Poor" : {min: 0, max: 50}
,"Average": {min: 50, max: 75}
,"Good" : {min: 75, max: 100}
,"Perfect": {min: 100}
,"Applying": {applying: true}
};
var interval = compliance[data.split(' ')[0]];
var complianceFilter = {complianceFilter:interval};
window.location = contextPath + "/secure/nodeManager/nodes#" + JSON.stringify(complianceFilter);
var filter = {score:data};
window.location = contextPath + "/secure/nodeManager/nodes#" + JSON.stringify(filter);
return;

default:
return;
if (id.startsWith("score-")) {
var scoreId = id.substring(6)
var filter = {scoreDetails:{[scoreId]:data}};
window.location = contextPath + "/secure/nodeManager/nodes#" + JSON.stringify(filter);
return;
} else
return;
}
var url = contextPath + "/secure/nodeManager/searchNodes#" + JSON.stringify(query);
window.location = url;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,35 +72,45 @@ $.fn.dataTable.ext.search.push(
var param = decodeURIComponent(window.location.hash.substring(1));
if (param !== "" && window.location.pathname === contextPath + "/secure/nodeManager/nodes") {
var obj = JSON.parse(param);
var min = obj.complianceFilter.min;
var max = obj.complianceFilter.max;
var applying = obj.complianceFilter.applying;
var score = obj.score

if (min === undefined && !applying)
return true;

console.log(score)
console.log(settings.aoColumns)
// look for the compliance column
var complianceCol = settings.aoColumns.find(a => a.data == "compliance");

if (complianceCol !== undefined) {
var result = true
if (score !== undefined) {
var complianceCol = settings.aoColumns.find(a => a.data == "score.score");
// here, we get the id of the row element by looking deep inside settings...
// maybe there exists something cleaner.
// we get a string, rather than an array
if ( complianceCol !== undefined) {
var complianceString = data[complianceCol.idx];
if (complianceString !== undefined) {
result = score === complianceString
}
}
}


var complianceString = data[complianceCol.idx];
if (complianceString !== undefined) {
if (applying) {
return isApplyingFromComplianceString(complianceString);
} else {
var compliance = computeCompliancePercentFromString(complianceString);
var scoreDetails = obj.scoreDetails
if (scoreDetails !== undefined) {
for (const [scoreId, value] of Object.entries(scoreDetails)) {

if (max === undefined)
return compliance >= min;
else
return compliance >= min && compliance < max;
var complianceCol = settings.aoColumns.find(a => a.value == scoreId);
// here, we get the id of the row element by looking deep inside settings...
// maybe there exists something cleaner.
// we get a string, rather than an array
if ( complianceCol !== undefined) {
var complianceString = data[complianceCol.idx];
if (complianceString !== undefined) {
result = result && value === complianceString
}
}
}
}
return result
}
return true;
});
Expand Down Expand Up @@ -1429,6 +1439,32 @@ function createNodeTable(gridId, refresh) {
var colTitle = columns.map(function(c) { return c.title})
dynColumns = allColumnsKeys.filter(function(c) { return !(colTitle.includes(c))})

var param = decodeURIComponent(window.location.hash.substring(1));
if (param !== "") {
try {
var obj = JSON.parse(param);
var score = obj.score
if (score !== undefined) {
var scoreColumn = columns.find(a => a.data == "score.score");
if (scoreColumn === undefined) {
columns.push(allColumns["Score"])
}
}


var scoreDetails = obj.scoreDetails
if (scoreDetails !== undefined) {
for (const [scoreId, value] of Object.entries(scoreDetails)) {
var scoreColumn = columns.find(a => a.value == scoreId);
if (scoreColumn === undefined) {
columns.push(allColumns["Score details"](scoreId))
}
}
}
} catch(e) {

}
}
var params = {
"filter" : true
, "paging" : true
Expand Down

0 comments on commit 2547044

Please sign in to comment.