File tree Expand file tree Collapse file tree 3 files changed +14
-8
lines changed
awesome_dashboard/static/src Expand file tree Collapse file tree 3 files changed +14
-8
lines changed Original file line number Diff line number Diff line change 1- import { Component , onWillStart } from "@odoo/owl" ;
1+ import { Component , onWillStart , useState } from "@odoo/owl" ;
22import { registry } from "@web/core/registry" ;
33import { useService } from "@web/core/utils/hooks" ;
44import { 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 ( ) {
Original file line number Diff line number Diff line change @@ -9,7 +9,9 @@ import { loadJS } from "@web/core/assets";
99
1010export 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" ) ;
Original file line number Diff line number Diff line change 1+ import { reactive } from "@odoo/owl" ;
12import { rpc } from "@web/core/network/rpc" ;
23import { registry } from "@web/core/registry" ;
34import { memoize } from "@web/core/utils/functions" ;
@@ -7,8 +8,14 @@ export async function loadStatistic() {
78}
89
910export 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
You can’t perform that action at this time.
0 commit comments