프로젝트/사용자 관리 컨테이너와 같은 형태로 통일한다. 등록 폼을 화면에 상시
노출하지 않고, 우측 상단 [+] 모달로 받아 그룹(임시 프로젝트명) 아래 파일 표를
그린다.
프론트엔드
- B01_Dashboard_UI_TempModal.ts 신설: 등록/추가 모달(임시 프로젝트명 + 파일 선택,
고른 파일을 모달 안 표로 표시, 하단 [취소][확인] — 기존 대시보드 모달과 동일 규격)
- B01_Dashboard_UI_TempUpload.ts: 섹션 전체(제목·[+]·목록)를 반환하도록 변경.
그룹 카드 + 파일 표(종류/파일명/크기/상태/작업), 그룹별 [파일 추가],
파일별 [삭제], 진행률은 해당 파일 행 안에서 표시
- 청크마다 목록을 다시 조회하지 않고 막대 DOM만 갱신하도록 정리
- 대시보드 배치: 프로젝트 컨테이너 바로 아래(역할 3분기 모두)
백엔드
- DELETE /api/temp-uploads/{batch_id}/files/{file_type}: DB 행과 임시 저장소
실제 파일을 함께 삭제. 필수 파일이 빠지면 상태를 uploading으로 되돌리고
만료일은 최초 완료 시점 기준을 유지
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
204 lines
7.2 KiB
TypeScript
204 lines
7.2 KiB
TypeScript
import { ROUTES } from "@config/config_frontend";
|
|
import {
|
|
createButton,
|
|
createTag,
|
|
hideLoadingOverlay,
|
|
showLoadingOverlay,
|
|
showToast,
|
|
} from "@ui/ui_template_elements";
|
|
import { section } from "@ui/ui_template_general_blocks";
|
|
import { navigateTo } from "../A00_Common/router";
|
|
import {
|
|
fetchAllCompanies,
|
|
fetchAllJoinRequests,
|
|
fetchAllProjects,
|
|
fetchAllUsers,
|
|
fetchAuditLogs,
|
|
fetchCompanyJoinRequests,
|
|
fetchCompanyMembers,
|
|
fetchCompanyProjects,
|
|
fetchDashboardMe,
|
|
fetchSystemResources,
|
|
fetchUserCompany,
|
|
fetchUserProjects,
|
|
type AuditLog,
|
|
type CompanyInfo,
|
|
type DashboardUser,
|
|
type JoinRequest,
|
|
type Member,
|
|
type ProjectItem,
|
|
type ResourceData,
|
|
} from "./B01_Dashboard_Api_Fetch";
|
|
import { auditLogTable, userTable } from "./B01_Dashboard_UI_Admin";
|
|
import { L, roleLabel } from "./B01_Dashboard_UI_Common";
|
|
import {
|
|
buildCompanyPanel,
|
|
companyTable,
|
|
joinRequestTable,
|
|
memberTable,
|
|
} from "./B01_Dashboard_UI_Company";
|
|
import { openAddMemberModal, openCreateCompanyModal } from "./B01_Dashboard_UI_Modals";
|
|
import { buildProfileForm, buildSecurityForm } from "./B01_Dashboard_UI_Profile";
|
|
import { projectTable } from "./B01_Dashboard_UI_Projects";
|
|
import { buildResourcePanel } from "./B01_Dashboard_UI_Resources";
|
|
import { buildTempUploadSection } from "./B01_Dashboard_UI_TempUpload";
|
|
import "./B01_Dashboard_UI_Style.css";
|
|
|
|
export interface DashboardState {
|
|
user: DashboardUser;
|
|
userProjects: ProjectItem[];
|
|
companyProjects: ProjectItem[];
|
|
allProjects: ProjectItem[];
|
|
company: CompanyInfo | null;
|
|
members: Member[];
|
|
joinRequests: JoinRequest[];
|
|
allCompanies: CompanyInfo[];
|
|
allUsers: DashboardUser[];
|
|
allJoinRequests: JoinRequest[];
|
|
auditLogs: AuditLog[];
|
|
resources: ResourceData | null;
|
|
}
|
|
|
|
export async function renderB01Dashboard(root: HTMLElement): Promise<void> {
|
|
showLoadingOverlay();
|
|
try {
|
|
const user = await fetchDashboardMe();
|
|
const state: DashboardState = {
|
|
user,
|
|
userProjects: [],
|
|
companyProjects: [],
|
|
allProjects: [],
|
|
company: null,
|
|
members: [],
|
|
joinRequests: [],
|
|
allCompanies: [],
|
|
allUsers: [],
|
|
allJoinRequests: [],
|
|
auditLogs: [],
|
|
resources: null,
|
|
};
|
|
await loadRoleData(state);
|
|
root.innerHTML = "";
|
|
root.append(buildPage(state));
|
|
} catch (error) {
|
|
showToast(error instanceof Error ? error.message : L("B01_Dashboard_LoadFailed"), "error");
|
|
} finally {
|
|
hideLoadingOverlay();
|
|
}
|
|
}
|
|
|
|
async function loadRoleData(state: DashboardState): Promise<void> {
|
|
if (state.user.role === "SYSTEM_ADMIN") {
|
|
const results = await Promise.allSettled([
|
|
fetchAllCompanies(),
|
|
fetchAllUsers(),
|
|
fetchAllJoinRequests(),
|
|
fetchAuditLogs(),
|
|
fetchSystemResources(7),
|
|
fetchAllProjects(),
|
|
]);
|
|
state.allCompanies = results[0].status === "fulfilled" ? results[0].value : [];
|
|
state.allUsers = results[1].status === "fulfilled" ? results[1].value : [];
|
|
state.allJoinRequests = results[2].status === "fulfilled" ? results[2].value : [];
|
|
state.auditLogs = results[3].status === "fulfilled" ? results[3].value : [];
|
|
state.resources = results[4].status === "fulfilled" ? results[4].value : null;
|
|
state.allProjects = results[5].status === "fulfilled" ? results[5].value : [];
|
|
|
|
results.forEach((res, idx) => {
|
|
if (res.status === "rejected") {
|
|
console.error(`System Admin API failed at index ${idx}:`, res.reason);
|
|
}
|
|
});
|
|
return;
|
|
}
|
|
const [projects, company] = await Promise.all([
|
|
fetchUserProjects().catch(() => []),
|
|
fetchUserCompany().catch(() => null),
|
|
]);
|
|
state.userProjects = projects;
|
|
state.company = company;
|
|
if (state.user.role === "ADMIN") {
|
|
const [members, requests, companyProjects] = await Promise.all([
|
|
fetchCompanyMembers().catch(() => []),
|
|
fetchCompanyJoinRequests().catch(() => []),
|
|
fetchCompanyProjects().catch(() => []),
|
|
]);
|
|
state.members = members;
|
|
state.joinRequests = requests;
|
|
state.companyProjects = companyProjects;
|
|
}
|
|
}
|
|
|
|
function buildPage(state: DashboardState): HTMLElement {
|
|
const page = document.createElement("div");
|
|
page.className = "b01-dashboard";
|
|
page.append(buildHeader(state.user));
|
|
|
|
const grid = document.createElement("div");
|
|
grid.className = "b01-dashboard__grid";
|
|
|
|
if (state.user.role === "SYSTEM_ADMIN") {
|
|
grid.append(
|
|
section(L("B01_Dashboard_Resources"), buildResourcePanel(state.resources), true),
|
|
section(L("B01_Dashboard_Projects"), projectTable(state.allProjects, state.user), true, [
|
|
createButton({ label: "+", onClick: () => navigateTo(ROUTES.B02_PROJ_REGISTER) }),
|
|
]),
|
|
buildTempUploadSection(),
|
|
section(L("B01_Dashboard_Users"), userTable(state.allUsers, state.user), true, [
|
|
createButton({ label: "+", onClick: () => openAddMemberModal() }),
|
|
]),
|
|
section(L("B01_Dashboard_JoinRequests"), joinRequestTable(state.allJoinRequests, true), true),
|
|
section(L("B01_Dashboard_Companies"), companyTable(state.allCompanies), true, [
|
|
createButton({ label: "+", onClick: () => openCreateCompanyModal() }),
|
|
]),
|
|
section(L("B01_Dashboard_AuditLogs"), auditLogTable(state.auditLogs), true),
|
|
);
|
|
} else if (state.user.role === "ADMIN") {
|
|
grid.append(
|
|
section(L("B01_Dashboard_Projects"), projectTable(state.companyProjects, state.user), true, [
|
|
createButton({ label: "+", onClick: () => navigateTo(ROUTES.B02_PROJ_REGISTER) }),
|
|
]),
|
|
buildTempUploadSection(),
|
|
section(L("B01_Dashboard_Members"), memberTable(state.members, state.user), true, [
|
|
createButton({ label: "+", onClick: () => openAddMemberModal() }),
|
|
]),
|
|
section(L("B01_Dashboard_JoinRequests"), joinRequestTable(state.joinRequests, false), true),
|
|
section(L("B01_Dashboard_Company"), buildCompanyPanel(state), true),
|
|
);
|
|
} else {
|
|
grid.append(
|
|
section(L("B01_Dashboard_Projects"), projectTable(state.userProjects, state.user), true, [
|
|
createButton({ label: "+", onClick: () => navigateTo(ROUTES.B02_PROJ_REGISTER) }),
|
|
]),
|
|
// 임시 보관함 — 프로젝트를 만들기 전에 자료를 올려 두는 곳이라 프로젝트 목록
|
|
// 바로 아래에 둔다(2026-08-08 사용자 지시).
|
|
buildTempUploadSection(),
|
|
section(L("B01_Dashboard_Company"), buildCompanyPanel(state), true),
|
|
);
|
|
}
|
|
|
|
grid.append(
|
|
section(L("B01_Dashboard_Profile"), buildProfileForm(state.user)),
|
|
section(L("B01_Account_Section_Security"), buildSecurityForm()),
|
|
);
|
|
page.append(grid);
|
|
return page;
|
|
}
|
|
|
|
function buildHeader(user: DashboardUser): HTMLElement {
|
|
const header = document.createElement("header");
|
|
header.className = "b01-dashboard__header";
|
|
const text = document.createElement("div");
|
|
const title = document.createElement("h1");
|
|
title.className = "b01-dashboard__title";
|
|
title.textContent = L("B01_Dashboard_Title");
|
|
const subtitle = document.createElement("p");
|
|
subtitle.className = "b01-dashboard__subtitle";
|
|
subtitle.textContent = L("B01_Dashboard_Subtitle");
|
|
text.append(title, subtitle);
|
|
const tag = createTag(roleLabel(user.role), user.role === "SYSTEM_ADMIN" ? "accent" : "neutral");
|
|
tag.classList.add("b01-dashboard__role");
|
|
header.append(text, tag);
|
|
return header;
|
|
}
|