Browse Source

Fix HTML email preview in the checks list

pull/492/head
Pēteris Caune 4 years ago
parent
commit
57336187a7
No known key found for this signature in database GPG Key ID: E28D7679E9A9EDE2
6 changed files with 24 additions and 6 deletions
  1. +1
    -1
      static/css/ping_details.css
  2. +12
    -0
      static/js/checks.js
  3. +5
    -2
      static/js/details.js
  4. +5
    -2
      static/js/log.js
  5. +1
    -0
      templates/front/my_checks.html
  6. +0
    -1
      templates/front/ping_details.html

+ 1
- 1
static/css/ping_details.css View File

@ -27,7 +27,7 @@
line-height: 1em; line-height: 1em;
} }
#email-body-html-iframe {
#email-body-html iframe {
border: 0; border: 0;
width: 100%; width: 100%;
height: 500px; height: 500px;


+ 12
- 0
static/js/checks.js View File

@ -59,6 +59,18 @@ $(function () {
var lastPingUrl = base + "/checks/" + code + "/last_ping/"; var lastPingUrl = base + "/checks/" + code + "/last_ping/";
$.get(lastPingUrl, function(data) { $.get(lastPingUrl, function(data) {
$("#ping-details-body" ).html(data); $("#ping-details-body" ).html(data);
var htmlPre = $("#email-body-html pre");
if (htmlPre.length) {
var opts = {USE_PROFILES: {html: true}};
var clean = DOMPurify.sanitize(htmlPre.text(), opts);
var blob = new Blob([clean], {type: "text/html; charset=utf-8"});
var iframe = document.createElement("iframe");
iframe.sandbox = "";
iframe.src = URL.createObjectURL(blob);
htmlPre.replaceWith(iframe);
}
}); });
var logUrl = base + "/checks/" + code + "/log/"; var logUrl = base + "/checks/" + code + "/log/";


+ 5
- 2
static/js/details.js View File

@ -139,8 +139,11 @@ $(function () {
var clean = DOMPurify.sanitize(htmlPre.text(), opts); var clean = DOMPurify.sanitize(htmlPre.text(), opts);
var blob = new Blob([clean], {type: "text/html; charset=utf-8"}); var blob = new Blob([clean], {type: "text/html; charset=utf-8"});
htmlPre.remove();
document.getElementById("email-body-html-iframe").src = URL.createObjectURL(blob);
var iframe = document.createElement("iframe");
iframe.sandbox = "";
iframe.src = URL.createObjectURL(blob);
htmlPre.replaceWith(iframe);
} }
} }
); );


+ 5
- 2
static/js/log.js View File

@ -12,8 +12,11 @@ $(function () {
var clean = DOMPurify.sanitize(htmlPre.text(), opts); var clean = DOMPurify.sanitize(htmlPre.text(), opts);
var blob = new Blob([clean], {type: "text/html; charset=utf-8"}); var blob = new Blob([clean], {type: "text/html; charset=utf-8"});
htmlPre.remove();
document.getElementById("email-body-html-iframe").src = URL.createObjectURL(blob);
var iframe = document.createElement("iframe");
iframe.sandbox = "";
iframe.src = URL.createObjectURL(blob);
htmlPre.replaceWith(iframe);
} }
}); });


+ 1
- 0
templates/front/my_checks.html View File

@ -96,6 +96,7 @@
<script src="{% static 'js/selectize.min.js' %}"></script> <script src="{% static 'js/selectize.min.js' %}"></script>
<script src="{% static 'js/nouislider.min.js' %}"></script> <script src="{% static 'js/nouislider.min.js' %}"></script>
<script src="{% static 'js/clipboard.min.js' %}"></script> <script src="{% static 'js/clipboard.min.js' %}"></script>
<script src="{% static 'js/purify.min.js' %}"></script>
<script src="{% static 'js/update-timeout-modal.js' %}"></script> <script src="{% static 'js/update-timeout-modal.js' %}"></script>
<script src="{% static 'js/adaptive-setinterval.js' %}"></script> <script src="{% static 'js/adaptive-setinterval.js' %}"></script>
<script src="{% static 'js/checks.js' %}"></script> <script src="{% static 'js/checks.js' %}"></script>


+ 0
- 1
templates/front/ping_details.html View File

@ -106,7 +106,6 @@
{% if html %} {% if html %}
<div id="email-body-html" class="tab-pane"> <div id="email-body-html" class="tab-pane">
<pre>{{ html }}</pre> <pre>{{ html }}</pre>
<iframe id="email-body-html-iframe" sandbox></iframe>
</div> </div>
{% endif %} {% endif %}
</div> </div>


Loading…
Cancel
Save