File tree Expand file tree Collapse file tree 2 files changed +19
-2
lines changed
awesome_dashboard/static/src Expand file tree Collapse file tree 2 files changed +19
-2
lines changed Original file line number Diff line number Diff line change @@ -5,19 +5,19 @@ import { registry } from "@web/core/registry";
5
5
import { Layout } from "@web/search/layout" ;
6
6
import { useService } from "@web/core/utils/hooks" ;
7
7
import { DashboardItem } from "./dashboard_item" ;
8
- import { rpc } from "@web/core/network/rpc" ;
9
8
10
9
class AwesomeDashboard extends Component {
11
10
static template = "awesome_dashboard.AwesomeDashboard" ;
12
11
static components = { Layout, DashboardItem } ;
13
12
14
13
setup ( ) {
15
14
this . action = useService ( "action" ) ;
15
+ this . statisticsService = useService ( "awesome_dashboard.statistics" ) ;
16
16
this . display = {
17
17
controlPanel : { } ,
18
18
} ;
19
19
onWillStart ( async ( ) => {
20
- this . statistics = await rpc ( "/awesome_dashboard/statistics" ) ;
20
+ this . statistics = await this . statisticsService . getStatistics ( ) ;
21
21
} )
22
22
}
23
23
Original file line number Diff line number Diff line change
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 ) ;
You can’t perform that action at this time.
0 commit comments