Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
nopaque
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Monitor
Service Desk
Analyze
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
SFB 1288 - INF
nopaque
Commits
45a3c664
Commit
45a3c664
authored
4 years ago
by
Patrick Jentsch
Browse files
Options
Downloads
Plain Diff
Merge branch 'development' of gitlab.ub.uni-bielefeld.de:sfb1288inf/opaque into development
parents
565274fc
5dfaf517
No related branches found
No related tags found
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
app/static/js/nopaque.Results.js
+8
-16
8 additions, 16 deletions
app/static/js/nopaque.Results.js
app/static/js/nopaque.lists.js
+1
-0
1 addition, 0 deletions
app/static/js/nopaque.lists.js
app/templates/corpora/analyse_corpus.html.j2
+16
-4
16 additions, 4 deletions
app/templates/corpora/analyse_corpus.html.j2
with
25 additions
and
20 deletions
app/static/js/nopaque.Results.js
+
8
−
16
View file @
45a3c664
...
...
@@ -33,7 +33,7 @@ class ResultsJSON {
}
// function creates a unique and safe filename for the download
createDownloadFilename
()
{
createDownloadFilename
(
suffix
)
{
let
today
;
let
currentDate
;
let
currentTime
;
...
...
@@ -48,36 +48,28 @@ class ResultsJSON {
`
${
today
.
getUTCMinutes
()}
m`
+
`
${
today
.
getUTCSeconds
()}
s`
;
safeFilename
=
this
.
query
.
replace
(
/
[^
a-z0-9_-
]
/gi
,
"
_
"
);
resultFilename
=
`UTC-
${
currentDate
}
_
${
currentTime
}
_
${
safeFilename
}
`
;
resultFilename
=
`UTC-
${
currentDate
}
_
${
currentTime
}
_
${
safeFilename
}
_
${
suffix
}
`
;
return
resultFilename
}
// Function to download data as Blob created from string
// should be private but that is not yet a feature of javascript 08.04.2020
download
(
downloadElem
,
dataStr
,
filename
,
type
,
filenameSlug
)
{
let
file
;
download
(
downloadElement
,
dataStr
,
filename
,
type
,
filenameSlug
)
{
console
.
log
(
"
Start Download!
"
);
let
file
;
filename
+=
filenameSlug
;
file
=
new
Blob
([
dataStr
],
{
type
:
type
});
if
(
window
.
navigator
.
msSaveOrOpenBlob
)
{
// IE10+
window
.
navigator
.
msSaveOrOpenBlob
(
file
,
filename
);
}
else
{
// Others
var
url
=
URL
.
createObjectURL
(
file
);
downloadElem
.
href
=
url
;
downloadElem
.
download
=
filename
;
}
downloadElement
.
href
=
url
;
downloadElement
.
download
=
filename
;
}
// function to download the results as JSON
downloadJSONRessource
(
resultFilename
)
{
downloadJSONRessource
(
resultFilename
,
downloadData
,
downloadElement
)
{
let
dataStr
;
let
downloadElement
;
// stringify JSON object for json download
// use tabs to save some space
dataStr
=
JSON
.
stringify
(
results
.
resultsJSON
,
undefined
,
"
\t
"
);
// get downloadResultsElement
downloadElement
=
document
.
getElementById
(
"
download-results-json
"
);
dataStr
=
JSON
.
stringify
(
downloadData
,
undefined
,
"
\t
"
);
// start actual download
this
.
download
(
downloadElement
,
dataStr
,
resultFilename
,
"
text/json
"
,
"
.json
"
)
}
...
...
This diff is collapsed.
Click to expand it.
app/static/js/nopaque.lists.js
+
1
−
0
View file @
45a3c664
...
...
@@ -210,6 +210,7 @@ class ResultsList extends List {
let
uniqueS
;
this
.
contextData
=
response
.
payload
;
this
.
contextData
[
"
query
"
]
=
results
.
resultsJSON
.
query
;
contextResultsElement
=
document
.
getElementById
(
"
context-results
"
);
modalExpertModeSwitchElement
=
document
.
getElementById
(
"
inspect-display-options-form-expert_mode_inspect
"
);
highlightSentencesSwitchElement
=
document
.
getElementById
(
"
inspect-display-options-form-highlight_sentences
"
);
...
...
This diff is collapsed.
Click to expand it.
app/templates/corpora/analyse_corpus.html.j2
+
16
−
4
View file @
45a3c664
...
...
@@ -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 %}
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment