- 판 = resources/master_template/calc_sites.json(기본값 = 등록부 자리 그대로 · 전부 both) - common_util_calc_sites — 묶음 8 줄(등록부 45 #) · 읽기 · 검사(잠금 · 모르는 줄 · 값 = 400) · 통째 쓰기 - GET /api/dashboard/calc-sites(로그인) · PUT /api/dashboard/admin/calc-sites(시스템 관리자) · 바뀐 줄마다 CALC_SITE_CHANGE 시스템 로그 - 대시보드 시스템 설정 「계산 자리」 카드(시스템 관리자만 · ☰ 엔 없음) · 체크 창(칸 둘 · 잠긴 줄 까닭 · 지금 서버 N 줄 · 다음 열기부터) - design_calc_sites — B05 · B06 열 때 한 번 받음 · G1 server = ground 단계 안에서만 서버 표본(cross 격자 그대로) · D3 server = 워커 안 띄움 - 시험 test_309_2_calc_sites 새 · test_b01_settings_cards · test_225_drawer_shortcuts 덧 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
60 lines
2.4 KiB
TypeScript
60 lines
2.4 KiB
TypeScript
/* =============================================================================
|
|
* design_calc_sites.ts
|
|
* 계산 자리 판(PLAN 504-2 · 요구 309-2) — B05 · B06 페이지 열 때 한 번 받아 페이지 수명 동안 씀.
|
|
* 판 = 서버 `resources/master_template/calc_sites.json`(`common_util_calc_sites.py`) · 쓰기 = 시스템 관리자
|
|
* 「계산 자리」 창(`B01_Dashboard_UI_CalcSites.ts`). 열린 페이지는 다음 열기부터 · 못 받으면 전부 both.
|
|
* ground_sample(G1) server = ground 단계가 격자 대신 서버 표본(`B05_Profile_Api_TerrainGrid.ts`)
|
|
* corridor_mesh(D3) server = 3D 미리보기 워커 안 띄움 · 서버 모형만(`B05_Profile_UI_Corridor_Worker_Client.ts`)
|
|
* ========================================================================== */
|
|
|
|
import { API_BASE_URL } from "@config/config_frontend";
|
|
|
|
export type CalcSiteValue = "both" | "server";
|
|
|
|
export interface CalcSiteGroup {
|
|
key: string;
|
|
nos: string[];
|
|
switchable: boolean;
|
|
fixed: "both" | "server" | "browser" | null;
|
|
why: string | null;
|
|
}
|
|
|
|
export interface CalcSitesBoard {
|
|
version: number;
|
|
sites: Record<string, CalcSiteValue>;
|
|
groups: CalcSiteGroup[];
|
|
}
|
|
|
|
async function request(init: RequestInit = {}): Promise<CalcSitesBoard> {
|
|
const path = init.method === "PUT" ? "/dashboard/admin/calc-sites" : "/dashboard/calc-sites";
|
|
const response = await fetch(`${API_BASE_URL}${path}`, {
|
|
credentials: "include",
|
|
headers: { "Content-Type": "application/json" },
|
|
...init,
|
|
});
|
|
const data = (await response.json()) as CalcSitesBoard & { detail?: string };
|
|
if (!response.ok) throw new Error(data.detail ?? `HTTP ${response.status}`);
|
|
return data;
|
|
}
|
|
|
|
export const fetchCalcSites = (): Promise<CalcSitesBoard> => request();
|
|
|
|
export const saveCalcSites = (sites: Record<string, CalcSiteValue>): Promise<CalcSitesBoard> =>
|
|
request({ method: "PUT", body: JSON.stringify({ sites }) });
|
|
|
|
let opened: Promise<Record<string, CalcSiteValue>> | null = null;
|
|
|
|
/** 페이지 열 때 — 새로 받음(앞 페이지 판 버림). */
|
|
export function openCalcSites(): Promise<Record<string, CalcSiteValue>> {
|
|
opened = fetchCalcSites().then(
|
|
(board) => board.sites,
|
|
() => ({}),
|
|
);
|
|
return opened;
|
|
}
|
|
|
|
/** 이 묶음을 조작 중에도 서버가 셈? — 받기 전이면 받기를 기다림. */
|
|
export async function calcOnServer(key: string): Promise<boolean> {
|
|
return (await (opened ?? openCalcSites()))[key] === "server";
|
|
}
|