diff --git a/dashboard/fixtures/dashboard_icon.json b/dashboard/fixtures/dashboard_icon.json new file mode 100644 index 0000000..5cb31a2 --- /dev/null +++ b/dashboard/fixtures/dashboard_icon.json @@ -0,0 +1,13 @@ +[ + { + "color": "#449CF0", + "docstatus": 0, + "doctype": "Dashboard Icon", + "icon": "fas fa-th", + "label": "OfficeTrax", + "modified": "2025-07-18 17:13:30.629925", + "name": "eea9orlie0", + "roles": "OfficeTrax", + "url": "seahaven.core7.net" + } +] \ No newline at end of file diff --git a/dashboard/hooks.py b/dashboard/hooks.py index 6904247..589fbd9 100644 --- a/dashboard/hooks.py +++ b/dashboard/hooks.py @@ -242,3 +242,4 @@ app_license = "mit" # "Logging DocType Name": 30 # days to retain logs # } +fixtures = ["Dashboard Icon"] diff --git a/dashboard/www/dashboard/index.html b/dashboard/www/dashboard/index.html index ac3f0fc..094112e 100644 --- a/dashboard/www/dashboard/index.html +++ b/dashboard/www/dashboard/index.html @@ -1,26 +1,12 @@

Sea Haven Portal

- {% if "Accounts User" in roles %} - - -
Accounting
-
- {% endif %} - - {% if "Wiki Editor" in roles %} - - -
Wiki
-
- {% endif %} - - {% if "OfficeTrax" in roles %} - - -
OfficeTrax
-
- {% endif %} + {% for icon in icons %} + + +
{{ icon.label }}
+
+ {% endfor %}
@@ -68,4 +54,4 @@ } - + diff --git a/dashboard/www/dashboard/index.py b/dashboard/www/dashboard/index.py index a8c36bb..439f2a1 100644 --- a/dashboard/www/dashboard/index.py +++ b/dashboard/www/dashboard/index.py @@ -2,5 +2,14 @@ import frappe def get_context(context): user = frappe.session.user - context.roles = frappe.get_roles(user) + user_roles = frappe.get_roles(user) + + icons = frappe.get_all("Dashboard Icon", fields=["label", "icon", "url", "role"]) + visible_icons = [] + + for icon in icons: + if not icon.role or icon.role in user_roles: + visible_icons.append(icon) + + context.icons = visible_icons return context