File size: 8,409 Bytes
7df743a
 
 
 
 
 
d3eadf4
7df743a
d3eadf4
 
 
 
 
 
 
 
 
 
 
 
 
 
 
7df743a
 
 
d3eadf4
 
 
 
 
 
 
 
7df743a
d3eadf4
 
 
 
 
7df743a
 
 
 
d3eadf4
 
 
 
7df743a
d3eadf4
 
 
 
 
 
7df743a
d3eadf4
 
 
 
 
 
7df743a
 
d3eadf4
 
 
 
 
 
 
 
 
 
 
7df743a
d3eadf4
 
 
 
 
7df743a
d3eadf4
 
7df743a
d3eadf4
 
 
 
 
 
 
 
 
7df743a
d3eadf4
 
 
 
 
 
 
 
 
 
 
 
7df743a
d3eadf4
7df743a
d3eadf4
7df743a
 
d3eadf4
 
 
7df743a
d3eadf4
 
 
 
7df743a
d3eadf4
 
 
 
 
 
 
 
 
7df743a
d3eadf4
 
 
 
 
 
 
7df743a
d3eadf4
 
 
 
 
7df743a
e4cb1f1
d3eadf4
 
 
e4cb1f1
 
d3eadf4
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
e4cb1f1
 
 
d3eadf4
e4cb1f1
 
 
d3eadf4
 
 
 
 
 
 
 
 
 
 
 
 
 
 
e4cb1f1
7df743a
 
 
d3eadf4
 
 
 
 
 
e4cb1f1
d3eadf4
 
 
 
 
 
 
 
 
 
 
7df743a
d3eadf4
 
 
 
 
 
 
 
7df743a
 
d3eadf4
 
 
7df743a
 
 
d3eadf4
 
 
 
 
 
 
 
e4cb1f1
d3eadf4
 
 
 
 
e4cb1f1
d3eadf4
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
e4cb1f1
d3eadf4
7df743a
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
<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8" />
  <meta name="viewport" content="width=device-width, initial-scale=1">
  <title>Upload Database</title>
  <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.4.0/css/all.min.css">
  <style>
    :root {
      --primary: #10a37f;
      --primary-dark: #0d8a6a;
      --bg-color: #343541;
      --chat-bg: #444654;
      --user-bg: #343541;
      --text-color: #ececf1;
      --text-secondary: #acacbe;
      --border-color: #565869;
      --error-color: #ef4146;
      --warning-color: #f0b72f;
    }

    * {
      box-sizing: border-box;
      margin: 0;
      padding: 0;
    }

    body {
      background-color: var(--bg-color);
      color: var(--text-color);
      font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
      display: flex;
      flex-direction: column;
      min-height: 100vh;
    }

    nav {
      background-color: var(--user-bg);
      padding: 12px 20px;
      border-bottom: 1px solid var(--border-color);
      display: flex;
      justify-content: space-between;
      align-items: center;
    }

    .nav-title {
      font-size: 1.2rem;
      font-weight: 600;
    }

    .btn {
      background-color: var(--primary);
      color: white;
      border: none;
      border-radius: 4px;
      padding: 8px 12px;
      font-size: 0.9rem;
      cursor: pointer;
      display: flex;
      align-items: center;
      gap: 6px;
      transition: background-color 0.2s;
      text-decoration: none;
    }

    .btn:hover {
      background-color: var(--primary-dark);
    }

    main {
      flex: 1;
      display: flex;
      flex-direction: column;
      align-items: center;
      padding: 40px 20px;
    }

    .upload-container {
      max-width: 600px;
      width: 100%;
      background-color: var(--chat-bg);
      border-radius: 8px;
      padding: 30px;
      box-shadow: 0 4px 12px rgba(0,0,0,0.1);
    }

    .upload-header {
      margin-bottom: 24px;
      text-align: center;
    }

    .upload-header h1 {
      font-size: 1.5rem;
      margin-bottom: 8px;
    }

    .upload-header p {
      color: var(--text-secondary);
      font-size: 0.9rem;
    }

    .upload-icon {
      font-size: 2.5rem;
      color: var(--primary);
      margin-bottom: 16px;
    }

    .form-group {
      margin-bottom: 20px;
    }

    .form-group label {
      display: block;
      margin-bottom: 8px;
      font-size: 0.9rem;
      color: var(--text-secondary);
    }

    .file-input-wrapper {
      position: relative;
      margin-bottom: 20px;
    }

    .file-input-label {
      display: flex;
      flex-direction: column;
      align-items: center;
      justify-content: center;
      padding: 40px 20px;
      border: 2px dashed var(--border-color);
      border-radius: 8px;
      cursor: pointer;
      transition: all 0.2s;
      text-align: center;
    }

    .file-input-label:hover {
      border-color: var(--primary);
      background-color: rgba(16, 163, 127, 0.05);
    }

    .file-input-label i {
      font-size: 2rem;
      color: var(--primary);
      margin-bottom: 12px;
    }

    .file-input-label span {
      font-size: 0.9rem;
      color: var(--text-secondary);
    }

    .file-input-label strong {
      color: var(--primary);
      font-weight: 600;
    }

    .file-input {
      position: absolute;
      width: 0.1px;
      height: 0.1px;
      opacity: 0;
      overflow: hidden;
      z-index: -1;
    }

    .file-name {
      margin-top: 8px;
      font-size: 0.9rem;
      color: var(--text-color);
      display: none;
    }

    .submit-btn {
      width: 100%;
      padding: 12px;
      font-size: 1rem;
      font-weight: 500;
    }

    .submit-btn:disabled {
      background-color: var(--border-color);
      cursor: not-allowed;
    }

    .alert {
      position: fixed;
      top: 20px;
      left: 50%;
      transform: translateX(-50%);
      padding: 12px 20px;
      border-radius: 8px;
      background-color: var(--error-color);
      color: white;
      z-index: 1000;
      display: flex;
      align-items: center;
      gap: 8px;
      box-shadow: 0 4px 12px rgba(0,0,0,0.15);
      animation: slideIn 0.3s ease-out;
    }

    .alert-success {
      background-color: var(--primary);
    }

    .alert-warning {
      background-color: var(--warning-color);
    }

    @keyframes slideIn {
      from { top: -50px; opacity: 0; }
      to { top: 20px; opacity: 1; }
    }

    footer {
      background-color: var(--user-bg);
      padding: 12px 20px;
      border-top: 1px solid var(--border-color);
      font-size: 0.8rem;
      color: var(--text-secondary);
      text-align: center;
    }
  </style>
