diff --git a/app/modules/live/CLAUDE.md b/app/modules/live/CLAUDE.md index e31fe1f..5f7b548 100644 --- a/app/modules/live/CLAUDE.md +++ b/app/modules/live/CLAUDE.md @@ -17,7 +17,8 @@ - **달력 보기** `/live/calendar?month=`(`store.build_calendar`, 사용자가 준 화면 참고, 글자도 영어 그대로) — 줄 = 2시간 칸(06:00~24:00 늘 보임, 그보다 이른 칸은 방송이 있을 때만, 칸은 시작 시간으로 정함), 열 = 날짜, 주말 노랑, 위 달 합계, 맨 아래 날짜별 TOTAL SALES·AD SPEND·HOST FEE·ROAS. 카드 머리 = **Tiktok Handle**(없으면 이름, 색 = 호스트 id 순 `HOST_COLORS`), SALES·COM·Fee. 카드 머리를 끌어 빈 칸으로 = 옮기기(`move`, 방송 길이 유지) · 다른 카드 위 = 맞바꾸기(`swap_with`, 날짜·시간 교환). 다시 그린 뒤 가로 위치 유지(sessionStorage). 빈 칸 + = 그 날짜·시간이 채워진 추가 창. **AD SPEND** = 날짜별 광고비 `live_daily_ad_spend`(마이그레이션 002, `POST /live/ad-spend`, 빈칸 = 지우기), ROAS = 판매금액 ÷ 광고비(광고비 없으면 `-`). 002 미적용이면 0 으로 보이고 저장만 안내. -- **오른쪽 달력**(2026-11-05, 달력 보기만, 세로 2분할 `.lv-split` — 스크롤해도 오른쪽 위에 고정, 예전 날짜로 이동 줄 대신, 공용 `erp-datepop` `mountRange` + `locale` 옵션으로 영문) — 날짜를 누르면 그 날이 표 맨 왼쪽(마지막 날까지 — `endGap` 이 표 끝에 여백), 다른 달이면 그 달 화면으로 가서 맨 왼쪽(sessionStorage `lv_cal_jump`). 표시만 하고 요금·일수에 안 씀. 테스트 `tests/js/live_calendar.browser.test.js`(`render_live.py`). +- **한 화면 맞춤**(2026-11-05) — 달력 보기는 넓은 화면(1101px 이상)에서 페이지 세로 스크롤 없음: `.lv-cal-wrap` 이 남은 높이를 쓰고, 풀HD 브라우저(세로 880px 이상)면 9개 시간 칸·합계 줄이 표 안 스크롤 없이 들어간다(카드가 한 칸에 겹치거나 창이 더 낮으면 표 안에서 스크롤). 카드·표 글자·칸 크기를 늘리면 `live_calendar.browser.test.js` 로 다시 확인. +- **오른쪽 달력**(2026-11-05, 달력 보기만, 세로 2분할 `.lv-split`, 240px = 공용 달력의 80%, 예전 날짜로 이동 줄 대신, 공용 `erp-datepop` `mountRange` + `locale` 옵션으로 영문) — 날짜를 누르면 그 날이 표 맨 왼쪽(마지막 날까지 — `endGap` 이 표 끝에 여백), 다른 달이면 그 달 화면으로 가서 맨 왼쪽(sessionStorage `lv_cal_jump`). 표시만 하고 요금·일수에 안 씀. 테스트 `tests/js/live_calendar.browser.test.js`(`render_live.py`). **말레이시아 공휴일 표 = `holidays.py`**(쿠알라룸푸르 기준, 2026·2027, 대체휴일 포함) — 이슬람 명절은 달 관측으로 바뀔 수 있고, 2028 은 공고되면 손으로 추가. - **결과 이미지** — 방송 저장과 한 트랜잭션, JPG·PNG·WebP, 한 장 8MB, 방송당 10장(`store.MAX_IMAGES`). `prepare_photo` 가 실제 이미지 확인·긴 변 2400px·EXIF(GPS 등) 제거. BYTEA 저장. `GET /live/images/{id}`(권한 필요, 하루 private 캐시), `?thumb=1` = 160px JPEG(그때그때 만듦). 올린 뒤 내용이 안 바뀐다는 전제 — 이미지를 고치는 기능을 넣으면 캐시도 바꿀 것. diff --git a/app/modules/live/templates/live/calendar.html b/app/modules/live/templates/live/calendar.html index 4939c92..129f51d 100644 --- a/app/modules/live/templates/live/calendar.html +++ b/app/modules/live/templates/live/calendar.html @@ -1,7 +1,7 @@ {% extends "erp_base.html" %} {#- 라이브 커머스 달력 보기(2026-11-04) — 줄 = 2시간 칸, 열 = 날짜, 맨 아래 = 날짜별 합계. 카드 머리 = 호스트 간단한 이름 + 그 방송의 틱톡 계정. 카드 머리를 끌어 빈 칸으로 옮기거나 다른 카드 위에 놓아 맞바꾼다(live.js). 문구 = t()(i18n.py), 영문은 CSS 로 대문자(받은 화면과 같게). -#} -{% block head_extra %} +{% block head_extra %} {% endblock %} diff --git a/app/modules/live/templates/live/index.html b/app/modules/live/templates/live/index.html index f7aa81f..5f42145 100644 --- a/app/modules/live/templates/live/index.html +++ b/app/modules/live/templates/live/index.html @@ -1,6 +1,6 @@ {% extends "erp_base.html" %} {#- 라이브 커머스 스케줄표(2026-11-04) — 달마다 방송 목록. 추가·고치기 창은 달력과 공용(_dialog.html, live.js). 문구 = t()(i18n.py). -#} -{% block head_extra %}{% endblock %} +{% block head_extra %}{% endblock %} {% block content %}
diff --git a/app/modules/live/templates/live/settings.html b/app/modules/live/templates/live/settings.html index 2b37332..137cd3d 100644 --- a/app/modules/live/templates/live/settings.html +++ b/app/modules/live/templates/live/settings.html @@ -1,6 +1,6 @@ {% extends "erp_base.html" %} {#- 라이브 커머스 설정(2026-11-04) — 호스트 정보. 계좌 등 개인정보·지우기는 ERP 관리자만(router.settings), 칩 권한자는 이름·상태만 보임 — `live_host` = 새 등록, `live_host_edit` = 고치기(개인정보는 빈칸으로 열림, 비워 두면 그대로). 추가·고치기는 같은 창(live.js). 문구 = t()(i18n.py). -#} -{% block head_extra %}{% endblock %} +{% block head_extra %}{% endblock %} {% block content %}
diff --git a/app/static/live.css b/app/static/live.css index 6ca8e16..c06bf8f 100644 --- a/app/static/live.css +++ b/app/static/live.css @@ -36,58 +36,79 @@ /* ── 달력 보기 ── */ .lv-kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 10px; } -.lv-kpi { display: flex; flex-direction: column; gap: 2px; padding: 10px 14px; border: 1px solid var(--color-subtle-ash, #e5e5e5); border-radius: 10px; background: #fff; } -.lv-kpi span { font-size: 11px; font-weight: 600; letter-spacing: .04em; color: var(--color-midtone-gray, #666); } -.lv-kpi b { font-size: 18px; font-variant-numeric: tabular-nums; } -.lv-tip { margin: 0; padding: 8px 12px; border: 1px solid var(--color-subtle-ash, #e5e5e5); border-radius: 10px; background: #f6f8fb; font-size: 13px; color: #374151; } +.lv-kpi { display: flex; flex-direction: column; gap: 0; padding: 4px 12px; border: 1px solid var(--color-subtle-ash, #e5e5e5); border-radius: 10px; background: #fff; } +.lv-kpi span { font-size: 10px; font-weight: 600; letter-spacing: .04em; color: var(--color-midtone-gray, #666); } +.lv-kpi b { font-size: 15px; font-variant-numeric: tabular-nums; } +.lv-tip { margin: 0; padding: 2px 12px; border: 1px solid var(--color-subtle-ash, #e5e5e5); border-radius: 10px; background: #f6f8fb; font-size: 11.5px; color: #374151; } /* 달력 보기 = 세로 2분할: 왼쪽 표 + 오른쪽 위에 붙는 달력(공용 erp-datepop 서식) */ -.lv-split { display: grid; grid-template-columns: minmax(0, 1fr) 300px; gap: 14px; align-items: start; } -.lv-side-cal { position: sticky; top: 0; box-sizing: border-box; padding: 12px; border: 1px solid #cfd4dc; border-radius: 10px; background: #fff; font-size: 13px; } +.lv-split { display: grid; grid-template-columns: minmax(0, 1fr) 240px; gap: 12px; } +.lv-split > .lv { gap: 6px; } +/* 풀HD 브라우저(세로 약 880~940px)에서 페이지 세로 스크롤 없이 한 화면 — 표 상자가 남은 높이를 쓰고, 더 좁은 창이나 카드가 겹친 칸은 표 안에서 스크롤 */ +@media (min-width: 1101px) { + .erp-page:has(> .lv-split) { overflow: hidden; padding: 10px 12px; } + .lv-split { flex: 1 1 auto; min-height: 0; grid-template-rows: minmax(0, 1fr); } + .lv-split > .lv { min-height: 0; } + .lv-split .lv-cal-wrap { flex: 1 1 auto; min-height: 0; max-height: none; } + .lv-split .lv-cal { height: 100%; } +} @media (max-width: 1100px) { .lv-split { grid-template-columns: minmax(0, 1fr); } - .lv-side-cal { position: static; order: -1; max-width: 340px; } + .lv-side-cal { order: -1; max-width: 340px; } } +/* 오른쪽 달력 = 공용 달력의 80% */ +.lv-side-cal { align-self: start; box-sizing: border-box; padding: 10px; border: 1px solid #cfd4dc; border-radius: 10px; background: #fff; font-size: 10.4px; } +.lv-side-cal .pj-dp-nav { margin: 0 0 4px; } +.lv-side-cal .pj-dp-title { font-size: 11.2px; } +.lv-side-cal .pj-dp-navbtn { width: 22px; height: 22px; } +.lv-side-cal .pj-dp-navbtn .material-symbols-outlined { font-size: 18px; } +.lv-side-cal .pj-dp-wd { padding: 3px 0 4px; font-size: 9.6px; } +.lv-side-cal .pj-dp-day { height: 27px; font-size: 10.8px; } +.lv-side-cal .pj-dp-day::before { width: 24px; height: 24px; top: 13.5px; } +.lv-side-cal .pj-dp-num { height: 27px; } +.lv-side-cal .pj-dp-day.has-hol { height: 37px; } +.lv-side-cal .pj-dp-hol { margin-top: -2px; font-size: 8px; } .lv-cal-wrap { overflow: auto; max-height: calc(100vh - 150px); border: 1px solid #cfd4dc; border-radius: 10px; background: #fff; } .lv-cal { border-collapse: separate; border-spacing: 0; min-width: max-content; } .lv-cal th, .lv-cal td { border-right: 1px solid #e3e6eb; border-bottom: 1px solid #e3e6eb; } -.lv-cal thead th { position: sticky; top: 0; z-index: 2; width: 182px; min-width: 182px; padding: 8px 6px; background: #e4e8ee; text-align: center; font-weight: 700; } +.lv-cal thead th { position: sticky; top: 0; z-index: 2; width: 182px; min-width: 182px; height: 1px; padding: 3px 6px; background: #e4e8ee; text-align: center; font-weight: 700; } .lv-cal thead th.is-weekend { background: #f5efd3; color: #7a5c00; } .lv-cal thead th.is-today { box-shadow: inset 0 -3px 0 #111; } -.lv-cal-weekday { font-size: 13px; letter-spacing: .03em; } -.lv-cal-count { display: inline-block; min-width: 18px; padding: 0 4px; margin-left: 2px; border: 1px solid #cfd4dc; border-radius: 4px; background: #fff; color: #374151; font-size: 11px; font-weight: 600; } -.lv-cal-date { margin-top: 2px; font-size: 11px; font-weight: 600; color: #6b7280; } -.lv-cal .lv-cal-time { position: sticky; left: 0; z-index: 1; width: 132px; min-width: 132px; padding: 8px; background: #f6f7f9; text-align: center; font-size: 13px; font-weight: 700; white-space: nowrap; } +.lv-cal-weekday { font-size: 11.5px; letter-spacing: .03em; } +.lv-cal-count { display: inline-block; min-width: 15px; padding: 0 3px; margin-left: 2px; border: 1px solid #cfd4dc; border-radius: 4px; background: #fff; color: #374151; font-size: 9.5px; font-weight: 600; } +.lv-cal-date { margin-top: 0; font-size: 9.5px; font-weight: 600; color: #6b7280; } +.lv-cal .lv-cal-time { position: sticky; left: 0; z-index: 1; width: 112px; min-width: 112px; padding: 2px 6px; background: #f6f7f9; text-align: center; font-size: 11.5px; font-weight: 700; white-space: nowrap; } .lv-cal thead .lv-cal-time { z-index: 3; background: #d9dee6; } -.lv-cal .lv-cal-time small { display: block; margin-top: 2px; font-size: 10.5px; font-weight: 600; color: #6b7280; } -.lv-cell { min-height: 100px; padding: 4px; vertical-align: top; background: #fff; } +.lv-cal .lv-cal-time small { display: block; margin-top: 0; font-size: 9px; font-weight: 600; color: #6b7280; } +.lv-cell { padding: 2px; vertical-align: top; background: #fff; } .lv-cell.is-weekend { background: #fffdf3; } .lv-cell.is-drop { background: #e8f1ff; box-shadow: inset 0 0 0 2px #3b82f6; } -.lv-cell-add { display: block; width: 100%; min-height: 88px; border: 1px dashed #d8dce3; border-radius: 6px; background: transparent; color: #b0b6c0; font-size: 16px; cursor: pointer; } +.lv-cell-add { display: block; width: 100%; height: 100%; min-height: 52px; border: 1px dashed #d8dce3; border-radius: 6px; background: transparent; color: #b0b6c0; font-size: 14px; cursor: pointer; } .lv-cell-add:hover, .lv-cell-add:focus-visible { border-color: #6b7280; color: #374151; } -.lv-card { margin-bottom: 4px; border: 1.5px solid #1f2937; border-radius: 6px; background: #fff; overflow: hidden; } -.lv-card-head { display: flex; align-items: center; gap: 4px; padding: 3px 6px; border-bottom: 1px solid #1f2937; cursor: grab; } +.lv-card + .lv-card { margin-top: 2px; } +.lv-card { border: 1px solid #1f2937; border-radius: 6px; background: #fff; overflow: hidden; } +.lv-card-head { display: flex; align-items: center; gap: 3px; padding: 1px 4px; border-bottom: 1px solid #1f2937; cursor: grab; } .lv-card-head:active { cursor: grabbing; } -.lv-card-name small { display: block; overflow: hidden; text-overflow: ellipsis; text-transform: none; font-size: 10px; font-weight: 600; letter-spacing: 0; } -.lv-card-grip { font-size: 12px; color: #374151; } -.lv-card-name { flex: 1 1 auto; min-width: 0; overflow: hidden; text-align: center; text-overflow: ellipsis; white-space: nowrap; text-transform: uppercase; font-size: 13px; font-weight: 800; letter-spacing: .03em; color: #111; } -.lv-card-edit { padding: 0 2px; border: 0; background: none; color: #374151; font-size: 13px; cursor: pointer; } +.lv-card-name small { display: block; overflow: hidden; text-overflow: ellipsis; text-transform: none; font-size: 9px; line-height: 1.1; font-weight: 600; letter-spacing: 0; } +.lv-card-grip { font-size: 10px; color: #374151; } +.lv-card-name { flex: 1 1 auto; min-width: 0; overflow: hidden; text-align: center; text-overflow: ellipsis; white-space: nowrap; text-transform: uppercase; font-size: 11px; line-height: 1.2; font-weight: 800; letter-spacing: .03em; color: #111; } +.lv-card-edit { padding: 0 2px; border: 0; background: none; color: #374151; font-size: 11px; cursor: pointer; } .lv-card-nums { display: grid; grid-template-columns: 1fr 1fr; } -.lv-card-nums div { display: flex; flex-direction: column; text-align: center; } +.lv-card-nums div { display: flex; align-items: baseline; justify-content: center; gap: 4px; padding: 1px 2px; white-space: nowrap; } .lv-card-nums div + div { border-left: 1px solid #e3e6eb; } -.lv-card-nums span { padding: 2px 0; background: #f6f7f9; font-size: 10px; font-weight: 600; color: #4b5563; } -.lv-card-nums b { padding: 3px 0; font-size: 14px; font-variant-numeric: tabular-nums; } -.lv-card-foot { display: flex; justify-content: space-between; gap: 4px; padding: 2px 6px; border-top: 1px solid #e3e6eb; background: #f6f7f9; font-size: 10.5px; font-weight: 600; color: #4b5563; } +.lv-card-nums span { font-size: 9px; font-weight: 600; color: #4b5563; } +.lv-card-nums b { font-size: 11px; font-variant-numeric: tabular-nums; } +.lv-card-foot { display: flex; justify-content: space-between; gap: 4px; padding: 0 4px; border-top: 1px solid #e3e6eb; background: #f6f7f9; font-size: 9px; font-weight: 600; color: #4b5563; } .lv-card-foot b { color: #8a2c0d; } .lv-card-foot a { color: #1d4f91; } -.lv-cal tfoot th, .lv-cal tfoot td { position: sticky; bottom: 0; z-index: 2; padding: 8px; background: #101a33; color: #fff; border-color: #2a3550; } -.lv-cal tfoot .lv-cal-time { z-index: 3; background: #101a33; font-size: 12px; } -.lv-total { display: flex; flex-direction: column; gap: 2px; margin: 0; font-size: 11px; font-weight: 600; } +.lv-cal tfoot th, .lv-cal tfoot td { position: sticky; bottom: 0; z-index: 2; height: 1px; padding: 3px 6px; background: #101a33; color: #fff; border-color: #2a3550; } +.lv-cal tfoot .lv-cal-time { z-index: 3; background: #101a33; font-size: 11px; } +.lv-total { display: flex; flex-direction: column; gap: 0; margin: 0; font-size: 9.5px; line-height: 1.25; font-weight: 600; } .lv-total div { display: flex; justify-content: space-between; gap: 6px; } .lv-total dt { color: #aab3c5; } .lv-total dd { margin: 0; font-variant-numeric: tabular-nums; color: #fbbf72; white-space: nowrap; } .lv-total dd.is-sales { color: #6ee7a8; } -.lv-total-edit { padding: 0 2px; border: 0; background: none; color: #cbd5e1; font-size: 11px; cursor: pointer; } +.lv-total-edit { padding: 0 2px; border: 0; background: none; color: #cbd5e1; font-size: 9.5px; line-height: 1; cursor: pointer; } .lv-dlg { width: min(560px, calc(100vw - 32px)); max-height: calc(100vh - 40px); padding: 0; border: 1px solid var(--color-subtle-ash, #e5e5e5); border-radius: 12px; } .lv-dlg::backdrop { background: rgba(0, 0, 0, .35); } diff --git a/tests/js/live_calendar.browser.test.js b/tests/js/live_calendar.browser.test.js index 59d85f1..a0785af 100644 --- a/tests/js/live_calendar.browser.test.js +++ b/tests/js/live_calendar.browser.test.js @@ -50,7 +50,7 @@ function check(name, cond, extra) { const s = document.getElementById("lv-side-cal").getBoundingClientRect(), l = document.querySelector(".lv").getBoundingClientRect(); return { left: l.left - page.left, right: page.right - s.right }; }); - check("좌우 여백 16px", edges.left <= 17 && edges.right <= 34, edges); // 오른쪽 = 여백 + 스크롤 막대 + check("좌우 여백 12px", edges.left <= 13 && edges.right <= 13, edges); await p.setViewportSize({ width: 2400, height: 900 }); await p.waitForTimeout(100); const wide = await p.evaluate(function () { @@ -58,16 +58,28 @@ function check(name, cond, extra) { return { pageRight: page.right, shell: document.documentElement.clientWidth }; }); check("넓은 화면도 전체 너비(최대 폭 해제)", Math.abs(wide.pageRight - wide.shell) < 2, wide); - await p.setViewportSize({ width: 1600, height: 500 }); + // 풀HD 브라우저 — 페이지 세로 스크롤 없음, 모든 시간 칸에 카드가 있어도 표 안 스크롤도 없음 + const fit = function () { + return p.evaluate(function () { + const pg = document.querySelector(".erp-page"), w = document.getElementById("lv-cal-wrap"); + return { page: pg.scrollHeight - pg.clientHeight, table: w.scrollHeight - w.clientHeight, wrapH: w.clientHeight, row: document.querySelector(".lv-cal tbody tr").getBoundingClientRect().height }; + }); + }; + for (const h of [937, 880]) { + await p.setViewportSize({ width: 1920, height: h }); + await p.waitForTimeout(100); + const f = await fit(); + check("1920×" + h + ": 페이지·표 세로 스크롤 없음", f.page <= 0 && f.table <= 0, f); + if (h === 880) await p.screenshot({ path: path.join(__dirname, ".out", "live_fit_880.png") }); + } + await p.setViewportSize({ width: 1600, height: 600 }); await p.waitForTimeout(100); - await p.evaluate(function () { document.querySelector(".erp-page").scrollTop = 200; }); - await p.waitForTimeout(100); - const scrolled = await p.evaluate(function () { - const pg = document.querySelector(".erp-page"); - return { moved: pg.scrollTop, top: document.getElementById("lv-side-cal").getBoundingClientRect().top - pg.getBoundingClientRect().top }; - }); - check("스크롤해도 달력이 위에 고정", scrolled.moved > 0 && Math.abs(scrolled.top - 16) < 2, scrolled); - await p.evaluate(function () { document.querySelector(".erp-page").scrollTop = 0; }); + const small = await fit(); + check("더 낮은 창: 페이지는 안 움직이고 표 안에서 스크롤", small.page <= 0 && small.table > 0, small); + const miniW = (await p.locator("#lv-side-cal").boundingBox()).width; + check("오른쪽 달력 = 240px(300px × 80%)", Math.round(miniW) === 240, miniW); + const miniDay = await day("2026-11-17").evaluate(function (el) { const c = getComputedStyle(el); return c.height + "|" + c.fontSize; }); + check("달력 칸·글자도 80%", miniDay === "27px|10.8px", miniDay); await p.setViewportSize({ width: 1600, height: 900 }); await p.waitForTimeout(100); check("디파발리 = 빨강·이름·말풍선", (await day("2026-11-08").getAttribute("class")).includes("has-hol") && (await day("2026-11-08").getAttribute("title")) === "디파발리"); diff --git a/tests/js/render_live.py b/tests/js/render_live.py index 1673686..f19248f 100644 --- a/tests/js/render_live.py +++ b/tests/js/render_live.py @@ -34,8 +34,11 @@ class Fake: def list_broadcasts(self, start, end): if start.month != 11: return [] - return [{"id": 1, "host_id": 1, "host_name": "Nabella", "tiktok_handle": "MainAccount", "broadcast_date": date(2026, 11, 5), "start_time": time(8), - "end_time": time(10), "venue": "", "sales_amount": Decimal("500"), "images": []}] + # 운영 화면처럼 — 6·8·16시 칸에 카드(세 줄 모두 카드가 있으면 그 줄이 가장 높다), 모든 시간 칸을 채워 높이 최악으로 + return [{"id": h, "host_id": 1, "host_name": "Nabella", "tiktok_handle": "MainAccount", "broadcast_date": date(2026, 11, 5), "start_time": time(h), + "end_time": time(h + 2), "venue": "", "sales_amount": Decimal("500"), "images": []} for h in range(6, 24, 2) if h < 22] + \ + [{"id": 22, "host_id": 1, "host_name": "Nabella", "tiktok_handle": "MainAccount", "broadcast_date": date(2026, 11, 5), "start_time": time(22), + "end_time": time(23, 30), "venue": "", "sales_amount": Decimal("500"), "images": []}] def ad_spends(self, start, end): return {}