From 385cc8d6225e8984e33cae6102eee5bc1e49e7ba Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?L=C3=A9opold=20Cantraine?= Date: Tue, 23 Sep 2025 11:25:53 +0200 Subject: [PATCH 1/3] [ADD] Web framework tutorial --- .../static/src/dashboard/dashboard.js | 31 +++++++++++ .../static/src/dashboard/dashboard.scss | 3 ++ .../static/src/dashboard/dashboard.xml | 51 +++++++++++++++++++ .../static/src/dashboard/dashboard_item.js | 15 ++++++ .../static/src/dashboard/dashboard_item.xml | 12 +++++ .../static/src/dashboard/piechart.js | 39 ++++++++++++++ .../static/src/dashboard/piechart.xml | 10 ++++ .../static/src/dashboard_loader.js | 0 awesome_dashboard/static/src/statistics.js | 21 ++++++++ awesome_owl/static/src/card/card.js | 30 +++++++++++ awesome_owl/static/src/card/card.xml | 14 +++++ awesome_owl/static/src/counter/counter.js | 18 +++++++ awesome_owl/static/src/counter/counter.xml | 9 ++++ awesome_owl/static/src/playground.js | 20 ++++++-- awesome_owl/static/src/playground.xml | 15 ++++-- awesome_owl/static/src/todo/todo-item.xml | 14 +++++ awesome_owl/static/src/todo/todo_item.js | 20 ++++++++ awesome_owl/static/src/todo/todo_list.js | 31 +++++++++++ awesome_owl/static/src/todo/todo_list.xml | 13 +++++ awesome_owl/static/src/utils.js | 8 +++ 20 files changed, 368 insertions(+), 6 deletions(-) create mode 100644 awesome_dashboard/static/src/dashboard/dashboard.js create mode 100644 awesome_dashboard/static/src/dashboard/dashboard.scss create mode 100644 awesome_dashboard/static/src/dashboard/dashboard.xml create mode 100644 awesome_dashboard/static/src/dashboard/dashboard_item.js create mode 100644 awesome_dashboard/static/src/dashboard/dashboard_item.xml create mode 100644 awesome_dashboard/static/src/dashboard/piechart.js create mode 100644 awesome_dashboard/static/src/dashboard/piechart.xml create mode 100644 awesome_dashboard/static/src/dashboard_loader.js create mode 100644 awesome_dashboard/static/src/statistics.js create mode 100644 awesome_owl/static/src/card/card.js create mode 100644 awesome_owl/static/src/card/card.xml create mode 100644 awesome_owl/static/src/counter/counter.js create mode 100644 awesome_owl/static/src/counter/counter.xml create mode 100644 awesome_owl/static/src/todo/todo-item.xml create mode 100644 awesome_owl/static/src/todo/todo_item.js create mode 100644 awesome_owl/static/src/todo/todo_list.js create mode 100644 awesome_owl/static/src/todo/todo_list.xml create mode 100644 awesome_owl/static/src/utils.js diff --git a/awesome_dashboard/static/src/dashboard/dashboard.js b/awesome_dashboard/static/src/dashboard/dashboard.js new file mode 100644 index 00000000000..dd8878e5084 --- /dev/null +++ b/awesome_dashboard/static/src/dashboard/dashboard.js @@ -0,0 +1,31 @@ +import { Component, useState } from "@odoo/owl"; +import { registry } from "@web/core/registry"; +import { Layout } from "@web/search/layout"; +import { useService } from "@web/core/utils/hooks"; +import { DashboardItem } from "./dashboard_item"; +import { PieChart } from "./piechart"; + +class AwesomeDashboard extends Component { + static template = "awesome_dashboard.AwesomeDashboard"; + static components = { Layout, DashboardItem, PieChart }; + + setup() { + this.action = useService("action"); + this.statistics = useState(useService("awesome_dashboard.statistics")); + } + + openCustomerView() { + this.action.doAction("base.action_partner_form"); + } + + openLeads() { + this.action.doAction({ + type: "ir.actions.act_window", + name: "All leads", + res_model: "crm.lead", + views: [[false, "list"], [false, "form"]], + }); + } +} + +registry.category("lazy_components").add("awesome_dashboard.dashboard", AwesomeDashboard); diff --git a/awesome_dashboard/static/src/dashboard/dashboard.scss b/awesome_dashboard/static/src/dashboard/dashboard.scss new file mode 100644 index 00000000000..769fc1e72f9 --- /dev/null +++ b/awesome_dashboard/static/src/dashboard/dashboard.scss @@ -0,0 +1,3 @@ +.o_dashboard { + background-color: gray; +} \ No newline at end of file diff --git a/awesome_dashboard/static/src/dashboard/dashboard.xml b/awesome_dashboard/static/src/dashboard/dashboard.xml new file mode 100644 index 00000000000..258a8a89eaf --- /dev/null +++ b/awesome_dashboard/static/src/dashboard/dashboard.xml @@ -0,0 +1,51 @@ + + + + + + + + + +
+ + Number of new orders this month : +
+ +
+
+ + Total amount of new orders this month : +
+ +
+
+ + Average amount of t-shirt by order this month : +
+ +
+
+ + Number of cancelled orders this month : +
+ +
+
+ + Average time for an order to go from 'new' to 'sent' or 'cancelled': +
+ +
+
+ +
+ + + +
+
+
+
+ +
diff --git a/awesome_dashboard/static/src/dashboard/dashboard_item.js b/awesome_dashboard/static/src/dashboard/dashboard_item.js new file mode 100644 index 00000000000..2440bdf179f --- /dev/null +++ b/awesome_dashboard/static/src/dashboard/dashboard_item.js @@ -0,0 +1,15 @@ +import { Component } from "@odoo/owl"; + +export class DashboardItem extends Component { + static template = "awesome_dashboard.DashboardItem" + static props = { + slots: { + type: Object, + }, + size: { + type: Number, + default: 1, + optional: true, + }, + }; +} \ No newline at end of file diff --git a/awesome_dashboard/static/src/dashboard/dashboard_item.xml b/awesome_dashboard/static/src/dashboard/dashboard_item.xml new file mode 100644 index 00000000000..baa15f159c4 --- /dev/null +++ b/awesome_dashboard/static/src/dashboard/dashboard_item.xml @@ -0,0 +1,12 @@ + + + + +
+
+ +
+
+
+ +
\ No newline at end of file diff --git a/awesome_dashboard/static/src/dashboard/piechart.js b/awesome_dashboard/static/src/dashboard/piechart.js new file mode 100644 index 00000000000..8987f4a8ccb --- /dev/null +++ b/awesome_dashboard/static/src/dashboard/piechart.js @@ -0,0 +1,39 @@ +import { loadJS } from "@web/core/assets"; +import { Component, onWillStart, useRef, useEffect, onWillUnmount } from "@odoo/owl"; + +export class PieChart extends Component { + static template = "awesome_dashboard.PieChart"; + static props = { + label: String, + data: Object, + }; + + setup() { + this.canvasRef = useRef("canvas"); + onWillStart(() => loadJS("/web/static/lib/Chart/Chart.js")); + useEffect(() => { + if (this.chart) { this.chart.destroy();} + this.displayChart(); + }); + onWillUnmount(() => { + this.chart.destroy(); + }); + } + + displayChart() { + const labels = Object.keys(this.props.data); + const data = Object.values(this.props.data); + this.chart = new Chart(this.canvasRef.el, { + type: "pie", + data: { + labels: labels, + datasets: [ + { + label: this.props.label, + data: data, + }, + ], + }, + }); + } +} \ No newline at end of file diff --git a/awesome_dashboard/static/src/dashboard/piechart.xml b/awesome_dashboard/static/src/dashboard/piechart.xml new file mode 100644 index 00000000000..18416e9a223 --- /dev/null +++ b/awesome_dashboard/static/src/dashboard/piechart.xml @@ -0,0 +1,10 @@ + + + +
+
+ +
+
+
+
\ No newline at end of file diff --git a/awesome_dashboard/static/src/dashboard_loader.js b/awesome_dashboard/static/src/dashboard_loader.js new file mode 100644 index 00000000000..e69de29bb2d diff --git a/awesome_dashboard/static/src/statistics.js b/awesome_dashboard/static/src/statistics.js new file mode 100644 index 00000000000..59326f0dac7 --- /dev/null +++ b/awesome_dashboard/static/src/statistics.js @@ -0,0 +1,21 @@ +import { registry } from "@web/core/registry"; +import { rpc } from "@web/core/network/rpc"; +import { reactive } from "@odoo/owl"; + +const statisticService = { + start() { + const statistics = reactive({debounce: false}); + + async function loadStatistics() { + const updates = await rpc("/awesome_dashboard/statistics"); + Object.assign(statistics, updates, {debounce: true}); + } + + setInterval(loadStatistics, 5 * 1000); + loadStatistics(); + + return statistics; + } +}; + +registry.category("services").add("awesome_dashboard.statistics", statisticService); diff --git a/awesome_owl/static/src/card/card.js b/awesome_owl/static/src/card/card.js new file mode 100644 index 00000000000..f2816f8c1e1 --- /dev/null +++ b/awesome_owl/static/src/card/card.js @@ -0,0 +1,30 @@ +import { Component, useState } from "@odoo/owl"; + +export class Card extends Component { + static template = "awesome_owl.card"; + static props = { + title: String, + slots: { + type: Object, + shape: { + default: true + }, + optional: true, + } + }; + + setup() { + this.state = useState({ + open: true, + title: this.props.title, + }); + } + + increment() { + this.state.value++; + } + + toggleOpen() { + this.state.open = !this.state.open; + } +} diff --git a/awesome_owl/static/src/card/card.xml b/awesome_owl/static/src/card/card.xml new file mode 100644 index 00000000000..4f0700d1424 --- /dev/null +++ b/awesome_owl/static/src/card/card.xml @@ -0,0 +1,14 @@ + + + +
+ +
+
+

