aktivitaet: commit-messages im tagesdetail aufklappbar
Neuer schlanker Endpunkt /api/activity/day?date= liefert die Commit- Betreffzeilen eines lokalen Tages (nur Git-Projekte, lazy beim Aufklappen). Client zeigt sie je Projekt unter dem Tagesdetail, pro Tag gecacht. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
@@ -2093,12 +2093,32 @@ function actRow(p, meta) {
|
|||||||
}
|
}
|
||||||
const actMeta = (files, commits) => [files ? t(files === 1 ? 'act.file1' : 'act.filesN', { n: files }) : '', commits ? t(commits === 1 ? 'act.commit1' : 'act.commitsN', { n: commits }) : ''].filter(Boolean).join(' · ')
|
const actMeta = (files, commits) => [files ? t(files === 1 ? 'act.file1' : 'act.filesN', { n: files }) : '', commits ? t(commits === 1 ? 'act.commit1' : 'act.commitsN', { n: commits }) : ''].filter(Boolean).join(' · ')
|
||||||
|
|
||||||
|
const dayCommitsCache = {}
|
||||||
function renderActDay() {
|
function renderActDay() {
|
||||||
const e = actData.days[actDay]
|
const e = actData.days[actDay]
|
||||||
document.getElementById('acDayTitle').textContent = fmtDay(actDay)
|
document.getElementById('acDayTitle').textContent = fmtDay(actDay)
|
||||||
document.getElementById('acDay').innerHTML = e?.projects.length
|
const el = document.getElementById('acDay')
|
||||||
? `<div class="aclist">${e.projects.map((p) => actRow(p.name, actMeta(p.files, p.commits))).join('')}</div>`
|
if (!e?.projects.length) { el.innerHTML = `<div class="hint">${t('act.nothingDay')}</div>`; return }
|
||||||
: `<div class="hint">${t('act.nothingDay')}</div>`
|
const hasCommits = e.projects.some((p) => p.commits > 0)
|
||||||
|
el.innerHTML = `<div class="aclist">${e.projects.map((p) => actRow(p.name, actMeta(p.files, p.commits))).join('')}</div>` +
|
||||||
|
(hasCommits ? `<details class="accommits" id="acCommits"><summary>${ic('git-commit-horizontal', 'sm')}${t('act.showCommits')}${ic('chevron-down', 'sm')}</summary><div class="acc-body"></div></details>` : '')
|
||||||
|
const det = document.getElementById('acCommits')
|
||||||
|
if (det) det.addEventListener('toggle', () => { if (det.open) loadDayCommits(actDay, det.querySelector('.acc-body')) })
|
||||||
|
}
|
||||||
|
// lazy: commit messages for the selected day (only git projects, server-side)
|
||||||
|
async function loadDayCommits(day, box) {
|
||||||
|
if (box.dataset.loadedDay === day) return
|
||||||
|
box.dataset.loadedDay = day
|
||||||
|
box.innerHTML = `<span class="hint">${t('info.loading')}</span>`
|
||||||
|
let data = dayCommitsCache[day]
|
||||||
|
if (!data) {
|
||||||
|
try { data = await (await fetch('/api/activity/day?date=' + encodeURIComponent(day))).json() }
|
||||||
|
catch { box.dataset.loadedDay = ''; box.innerHTML = `<span class="hint">${t('err.saveFailed')}</span>`; return }
|
||||||
|
dayCommitsCache[day] = data
|
||||||
|
}
|
||||||
|
box.innerHTML = data.projects?.length
|
||||||
|
? data.projects.map((p) => `<div class="acc-proj"><b>${escapeHtml(p.name)}</b><ul>${p.msgs.map((m) => `<li>${escapeHtml(m)}</li>`).join('')}</ul></div>`).join('')
|
||||||
|
: `<span class="hint">${t('act.nothingDay')}</span>`
|
||||||
}
|
}
|
||||||
|
|
||||||
function renderActTop() {
|
function renderActTop() {
|
||||||
|
|||||||
@@ -424,6 +424,16 @@
|
|||||||
.aclist.spark-list button { grid-template-columns: minmax(0, 1fr) 72px auto; }
|
.aclist.spark-list button { grid-template-columns: minmax(0, 1fr) 72px auto; }
|
||||||
.spark { display: inline-flex; align-items: flex-end; gap: 1px; height: 20px; width: 72px; }
|
.spark { display: inline-flex; align-items: flex-end; gap: 1px; height: 20px; width: 72px; }
|
||||||
.spark i { flex: 1; min-width: 1px; background: color-mix(in srgb, var(--accent) 55%, transparent); border-radius: 1px; align-self: flex-end; }
|
.spark i { flex: 1; min-width: 1px; background: color-mix(in srgb, var(--accent) 55%, transparent); border-radius: 1px; align-self: flex-end; }
|
||||||
|
/* expandable commit messages in the day detail */
|
||||||
|
.accommits { margin-top: 10px; border-top: 1px solid var(--border); padding-top: 8px; }
|
||||||
|
.accommits > summary { list-style: none; cursor: pointer; display: flex; align-items: center; gap: 7px; font-size: 12.5px; color: var(--muted); font-weight: 600; }
|
||||||
|
.accommits > summary::-webkit-details-marker { display: none; }
|
||||||
|
.accommits > summary > .i:last-child { margin-left: auto; transition: transform .18s; }
|
||||||
|
.accommits[open] > summary > .i:last-child { transform: rotate(180deg); }
|
||||||
|
.acc-body { margin-top: 8px; display: flex; flex-direction: column; gap: 10px; }
|
||||||
|
.acc-proj b { font-size: 12.5px; }
|
||||||
|
.acc-proj ul { margin: 4px 0 0; padding-left: 18px; }
|
||||||
|
.acc-proj li { font-size: 12.5px; color: var(--muted); line-height: 1.5; overflow-wrap: anywhere; }
|
||||||
.aclist { display: flex; flex-direction: column; gap: 2px; }
|
.aclist { display: flex; flex-direction: column; gap: 2px; }
|
||||||
.aclist button { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 10px; align-items: center; border: none; background: none; padding: 6px 8px; margin: 0 -8px; border-radius: 7px; cursor: pointer; text-align: left; font: inherit; color: inherit; }
|
.aclist button { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 10px; align-items: center; border: none; background: none; padding: 6px 8px; margin: 0 -8px; border-radius: 7px; cursor: pointer; text-align: left; font: inherit; color: inherit; }
|
||||||
.aclist button:hover { background: var(--surface-2); }
|
.aclist button:hover { background: var(--surface-2); }
|
||||||
|
|||||||
15
server.js
15
server.js
@@ -934,6 +934,21 @@ app.get('/api/projects/:name/activity', handle(async (req, res) => {
|
|||||||
res.json({ files: a.files ?? null, commits: a.commits, today: activity.dayOf(Date.now()) })
|
res.json({ files: a.files ?? null, commits: a.commits, today: activity.dayOf(Date.now()) })
|
||||||
}))
|
}))
|
||||||
|
|
||||||
|
// Commit messages of one local day (lazy, for the activity day detail). Only queries git projects.
|
||||||
|
app.get('/api/activity/day', handle(async (req, res) => {
|
||||||
|
const date = String(req.query.date ?? '')
|
||||||
|
if (!/^\d{4}-\d{2}-\d{2}$/.test(date)) return res.status(400).json({ error: 'bad date' })
|
||||||
|
const list = projectList().filter((p) => fs.existsSync(path.join(p.root.path, p.folder, '.git')))
|
||||||
|
const out = await pool(list, 8, async (p) => {
|
||||||
|
const dir = path.join(p.root.path, p.folder)
|
||||||
|
const r = await run('git', ['-C', dir, 'log', `--since=${date} 00:00:00`, `--until=${date} 23:59:59`,
|
||||||
|
'--no-merges', '--format=%s'], { timeout: 8000 }).catch(() => ({ stdout: '' }))
|
||||||
|
const msgs = r.stdout.split(/\r?\n/).map((s) => s.trim()).filter(Boolean).slice(0, 30)
|
||||||
|
return msgs.length ? { name: p.key, msgs } : null
|
||||||
|
})
|
||||||
|
res.json({ date, projects: out.filter(Boolean) })
|
||||||
|
}))
|
||||||
|
|
||||||
// Storage page: every shown project with its scan result (size, split, cleanup candidates).
|
// Storage page: every shown project with its scan result (size, split, cleanup candidates).
|
||||||
app.get('/api/storage', (req, res) => {
|
app.get('/api/storage', (req, res) => {
|
||||||
const list = projectList().map((p) => {
|
const list = projectList().map((p) => {
|
||||||
|
|||||||
Reference in New Issue
Block a user