diff --git a/crm/api/dashboard.py b/crm/api/dashboard.py
index a9910a70..b6ca7aff 100644
--- a/crm/api/dashboard.py
+++ b/crm/api/dashboard.py
@@ -27,7 +27,7 @@ def get_dashboard(from_date="", to_date="", user=""):
layout = json.loads(dashboard.layout) if dashboard and dashboard.layout else []
for l in layout:
- method_name = f"get_{l['id']}"
+ method_name = f"get_{l['name']}"
if hasattr(frappe.get_attr("crm.api.dashboard"), method_name):
method = getattr(frappe.get_attr("crm.api.dashboard"), method_name)
l["data"] = method(from_date, to_date, user)
@@ -37,6 +37,29 @@ def get_dashboard(from_date="", to_date="", user=""):
return layout
+@frappe.whitelist()
+@sales_user_only
+def get_chart(name, type, from_date="", to_date="", user=""):
+ """
+ Get number chart data for the dashboard.
+ """
+ if not from_date or not to_date:
+ from_date = frappe.utils.get_first_day(from_date or frappe.utils.nowdate())
+ to_date = frappe.utils.get_last_day(to_date or frappe.utils.nowdate())
+
+ roles = frappe.get_roles(frappe.session.user)
+ is_sales_user = "Sales User" in roles and "Sales Manager" not in roles and "System Manager" not in roles
+ if is_sales_user and not user:
+ user = frappe.session.user
+
+ method_name = f"get_{name}"
+ if hasattr(frappe.get_attr("crm.api.dashboard"), method_name):
+ method = getattr(frappe.get_attr("crm.api.dashboard"), method_name)
+ return method(from_date, to_date, user)
+ else:
+ return {"error": _("Invalid chart name")}
+
+
def get_total_leads(from_date, to_date, user=""):
"""
Get lead count for the dashboard.
diff --git a/frontend/components.d.ts b/frontend/components.d.ts
index 1f614b2e..c1dd22b6 100644
--- a/frontend/components.d.ts
+++ b/frontend/components.d.ts
@@ -12,6 +12,7 @@ declare module 'vue' {
Activities: typeof import('./src/components/Activities/Activities.vue')['default']
ActivityHeader: typeof import('./src/components/Activities/ActivityHeader.vue')['default']
ActivityIcon: typeof import('./src/components/Icons/ActivityIcon.vue')['default']
+ AddChartModal: typeof import('./src/components/Dashboard/AddChartModal.vue')['default']
AddExistingUserModal: typeof import('./src/components/Modals/AddExistingUserModal.vue')['default']
AddressIcon: typeof import('./src/components/Icons/AddressIcon.vue')['default']
AddressModal: typeof import('./src/components/Modals/AddressModal.vue')['default']
diff --git a/frontend/src/components/Dashboard/AddChartModal.vue b/frontend/src/components/Dashboard/AddChartModal.vue
new file mode 100644
index 00000000..72fe60dd
--- /dev/null
+++ b/frontend/src/components/Dashboard/AddChartModal.vue
@@ -0,0 +1,165 @@
+
+
+
+
+
diff --git a/frontend/src/pages/Dashboard.vue b/frontend/src/pages/Dashboard.vue
index 3cbc1e25..b3c1df8b 100644
--- a/frontend/src/pages/Dashboard.vue
+++ b/frontend/src/pages/Dashboard.vue
@@ -23,6 +23,13 @@
+
+
+