Files
tk-factory-services/system1-factory/web/public/js/work-management.js
Hyungi Ahn ba9ef32808 security: 보안 강제 시스템 구축 + 하드코딩 비밀번호 제거
보안 감사 결과 CRITICAL 2건, HIGH 5건 발견 → 수정 완료 + 자동화 구축.

[보안 수정]
- issue-view.js: 하드코딩 비밀번호 → crypto.getRandomValues() 랜덤 생성
- pushSubscriptionController.js: ntfy 비밀번호 → process.env.NTFY_SUB_PASSWORD
- DEPLOY-GUIDE.md/PROGRESS.md/migration SQL: 평문 비밀번호 → placeholder
- docker-compose.yml/.env.example: NTFY_SUB_PASSWORD 환경변수 추가

[보안 강제 시스템 - 신규]
- scripts/security-scan.sh: 8개 규칙 (CRITICAL 2, HIGH 4, MEDIUM 2)
  3모드(staged/all/diff), severity, .securityignore, MEDIUM 임계값
- .githooks/pre-commit: 로컬 빠른 피드백
- .githooks/pre-receive-server.sh: Gitea 서버 최종 차단
  bypass 거버넌스([SECURITY-BYPASS: 사유] + 사용자 제한 + 로그)
- SECURITY-CHECKLIST.md: 10개 카테고리 자동/수동 구분
- docs/SECURITY-GUIDE.md: 운영자 가이드 (워크플로우, bypass, FAQ)

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-10 09:44:21 +09:00

173 lines
4.7 KiB
JavaScript

// 작업 관리 페이지 JavaScript
// 전역 변수
let statsData = {
projects: 0,
workers: 0,
tasks: 0,
codeTypes: 0
};
// 페이지 초기화
document.addEventListener('DOMContentLoaded', function() {
initializePage();
loadStatistics();
});
// 페이지 초기화
function initializePage() {
// 시간 업데이트 시작
updateCurrentTime();
setInterval(updateCurrentTime, 1000);
// 사용자 정보 업데이트
updateUserInfo();
// 프로필 메뉴 토글
setupProfileMenu();
// 로그아웃 버튼
setupLogoutButton();
}
// 현재 시간 업데이트 (시 분 초 형식으로 고정)
function updateCurrentTime() {
const now = new Date();
const hours = String(now.getHours()).padStart(2, '0');
const minutes = String(now.getMinutes()).padStart(2, '0');
const seconds = String(now.getSeconds()).padStart(2, '0');
const timeString = `${hours}${minutes}${seconds}`;
const timeElement = document.getElementById('timeValue');
if (timeElement) {
timeElement.textContent = timeString;
}
}
// navbar/sidebar는 app-init.js에서 공통 처리
function updateUserInfo() {
// app-init.js가 navbar 사용자 정보를 처리
}
// 프로필 메뉴 설정
function setupProfileMenu() {
const userProfile = document.getElementById('userProfile');
const profileMenu = document.getElementById('profileMenu');
if (userProfile && profileMenu) {
userProfile.addEventListener('click', function(e) {
e.stopPropagation();
const isVisible = profileMenu.style.display === 'block';
profileMenu.style.display = isVisible ? 'none' : 'block';
});
// 외부 클릭 시 메뉴 닫기
document.addEventListener('click', function() {
profileMenu.style.display = 'none';
});
}
}
// 로그아웃 버튼 설정
function setupLogoutButton() {
const logoutBtn = document.getElementById('logoutBtn');
if (logoutBtn) {
logoutBtn.addEventListener('click', function() {
if (confirm('로그아웃 하시겠습니까?')) {
if (window.clearSSOAuth) window.clearSSOAuth();
window.location.href = window.getLoginUrl ? window.getLoginUrl() : '/login';
}
});
}
}
// 통계 데이터 로드
async function loadStatistics() {
try {
// 프로젝트 수 조회
try {
const projectsResponse = await apiCall('/projects', 'GET');
if (projectsResponse && Array.isArray(projectsResponse)) {
statsData.projects = projectsResponse.length;
updateStatDisplay('projectCount', statsData.projects);
}
} catch (error) {
console.warn('프로젝트 통계 로드 실패:', error);
updateStatDisplay('projectCount', '오류');
}
// 작업자 수 조회
try {
const workersResponse = await apiCall('/workers', 'GET');
if (workersResponse && Array.isArray(workersResponse)) {
const activeWorkers = workersResponse.filter(w => w.status === 'active');
statsData.workers = activeWorkers.length;
updateStatDisplay('workerCount', statsData.workers);
}
} catch (error) {
console.warn('작업자 통계 로드 실패:', error);
updateStatDisplay('workerCount', '오류');
}
// 작업 유형 수 조회
try {
const tasksResponse = await apiCall('/tasks', 'GET');
if (tasksResponse && Array.isArray(tasksResponse)) {
const activeTasks = tasksResponse.filter(t => t.is_active);
statsData.tasks = activeTasks.length;
updateStatDisplay('taskCount', statsData.tasks);
}
} catch (error) {
console.warn('작업 유형 통계 로드 실패:', error);
updateStatDisplay('taskCount', '오류');
}
// 코드 타입 수 조회 (임시로 고정값)
statsData.codeTypes = 3; // ISSUE_TYPE, ERROR_TYPE, WORK_STATUS
updateStatDisplay('codeTypeCount', statsData.codeTypes);
} catch (error) {
console.error('통계 데이터 로딩 오류:', error);
}
}
// 통계 표시 업데이트
function updateStatDisplay(elementId, value) {
const element = document.getElementById(elementId);
if (element) {
element.textContent = value;
// 애니메이션 효과
element.style.transform = 'scale(1.1)';
setTimeout(() => {
element.style.transform = 'scale(1)';
}, 200);
}
}
// 최근 활동 관련 함수들 제거됨
// 페이지 네비게이션
function navigateToPage(url) {
// 로딩 효과
const card = event.currentTarget;
const originalContent = card.innerHTML;
card.style.opacity = '0.7';
card.style.pointerEvents = 'none';
// 잠시 후 페이지 이동
setTimeout(() => {
window.location.href = url;
}, 300);
}
// showToast → api-base.js 전역 사용
// 전역 함수로 노출
window.navigateToPage = navigateToPage;