Skip to content

Commit

Permalink
Merge pull request #156 from ivanyu/ivanyu/gh-154-cut-str-repr-in-obj…
Browse files Browse the repository at this point in the history
…ect-view

ui: cut str_repr in object view
  • Loading branch information
ivanyu authored Nov 13, 2022
2 parents 93bdd44 + 402a048 commit c35ba95
Showing 1 changed file with 16 additions and 1 deletion.
17 changes: 16 additions & 1 deletion pyheap-ui/src/pyheap_ui/templates/objects.html
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,14 @@
<p><strong>Type:</strong> <code>{{ type }}</code></p>
<p><strong>Size:</strong> {{ obj.size }} B</p>
<p><strong>Retained heap:</strong> {{ retained_heap.get_for_object(address) }} B</p>
<p><strong>String representation:</strong> <span class="inline-object-str text-muted">{{ obj.str_repr }}</span></p>
<p><strong>String representation:</strong> <span class="inline-object-str text-muted">
{% if obj.str_repr|length > 1000 %}
<span>{{ obj.str_repr|truncate(1000, end="") }} <a title="Expand" onclick="toggleFullText(event)" href="#">...</a></span>
<span style="display: none;">{{ obj.str_repr }}</span>
{% else %}
{{ obj.str_repr }}
{% endif %}
</span></p>

<div class="accordion">
<div class="accordion-item">
Expand Down Expand Up @@ -207,6 +214,14 @@ <h2 class="accordion-header" id="panelInboundReferences">

{% block script %}
<script>
function toggleFullText(event) {
const a = event.target;
const shortTextSpan = a.parentElement;
const longTextSpan = shortTextSpan.nextElementSibling;
shortTextSpan.remove();
longTextSpan.style.display = 'block';
event.preventDefault();
}
const rootAddr = {{ address }};
</script>
<script src="/static/objects.js"></script>
Expand Down

0 comments on commit c35ba95

Please sign in to comment.