commit bc0f4f83bc34e98731f545e1bcc0b0cb036014b0 Author: Adam Moussa Date: Fri May 2 23:05:24 2025 +0000 Make URLs dynamic, add after_install hook, add README diff --git a/README.md b/README.md new file mode 100644 index 0000000..1e53238 --- /dev/null +++ b/README.md @@ -0,0 +1,22 @@ +# Sea Haven Portal Dashboard (`portal_dashboard`) + +A lightweight, role-based landing page app for Frappe/ERPNext. Shows a clean tile-style interface for navigating to apps like ERP, Wiki, CRM — all based on user roles. + +--- + +## 🚀 Features + +- Clean, responsive tile dashboard +- Icons + labels based on Frappe user roles +- Dynamic subdomain routing (e.g., `accounting.yourdomain.com`) +- Auto-redirect for non-portal subdomains +- Auto-sets homepage on install + +--- + +## 🛠 Installation + +### 1. Get the app + +```bash +bench get-app portal_dashboard https://github.com/yourusername/portal_dashboard.git diff --git a/portal_dashboard/__init__.py b/portal_dashboard/__init__.py new file mode 100644 index 0000000..f102a9c --- /dev/null +++ b/portal_dashboard/__init__.py @@ -0,0 +1 @@ +__version__ = "0.0.1" diff --git a/portal_dashboard/__pycache__/__init__.cpython-310.pyc b/portal_dashboard/__pycache__/__init__.cpython-310.pyc new file mode 100644 index 0000000..91c43e0 Binary files /dev/null and b/portal_dashboard/__pycache__/__init__.cpython-310.pyc differ diff --git a/portal_dashboard/__pycache__/hooks.cpython-310.pyc b/portal_dashboard/__pycache__/hooks.cpython-310.pyc new file mode 100644 index 0000000..0a352b7 Binary files /dev/null and b/portal_dashboard/__pycache__/hooks.cpython-310.pyc differ diff --git a/portal_dashboard/config/__init__.py b/portal_dashboard/config/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/portal_dashboard/config/desktop.py b/portal_dashboard/config/desktop.py new file mode 100644 index 0000000..0054982 --- /dev/null +++ b/portal_dashboard/config/desktop.py @@ -0,0 +1,10 @@ +from frappe import _ + +def get_data(): + return [ + { + "module_name": "Portal Dashboard", + "type": "module", + "label": _("Portal Dashboard") + } + ] diff --git a/portal_dashboard/config/docs.py b/portal_dashboard/config/docs.py new file mode 100644 index 0000000..29b9d2e --- /dev/null +++ b/portal_dashboard/config/docs.py @@ -0,0 +1,10 @@ +""" +Configuration for docs +""" + +# source_link = "https://github.com/[org_name]/portal_dashboard" +# headline = "App that does everything" +# sub_heading = "Yes, you got that right the first time, everything" + +def get_context(context): + context.brand_html = "Portal Dashboard" diff --git a/portal_dashboard/hooks.py b/portal_dashboard/hooks.py new file mode 100644 index 0000000..673a750 --- /dev/null +++ b/portal_dashboard/hooks.py @@ -0,0 +1,219 @@ +app_name = "portal_dashboard" +app_title = "Portal Dashboard" +app_publisher = "Adam Moussa" +app_description = "A role based tile dashboard for navigation to internal resources" +app_email = "adam@seahaven.com" +app_license = "MIT" +after_install = "portal_dashboard.setup.install.run" +web_routes = [ + {"path": "/", "controller": "portal_dashboard.www.index", "login_required": 1} +] + +# Includes in +# ------------------ + +# include js, css files in header of desk.html +# app_include_css = "/assets/portal_dashboard/css/portal_dashboard.css" +# app_include_js = "/assets/portal_dashboard/js/portal_dashboard.js" + +# include js, css files in header of web template +# web_include_css = "/assets/portal_dashboard/css/portal_dashboard.css" +# web_include_js = "/assets/portal_dashboard/js/portal_dashboard.js" + +# include custom scss in every website theme (without file extension ".scss") +# website_theme_scss = "portal_dashboard/public/scss/website" + +# include js, css files in header of web form +# webform_include_js = {"doctype": "public/js/doctype.js"} +# webform_include_css = {"doctype": "public/css/doctype.css"} + +# include js in page +# page_js = {"page" : "public/js/file.js"} + +# include js in doctype views +# doctype_js = {"doctype" : "public/js/doctype.js"} +# doctype_list_js = {"doctype" : "public/js/doctype_list.js"} +# doctype_tree_js = {"doctype" : "public/js/doctype_tree.js"} +# doctype_calendar_js = {"doctype" : "public/js/doctype_calendar.js"} + +# Home Pages +# ---------- + +# application home page (will override Website Settings) +# home_page = "login" + +# website user home page (by Role) +# role_home_page = { +# "Role": "home_page" +# } + +# Generators +# ---------- + +# automatically create page for each record of this doctype +# website_generators = ["Web Page"] + +# Jinja +# ---------- + +# add methods and filters to jinja environment +# jinja = { +# "methods": "portal_dashboard.utils.jinja_methods", +# "filters": "portal_dashboard.utils.jinja_filters" +# } + +# Installation +# ------------ + +# before_install = "portal_dashboard.install.before_install" +# after_install = "portal_dashboard.install.after_install" + +# Uninstallation +# ------------ + +# before_uninstall = "portal_dashboard.uninstall.before_uninstall" +# after_uninstall = "portal_dashboard.uninstall.after_uninstall" + +# Integration Setup +# ------------------ +# To set up dependencies/integrations with other apps +# Name of the app being installed is passed as an argument + +# before_app_install = "portal_dashboard.utils.before_app_install" +# after_app_install = "portal_dashboard.utils.after_app_install" + +# Integration Cleanup +# ------------------- +# To clean up dependencies/integrations with other apps +# Name of the app being uninstalled is passed as an argument + +# before_app_uninstall = "portal_dashboard.utils.before_app_uninstall" +# after_app_uninstall = "portal_dashboard.utils.after_app_uninstall" + +# Desk Notifications +# ------------------ +# See frappe.core.notifications.get_notification_config + +# notification_config = "portal_dashboard.notifications.get_notification_config" + +# Permissions +# ----------- +# Permissions evaluated in scripted ways + +# permission_query_conditions = { +# "Event": "frappe.desk.doctype.event.event.get_permission_query_conditions", +# } +# +# has_permission = { +# "Event": "frappe.desk.doctype.event.event.has_permission", +# } + +# DocType Class +# --------------- +# Override standard doctype classes + +# override_doctype_class = { +# "ToDo": "custom_app.overrides.CustomToDo" +# } + +# Document Events +# --------------- +# Hook on document methods and events + +# doc_events = { +# "*": { +# "on_update": "method", +# "on_cancel": "method", +# "on_trash": "method" +# } +# } + +# Scheduled Tasks +# --------------- + +# scheduler_events = { +# "all": [ +# "portal_dashboard.tasks.all" +# ], +# "daily": [ +# "portal_dashboard.tasks.daily" +# ], +# "hourly": [ +# "portal_dashboard.tasks.hourly" +# ], +# "weekly": [ +# "portal_dashboard.tasks.weekly" +# ], +# "monthly": [ +# "portal_dashboard.tasks.monthly" +# ], +# } + +# Testing +# ------- + +# before_tests = "portal_dashboard.install.before_tests" + +# Overriding Methods +# ------------------------------ +# +# override_whitelisted_methods = { +# "frappe.desk.doctype.event.event.get_events": "portal_dashboard.event.get_events" +# } +# +# each overriding function accepts a `data` argument; +# generated from the base implementation of the doctype dashboard, +# along with any modifications made in other Frappe apps +# override_doctype_dashboards = { +# "Task": "portal_dashboard.task.get_dashboard_data" +# } + +# exempt linked doctypes from being automatically cancelled +# +# auto_cancel_exempted_doctypes = ["Auto Repeat"] + +# Ignore links to specified DocTypes when deleting documents +# ----------------------------------------------------------- + +# ignore_links_on_delete = ["Communication", "ToDo"] + +# Request Events +# ---------------- +# before_request = ["portal_dashboard.utils.before_request"] +# after_request = ["portal_dashboard.utils.after_request"] + +# Job Events +# ---------- +# before_job = ["portal_dashboard.utils.before_job"] +# after_job = ["portal_dashboard.utils.after_job"] + +# User Data Protection +# -------------------- + +# user_data_fields = [ +# { +# "doctype": "{doctype_1}", +# "filter_by": "{filter_by}", +# "redact_fields": ["{field_1}", "{field_2}"], +# "partial": 1, +# }, +# { +# "doctype": "{doctype_2}", +# "filter_by": "{filter_by}", +# "partial": 1, +# }, +# { +# "doctype": "{doctype_3}", +# "strict": False, +# }, +# { +# "doctype": "{doctype_4}" +# } +# ] + +# Authentication and authorization +# -------------------------------- + +# auth_hooks = [ +# "portal_dashboard.auth.validate" +# ] diff --git a/portal_dashboard/install.py b/portal_dashboard/install.py new file mode 100644 index 0000000..35eb886 --- /dev/null +++ b/portal_dashboard/install.py @@ -0,0 +1,8 @@ +import frappe + +def run(): + # Force home page to our portal dashboard + frappe.db.set_single_value("Website Settings", "home_page", "index") + + # Optional: log it + frappe.logger().info("Set home_page to 'index' for portal_dashboard.") diff --git a/portal_dashboard/modules.txt b/portal_dashboard/modules.txt new file mode 100644 index 0000000..e85aa60 --- /dev/null +++ b/portal_dashboard/modules.txt @@ -0,0 +1 @@ +Portal Dashboard \ No newline at end of file diff --git a/portal_dashboard/patches.txt b/portal_dashboard/patches.txt new file mode 100644 index 0000000..e69de29 diff --git a/portal_dashboard/portal_dashboard/__init__.py b/portal_dashboard/portal_dashboard/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/portal_dashboard/public/.gitkeep b/portal_dashboard/public/.gitkeep new file mode 100644 index 0000000..e69de29 diff --git a/portal_dashboard/templates/__init__.py b/portal_dashboard/templates/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/portal_dashboard/templates/pages/__init__.py b/portal_dashboard/templates/pages/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/portal_dashboard/www/__pycache__/index.cpython-310.pyc b/portal_dashboard/www/__pycache__/index.cpython-310.pyc new file mode 100644 index 0000000..ecb5e9f Binary files /dev/null and b/portal_dashboard/www/__pycache__/index.cpython-310.pyc differ diff --git a/portal_dashboard/www/index.html b/portal_dashboard/www/index.html new file mode 100644 index 0000000..ebf20eb --- /dev/null +++ b/portal_dashboard/www/index.html @@ -0,0 +1,104 @@ + + + +
+
+ + +
+
+ + + + + Sea Haven Portal + + + + + + {% if frappe.session.user == "Guest" %} + + {% endif %} + +

