water-water commited on
Commit
89d9b0d
·
verified ·
1 Parent(s): 3c2bb5c

Upload 2 files

Browse files
Files changed (2) hide show
  1. app.py +37 -0
  2. index.html +531 -0
app.py ADDED
@@ -0,0 +1,37 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from flask import Flask, render_template, request, jsonify
2
+ import requests
3
+ import json
4
+
5
+ app = Flask(__name__)
6
+
7
+ @app.route('/')
8
+ def index():
9
+ return render_template('index.html')
10
+
11
+ @app.route('/chat', methods=['POST'])
12
+ def chat():
13
+ try:
14
+ data = request.get_json()
15
+ query = data.get('query', '')
16
+
17
+ # Make request to the chat API
18
+ response = requests.post(
19
+ 'http://127.0.0.1:8000/generate_response',
20
+ json={"query": query},
21
+ headers={'Content-Type': 'application/json'},
22
+ timeout=30
23
+ )
24
+
25
+ if response.status_code == 200:
26
+ result = response.json()
27
+ return jsonify({"answer": result.get("answer", "No response received")})
28
+ else:
29
+ return jsonify({"answer": "Sorry, I'm having trouble connecting to the AI service."}), 500
30
+
31
+ except requests.exceptions.RequestException as e:
32
+ return jsonify({"answer": "Connection error. Please make sure the AI service is running."}), 500
33
+ except Exception as e:
34
+ return jsonify({"answer": "An unexpected error occurred."}), 500
35
+
36
+ if __name__ == '__main__':
37
+ app.run(debug=True, port=5000)
index.html ADDED
@@ -0,0 +1,531 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <!DOCTYPE html>
2
+ <html lang="en">
3
+ <head>
4
+ <meta charset="UTF-8">
5
+ <meta name="viewport" content="width=device-width, initial-scale=1.0">
6
+ <title>AI Project Manager</title>
7
+ <script src="https://cdn.jsdelivr.net/npm/chart.js"></script>
8
+ <link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0/dist/css/bootstrap.min.css" rel="stylesheet">
9
+ <link href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.0.0/css/all.min.css" rel="stylesheet">
10
+ <style>
11
+ :root {
12
+ --primary-color: #2c3e50;
13
+ --secondary-color: #3498db;
14
+ --accent-color: #e74c3c;
15
+ --success-color: #27ae60;
16
+ --warning-color: #f39c12;
17
+ --background-color: #f8f9fa;
18
+ --card-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
19
+ }
20
+
21
+ body {
22
+ background-color: var(--background-color);
23
+ font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
24
+ }
25
+
26
+ .navbar {
27
+ background: linear-gradient(135deg, var(--primary-color), var(--secondary-color));
28
+ box-shadow: var(--card-shadow);
29
+ }
30
+
31
+ .navbar-brand {
32
+ font-weight: bold;
33
+ font-size: 1.5rem;
34
+ color: white !important;
35
+ }
36
+
37
+ .dashboard-card {
38
+ background: white;
39
+ border-radius: 12px;
40
+ box-shadow: var(--card-shadow);
41
+ transition: transform 0.3s ease;
42
+ border: none;
43
+ }
44
+
45
+ .dashboard-card:hover {
46
+ transform: translateY(-2px);
47
+ }
48
+
49
+ .filter-section {
50
+ background: white;
51
+ border-radius: 12px;
52
+ box-shadow: var(--card-shadow);
53
+ padding: 20px;
54
+ margin-bottom: 20px;
55
+ }
56
+
57
+ .chart-container {
58
+ position: relative;
59
+ height: 300px;
60
+ padding: 20px;
61
+ }
62
+
63
+ .priority-table {
64
+ max-height: 300px;
65
+ overflow-y: auto;
66
+ }
67
+
68
+ .priority-high {
69
+ color: var(--accent-color);
70
+ font-weight: bold;
71
+ }
72
+
73
+ .priority-medium {
74
+ color: var(--warning-color);
75
+ font-weight: bold;
76
+ }
77
+
78
+ .priority-low {
79
+ color: var(--success-color);
80
+ font-weight: bold;
81
+ }
82
+
83
+ .chat-container {
84
+ background: white;
85
+ border-radius: 12px;
86
+ box-shadow: var(--card-shadow);
87
+ height: 500px;
88
+ display: flex;
89
+ flex-direction: column;
90
+ }
91
+
92
+ .chat-header {
93
+ background: linear-gradient(135deg, var(--primary-color), var(--secondary-color));
94
+ color: white;
95
+ padding: 15px 20px;
96
+ border-radius: 12px 12px 0 0;
97
+ font-weight: bold;
98
+ }
99
+
100
+ .chat-messages {
101
+ flex: 1;
102
+ padding: 20px;
103
+ overflow-y: auto;
104
+ max-height: 350px;
105
+ }
106
+
107
+ .message {
108
+ margin-bottom: 15px;
109
+ animation: fadeIn 0.3s ease;
110
+ }
111
+
112
+ .message.user {
113
+ text-align: right;
114
+ }
115
+
116
+ .message.bot {
117
+ text-align: left;
118
+ }
119
+
120
+ .message-bubble {
121
+ display: inline-block;
122
+ padding: 12px 16px;
123
+ border-radius: 18px;
124
+ max-width: 70%;
125
+ word-wrap: break-word;
126
+ }
127
+
128
+ .message.user .message-bubble {
129
+ background: var(--secondary-color);
130
+ color: white;
131
+ }
132
+
133
+ .message.bot .message-bubble {
134
+ background: #e9ecef;
135
+ color: var(--primary-color);
136
+ }
137
+
138
+ .chat-input-container {
139
+ padding: 20px;
140
+ border-top: 1px solid #e9ecef;
141
+ border-radius: 0 0 12px 12px;
142
+ }
143
+
144
+ .chat-input {
145
+ border: 2px solid #e9ecef;
146
+ border-radius: 25px;
147
+ padding: 12px 20px;
148
+ transition: border-color 0.3s ease;
149
+ }
150
+
151
+ .chat-input:focus {
152
+ border-color: var(--secondary-color);
153
+ box-shadow: 0 0 0 0.2rem rgba(52, 152, 219, 0.25);
154
+ }
155
+
156
+ .btn-send {
157
+ background: var(--secondary-color);
158
+ border: none;
159
+ border-radius: 50%;
160
+ width: 45px;
161
+ height: 45px;
162
+ color: white;
163
+ transition: background-color 0.3s ease;
164
+ }
165
+
166
+ .btn-send:hover {
167
+ background: var(--primary-color);
168
+ color: white;
169
+ }
170
+
171
+ @keyframes fadeIn {
172
+ from { opacity: 0; transform: translateY(10px); }
173
+ to { opacity: 1; transform: translateY(0); }
174
+ }
175
+
176
+ .loading {
177
+ display: none;
178
+ text-align: center;
179
+ color: #6c757d;
180
+ }
181
+
182
+ .loading .spinner-border {
183
+ width: 1rem;
184
+ height: 1rem;
185
+ }
186
+
187
+ @media (max-width: 768px) {
188
+ .chart-container {
189
+ height: 250px;
190
+ }
191
+
192
+ .chat-container {
193
+ height: 400px;
194
+ }
195
+
196
+ .chat-messages {
197
+ max-height: 250px;
198
+ }
199
+ }
200
+ </style>
201
+ </head>
202
+ <body>
203
+ <!-- Navigation Bar -->
204
+ <nav class="navbar navbar-expand-lg">
205
+ <div class="container">
206
+ <a class="navbar-brand" href="#">
207
+ <i class="fas fa-chart-line me-2"></i>AI Project Manager
208
+ </a>
209
+ </div>
210
+ </nav>
211
+
212
+ <div class="container mt-4">
213
+ <!-- Filter Section -->
214
+ <div class="filter-section">
215
+ <div class="row g-3">
216
+ <div class="col-md-4">
217
+ <label class="form-label"><i class="fas fa-calendar me-2"></i>Date Range</label>
218
+ <div class="input-group">
219
+ <input type="date" class="form-control" value="2024-01-01">
220
+ <span class="input-group-text">to</span>
221
+ <input type="date" class="form-control" value="2024-12-31">
222
+ </div>
223
+ </div>
224
+ <div class="col-md-4">
225
+ <label class="form-label"><i class="fas fa-tasks me-2"></i>Status</label>
226
+ <select class="form-select">
227
+ <option>All Status</option>
228
+ <option>Active</option>
229
+ <option>Completed</option>
230
+ <option>On Hold</option>
231
+ <option>Cancelled</option>
232
+ </select>
233
+ </div>
234
+ <div class="col-md-4">
235
+ <label class="form-label"><i class="fas fa-project-diagram me-2"></i>Project</label>
236
+ <select class="form-select">
237
+ <option>All Projects</option>
238
+ <option>E-commerce Platform</option>
239
+ <option>Mobile App</option>
240
+ <option>Data Analytics</option>
241
+ <option>AI Chatbot</option>
242
+ </select>
243
+ </div>
244
+ </div>
245
+ </div>
246
+
247
+ <!-- Dashboard Cards -->
248
+ <div class="row g-4 mb-4">
249
+ <!-- Project Breakdown Chart -->
250
+ <div class="col-lg-4">
251
+ <div class="card dashboard-card h-100">
252
+ <div class="card-header bg-transparent">
253
+ <h5 class="mb-0"><i class="fas fa-chart-pie me-2"></i>Project Breakdown</h5>
254
+ </div>
255
+ <div class="chart-container">
256
+ <canvas id="projectChart"></canvas>
257
+ </div>
258
+ </div>
259
+ </div>
260
+
261
+ <!-- Task Status Chart -->
262
+ <div class="col-lg-4">
263
+ <div class="card dashboard-card h-100">
264
+ <div class="card-header bg-transparent">
265
+ <h5 class="mb-0"><i class="fas fa-chart-donut me-2"></i>Task Status</h5>
266
+ </div>
267
+ <div class="chart-container">
268
+ <canvas id="taskChart"></canvas>
269
+ </div>
270
+ </div>
271
+ </div>
272
+
273
+ <!-- Priority Projects Table -->
274
+ <div class="col-lg-4">
275
+ <div class="card dashboard-card h-100">
276
+ <div class="card-header bg-transparent">
277
+ <h5 class="mb-0"><i class="fas fa-list me-2"></i>Priority Projects</h5>
278
+ </div>
279
+ <div class="card-body p-0">
280
+ <div class="priority-table">
281
+ <table class="table table-hover mb-0">
282
+ <thead class="table-light">
283
+ <tr>
284
+ <th>Project</th>
285
+ <th>Priority</th>
286
+ <th>Progress</th>
287
+ </tr>
288
+ </thead>
289
+ <tbody>
290
+ <tr>
291
+ <td>E-commerce Platform</td>
292
+ <td><span class="priority-high">High</span></td>
293
+ <td>
294
+ <div class="progress" style="height: 8px;">
295
+ <div class="progress-bar bg-danger" style="width: 75%"></div>
296
+ </div>
297
+ </td>
298
+ </tr>
299
+ <tr>
300
+ <td>Mobile App Development</td>
301
+ <td><span class="priority-high">High</span></td>
302
+ <td>
303
+ <div class="progress" style="height: 8px;">
304
+ <div class="progress-bar bg-warning" style="width: 60%"></div>
305
+ </div>
306
+ </td>
307
+ </tr>
308
+ <tr>
309
+ <td>Data Analytics Dashboard</td>
310
+ <td><span class="priority-medium">Medium</span></td>
311
+ <td>
312
+ <div class="progress" style="height: 8px;">
313
+ <div class="progress-bar bg-info" style="width: 40%"></div>
314
+ </div>
315
+ </td>
316
+ </tr>
317
+ <tr>
318
+ <td>AI Chatbot Integration</td>
319
+ <td><span class="priority-medium">Medium</span></td>
320
+ <td>
321
+ <div class="progress" style="height: 8px;">
322
+ <div class="progress-bar bg-success" style="width: 90%"></div>
323
+ </div>
324
+ </td>
325
+ </tr>
326
+ <tr>
327
+ <td>Website Redesign</td>
328
+ <td><span class="priority-low">Low</span></td>
329
+ <td>
330
+ <div class="progress" style="height: 8px;">
331
+ <div class="progress-bar bg-secondary" style="width: 25%"></div>
332
+ </div>
333
+ </td>
334
+ </tr>
335
+ <tr>
336
+ <td>API Documentation</td>
337
+ <td><span class="priority-low">Low</span></td>
338
+ <td>
339
+ <div class="progress" style="height: 8px;">
340
+ <div class="progress-bar bg-success" style="width: 85%"></div>
341
+ </div>
342
+ </td>
343
+ </tr>
344
+ <tr>
345
+ <td>Security Audit</td>
346
+ <td><span class="priority-high">High</span></td>
347
+ <td>
348
+ <div class="progress" style="height: 8px;">
349
+ <div class="progress-bar bg-warning" style="width: 50%"></div>
350
+ </div>
351
+ </td>
352
+ </tr>
353
+ </tbody>
354
+ </table>
355
+ </div>
356
+ </div>
357
+ </div>
358
+ </div>
359
+ </div>
360
+
361
+ <!-- Chat Section -->
362
+ <div class="row">
363
+ <div class="col-12">
364
+ <div class="chat-container">
365
+ <div class="chat-header">
366
+ <i class="fas fa-robot me-2"></i>AI Project Assistant
367
+ </div>
368
+ <div class="chat-messages" id="chatMessages">
369
+ <div class="message bot">
370
+ <div class="message-bubble">
371
+ Hello! I'm your AI Project Assistant. How can I help you manage your projects today?
372
+ </div>
373
+ </div>
374
+ </div>
375
+ <div class="loading" id="loadingIndicator">
376
+ <div class="spinner-border me-2" role="status"></div>
377
+ <span>AI is thinking...</span>
378
+ </div>
379
+ <div class="chat-input-container">
380
+ <div class="input-group">
381
+ <input type="text" class="form-control chat-input" id="chatInput"
382
+ placeholder="Ask me about your projects..."
383
+ onkeypress="handleKeyPress(event)">
384
+ <button class="btn btn-send" onclick="sendMessage()">
385
+ <i class="fas fa-paper-plane"></i>
386
+ </button>
387
+ </div>
388
+ </div>
389
+ </div>
390
+ </div>
391
+ </div>
392
+ </div>
393
+
394
+ <script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0/dist/js/bootstrap.bundle.min.js"></script>
395
+ <script>
396
+ // Initialize Charts
397
+ const projectCtx = document.getElementById('projectChart').getContext('2d');
398
+ const projectChart = new Chart(projectCtx, {
399
+ type: 'pie',
400
+ data: {
401
+ labels: ['E-commerce', 'Mobile App', 'Data Analytics', 'AI Chatbot', 'Others'],
402
+ datasets: [{
403
+ data: [30, 25, 20, 15, 10],
404
+ backgroundColor: [
405
+ '#e74c3c',
406
+ '#3498db',
407
+ '#f39c12',
408
+ '#27ae60',
409
+ '#9b59b6'
410
+ ],
411
+ borderWidth: 2,
412
+ borderColor: '#fff'
413
+ }]
414
+ },
415
+ options: {
416
+ responsive: true,
417
+ maintainAspectRatio: false,
418
+ plugins: {
419
+ legend: {
420
+ position: 'bottom',
421
+ labels: {
422
+ padding: 15,
423
+ usePointStyle: true
424
+ }
425
+ }
426
+ }
427
+ }
428
+ });
429
+
430
+ const taskCtx = document.getElementById('taskChart').getContext('2d');
431
+ const taskChart = new Chart(taskCtx, {
432
+ type: 'doughnut',
433
+ data: {
434
+ labels: ['Completed', 'In Progress', 'On Hold', 'Pending'],
435
+ datasets: [{
436
+ data: [45, 30, 15, 10],
437
+ backgroundColor: [
438
+ '#27ae60',
439
+ '#3498db',
440
+ '#f39c12',
441
+ '#e74c3c'
442
+ ],
443
+ borderWidth: 2,
444
+ borderColor: '#fff'
445
+ }]
446
+ },
447
+ options: {
448
+ responsive: true,
449
+ maintainAspectRatio: false,
450
+ plugins: {
451
+ legend: {
452
+ position: 'bottom',
453
+ labels: {
454
+ padding: 15,
455
+ usePointStyle: true
456
+ }
457
+ }
458
+ }
459
+ }
460
+ });
461
+
462
+ // Chat functionality
463
+ function addMessage(message, isUser = false) {
464
+ const chatMessages = document.getElementById('chatMessages');
465
+ const messageDiv = document.createElement('div');
466
+ messageDiv.className = `message ${isUser ? 'user' : 'bot'}`;
467
+
468
+ const bubbleDiv = document.createElement('div');
469
+ bubbleDiv.className = 'message-bubble';
470
+ bubbleDiv.textContent = message;
471
+
472
+ messageDiv.appendChild(bubbleDiv);
473
+ chatMessages.appendChild(messageDiv);
474
+
475
+ // Scroll to bottom
476
+ chatMessages.scrollTop = chatMessages.scrollHeight;
477
+ }
478
+
479
+ function showLoading(show) {
480
+ const loadingIndicator = document.getElementById('loadingIndicator');
481
+ loadingIndicator.style.display = show ? 'block' : 'none';
482
+ }
483
+
484
+ async function sendMessage() {
485
+ const chatInput = document.getElementById('chatInput');
486
+ const message = chatInput.value.trim();
487
+
488
+ if (!message) return;
489
+
490
+ // Add user message
491
+ addMessage(message, true);
492
+ chatInput.value = '';
493
+
494
+ // Show loading
495
+ showLoading(true);
496
+
497
+ try {
498
+ const response = await fetch('/chat', {
499
+ method: 'POST',
500
+ headers: {
501
+ 'Content-Type': 'application/json',
502
+ },
503
+ body: JSON.stringify({ query: message })
504
+ });
505
+
506
+ const data = await response.json();
507
+
508
+ // Hide loading
509
+ showLoading(false);
510
+
511
+ // Add bot response
512
+ addMessage(data.answer || 'Sorry, I could not process your request.');
513
+
514
+ } catch (error) {
515
+ console.error('Error:', error);
516
+ showLoading(false);
517
+ addMessage('Sorry, there was an error processing your request. Please try again.');
518
+ }
519
+ }
520
+
521
+ function handleKeyPress(event) {
522
+ if (event.key === 'Enter') {
523
+ sendMessage();
524
+ }
525
+ }
526
+
527
+ // Auto-focus chat input
528
+ document.getElementById('chatInput').focus();
529
+ </script>
530
+ </body>
531
+ </html>