diff --git a/.gitignore b/.gitignore index b6e47617de1..cbb028e80c1 100644 --- a/.gitignore +++ b/.gitignore @@ -3,6 +3,9 @@ __pycache__/ *.py[cod] *$py.class +# Ruff filter +*.toml + # C extensions *.so diff --git a/awesome_dashboard/__manifest__.py b/awesome_dashboard/__manifest__.py index a1cd72893d7..e30cf9f72ef 100644 --- a/awesome_dashboard/__manifest__.py +++ b/awesome_dashboard/__manifest__.py @@ -1,4 +1,3 @@ -# -*- coding: utf-8 -*- { 'name': "Awesome Dashboard", @@ -23,8 +22,11 @@ ], 'assets': { 'web.assets_backend': [ - 'awesome_dashboard/static/src/**/*', + 'awesome_dashboard/static/src/dashboard_action.js', + ], + 'awesome_dashboard.dashboard': [ + 'awesome_dashboard/static/src/dashboard/**/*', ], }, - 'license': 'AGPL-3' + 'license': 'AGPL-3', } diff --git a/awesome_dashboard/static/img/dashboard_bg.jpg b/awesome_dashboard/static/img/dashboard_bg.jpg new file mode 100644 index 00000000000..5590ece076b Binary files /dev/null and b/awesome_dashboard/static/img/dashboard_bg.jpg differ diff --git a/awesome_dashboard/static/src/dashboard.js b/awesome_dashboard/static/src/dashboard.js deleted file mode 100644 index c4fb245621b..00000000000 --- a/awesome_dashboard/static/src/dashboard.js +++ /dev/null @@ -1,8 +0,0 @@ -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 - - - diff --git a/awesome_dashboard/static/src/dashboard/Dashboard/dashboard.js b/awesome_dashboard/static/src/dashboard/Dashboard/dashboard.js new file mode 100644 index 00000000000..ea092f333db --- /dev/null +++ b/awesome_dashboard/static/src/dashboard/Dashboard/dashboard.js @@ -0,0 +1,69 @@ +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 "../DashboardItem/dashboarditem"; +import { DashboardSettings } from "../DashboardSettings/dashboardsettings"; +import "../dashboard_items"; + +const STORAGE_KEY = "awesome_dashboard.removed_item_ids"; + +class AwesomeDashboard extends Component { + static template = "awesome_dashboard.AwesomeDashboard"; + static components = { Layout, DashboardItem }; + + setup() { + this.allItems = registry.category("awesome_dashboard").getAll(); + this.actionService = useService("action"); + this.dialogService = useService("dialog"); + this.statisticsService = useService("awesome_dashboard.statistics"); + this.statistics = useState(this.statisticsService.statistics); + this.state = useState({ + removedItemIds: this.loadRemovedItemIds(), + }); + } + + loadRemovedItemIds() { + try { + const value = localStorage.getItem(STORAGE_KEY); + const parsed = value ? JSON.parse(value) : []; + return Array.isArray(parsed) ? parsed : []; + } catch { + return []; + } + } + + saveRemovedItemIds(removedItemIds) { + localStorage.setItem(STORAGE_KEY, JSON.stringify(removedItemIds)); + this.state.removedItemIds = removedItemIds; + } + + get items() { + const removedIds = new Set(this.state.removedItemIds); + return this.allItems.filter((item) => !removedIds.has(item.id)); + } + + openCustomers() { + this.actionService.doAction("base.action_partner_form"); + } + + openLeads() { + this.actionService.doAction({ + type: "ir.actions.act_window", + name: "Leads", + res_model: "crm.lead", + views: [[false, "list"], [false, "form"]], + }); + } + + openSettings() { + this.dialogService.add(DashboardSettings, { + title: "Dashboard settings", + removedItemIds: this.state.removedItemIds, + applyConfiguration: (removedItemIds) => this.saveRemovedItemIds(removedItemIds), + }); + } + +} + +registry.category("lazy_components").add("AwesomeDashboard", AwesomeDashboard); diff --git a/awesome_dashboard/static/src/dashboard/Dashboard/dashboard.scss b/awesome_dashboard/static/src/dashboard/Dashboard/dashboard.scss new file mode 100644 index 00000000000..e61057d0d5a --- /dev/null +++ b/awesome_dashboard/static/src/dashboard/Dashboard/dashboard.scss @@ -0,0 +1,22 @@ +.o_dashboard { + background-image: url("/awesome_dashboard/static/img/dashboard_bg.jpg"); + background-repeat: no-repeat; + background-position: center; + background-size: cover; + + .o_dashboard_row { + display: flex; + flex-wrap: wrap; + justify-content: center; + } + + .o_header_dashboard_item { + font-size: 1.5em; + } + + .o_average_quantity { + font-size: 2em; + color: #008528; + font-weight: bold; + } +} diff --git a/awesome_dashboard/static/src/dashboard/Dashboard/dashboard.xml b/awesome_dashboard/static/src/dashboard/Dashboard/dashboard.xml new file mode 100644 index 00000000000..595de5f1b89 --- /dev/null +++ b/awesome_dashboard/static/src/dashboard/Dashboard/dashboard.xml @@ -0,0 +1,23 @@ + + + + + + + +