Skip to content

Commit

Permalink
qtip possible everywhere
Browse files Browse the repository at this point in the history
  • Loading branch information
proost committed Mar 31, 2017
1 parent 6b0fd87 commit 542a808
Show file tree
Hide file tree
Showing 9 changed files with 78 additions and 7 deletions.
13 changes: 13 additions & 0 deletions planet/controllers/sequence.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,19 @@ def sequence_view(sequence_id):
)


@sequence.route('/tooltip/<sequence_id>')
@cache.cached()
def sequence_tooltip(sequence_id):
"""
Get a sequence based on the ID and show the details for this sequence
:param sequence_id: ID of the sequence
"""
current_sequence = Sequence.query.get_or_404(sequence_id)

return render_template('tooltips/sequence.html', sequence=current_sequence)


@sequence.route('/modal/coding/<sequence_id>')
def sequence_modal_coding(sequence_id):
"""
Expand Down
2 changes: 1 addition & 1 deletion planet/models/expression/profiles.py
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ def get_heatmap(species_id, probes):
else:
values[o] = log(values[o]/row_mean, 2)

output.append({"name": name, "values": values})
output.append({"name": name, "values": values, "sequence_id": profile.sequence_id})

return {'order': order, 'heatmap_data': output}

Expand Down
3 changes: 2 additions & 1 deletion planet/models/trees.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,8 @@ class Tree(db.Model):
id = db.Column(db.Integer, primary_key=True)

label = db.Column(db.String(50, collation=SQL_COLLATION), index=True)
data = db.Column(db.Text)
data_newick = db.Column(db.Text)
data_phyloxml = db.Column(db.Text)

method_id = db.Column(db.Integer, db.ForeignKey('tree_methods.id'), index=True)
cluster_id = db.Column(db.Integer, db.ForeignKey('coexpression_clusters.id'), index=True)
2 changes: 1 addition & 1 deletion planet/templates/admin/add/sequence_descriptions.html
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

{% block body %}
{% if form %}
<h1>Add XRefs <small>(to sequences)</small></h1>
<h1>Add Descriptions <small>(to sequences)</small></h1>
<div class="row">
<div class="col-lg-8 col-md-8 col-sm-6 col-xs-12">
<form method="POST" action="{{ url_for('admin_controls.add_descriptions') }}" role="form" enctype="multipart/form-data">
Expand Down
38 changes: 38 additions & 0 deletions planet/templates/base.html
Original file line number Diff line number Diff line change
Expand Up @@ -161,8 +161,46 @@
<script src="{{ url_for('static', filename='js/planet_loader.js') }}"></script>
<script src="{{ url_for('static', filename='js/planet_pagination.js') }}"></script>
<script src="{{ url_for('static', filename='js/planet_ajax_table.js') }}"></script>
<script src="{{ url_for('static', filename='js/jquery.qtip.min.js') }}"></script>
<!-- code to reload modal on each click -->
<script>
$(function () {
$('.qtip_tooltip').each(function() {
$(this).qtip({
content: {
text: function(event, api) {
$.ajax({
url: api.elements.target.attr('qtip_href')
})
.then(function(content) {
// Set the tooltip content upon successful retrieval
api.set('content.text', content);
}, function(xhr, status, error) {
// Upon failure... set the tooltip content to error
api.set('content.text', status + ': ' + error);
});

return 'Loading...'; // Set some initial text
}
},
show: {
effect: function() {
$(this).fadeTo(500, 1);
}
},
hide: {
effect: function() {
$(this).fadeTo(500, 0);
}
},
position: {
viewport: $(window)
},
style: 'qtip-bootstrap'
});
});
});

$(function () {

$("#leafy_loader").html(get_loader_svg('loader_leafy'));
Expand Down
2 changes: 0 additions & 2 deletions planet/templates/expression_graph.html
Original file line number Diff line number Diff line change
Expand Up @@ -372,8 +372,6 @@ <h4 class="modal-title" id="imageModalLabel"><strong>Export Image</strong></h4>
<script src="{{ url_for('static', filename='js/cytoscape.min.js') }}"></script>

<!--<script src="{{ url_for('static', filename='js/cytoscape-cose-bilkent.js') }}"></script>-->

<script src="{{ url_for('static', filename='js/jquery.qtip.min.js') }}"></script>
<script src="{{ url_for('static', filename='js/cytoscape-qtip.js') }}"></script>
<script src="{{ url_for('static', filename='js/planet_graph.js') }}"></script>
<script>
Expand Down
8 changes: 7 additions & 1 deletion planet/templates/expression_heatmap.html
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,13 @@ <h1>Heatmap</h1>
<tbody>
{% for p in profiles %}
<tr class="heatmap">
<td>{{ p.name }}</td>
{% if p.sequence_id %}
<td><a href="{{ url_for('sequence.sequence_view', sequence_id=p.sequence_id) }}"
class="qtip_tooltip"
qtip_href="{{ url_for('sequence.sequence_tooltip', sequence_id=p.sequence_id) }}">{{ p.name }}</a></td>
{% else %}
<td>{{ p.name }}</td>
{% endif %}
{% for o in order %}
<td class="value">{{ p['values'][o]|round(2) }}</td>
{% endfor %}
Expand Down
11 changes: 11 additions & 0 deletions planet/templates/tooltips/sequence.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<div>
{% if sequence.aliases %}
<div><strong>Aliases: </strong>{{ sequence.aliases }}</div>
<hr />
{% endif %}
{% if sequence.description %}
<div><strong>Description: </strong>{{ sequence.description }}</div>
{% else %}
<div><em class="text-muted">No description available</em></div>
{% endif %}
</div>
6 changes: 5 additions & 1 deletion tests/website.py
Original file line number Diff line number Diff line change
Expand Up @@ -252,6 +252,10 @@ def test_sequence(self):
self.assert_template_used('sequence.html')
self.assert200(response)

response = self.client.get("/sequence/tooltip/%d" % sequence.id)
self.assert_template_used('tooltips/sequence.html')
self.assert200(response)

response = self.client.get("/sequence/fasta/coding/%d" % sequence.id)
self.assert200(response)
data = response.data.decode("utf-8").strip()
Expand Down Expand Up @@ -678,7 +682,7 @@ def test_heatmap(self):
response = self.client.post('/heatmap/', data=dict(probes=profile.probe, species_id=profile.species_id))
self.assert_template_used('expression_heatmap.html')
self.assert200(response)
self.assertTrue('<td>' + profile.probe + '</td>' in response.data.decode('utf-8'))
self.assertTrue(profile.probe in response.data.decode('utf-8'))

response = self.client.get('/heatmap/cluster/%d' % cluster.id)
self.assert_template_used('expression_heatmap.html')
Expand Down

0 comments on commit 542a808

Please sign in to comment.