Commit 8ff48bb0 authored by LE GAC Renaud's avatar LE GAC Renaud
Browse files

Update the model report/ui to remove the obsolete tables: graphs, lists, metrics1d and metrics2d.

parent bfe149df
......@@ -22,35 +22,6 @@ AGGREGATE_FUNCS = {
"std": np.std,
"var": np.var}
DEF_COLUMNS_LISTS = \
"""[{
"xtype": "rownumberer"
}, {
"dbfield": "?.?",
"flex": 1,
"text": "?",
"xtype": "gridcolumn"
}]"""
DEF_COLUMNS_METRIC1D = \
"""[{
"aggregate": "?",
"align": "right",
"dbfield": "?.?",
"format": "0.0",
"text": "?",
"xtype": "numbercolumn"
}]"""
DEF_FEATURES = \
"""[{
"ftype": "groupingsummary",
"groupHeaderTpl": "{name}",
"startCollapsed": false
}, {
"ftype": "summary"
}]"""
DEF_GRAPH = {
"colormap": "Pastel1",
"kind": "",
......@@ -65,12 +36,6 @@ DEF_GRAPH = {
"width": 0.8,
"ylim": ""}
DEF_PLOT = \
"""{
"kind": "?",
"stacked": false
}"""
DEF_SUMMARY = {
"functions": "",
"labels": ""}
......@@ -82,10 +47,6 @@ TP_AGG = \
TP_COLUMNS = "Configure the column of the grid displayed in the view."
TP_CONDITIONS = \
"Database query to select history records:<br> " \
"(db.events.event == 'People') & (db.history.data.like('%cdd%'))<br>"
TP_GROUP_FIELD_LISTS = \
"Row are grouped according to the value of that field. " \
"It can be any field defined in the source."
......@@ -94,16 +55,11 @@ TP_GROUP_FIELD_METRICS = \
"Metric are computed for each value of that field. " \
"It can be any field defined in the source"
TP_FEATURES = "Summary value can be computed for columns."
TP_SORTERS = \
"Entries are sorted according to the value of these fields. "\
"It can be any field defined in the source. "\
"Descending order is obtained by using the '~field' construct."
TP_SUMMARY_X = "To sum, for example, the content of each row."
TP_SUMMARY_Y = "To sum, for example, the content of each column."
class Report(object):
"""Create the tables ``Lists`` and ``metrics2D`` for the reporting
......@@ -123,84 +79,9 @@ class Report(object):
T (gluon.languages.translator): language translator
"""
Report.graphs(db, T)
Report.lists(db, T)
Report.lists2(db, T)
Report.metrics1d(db, T)
Report.metrics2d(db, T)
Report.metrics2d2(db, T)
@staticmethod
def graphs(db, T):
"""graphs table
Args:
db (pyDAL.DAL): database connection
T (gluon.languages.translator): language translator
Returns:
pyDAL.Table
"""
def_plot = (None if db._migrate else DEF_PLOT)
table = db.define_table(
"graphs",
Field("name", "string", length=255, notnull=True, unique=True),
Field("title", "string", length=255),
Field("report_type", "string", length=255, notnull=True),
Field("report_name", "string", length=255, notnull=True),
Field("plot", "text", notnull=True, default=def_plot),
Field("definition", "text"),
migrate="graphs.table")
return table
@staticmethod
def lists(db, T):
"""lists table
Args:
db (pyDAL.DAL): database connection
T (gluon.languages.translator): language translator
Returns:
pyDAL.Table
"""
def_columns = (None if db._migrate else DEF_COLUMNS_LISTS)
def_features = (None if db._migrate else DEF_FEATURES)
table = db.define_table(
"lists",
Field("name", "string", length=255, notnull=True, unique=True),
Field("title", "string", length=255),
Field("conditions", "text", comment=T(TP_CONDITIONS)),
Field("group_field",
"string",
length=255,
comment=T(TP_GROUP_FIELD_LISTS)),
Field("sorters", "list:string", comment=TP_SORTERS),
Field("columns",
"text",
default=def_columns,
comment=T(TP_COLUMNS),
notnull=True),
Field("features",
"text",
default=def_features,
comment=T(TP_FEATURES)),
Field("definition", "text"),
migrate="lists.table")
return table
@staticmethod
def lists2(db, T):
"""lists2 table
......@@ -264,89 +145,6 @@ class Report(object):
return table
@staticmethod
def metrics1d(db, T):
"""metrics1d table
Args:
db (pyDAL.DAL): database connection
T (gluon.languages.translator): language translator
Returns:
pyDAL.Table
"""
def_columns = (None if db._migrate else DEF_COLUMNS_METRIC1D)
db.define_table(
"metrics1d",
Field("name", "string", length=255, notnull=True, unique=True),
Field("title", "string", length=255),
Field("conditions", "text", comment=T(TP_CONDITIONS)),
Field("group_field",
"string",
length=255,
comment=T(TP_GROUP_FIELD_METRICS),
notnull=True),
Field("columns",
"text",
default=def_columns,
comment=T(TP_COLUMNS),
notnull=True),
Field("definition", "text"),
migrate="metrics1d.table")
@staticmethod
def metrics2d(db, T):
"""metrics2d table
Args:
db (pyDAL.DAL): database connection
T (gluon.languages.translator): language translator
Returns:
pyDAL.Table
"""
table = db.define_table(
"metrics2d",
Field("name", "string", length=255, notnull=True, unique=True),
Field("title", "string", length=255),
Field("conditions", "text", comment=T(TP_CONDITIONS)),
Field("group_field_x",
"string",
length=255,
notnull=True,
comment=T(TP_GROUP_FIELD_METRICS)),
Field("group_field_y",
"string",
length=255,
notnull=True,
comment=T(TP_GROUP_FIELD_METRICS)),
Field("metric_field_z",
"string",
length=255,
notnull=True,
comment=T(TP_GROUP_FIELD_METRICS)),
Field("aggregation_z",
"string",
length=255,
notnull=True,
comment=T(TP_AGG)),
Field("definition", "text"),
migrate="metrics2d.table")
return table
@staticmethod
def metrics2d2(db, T):
"""metrics2d2 table
......@@ -438,11 +236,7 @@ class Report(object):
list
"""
lst = ["graphs",
"lists",
"lists2",
"metrics1d",
"metrics2d"
lst = ["lists2",
"metrics2d2"]
return lst
......@@ -40,172 +40,9 @@ class ReportUi(object):
T (gluon.languages.translator): language translator
"""
ReportUi.graphs(db, T)
ReportUi.lists(db, T)
ReportUi.lists2(db, T)
ReportUi.metrics1d(db, T)
ReportUi.metrics2d(db, T)
ReportUi.metrics2d2(db, T)
@staticmethod
def graphs(db, T):
"""UI for the graphs table
Args:
db (pyDAL.DAL): database connection
T (gluon.languages.translator): language translator
"""
# ....................................................................
#
# Fields
#
mdf = fieldsModifier("graphs")
mdf.configure_field("definition", height=110)
mdf.configure_field("plot", height=240, hideLabel=True)
# the field report type and name are linked ComboBox
store = dbui.Store(data=[], fields=[])
store.fields.append(dict(name="report_type", type="string"))
store.fields.append(dict(name="report_name", type="string"))
for tablename in ("lists", "metrics1d", "metrics2d"):
for row in db().select(db[tablename].name):
store.data.append(
dict(report_type=tablename, report_name=row.name))
mdf.configure_field("report_type",
displayField="report_type",
emptyText=T("select..."),
itemId="mastercombo_report_type",
refStore=store,
valueField="report_type",
xtype="xcomboboxmaster")
mdf.configure_field("report_name",
displayField="report_name",
emptyText=T("select..."),
masterItemId="mastercombo_report_type",
masterValueField="report_type",
refStore=store,
valueField="report_name",
xtype="xcomboboxslave")
# ....................................................................
#
# Form
#
mdf = formModifier("graphs")
mdf.merge_fields("name",
"title",
"report_type",
"report_name",
"definition",
title=T("General"))
mdf.merge_fields("plot", title=T("Configure"))
mdf.set_mapper(dbui.map_tabpanel)
mdf.configure(fieldDefaults={"labelWidth": 135}, width=450)
# ....................................................................
#
# Grid
#
mdf = gridModifier("graphs")
mdf.configure_column("name", width=30)
mdf.configure_column("report_type", width=20)
mdf.hide_columns("plot",
"report_name",
"title")
# ....................................................................
#
# Store
#
storeModifier("graphs").orderby(db.graphs.name)
@staticmethod
def lists(db, T):
"""UI for the lists table
Args:
db (pyDAL.DAL): database connection
T (gluon.languages.translator): language translator
"""
# ....................................................................
#
# Fields
#
mdf = fieldsModifier("lists")
mdf.configure_field("columns",
editorHeight=240,
hideLabel=True,
language="json",
xtype="xaceeditorfield")
mdf.configure_field("definition", height=100)
mdf.configure_field("features",
editorHeight=240,
hideLabel=True,
language="json",
xtype="xaceeditorfield")
mdf.configure_field("sorters",
height=210,
hideHeader=True,
minimumRows=10)
# ....................................................................
#
# Form
#
mdf = formModifier("lists")
mdf.merge_fields("name",
"title",
"definition",
"conditions",
title=T("General"))
mdf.merge_fields("group_field",
"sorters",
title=T("Group"))
mdf.merge_fields("columns",
title=T("Columns"))
mdf.merge_fields("features",
title=T("Summary"))
mdf.set_mapper(dbui.map_tabpanel)
mdf.configure(width=450)
# ....................................................................
#
# Grid
#
mdf = gridModifier("lists")
mdf.configure_column("name", width=30)
mdf.hide_columns("title",
"columns",
"conditions",
"features",
"group_field",
"sorters")
# ....................................................................
#
# Store
#
storeModifier("lists").orderby(db.lists.name)
@staticmethod
def lists2(db, T):
"""UI for the lists table
......@@ -316,125 +153,6 @@ class ReportUi(object):
#
storeModifier("lists2").orderby(db.lists2.name)
@staticmethod
def metrics1d(db, T):
"""UI for the metrics1d table
Args:
db (pyDAL.DAL): database connection
T (gluon.languages.translator): language translator
"""
# ....................................................................
#
# Fields
#
mdf = fieldsModifier("metrics1d")
mdf.configure_field("columns",
editorHeight=240,
hideLabel=True,
language="json",
xtype="xaceeditorfield")
mdf.configure_field("definition", height=100)
# ....................................................................
#
# Form
#
mdf = formModifier("metrics1d")
mdf.merge_fields("name",
"title",
"definition",
"conditions",
title=T("General"))
mdf.merge_fields("group_field",
title=T("Group"))
mdf.merge_fields("columns",
title=T("Columns"))
mdf.set_mapper(dbui.map_tabpanel)
mdf.configure(width=450)
# ....................................................................
#
# Grid
#
mdf = gridModifier("metrics1d")
mdf.configure_column("name", width=30)
mdf.hide_columns("title",
"columns",
"conditions",
"group_field")
# ....................................................................
#
# Store
#
storeModifier("metrics1d").orderby(db.metrics1d.name)
@staticmethod
def metrics2d(db, T):
"""UI for the metrics2d table
Args:
db (pyDAL.DAL): database connection
T (gluon.languages.translator): language translator
"""
# ....................................................................
#
# Fields
#
mdf = fieldsModifier("metrics2d")
mdf.configure_field("conditions", height=110)
mdf.configure_field("definition", height=110)
# ....................................................................
#
# Form
#
mdf = formModifier("metrics2d")
mdf.merge_fields("name",
"title",
"definition",
"conditions",
title=T("General"))
mdf.merge_fields("group_field_x",
"group_field_y",
"metric_field_z",
"aggregation_z",
title=T("Aggregate"))
mdf.set_mapper(dbui.map_tabpanel)
mdf.configure(width=450)
# ....................................................................
#
# Grid
#
mdf = gridModifier("metrics2d")
mdf.configure_column("name", width=30)
mdf.hide_columns("aggregation_z",
"conditions",
"group_field_x",
"group_field_y",
"metric_field_z",
"title")
# ....................................................................
#
# Store
#
storeModifier("metrics2d").orderby(db.metrics2d.name)
@staticmethod
def metrics2d2(db, T):
"""UI for the metrics2d2 table
......
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