-
Notifications
You must be signed in to change notification settings - Fork 2.6k
Awesome Dashboard #978
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
Open
Mohamed-Dallash
wants to merge
21
commits into
odoo:18.0
Choose a base branch
from
odoo-dev:18.0-build-a-dashboard-mohmo
base: 18.0
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Awesome Dashboard #978
Changes from all commits
Commits
Show all changes
21 commits
Select commit
Hold shift + click to select a range
e610aa0
[IMP] dashboard: add layout component to dashboard
Mohamed-Dallash c1be7a0
[IMP] dashboard: add quick navigation buttons
Mohamed-Dallash ec83700
[ADD] Dashboard Item
Mohamed-Dallash 379d84d
[IMP] Dashboard: add some statistics to the dashboard, get the data f…
Mohamed-Dallash a652292
[IMP] dashboard: add statistics caching
Mohamed-Dallash c38b2b8
[IMP] dashboard: add pie chart for shirt orders by size to the dashboard
Mohamed-Dallash f8818ed
[IMP] dashboard: periodically update statistics
Mohamed-Dallash 670399f
[IMP] dashboard: lazy load the dashboard
Mohamed-Dallash 704adb3
[IMP] dashboard: make the dashboard generic
Mohamed-Dallash aec9520
[IMP] dashbaord: make the dashboard estensible
Mohamed-Dallash 10d91f0
[IMP] dashboard: add and remove dashboard items
Mohamed-Dallash 62a0dcb
[IMP] dashboard: add new lines to files that didn't have it at the en…
Mohamed-Dallash 93eba2e
[IMP] dashboard: allow variable chart type
Mohamed-Dallash bbd55c6
[IMP] dashboard: update formatting in configuration_dialog
Mohamed-Dallash 9c6d675
[IMP] dashboard: remove unnecessary browser import
Mohamed-Dallash e490a77
[IMP] dashboard: make titles translatable
Mohamed-Dallash 55a69a3
[I18N] dashboard: add arabic translations
Mohamed-Dallash f66adc5
[IMP] dashboard: store user dashboard preferences in the DB instead …
Mohamed-Dallash a7e1441
[IMP] dashboard: tidy up the get disabled items function
Mohamed-Dallash dc5abeb
[IMP] dashboard: use more concise naming for disabled items variable
Mohamed-Dallash d8b2a2c
[IMP] dashboard: remove unnecessary default string, unnecessary array…
Mohamed-Dallash 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
There are no files selected for viewing
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 |
---|---|---|
@@ -1,3 +1,4 @@ | ||
# -*- coding: utf-8 -*- | ||
|
||
from . import controllers | ||
from . import models |
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
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,87 @@ | ||
# Translation of Odoo Server. | ||
# This file contains the translation of the following modules: | ||
# * awesome_dashboard | ||
# | ||
msgid "" | ||
msgstr "" | ||
"Project-Id-Version: Odoo Server 18.0+e\n" | ||
"Report-Msgid-Bugs-To: \n" | ||
"POT-Creation-Date: 2025-09-29 07:53+0000\n" | ||
"PO-Revision-Date: 2025-09-29 07:53+0000\n" | ||
"Last-Translator: \n" | ||
"Language-Team: \n" | ||
"MIME-Version: 1.0\n" | ||
"Content-Type: text/plain; charset=UTF-8\n" | ||
"Content-Transfer-Encoding: \n" | ||
"Plural-Forms: \n" | ||
|
||
#. module: awesome_dashboard | ||
#. odoo-javascript | ||
#: code:addons/awesome_dashboard/static/src/dashboard/dashboard_items.js:0 | ||
msgid "Average amount of t-shirt by order this month" | ||
msgstr "Average amount of t-shirt by order this month (AR)" | ||
|
||
#. module: awesome_dashboard | ||
#. odoo-javascript | ||
#: code:addons/awesome_dashboard/static/src/dashboard/dashboard_items.js:0 | ||
msgid "Average time for an order to go from 'new' to 'sent' of 'cancelled'" | ||
msgstr "Average time for an order to go from 'new' to 'sent' of 'cancelled' (AR)" | ||
|
||
#. module: awesome_dashboard | ||
#: model:ir.ui.menu,name:awesome_dashboard.menu_root | ||
msgid "Awesome Dashboard" | ||
msgstr "Awesome Dashboard (AR)" | ||
|
||
#. module: awesome_dashboard | ||
#. odoo-javascript | ||
#: code:addons/awesome_dashboard/static/src/dashboard/dashboard.xml:0 | ||
msgid "Customers" | ||
msgstr "Customers (AR)" | ||
|
||
#. module: awesome_dashboard | ||
#: model:ir.actions.client,name:awesome_dashboard.dashboard | ||
#: model:ir.ui.menu,name:awesome_dashboard.dashboard_menu | ||
msgid "Dashboard" | ||
msgstr "Dashboard (AR)" | ||
|
||
#. module: awesome_dashboard | ||
#. odoo-javascript | ||
#: code:addons/awesome_dashboard/static/src/dashboard/configuration_dialog/configuration_dialog.xml:0 | ||
msgid "Done" | ||
msgstr "Done (AR)" | ||
|
||
#. module: awesome_dashboard | ||
#. odoo-javascript | ||
#: code:addons/awesome_dashboard/static/src/dashboard/dashboard.xml:0 | ||
msgid "Leads" | ||
msgstr "Leads (AR)" | ||
|
||
#. module: awesome_dashboard | ||
#. odoo-javascript | ||
#: code:addons/awesome_dashboard/static/src/dashboard/dashboard_items.js:0 | ||
msgid "Number of cancelled orders this month" | ||
msgstr "Number of cancelled orders this month (AR)" | ||
|
||
#. module: awesome_dashboard | ||
#. odoo-javascript | ||
#: code:addons/awesome_dashboard/static/src/dashboard/dashboard_items.js:0 | ||
msgid "Number of new orders this month" | ||
msgstr "Number of new orders this month (AR)" | ||
|
||
#. module: awesome_dashboard | ||
#. odoo-javascript | ||
#: code:addons/awesome_dashboard/static/src/dashboard/dashboard_items.js:0 | ||
msgid "Shirt orders by size" | ||
msgstr "Shirt orders by size (AR)" | ||
|
||
#. module: awesome_dashboard | ||
#. odoo-javascript | ||
#: code:addons/awesome_dashboard/static/src/dashboard/dashboard_items.js:0 | ||
msgid "Total amount of new orders this month" | ||
msgstr "Total amount of new orders this month (AR)" | ||
|
||
#. module: awesome_dashboard | ||
#. odoo-javascript | ||
#: code:addons/awesome_dashboard/static/src/dashboard/configuration_dialog/configuration_dialog.xml:0 | ||
msgid "Which cards do you wish to see?" | ||
msgstr "Which cards do you wish to see (AR)?" |
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 @@ | ||
from . import res_users_settings |
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,7 @@ | ||
from odoo import models, fields | ||
|
||
|
||
class ResUsersSettings(models.Model): | ||
_inherit = "res.users.settings" | ||
|
||
disabled_dashboard_items = fields.Text() |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
12 changes: 12 additions & 0 deletions
12
awesome_dashboard/static/src/dashboard/chart_card/chart_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,12 @@ | ||
import { Component } from "@odoo/owl"; | ||
import { DashboardChart } from "../dashboard_chart"; | ||
|
||
export class ChartCard extends Component { | ||
static template = "awesome_dashboard.ChartCard"; | ||
static components = { DashboardChart }; | ||
static props = { | ||
title: String, | ||
value: Object, | ||
type: String, | ||
} | ||
} |
9 changes: 9 additions & 0 deletions
9
awesome_dashboard/static/src/dashboard/chart_card/chart_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,9 @@ | ||
<?xml version="1.0" encoding="UTF-8" ?> | ||
<templates xml:space="preserve"> | ||
|
||
<t t-name="awesome_dashboard.ChartCard"> | ||
<t t-esc="props.title"/> | ||
<DashboardChart label="props.title" data="props.value" type="props.type"/> | ||
</t> | ||
|
||
</templates> |
42 changes: 42 additions & 0 deletions
42
awesome_dashboard/static/src/dashboard/configuration_dialog/configuration_dialog.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,42 @@ | ||
import { Component, useState } from "@odoo/owl"; | ||
import { Dialog } from "@web/core/dialog/dialog"; | ||
import { CheckBox } from "@web/core/checkbox/checkbox"; | ||
|
||
|
||
export class ConfigurationDialog extends Component { | ||
static template = "awesome_dashboard.ConfigurationDialog"; | ||
static components = { Dialog, CheckBox }; | ||
static props = { | ||
items: { type: Array }, | ||
disabledItems: { | ||
type: Array, | ||
element: { | ||
type: String, | ||
} | ||
}, | ||
onUpdateConfig: Function, | ||
close: Function, | ||
} | ||
|
||
setup() { | ||
this.items = useState(this.props.items.map((item) => { | ||
return { | ||
id: item.id, | ||
description: item.description, | ||
enabled: !this.props.disabledItems.includes(item.id), | ||
} | ||
})); | ||
} | ||
|
||
onChange(checked, item) { | ||
item.enabled = checked; | ||
const updatedDisabledItems = Object.values(this.items).filter( | ||
(item) => !item.enabled | ||
).map((item) => item.id); | ||
this.props.onUpdateConfig(updatedDisabledItems); | ||
} | ||
|
||
done() { | ||
this.props.close(); | ||
} | ||
} |
18 changes: 18 additions & 0 deletions
18
awesome_dashboard/static/src/dashboard/configuration_dialog/configuration_dialog.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,18 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<templates> | ||
<t t-name="awesome_dashboard.ConfigurationDialog"> | ||
<Dialog size="'md'" title="'Dashboard items configuration'"> | ||
Which cards do you wish to see? | ||
<t t-foreach="items" t-as="item" t-key="item.id"> | ||
<CheckBox value="item.enabled" onChange="(ev) => this.onChange(ev,item)"> | ||
<t t-esc="item.description"/> | ||
</CheckBox> | ||
</t> | ||
<t t-set-slot="footer"> | ||
<button class="btn btn-primary" t-on-click="done"> | ||
Done | ||
</button> | ||
</t> | ||
</Dialog> | ||
</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,57 @@ | ||
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 { ConfigurationDialog } from "./configuration_dialog/configuration_dialog"; | ||
import { user } from "@web/core/user"; | ||
|
||
class AwesomeDashboard extends Component { | ||
static template = "awesome_dashboard.AwesomeDashboard"; | ||
static components = { Layout, DashboardItem }; | ||
|
||
setup() { | ||
this.action = useService("action"); | ||
this.statistics = useState(useService("statistics_service")); | ||
this.items = registry.category("awesome_dashboard").getAll(); | ||
this.dialog = useService("dialog"); | ||
this.state = useState({ disabledItems: this.getDisabledItems() }) | ||
} | ||
|
||
getDisabledItems() { | ||
const disabled_items = user.settings.disabled_dashboard_items; | ||
return disabled_items ? disabled_items.split(",") : []; | ||
} | ||
|
||
openCustomers() { | ||
this.action.doAction("base.action_partner_form"); | ||
} | ||
|
||
openLeads() { | ||
this.action.doAction({ | ||
type: 'ir.actions.act_window', | ||
name: "Leads", | ||
target: 'current', | ||
res_model: 'crm.lead', | ||
views: [ | ||
[false, 'list'], | ||
[false, 'form'], | ||
], | ||
}); | ||
} | ||
|
||
updateConfig(newDisabledItems) { | ||
this.state.disabledItems = newDisabledItems; | ||
user.setUserSettings("disabled_dashboard_items", this.state.disabledItems.join(",")); | ||
} | ||
|
||
openConfig() { | ||
this.dialog.add(ConfigurationDialog, { | ||
items: this.items, | ||
disabledItems: this.state.disabledItems, | ||
onUpdateConfig: this.updateConfig.bind(this), | ||
}); | ||
} | ||
} | ||
|
||
registry.category("lazy_components").add("AwesomeDashboard", 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,3 @@ | ||
.o_dashboard { | ||
background-color: gray; | ||
} |
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"> | ||
<Layout display="{controlPanel: {}}" className="'o_dashboard h-100'"> | ||
<t t-set-slot="layout-buttons"> | ||
<button class="btn btn-primary" t-on-click="openCustomers">Customers</button> | ||
<button class="btn btn-primary" t-on-click="openLeads">Leads</button> | ||
</t> | ||
<t t-set-slot="control-panel-additional-actions"> | ||
<button class="btn p-0 ms-1 border-0" t-on-click="openConfig"> | ||
<i class="fa fa-cog"/> | ||
</button> | ||
</t> | ||
<div class="d-flex flex-wrap" t-if="statistics.isReady"> | ||
<t t-foreach="items" t-as="item" t-key="item.id"> | ||
<DashboardItem t-if="!state.disabledItems.includes(item.id)" size="item.size"> | ||
<t t-set="itemProp" t-value="item.props ? item.props(statistics) : {'data': statistics}"/> | ||
<t t-component="item.Component" t-props="itemProp" /> | ||
</DashboardItem> | ||
</t> | ||
</div> | ||
</Layout> | ||
</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,39 @@ | ||
import { Component, onWillStart, useRef, useEffect, onWillUnmount } from "@odoo/owl"; | ||
import { loadJS } from "@web/core/assets"; | ||
|
||
export class DashboardChart extends Component { | ||
static template = "awesome_dashboard.DashboardChart" | ||
static props = { | ||
label: String, | ||
data: Object, | ||
type: { validate: t => ["pie", "bar", "line"].includes(t) }, | ||
} | ||
|
||
setup() { | ||
this.canvasRef = useRef('canvas') | ||
onWillStart(() => { | ||
return loadJS("/web/static/lib/Chart/Chart.js") | ||
}) | ||
useEffect(() => this.renderChart()); | ||
onWillUnmount(() => { | ||
this.chart?.destroy(); | ||
}) | ||
} | ||
|
||
renderChart() { | ||
this.chart?.destroy(); | ||
const config = { | ||
type: this.props.type, | ||
data: { | ||
labels: Object.keys(this.props.data), | ||
datasets: [{ | ||
label: this.props.label, | ||
data: Object.values(this.props.data) | ||
|
||
}], | ||
} | ||
|
||
}; | ||
this.chart = new Chart(this.canvasRef.el, config); | ||
} | ||
} |
10 changes: 10 additions & 0 deletions
10
awesome_dashboard/static/src/dashboard/dashboard_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,10 @@ | ||
<?xml version="1.0" encoding="UTF-8" ?> | ||
<templates xml:space="preserve"> | ||
|
||
<t t-name="awesome_dashboard.DashboardChart"> | ||
<div class="canvas-container mt-auto d-flex align-items-end"> | ||
<canvas t-ref="canvas"/> | ||
</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,15 @@ | ||
import { Component } from "@odoo/owl"; | ||
|
||
export class DashboardItem extends Component { | ||
static template = "awesome_dashboard.DashboardItem"; | ||
static props = { | ||
slots: Object, | ||
size: { | ||
type: Number, | ||
optional: true, | ||
} | ||
} | ||
static defaultProps = { | ||
size: 1, | ||
} | ||
} |
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,12 @@ | ||
<?xml version="1.0" encoding="UTF-8" ?> | ||
<templates xml:space="preserve"> | ||
|
||
<t t-name="awesome_dashboard.DashboardItem"> | ||
<div class="card d-inline-block m-2" t-attf-style="width: {{18*props.size}}rem;"> | ||
<div class="card-body"> | ||
<t t-slot="default"/> | ||
</div> | ||
</div> | ||
</t> | ||
|
||
</templates> |
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.
Uh oh!
There was an error while loading. Please reload this page.