feat: MachineBridge 추가 및 fetch API를 HostObject 호출로 전환

- WebView2 HostObject 기반 MachineBridge 브릿지 클래스 추가
  - MachineBridge.cs (메인), Login, Dashboard, Todo, Common, Jobreport, Kuntae, Project 모듈
- WebSocketServer.cs 추가 (실시간 통신용)
- fDashboardNew 다이얼로그 추가
- Jobreport/index.html, Project/index.html의 fetch API를 machine HostObject 호출로 전환
- DashBoardController.cs의 gcode null 처리 추가
- 사용하지 않는 파일 삭제 (navigation.html, common-nav.js, navigation.js, _add_to_project.py, _project_updater.js)

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
backuppc
2025-11-25 16:06:35 +09:00
parent f0d46b7cb1
commit 44af041d1a
24 changed files with 2622 additions and 1454 deletions

View File

@@ -473,6 +473,9 @@
</div>
</div>
<!-- 공통 네비게이션 -->
<script src="/js/common-navigation.js"></script>
<script>
let projects = [];
let currentProjectIdx = null;
@@ -483,109 +486,14 @@
let itemsPerPage = 10;
let filteredProjects = [];
// machine HostObject 참조
const machine = window.chrome.webview.hostObjects.machine;
// 초기화
document.addEventListener('DOMContentLoaded', function() {
initializeApp();
});
// 네비게이션 클래스
class CommonNavigation {
constructor(currentPage = '') {
this.currentPage = currentPage;
this.createNavigation();
}
async createNavigation() {
try {
const response = await fetch('/Common/GetNavigationMenu');
const data = await response.json();
if (data.Success && data.Data) {
this.createNavigationFromData(data.Data);
} else {
this.createFallbackNavigation();
}
} catch (error) {
console.error('Navigation initialization failed:', error);
this.createFallbackNavigation();
}
}
createNavigationFromData(menuItems) {
const nav = document.createElement('nav');
nav.className = 'glass-effect border-b border-white/10';
nav.innerHTML = this.getNavigationHTML(menuItems);
document.body.insertBefore(nav, document.body.firstChild);
}
createFallbackNavigation() {
this.createNavigation();
}
createNavigation() {
const nav = document.createElement('nav');
nav.className = 'glass-effect border-b border-white/10';
nav.innerHTML = this.getNavigationHTML();
document.body.insertBefore(nav, document.body.firstChild);
}
getNavigationHTML(menuItems = null) {
if (!menuItems) {
menuItems = [
{ key: 'dashboard', title: '대시보드', url: '/Dashboard/', icon: 'M3 7v10a2 2 0 002 2h14a2 2 0 002-2V9a2 2 0 00-2-2H5a2 2 0 00-2-2z M8 5a2 2 0 012-2h4a2 2 0 012 2v2H8V5z' },
{ key: 'common', title: '공용코드', url: '/Common', icon: 'M9 12h6m-6 4h6m2 5H7a2 2 0 01-2-2V5a2 2 0 012-2h5.586a1 1 0 01.707.293l5.414 5.414a1 1 0 01.293.707V19a2 2 0 01-2 2z' },
{ key: 'jobreport', title: '업무일지', url: '/Jobreport/', icon: 'M9 5H7a2 2 0 00-2 2v10a2 2 0 002 2h8a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2' },
{ key: 'kuntae', title: '근태관리', url: '/Kuntae/', icon: 'M12 8v4l3 3m6-3a9 9 0 11-18 0 9 9 0 0118 0z' },
{ key: 'todo', title: '할일관리', url: '/Todo/', icon: 'M9 5H7a2 2 0 00-2 2v10a2 2 0 002 2h8a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2M12 12l2 2 4-4' },
{ key: 'project', title: '프로젝트', url: '/Project/', icon: 'M19 11H5m14 0a2 2 0 012 2v6a2 2 0 01-2 2H5a2 2 0 01-2-2v-6a2 2 0 012-2m14 0V9a2 2 0 00-2-2M5 11V9a2 2 0 012-2m0 0V5a2 2 0 012-2h6a2 2 0 012 2v2M7 7h10' }
];
}
return `
<div class="container mx-auto px-4">
<div class="flex items-center justify-between h-16">
<div class="flex items-center space-x-8">
<a href="/Dashboard/" class="flex items-center space-x-2 hover:opacity-80 transition-opacity cursor-pointer">
<svg class="w-8 h-8 text-white" fill="none" stroke="currentColor" viewBox="0 0 24 24">
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M19 11H5m14 0a2 2 0 012 2v6a2 2 0 01-2 2H5a2 2 0 01-2-2v-6a2 2 0 012-2m14 0V9a2 2 0 00-2-2M5 11V9a2 2 0 012-2m0 0V5a2 2 0 012-2h6a2 2 0 012 2v2M7 7h10"></path>
</svg>
<span class="text-xl font-bold text-white">GroupWare</span>
</a>
<nav class="hidden md:flex space-x-1">
${menuItems.map(item => `
<a href="${item.url}" class="px-3 py-2 rounded-md text-sm font-medium transition-colors ${
this.currentPage === item.key
? 'bg-white/20 text-white'
: 'text-white/60 hover:text-white hover:bg-white/10'
}">
<svg class="w-4 h-4 inline mr-1" fill="none" stroke="currentColor" viewBox="0 0 24 24">
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="${item.icon}"></path>
</svg>
${item.title}
</a>
`).join('')}
</nav>
</div>
<div class="flex items-center space-x-4">
<div class="text-sm text-white/60">
<span id="currentUser">사용자</span>
</div>
</div>
</div>
</div>
`;
}
}
function initNavigation(currentPage = '') {
try {
new CommonNavigation(currentPage);
} catch (error) {
console.error('Navigation initialization failed:', error);
new CommonNavigation(currentPage);
}
}
function initializeApp() {
initNavigation('project');
getCurrentUser();
@@ -593,24 +501,24 @@
setupEventListeners();
}
function getCurrentUser() {
async function getCurrentUser() {
// 현재 로그인된 사용자 정보 가져오기
fetch('/Common/GetCurrentUser')
.then(response => response.json())
.then(data => {
if (data.Success && data.Data) {
currentUser = data.Data.userName || data.Data.name || '사용자';
document.getElementById('currentUser').textContent = currentUser;
} else {
currentUser = '사용자';
document.getElementById('currentUser').textContent = currentUser;
}
})
.catch(error => {
console.error('Error getting current user:', error);
try {
const jsonStr = await machine.GetCurrentUser();
const data = JSON.parse(jsonStr);
if (data.Success && data.Data) {
currentUser = data.Data.userName || data.Data.name || '사용자';
document.getElementById('currentUser').textContent = currentUser;
} else {
currentUser = '사용자';
document.getElementById('currentUser').textContent = currentUser;
});
}
} catch (error) {
console.error('Error getting current user:', error);
currentUser = '사용자';
document.getElementById('currentUser').textContent = currentUser;
}
}
function setupEventListeners() {
@@ -648,31 +556,31 @@
});
}
function loadProjects() {
async function loadProjects() {
const status = document.getElementById('statusFilter').value;
const userFilter = document.getElementById('managerFilter').value;
fetch(`/Project/GetProjects?status=${status}&userFilter=${userFilter}`)
.then(response => response.json())
.then(data => {
if (!data.Success) {
console.error('Error:', data.Message);
document.getElementById('projectTableBody').innerHTML = '<tr><td colspan="23" class="px-6 py-4 text-center text-red-400">데이터를 불러오는데 실패했습니다.</td></tr>';
return;
}
projects = data.Data || [];
if (data.CurrentUser) {
currentUser = data.CurrentUser;
document.getElementById('currentUser').textContent = currentUser;
}
currentPage = 1;
filterData();
updateStatusCounts();
})
.catch(error => {
console.error('Error:', error);
try {
const jsonStr = await machine.Project_GetProjects(status, userFilter);
const data = JSON.parse(jsonStr);
if (!data.Success) {
console.error('Error:', data.Message);
document.getElementById('projectTableBody').innerHTML = '<tr><td colspan="23" class="px-6 py-4 text-center text-red-400">데이터를 불러오는데 실패했습니다.</td></tr>';
});
return;
}
projects = data.Data || [];
if (data.CurrentUser) {
currentUser = data.CurrentUser;
document.getElementById('currentUser').textContent = currentUser;
}
currentPage = 1;
filterData();
updateStatusCounts();
} catch (error) {
console.error('Error:', error);
document.getElementById('projectTableBody').innerHTML = '<tr><td colspan="23" class="px-6 py-4 text-center text-red-400">데이터를 불러오는데 실패했습니다.</td></tr>';
}
}
function updateStatusCounts() {
@@ -830,37 +738,37 @@
document.getElementById('projectModal').classList.remove('hidden');
}
function editProject(idx) {
async function editProject(idx) {
currentProjectIdx = idx;
fetch(`/Project/GetProject?id=${idx}`)
.then(response => response.json())
.then(data => {
if (!data.Success) {
alert('프로젝트 정보를 불러오는데 실패했습니다: ' + data.Message);
return;
}
const project = data.Data;
document.getElementById('modalTitle').textContent = '프로젝트 편집';
document.getElementById('projectIdx').value = project.idx;
document.getElementById('projectName').value = project.프로젝트명 || '';
document.getElementById('projectProcess').value = project.프로젝트공정 || '';
document.getElementById('projectSdate').value = project.시작일 || '';
document.getElementById('projectEdate').value = project.완료 || '';
document.getElementById('projectDdate').value = project.료일 || '';
document.getElementById('projectOdate').value = project.출고 || '';
document.getElementById('projectUserManager').value = project.프로젝트관리자 || '';
document.getElementById('projectStatus').value = project.상태 || '진행';
document.getElementById('projectMemo').value = project.memo || '';
document.getElementById('deleteProjectBtn').classList.remove('hidden');
document.getElementById('projectModal').classList.remove('hidden');
})
.catch(error => {
console.error('Error:', error);
alert('프로젝트 정보를 불러오는데 실패했습니다.');
});
try {
const jsonStr = await machine.Project_GetProject(idx);
const data = JSON.parse(jsonStr);
if (!data.Success) {
alert('프로젝트 정보를 불러오는데 실패했습니다: ' + data.Message);
return;
}
const project = data.Data;
document.getElementById('modalTitle').textContent = '프로젝트 편집';
document.getElementById('projectIdx').value = project.idx;
document.getElementById('projectName').value = project.프로젝트 || '';
document.getElementById('projectProcess').value = project.프로젝트공정 || '';
document.getElementById('projectSdate').value = project.시작 || '';
document.getElementById('projectEdate').value = project.료일 || '';
document.getElementById('projectDdate').value = project.만료 || '';
document.getElementById('projectOdate').value = project.출고일 || '';
document.getElementById('projectUserManager').value = project.프로젝트관리자 || '';
document.getElementById('projectStatus').value = project.상태 || '진행';
document.getElementById('projectMemo').value = project.memo || '';
document.getElementById('deleteProjectBtn').classList.remove('hidden');
document.getElementById('projectModal').classList.remove('hidden');
} catch (error) {
console.error('Error:', error);
alert('프로젝트 정보를 불러오는데 실패했습니다.');
}
}
function closeProjectModal() {
@@ -868,9 +776,9 @@
document.getElementById('deleteModal').classList.add('hidden');
}
function handleFormSubmit(e) {
async function handleFormSubmit(e) {
e.preventDefault();
const projectData = {
idx: currentProjectIdx ? parseInt(document.getElementById('projectIdx').value) : 0,
name: document.getElementById('projectName').value,
@@ -883,19 +791,16 @@
status: document.getElementById('projectStatus').value,
memo: document.getElementById('projectMemo').value
};
const url = currentProjectIdx ? '/Project/UpdateProject' : '/Project/CreateProject';
const method = currentProjectIdx ? 'PUT' : 'POST';
fetch(url, {
method: method,
headers: {
'Content-Type': 'application/json',
},
body: JSON.stringify(projectData)
})
.then(response => response.json())
.then(data => {
try {
let jsonStr;
if (currentProjectIdx) {
jsonStr = await machine.Project_UpdateProject(JSON.stringify(projectData));
} else {
jsonStr = await machine.Project_CreateProject(JSON.stringify(projectData));
}
const data = JSON.parse(jsonStr);
if (!data.Success) {
alert('오류: ' + data.Message);
} else {
@@ -903,11 +808,10 @@
closeProjectModal();
loadProjects();
}
})
.catch(error => {
} catch (error) {
console.error('Error:', error);
alert('저장 중 오류가 발생했습니다.');
});
}
}
function deleteCurrentProject() {
@@ -918,14 +822,13 @@
document.getElementById('deleteModal').classList.add('hidden');
}
function confirmDelete() {
async function confirmDelete() {
if (!currentProjectIdx) return;
fetch(`/Project/DeleteProject?id=${currentProjectIdx}`, {
method: 'DELETE'
})
.then(response => response.json())
.then(data => {
try {
const jsonStr = await machine.Project_DeleteProject(currentProjectIdx);
const data = JSON.parse(jsonStr);
if (!data.Success) {
alert('오류: ' + data.Message);
} else {
@@ -933,11 +836,10 @@
closeProjectModal();
loadProjects();
}
})
.catch(error => {
} catch (error) {
console.error('Error:', error);
alert('삭제 중 오류가 발생했습니다.');
});
}
}
function getStatusClass(status) {