Added a download button to GUI in order to download reports easily

This commit is contained in:
marvindoering 2021-02-14 18:15:23 +01:00
parent 7ff5287a23
commit 65a988f13b
2 changed files with 16 additions and 1 deletions

View file

@ -13,7 +13,7 @@ View [validator configuration](/server/config) or <a href="/server/health" targe
<div>
<label for="file">Choose a file</label>
<input type="file" id="file" name="myFile">
<input type="submit" id="submit" value="Validate" onclick="return validate();">
<input type="submit" id="submit" value="Validate" onclick="return validate();"><input type="button" id="dwn-btn" value="Download Report" onclick="return reporting();">
</div>
<div id="result"></div>
</form>

View file

@ -40,6 +40,7 @@
<body>
<script type="text/javascript">
var report;
var validate = function () {
const input = document.getElementById('file');
@ -62,6 +63,20 @@
return false;
};
var reporting = function() {
var filename = "report.html";
var element = document.createElement('a');
element.setAttribute('href', 'data:text/plain;charset=utf-8,' + encodeURIComponent(report));
element.setAttribute('download', filename);
element.style.display = 'none';
document.body.appendChild(element);
element.click();
document.body.removeChild(element);
}
</script>