Skip to content

Commit e4bf1fb

Browse files
committed
[IMP] awesome_dashboard: real life update
1 parent 8750017 commit e4bf1fb

File tree

3 files changed

+14
-8
lines changed

3 files changed

+14
-8
lines changed

awesome_dashboard/static/src/dashboard.js

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { Component, onWillStart } from "@odoo/owl";
1+
import { Component, onWillStart, useState } from "@odoo/owl";
22
import { registry } from "@web/core/registry";
33
import { useService } from "@web/core/utils/hooks";
44
import { Layout } from "@web/search/layout";
@@ -12,10 +12,7 @@ class AwesomeDashboard extends Component {
1212
setup() {
1313
this.action = useService("action");
1414
this.statisticService = useService("statistics");
15-
16-
onWillStart(async () => {
17-
this.statistics = await this.statisticService.loadStatistic();
18-
});
15+
this.statistics = useState(this.statisticService);
1916
}
2017

2118
openLeads() {

awesome_dashboard/static/src/pie_chart/pie_chart.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,9 @@ import { loadJS } from "@web/core/assets";
99

1010
export class PieChart extends Component {
1111
static template = "awesome_dashboard.PieChart";
12-
static props = { data: { optional: true } }
12+
static props = {
13+
data: { default: {}, type: Object },
14+
}
1315

1416
setup() {
1517
this.rootRef = useRef("root");

awesome_dashboard/static/src/statistics_service.js

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import { reactive } from "@odoo/owl";
12
import { rpc } from "@web/core/network/rpc";
23
import { registry } from "@web/core/registry";
34
import { memoize } from "@web/core/utils/functions";
@@ -7,8 +8,14 @@ export async function loadStatistic() {
78
}
89

910
export const statisticsService = {
10-
start() {
11-
return { loadStatistic: memoize(loadStatistic) };
11+
async start() {
12+
const data = reactive(await loadStatistic());
13+
14+
setInterval(async () => {
15+
data = await loadStatistic();
16+
}, 10 * 60 * 1000);
17+
18+
return data;
1219
}
1320
}
1421

0 commit comments

Comments
 (0)