Skip to content

Commit ddd9e28

Browse files
committed
[ADD] awesome_dashboard: task 4 (statistics)
1 parent 67e8dc2 commit ddd9e28

File tree

3 files changed

+45
-17
lines changed

3 files changed

+45
-17
lines changed

awesome_dashboard/static/src/dashboard.js

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
1-
import { Component, useState, onWillStart } from "@odoo/owl";
2-
import { registry } from "@web/core/registry";
3-
import { Layout } from "@web/search/layout";
4-
import { useService } from "@web/core/utils/hooks"
5-
import { _t } from "@web/core/l10n/translation";
6-
import { DashboardItem } from "./dashboard_item";
7-
import { rpc } from "@web/core/network/rpc";
1+
import {Component, onWillStart, useState} from "@odoo/owl";
2+
import {registry} from "@web/core/registry";
3+
import {Layout} from "@web/search/layout";
4+
import {useService} from "@web/core/utils/hooks"
5+
import {_t} from "@web/core/l10n/translation";
6+
import {DashboardItem} from "./dashboard_item";
7+
import {rpc} from "@web/core/network/rpc";
88

99
class AwesomeDashboard extends Component {
1010
static template = "awesome_dashboard.AwesomeDashboard";
@@ -13,9 +13,10 @@ class AwesomeDashboard extends Component {
1313
setup() {
1414
this.action = useService("action");
1515
onWillStart(async () => {
16-
const result = await rpc("/awesome_dashboard/statistics");
16+
const result = await rpc("/awesome_dashboard/statistics", {});
17+
this.statistics = result
18+
console.log(this.statistics);
1719
})
18-
//this.statistics = useState(useService("awesome_dashboard.statistics"));
1920
}
2021

2122
openCustomers() {

awesome_dashboard/static/src/dashboard.xml

Lines changed: 29 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,38 @@
33

44
<t t-name="awesome_dashboard.AwesomeDashboard">
55
<Layout display="{controlPanel: {} }" className="'o_dashboard h-100'">
6-
<button class="btn btn-primary" t-on-click="openCustomers">Customers</button>
7-
<button class="btn btn-primary" t-on-click="openLeads">Leads</button>
6+
7+
<t t-set-slot="layout-buttons">
8+
<button class="btn btn-primary" t-on-click="openCustomers">Customers</button>
9+
<button class="btn btn-primary" t-on-click="openLeads">Leads</button>
10+
</t>
11+
812
<DashboardItem>
9-
<p>content 1</p>
13+
<t t-set-slot="title">
14+
New orders
15+
</t>
16+
<t t-set-slot="number">
17+
<t t-out="statistics.nb_new_orders" />
18+
</t>
1019
</DashboardItem>
11-
<DashboardItem size="2">
12-
<p>content 2</p>
20+
<DashboardItem>
21+
<t t-set-slot="title">
22+
Total amount
23+
</t>
24+
<t t-set-slot="number">
25+
<t t-out="statistics.total_amount" />
26+
</t>
1327
</DashboardItem>
28+
<DashboardItem>
29+
<t t-set-slot="title">
30+
Average time
31+
</t>
32+
<t t-set-slot="number">
33+
<t t-out="statistics.average_time"/>
34+
</t>
35+
</DashboardItem>
36+
37+
1438
</Layout>
1539

1640
</t>

awesome_dashboard/static/src/dashboard_item.xml

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,12 @@
22
<templates xml:space="preserve">
33

44
<t t-name="awesome_dashboard.DashboardItem">
5-
<div class="card m-2" t-attf-style="width: {{18 * props.size }}rem;">
6-
<div class="card-body">
7-
<t t-slot="default"/>
5+
<div class="card m-3 p-1" t-attf-style="width: {{18 * props.size }}rem;">
6+
<div class="card-title fs-3 mt-3 text-center">
7+
<t t-slot="title"/>
8+
</div>
9+
<div class="card-body fs-1 fw-bold text-success text-center">
10+
<t t-slot="number"/>
811
</div>
912
</div>
1013
</t>

0 commit comments

Comments
 (0)