mirror of
https://gitlab.ub.uni-bielefeld.de/sfb1288inf/nopaque.git
synced 2024-11-15 01:05:42 +00:00
Merge branch 'development' of gitlab.ub.uni-bielefeld.de:sfb1288inf/opaque into development
This commit is contained in:
commit
45a3c664a2
@ -33,7 +33,7 @@ class ResultsJSON {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// function creates a unique and safe filename for the download
|
// function creates a unique and safe filename for the download
|
||||||
createDownloadFilename() {
|
createDownloadFilename(suffix) {
|
||||||
let today;
|
let today;
|
||||||
let currentDate;
|
let currentDate;
|
||||||
let currentTime;
|
let currentTime;
|
||||||
@ -48,36 +48,28 @@ class ResultsJSON {
|
|||||||
`${today.getUTCMinutes()}m` +
|
`${today.getUTCMinutes()}m` +
|
||||||
`${today.getUTCSeconds()}s`;
|
`${today.getUTCSeconds()}s`;
|
||||||
safeFilename = this.query.replace(/[^a-z0-9_-]/gi, "_");
|
safeFilename = this.query.replace(/[^a-z0-9_-]/gi, "_");
|
||||||
resultFilename = `UTC-${currentDate}_${currentTime}_${safeFilename}`;
|
resultFilename = `UTC-${currentDate}_${currentTime}_${safeFilename}_${suffix}`;
|
||||||
return resultFilename
|
return resultFilename
|
||||||
}
|
}
|
||||||
|
|
||||||
// Function to download data as Blob created from string
|
// Function to download data as Blob created from string
|
||||||
// should be private but that is not yet a feature of javascript 08.04.2020
|
// should be private but that is not yet a feature of javascript 08.04.2020
|
||||||
download(downloadElem, dataStr, filename, type, filenameSlug) {
|
download(downloadElement, dataStr, filename, type, filenameSlug) {
|
||||||
let file;
|
|
||||||
console.log("Start Download!");
|
console.log("Start Download!");
|
||||||
|
let file;
|
||||||
filename += filenameSlug;
|
filename += filenameSlug;
|
||||||
file = new Blob([dataStr], {type: type});
|
file = new Blob([dataStr], {type: type});
|
||||||
if (window.navigator.msSaveOrOpenBlob) {// IE10+
|
|
||||||
window.navigator.msSaveOrOpenBlob(file, filename);
|
|
||||||
}
|
|
||||||
else { // Others
|
|
||||||
var url = URL.createObjectURL(file);
|
var url = URL.createObjectURL(file);
|
||||||
downloadElem.href = url;
|
downloadElement.href = url;
|
||||||
downloadElem.download = filename;
|
downloadElement.download = filename;
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// function to download the results as JSON
|
// function to download the results as JSON
|
||||||
downloadJSONRessource(resultFilename) {
|
downloadJSONRessource(resultFilename, downloadData, downloadElement) {
|
||||||
let dataStr;
|
let dataStr;
|
||||||
let downloadElement;
|
|
||||||
// stringify JSON object for json download
|
// stringify JSON object for json download
|
||||||
// use tabs to save some space
|
// use tabs to save some space
|
||||||
dataStr = JSON.stringify(results.resultsJSON, undefined, "\t");
|
dataStr = JSON.stringify(downloadData, undefined, "\t");
|
||||||
// get downloadResultsElement
|
|
||||||
downloadElement = document.getElementById("download-results-json");
|
|
||||||
// start actual download
|
// start actual download
|
||||||
this.download(downloadElement, dataStr, resultFilename, "text/json", ".json")
|
this.download(downloadElement, dataStr, resultFilename, "text/json", ".json")
|
||||||
}
|
}
|
||||||
|
@ -210,6 +210,7 @@ class ResultsList extends List {
|
|||||||
let uniqueS;
|
let uniqueS;
|
||||||
|
|
||||||
this.contextData = response.payload;
|
this.contextData = response.payload;
|
||||||
|
this.contextData["query"] = results.resultsJSON.query;
|
||||||
contextResultsElement = document.getElementById("context-results");
|
contextResultsElement = document.getElementById("context-results");
|
||||||
modalExpertModeSwitchElement = document.getElementById("inspect-display-options-form-expert_mode_inspect");
|
modalExpertModeSwitchElement = document.getElementById("inspect-display-options-form-expert_mode_inspect");
|
||||||
highlightSentencesSwitchElement = document.getElementById("inspect-display-options-form-highlight_sentences");
|
highlightSentencesSwitchElement = document.getElementById("inspect-display-options-form-highlight_sentences");
|
||||||
|
@ -260,7 +260,10 @@
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="modal-footer">
|
<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>
|
<a href="#!" class="modal-close waves-effect waves-light red btn">Close</a>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@ -300,6 +303,7 @@
|
|||||||
let displayOptionsData; // Getting form data from display options
|
let displayOptionsData; // Getting form data from display options
|
||||||
let displayOptionsFormElement; // Form holding the display informations
|
let displayOptionsFormElement; // Form holding the display informations
|
||||||
let downloadResultsJSONElement; // button for downloading results as JSON
|
let downloadResultsJSONElement; // button for downloading results as JSON
|
||||||
|
let downloadInspectContextElement; // button for downloading inspect context
|
||||||
let exportModal; // Download options modal
|
let exportModal; // Download options modal
|
||||||
let firstPageElement; // first page element of resultsList pagination
|
let firstPageElement; // first page element of resultsList pagination
|
||||||
let hitsPerPageInputElement;
|
let hitsPerPageInputElement;
|
||||||
@ -444,11 +448,19 @@
|
|||||||
queryResultsExportElement.onclick = () => {
|
queryResultsExportElement.onclick = () => {
|
||||||
exportModal.open();
|
exportModal.open();
|
||||||
}
|
}
|
||||||
|
|
||||||
// add onclick to download JSON button and download the file
|
// add onclick to download JSON button and download the file
|
||||||
downloadResultsJSONElement = document.getElementById("download-results-json")
|
downloadResultsJSONElement = document.getElementById("download-results-json")
|
||||||
downloadResultsJSONElement.onclick = () => {
|
downloadResultsJSONElement.onclick = () => {
|
||||||
let filename = results.resultsJSON.createDownloadFilename();
|
let filename = results.resultsJSON.createDownloadFilename("matches");
|
||||||
results.resultsJSON.downloadJSONRessource(filename)};
|
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>
|
</script>
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
|
Loading…
Reference in New Issue
Block a user