+ +

+
+
+
+
\ No newline at end of file diff --git a/awesome_owl/static/src/counter/counter.js b/awesome_owl/static/src/counter/counter.js new file mode 100644 index 00000000000..9c72c4ccf34 --- /dev/null +++ b/awesome_owl/static/src/counter/counter.js @@ -0,0 +1,18 @@ +import { Component, useState } from "@odoo/owl"; + +export class Counter extends Component { + static template = "awesome_owl.counter"; + static props = {onChange: {type: Function, optional: true}}; + + setup() { + this.state = useState({ value: 0 }); + } + + increment() { + this.state.value++; + if (this.props.onChange) { + console.log("Incrementing, new value:", this.state.value); + this.props.onChange(); + } + } +} diff --git a/awesome_owl/static/src/counter/counter.xml b/awesome_owl/static/src/counter/counter.xml new file mode 100644 index 00000000000..57a474dc5e9 --- /dev/null +++ b/awesome_owl/static/src/counter/counter.xml @@ -0,0 +1,9 @@ + + + + +

Counter:

+ +
+ +
diff --git a/awesome_owl/static/src/playground.js b/awesome_owl/static/src/playground.js index 657fb8b07bb..678555a03af 100644 --- a/awesome_owl/static/src/playground.js +++ b/awesome_owl/static/src/playground.js @@ -1,7 +1,21 @@ -/** @odoo-module **/ - -import { Component } from "@odoo/owl"; +import { Component, useState, markup } from "@odoo/owl"; +import { Counter } from "./counter/counter"; +import { Card } from "./card/card"; +import { TodoList } from "./todo/todo_list"; export class Playground extends Component { static template = "awesome_owl.playground"; + static components = { Counter, Card, TodoList }; + + setup() { + this.state = useState({ sum: 2 }); + this.incrementSum = this.incrementSum.bind(this); + } + + fst_value = markup("fst"); + snd_value = "snd"; + + incrementSum() { + this.state.sum++; + } } diff --git a/awesome_owl/static/src/playground.xml b/awesome_owl/static/src/playground.xml index 4fb905d59f9..7b21f2fef50 100644 --- a/awesome_owl/static/src/playground.xml +++ b/awesome_owl/static/src/playground.xml @@ -2,9 +2,18 @@ -
- hello world + + +

