- 대시보드 세부 페이지 `#/b01-account?view=ui-kit` 등록부 한 줄(시스템 관리 묶음 · SYSTEM_ADMIN 만) - ui_template_ui_kit.ts — 테마 칸마다 iframe(data-theme)에 지금 CSS 를 옮겨 실제 값으로 그림 - ui_template_ui_kit_parts.ts — 표준 부품 30 줄(552-2 기본 · 552-3 묶음 · 552-4 틀) · 머리 = 부품 규칙(자리 · 이름 · data-size · data-state · 색 · 아이콘) - 지금 PageKit · 공용 부품 견본(단추 · 입력 · 고르기 · 탭 · 배지 · 표 · ⋯ · 빈 상태 · 설정 줄 · 아이콘) · 나머지 빈 자리 - test_546 시스템 메뉴 기대값에 ui-kit 더함 · 새 지킴 시험 test_552_1_ui_kit Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
93 lines
5.4 KiB
TypeScript
93 lines
5.4 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";
|
|
import { mountUiKit } from "@ui/ui_template_ui_kit";
|
|
|
|
/** 역할 넷 — 산림청 = 세션 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: "ui-kit", title: "부품 모음", group: "system", roles: ["SYSTEM_ADMIN"], icon: "adjustments", mount: mountUiKit },
|
|
// 도움
|
|
{ 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)!;
|
|
}
|