Gui editable #2

Merged
amoussa1229 merged 4 commits from gui-editable into main 2025-07-20 20:16:30 +00:00
8 changed files with 1701 additions and 23 deletions

4
.gitignore vendored
View file

@ -4,4 +4,6 @@
*.swp
tags
node_modules
__pycache__
__pycache__
dashboard_structure.txt
structure.txt

View file

@ -0,0 +1 @@
[]

View file

@ -0,0 +1,46 @@
[
{
"color": "#29CD42",
"docstatus": 0,
"doctype": "Dashboard Icon",
"icon": "fa-book",
"label": "Google",
"modified": "2025-07-20 15:50:15.581796",
"name": "l5bud58lt3",
"role": "Google",
"url": "https://google.com"
},
{
"color": "#ED6396",
"docstatus": 0,
"doctype": "Dashboard Icon",
"icon": "fa-book",
"label": "Facebook",
"modified": "2025-07-20 15:52:29.237652",
"name": "mf42urcnh1",
"role": "Facebook",
"url": "https://facebook.com"
},
{
"color": "#449CF0",
"docstatus": 0,
"doctype": "Dashboard Icon",
"icon": "fas fa-th",
"label": "OfficeTrax",
"modified": "2025-07-18 17:13:30.629925",
"name": "eea9orlie0",
"role": "OfficeTrax",
"url": "seahaven.core7.net"
},
{
"color": "#39E4A5",
"docstatus": 0,
"doctype": "Dashboard Icon",
"icon": "fa-book",
"label": "test",
"modified": "2025-07-20 16:03:47.685306",
"name": "t34ajbku7b",
"role": "Google",
"url": "https://google.com"
}
]

File diff suppressed because it is too large Load diff

View file

@ -242,3 +242,24 @@ app_license = "mit"
# "Logging DocType Name": 30 # days to retain logs
# }
fixtures = [
{
"dt": "Custom Field",
"filters": [
["dt", "in", ["Dashboard Icon"]]
]
},
{
"dt": "Property Setter"
},
"Dashboard Icon" # export the entire custom DocType
]
doc_events = {
"Dashboard Icon": {
"after_insert": "dashboard.utils.cache.clear_dashboard_cache",
"on_update": "dashboard.utils.cache.clear_dashboard_cache",
"on_trash": "dashboard.utils.cache.clear_dashboard_cache",
}
}

9
dashboard/utils/cache.py Normal file
View file

@ -0,0 +1,9 @@
import frappe
from frappe.website.utils import clear_cache
def clear_dashboard_cache(doc=None, method=None):
# Clear the cache for the specific "/dashboard" route
clear_cache("/dashboard")
# Optionally clear general site cache as well
frappe.clear_cache()

View file

@ -1,26 +1,12 @@
<div class="portal-wrapper">
<h1>Sea Haven Portal</h1>
<div class="grid">
{% if "Accounts User" in roles %}
<a href="https://accounting.getmynewsite.com" class="app-link">
<i class="fas fa-file-invoice-dollar"></i>
<div class="app-label">Accounting</div>
</a>
{% endif %}
{% if "Wiki Editor" in roles %}
<a href="https://wiki.getmynewsite.com" class="app-link">
<i class="fas fa-book"></i>
<div class="app-label">Wiki</div>
</a>
{% endif %}
{% if "OfficeTrax" in roles %}
<a href="https://seahaven.core7.net" class="app-link">
<i class="fas fa-th"></i>
<div class="app-label">OfficeTrax</div>
</a>
{% endif %}
{% for icon in icons %}
<a href="{{ icon.url }}" class="app-link">
<i class="fas {{ icon.icon }}"></i>
<div class="app-label">{{ icon.label }}</div>
</a>
{% endfor %}
</div>
</div>
@ -68,4 +54,4 @@
}
</style>
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.5.0/css/all.min.css" />
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.5.0/css/all.min.css">

View file

@ -1,6 +1,17 @@
import frappe
no_cache = 1
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