feat(profile): personal account page with own-profile editing

Add public/profile.html + public/js/profile.js: hash-routed page with
tabs for personal data, password, AI models, prompts and branches
(admin-only), plus clickable counters for the user's own work.

Server:
- users gains email/phone/avatar (init.sql, migration.sql, ensureUserTables)
- GET /api/users/:id — self or admin, returns created_at and branch_ids
- GET /api/users/:id/stats — entries/shorts/feedbacks/lessons/groups counts
- PUT /api/users/:id/profile — name/email/phone/password, audit user.profile.update
- POST /api/users/:id/avatar — upload.single('photo'), audit user.avatar.update
- safeUser() now exposes email/phone/avatar/created_at
- users.avatar added to sweepOrphanedUploads and BROKEN_IMAGE_SOURCES
- getPersonalAiModels()/resolveUserAiProfile() for personal AI profiles;
  POST /api/shorts/ai-correct resolves them and 400s on unknown profile

Frontend:
- sidebar entry "Профиль"; .btn-secondary/.btn-xs/.muted in admin.css
- profile.js saves AI and prompt tabs as two independent PUTs
- feedback.js and shorts.js now fill model selects from
  GET /api/ai/profiles/options by role (admin sees system profiles,
  tutor sees native + own models) so the choice is actually persisted

Docs: AGENTS.md 3h updated, new section 3p.
This commit is contained in:
dev
2026-10-16 23:49:29 +03:00
parent 76cab1b97a
commit 9ae54da2e4
10 changed files with 1634 additions and 32 deletions
+1
View File
@@ -50,6 +50,7 @@ function buildSidebar(active) {
if (!el) return;
const base = [
{ page: 'dashboard', label: 'Дашборд', icon: 'layout-dashboard' },
{ page: 'profile', label: 'Профиль', icon: 'user' },
{ page: 'journal', label: 'Журнал', icon: 'book-open' },
{ page: 'lessons', label: 'Отчёты о занятиях', icon: 'notebook-pen' },
{ page: 'students', label: 'Ученики', icon: 'graduation-cap' },