feat(dashboard): даты по всей оси X, легенда вниз, крупнее шрифты, запоминаемый выбор упражнения, сводка по упражнению с синергичными
This commit is contained in:
@@ -1,7 +1,11 @@
|
||||
// frontend/js/render/dashboard-screen.js
|
||||
|
||||
import { state } from '../state.js';
|
||||
import { escapeHtml } from '../utils.js';
|
||||
import { drawExerciseProgress, drawBodyMetricsGraph } from './dashboard.js';
|
||||
import { showExerciseSummary } from '../modals/exercise-summary.js';
|
||||
|
||||
const CHART_EX_KEY = 'gym_dash_char…ise';
|
||||
|
||||
export function renderDashboard() {
|
||||
const app = document.getElementById('app');
|
||||
@@ -20,10 +24,13 @@ export function renderDashboard() {
|
||||
<label>Выберите упражнение</label>
|
||||
<select id="dash-ex-select" onchange="DashboardLogic.updateExerciseChart()">
|
||||
<option value="">— Выберите —</option>
|
||||
${getUniqueExercises().map(ex => `<option value="${ex}">${ex}</option>`).join('')}
|
||||
${getUniqueExercises().map(ex => `<option value="${escapeHtml(ex)}">${escapeHtml(ex)}</option>`).join('')}
|
||||
</select>
|
||||
</div>
|
||||
<canvas id="chart-exercise" width="400" height="200" style="width:100%; background:#1e1e1e; border-radius:8px;"></canvas>
|
||||
<canvas id="chart-exercise" width="400" height="250" style="width:100%; background:#1e1e1e; border-radius:8px;"></canvas>
|
||||
<div style="margin-top:8px">
|
||||
<button class="btn btn-small btn-secondary" onclick="DashboardLogic.showExSummary()">📋 Сводка по упражнению</button>
|
||||
</div>
|
||||
<p class="text-muted text-small mt-10">Главное — рабочий максимум «вес × повторы»: зелёный — прогресс (вес выше или тот же вес и больше повторов), красный — откат. Тусклые точки — остальные подходы, «×N» — их число. Последние 10 тренировок.</p>
|
||||
</div>
|
||||
|
||||
@@ -53,6 +60,8 @@ export function renderDashboard() {
|
||||
updateExerciseChart: () => {
|
||||
const select = document.getElementById('dash-ex-select');
|
||||
const canvas = document.getElementById('chart-exercise');
|
||||
// Выбор упражнения запоминается и восстанавливается при следующем открытии
|
||||
localStorage.setItem(CHART_EX_KEY, select.value);
|
||||
if (select.value) {
|
||||
drawExerciseProgress(canvas, select.value);
|
||||
} else {
|
||||
@@ -63,6 +72,11 @@ export function renderDashboard() {
|
||||
ctx.fillText('Выберите упражнение выше', canvas.width/2, canvas.height/2);
|
||||
}
|
||||
},
|
||||
showExSummary: () => {
|
||||
const select = document.getElementById('dash-ex-select');
|
||||
if (!select.value) { alert('Сначала выберите упражнение'); return; }
|
||||
showExerciseSummary(select.value);
|
||||
},
|
||||
updateBodyChart: () => {
|
||||
const clientSel = document.getElementById('dash-client-select');
|
||||
const metricSel = document.getElementById('dash-metric-select');
|
||||
@@ -77,7 +91,10 @@ export function renderDashboard() {
|
||||
}
|
||||
};
|
||||
|
||||
// Первичная отрисовка (пустые состояния)
|
||||
// Первичная отрисовка: восстанавливаем закреплённый выбор упражнения
|
||||
const saved = localStorage.getItem(CHART_EX_KEY);
|
||||
const exSelect = document.getElementById('dash-ex-select');
|
||||
if (saved && Array.from(exSelect.options).some(o => o.value === saved)) exSelect.value = saved;
|
||||
DashboardLogic.updateExerciseChart();
|
||||
if(state.metricTypes.length > 0) {
|
||||
document.getElementById('dash-metric-select').value = state.metricTypes[0].id;
|
||||
|
||||
Reference in New Issue
Block a user