-
Notifications
You must be signed in to change notification settings - Fork 2.3k
Draft
Changes from 1 commit
Commits
Show all changes
15 commits
Select commit
Hold shift + click to select a range
1b57e98
[ADD] estate: initial Real Estate module with models, views, and rela…
raaa-odoo e65a6c3
[ADD] estate: constraints, compute fields, and offer logic enhancements
raaa-odoo d265965
[IMP] estate: implement business logic for offers, constraints, state…
raaa-odoo 734a361
[IMP] estate: apply styling improvements to code
raaa-odoo 35f9b50
[IMP] estate: Again apply styling improvements to code
raaa-odoo d52e2a3
[IMP] estate: add chatter, demo data, access rules, and PDF report
raaa-odoo f2062aa
[IMP] estate: add website controller, offer wizard & tests
raaa-odoo c431e83
[IMP] estate: add website controller, offer wizard & tests
raaa-odoo 6f6bcb8
[IMP] estate, awesome_owl: update estate tests and complete OWL exerc…
raaa-odoo 1cbf9c3
[IMP] estate: update the test cases logic
raaa-odoo 4c06dbd
[IMP] awesome_dashboard: make dashboard items dynamic and reusable
raaa-odoo 8b6372c
[ADD] rental,sale: implement mandatory rental deposit system
raaa-odoo 0f69fe9
[IMP] estate: implement business logic for offers, constraints, state…
raaa-odoo a656668
[IMP] rental_deposit: Fix the the error.
raaa-odoo bc2e9aa
[IMP] rental_deposit: Fix the the error.
raaa-odoo File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
[IMP] awesome_dashboard: make dashboard items dynamic and reusable
This commit restructures the dashboard to render items dynamically based on a centralized configuration list. This approach enables easier extension and reuse of dashboard item types, improving maintainability and scalability. Key changes include: Introduction of dashboard_items.js to define a list of item configurations, including type, title, and props. This enables dynamic rendering of dashboard widgets like NumberCard and PieChartCard. The DashboardItem component now acts as a dynamic wrapper that loads and renders the appropriate child component based on its type. This is achieved using Owl's dynamic component syntax and t-component. Separation of each card type into its own file (NumberCard, PieChartCard) to promote single-responsibility design and reuse across modules. All components continue to use Bootstrap utility classes and maintain responsive, clean, and modern styling. This change lays the foundation for a fully extensible dashboard architecture, where new visualizations can be added without modifying the core dashboard view.
- Loading branch information
commit 4c06dbdff8aa014a5ffe4842b4c6923b2b963068
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
10000
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
.dashboard-card-wrapper { | ||
transition: transform 0.3s ease, box-shadow 0.3s ease; | ||
} | ||
|
||
.dashboard-card { | ||
border-radius: 1rem; | ||
transition: all 0.3s ease-in-out; | ||
cursor: pointer; | ||
} | ||
|
||
.dashboard-card:hover { | ||
transform: translateY(-5px); | ||
box-shadow: 0 10px 20px rgba(0, 0, 0, 0.12); | ||
} | ||
|
This file was deleted.
Oops, something went wrong.
29 changes: 29 additions & 0 deletions
29
awesome_dashboard/static/src/dashboard/components/dashboard_item/dashboard.scss
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
// .o_dashboard_cards { | ||
// display: flex; | ||
// flex-wrap: wrap; | ||
// gap: 1rem; | ||
// } | ||
|
||
.dashboard-item { | ||
background: white; | ||
padding: 1.5rem; | ||
border-radius: 0.75rem; | ||
box-shadow: 0 2px 6px rgba(0, 0, 0, 0.1); | ||
min-height: 150px; | ||
display: flex; | ||
flex-direction: column; | ||
justify-content: center; | ||
align-items: center; | ||
|
||
h5 { | ||
font-size: 1rem; | ||
margin-bottom: 0.5rem; | ||
text-align: center; | ||
} | ||
|
||
p { | ||
font-size: 1.5rem; | ||
font-weight: bold; | ||
color: green; | ||
} | ||
} |
6 changes: 6 additions & 0 deletions
6
awesome_dashboard/static/src/dashboard/components/dashboard_item/dashboard_item.js
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
import { Component } from "@odoo/owl"; | ||
|
||
export class DashboardItem extends Component { | ||
static template = "awesome_dashboard.DashboardItem"; | ||
static props = { size: { type: Number, optional: true, default: 1 } }; | ||
} |
10 changes: 10 additions & 0 deletions
10
awesome_dashboard/static/src/dashboard/components/dashboard_item/dashboard_item.xml
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
<templates xml:space="preserve"> | ||
<t t-name="awesome_dashboard.DashboardItem"> | ||
<div class="card p-3 m-1 h-100 shadow-sm dashboard-card animate-hover"> | ||
<div class="card-body overflow-auto"> | ||
<t t-slot="default"/> | ||
</div> | ||
</div> | ||
</t> | ||
</templates> | ||
|
9 changes: 9 additions & 0 deletions
9
awesome_dashboard/static/src/dashboard/components/number_card/number_card.js
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
import { Component } from "@odoo/owl"; | ||
|
||
export class NumberCard extends Component { | ||
static template = "awesome_dashboard.NumberCard"; | ||
static props = { | ||
label: String, | ||
value: [Number, String], | ||
}; | ||
} |
10 changes: 10 additions & 0 deletions
10
awesome_dashboard/static/src/dashboard/components/number_card/number_card.xml
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
<templates xml:space="preserve"> | ||
<t t-name="awesome_dashboard.NumberCard"> | ||
<h4 class="text-nowrap"> | ||
<t t-out="props.label"/> | ||
</h4> | ||
<p class="fs-2 fw-bold"> | ||
<t t-out="props.value"/> | ||
</p> | ||
</t> | ||
</templates> |
62 changes: 62 additions & 0 deletions
62
awesome_dashboard/static/src/dashboard/components/pie_chart/pie_chart.js
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<
F438
span aria-label="This line has hidden Unicode characters" data-view-component="true" class="line-alert tooltipped tooltipped-e">
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
/** @odoo-module **/ | ||
|
||
import { Component, useRef, onWillStart, onMounted, onWillUpdateProps } from '@odoo/owl'; | ||
import { loadJS } from "@web/core/assets"; | ||
|
||
export class PieChart extends Component { | ||
static template = 'awesome_dashboard.PieChart'; | ||
|
||
static props = { | ||
data: Object, | ||
}; | ||
|
||
setup() { | ||
this.canvasRef = useRef('chartCanvas'); | ||
this.chart = null; | ||
|
||
onWillStart(async () => { | ||
await loadJS("/web/static/lib/Chart/Chart.js"); | ||
}); | ||
|
||
onMounted(() => { | ||
this.renderChart(); | ||
}); | ||
|
||
onWillUpdateProps((nextProps) => { | ||
if (this.chart) { | ||
// Update dataset data with new props | ||
this.chart.data.labels = Object.keys(nextProps.data); | ||
this.chart.data.datasets[0].data = Object.values(nextProps.data); | ||
this.chart.update(); // ✅ Trigger re-render | ||
} | ||
}); | ||
} | ||
|
||
renderChart() { | ||
const ctx = this.canvasRef.el.getContext('2d'); | ||
this.chart = new Chart(ctx, { | ||
type: "pie", | ||
data: { | ||
labels: Object.keys(this.props.data), | ||
datasets: [ | ||
{ | ||
label: "Orders by T-shirt Size", | ||
data: Object.values(this.props.data), | ||
backgroundColor: [ | ||
"#3498db", "#2ecc71", "#f1c40f", "#e67e22", "#9b59b6" | ||
], | ||
borderWidth: 1 | ||
} | ||
] | ||
}, | ||
options: { | ||
responsive: true, | ||
plugins: { | ||
legend: { | ||
position: "right" | ||
} | ||
} | ||
} | ||
}); | ||
} | ||
} |
5 changes: 5 additions & 0 deletions
5
awesome_dashboard/static/src/dashboard/components/pie_chart/pie_chart.xml
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
<t t-name="awesome_dashboard.PieChart" owl="1"> | ||
<div class="w-100 h-100"> | ||
<canvas t-ref="chartCanvas" style="width: 100%; height: 300px;"></canvas> | ||
</div> | ||
</t> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
import { Component, useState, onWillStart } from "@odoo/owl"; | ||
import { useService } from "@web/core/utils/hooks"; | ||
import { registry } from "@web/core/registry"; | ||
import { Layout } from "@web/search/layout"; | ||
import { DashboardItem } from "./components/dashboard_item/dashboard_item"; | ||
import { NumberCard } from "./components/number_card/number_card"; | ||
import { PieChart } from "./components/pie_chart/pie_chart"; | ||
import { SettingDialog } from "./setting/setting_dialog"; | ||
|
||
class AwesomeDashboard extends Component { | ||
static template = "awesome_dashboard.AwesomeDashboard"; | ||
static components = { Layout, DashboardItem, NumberCard, PieChart }; | ||
|
||
setup() { | ||
this.dialogService = useService("dialog"); | ||
this.action = useService("action"); | ||
this.statisticsService = useService("awesome_dashboard.statistics"); | ||
this.statistics = useState(this.statisticsService.data); | ||
this.state = useState({ hiddenItems: JSON.parse(localStorage.getItem("awesome_dashboard_hidden_items")) || [] }); | ||
} | ||
|
||
openCustomers = () => { | ||
this.action.doAction("base.action_partner_customer_form", { | ||
views: [[false, "kanban"]], | ||
}); | ||
} | ||
|
||
openLeads = () => { | ||
this.action.doAction({ | ||
type: "ir.actions.act_window", | ||
name: "Leads", | ||
res_model: "crm.lead", | ||
views: [ | ||
[false, "list"], | ||
[false, "form"] | ||
] | ||
}); | ||
} | ||
|
||
getFilteredItems = () => { | ||
const hiddenSet = new Set(this.state.hiddenItems); | ||
return registry.category("awesome_dashboard.items").getAll().filter(item => !hiddenSet.has(item.id)); | ||
} | ||
|
||
openSettings = () => { | ||
this.dialogService.add(SettingDialog, { | ||
onApply: (hiddenItems) => { | ||
localStorage.setItem("awesome_dashboard_hidden_items", JSON.stringify(hiddenItems)); | ||
this.state.hiddenItems = hiddenItems; | ||
} | ||
}); | ||
} | ||
} | ||
|
||
registry.category("lazy_components").add("awesome_dashboard.dashboard", AwesomeDashboard); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
<?xml version="1.0" encoding="UTF-8" ?> | ||
<templates xml:space="preserve"> | ||
<t t-name="awesome_dashboard.AwesomeDashboard"> | ||
<div class="o_action"> | ||
<Layout display="{ controlPanel: {} }" className="'o_dashboard '"> | ||
<t t-set-slot="control-panel-create-button"> | ||
<button class="btn btn-primary" t-on-click="openCustomers"> Customers</button> | ||
<button class="btn btn-secondary" t-on-click="openLeads"> Leads </button> | ||
</t> | ||
<t t-set-slot="control-panel-additional-actions"> | ||
<button class="btn p-0" t-on-click="openSettings"> | ||
<i class="fa fa-cog">Settings</i> | ||
</button> | ||
</t> | ||
<div class="d-flex flex-wrap text-center"> | ||
<t t-foreach="getFilteredItems()" t-as="item" t-key="item.id"> | ||
<DashboardItem size="item.size || 1"> | ||
<t t-set="itemProps" t-value="item.props ? item.props(statistics) : {'data': statistics}"/> | ||
<t t-component="item.component" t-props="itemProps"/> | ||
</DashboardItem> | ||
</t> | ||
</div> | ||
</Layout> | ||
</div> | ||
</t> | ||
</templates> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
import { registry } from "@web/core/registry" | ||
import { NumberCard } from "./components/number_card/number_card"; | ||
import { PieChart } from "./components/pie_chart/pie_chart"; | ||
import { _t } from "@web/core/l10n/translation"; | ||
|
||
const dashboardRegistry = registry.category("awesome_dashboard.items"); | ||
|
||
|
||
dashboardRegistry.add("average_quantity", { | ||
id: "average_quantity", | ||
description: _t("Average amount of t-shirt"), | ||
component: NumberCard, | ||
size: 2, | ||
props: (data) => ({ | ||
label: _t("Average Quantity"), | ||
value: data.average_quantity, | ||
}), | ||
}); | ||
|
||
dashboardRegistry.add("average_time", { | ||
id: "average_time", | ||
description: _t("Average order processing time"), | ||
component: NumberCard, | ||
size: 2, | ||
props: (data) => ({ | ||
label: _t("Average time"), | ||
value: data.average_time, | ||
}), | ||
}); | ||
|
||
dashboardRegistry.add("nb_new_orders", { | ||
id: "nb_new_orders", | ||
description: _t("New orders this month"), | ||
component: NumberCard, | ||
size: 1, | ||
props: (data) => ({ | ||
label: _t("New orders this month"), | ||
value: data.nb_new_orders, | ||
}), | ||
}); | ||
|
||
dashboardRegistry.add("nb_cancelled_orders", { | ||
id: "nb_cancelled_orders", | ||
description: _t("Cancelled orders this month"), | ||
component: NumberCard, | ||
size: 1, | ||
props: (data) => ({ | ||
label: _t("Number of Cancelled Orders this month"), | ||
value: data.nb_cancelled_orders, | ||
}), | ||
}); | ||
|
||
dashboardRegistry.add("total_amount", { | ||
id: "total_amount", | ||
description: _t("Total sales amount"), | ||
component: NumberCard, | ||
size: 1, | ||
props: (data) => ({ | ||
label: _t("Total amount of new Orders This Month"), | ||
value: data.total_amount, | ||
}), | ||
}); | ||
|
||
dashboardRegistry.add("orders_by_size", { | ||
id: "orders_by_size", | ||
description: _t("Shirt orders by size"), | ||
component: PieChart, | ||
size: 2, | ||
props: (data) => ({ | ||
label: _t("Shirt orders by size"), | ||
data: data.orders_by_size, | ||
}), | ||
}); |
36 changes: 36 additions & 0 deletions
36
awesome_dashboard/static/src/dashboard/services/statistics.js
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
import { registry } from "@web/core/registry"; | ||
import { rpc } from "@web/core/network/rpc"; | ||
import { reactive } from "@odoo/owl"; | ||
import { memoize } from "@web/core/utils/functions"; | ||
|
||
|
||
export const statisticsService = { | ||
|
||
start() { | ||
const stats = reactive({ | ||
nb_new_orders: 0, | ||
total_amount: 0, | ||
average_quantity: 0, | ||
nb_cancelled_orders: 0, | ||
average_time: 0, | ||
orders_by_size: { m: 0, s: 0, xl: 0 } | ||
}); | ||
|
||
const loadStatistics = memoize(async () => { | ||
const result = await rpc("/awesome_dashboard/statistics", {}); | ||
if (result) { | ||
Object.assign(stats, result); | ||
} | ||
}); | ||
|
||
loadStatistics(); | ||
|
||
setInterval(() => { | ||
loadStatistics(); | ||
}, 1000); | ||
|
||
return { data: stats }; | ||
}, | ||
}; | ||
|
||
registry.category("services").add("awesome_dashboard.statistics", statisticsService); |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
[ADD] estate: initial Real Estate module with models, views, and rela… #757
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: 18.0
Are you sure you want to change the base?