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

Rename the view grid2.html as grid.html.

parent 80bb3a05
# -*- coding: utf-8 -*-
"""new_report controllers
"""plugin_event controllers
"""
import urllib
......@@ -29,7 +29,7 @@ def grid():
except (IndexError, ReportException, TypeError, ValueError) as e:
return INLINE_ALERT % ("REPORT Error...", e)
response.view = "plugin_event/grid2.html"
response.view = "plugin_event/grid.html"
return dict(cfg_store=store, grid=grid, title=title)
......
......@@ -9,19 +9,15 @@
#--------------------------------------------------------------------------
# Prepare the data
# - The HTML tilte
# - The DIV blocks
# - Export python variables to javascript
#--------------------------------------------------------------------------
import json
from datetime import datetime
#
# The title and the DIV block
# The title
#
divgrid = "grid-%s" % id(cfg_store)
response.write(H2(title, _class="dbui-h2 dbui-small-cap"))
response.write(DIV(_id=divgrid))
title = H2(title, _class="dbui-h2 dbui-small-cap")
#
# Convert store and grid configuration as string
......@@ -40,96 +36,67 @@
"margin-bottom: 3ex;",
"margin-top: 2ex;"]
response.write(P(delta, _style="".join(style)))
delta = P(delta, _style="".join(style))
}}
<script type="text/javascript">
/**
* Helper function to convert a duration in nanosecond into a string.
*
* @param {Number} value
* The duration in seconds
*
* @return {String}
* The duration express as the number of year + the number of months
* e.g. "3y + 09m"
*
*/
function reprDuration(value) {
"use strict";
var duration = value,
month, nd, nm, ny, rep, year;
// duration of year and month in seconds
year = 365 * 24 * 3600;
month = year / 12;
// number of years and months
ny = Math.floor(duration / year);
nm = Math.floor((duration - ny * year) / month);
// format the number of month
nm = Ext.String.leftPad(nm.toString(), 2, '0');
// format the response
if (ny > 0) {
rep = Ext.String.format("{0}y + {1}m", ny, nm);
} else if (nm > 0) {
rep = Ext.String.format("{0}m", nm);
} else {
nd = duration / (24 * 3600);
rep = Ext.String.leftPad(nd.toString(), 2, '0');
}
return rep;
}
var cfgGrid = {{=XML(cfg_grid)}},
cfgStore = {{=XML(cfg_store)}},
columns = cfgGrid.columns,
features = cfgGrid.features,
divgrid = '{{=divgrid}}',
nColumns = columns.length,
i, grid;
footer, header, main, tabPanel;
// convert renderer / summaryRenderer properties
// typicaly a string to a function
//
for (i = 0; i < nColumns; i += 1) {
if (columns[i].renderer !== undefined) {
columns[i].renderer = eval(columns[i].renderer);
}
if (columns[i].summaryRenderer !== undefined) {
columns[i].summaryRenderer = eval(columns[i].summaryRenderer);
}
}
// Retrieve the mainPanel which will embedded the grid
// viewport > tabpanel > tab[active] > panelwithurlselector > mainPanel
//
tabPanel = Ext.ComponentQuery.query("xviewport > tabpanel")[0];
main = tabPanel.getActiveTab().down("xpanelwithurlselector #mainPanel");
// instantiate the grid
//
// remove all embeded object
// Avoid proliferation of useless object
// Keep the memory foot print low
//
main.removeAll(true);
// NOTE ExtJS 6.2.0
// With ExtJS 6.2.0, the configuration is not working:
//
// plugins: ['pGridExport', 'pMathJax']
// configure the header
//
// It is related to layout and pMathJax !
// Remove pMathJax since its use is marginal in that application.
header = {
border: false,
html: '{{=title}}',
xtype: "panel"
};
//
// configure the grid
//
cfgGrid = Ext.apply(cfgGrid, {
plugins: ['pGridExport'],
store: cfgStore,
forceFit: true,
padding: "10 40 20 30",
renderTo: divgrid
xtype: "xgrid"
});
Ext.create('Dbui.grid.Panel', cfgGrid);
//
// configure the footer
//
footer = {
border: false,
html: '{{=delta}}',
xtype: "panel"
};
//
// Add sub-panels to the main one
//
main.add({
border: false,
items: [header, cfgGrid, footer],
layout: "anchor",
scrollable: true,
xtype: "panel"
});
</script>
{{
#--------------------------------------------------------------------------
#
# The python controller return the variables:
# - cfg_store (Storage)
# - grid (Storage)
# - title (string)
#
#--------------------------------------------------------------------------
# Prepare the data
# - The HTML tilte
# - Export python variables to javascript
#--------------------------------------------------------------------------
import json
from datetime import datetime
#
# The title
#
title = H2(title, _class="dbui-h2 dbui-small-cap")
#
# Convert store and grid configuration as string
#
cfg_grid = json.dumps(grid, cls=dbui.JSONEncoder)
cfg_store = json.dumps(cfg_store, cls=dbui.JSONEncoder)
#
# the footer, processing time of the request
#
delta = (datetime.now()-request.now).total_seconds()
delta = T('Processing time %s seconds') % round(delta, 2)
style = ["font-size: 10px;",
"margin-left: 10px;",
"margin-bottom: 3ex;",
"margin-top: 2ex;"]
delta = P(delta, _style="".join(style))
}}
<script type="text/javascript">
var cfgGrid = {{=XML(cfg_grid)}},
cfgStore = {{=XML(cfg_store)}},
footer, header, main, tabPanel;
//
// Retrieve the mainPanel which will embedded the grid
// viewport > tabpanel > tab[active] > panelwithurlselector > mainPanel
//
tabPanel = Ext.ComponentQuery.query("xviewport > tabpanel")[0];
main = tabPanel.getActiveTab().down("xpanelwithurlselector #mainPanel");
//
// remove all embeded object
// Avoid proliferation of useless object
// Keep the memory foot print low
//
main.removeAll(true);
//
// configure the header
//
header = {
border: false,
html: '{{=title}}',
xtype: "panel"
};
//
// configure the grid
//
cfgGrid = Ext.apply(cfgGrid, {
plugins: ['pGridExport'],
store: cfgStore,
forceFit: true,
padding: "10 40 20 30",
xtype: "xgrid"
});
//
// configure the footer
//
footer = {
border: false,
html: '{{=delta}}',
xtype: "panel"
};
//
// Add sub-panels to the main one
//
main.add({
border: false,
items: [header, cfgGrid, footer],
layout: "anchor",
scrollable: true,
xtype: "panel"
});
</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