Commit 646bce24 authored by LE GAC Renaud's avatar LE GAC Renaud
Browse files

Update new report by adding list and metric2d controllers and by removing grid2d.

parent 18a25454
......@@ -3,32 +3,63 @@
"""
import json
import urllib
from gluon.tools import PluginManager
from plugin_dbui import INLINE_ALERT, Selector
from plugin_event import List2, Metric2D2, ReportException
from plugin_event import Graph2, List2, Metric2D2, ReportException
def grid2():
"""New approach to generate lists and metrics2D.
def list():
"""The report is a list rendered by an ``Ext.grid.Panel`` widget.
Its context menu allows to export the content of the table as a CSV, LaTeX
or PDF format.
The controller extracts the configuration of the report from the database.
It builds the DataFrame, extracts the configuration for the
``Ext.data.Store`` as well as the ``Ext.grid.Panel``. The former contains
the data displayed in the grid.
"""
try:
if "id_lists2" in request.vars:
report = List2(request.vars.id_lists2)
elif "id_metrics2d2" in request.vars:
report = Metric2D2(request.vars.id_metrics2d2)
report = List2(request.vars.id_list)
store = report.get_store_configuration()
grid = report.get_grid_configuration()
title = report.get_title()
except (IndexError, ReportException, TypeError, ValueError) as e:
return INLINE_ALERT % ("REPORT Error...", e)
store = report.get_store_configuration()
grid = report.get_grid_configuration()
title = report.get_title()
response.view = "plugin_event/grid2.html"
return dict(cfg_store=store, grid=grid, title=title)
def metric2d():
"""The report contains a table rendered by an ``Ext.grid.Panel`` widget
and a graph rendered as an image. The context menu associated to the grid
allows to export the content of the table as a CSV, LaTeX or PDF format.
The context menu associated to the image allow to export in PNG or PDF
format.
The controller extracts the configuration of the report from the database.
It builds the DataFrame, extracts the the configuration for the
``Ext.data.Store`` as well as the ``Ext.grid.Panel`` and generated
the graph.
"""
try:
report = Metric2D2(request.vars.id_metric2d)
store = report.get_store_configuration()
grid = report.get_grid_configuration()
title = report.get_title()
graph = Graph2(report)
img = graph.to_svg()
img = urllib.quote(img)
except (IndexError, ReportException, TypeError, ValueError) as e:
return INLINE_ALERT % ("REPORT Error...", e)
response.view = "plugin_event/grid_and_graph.html"
return dict(cfg_store=store, grid=grid, img=img, title=title)
......@@ -269,8 +269,8 @@ class ViewportUi(object):
for row in db(db.lists2.id > 0).select(orderby=db.lists2.name):
panel = selector_panel
panel.baseUrl = URL("new_report", "grid2")
panel.baseParams = {"id_lists2": row.id}
panel.baseUrl = URL("new_report", "list")
panel.baseParams = {"id_list": row.id}
add_child(row.name, panel)
......@@ -353,8 +353,8 @@ class ViewportUi(object):
for row in db(db.metrics2d2.id > 0).select(orderby=db.metrics2d2.name):
panel = selector_panel
panel.baseUrl = URL("new_report", "grid2")
panel.baseParams = {"id_metrics2d2": row.id}
panel.baseUrl = URL("new_report", "metric2d")
panel.baseParams = {"id_metric2d": row.id}
node.add_child(row.name, panel)
......
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