-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathkimp_status.html
More file actions
462 lines (422 loc) · 17.6 KB
/
Copy pathkimp_status.html
File metadata and controls
462 lines (422 loc) · 17.6 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
<!--
<%@ page contentType="text/html;charset=UTF-8" language="java" isELIgnored="true" %>
<%
org.example.config.auth.dto.SessionUser sUser = (org.example.config.auth.dto.SessionUser) request.getAttribute("user");
if (sUser != null) {
%>
<script>
sessionStorage.setItem("user-id", "<%= sUser.getId() %>");
sessionStorage.setItem("user", JSON.stringify({
id: "<%= sUser.getId() %>",
name: "<%= sUser.getName() %>",
email: "<%= sUser.getEmail() %>",
picture: "<%= sUser.getPicture() != null ? sUser.getPicture() : "" %>",
role: "<%= sUser.getRole() %>"
}));
</script>
<%
}
%>
-->
<!DOCTYPE html>
<html lang="ko">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0, user-scalable=no" />
<title>김치만들기 - 실시간 실습 현황</title>
<link href="https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&family=Noto+Sans+KR:wght@300;400;500;700&display=swap" rel="stylesheet">
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap-icons@1.11.3/font/bootstrap-icons.min.css">
<script src="./js/auth.js" type="text/javascript"></script>
<script src="./js/auth-guard.js" type="text/javascript"></script>
<script src="./js/store.js" type="text/javascript"></script>
<script src="./js/engine.js" type="text/javascript"></script>
<style>
:root {
--bg-color: #0b0b16;
--card-bg: #121226;
--card-border: #1e1e3f;
--text-main: #ffffff;
--text-sub: #76769e;
--neon-blue: #7b92ff;
--amber-accent: #e85d04;
--neon-green: #00b894;
--btn-disabled: #1d1d36;
}
* { box-sizing: border-box; margin: 0; padding: 0; }
body {
background-color: var(--bg-color);
color: var(--text-main);
font-family: 'Inter', 'Noto Sans KR', sans-serif;
min-height: 100vh;
display: flex;
justify-content: center;
overflow-x: hidden;
}
.app-container {
width: 100%;
max-width: 480px;
background-color: #0b0b16;
display: flex;
flex-direction: column;
padding: 16px 16px 120px 16px;
position: relative;
}
.time-header {
display: grid;
grid-template-columns: 1fr 1fr;
padding: 16px 8px;
margin-bottom: 8px;
border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}
.time-box { display: flex; flex-direction: column; }
.time-box.left { align-items: flex-start; }
.time-box.right { align-items: flex-end; }
.time-value {
font-family: 'Outfit', 'Inter', sans-serif;
font-size: 32px;
font-weight: 700;
color: var(--neon-blue);
letter-spacing: 0.5px;
}
.time-label { font-size: 11px; color: var(--text-sub); margin-top: 4px; }
.app-header {
display: flex;
justify-content: space-between;
align-items: center;
padding: 12px 4px;
margin-bottom: 16px;
}
.header-title {
font-size: 20px;
font-weight: 700;
display: flex;
align-items: center;
gap: 8px;
}
.header-title i { color: var(--neon-green); }
.header-meta {
font-size: 12px;
color: var(--text-sub);
background: rgba(255,255,255,0.05);
padding: 4px 8px;
border-radius: 4px;
}
.section-title {
font-size: 15px;
font-weight: 700;
display: flex;
align-items: center;
gap: 6px;
margin-bottom: 12px;
padding: 0 4px;
}
.section-title.timeline-title i { color: var(--neon-blue); }
.section-title.salary-title i { color: var(--neon-green); }
/* 급여 테이블 */
.salary-list {
display: flex;
flex-direction: column;
gap: 10px;
margin-bottom: 24px;
}
.salary-item {
background-color: var(--card-bg);
border: 1px solid var(--card-border);
border-radius: 12px;
padding: 14px 16px;
display: flex;
justify-content: space-between;
align-items: center;
}
.user-info { display: flex; align-items: center; gap: 10px; }
.user-icon {
width: 36px;
height: 36px;
border-radius: 50%;
background-color: rgba(123, 92, 245, 0.15);
color: var(--neon-blue);
display: flex;
align-items: center;
justify-content: center;
font-size: 18px;
}
.user-icon.helper {
background-color: rgba(0, 184, 148, 0.15);
color: var(--neon-green);
}
.user-details { display: flex; flex-direction: column; gap: 2px; }
.user-name { font-size: 14px; font-weight: 700; color: #fff; }
.user-role { font-size: 10px; color: var(--text-sub); }
.user-salary { text-align: right; }
.user-salary-val { font-size: 16px; font-weight: 700; color: #fff; }
.user-salary-bonus { font-size: 10px; color: var(--neon-green); margin-top: 2px; }
/* 타임라인 카드 */
.timeline-card {
background-color: var(--card-bg);
border: 1px solid var(--card-border);
border-radius: 16px;
padding: 20px;
display: flex;
flex-direction: column;
gap: 16px;
max-height: 480px;
overflow-y: auto;
}
.timeline-item {
display: flex;
gap: 12px;
position: relative;
padding-bottom: 16px;
}
.timeline-item:last-child {
padding-bottom: 0;
}
.timeline-item::after {
content: '';
position: absolute;
left: 77px;
top: 24px;
bottom: 0;
width: 1px;
background-color: var(--card-border);
}
.timeline-item:last-child::after { display: none; }
.timeline-time {
font-size: 11px;
color: var(--text-sub);
width: 55px;
text-align: right;
padding-top: 4px;
font-variant-numeric: tabular-nums;
}
.timeline-dot {
width: 8px;
height: 8px;
border-radius: 50%;
background-color: var(--card-border);
margin-top: 7px;
flex-shrink: 0;
z-index: 1;
}
.timeline-item.highlight .timeline-dot {
background-color: var(--neon-blue);
box-shadow: 0 0 8px var(--neon-blue);
}
.timeline-item.helper-log .timeline-dot {
background-color: var(--neon-green);
box-shadow: 0 0 8px var(--neon-green);
}
.timeline-item.warning-log .timeline-dot {
background-color: var(--amber-accent);
box-shadow: 0 0 8px var(--amber-accent);
}
.timeline-text {
font-size: 12px;
color: #d1d1e6;
line-height: 1.5;
flex: 1;
}
</style>
<link rel="manifest" href="./manifest.json">
<meta name="theme-color" content="#09031f">
<link rel="apple-touch-icon" href="./icons/icon-192x192.png">
<meta name="mobile-web-app-capable" content="yes">
<meta name="apple-mobile-web-app-capable" content="yes">
<meta name="apple-mobile-web-app-status-bar-style" content="black-translucent">
<script src="./js/pwa.js?v=20260731-pwa-v8" defer></script>
</head>
<body>
<div class="app-container">
<!-- ── 상단 시계 표시 ── -->
<div class="time-header">
<div class="time-box left">
<span class="time-value" id="current-clock">·15:04</span>
<span class="time-label">현재 시간 (시작: 15:00)</span>
</div>
<div class="time-box right">
<span class="time-value" id="remaining-clock">01:56:00</span>
<span class="time-label">남은 세션 시간</span>
</div>
</div>
<header class="app-header">
<div class="header-title">
<i class="bi bi-activity"></i>
<span>실시간 실습 현황판</span>
</div>
<span class="header-meta">김치만들기 공정</span>
</header>
<!-- ── 3인 실시간 급여 ── -->
<div class="section-title salary-title">
<i class="bi bi-wallet2"></i>
<span>참여자 실시간 누적 급여</span>
</div>
<div class="salary-list" id="salary-list-container">
<!-- 동적으로 참여자 급여 목록이 렌더링됩니다. -->
</div>
<!-- ── 실시간 타임라인 로그 ── -->
<div class="section-title timeline-title">
<i class="bi bi-clock-history"></i>
<span>시간순 실습 타임라인 로그</span>
</div>
<div id="timeline-container" class="timeline-card">
<!-- 동적으로 타임라인 목록이 시간순 역순(최신이 맨 위)으로 추가됩니다. -->
</div>
</div>
<script>
// 현재 로그인 사용자 정보
var _statusSessionUser = window.AuthManager ? window.AuthManager.getCurrentUser() : null;
if (!_statusSessionUser) {
try { _statusSessionUser = JSON.parse(sessionStorage.getItem('user')); } catch(e) {}
}
// 시계 동기화
function syncClock() {
var remaining = getPartitionedItem('kimp_remaining_seconds');
var hour = getPartitionedItem('kimp_clock_hour');
var minute = getPartitionedItem('kimp_clock_minute');
var second = getPartitionedItem('kimp_second_counter');
if (remaining !== null) {
var rem = parseInt(remaining);
var h = Math.floor(rem / 3600);
var m = Math.floor((rem % 3600) / 60);
var s = rem % 60;
document.getElementById('remaining-clock').textContent =
String(h).padStart(2, '0') + ':' +
String(m).padStart(2, '0') + ':' +
String(s).padStart(2, '0');
}
if (hour !== null && minute !== null) {
document.getElementById('current-clock').textContent =
'·' + String(hour).padStart(2, '0') + ':' +
String(minute).padStart(2, '0');
}
}
// 급여 동기화 - store.js의 state.workers 기반 동적 렌더링
function syncSalaries() {
var container = document.getElementById('salary-list-container');
if (!container) return;
var store = window.FactoryStore;
if (!store) return;
var state = store.getState();
var workers = state.workers || {};
var currentUserId = state.currentUser ? state.currentUser.id : null;
var html = '';
// workers에 등록된 모든 근로자 순회
Object.keys(workers).forEach(function(uId) {
var w = workers[uId];
if (!w) return;
// 매니저(ID=1)는 급여 전광판에 표시하지 않음 (생산지시서 관리를 담당하기 때문)
if (String(uId) === "1") return;
var isSelf = currentUserId && String(uId) === String(currentUserId);
var isHelper = String(uId) === "4"; // 김영희 헬퍼 고유 ID
var userRole = isHelper ? '현장 지원 헬퍼' : '가상 체험자';
if (isSelf) {
userRole += ' (본인)';
}
// 급여 계산
var salaryVal = 0;
// _calcElapsedSinceCheckIn과 동일하게 계산
function calcSalary(targetWorker) {
const elapsedSeconds = 7200 - state.remainingSeconds;
if (!targetWorker.checkInTime || targetWorker.checkInTime === '-') return 0;
const parts = targetWorker.checkInTime.split(':');
if (parts.length < 2) return 0;
const ciH = parseInt(parts[0]) || 0;
const ciM = parseInt(parts[1]) || 0;
const ciS = parts.length > 2 ? (parseInt(parts[2]) || 0) : 0;
const checkInSecs = ciH * 3600 + ciM * 60 + ciS;
const now = new Date();
const nowSecs = now.getHours() * 3600 + now.getMinutes() * 60 + now.getSeconds();
let diff = nowSecs - checkInSecs;
if (diff < 0) diff += 86400;
if (isHelper) {
const baseSalary = Math.floor(diff * (12384 / 3600));
return baseSalary + (targetWorker.helperBonus || 0);
} else {
const workSeconds = Math.max(0, diff - (targetWorker.accumBreakSeconds || 0));
return Math.floor(workSeconds * (12384 / 3600));
}
}
salaryVal = calcSalary(w);
var salaryColor = isHelper ? 'var(--neon-green)' : '#fff';
var borderStyle = isSelf ? 'border: 2px solid var(--neon-blue);' : '';
var helperBonus = w.helperBonus || 0;
html += `
<div class="salary-item" style="${borderStyle}">
<div class="user-info">
<div class="user-icon ${isHelper ? 'helper' : ''}"><i class="bi bi-${isHelper ? 'person-workspace' : 'person-fill'}"></i></div>
<div class="user-details">
<span class="user-name">${w.name || '참여자'}</span>
<span class="user-role" ${isHelper ? 'style="color: var(--neon-green);"' : ''}>${userRole}</span>
</div>
</div>
<div class="user-salary">
<span class="user-salary-val" style="color: ${salaryColor};">${salaryVal.toLocaleString()} KRW</span>
${isHelper && helperBonus > 0 ? `<div class="user-salary-bonus" id="helper-bonus-row">보너스 수당: ${helperBonus.toLocaleString()} KRW (${Math.floor(helperBonus/500)}회)</div>` : ''}
</div>
</div>`;
});
if (!html) {
html = '<div style="text-align: center; color: var(--text-sub); padding: 20px 0;">참여자 데이터가 없습니다.</div>';
}
container.innerHTML = html;
}
// 타임라인 동기화
function syncTimeline() {
var timelineStr = getPartitionedItem('kimp_session_timeline');
var container = document.getElementById('timeline-container');
if (!container) return;
if (!timelineStr) {
container.innerHTML = '<div style="text-align: center; color: var(--text-sub); padding: 20px 0;">로그가 없습니다.</div>';
return;
}
var list = JSON.parse(timelineStr);
var chronological = list.slice();
var html = "";
chronological.forEach(function(item) {
var logClass = "timeline-item";
if (item.text.indexOf("시작했습니다") !== -1) {
logClass += " highlight";
} else if (item.text.indexOf("헬퍼") !== -1 || item.text.indexOf("보너스") !== -1) {
logClass += " helper-log";
} else if (item.text.indexOf("도움 요청했습니다") !== -1 || item.text.indexOf("도움 요청을") !== -1) {
logClass += " warning-log";
}
html += `
<div class="${logClass}">
<div class="timeline-time">${item.time}</div>
<div class="timeline-dot"></div>
<div class="timeline-text">${item.text}</div>
</div>
`;
});
container.innerHTML = html;
}
// 이벤트 수신
window.addEventListener('storage', function(e) {
if (e.key === window.getStorageKey('kimp_remaining_seconds') || e.key === window.getStorageKey('kimp_clock_hour')) {
syncClock();
}
// kimp_salary, kimp_helper_bonus, kimp_workers_progress 변경 시 급여 재렌더링
if (e.key === null ||
e.key === window.getStorageKey('kimp_salary') ||
e.key === window.getStorageKey('kimp_helper_bonus') ||
e.key === 'kimp_workers_progress') {
syncSalaries();
}
if (e.key === window.getStorageKey('kimp_session_timeline')) {
syncTimeline();
}
});
// 초기화
syncClock();
syncSalaries();
syncTimeline();
// 1초마다 자동 리프레시 폴백
setInterval(function() {
syncClock();
syncSalaries();
syncTimeline();
}, 1000);
</script>
</body>
</html>