refactor(web-ui): Apply modular structure and refactor dashboard
This commit applies the modular refactoring to the web-ui,
including the new daily attendance tracking feature.
- **Modular Structure:** Re-introduced the modular files 'config.js',
'component-loader.js', and 'navigation.js' to centralize configuration,
component loading, and navigation logic.
- **Refactored Dashboard:** Refactored 'group-leader-dashboard.js' to use
the new 'apiCall' function from 'api-config.js' for API requests,
removing duplicated code and improving error handling.
- **ES6 Modules:** Updated 'group-leader.html' to load scripts as
ES6 modules ('type="module"'), ensuring compatibility with the
modular JavaScript files.
- **Clean-up:** Removed unnecessary global variables and duplicated
functions, improving code quality and maintainability.
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
// /js/group-leader-dashboard.js
|
||||
// 그룹장 전용 대시보드 - 실시간 근태 및 작업 현황 (Real Data Version)
|
||||
import { apiCall } from './api-config.js';
|
||||
|
||||
console.log('📊 그룹장 대시보드 스크립트 로딩 (Live Data)');
|
||||
|
||||
@@ -54,13 +55,7 @@ async function loadDailyWorkStatus() {
|
||||
`;
|
||||
|
||||
try {
|
||||
const response = await fetch(`${window.API_BASE_URL}/attendance/daily-status?date=${currentSelectedDate}`, {
|
||||
headers: getAuthHeaders()
|
||||
});
|
||||
|
||||
if (!response.ok) throw new Error('데이터 로드 실패');
|
||||
|
||||
const result = await response.json();
|
||||
const result = await apiCall(`/attendance/daily-status?date=${currentSelectedDate}`);
|
||||
const workers = result.data || [];
|
||||
|
||||
renderWorkStatus(workers);
|
||||
@@ -143,15 +138,6 @@ function renderWorkStatus(workers) {
|
||||
container.innerHTML = html;
|
||||
}
|
||||
|
||||
// 🔐 인증 헤더 헬퍼
|
||||
function getAuthHeaders() {
|
||||
const token = localStorage.getItem('token');
|
||||
return {
|
||||
'Authorization': `Bearer ${token}`,
|
||||
'Content-Type': 'application/json'
|
||||
};
|
||||
}
|
||||
|
||||
// 🍞 토스트 메시지 (기존 modern-dashboard.js에 있다면 중복 주의, 없으면 사용)
|
||||
function showToast(message, type = 'info') {
|
||||
if (window.showToast) {
|
||||
@@ -163,12 +149,9 @@ function showToast(message, type = 'info') {
|
||||
|
||||
// 초기화
|
||||
document.addEventListener('DOMContentLoaded', () => {
|
||||
// API_BASE_URL 설정 (없으면 기본값)
|
||||
if (!window.API_BASE_URL) window.API_BASE_URL = '/api';
|
||||
|
||||
initDateSelector();
|
||||
loadDailyWorkStatus();
|
||||
});
|
||||
|
||||
// 전역 노출
|
||||
window.refreshTeamStatus = loadDailyWorkStatus;
|
||||
// 전역 노출 대신 모듈로 내보내기
|
||||
export { loadDailyWorkStatus as refreshTeamStatus };
|
||||
Reference in New Issue
Block a user