Skip to content

Commit f233d5c

Browse files
committed
[IMP] awesome_dashboard: task 5
1 parent ddd9e28 commit f233d5c

File tree

4 files changed

+25
-7
lines changed

4 files changed

+25
-7
lines changed

awesome_dashboard/static/src/dashboard.js

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,20 +3,20 @@ import {registry} from "@web/core/registry";
33
import {Layout} from "@web/search/layout";
44
import {useService} from "@web/core/utils/hooks"
55
import {_t} from "@web/core/l10n/translation";
6-
import {DashboardItem} from "./dashboard_item";
7-
import {rpc} from "@web/core/network/rpc";
6+
import {DashboardItem} from "./dashboard_item/dashboard_item";
87

98
class AwesomeDashboard extends Component {
109
static template = "awesome_dashboard.AwesomeDashboard";
1110
static components = { Layout, DashboardItem };
1211

1312
setup() {
1413
this.action = useService("action");
15-
onWillStart(async () => {
16-
const result = await rpc("/awesome_dashboard/statistics", {});
17-
this.statistics = result
18-
console.log(this.statistics);
19-
})
14+
this.statsService = useService("awesome_dashboard.statistics");
15+
16+
onWillStart(async () => {
17+
this.statistics = await this.statsService.loadStatistics();
18+
});
19+
console.log(this.statistics);
2020
}
2121

2222
openCustomers() {
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
import { registry } from "@web/core/registry";
2+
import { rpc } from "@web/core/network/rpc";
3+
import { memoize } from "@web/core/utils/functions";
4+
// import { reactive } from "@odoo/owl";
5+
6+
const statisticsService = {
7+
8+
start() {
9+
10+
const loadStatistics = memoize(async() => {
11+
return await rpc("/awesome_dashboard/statistics", {});
12+
});
13+
14+
return { loadStatistics };
15+
}
16+
}
17+
18+
registry.category("services").add("awesome_dashboard.statistics", statisticsService);

0 commit comments

Comments
 (0)