-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathai-assistant.html
More file actions
412 lines (387 loc) · 18.3 KB
/
ai-assistant.html
File metadata and controls
412 lines (387 loc) · 18.3 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
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>AI Assistant Simpatico HR</title>
<link rel="stylesheet" href="/hr-modules.css">
<style>
.ai-layout {
display: grid;
grid-template-columns: 280px 1fr;
height: calc(100vh - 180px); /* Adjust for dashboard topbar/padding */
overflow: hidden;
border: 1px solid var(--hr-border);
border-radius: var(--hr-radius-lg);
background: var(--hr-bg-base);
}
/* Left: Chat history */
.ai-sidebar {
background: var(--hr-bg-surface);
border-right: 1px solid var(--hr-border);
display: flex; flex-direction: column;
overflow: hidden;
}
.ai-sidebar-head {
padding: 16px; border-bottom: 1px solid var(--hr-border);
display: flex; align-items: center; justify-content: space-between;
}
.ai-sidebar-head h3 {
font-family: var(--hr-font-display); font-size: 14px; font-weight: 600;
}
.ai-history { flex:1; overflow-y:auto; padding:8px; }
.ai-history-item {
padding: 10px 12px; border-radius: var(--hr-radius);
cursor: pointer; transition: var(--hr-transition);
border: 1px solid transparent; margin-bottom: 2px;
}
.ai-history-item:hover { background: rgba(255,255,255,.04); }
.ai-history-item.active { background: var(--hr-primary-dim); border-color: var(--hr-primary-glow); }
.ai-history-item .hi-title {
font-size: 13px; font-weight: 500; color: var(--hr-text-primary);
white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.ai-history-item .hi-date { font-size: 11px; color: var(--hr-text-muted); margin-top: 2px; }
/* Suggested prompts */
.ai-suggestions { padding: 12px; border-top: 1px solid var(--hr-border); }
.ai-suggestions h4 { font-size: 11px; font-weight: 600; color: var(--hr-text-muted); text-transform: uppercase; letter-spacing: .06em; margin-bottom: 8px; }
.suggest-chip {
display: block; width: 100%; text-align: left;
padding: 8px 10px; background: var(--hr-bg-elevated);
border: 1px solid var(--hr-border); border-radius: var(--hr-radius);
font-size: 12.5px; color: var(--hr-text-secondary);
cursor: pointer; transition: var(--hr-transition); margin-bottom: 5px;
font-family: var(--hr-font-body);
}
.suggest-chip:hover { border-color: var(--hr-primary); color: var(--hr-text-primary); }
/* Right: Chat area */
.ai-chat {
display: flex; flex-direction: column;
background: var(--hr-bg-base);
overflow: hidden;
}
.ai-chat-header {
padding: 16px 24px;
background: var(--hr-bg-surface);
border-bottom: 1px solid var(--hr-border);
display: flex; align-items: center; justify-content: space-between;
}
.ai-chat-header h2 {
font-family: var(--hr-font-display); font-size: 16px; font-weight: 600;
}
.ai-badge {
display: flex; align-items: center; gap: 6px;
background: var(--hr-primary-dim); border: 1px solid rgba(0,196,255,.2);
border-radius: 20px; padding: 4px 12px;
font-size: 12px; font-weight: 600; color: var(--hr-primary);
}
.ai-badge .dot {
width: 6px; height: 6px; border-radius: 50%;
background: var(--hr-primary);
animation: pulse 2s infinite;
}
@keyframes pulse { 0%,100%{opacity:1} 50%{opacity:.4} }
/* Messages */
.ai-messages {
flex: 1; overflow-y: auto; padding: 24px;
display: flex; flex-direction: column; gap: 20px;
}
.ai-msg { display: flex; gap: 12px; max-width: 800px; }
.ai-msg.user { flex-direction: row-reverse; align-self: flex-end; }
.ai-msg.assistant { align-self: flex-start; }
.msg-avatar {
width: 32px; height: 32px; border-radius: 50%;
display: flex; align-items: center; justify-content: center;
font-size: 13px; font-weight: 700; flex-shrink: 0;
}
.msg-avatar.ai-av {
background: linear-gradient(135deg, #00c4ff, #8b5cf6);
color: #fff;
}
.msg-avatar.user-av {
background: var(--hr-bg-elevated); border: 1px solid var(--hr-border);
color: var(--hr-text-primary);
}
.msg-bubble {
border-radius: var(--hr-radius-lg);
padding: 14px 18px;
font-size: 14px; line-height: 1.6;
max-width: 600px;
}
.ai-msg.user .msg-bubble {
background: var(--hr-primary); color: #000;
border-bottom-right-radius: 4px;
}
.ai-msg.assistant .msg-bubble {
background: var(--hr-bg-card);
border: 1px solid var(--hr-border);
color: var(--hr-text-primary);
border-bottom-left-radius: 4px;
}
.ai-msg.assistant .msg-bubble p { margin-bottom: 10px; }
.ai-msg.assistant .msg-bubble p:last-child { margin-bottom: 0; }
.ai-msg.assistant .msg-bubble strong { color: var(--hr-primary); font-weight: 600; }
.ai-msg.assistant .msg-bubble ul { padding-left: 18px; }
.ai-msg.assistant .msg-bubble li { margin-bottom: 4px; }
.ai-msg.assistant .msg-bubble code {
background: var(--hr-bg-elevated); border: 1px solid var(--hr-border);
border-radius: 4px; padding: 2px 6px;
font-family: var(--hr-font-mono); font-size: 12px;
}
.msg-time { font-size: 11px; color: var(--hr-text-muted); margin-top: 4px; padding: 0 4px; }
/* Typing indicator */
.typing-indicator {
display: flex; gap: 4px; align-items: center;
padding: 14px 18px; background: var(--hr-bg-card);
border: 1px solid var(--hr-border); border-radius: var(--hr-radius-lg);
border-bottom-left-radius: 4px;
}
.typing-dot {
width: 7px; height: 7px; border-radius: 50%;
background: var(--hr-text-muted);
animation: typingBounce 1.2s infinite;
}
.typing-dot:nth-child(2) { animation-delay: .2s; }
.typing-dot:nth-child(3) { animation-delay: .4s; }
@keyframes typingBounce { 0%,60%,100%{transform:translateY(0)} 30%{transform:translateY(-6px)} }
/* Input area */
.ai-input-area {
padding: 16px 24px;
background: var(--hr-bg-surface);
border-top: 1px solid var(--hr-border);
}
.ai-context-bar {
display: flex; gap: 8px; margin-bottom: 10px; flex-wrap: wrap;
}
.context-chip {
display: flex; align-items: center; gap: 5px;
background: var(--hr-bg-elevated); border: 1px solid var(--hr-border);
border-radius: 20px; padding: 3px 10px;
font-size: 12px; color: var(--hr-text-secondary); cursor: pointer;
transition: var(--hr-transition);
}
.context-chip:hover { border-color: var(--hr-primary); color: var(--hr-primary); }
.context-chip.active { background: var(--hr-primary-dim); border-color: rgba(0,196,255,.3); color: var(--hr-primary); }
.ai-input-row {
display: flex; gap: 10px; align-items: flex-end;
}
.ai-textarea-wrap {
flex: 1; background: var(--hr-bg-elevated);
border: 1px solid var(--hr-border); border-radius: var(--hr-radius-lg);
transition: var(--hr-transition); overflow: hidden;
}
.ai-textarea-wrap:focus-within { border-color: var(--hr-primary); box-shadow: 0 0 0 3px var(--hr-primary-dim); }
.ai-textarea {
width: 100%; padding: 12px 16px;
background: none; border: none; outline: none;
font-family: var(--hr-font-body); font-size: 14px;
color: var(--hr-text-primary); resize: none;
min-height: 48px; max-height: 160px;
}
.ai-textarea::placeholder { color: var(--hr-text-muted); }
.ai-send-btn {
width: 44px; height: 44px; border-radius: 50%;
background: var(--hr-primary); color: #000;
border: none; cursor: pointer; display: flex;
align-items: center; justify-content: center;
transition: var(--hr-transition); flex-shrink: 0;
}
.ai-send-btn:hover { filter: brightness(1.1); box-shadow: 0 0 16px var(--hr-primary-glow); }
.ai-send-btn:disabled { opacity: .4; cursor: not-allowed; }
.ai-send-btn svg { width: 18px; height: 18px; }
/* Welcome screen */
.ai-welcome {
flex: 1; display: flex; flex-direction: column;
align-items: center; justify-content: center;
padding: 40px; text-align: center;
}
.ai-welcome .logo {
width: 64px; height: 64px; border-radius: 20px;
background: linear-gradient(135deg, var(--hr-primary-dim), var(--hr-primary-glow));
border: 1px solid var(--hr-primary-glow);
display: flex; align-items: center; justify-content: center;
font-size: 28px; margin-bottom: 20px;
}
.ai-welcome h2 {
font-family: var(--hr-font-display); font-size: 22px; font-weight: 700;
margin-bottom: 8px;
}
.ai-welcome p {
font-size: 14px; color: var(--hr-text-secondary); max-width: 440px;
line-height: 1.6; margin-bottom: 24px;
}
.welcome-grid {
display: grid; grid-template-columns: 1fr 1fr; gap: 10px;
max-width: 500px; width: 100%;
}
.welcome-card {
background: var(--hr-bg-card); border: 1px solid var(--hr-border);
border-radius: var(--hr-radius-lg); padding: 14px 16px;
cursor: pointer; text-align: left; transition: var(--hr-transition);
font-family: var(--hr-font-body);
}
.welcome-card:hover { border-color: var(--hr-primary); background: var(--hr-primary-dim); }
.welcome-card .wc-icon { font-size: 18px; margin-bottom: 6px; }
.welcome-card .wc-title { font-size: 13px; font-weight: 600; color: var(--hr-text-primary); }
.welcome-card .wc-sub { font-size: 12px; color: var(--hr-text-muted); margin-top: 2px; }
/* Tool calls display */
.tool-call {
background: var(--hr-bg-elevated); border: 1px solid var(--hr-border-light);
border-radius: var(--hr-radius); padding: 8px 12px; margin-top: 8px;
font-family: var(--hr-font-mono); font-size: 12px; color: var(--hr-text-muted);
}
.tool-call .tc-label { color: var(--hr-primary); font-weight: 600; margin-right: 6px; }
</style>
<script>
// Hide shell when loaded inside dashboard iframe
if (window.self !== window.top) {
document.addEventListener("DOMContentLoaded", function() {
var shell = document.querySelector(".hr-shell");
if (shell) {
shell.style.gridTemplateColumns = "1fr";
shell.style.gridTemplateRows = "1fr";
}
var topbar = document.querySelector(".hr-topbar");
if (topbar) topbar.style.display = "none";
var sidebar = document.querySelector(".hr-sidebar");
if (sidebar) sidebar.style.display = "none";
var main = document.querySelector(".hr-main");
if (main) {
main.style.gridColumn = "1";
main.style.padding = "20px";
}
});
}
</script></head>
<body class="hr-module">
<div style="display:flex;flex-direction:column;height:100vh;">
<!-- Topbar -->
<header class="hr-topbar">
<a href="/dashboard/hr.html" class="hr-topbar-brand">
<img src="favicon-96x96.png" style="width:24px;height:24px;margin-right:10px;border-radius:4px">Simpatico<span>HR</span>
</a>
<div class="hr-topbar-right">
<div class="ai-badge"><div class="dot"></div>Cloudflare AI Active</div>
<div class="hr-avatar" id="user-avatar">U</div>
</div>
</header>
<div class="hr-main" style="display:contents;">
<div class="ai-layout">
<!-- Left sidebar -->
<div class="ai-sidebar">
<div class="ai-sidebar-head">
<h3>Conversations</h3>
<button class="hr-btn hr-btn-ghost hr-btn-sm" onclick="newChat()">+ New</button>
</div>
<div class="ai-history" id="chat-history">
<!-- JS rendered -->
</div>
<div class="ai-suggestions">
<h4>Quick Actions</h4>
<button class="suggest-chip" onclick="suggest('Summarize workforce health for this month')"> Workforce health summary</button>
<button class="suggest-chip" onclick="suggest('Which employees have compliance training overdue')"> Compliance alerts</button>
<button class="suggest-chip" onclick="suggest('Draft a performance improvement plan template')"> PIP template</button>
<button class="suggest-chip" onclick="suggest('Analyze turnover trends and identify at-risk employees')"> Turnover analysis</button>
<button class="suggest-chip" onclick="suggest('What is the total payroll cost this month')"> Payroll cost check</button>
</div>
</div>
<!-- Chat area -->
<div class="ai-chat" id="ai-chat">
<!-- Welcome or messages -->
<div class="ai-chat-header">
<h2 id="chat-title">HR AI Assistant</h2>
<div style="display:flex;gap:8px">
<button class="hr-btn hr-btn-ghost hr-btn-sm" onclick="clearChat()">Clear</button>
<button class="hr-btn hr-btn-ghost hr-btn-sm" onclick="exportChat()">Export</button>
</div>
</div>
<div class="ai-messages" id="messages-container">
<div class="ai-welcome" id="welcome-screen">
<h2>Your HR Intelligence Layer</h2>
<p>Ask me anything about your workforce from headcount analytics and payroll queries to drafting policies, generating reports, or coaching on HR best practices.</p>
<div class="welcome-grid">
<button class="welcome-card" onclick="suggest('Give me a full workforce health snapshot')">
<div class="wc-icon">
<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><path d="M3 3v18h18"/><path d="m19 9-5 5-4-4-3 3"/></svg>
</div>
<div class="wc-title">Workforce Snapshot</div>
<div class="wc-sub">Real-time HR metrics overview</div>
</button>
<button class="welcome-card" onclick="suggest('Draft an employee warning letter template')">
<div class="wc-icon">
<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><path d="M14.5 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V7.5L14.5 2z"/><polyline points="14 2 14 8 20 8"/></svg>
</div>
<div class="wc-title">Draft HR Documents</div>
<div class="wc-sub">Letters, policies, templates</div>
</button>
<button class="welcome-card" onclick="suggest('Who are my top performers based on recent reviews')">
<div class="wc-icon">
<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><circle cx="12" cy="8" r="7"/><polyline points="8.21 13.89 7 23 12 20 17 23 15.79 13.88"/></svg>
</div>
<div class="wc-title">Performance Insights</div>
<div class="wc-sub">Review data & recommendations</div>
</button>
<button class="welcome-card" onclick="suggest('What hiring trends should I watch in my industry')">
<div class="wc-icon">
<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><path d="M2 3h6a4 4 0 0 1 4 4v14a3 3 0 0 0-3-3H2z"/><path d="M22 3h-6a4 4 0 0 0-4 4v14a3 3 0 0 1 3-3h7z"/></svg>
</div>
<div class="wc-title">HR Trends & Advice</div>
<div class="wc-sub">Expert guidance on HR topics</div>
</button>
<button class="welcome-card" onclick="suggest('Access my job postings and suggest innovative technology features for our ATS')">
<div class="wc-icon">
<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><path d="M12 2L2 7l10 5 10-5-10-5zM2 17l10 5 10-5M2 12l10 5 10-5"/></svg>
</div>
<div class="wc-title">Job Postings & Tech</div>
<div class="wc-sub">Voice/chat ATS job features</div>
</button>
</div>
</div>
</div>
<!-- Context bar + input -->
<div class="ai-input-area">
<div class="ai-context-bar">
<button class="context-chip active" id="ctx-employees" onclick="toggleContext('employees')">
<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" style="width:12px;height:12px"><path d="M17 21v-2a4 4 0 0 0-4-4H5a4 4 0 0 0-4 4v2"/><circle cx="9" cy="7" r="4"/></svg>
Employees
</button>
<button class="context-chip" id="ctx-payroll" onclick="toggleContext('payroll')"> Payroll</button>
<button class="context-chip" id="ctx-performance" onclick="toggleContext('performance')"> Performance</button>
<button class="context-chip" id="ctx-training" onclick="toggleContext('training')"> Training</button>
<button class="context-chip" id="ctx-leave" onclick="toggleContext('leave')"> Leave</button>
<button class="context-chip" id="ctx-jobs" onclick="toggleContext('jobs')"> <i class="fas fa-briefcase"></i> Jobs</button>
</div>
<div class="ai-input-row">
<div class="ai-textarea-wrap">
<textarea
class="ai-textarea"
id="ai-input"
placeholder="Ask anything or use Voice Command to access job postings and innovative tech..."
rows="1"
onkeydown="handleKey(event)"
oninput="autoResize(this)"
></textarea>
</div>
<button class="ai-send-btn" style="background:var(--hr-bg-elevated);color:var(--hr-text-primary);border:1px solid var(--hr-border)" id="mic-btn" onclick="toggleVoice()">
<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.5"><path d="M12 2a3 3 0 0 0-3 3v7a3 3 0 0 0 6 0V5a3 3 0 0 0-3-3z"/><path d="M19 10v2a7 7 0 0 1-14 0v-2"/><line x1="12" y1="19" x2="12" y2="23"/><line x1="8" y1="23" x2="16" y2="23"/></svg>
</button>
<button class="ai-send-btn" id="send-btn" onclick="sendMessage()">
<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.5"><line x1="22" y1="2" x2="11" y2="13"/><polygon points="22 2 15 22 11 13 2 9 22 2"/></svg>
</button>
</div>
<div style="margin-top:8px;font-size:11px;color:var(--hr-text-muted);text-align:center">
Powered by Cloudflare AI Context-aware queries with live HR data Vector search via Cloudflare Vectorize
</div>
</div>
</div>
</div> <!-- End ai-layout -->
</div> <!-- End hr-main -->
</div>
<div class="hr-toast-container" id="toasts"></div>
<script src="https://cdn.jsdelivr.net/npm/@supabase/supabase-js@2"></script>
<script src="/js/hr-config.js"></script>
<script src="/js/shared-utils.js"></script>
<script src="/js/supabase-client.js"></script>
<script src="/js/ai-assistant.js"></script>
</body>
</html>