Commit d32fded1 authored by LE GAC Renaud's avatar LE GAC Renaud
Browse files

Simplify the name of the graph views.

parent 7d937d6d
......@@ -66,12 +66,12 @@ def metric2d():
elif extension == "pdf":
data = graph.to_pdf()
response.view = "plugin_event/graph_mpl.pdf"
response.view = "plugin_event/graph.pdf"
return dict(data=data, title=title)
elif extension == "png":
data = graph.to_png()
response.view = "plugin_event/graph_mpl.png"
response.view = "plugin_event/graph.png"
return dict(data=data, title=title)
except (IndexError, ReportException, TypeError, ValueError) as e:
......
{{
#.........................................................................
#
# The python controller return image as a string:
# - data (string)
# - title (string)
#
import datetime
import urllib
# build the url to retrieve the png or pdf image
# it should contains the current "vars" use to generate the image
myapp = request.application
myvars = urllib.urlencode(request.vars)
url_pdf = "/%s/plugin_event/graph_mpl.pdf?%s" % (myapp, myvars)
url_png = "/%s/plugin_event/graph_mpl.png?%s" % (myapp, myvars)
# unique identfier for the div block
divid = "myimage-%i" % id(data)
# elapse time for the footer
delta = (datetime.datetime.now()-request.now).total_seconds()
processing_time = T('Processing time %s seconds') % round(delta, 2)
# translate
trExport = T("Right click on the image in order to export it...")
trToPDF = T("Export to PDF...")
trToPNG = T("Export to PNG...")
}}
<h2 class="dbui-h2 dbui-small-cap">{{=title}}</h2>
<div id="{{=divid}}"></div>
<p class="dbui-p">
<br>
{{=trExport}}<br>
{{=processing_time}}
</p>
<script type="text/javascript">
/**
* Create the panel to include the image
* The panel allow to expose a context menu which can be used to
* export the image in different format
*/
var menu, panel;
panel = Ext.create("Ext.panel.Panel", {
border: false,
html: '<img src="data:image/svg+xml;utf8,{{=data}}" height=400></img>',
layout: "fit",
padding: "0 0 0 30",
renderTo: "{{=divid}}",
});
menu = Ext.create("Ext.menu.Menu", {
items: [{
text: "{{=trToPNG}}",
href: "{{=url_png}}",
iconCls: "xminetype-png"
}, {
text: "{{=trToPDF}}",
href: "{{=url_pdf}}",
iconCls: "xminetype-pdf"
}]
});
panel.body.on("contextmenu", function(event) {
event.stopEvent();
menu.showAt(event.getXY());
});
</script>
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment