feat(performance): 기간 빠른 선택 이번달·올해만(기본 이번달) · 일자별 표 제목·기간 합계 행 스크롤 고정

- 매출 실적·광고비 탭 오늘·이번주 버튼 삭제, 매출 실적 기본 기간 = 이번달
- 일자별 표 상자(.perf-main-wrap)를 화면 높이로 묶어 상자 안 세로 스크롤 — 제목 행 + 맨 위 기간 합계 행 sticky
  (합계 행 top = 제목 행 높이 --perf-head-h, stickyHead 가 ResizeObserver 로 잼), 날짜 열 가로 고정은 그대로
- 테스트: perf_sticky.browser.test.js(실제 브라우저), test_ad_spend 빠른 선택 순서

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-10-26 12:29:09 +09:00
parent 7731e4e8de
commit 3d14ff4a85
12 changed files with 135 additions and 18 deletions
+5
View File
@@ -44,6 +44,11 @@
서버가 계산(원 반올림)해 금액으로, 식은 `formula` 열에 저장 → 칸 `is-formula` 파랑 굵은 숫자, 다시 누르면 식. 숫자 입력·업로드·광고 API 로 덮으면 식 지움(`db._set_formulas`, 008 미적용이면 조용히 건너뜀).
광고비 탭 직접 입력값은 파랑 **보통 굵기**(굵게는 계산식만), 매출 탭 수동 입력값은 예전처럼 파랑 굵게.
- 일자별 표 **기간 합계 행은 맨 위**(제목 행 바로 아래, 2026-10-21 `calc.main_table`) — 매출·광고비 공통, 연간 보기 "연간 합계"는 그대로 맨 아래.
- **기간 빠른 선택 = 이번달·올해·직접선택**(2026-10-26 — 오늘·이번주 버튼 삭제, `dashboard.build_dashboard`·`ad_spend.build_ad_dashboard` 의 `nav.quick`),
매출 실적 기본 기간도 **이번달**(`router.dashboard_page` `period="month"`, 광고비는 원래 이번달). day·week 주소(`?period=week`)는 그대로 열린다.
- **일자별 표 스크롤 고정**(2026-10-26, `.perf-main-wrap`) — 표 상자를 화면 높이(`100vh − 상단 바 − 24px`)로 묶어 상자 안에서 세로 스크롤,
제목 행 + 맨 위 기간 합계 행(`tbody tr.perf-row-total:first-child`)이 sticky. 합계 행 top = 제목 행 높이(`--perf-head-h`, `performance.js stickyHead`
가 ResizeObserver 로 잼). 상자가 가로 스크롤이라 페이지 스크롤 기준 sticky 는 안 먹어서 상자 안 스크롤로 했다. 테스트 `tests/js/perf_sticky.browser.test.js`.
- 열 순서 카페24·네이버·쿠팡(윙)·쿠팡(로켓)·오늘의집·G마켓·카카오·GS샵·11번가·롯데ON·토스·애터미아자몰(마이그레이션 003).
- 쿠팡(로켓)·애터미아자몰은 **수동 입력 전용**(`adapters/manual.py`, `manual_only` — 매출 업데이트에서 빠지고 인증 설정·연결 테스트 없음, 수동 입력 늘 켜짐).
- **직접 추가 쇼핑몰·그룹·순서 드래그**(2026-10-22, 마이그레이션 009 `is_custom`·`is_group`·`parent_code`) — 설정 [+ 쇼핑몰 추가(수동 입력)]
+1 -2
View File
@@ -553,9 +553,8 @@ def build_ad_dashboard(store: Any, *, kind: str, anchor: date, today: date,
next_url = url("custom", start=period.end + timedelta(days=1), end=period.end + length)
else:
prev_url, next_url = url(period.kind, period.prev_anchor), url(period.kind, period.next_anchor)
# 빠른 선택은 이번달·올해만(2026-10-26 — 오늘·이번주 버튼 삭제, 매출 실적과 같게)
nav = {"prev": prev_url, "next": next_url, "quick": [
{"label": "오늘", "url": url("day", today), "active": period.kind == "day" and period.start == today},
{"label": "이번주", "url": url("week", today), "active": period.kind == "week" and period.start <= today <= period.end},
{"label": "이번달", "url": url("month", today), "active": period.kind == "month" and period.start <= today <= period.end},
{"label": "올해", "url": url("year", today), "active": period.kind == "year" and period.start <= today <= period.end},
]}
+1 -4
View File
@@ -249,11 +249,8 @@ def build_dashboard(store: Any, *, kind: str, anchor: date, today: date,
next_url = url(period.kind, period.next_anchor)
nav = {
"prev": prev_url, "next": next_url,
# 빠른 선택은 이번달·올해만(2026-10-26 — 오늘·이번주 버튼 삭제, 기본 = 이번달)
"quick": [
{"key": "day", "label": "오늘", "url": url("day", today),
"active": period.kind == "day" and period.start == today},
{"key": "week", "label": "이번주", "url": url("week", today),
"active": period.kind == "week" and period.start <= today <= period.end},
{"key": "month", "label": "이번달", "url": url("month", today),
"active": period.kind == "month" and period.start <= today <= period.end},
{"key": "year", "label": "올해", "url": url("year", today),
+1 -1
View File
@@ -121,7 +121,7 @@ def health(request: Request) -> JSONResponse:
@router.get("/", response_class=HTMLResponse)
def dashboard_page(
request: Request,
period: str = "week",
period: str = "month",
d: str | None = None,
from_: str | None = Query(None, alias="from"),
to: str | None = None,
@@ -1,6 +1,6 @@
{% extends "erp_base.html" %}
{% block head_extra %}<link rel="stylesheet" href="/static/performance.css?v=20261022c" />{% endblock %}
{% block head_extra %}<link rel="stylesheet" href="/static/performance.css?v=20261026a" />{% endblock %}
{#- ROAS 덧붙임 — "광고비(ROAS%)". 광고비가 없으면 아무것도 안 붙는다. -#}
{%- macro roas(p) -%}{%- if p is not none -%}<span class="perf-roas">({{ "{:,}".format(p) }}%)</span>{%- endif -%}{%- endmacro -%}
@@ -96,7 +96,8 @@
{% endif %}
</div>
</div>
<div class="erp-table-wrap perf-table-wrap">
<div class="erp-table-wrap perf-table-wrap perf-main-wrap">
{#- perf-main-wrap(2026-10-26) = 표 안에서 세로 스크롤 — 제목 행·기간 합계 행 고정 -#}
{#- perf-autofit(2026-10-22) = 열 너비는 내용 길이만큼, 날짜 열은 가로 스크롤해도 고정(매출 실적 표와 같음) -#}
<table class="perf-table perf-main perf-autofit">
<thead>
@@ -240,4 +241,4 @@
} | tojson }}</script>
{% endblock %}
{% block scripts %}<script src="/static/performance.js?v=20261022e" defer></script>{% endblock %}
{% block scripts %}<script src="/static/performance.js?v=20261026a" defer></script>{% endblock %}
@@ -1,6 +1,6 @@
{% extends "erp_base.html" %}
{% block head_extra %}<link rel="stylesheet" href="/static/performance.css?v=20261022c" />{% endblock %}
{% block head_extra %}<link rel="stylesheet" href="/static/performance.css?v=20261026a" />{% endblock %}
{%- macro won(v) -%}
{%- if v is none -%}<span class="perf-na"></span>
@@ -134,7 +134,8 @@
<button type="button" class="perf-seg" data-metric="net">수수료 차감 매출</button>
</div>
</div>
<div class="erp-table-wrap perf-table-wrap">
<div class="erp-table-wrap perf-table-wrap perf-main-wrap">
{#- perf-main-wrap(2026-10-26) = 표 안에서 세로 스크롤 — 제목 행·기간 합계 행 고정 -#}
{#- perf-autofit(2026-10-22) = 열 너비는 내용 길이만큼, 날짜 열은 가로 스크롤해도 고정 -#}
<table class="perf-table perf-main perf-autofit">
<thead>
@@ -291,4 +292,4 @@
} | tojson }}</script>
{% endblock %}
{% block scripts %}<script src="/static/performance.js?v=20261022e" defer></script>{% endblock %}
{% block scripts %}<script src="/static/performance.js?v=20261026a" defer></script>{% endblock %}
@@ -1,6 +1,6 @@
{% extends "erp_base.html" %}
{% block head_extra %}<link rel="stylesheet" href="/static/performance.css?v=20261022c" />{% endblock %}
{% block head_extra %}<link rel="stylesheet" href="/static/performance.css?v=20261026a" />{% endblock %}
{%- macro when(v) -%}{{ (v or '')[:16] | replace('T', ' ') or '—' }}{%- endmacro -%}
@@ -259,4 +259,4 @@
</section>
{% endblock %}
{% block scripts %}<script src="/static/performance.js?v=20261022e" defer></script>{% endblock %}
{% block scripts %}<script src="/static/performance.js?v=20261026a" defer></script>{% endblock %}
@@ -146,7 +146,7 @@ def test_ad_dashboard_month():
assert ctx["roas_basis"]["google"] == "" and ctx["roas_basis"]["coupang_wing"] == "쿠팡(윙)"
assert {r["code"]: r for r in ctx["month"]["rows"]}["google"]["roas"] is None
assert ads.roas(1, 3) == 33 and ads.roas(1, 200) == 1 and ads.roas(5, 0) is None # 0.5% 반올림 → 1
assert ctx["nav"]["quick"][2]["active"] # 이번달
assert ctx["nav"]["quick"][0]["active"] # 이번달
def test_ad_dashboard_year_and_missing_table():
+9
View File
@@ -457,3 +457,12 @@ body.perf-dragging, body.perf-dragging * { cursor: grabbing !important; user-sel
.perf-memo-input { width: 100%; box-sizing: border-box; min-height: 110px; padding: 10px; border: 1px solid #d8dce2; border-radius: 8px;
font: inherit; font-size: 13.5px; line-height: 1.5; resize: vertical; }
.perf-memo-input:focus { outline: none; border-color: #1a56db; box-shadow: 0 0 0 3px rgba(26, 86, 219, .12); }
/* ── 일자별 표 스크롤 고정(2026-10-26): 표 상자 안에서 세로 스크롤 → 제목 행 + 맨 위 기간 합계 행 고정 ──
(상자가 가로 스크롤(overflow-x)이라 페이지 스크롤 기준 sticky 는 안 먹는다 — 상자 높이를 화면 높이로 묶고 상자 안에서 스크롤)
--perf-head-h = 제목 행 높이(performance.js stickyHead 가 잼, 기본 31px). 연간 보기 "연간 합계"는 맨 아래 그대로. */
.perf-main-wrap { overflow: auto; max-height: calc(100vh - var(--erp-topbar-h, 56px) - 24px); overscroll-behavior: contain; }
.perf-main-wrap .perf-main thead th { z-index: 3; }
.perf-main-wrap .perf-main thead th.perf-th-label { z-index: 5; }
.perf-main-wrap .perf-main tbody tr.perf-row-total:first-child > * { position: sticky; top: var(--perf-head-h, 31px); z-index: 1; }
.perf-main-wrap .perf-main tbody tr.perf-row-total:first-child > .perf-td-label { left: 0; z-index: 4; }
+14 -1
View File
@@ -1434,9 +1434,22 @@
});
}
// 일자별 표 스크롤 고정(2026-10-26) — 기간 합계 행이 제목 행 바로 밑에 붙도록 제목 행 높이를 CSS 변수로.
// 그룹 접기·화면 크기·글꼴에 따라 높이가 바뀌므로 ResizeObserver 로 다시 잰다.
function stickyHead(root) {
root.querySelectorAll(".perf-main-wrap").forEach(function (wrap) {
const head = wrap.querySelector("thead");
if (!head) return;
const measure = function () { wrap.style.setProperty("--perf-head-h", head.getBoundingClientRect().height + "px"); };
measure();
if (window.ResizeObserver) new ResizeObserver(measure).observe(head);
else window.addEventListener("resize", measure);
});
}
document.addEventListener("DOMContentLoaded", function () {
const dash = document.getElementById("perf-dash");
if (dash) initDashboard(dash);
if (dash) { initDashboard(dash); stickyHead(dash); }
const set = document.getElementById("perf-settings");
if (set) initSettings(set);
});
+86
View File
@@ -0,0 +1,86 @@
// 실적 — 기간 빠른 선택(이번달·올해만, 기본 이번달) · 일자별 표 스크롤 고정(2026-10-26) — 실제 브라우저(Chromium).
// python tests/js/render_performance.py
// NODE_PATH=<playwright 경로> PJ_TEST_BROWSER=<Chrome 경로> node tests/js/perf_sticky.browser.test.js
// 매출 실적(이번달)·광고비(이번달): 표 상자 안에서 세로 스크롤하면 제목 행은 상자 맨 위, 기간 합계 행은 제목 행 바로 아래에 붙어 있고
// 날짜 칸은 가로 스크롤해도 왼쪽 고정(예전 그대로). 오늘·이번주 버튼은 없다.
const fs = require("fs"), path = require("path");
const { chromium } = require("playwright");
const ROOT = path.join(__dirname, "..", "..");
const fails = [];
function check(name, cond, extra) {
if (cond) console.log("PASS " + name);
else { console.log("FAIL " + name + (extra !== undefined ? " → " + JSON.stringify(extra) : "")); fails.push(name); }
}
function page(file) {
const css = fs.readFileSync(path.join(ROOT, "app", "static", "performance.css"), "utf8");
const js = fs.readFileSync(path.join(ROOT, "app", "static", "performance.js"), "utf8");
return fs.readFileSync(path.join(__dirname, ".out", file), "utf8")
.replace(/<link rel="stylesheet" href="\/static\/performance\.css[^"]*" \/>/, function () { return "<style>" + css + "</style>"; })
.replace(/<script src="\/static\/performance\.js[^"]*" defer><\/script>/, function () { return "<script>" + js + "</script>"; });
}
async function stickyFlow(browser, file, label) {
const ctx = await browser.newContext({ viewport: { width: 900, height: 600 } });
const p = await ctx.newPage();
await p.route("**/*", function (r) {
const url = new URL(r.request().url()).pathname;
if (url.startsWith("/performance/api/")) { r.fulfill({ status: 200, contentType: "application/json", body: "{}" }); return; }
r.fulfill({ status: 200, contentType: "text/html; charset=utf-8", body: page(file) });
});
await p.goto("http://perf.test/performance/");
const quick = await p.evaluate(function () {
return Array.from(document.querySelectorAll(".perf-quick .perf-seg")).map(function (n) { return n.textContent.trim(); });
});
check(label + " 빠른 선택 = 이번달·올해·직접선택(오늘·이번주 없음)", JSON.stringify(quick) === '["이번달","올해","직접선택"]', quick);
const geo = async function () {
return p.evaluate(function () {
const wrap = document.querySelector(".perf-main-wrap");
const head = wrap.querySelector("thead th:nth-child(2)");
const total = wrap.querySelector("tbody tr.perf-row-total:first-child");
const totalCell = total.querySelector("td");
const label = total.querySelector(".perf-td-label");
const w = wrap.getBoundingClientRect();
return { wrapTop: w.top, wrapLeft: w.left, scrollH: wrap.scrollHeight, clientH: wrap.clientHeight,
headTop: head.getBoundingClientRect().top, headBottom: head.getBoundingClientRect().bottom,
totalTop: totalCell.getBoundingClientRect().top, labelLeft: label.getBoundingClientRect().left,
totalText: label.textContent.trim(),
// 기간 합계 행 위에 다른 줄이 겹쳐 보이지 않는가 — 합계 칸 가운데를 찍으면 합계 행 칸이 나와야 한다
hit: (function () {
const r = totalCell.getBoundingClientRect();
const el = document.elementFromPoint(r.left + r.width / 2, r.top + r.height / 2);
return !!el && !!el.closest("tr.perf-row-total");
})(),
labelHit: (function () {
const r = label.getBoundingClientRect();
const el = document.elementFromPoint(r.left + r.width / 2, r.top + r.height / 2);
return !!el && !!el.closest("tr.perf-row-total");
})() };
});
};
const g0 = await geo();
check(label + " 표 상자가 세로로 스크롤된다(화면 높이로 묶음)", g0.scrollH > g0.clientH + 100, g0);
check(label + " 맨 위 행 = 기간 합계", g0.totalText === "기간 합계", g0.totalText);
await p.evaluate(function () { document.querySelector(".perf-main-wrap").scrollTop = 400; });
await p.waitForTimeout(50);
const g1 = await geo();
check(label + " 세로 스크롤 뒤 제목 행 = 상자 맨 위", Math.abs(g1.headTop - g1.wrapTop) <= 1.5, g1);
check(label + " 세로 스크롤 뒤 기간 합계 행 = 제목 행 바로 아래", Math.abs(g1.totalTop - g1.headBottom) <= 1.5 && g1.hit, g1);
await p.evaluate(function () { document.querySelector(".perf-main-wrap").scrollLeft = 300; });
await p.waitForTimeout(50);
const g2 = await geo();
check(label + " 가로 스크롤해도 기간 합계 날짜 칸은 왼쪽 고정", Math.abs(g2.labelLeft - g2.wrapLeft) <= 1.5 && g2.labelHit, g2);
await ctx.close();
}
(async function () {
const exe = process.env.PJ_TEST_BROWSER;
const browser = await chromium.launch(exe ? { executablePath: exe } : {});
try {
await stickyFlow(browser, "perf_dash_month.html", "[매출 실적]");
await stickyFlow(browser, "perf_ads.html", "[광고비]");
} finally {
await browser.close();
}
if (fails.length) { console.log("\n" + fails.length + " FAILED"); process.exit(1); }
console.log("\nALL PASS");
})().catch(function (e) { console.error(e); process.exit(1); });
+7 -1
View File
@@ -94,7 +94,13 @@ def main() -> None:
html = e.get_template("performance/index.html").render(**base, active_tab="dashboard", metric="net", **ctx)
with open(os.path.join(OUT_DIR, "perf_dash.html"), "w", encoding="utf-8") as f:
f.write(html)
actx = build_ad_dashboard(FakeStore(), kind="month", anchor=date(2026, 10, 7), today=date(2026, 10, 7),
# 이번달 보기(기본, 2026-10-26) — 맨 위 기간 합계 행이 있는 표(제목·합계 행 스크롤 고정 확인용)
mctx = build_dashboard(FakeStore(), kind="month", anchor=date(2026, 10, 7), today=date(2026, 10, 7))
mctx["auto_sync"] = ctx["auto_sync"]
html = e.get_template("performance/index.html").render(**base, active_tab="dashboard", metric="net", **mctx)
with open(os.path.join(OUT_DIR, "perf_dash_month.html"), "w", encoding="utf-8") as f:
f.write(html)
actx =build_ad_dashboard(FakeStore(), kind="month", anchor=date(2026, 10, 7), today=date(2026, 10, 7),
sales_codes=["cafe24", "coupang"])
actx["ad_sync_sources"] = [{"code": "google", "name": "구글 광고"}] # [구글 광고 불러오기]
actx["auto_sync"] = ctx["auto_sync"] # 광고비 탭도 다음 업데이트 카운트다운(router._auto_sync_ctx)