Sea Haven Portal

+
+ {% for app in apps %} + + +
{{ app.label }}
+
+ {% endfor %} +
+ + diff --git a/portal_dashboard/www/index.py b/portal_dashboard/www/index.py new file mode 100644 index 0000000..4b5ff7c --- /dev/null +++ b/portal_dashboard/www/index.py @@ -0,0 +1,39 @@ +import frappe + +def get_context(context): + host = frappe.local.request.host + base_domain = ".".join(host.split(".")[1:]) + + if not host.startswith("portal."): + frappe.local.flags.redirect_location = "/app" + raise frappe.Redirect + + user = frappe.session.user + roles = frappe.get_roles(user) + + user = frappe.session.user + roles = frappe.get_roles(user) + + apps = [ + { + "label": "ERP", + "icon": "fa-warehouse", + "url": "https://accounting.{base_domain}", + "roles": ["Accounts User", "Accounts Manager"] + }, + { + "label": "Wiki", + "icon": "fa-book", + "url": "https://wiki.{base_domain}", + "roles": ["Employee", "System Manager"] + }, + { + "label": "CRM", + "icon": "fa-user-friends", + "url": "https://crm.{base_domain}", + "roles": ["Sales User", "Sales Manager"] + } + ] + + context.apps = [app for app in apps if any(role in roles for role in app["roles"])] + return context