fix: light refactor, add code quality tooling
This commit is contained in:
parent
4e60535f86
commit
0e9fdcb0a3
10 changed files with 127 additions and 1689 deletions
|
|
@ -63,6 +63,26 @@ repos:
|
||||||
dashboard/public/js/lib/.*
|
dashboard/public/js/lib/.*
|
||||||
)$
|
)$
|
||||||
|
|
||||||
|
- repo: https://github.com/codespell-project/codespell
|
||||||
|
rev: v2.3.0
|
||||||
|
hooks:
|
||||||
|
- id: codespell
|
||||||
|
additional_dependencies:
|
||||||
|
- tomli
|
||||||
|
args: ['-L', '']
|
||||||
|
|
||||||
|
- repo: https://github.com/agritheory/test_utils/
|
||||||
|
rev: v0.17.0
|
||||||
|
hooks:
|
||||||
|
- id: update_pre_commit_config
|
||||||
|
- id: validate_customizations
|
||||||
|
always_run: true
|
||||||
|
- id: validate_copyright
|
||||||
|
files: '\.(js|ts|py|md)$'
|
||||||
|
args: ['--app', 'dashboard']
|
||||||
|
- id: clean_customized_doctypes
|
||||||
|
args: ['--app', 'dashboard']
|
||||||
|
|
||||||
ci:
|
ci:
|
||||||
autoupdate_schedule: weekly
|
autoupdate_schedule: weekly
|
||||||
skip: []
|
skip: []
|
||||||
|
|
|
||||||
|
|
@ -46,7 +46,7 @@
|
||||||
"modified_by": "Administrator",
|
"modified_by": "Administrator",
|
||||||
"module": "Dashboard",
|
"module": "Dashboard",
|
||||||
"name": "Dashboard Icon",
|
"name": "Dashboard Icon",
|
||||||
"owner": "adam@seahavenind.com",
|
"owner": "Administrator",
|
||||||
"permissions": [
|
"permissions": [
|
||||||
{
|
{
|
||||||
"create": 1,
|
"create": 1,
|
||||||
|
|
|
||||||
11
dashboard/dashboard/doctype/dashboard_icon/dashboard_icon.py
Normal file
11
dashboard/dashboard/doctype/dashboard_icon/dashboard_icon.py
Normal file
|
|
@ -0,0 +1,11 @@
|
||||||
|
# Copyright (c) 2025, Adam Moussa and contributors
|
||||||
|
# For license information, please see license.txt
|
||||||
|
|
||||||
|
import frappe
|
||||||
|
from frappe.model.document import Document
|
||||||
|
from frappe.website.utils import clear_cache
|
||||||
|
|
||||||
|
|
||||||
|
class DashboardIcon(Document):
|
||||||
|
def validate(self):
|
||||||
|
clear_cache("/dashboard")
|
||||||
|
|
@ -1 +0,0 @@
|
||||||
[]
|
|
||||||
File diff suppressed because it is too large
Load diff
|
|
@ -1,3 +1,6 @@
|
||||||
|
# Copyright (c) 2025, Adam Moussa and contributors
|
||||||
|
# For license information, please see license.txt
|
||||||
|
|
||||||
app_name = "dashboard"
|
app_name = "dashboard"
|
||||||
app_title = "Dashboard"
|
app_title = "Dashboard"
|
||||||
app_publisher = "Adam Moussa"
|
app_publisher = "Adam Moussa"
|
||||||
|
|
@ -243,23 +246,5 @@ app_license = "mit"
|
||||||
# }
|
# }
|
||||||
|
|
||||||
fixtures = [
|
fixtures = [
|
||||||
{
|
"Dashboard Icon",
|
||||||
"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",
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
|
||||||
3
dashboard/www/__init__.py
Normal file
3
dashboard/www/__init__.py
Normal file
|
|
@ -0,0 +1,3 @@
|
||||||
|
# Copyright (c) 2025, Adam Moussa and contributors
|
||||||
|
# For license information, please see license.txt
|
||||||
|
|
||||||
|
|
@ -1,57 +1,74 @@
|
||||||
<div class="portal-wrapper">
|
{% extends "templates/web.html" %}
|
||||||
<h1>Sea Haven Portal</h1>
|
{% block content %}
|
||||||
<div class="grid">
|
<div class="portal-wrapper">
|
||||||
{% for icon in icons %}
|
<h1>Sea Haven Portal</h1>
|
||||||
<a href="{{ icon.url }}" class="app-link">
|
<div class="grid">
|
||||||
<i class="fas {{ icon.icon }}"></i>
|
{% for icon in icons %}
|
||||||
<div class="app-label">{{ icon.label }}</div>
|
<a href="{{ icon.url }}" class="app-link">
|
||||||
</a>
|
<i class="fas {{ icon.icon }}"></i>
|
||||||
{% endfor %}
|
<div class="app-label">{{ icon.label }}</div>
|
||||||
</div>
|
</a>
|
||||||
</div>
|
{% endfor %}
|
||||||
|
</div>
|
||||||
<style>
|
</div>
|
||||||
.portal-wrapper {
|
<script>
|
||||||
text-align: center;
|
window.csrf_token = '{{ csrf_token }}'
|
||||||
padding: 40px;
|
frappe.user = '{{ user }}'
|
||||||
font-family: "Segoe UI", sans-serif;
|
</script>
|
||||||
background-color: #f9f9f9;
|
{% endblock %}
|
||||||
}
|
{%- block style -%}
|
||||||
h1 {
|
<style>
|
||||||
margin-bottom: 40px;
|
.portal-wrapper {
|
||||||
font-size: 2.5rem;
|
text-align: center;
|
||||||
color: #333;
|
padding: 40px;
|
||||||
}
|
font-family: "Segoe UI", sans-serif;
|
||||||
.grid {
|
background-color: #f9f9f9;
|
||||||
display: grid;
|
}
|
||||||
grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
|
|
||||||
gap: 30px;
|
h1 {
|
||||||
max-width: 800px;
|
margin-bottom: 40px;
|
||||||
margin: 0 auto;
|
font-size: 2.5rem;
|
||||||
}
|
color: #333;
|
||||||
.app-link {
|
}
|
||||||
background: #fff;
|
|
||||||
padding: 30px 20px;
|
.grid {
|
||||||
border-radius: 10px;
|
display: grid;
|
||||||
text-decoration: none;
|
grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
|
||||||
color: #333;
|
gap: 30px;
|
||||||
box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
|
max-width: 800px;
|
||||||
transition: transform 0.2s, box-shadow 0.2s;
|
margin: 0 auto;
|
||||||
}
|
}
|
||||||
.app-link:hover {
|
|
||||||
transform: translateY(-4px);
|
.app-link {
|
||||||
box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
|
background: #fff;
|
||||||
}
|
padding: 30px 20px;
|
||||||
.app-link i {
|
border-radius: 10px;
|
||||||
font-size: 2.5rem;
|
text-decoration: none;
|
||||||
margin-bottom: 10px;
|
color: #333;
|
||||||
color: #007bff;
|
box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
|
||||||
}
|
transition: transform 0.2s, box-shadow 0.2s;
|
||||||
.app-label {
|
}
|
||||||
font-size: 1rem;
|
|
||||||
font-weight: 600;
|
.app-link:hover {
|
||||||
margin-top: 10px;
|
transform: translateY(-4px);
|
||||||
}
|
box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
|
||||||
</style>
|
}
|
||||||
|
|
||||||
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.5.0/css/all.min.css">
|
.app-link i {
|
||||||
|
font-size: 2.5rem;
|
||||||
|
margin-bottom: 10px;
|
||||||
|
color: #007bff;
|
||||||
|
}
|
||||||
|
|
||||||
|
.app-label {
|
||||||
|
font-size: 1rem;
|
||||||
|
font-weight: 600;
|
||||||
|
margin-top: 10px;
|
||||||
|
}
|
||||||
|
.web-footer {
|
||||||
|
display: none;
|
||||||
|
}
|
||||||
|
</style>
|
||||||
|
|
||||||
|
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.5.0/css/all.min.css">
|
||||||
|
{% endblock %}
|
||||||
|
|
@ -1,17 +1,22 @@
|
||||||
|
# Copyright (c) 2025, Adam Moussa and contributors
|
||||||
|
# For license information, please see license.txt
|
||||||
|
|
||||||
import frappe
|
import frappe
|
||||||
|
|
||||||
no_cache = 1
|
no_cache = 1
|
||||||
|
|
||||||
|
|
||||||
def get_context(context):
|
def get_context(context):
|
||||||
user = frappe.session.user
|
user = frappe.session.user
|
||||||
user_roles = frappe.get_roles(user)
|
user_roles = frappe.get_roles(user)
|
||||||
|
|
||||||
icons = frappe.get_all("Dashboard Icon", fields=["label", "icon", "url", "role"])
|
icons = frappe.get_all("Dashboard Icon", fields=["label", "icon", "url", "role"])
|
||||||
visible_icons = []
|
print(icons)
|
||||||
|
visible_icons = []
|
||||||
|
|
||||||
for icon in icons:
|
for icon in icons:
|
||||||
if not icon.role or icon.role in user_roles:
|
if not icon.role or icon.role in user_roles:
|
||||||
visible_icons.append(icon)
|
visible_icons.append(icon)
|
||||||
|
|
||||||
context.icons = visible_icons
|
context.icons = visible_icons
|
||||||
return context
|
return context
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue