Files
Aislo/B01_Dashboard/B01_Dashboard_UI_Views.ts
T
eomsangdonandClaude Opus 5.5 43d0ccb63f merge(B01): main_laptop_1(549-2 시스템 관리 · 내 정보) 합침 — 옛 구역 정리 · 시험 옮김
- B01_Dashboard_UI_Legacy.ts: 세부 페이지가 다 갈아 끼워 옛 구역 · mountLegacy 지움 · 고른 회사 자리 · 상태 타입만 남김
- B01_Dashboard_UI_Views.ts: 쓰는 곳 없는 legacy 도우미 지움
- B01_Dashboard_UI_Style_Pages.css: 배지 색(549-1) · 시스템 관리 꼴(549-2) 둘 다 살림
- test_b01_settings_cards · test_309_2: 지운 옛 카드 부품 대신 settingLinks · 설계 기본값 페이지 · 사람 페이지를 읽음(낡은 시험)

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-26 18:33:32 +09:00

91 lines
5.3 KiB
TypeScript

/* =============================================================================
* B01_Dashboard_UI_Views.ts
* 대시보드 세부 페이지 등록부(546) — 한 줄 = 한 페이지 · 주소 `#/b01-account?view=<열쇠>&…`.
* key = 주소 열쇠 · title = 메뉴 · 머리 글 · group = 메뉴 묶음(hidden = 메뉴에 안 보임 · 주소로만)
* roles = 보이는 역할(없는 역할은 메뉴에서 숨고 주소로 와도 홈) · icon = ui_template_icons 이름
* mount(host, ctx) = host 에 그림 · 정리 함수를 돌려주면 떠날 때 부름(비동기 가능)
* ctx = { me, role, companyId, go(view, params?) } — companyId = 시스템 관리자는 머리에서 고른 회사
* 새 페이지는 자기 줄만 갈아 끼움.
* ========================================================================== */
import type { IconName } from "@ui/ui_template_icons";
import type { DashboardUser } from "./B01_Dashboard_Api_Fetch";
import { mountHome } from "./B01_Dashboard_UI_Home";
import { mountChat, mountGuide } from "./B01_Dashboard_UI_Nav";
import { mountAssigned } from "./B01_Dashboard_UI_View_Assigned";
import { mountCompany } from "./B01_Dashboard_UI_View_Company";
import { mountCompanyDefaults } from "./B01_Dashboard_UI_View_CompanyDefaults";
import { mountPeople } from "./B01_Dashboard_UI_View_People";
import { mountTemp } from "./B01_Dashboard_UI_View_Temp";
import { mountProjectDetail } from "./B01_Dashboard_UI_ProjectDetail";
import { mountProjectList } from "./B01_Dashboard_UI_ProjectList";
import { mountMe } from "./B01_Dashboard_UI_View_Me";
import { mountSysCompanies } from "./B01_Dashboard_UI_View_SysCompanies";
import { mountSysDefaults } from "./B01_Dashboard_UI_View_SysDefaults";
import { mountSysLogs } from "./B01_Dashboard_UI_View_SysLogs";
import { mountSysOverview } from "./B01_Dashboard_UI_View_SysOverview";
import { mountSysUsers } from "./B01_Dashboard_UI_View_SysUsers";
/** 역할 넷 — 산림청 = 세션 is_forest_service 인 일반 사용자(회사 관리자 · 시스템 관리자가 앞섬) */
export type ViewRole = "USER" | "ADMIN" | "FOREST" | "SYSTEM_ADMIN";
export type ViewGroup = "work" | "company" | "system" | "help" | "hidden";
export interface ViewCtx {
me: DashboardUser;
role: ViewRole;
companyId: number | null;
go: (view: string, params?: Record<string, string>) => void;
}
type Cleanup = (() => void) | void;
export interface View {
key: string;
title: string;
group: ViewGroup;
roles: readonly ViewRole[];
icon?: IconName;
mount: (host: HTMLElement, ctx: ViewCtx) => Cleanup | Promise<Cleanup>;
}
export const DEFAULT_VIEW = "home";
const ALL: readonly ViewRole[] = ["USER", "ADMIN", "FOREST", "SYSTEM_ADMIN"];
// prettier-ignore
export const VIEWS: View[] = [
// 작업
{ key: "home", title: "홈", group: "work", roles: ALL, icon: "home", mount: mountHome },
{ key: "projects", title: "프로젝트", group: "work", roles: ALL, icon: "folder", mount: mountProjectList },
{ key: "project", title: "프로젝트 상세", group: "hidden", roles: ALL, mount: mountProjectDetail },
{ key: "assigned", title: "받은 예정노선", group: "work", roles: ["USER", "ADMIN", "SYSTEM_ADMIN"], icon: "route", mount: mountAssigned },
{ key: "temp", title: "임시 보관함", group: "work", roles: ALL, icon: "archive", mount: mountTemp },
// 회사 관리
{ key: "people", title: "사람", group: "company", roles: ["ADMIN", "SYSTEM_ADMIN"], icon: "users", mount: mountPeople },
{ key: "company", title: "회사 정보", group: "company", roles: ALL, icon: "building", mount: mountCompany },
{ key: "company-defaults", title: "회사 설계 기본값", group: "company", roles: ["USER", "ADMIN", "FOREST"], icon: "adjustments", mount: mountCompanyDefaults },
// 시스템 관리
{ key: "sys-overview", title: "개요", group: "system", roles: ["SYSTEM_ADMIN"], icon: "gauge", mount: mountSysOverview },
{ key: "sys-companies", title: "회사", group: "system", roles: ["SYSTEM_ADMIN"], icon: "building", mount: mountSysCompanies },
{ key: "sys-users", title: "사용자", group: "system", roles: ["SYSTEM_ADMIN"], icon: "user", mount: mountSysUsers },
{ key: "sys-defaults", title: "설계 기본값", group: "system", roles: ["SYSTEM_ADMIN"], icon: "database", mount: mountSysDefaults },
{ key: "sys-logs", title: "시스템 로그", group: "system", roles: ["SYSTEM_ADMIN"], icon: "fileText", mount: mountSysLogs },
// 도움
{ key: "guide", title: "사용자 가이드", group: "help", roles: ALL, icon: "book", mount: mountGuide },
{ key: "chat", title: "지식 챗봇", group: "help", roles: ALL, icon: "chatbot", mount: mountChat },
// 사용자 메뉴
{ key: "me", title: "내 정보", group: "hidden", roles: ALL, icon: "userCircle", mount: mountMe },
];
/** 역할 가르기 — 옛 B01 갈래(시스템 관리자 · 회사 관리자 · 그 밖) + 산림청 */
export function roleOf(me: DashboardUser, forest: boolean): ViewRole {
if (me.role === "SYSTEM_ADMIN" || me.role === "ADMIN") return me.role;
return forest ? "FOREST" : "USER";
}
/** 주소 열쇠 → 페이지 · 없거나 권한 없으면 홈 */
export function viewFor(key: string | null, role: ViewRole): View {
const found = VIEWS.find((v) => v.key === key && v.roles.includes(role));
return found ?? VIEWS.find((v) => v.key === DEFAULT_VIEW)!;
}