feat(project): dashboard workload by assignee with subtasks and completion
Replace the scheduled-tasks bar chart with a table of all tasks assigned
per person in scope (no due date needed, filters ignored): main tasks,
subtasks (new GET /api/projects/{id}/subtasks-summary), done counts and
completion rate, plus a total row. Admin only, as before.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -1544,6 +1544,23 @@ img.pj-person-ic { width: 22px; height: 22px; }
|
||||
box-shadow: var(--pj-card-shadow); padding: 18px 20px 20px; min-width: 0;
|
||||
}
|
||||
.pj-dash-card-wide { grid-column: 1 / -1; }
|
||||
/* 담당자별 작업 합계(메인·하위, 완료) 표 */
|
||||
.pj-dash-workload { overflow-x: auto; }
|
||||
.pj-wl-table { width: 100%; border-collapse: collapse; font-size: 13px; font-variant-numeric: tabular-nums; }
|
||||
.pj-wl-table th, .pj-wl-table td { padding: 8px 10px; border-bottom: 1px solid var(--pj-border); text-align: left; white-space: nowrap; }
|
||||
.pj-wl-table thead th { font-size: 12px; font-weight: 600; color: var(--pj-ink-soft); }
|
||||
.pj-wl-table thead th:nth-child(2), .pj-wl-table thead th:nth-child(3), .pj-wl-table thead th:nth-child(4) { text-align: right; }
|
||||
.pj-wl-table tbody th { font-weight: 600; }
|
||||
.pj-wl-cnt { text-align: right !important; width: 72px; }
|
||||
.pj-wl-num { min-width: 150px; }
|
||||
.pj-wl-num > span { margin-left: 8px; color: var(--pj-ink-soft); }
|
||||
.pj-wl-num b { color: var(--pj-ink); }
|
||||
.pj-wl-num em { font-style: normal; font-weight: 700; color: var(--pj-accent-dark); margin-left: 4px; }
|
||||
.pj-wl-num em.is-good { color: #1f8a4c; }
|
||||
.pj-wl-bar { display: inline-block; vertical-align: middle; width: 90px; height: 8px; border-radius: 999px; background: #eceef2; overflow: hidden; }
|
||||
.pj-wl-bar i { display: block; height: 100%; border-radius: inherit; background: var(--color-success-green, #2e9e5b); transition: width .6s cubic-bezier(.22,.9,.3,1); }
|
||||
.pj-wl-all .pj-wl-bar { width: 120px; }
|
||||
.pj-wl-total th, .pj-wl-total td { border-bottom: none; border-top: 2px solid var(--pj-border); font-weight: 700; }
|
||||
.pj-dash-card-title { font-size: 13.5px; font-weight: 700; color: var(--pj-ink); margin-bottom: 18px; }
|
||||
|
||||
/* 세로 막대(섹션별/담당자별 공용) */
|
||||
|
||||
+91
-15
@@ -5785,31 +5785,107 @@
|
||||
]));
|
||||
charts.appendChild(statusCard);
|
||||
|
||||
// 담당자별 예정된 작업 — 미완료 + 일정(시작/마감일) 있는 작업만, 상위 10명.
|
||||
// 담당자별 작업 합계(2026-10-07) — 이 범위에서 그 사람에게 배정된 작업 전부(마감일·필터와 무관),
|
||||
// 메인 작업과 하위 작업을 나눠 세고 완료 수·완료율. 하위 업무는 화면 목록에 없어 서버에서 따로 받는다.
|
||||
// 사람별 업무량이 드러나는 표라 관리자에게만 보여준다.
|
||||
if (isAdmin) {
|
||||
const byAssignee = {};
|
||||
incomplete.forEach(function (t) {
|
||||
if (!t.start_date && !t.due_date) return;
|
||||
const k = t.assignee_email ? capName(t.assignee_name || idOf(t.assignee_email)) : "담당자 없음";
|
||||
byAssignee[k] = (byAssignee[k] || 0) + 1;
|
||||
});
|
||||
let assigneeEntries = Object.keys(byAssignee).map(function (k) { return { label: k, value: byAssignee[k] }; })
|
||||
.sort(function (a, b) { return b.value - a.value; });
|
||||
if (assigneeEntries.length > 10) {
|
||||
const rest = assigneeEntries.slice(10).reduce(function (s, x) { return s + x.value; }, 0);
|
||||
assigneeEntries = assigneeEntries.slice(0, 10).concat([{ label: "기타", value: rest }]);
|
||||
}
|
||||
const assigneeCard = document.createElement("div");
|
||||
assigneeCard.className = "pj-dash-card pj-dash-card-wide";
|
||||
assigneeCard.innerHTML = '<div class="pj-dash-card-title">예정된 작업 합계(담당자별)</div>';
|
||||
assigneeCard.appendChild(dashBarChart(assigneeEntries));
|
||||
assigneeCard.innerHTML = '<div class="pj-dash-card-title">담당자별 작업 합계(메인·하위 작업, 완료)</div>' +
|
||||
'<div class="pj-dash-workload"></div>';
|
||||
charts.appendChild(assigneeCard);
|
||||
paintWorkload(assigneeCard.querySelector(".pj-dash-workload"));
|
||||
}
|
||||
|
||||
root.appendChild(charts);
|
||||
}
|
||||
|
||||
// ── 담당자별 작업 합계 — 메인(이 범위 최상위 작업, 중복 없이) + 하위(서버 subtasks-summary), 완료 수 ──
|
||||
let workloadCache = { scope: "", at: 0, subtasks: null, pending: null };
|
||||
function loadWorkloadSubtasks(force) {
|
||||
const fresh = workloadCache.scope === viewScope && Date.now() - workloadCache.at < 15000;
|
||||
if (!force && fresh && workloadCache.subtasks) return Promise.resolve(workloadCache.subtasks);
|
||||
if (workloadCache.pending && workloadCache.scope === viewScope) return workloadCache.pending;
|
||||
const scope = viewScope;
|
||||
workloadCache.scope = scope;
|
||||
workloadCache.pending = api("GET", "/project/api/projects/" + projectId + "/subtasks-summary?scope=" + scope)
|
||||
.then(function (res) {
|
||||
if (workloadCache.scope === scope) Object.assign(workloadCache, { at: Date.now(), subtasks: res.subtasks || [] });
|
||||
return res.subtasks || [];
|
||||
})
|
||||
.finally(function () { workloadCache.pending = null; });
|
||||
return workloadCache.pending;
|
||||
}
|
||||
function paintWorkload(box) {
|
||||
const seen = {}, rows = {};
|
||||
function row(email, name) {
|
||||
const k = email ? email.toLowerCase() : "";
|
||||
if (!rows[k]) rows[k] = { label: email ? capName(name || idOf(email)) : "담당자 없음", none: !email,
|
||||
main: 0, mainDone: 0, sub: 0, subDone: 0 };
|
||||
return rows[k];
|
||||
}
|
||||
const mains = scopeTasks().filter(function (t) {
|
||||
if (t.parent_task_id || seen[t.id]) return false;
|
||||
seen[t.id] = true; return true;
|
||||
});
|
||||
mains.forEach(function (t) {
|
||||
const r = row(t.assignee_email, t.assignee_name);
|
||||
r.main++; if (t.completed_at) r.mainDone++;
|
||||
});
|
||||
function draw(subs) {
|
||||
Object.keys(rows).forEach(function (k) { rows[k].sub = 0; rows[k].subDone = 0; });
|
||||
(subs || []).forEach(function (s) {
|
||||
if (!seen[s.parent_task_id]) return; // 이 범위의 메인 작업에 딸린 하위 작업만
|
||||
const r = row(s.assignee_email, s.assignee_name);
|
||||
r.sub++; if (s.done) r.subDone++;
|
||||
});
|
||||
const list = Object.keys(rows).map(function (k) { return rows[k]; })
|
||||
.filter(function (r) { return r.main + r.sub > 0; })
|
||||
.sort(function (a, b) { return (a.none - b.none) || ((b.main + b.sub) - (a.main + a.sub)) || a.label.localeCompare(b.label); });
|
||||
if (!list.length) { box.innerHTML = "<div class='pj-empty-sm'>배정된 작업이 없습니다.</div>"; return; }
|
||||
const total = list.reduce(function (t, r) {
|
||||
return { main: t.main + r.main, mainDone: t.mainDone + r.mainDone, sub: t.sub + r.sub, subDone: t.subDone + r.subDone };
|
||||
}, { main: 0, mainDone: 0, sub: 0, subDone: 0 });
|
||||
function bar(done, all) {
|
||||
const pct = all ? Math.round(done / all * 100) : 0;
|
||||
return '<div class="pj-wl-bar" title="완료 ' + done + ' / ' + all + '"><i style="width:' + pct + '%"></i></div>';
|
||||
}
|
||||
function cell(done, all) {
|
||||
return '<td class="pj-wl-num">' + (all ? bar(done, all) + '<span><b>' + done + "</b> / " + all + "</span>" : '<span class="pj-muted">—</span>') + "</td>";
|
||||
}
|
||||
function tr(r, cls) {
|
||||
const all = r.main + r.sub, done = r.mainDone + r.subDone, pct = all ? Math.round(done / all * 100) : 0;
|
||||
return '<tr class="' + (cls || "") + '"><th>' + escapeHtml(r.label) + "</th>" +
|
||||
'<td class="pj-wl-cnt">' + r.main + "</td>" + '<td class="pj-wl-cnt">' + r.sub + "</td>" +
|
||||
'<td class="pj-wl-cnt"><b>' + all + "</b></td>" +
|
||||
cell(r.mainDone, r.main) + cell(r.subDone, r.sub) +
|
||||
'<td class="pj-wl-num pj-wl-all">' + bar(done, all) + "<span><b>" + done + "</b> / " + all +
|
||||
' <em class="' + (pct >= 100 ? "is-good" : "") + '">' + pct + "%</em></span></td></tr>";
|
||||
}
|
||||
box.innerHTML = '<table class="pj-wl-table"><thead><tr><th>담당자</th><th>메인 작업</th><th>하위 작업</th><th>전체</th>' +
|
||||
"<th>메인 완료</th><th>하위 완료</th><th>전체 완료(완료율)</th></tr></thead><tbody>" +
|
||||
list.map(function (r) { return tr(r); }).join("") + "</tbody><tfoot>" +
|
||||
tr(Object.assign({ label: "합계" }, total), "pj-wl-total") + "</tfoot></table>";
|
||||
requestAnimationFrame(function () { // 막대는 0 에서 늘어나게
|
||||
box.querySelectorAll(".pj-wl-bar i").forEach(function (i) {
|
||||
const w = i.style.width; i.style.width = "0"; requestAnimationFrame(function () { i.style.width = w; });
|
||||
});
|
||||
});
|
||||
}
|
||||
if (workloadCache.subtasks && workloadCache.scope === viewScope) draw(workloadCache.subtasks);
|
||||
else box.innerHTML = "<div class='pj-empty-sm'>하위 작업을 불러오는 중…</div>";
|
||||
loadWorkloadSubtasks(false).then(function (subs) {
|
||||
if (box.isConnected) draw(subs);
|
||||
}).catch(function (err) {
|
||||
if (!box.isConnected) return;
|
||||
draw([]);
|
||||
const note = document.createElement("div");
|
||||
note.className = "pj-empty-sm";
|
||||
note.textContent = "하위 작업을 불러오지 못해 메인 작업만 표시합니다: " + err.message;
|
||||
box.appendChild(note);
|
||||
});
|
||||
}
|
||||
|
||||
// 서버가 돌려준 업무를 로컬 목록에 반영. 멀티호밍된 업무는 목록에 여러 행
|
||||
// (원래 소속 맥락 + 연결된 프로젝트 맥락)으로 들어 있으므로 같은 id 의 행을
|
||||
// 전부 고친다. 단 "어느 맥락의 세션인지"에 해당하는 필드는 행마다 다르다 —
|
||||
|
||||
Reference in New Issue
Block a user