Add DM Sans font integration and enhance dashboard context

- Added DM Sans font to the project, including multiple weights and styles for improved typography.
- Updated package.json and package-lock.json to include @fontsource/dm-sans dependency.
- Enhanced dashboard context to include current cluster CPU state, integrating new data into the context and API responses.
- Updated relevant templates and JavaScript to utilize the new current cluster data for better visualization and user experience.
This commit is contained in:
2026-02-07 16:51:24 +03:00
parent 0ecad9bd72
commit 917a7758bc
19 changed files with 181 additions and 16 deletions

View File

@@ -6,9 +6,6 @@
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>{% block title %}SWatcher{% endblock %}</title>
<link rel="icon" href="{% static 'favicon.ico' %}" type="image/x-icon">
<link rel="preconnect" href="https://fonts.googleapis.com">
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
<link href="https://fonts.googleapis.com/css2?family=DM+Sans:ital,opsz,wght@0,9..40,100..1000;1,9..40,100..1000&display=swap" rel="stylesheet">
<link rel="stylesheet" href="{% static 'css/output.css' %}">
<script src="{% static 'js/html2canvas-pro.min.js' %}"></script>
<script src="{% static 'js/jspdf.umd.min.js' %}"></script>

View File

@@ -443,6 +443,7 @@
{% block script %}
<script>
const SKELETON_MODE = {{ skeleton|yesno:"true,false" }};
const CURRENT_CLUSTER = {% if current_cluster %}{ "host_labels": {{ current_cluster.host_labels|safe }}, "cpu_current": {{ current_cluster.cpu_current|safe }} }{% else %}null{% endif %};
let auditData = {
{% if not skeleton %}
@@ -826,6 +827,19 @@
]).then(function(results) {
renderStats(results[0]);
renderAudits(results[1].audits);
if (!results[1].audits || results[1].audits.length === 0) {
var cc = results[1].current_cluster;
if (cc && cc.host_labels && cc.cpu_current && cc.host_labels.length) {
auditData["current"] = {
hostData: {
labels: cc.host_labels,
current: cc.cpu_current,
projected: cc.cpu_current
}
};
updateCPUCharts('current');
}
}
}).catch(function(err) {
var msg = err.status ? 'Failed to load data (' + err.status + ')' : 'Failed to load data';
var countEl = document.getElementById('auditsCount');
@@ -838,6 +852,15 @@
if (initialAudit && auditData[initialAudit]) {
document.getElementById('auditSelector').dispatchEvent(new Event('change'));
loadSelectedAudit();
} else if (!initialAudit && CURRENT_CLUSTER && CURRENT_CLUSTER.host_labels && CURRENT_CLUSTER.host_labels.length) {
auditData["current"] = {
hostData: {
labels: CURRENT_CLUSTER.host_labels,
current: CURRENT_CLUSTER.cpu_current,
projected: CURRENT_CLUSTER.cpu_current
}
};
updateCPUCharts('current');
}
}
});