Skip to content

Commit

Permalink
Merge pull request #43 from NickHarvey2/embeddedreport
Browse files Browse the repository at this point in the history
Embedded Report
  • Loading branch information
stevespringett committed Feb 4, 2018
2 parents 4860447 + fd4669d commit 4f37743
Showing 1 changed file with 20 additions and 5 deletions.
25 changes: 20 additions & 5 deletions sonar-dependency-check-plugin/src/main/resources/static/report.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,16 @@
window.registerExtension("dependencycheck/report", function(options) {
var isDisplayed = true;

if (!document.querySelector("style#dependency-check-report")) {
var style = document.createElement("style");
style.id = "dependency-check-report";
// WebKit hack :(
style.appendChild(document.createTextNode(""));
document.head.appendChild(style);
style.sheet.insertRule(".dependency-check-report-content {flex: 1 1 auto;}", 0);
style.sheet.insertRule(".dependency-check-report-container {display: flex; flex-direction: column;}", 0);
}

window.SonarRequest.getJSON("/api/measures/component", {
componentKey : options.component.key,
metricKeys : "report"
Expand All @@ -9,13 +19,11 @@ window.registerExtension("dependencycheck/report", function(options) {
var htmlString = response.component.measures.filter(measure => measure.metric === "report")[0].value;
var currentEl = options.el;
while (currentEl.id !== "container") {
currentEl.style.display = "flex";
currentEl.style.flex = "1 1 auto";
currentEl.style.flexDirection = "column";
currentEl.classList.add("dependency-check-report-content");
currentEl.classList.add("dependency-check-report-container");
currentEl = currentEl.parentElement;
}
currentEl.style.display = "flex";
currentEl.style.flexDirection = "column";
currentEl.classList.add("dependency-check-report-container");

var reportFrame = document.createElement("iframe");
reportFrame.sandbox.value = "allow-scripts allow-same-origin";
Expand All @@ -29,5 +37,12 @@ window.registerExtension("dependencycheck/report", function(options) {
return function() {
options.el.textContent = "";
var isDisplayed = false;
var currentEl = options.el;
while (currentEl.id !== "container") {
currentEl.classList.remove("dependency-check-report-content");
currentEl.classList.remove("dependency-check-report-container");
currentEl = currentEl.parentElement;
}
currentEl.classList.remove("dependency-check-report-container");
};
});

0 comments on commit 4f37743

Please sign in to comment.