Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
hub
ViralHostRangeDB
Commits
7245c58e
Commit
7245c58e
authored
Oct 09, 2019
by
Bryan BRANCOTTE
Browse files
ability to convert table to png while taking into account library limitations
parent
0c8837f7
Changes
3
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
src/viralhostrange/viralhostrangedb/static/js/html2png.js
0 → 100644
View file @
7245c58e
function
grid_host2png
(
filename
){
$
(
'
#grid_host
'
).
addClass
(
"
bg-white
"
);
$
(
"
#grid_container:not(.horizontal-col-header)
"
).
addClass
(
"
horizontal-col-header horizontal-col-header-html2png
"
);
$
(
"
#grid_container.hide-cols-with-no-infection
"
).
removeClass
(
"
hide-cols-with-no-infection
"
).
addClass
(
"
hide-cols-with-no-infection-html2png
"
);
$
(
"
#grid_container.hide-rows-with-no-infection
"
).
removeClass
(
"
hide-rows-with-no-infection
"
).
addClass
(
"
hide-rows-with-no-infection-html2png
"
);
html2canvas
(
document
.
querySelector
(
'
#grid_host
'
)).
then
(
function
(
canvas
)
{
var
link
=
document
.
createElement
(
'
a
'
);
if
(
typeof
link
.
download
===
'
string
'
)
{
link
.
href
=
canvas
.
toDataURL
();
link
.
download
=
filename
;
//Firefox requires the link to be in the body
document
.
body
.
appendChild
(
link
);
//simulate click
link
.
click
();
//remove the link when done
document
.
body
.
removeChild
(
link
);
$
(
'
#grid_host
'
).
removeClass
(
"
bg-white
"
);
$
(
"
#grid_container.horizontal-col-header-html2png
"
).
removeClass
(
"
horizontal-col-header horizontal-col-header-html2png
"
);
$
(
"
#grid_container.hide-cols-with-no-infection-html2png
"
).
addClass
(
"
hide-cols-with-no-infection
"
).
removeClass
(
"
hide-rows-with-no-infection-html2png
"
);
$
(
"
#grid_container.hide-rows-with-no-infection-html2png
"
).
addClass
(
"
hide-rows-with-no-infection
"
).
removeClass
(
"
hide-rows-with-no-infection-html2png
"
);
}
else
{
window
.
open
(
uri
);
}
});
}
\ No newline at end of file
src/viralhostrange/viralhostrangedb/templates/viralhostrangedb/browse.html
View file @
7245c58e
...
...
@@ -28,6 +28,12 @@
<i
class=
"fa fa-download"
></i>
{%trans "Download displayed data in a spreadsheet" %}
</button>
<button
class=
"dropdown-item"
type=
"button"
onclick=
"grid_host2png('file-name.png');"
>
<i
class=
"fa fa-image"
></i>
{%trans "Download displayed data as a figure" %}
</button>
<!-- <a class="dropdown-item disabled"-->
<!-- href="{% url 'viralhostrangedb:download_responses' %}"-->
<!-- >-->
...
...
@@ -69,6 +75,8 @@ var mem={};
{{block.super}}
<script
type=
"text/javascript"
src=
"{% sstatic '/js/browse.js' %}"
></script>
<script
type=
"text/javascript"
src=
"{% sstatic '/js/browse-sort.js' %}"
></script>
<script
src=
"https://cdnjs.cloudflare.com/ajax/libs/html2canvas/0.5.0-beta4/html2canvas.js"
></script>
<script
type=
"text/javascript"
src=
"{% sstatic '/js/html2png.js' %}"
></script>
{% endblock %}
{% block content %}
...
...
src/viralhostrange/viralhostrangedb/templates/viralhostrangedb/vh_detail.html
View file @
7245c58e
...
...
@@ -42,6 +42,12 @@ title="{% trans 'Open in the NCBI'%}">
<i
class=
"fa fa-download"
></i>
{%trans "Download displayed data in a spreadsheet" %}
</button>
<button
class=
"dropdown-item"
type=
"button"
onclick=
"grid_host2png('file-name.png');"
>
<i
class=
"fa fa-image"
></i>
{%trans "Download displayed data as a figure" %}
</button>
</div>
</div>
</div>
...
...
@@ -79,6 +85,8 @@ var detailed_kind="{{detailed_kind}}";
{{block.super}}
<script
type=
"text/javascript"
src=
"{% sstatic '/js/browse-sort.js' %}"
></script>
<script
type=
"text/javascript"
src=
"{% sstatic '/js/virus_or_host_detail.js' %}"
></script>
<script
src=
"https://cdnjs.cloudflare.com/ajax/libs/html2canvas/0.5.0-beta4/html2canvas.js"
></script>
<script
type=
"text/javascript"
src=
"{% sstatic '/js/html2png.js' %}"
></script>
{% endblock %}
{% block content%}
...
...
Bryan BRANCOTTE
@bbrancot
mentioned in issue
#68 (closed)
·
Oct 09, 2019
mentioned in issue
#68 (closed)
mentioned in issue #68
Toggle commit list
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment