feat(stats): график из статистики открывается той же полноэкранной страницей, что и иконка 📈 в тренировке (вместо inline-canvas с мелкими осями)
This commit is contained in:
@@ -2,8 +2,9 @@
|
||||
|
||||
import { state } from '../state.js';
|
||||
import { escapeHtml } from '../utils.js';
|
||||
import { drawExerciseProgress, drawBodyMetricsGraph } from './dashboard.js';
|
||||
import { drawBodyMetricsGraph } from './dashboard.js';
|
||||
import { showExerciseSummary } from '../modals/exercise-summary.js';
|
||||
import { showChartDialog } from '../modals/chart-modal.js';
|
||||
|
||||
const CHART_EX_KEY = 'gym_dash_char…ise';
|
||||
|
||||
@@ -22,16 +23,16 @@ export function renderDashboard() {
|
||||
<h3>💪 Прогресс упражнения</h3>
|
||||
<div class="field-group">
|
||||
<label>Выберите упражнение</label>
|
||||
<select id="dash-ex-select" onchange="DashboardLogic.updateExerciseChart()">
|
||||
<select id="dash-ex-select" onchange="DashboardLogic.rememberExercise()">
|
||||
<option value="">— Выберите —</option>
|
||||
${getUniqueExercises().map(ex => `<option value="${escapeHtml(ex)}">${escapeHtml(ex)}</option>`).join('')}
|
||||
</select>
|
||||
</div>
|
||||
<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 style="display:flex; gap:8px; flex-wrap:wrap">
|
||||
<button class="btn btn-primary" style="flex:1" onclick="DashboardLogic.openChart()">📈 Открыть график</button>
|
||||
<button class="btn btn-secondary" onclick="DashboardLogic.showExSummary()">📋 Сводка</button>
|
||||
</div>
|
||||
<p class="text-muted text-small mt-10">Главное — рабочий максимум «вес × повторы»: зелёный — прогресс (вес выше или тот же вес и больше повторов), красный — откат. Тусклые точки — остальные подходы, «×N» — их число. Последние 10 тренировок.</p>
|
||||
<p class="text-muted text-small mt-10">Главное — рабочий максимум «вес × повторы»: зелёный — прогресс (вес выше или тот же вес и больше повторов), красный — откат. Тусклые точки — остальные подходы, «×N» — их число.</p>
|
||||
</div>
|
||||
|
||||
<!-- Секция 2: Динамика тела -->
|
||||
@@ -57,20 +58,15 @@ export function renderDashboard() {
|
||||
`;
|
||||
|
||||
window.DashboardLogic = {
|
||||
updateExerciseChart: () => {
|
||||
// Выбор упражнения запоминается и восстанавливается при следующем открытии
|
||||
rememberExercise: () => {
|
||||
localStorage.setItem(CHART_EX_KEY, document.getElementById('dash-ex-select').value);
|
||||
},
|
||||
openChart: () => {
|
||||
const select = document.getElementById('dash-ex-select');
|
||||
const canvas = document.getElementById('chart-exercise');
|
||||
// Выбор упражнения запоминается и восстанавливается при следующем открытии
|
||||
if (!select.value) { alert('Сначала выберите упражнение'); return; }
|
||||
localStorage.setItem(CHART_EX_KEY, select.value);
|
||||
if (select.value) {
|
||||
drawExerciseProgress(canvas, select.value);
|
||||
} else {
|
||||
const ctx = canvas.getContext('2d');
|
||||
ctx.clearRect(0,0,canvas.width,canvas.height);
|
||||
ctx.fillStyle='#666';
|
||||
ctx.textAlign='center';
|
||||
ctx.fillText('Выберите упражнение выше', canvas.width/2, canvas.height/2);
|
||||
}
|
||||
showChartDialog(select.value);
|
||||
},
|
||||
showExSummary: () => {
|
||||
const select = document.getElementById('dash-ex-select');
|
||||
|
||||
Reference in New Issue
Block a user