diff options
| author | Adam Zapletal <adamzap@gmail.com> | 2025-09-11 13:47:21 -0500 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2025-09-11 20:47:21 +0200 |
| commit | 100d673a8ff0a9072ee0eeebcee4252f396049bf (patch) | |
| tree | c3930b6589c9e1535b573c8bd3529362b6d42b2e /dashboard | |
| parent | 7c05b00f33ab78e64d585660827d15d2fd660661 (diff) | |
Isolated `dashboard` app JavaScript (#2155)
* Isolated `dashboard` app JavaScript
This patch moves the `dashboard` app's JavaScript inclusion from the
project's `require.js` structure to the app itself.
This was achieved with a new block in the base template called
`javascript`. The rest of the site gets the default JavaScript includes,
and the `dashboard` app overrides the block to include the JavaScript
specific to it. The `dashboard` app benefits by not knowing about
JavaScript related to the rest of the site and vice versa.
None of the actual `dashboard` JavaScript code was changed. It was only
adapted to the new structure.
- Added `javascript` block to base template
- Added `dashboard_javascript` block to `dashboard` base template
- Included `dashboard` JavaScript directly in `dashboard` templates
- Removed `dashboard`-related entries in `main.js`
- Remove references to `jquery.flot.min.js` from base template
- This library is only used by the `dashboard` app
- Removed `dashboard-*` CSS classes only used by `require.js`
- Removed `require.js` structure in `dashboard` JavaScript files
- Simplified structure of `utils.js`
* Update `static` template tag loading
* Simplify JavaScript inclusion
Diffstat (limited to 'dashboard')
| -rw-r--r-- | dashboard/templates/base_dashboard.html | 7 | ||||
| -rw-r--r-- | dashboard/templates/dashboard/detail.html | 10 | ||||
| -rw-r--r-- | dashboard/templates/dashboard/index.html | 9 |
3 files changed, 23 insertions, 3 deletions
diff --git a/dashboard/templates/base_dashboard.html b/dashboard/templates/base_dashboard.html index f7c9a5f2..19773bd2 100644 --- a/dashboard/templates/base_dashboard.html +++ b/dashboard/templates/base_dashboard.html @@ -1,5 +1,6 @@ {% extends "base.html" %} {% load i18n %} +{% load static %} {% block sectionid %}dashboard{% endblock %} @@ -8,3 +9,9 @@ {% block header %} <h1>Development <em>dashboard</em></h1> {% endblock %} + +{% block javascript %} + <script src="{% static "js/lib/jquery.min.js" %}"></script> + <script src="{% static "js/lib/jquery.flot.min.js" %}"></script> + <script src="{% static "js/dashboard/utils.js" %}"></script> +{% endblock %} diff --git a/dashboard/templates/dashboard/detail.html b/dashboard/templates/dashboard/detail.html index 858c94f9..7484d964 100644 --- a/dashboard/templates/dashboard/detail.html +++ b/dashboard/templates/dashboard/detail.html @@ -1,10 +1,10 @@ {% extends "base_dashboard.html" %} -{% load i18n %} +{% load i18n static %} {% block title %}{{ metric }} | {{ block.super }}{% endblock %} {% block content %} - <div class="dashboard-detail"> + <div> <h2><a href="{{ metric.link }}">{{ metric }}</a></h2> <div class="graph-wrapper"> <div id="graph" class="graph" data-path="{% url "metric-list" host "dashboard" %}" data-metric="{{ metric.slug }}"></div> @@ -12,3 +12,9 @@ <a class="link-readmore back-link" href="{% url "dashboard-index" host "dashboard" %}">{% translate "All metrics" %}</a> </div> {% endblock %} + +{% block javascript %} + {{ block.super }} + + <script src="{% static "js/dashboard/detail.js" %}"></script> +{% endblock %} diff --git a/dashboard/templates/dashboard/index.html b/dashboard/templates/dashboard/index.html index e20ccb1d..276a1b01 100644 --- a/dashboard/templates/dashboard/index.html +++ b/dashboard/templates/dashboard/index.html @@ -1,8 +1,9 @@ {% extends "base_dashboard.html" %} {% load i18n %} +{% load static %} {% block content %} - <div class="dashboard-index"> + <div> {% for report in data %} {% ifchanged report.metric.category %} {% if report.metric.category %}<h2>{{ report.metric.category }}</h2>{% endif %} @@ -23,3 +24,9 @@ </p> </div> {% endblock %} + +{% block javascript %} + {{ block.super }} + + <script src="{% static "js/dashboard/index.js" %}"></script> +{% endblock %} |