Sum:

+
+ + + + +
+
+
- + diff --git a/awesome_owl/static/src/todo/todo-item.xml b/awesome_owl/static/src/todo/todo-item.xml new file mode 100644 index 00000000000..65b319ac416 --- /dev/null +++ b/awesome_owl/static/src/todo/todo-item.xml @@ -0,0 +1,14 @@ + + + +
+ + + + +
+
+
diff --git a/awesome_owl/static/src/todo/todo_item.js b/awesome_owl/static/src/todo/todo_item.js new file mode 100644 index 00000000000..bc6e1717871 --- /dev/null +++ b/awesome_owl/static/src/todo/todo_item.js @@ -0,0 +1,20 @@ +import { Component, useState } from "@odoo/owl"; + +export class TodoItem extends Component { + static template = "awesome_owl.todoItem"; + static props = { todo: Object, removeTodo: Function, toggle: Function }; + + setup() { + this.isCompleted = this.props.todo.isCompleted; + this.toggle = this.toggle.bind(this); + } + + toggle() { + this.props.toggle(this.props.todo); + } + + remove() { + this.props.removeTodo(this.props.todo); + } + +} diff --git a/awesome_owl/static/src/todo/todo_list.js b/awesome_owl/static/src/todo/todo_list.js new file mode 100644 index 00000000000..f8bbc891cda --- /dev/null +++ b/awesome_owl/static/src/todo/todo_list.js @@ -0,0 +1,31 @@ +import { Component, useState } from "@odoo/owl"; +import { TodoItem } from "./todo_item"; +import { useAutofocus } from "../utils"; + +export class TodoList extends Component { + static template = "awesome_owl.todolist"; + static components = { TodoItem }; + + setup() { + this.state = useState({todos : []}); + useAutofocus("input"); + } + + addTodo(ev) { + if (ev.keyCode === 13 && ev.target.value.trim().length > 0) { + this.state.todos.push({ id: this.state.todos.length, description: ev.target.value.trim() }); + ev.target.value = ""; + } + } + + removeTodo(todo) { + const index = this.state.todos.findIndex(t => t.id === todo.id); + if (index !== -1) { + this.state.todos.splice(index, 1); + } + } + + toggle(todo) { + todo.isCompleted = !todo.isCompleted; + } +} diff --git a/awesome_owl/static/src/todo/todo_list.xml b/awesome_owl/static/src/todo/todo_list.xml new file mode 100644 index 00000000000..ffefea33bab --- /dev/null +++ b/awesome_owl/static/src/todo/todo_list.xml @@ -0,0 +1,13 @@ + + + +

Todo List

+
+ + + + +
+
+ +
diff --git a/awesome_owl/static/src/utils.js b/awesome_owl/static/src/utils.js new file mode 100644 index 00000000000..6a5475b357e --- /dev/null +++ b/awesome_owl/static/src/utils.js @@ -0,0 +1,8 @@ +import { useRef, onMounted } from "@odoo/owl"; + +export function useAutofocus(refName) { + const ref = useRef(refName); + onMounted(() => { + ref.el.focus(); + }); +} \ No newline at end of file From 783c8d118c86a5d4eb8150ef7df3b9872db43412 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?L=C3=A9opold=20Cantraine?= Date: Wed, 24 Sep 2025 10:19:36 +0200 Subject: [PATCH 2/3] [ADD] Web framework tutorial --- awesome_dashboard/__manifest__.py | 9 ++++++--- awesome_dashboard/static/src/dashboard.js | 10 ---------- awesome_dashboard/static/src/dashboard.xml | 8 -------- 3 files changed, 6 insertions(+), 21 deletions(-) delete mode 100644 awesome_dashboard/static/src/dashboard.js delete mode 100644 awesome_dashboard/static/src/dashboard.xml diff --git a/awesome_dashboard/__manifest__.py b/awesome_dashboard/__manifest__.py index 31406e8addb..86a1da80afc 100644 --- a/awesome_dashboard/__manifest__.py +++ b/awesome_dashboard/__manifest__.py @@ -3,16 +3,16 @@ 'name': "Awesome Dashboard", 'summary': """ - Starting module for "Discover the JS framework, chapter 2: Build a dashboard" + Companion addon for the Odoo JS Framework Training """, 'description': """ - Starting module for "Discover the JS framework, chapter 2: Build a dashboard" + Companion addon for the Odoo JS Framework Training """, 'author': "Odoo", 'website': "https://www.odoo.com/", - 'category': 'Tutorials/AwesomeDashboard', + 'category': 'Tutorials', 'version': '0.1', 'application': True, 'installable': True, @@ -25,6 +25,9 @@ 'web.assets_backend': [ 'awesome_dashboard/static/src/**/*', ], + 'awesome_dashboard.dashboard': [ + 'awesome_dashboard/static/src/dashboard/**/*', + ], }, 'license': 'AGPL-3' } diff --git a/awesome_dashboard/static/src/dashboard.js b/awesome_dashboard/static/src/dashboard.js deleted file mode 100644 index 637fa4bb972..00000000000 --- a/awesome_dashboard/static/src/dashboard.js +++ /dev/null @@ -1,10 +0,0 @@ -/** @odoo-module **/ - -import { Component } from "@odoo/owl"; -import { registry } from "@web/core/registry"; - -class AwesomeDashboard extends Component { - static template = "awesome_dashboard.AwesomeDashboard"; -} - -registry.category("actions").add("awesome_dashboard.dashboard", AwesomeDashboard); diff --git a/awesome_dashboard/static/src/dashboard.xml b/awesome_dashboard/static/src/dashboard.xml deleted file mode 100644 index 1a2ac9a2fed..00000000000 --- a/awesome_dashboard/static/src/dashboard.xml +++ /dev/null @@ -1,8 +0,0 @@ - - - - - hello dashboard - - - From 48957dbb94aec6fff2d059981f0773de009d5f35 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?L=C3=A9opold=20Cantraine?= Date: Thu, 25 Sep 2025 13:43:49 +0200 Subject: [PATCH 3/3] [ADD] Chapter 2 of the webframework --- awesome_dashboard/__manifest__.py | 1 - .../static/src/dashboard/dashboard.js | 60 +++++++++++++++-- .../static/src/dashboard/dashboard.xml | 60 ++++++++--------- .../static/src/dashboard/dashboard_items.js | 64 +++++++++++++++++++ .../static/src/dashboard/number_card.js | 9 +++ .../static/src/dashboard/number_card.xml | 9 +++ .../static/src/dashboard/piechart_card.js | 11 ++++ .../static/src/dashboard/piechart_card.xml | 7 ++ .../static/src/dashboard_loader.js | 13 ++++ 9 files changed, 194 insertions(+), 40 deletions(-) create mode 100644 awesome_dashboard/static/src/dashboard/dashboard_items.js create mode 100644 awesome_dashboard/static/src/dashboard/number_card.js create mode 100644 awesome_dashboard/static/src/dashboard/number_card.xml create mode 100644 awesome_dashboard/static/src/dashboard/piechart_card.js create mode 100644 awesome_dashboard/static/src/dashboard/piechart_card.xml diff --git a/awesome_dashboard/__manifest__.py b/awesome_dashboard/__manifest__.py index 86a1da80afc..b04dc069d6c 100644 --- a/awesome_dashboard/__manifest__.py +++ b/awesome_dashboard/__manifest__.py @@ -1,4 +1,3 @@ -# -*- coding: utf-8 -*- { 'name': "Awesome Dashboard", diff --git a/awesome_dashboard/static/src/dashboard/dashboard.js b/awesome_dashboard/static/src/dashboard/dashboard.js index dd8878e5084..08cb03a83d8 100644 --- a/awesome_dashboard/static/src/dashboard/dashboard.js +++ b/awesome_dashboard/static/src/dashboard/dashboard.js @@ -3,15 +3,21 @@ import { registry } from "@web/core/registry"; import { Layout } from "@web/search/layout"; import { useService } from "@web/core/utils/hooks"; import { DashboardItem } from "./dashboard_item"; -import { PieChart } from "./piechart"; +import { Dialog } from "@web/core/dialog/dialog" +import { CheckBox } from "@web/core/checkbox/checkbox"; +import { browser } from "@web/core/browser/browser"; +import { _t } from "@web/core/l10n/translation"; class AwesomeDashboard extends Component { static template = "awesome_dashboard.AwesomeDashboard"; - static components = { Layout, DashboardItem, PieChart }; + static components = { Layout, DashboardItem }; setup() { this.action = useService("action"); this.statistics = useState(useService("awesome_dashboard.statistics")); + this.items = registry.category("awesome_dashboard.items").getAll(); + this.dialog = useService("dialog"); + this.state = useState({disabledItems: browser.localStorage.getItem("disabledDashboardItems")?.split(",") || []}); } openCustomerView() { @@ -21,11 +27,57 @@ class AwesomeDashboard extends Component { openLeads() { this.action.doAction({ type: "ir.actions.act_window", - name: "All leads", + name: _t("All leads"), res_model: "crm.lead", views: [[false, "list"], [false, "form"]], }); } + + openDialog() { + this.dialog.add(ConfigurationDialog, { + items: this.items, + disabledItems: this.state.disabledItems, + onUpdateConfiguration: this.updateConfiguration.bind(this), + }) + } + + updateConfiguration(newDisabledItems) { + this.state.disabledItems = newDisabledItems; + } +} + + +class ConfigurationDialog extends Component { + static template = "awesome_dashboard.ConfigurationDialog"; + static components = { Dialog, CheckBox }; + static props = ["close", "items", "disabledItems", "onUpdateConfiguration"]; + + setup() { + this.items = useState(this.props.items.map((item) => { + return { + ...item, + enabled: !this.props.disabledItems.includes(item.id), + } + })); + } + + done() { + this.props.close(); + } + + onChange(checked, changedItem) { + changedItem.enabled = checked; + const newDisabledItems = Object.values(this.items).filter( + (item) => !item.enabled + ).map((item) => item.id) + + browser.localStorage.setItem( + "disabledDashboardItems", + newDisabledItems, + ); + + this.props.onUpdateConfiguration(newDisabledItems); + } } -registry.category("lazy_components").add("awesome_dashboard.dashboard", AwesomeDashboard); +registry.category("lazy_components").add("AwesomeDashboard", AwesomeDashboard); diff --git a/awesome_dashboard/static/src/dashboard/dashboard.xml b/awesome_dashboard/static/src/dashboard/dashboard.xml index 258a8a89eaf..2b5149399d4 100644 --- a/awesome_dashboard/static/src/dashboard/dashboard.xml +++ b/awesome_dashboard/static/src/dashboard/dashboard.xml @@ -7,45 +7,35 @@ + + +
- - Number of new orders this month : -
- -
-
- - Total amount of new orders this month : -
- -
-
- - Average amount of t-shirt by order this month : -
- -
-
- - Number of cancelled orders this month : -
- -
-
- - Average time for an order to go from 'new' to 'sent' or 'cancelled': -
- -
-
- -
- - + + + + -
+
+ + + + + + + + + + + + + diff --git a/awesome_dashboard/static/src/dashboard/dashboard_items.js b/awesome_dashboard/static/src/dashboard/dashboard_items.js new file mode 100644 index 00000000000..83fced2cecf --- /dev/null +++ b/awesome_dashboard/static/src/dashboard/dashboard_items.js @@ -0,0 +1,64 @@ +import { _t } from "@web/core/l10n/translation"; +import { NumberCard } from "./number_card"; +import { PieChartCard } from "./piechart_card"; +import { registry } from "@web/core/registry"; + +const items = [ + { + id: "average_quantity", + description: _t("Average amount of t-shirt"), + Component: NumberCard, + props: (data) => ({ + title: _t("Average amount of t-shirt by order this month"), + value: data.average_quantity, + }) + }, + { + id: "average_time", + description: _t("Average time for an order"), + Component: NumberCard, + props: (data) => ({ + title: _t("Average time for an order to go from 'new' to 'sent' or 'cancelled'"), + value: data.average_time, + }) + }, + { + id: "number_new_orders", + description: _t("New orders this month"), + Component: NumberCard, + props: (data) => ({ + title: "Number of new orders this month", + value: data.nb_new_orders, + }) + }, + { + id: "cancelled_orders", + description: _t("Cancelled orders this month"), + Component: NumberCard, + props: (data) => ({ + title: _t("Number of cancelled orders this month"), + value: data.nb_cancelled_orders, + }) + }, + { + id: "amount_new_orders", + description: _t("amount orders this month"), + Component: NumberCard, + props: (data) => ({ + title: _t("Total amount of new orders this month"), + value: data.total_amount, + }) + }, + { + id: "pie_chart", + description: _t("Shirt orders by size"), + Component: PieChartCard, + size: 2, + props: (data) => ({ + title: _t("Shirt orders by size"), + values: data.orders_by_size, + }) + } +] + +items.forEach(item => registry.category("awesome_dashboard.items").add(item.id, item)); \ No newline at end of file diff --git a/awesome_dashboard/static/src/dashboard/number_card.js b/awesome_dashboard/static/src/dashboard/number_card.js new file mode 100644 index 00000000000..74638221df8 --- /dev/null +++ b/awesome_dashboard/static/src/dashboard/number_card.js @@ -0,0 +1,9 @@ +import { Component } from "@odoo/owl"; + +export class NumberCard extends Component { + static template = "awesome_dashboard.NumberCard" + static props = { + title: String, + value: Number, + } +} \ No newline at end of file diff --git a/awesome_dashboard/static/src/dashboard/number_card.xml b/awesome_dashboard/static/src/dashboard/number_card.xml new file mode 100644 index 00000000000..73bc3cac926 --- /dev/null +++ b/awesome_dashboard/static/src/dashboard/number_card.xml @@ -0,0 +1,9 @@ + + + + +
+ +
+
+
\ No newline at end of file diff --git a/awesome_dashboard/static/src/dashboard/piechart_card.js b/awesome_dashboard/static/src/dashboard/piechart_card.js new file mode 100644 index 00000000000..84aa34ee236 --- /dev/null +++ b/awesome_dashboard/static/src/dashboard/piechart_card.js @@ -0,0 +1,11 @@ +import { Component } from "@odoo/owl"; +import { PieChart} from "./piechart"; + +export class PieChartCard extends Component { + static template = "awesome_dashboard.PieChartCard" + static components = { PieChart }; + static props = { + title: String, + value: Object, + } +} \ No newline at end of file diff --git a/awesome_dashboard/static/src/dashboard/piechart_card.xml b/awesome_dashboard/static/src/dashboard/piechart_card.xml new file mode 100644 index 00000000000..62e9fd21256 --- /dev/null +++ b/awesome_dashboard/static/src/dashboard/piechart_card.xml @@ -0,0 +1,7 @@ + + + + + + + \ No newline at end of file diff --git a/awesome_dashboard/static/src/dashboard_loader.js b/awesome_dashboard/static/src/dashboard_loader.js index e69de29bb2d..60659c8b359 100644 --- a/awesome_dashboard/static/src/dashboard_loader.js +++ b/awesome_dashboard/static/src/dashboard_loader.js @@ -0,0 +1,13 @@ +import { Component, xml } from "@odoo/owl"; +import { LazyComponent } from "@web/core/assets"; +import { registry } from "@web/core/registry"; + +class DashboardLoader extends Component { + static components = { LazyComponent }; + static template = xml` + + `; + +} + +registry.category("actions").add("awesome_dashboard.dashboard", DashboardLoader);