Add download for context data.

This commit is contained in:
Stephan Porada
2020-04-27 13:25:29 +02:00
parent 76e7d65017
commit 5dfaf51793
3 changed files with 25 additions and 20 deletions

View File

@ -260,7 +260,10 @@
</div>
</div>
<div class="modal-footer">
<a href="#!" class="left waves-effect waves-light btn disabled">Export</a>
<a id="inspect-download-context" class="left waves-effect waves-light btn">
Export Context
<i class="material-icons right">file_download</i>
</a>
<a href="#!" class="modal-close waves-effect waves-light red btn">Close</a>
</div>
</div>
@ -300,6 +303,7 @@
let displayOptionsData; // Getting form data from display options
let displayOptionsFormElement; // Form holding the display informations
let downloadResultsJSONElement; // button for downloading results as JSON
let downloadInspectContextElement; // button for downloading inspect context
let exportModal; // Download options modal
let firstPageElement; // first page element of resultsList pagination
let hitsPerPageInputElement;
@ -444,11 +448,19 @@
queryResultsExportElement.onclick = () => {
exportModal.open();
}
// add onclick to download JSON button and download the file
downloadResultsJSONElement = document.getElementById("download-results-json")
downloadResultsJSONElement.onclick = () => {
let filename = results.resultsJSON.createDownloadFilename();
results.resultsJSON.downloadJSONRessource(filename)};
let filename = results.resultsJSON.createDownloadFilename("matches");
results.resultsJSON.downloadJSONRessource(filename, results.resultsJSON, downloadResultsJSONElement
)};
// add onclick to download JSON button and download the file
downloadInspectContextElement = document.getElementById("inspect-download-context")
downloadInspectContextElement.onclick = () => {
let filename = results.resultsJSON.createDownloadFilename("context");
console.log(filename);
results.resultsJSON.downloadJSONRessource(filename, results.resultsList.contextData, downloadInspectContextElement);
};
</script>
{% endblock %}