- Fixed issue with download button not working.

- Set button to only be active once the document has been validated.
- Fixed issue where the report was simple text and not readable html.
This commit is contained in:
marvindoering 2021-02-15 09:19:50 +01:00
parent 65a988f13b
commit dbaeedcef3
2 changed files with 10 additions and 5 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="button" id="dwn-btn" value="Download Report" onclick="return reporting();">
<input type="button" id="submit" value="Validate" onclick="return validate();"><input type="button" id="dwn-btn" value="Download Report" onclick="return reporting();" disabled>
</div>
<div id="result"></div>
</form>

View file

@ -42,9 +42,10 @@
var report;
var validate = function () {
var validate = function validate() {
const input = document.getElementById('file');
const output = document.getElementById('result');
const download = document.getElementById('dwn-btn');
var headers = new Headers();
headers.append('Content-Type', 'application/xml');
@ -58,12 +59,16 @@
fetch('/', requestOptions)
.then(response => response.text())
.then(result => output.innerText = result)
.then(result => {
output.innerHTML = result;
report = result;
download.disabled = false;
})
.catch(error => output.innerText = result);
return false;
};
var reporting = function() {
var reporting = function reporting() {
var filename = "report.html";
var element = document.createElement('a');
@ -76,7 +81,7 @@
element.click();
document.body.removeChild(element);
}
};
</script>