</head>
<body>
  <nav>
    <div class="nav-title">Agent Chat</div>
    <a href="/" class="btn">
      <i class="fas fa-arrow-left"></i> Back to Chat
    </a>
  </nav>

  <main>
    <div class="upload-container">
      <div class="upload-header">
        <div class="upload-icon">
          <i class="fas fa-database"></i>
        </div>
        <h1>Upload Database</h1>
        <p>Select a SQLite database file to upload (.db extension)</p>
      </div>

      <form method="POST" action="/upload" enctype="multipart/form-data" id="uploadForm">
        <div class="form-group">
          <div class="file-input-wrapper">
            <input type="file" id="dbFile" name="file" accept=".db" class="file-input" required>
            <label for="dbFile" class="file-input-label" id="fileInputLabel">
              <i class="fas fa-cloud-upload-alt"></i>
              <span>Drag & drop your file here or <strong>browse</strong></span>
              <span class="file-name" id="fileName"></span>
            </label>
          </div>
        </div>
        <div class="form-group">
          <button type="submit" class="btn submit-btn" id="submitBtn" disabled>
            <i class="fas fa-upload"></i> Upload Database
          </button>
        </div>
      </form>
    </div>
  </main>

  <footer>
    <div>Agent Chat v1.0 · © 2023</div>
  </footer>

  <div id="flash-message" class="alert" style="display: none;"></div>

  <script>
    const fileInput = document.getElementById('dbFile');
    const fileInputLabel = document.getElementById('fileInputLabel');
    const fileName = document.getElementById('fileName');
    const submitBtn = document.getElementById('submitBtn');
    const uploadForm = document.getElementById('uploadForm');
    const flashMessage = document.getElementById('flash-message');

    // Handle file selection
    fileInput.addEventListener('change', function() {
      if (this.files.length > 0) {
        const file = this.files[0];
        fileName.textContent = file.name;
        fileName.style.display = 'block';
        submitBtn.disabled = false;
        
        // Update label text
        fileInputLabel.querySelector('span').textContent = 'Selected file:';
        fileInputLabel.querySelector('i').className = 'fas fa-check-circle';
        fileInputLabel.querySelector('i').style.color = 'var(--primary)';
      } else {
        fileName.style.display = 'none';
        submitBtn.disabled = true;
        
        // Reset label text
        fileInputLabel.querySelector('span').textContent = 'Drag & drop your file here or <strong>browse</strong>';
        fileInputLabel.querySelector('i').className = 'fas fa-cloud-upload-alt';
      }
    });

    // Handle drag and drop
    fileInputLabel.addEventListener('dragover', (e) => {
      e.preventDefault();
      fileInputLabel.style.borderColor = 'var(--primary)';
      fileInputLabel.style.backgroundColor = 'rgba(16, 163, 127, 0.1)';
    });

    fileInputLabel.addEventListener('dragleave', () => {
      fileInputLabel.style.borderColor = 'var(--border-color)';
      fileInputLabel.style.backgroundColor = 'transparent';
    });

    fileInputLabel.addEventListener('drop', (e) => {
      e.preventDefault();
      fileInputLabel.style.borderColor = 'var(--border-color)';
      fileInputLabel.style.backgroundColor = 'transparent';
      
      if (e.dataTransfer.files.length) {
        fileInput.files = e.dataTransfer.files;
        const event = new Event('change');
        fileInput.dispatchEvent(event);
      }
    });

    // Handle flash messages
    if (flashMessage) {
      setTimeout(() => {
        flashMessage.style.display = 'none';
      }, 3000);
    }
  </script>
</body>
</html>