Skip to content

Commit d704def

Browse files
committed
[IMP] awesome_dashboard: Add statistics service
1 parent fa0e393 commit d704def

File tree

2 files changed

+19
-2
lines changed

2 files changed

+19
-2
lines changed

awesome_dashboard/static/src/dashboard.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,19 +5,19 @@ import { registry } from "@web/core/registry";
55
import { Layout } from "@web/search/layout";
66
import { useService } from "@web/core/utils/hooks";
77
import { DashboardItem } from "./dashboard_item";
8-
import { rpc } from "@web/core/network/rpc";
98

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

1413
setup(){
1514
this.action = useService("action");
15+
this.statisticsService = useService("awesome_dashboard.statistics");
1616
this.display = {
1717
controlPanel: {},
1818
};
1919
onWillStart(async() => {
20-
this.statistics = await rpc("/awesome_dashboard/statistics");
20+
this.statistics = await this.statisticsService.getStatistics();
2121
})
2222
}
2323

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

0 commit comments

Comments
 (0)