mirror of
https://github.com/mail-in-a-box/mailinabox.git
synced 2024-12-24 07:37:04 +00:00
load images as base64
This commit is contained in:
parent
dce4058705
commit
6883a60f5d
@ -521,7 +521,7 @@ def privacy_status_set():
|
|||||||
return "OK"
|
return "OK"
|
||||||
|
|
||||||
# Mailgraph
|
# Mailgraph
|
||||||
|
import base64
|
||||||
@app.route('/mailgraph/image.cgi', methods=['GET'])
|
@app.route('/mailgraph/image.cgi', methods=['GET'])
|
||||||
@authorized_personnel_only
|
@authorized_personnel_only
|
||||||
def mailgraph():
|
def mailgraph():
|
||||||
@ -540,11 +540,8 @@ def mailgraph():
|
|||||||
return ('Error generating mailgraph image: %s' % request.query_string, 500)
|
return ('Error generating mailgraph image: %s' % request.query_string, 500)
|
||||||
|
|
||||||
headers, image_bytes = bin_out.split(b'\n\n', 1)
|
headers, image_bytes = bin_out.split(b'\n\n', 1)
|
||||||
response = make_response(image_bytes)
|
|
||||||
for line in headers.splitlines():
|
return base64.b64encode(image_bytes)
|
||||||
name, value = line.decode("utf8").split(':', 1)
|
|
||||||
response.headers[name] = value
|
|
||||||
return response
|
|
||||||
|
|
||||||
return ('Mailgraph: no image requested', 500)
|
return ('Mailgraph: no image requested', 500)
|
||||||
|
|
||||||
|
@ -7,24 +7,24 @@
|
|||||||
</ul>
|
</ul>
|
||||||
|
|
||||||
<h3 id="G0">Last Day</h3>
|
<h3 id="G0">Last Day</h3>
|
||||||
<p><img src="" data-src="/admin/mailgraph/image.cgi?0-n" alt="mailgraph"/></p>
|
<p><img src="" data-src="/mailgraph/image.cgi?0-n" alt="mailgraph"/></p>
|
||||||
<p><img src="" data-src="/admin/mailgraph/image.cgi?0-e" alt="mailgraph"/></p>
|
<p><img src="" data-src="/mailgraph/image.cgi?0-e" alt="mailgraph"/></p>
|
||||||
<p><img src="" data-src="/admin/mailgraph/image.cgi?0-g" alt="mailgraph"/></p>
|
<p><img src="" data-src="/mailgraph/image.cgi?0-g" alt="mailgraph"/></p>
|
||||||
|
|
||||||
<h3 id="G1">Last Week</h3>
|
<h3 id="G1">Last Week</h3>
|
||||||
<p><img src="" data-src="/admin/mailgraph/image.cgi?1-n" alt="mailgraph"/></p>
|
<p><img src="" data-src="/mailgraph/image.cgi?1-n" alt="mailgraph"/></p>
|
||||||
<p><img src="" data-src="/admin/mailgraph/image.cgi?1-e" alt="mailgraph"/></p>
|
<p><img src="" data-src="/mailgraph/image.cgi?1-e" alt="mailgraph"/></p>
|
||||||
<p><img src="" data-src="/admin/mailgraph/image.cgi?1-g" alt="mailgraph"/></p>
|
<p><img src="" data-src="/mailgraph/image.cgi?1-g" alt="mailgraph"/></p>
|
||||||
|
|
||||||
<h3 id="G2">Last Month</h3>
|
<h3 id="G2">Last Month</h3>
|
||||||
<p><img src="" data-src="/admin/mailgraph/image.cgi?2-n" alt="mailgraph"/></p>
|
<p><img src="" data-src="/mailgraph/image.cgi?2-n" alt="mailgraph"/></p>
|
||||||
<p><img src="" data-src="/admin/mailgraph/image.cgi?2-e" alt="mailgraph"/></p>
|
<p><img src="" data-src="/mailgraph/image.cgi?2-e" alt="mailgraph"/></p>
|
||||||
<p><img src="" data-src="/admin/mailgraph/image.cgi?2-g" alt="mailgraph"/></p>
|
<p><img src="" data-src="/mailgraph/image.cgi?2-g" alt="mailgraph"/></p>
|
||||||
|
|
||||||
<h3 id="G3">Last Year</h3>
|
<h3 id="G3">Last Year</h3>
|
||||||
<p><img src="" data-src="/admin/mailgraph/image.cgi?3-n" alt="mailgraph"/></p>
|
<p><img src="" data-src="/mailgraph/image.cgi?3-n" alt="mailgraph"/></p>
|
||||||
<p><img src="" data-src="/admin/mailgraph/image.cgi?3-e" alt="mailgraph"/></p>
|
<p><img src="" data-src="/mailgraph/image.cgi?3-e" alt="mailgraph"/></p>
|
||||||
<p><img src="" data-src="/admin/mailgraph/image.cgi?3-g" alt="mailgraph"/></p>
|
<p><img src="" data-src="/mailgraph/image.cgi?3-g" alt="mailgraph"/></p>
|
||||||
|
|
||||||
<hr/>
|
<hr/>
|
||||||
|
|
||||||
@ -34,7 +34,14 @@
|
|||||||
<script type="text/javascript">
|
<script type="text/javascript">
|
||||||
function show_mailgraph() {
|
function show_mailgraph() {
|
||||||
$('[data-src]').each(function() {
|
$('[data-src]').each(function() {
|
||||||
$(this).attr('src', $(this).attr('data-src'));
|
api(
|
||||||
|
$(this).attr('data-src'),
|
||||||
|
'GET',
|
||||||
|
'',
|
||||||
|
function(data) {
|
||||||
|
$(this).attr('src', 'data:image/gif;base64,' + data);
|
||||||
|
}
|
||||||
|
);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
Loading…
Reference in New Issue
Block a user