-
Notifications
You must be signed in to change notification settings - Fork 39
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(interface): download report (#349)
- Loading branch information
1 parent
d8e73d1
commit 537e998
Showing
21 changed files
with
447 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -64,3 +64,4 @@ nsecure-result.json | |
vuln.json | ||
tmp/ | ||
dist/ | ||
reports |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,123 @@ | ||
.report--popup { | ||
min-width: 400px; | ||
padding: 40px; | ||
display: flex; | ||
flex-direction: column; | ||
} | ||
|
||
.report--popup>.title { | ||
height: 2px; | ||
background: #d3d3d387; | ||
margin: 0 10px; | ||
display: flex; | ||
align-items: center; | ||
justify-content: center; | ||
flex-shrink: 0; | ||
} | ||
|
||
.report--popup>.title>p { | ||
background: #f5f4f4; | ||
padding: 0 10px; | ||
font-family: "roboto"; | ||
font-weight: bold; | ||
letter-spacing: 1.2px; | ||
color: #255471; | ||
font-size: 20px; | ||
} | ||
|
||
.report--popup>form { | ||
display: flex; | ||
flex-direction: column; | ||
padding: 20px; | ||
padding-bottom: 0; | ||
} | ||
|
||
.report--popup>form label { | ||
color: #546884; | ||
margin-bottom: 8px; | ||
font-weight: 500; | ||
font-size: 18px; | ||
} | ||
|
||
.report--popup>form input { | ||
padding: 11px 6px; | ||
border: none; | ||
border-left: 4px solid #546884; | ||
margin-bottom: 10px; | ||
border-radius: 2px; | ||
box-shadow: 0px 3px 7px 1px rgba(0, 0, 0, 0.10); | ||
font-size: 16px; | ||
} | ||
|
||
.report--popup>form>button { | ||
border: none; | ||
padding: 8px; | ||
color: white; | ||
background: #43a82f; | ||
font-weight: bold; | ||
cursor: pointer; | ||
width: 120px; | ||
margin: auto; | ||
margin-top: 20px; | ||
font-size: 16px; | ||
border-radius: 4px; | ||
} | ||
|
||
.report--popup .spinner { | ||
width: 7px; | ||
height: 7px; | ||
display: inline-block; | ||
border-radius: 50%; | ||
margin-right: 10px; | ||
border: 3px solid white; | ||
animation: spinner-from 0.8s infinite linear alternate, spinner-to 1.6s infinite linear; | ||
} | ||
|
||
|
||
@keyframes spinner-from { | ||
0% { | ||
clip-path: polygon(50% 50%, 0 0, 50% 0%, 50% 0%, 50% 0%, 50% 0%, 50% 0%); | ||
} | ||
|
||
12.5% { | ||
clip-path: polygon(50% 50%, 0 0, 50% 0%, 100% 0%, 100% 0%, 100% 0%, 100% 0%); | ||
} | ||
|
||
25% { | ||
clip-path: polygon(50% 50%, 0 0, 50% 0%, 100% 0%, 100% 100%, 100% 100%, 100% 100%); | ||
} | ||
|
||
50% { | ||
clip-path: polygon(50% 50%, 0 0, 50% 0%, 100% 0%, 100% 100%, 50% 100%, 0% 100%); | ||
} | ||
|
||
62.5% { | ||
clip-path: polygon(50% 50%, 100% 0, 100% 0%, 100% 0%, 100% 100%, 50% 100%, 0% 100%); | ||
} | ||
|
||
75% { | ||
clip-path: polygon(50% 50%, 100% 100%, 100% 100%, 100% 100%, 100% 100%, 50% 100%, 0% 100%); | ||
} | ||
|
||
100% { | ||
clip-path: polygon(50% 50%, 50% 100%, 50% 100%, 50% 100%, 50% 100%, 50% 100%, 0% 100%); | ||
} | ||
} | ||
|
||
@keyframes spinner-to { | ||
0% { | ||
transform: scaleY(1) rotate(0deg); | ||
} | ||
|
||
49.99% { | ||
transform: scaleY(1) rotate(135deg); | ||
} | ||
|
||
50% { | ||
transform: scaleY(-1) rotate(0deg); | ||
} | ||
|
||
100% { | ||
transform: scaleY(-1) rotate(-135deg); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
// Import Internal Dependencies | ||
import { PopupTemplate } from "../../../popup/popup.js"; | ||
|
||
export class PopupReport { | ||
constructor(rootDependencyName) { | ||
this.rootDependencyName = rootDependencyName; | ||
} | ||
|
||
render() { | ||
const templateElement = document.getElementById("report-popup-template"); | ||
/** @type {HTMLElement} */ | ||
const clone = templateElement.content.cloneNode(true); | ||
const form = clone.querySelector("form"); | ||
clone.querySelector("#title").placeholder = `${this.rootDependencyName}'s report`; | ||
form.addEventListener("submit", (e) => { | ||
e.preventDefault(); | ||
|
||
form.querySelector(".spinner").classList.remove("hidden"); | ||
const title = form.querySelector("#title").value; | ||
const includesAllDeps = form.querySelector("#includesAllDeps").checked; | ||
|
||
fetch("/report", { | ||
method: "POST", | ||
body: JSON.stringify({ | ||
title, | ||
includesAllDeps | ||
}) | ||
}).then(async(response) => { | ||
const { data: json } = await response.json(); | ||
const url = window.URL.createObjectURL( | ||
new Blob( | ||
[new Uint8Array(json.data).buffer], { type: "application/pdf" } | ||
) | ||
); | ||
const link = document.createElement("a"); | ||
link.href = url; | ||
link.target = "_blank"; | ||
link.download = `${title}.pdf`; | ||
document.body.appendChild(link); | ||
link.click(); | ||
}).finally(() => { | ||
form.querySelector(".spinner").classList.add("hidden"); | ||
}); | ||
}, { once: true }); | ||
|
||
return new PopupTemplate( | ||
"report", | ||
clone | ||
); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.