mirror of
https://github.com/OCA/reporting-engine.git
synced 2025-02-16 16:30:38 +02:00
[IMP] kpi_dashboard: Compute on fly, allow to refresh data on fly
This commit is contained in:
@@ -10,7 +10,29 @@ odoo.define('kpi_dashboard.DashboardController', function (require) {
|
||||
var DashboardController = BasicController.extend({
|
||||
custom_events: _.extend({}, BasicController.prototype.custom_events, {
|
||||
addDashboard: '_addDashboard',
|
||||
refresh_on_fly: '_refreshOnFly',
|
||||
}),
|
||||
_refreshOnFly: function (event) {
|
||||
var self = this;
|
||||
this._rpc({
|
||||
model: this.modelName,
|
||||
method: 'read_dashboard_on_fly',
|
||||
args: [[this.renderer.state.res_id]],
|
||||
context: _.extend(
|
||||
{},
|
||||
this.model.get(this.handle, {raw: true}).getContext(),
|
||||
{bin_size: true}
|
||||
),
|
||||
}).then(function (data) {
|
||||
_.each(data, function (item) {
|
||||
// We will follow the same logic used on Bus Notifications
|
||||
self.renderer._onNotification([[
|
||||
"kpi_dashboard_" + self.renderer.state.res_id,
|
||||
item
|
||||
]])
|
||||
});
|
||||
});
|
||||
},
|
||||
renderPager: function ($node, options) {
|
||||
options = _.extend({}, options, {
|
||||
validate: this.canBeDiscarded.bind(this),
|
||||
|
||||
@@ -53,8 +53,21 @@ odoo.define('kpi_dashboard.DashboardRenderer', function (require) {
|
||||
'bus_service', 'onNotification',
|
||||
this, this._onNotification
|
||||
);
|
||||
if (this.state.specialData.compute_on_fly_refresh > 0) {
|
||||
// Setting the refresh interval
|
||||
this.on_fly_interval = setInterval(function () {
|
||||
self.trigger_up('refresh_on_fly');
|
||||
}, this.state.specialData.compute_on_fly_refresh *1000);
|
||||
};
|
||||
return $.when();
|
||||
},
|
||||
on_detach_callback: function () {
|
||||
// We want to clear the refresh interval once we exit the view
|
||||
if (this.on_fly_interval) {
|
||||
clearInterval(this.on_fly_interval)
|
||||
}
|
||||
this._super.apply(this, arguments);
|
||||
},
|
||||
_onNotification: function (notifications) {
|
||||
var self = this;
|
||||
_.each(notifications, function (notification) {
|
||||
|
||||
Reference in New Issue
Block a user