Spaces:
Sleeping
Sleeping
Update templates/upload.html
Browse files- templates/upload.html +276 -93
templates/upload.html
CHANGED
|
@@ -4,146 +4,329 @@
|
|
| 4 |
<meta charset="UTF-8" />
|
| 5 |
<meta name="viewport" content="width=device-width, initial-scale=1">
|
| 6 |
<title>Upload Database</title>
|
|
|
|
| 7 |
<style>
|
| 8 |
-
|
| 9 |
-
|
| 10 |
-
|
| 11 |
-
color: #
|
| 12 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 13 |
margin: 0;
|
| 14 |
padding: 0;
|
| 15 |
}
|
| 16 |
-
|
| 17 |
-
|
| 18 |
-
|
| 19 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 20 |
}
|
| 21 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 22 |
display: flex;
|
| 23 |
justify-content: space-between;
|
| 24 |
align-items: center;
|
| 25 |
-
margin-bottom: 20px;
|
| 26 |
}
|
| 27 |
-
|
| 28 |
-
|
| 29 |
-
|
|
|
|
| 30 |
}
|
| 31 |
-
|
| 32 |
-
|
| 33 |
-
color:
|
|
|
|
|
|
|
|
|
|
| 34 |
padding: 8px 12px;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 35 |
text-decoration: none;
|
| 36 |
-
border-radius: 5px;
|
| 37 |
}
|
| 38 |
-
|
| 39 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 40 |
}
|
| 41 |
-
|
| 42 |
-
.
|
| 43 |
-
|
|
|
|
|
|
|
| 44 |
border-radius: 8px;
|
| 45 |
-
padding:
|
|
|
|
| 46 |
}
|
| 47 |
-
|
| 48 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 49 |
}
|
| 50 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 51 |
.form-group {
|
| 52 |
-
margin-bottom:
|
| 53 |
}
|
|
|
|
| 54 |
.form-group label {
|
| 55 |
display: block;
|
| 56 |
-
margin-bottom:
|
|
|
|
|
|
|
| 57 |
}
|
| 58 |
-
|
| 59 |
-
|
| 60 |
-
|
| 61 |
-
|
| 62 |
-
border: 1px solid #ccc;
|
| 63 |
-
width: 100%;
|
| 64 |
-
background-color: #eaeaea;
|
| 65 |
-
color: #333;
|
| 66 |
}
|
| 67 |
-
|
| 68 |
-
|
| 69 |
-
|
| 70 |
-
|
| 71 |
-
|
| 72 |
-
|
|
|
|
|
|
|
|
|
|
| 73 |
cursor: pointer;
|
| 74 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 75 |
}
|
| 76 |
-
|
| 77 |
-
|
|
|
|
|
|
|
|
|
|
| 78 |
}
|
| 79 |
|
| 80 |
-
.
|
| 81 |
-
|
| 82 |
-
|
| 83 |
-
border-radius: 5px;
|
| 84 |
-
text-align: center;
|
| 85 |
-
position: absolute;
|
| 86 |
-
position-area: top center;
|
| 87 |
-
top: 30px;
|
| 88 |
-
align-items: center;
|
| 89 |
}
|
| 90 |
|
| 91 |
-
.
|
| 92 |
-
|
| 93 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 94 |
}
|
| 95 |
|
| 96 |
.alert-success {
|
| 97 |
-
|
| 98 |
-
color: #ffffff;
|
| 99 |
}
|
| 100 |
|
| 101 |
.alert-warning {
|
| 102 |
-
|
| 103 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 104 |
}
|
| 105 |
-
|
| 106 |
</style>
|
| 107 |
</head>
|
| 108 |
<body>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 109 |
|
| 110 |
-
<
|
| 111 |
-
|
| 112 |
-
|
| 113 |
-
|
| 114 |
-
|
| 115 |
-
|
| 116 |
-
|
| 117 |
-
|
| 118 |
-
|
| 119 |
-
|
| 120 |
-
|
| 121 |
-
<header>
|
| 122 |
-
<h1>Upload Database</h1>
|
| 123 |
-
<!-- Optional: Back link to main chat page -->
|
| 124 |
-
<a href="/" class="back-btn">Back to Chat</a>
|
| 125 |
-
</header>
|
| 126 |
-
<div class="form-container">
|
| 127 |
-
<h2>Upload a SQLite DB file</h2>
|
| 128 |
-
<form method="POST" action="/upload" enctype="multipart/form-data">
|
| 129 |
<div class="form-group">
|
| 130 |
-
<
|
| 131 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 132 |
</div>
|
| 133 |
<div class="form-group">
|
| 134 |
-
<button type="submit">
|
|
|
|
|
|
|
| 135 |
</div>
|
| 136 |
</form>
|
| 137 |
</div>
|
| 138 |
-
</
|
| 139 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 140 |
<script>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 141 |
const flashMessage = document.getElementById('flash-message');
|
| 142 |
-
|
| 143 |
-
|
| 144 |
-
|
| 145 |
-
|
| 146 |
-
|
| 147 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 148 |
</script>
|
|
|
|
| 149 |
</html>
|
|
|
|
| 4 |
<meta charset="UTF-8" />
|
| 5 |
<meta name="viewport" content="width=device-width, initial-scale=1">
|
| 6 |
<title>Upload Database</title>
|
| 7 |
+
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.4.0/css/all.min.css">
|
| 8 |
<style>
|
| 9 |
+
:root {
|
| 10 |
+
--primary: #10a37f;
|
| 11 |
+
--primary-dark: #0d8a6a;
|
| 12 |
+
--bg-color: #343541;
|
| 13 |
+
--chat-bg: #444654;
|
| 14 |
+
--user-bg: #343541;
|
| 15 |
+
--text-color: #ececf1;
|
| 16 |
+
--text-secondary: #acacbe;
|
| 17 |
+
--border-color: #565869;
|
| 18 |
+
--error-color: #ef4146;
|
| 19 |
+
--warning-color: #f0b72f;
|
| 20 |
+
}
|
| 21 |
+
|
| 22 |
+
* {
|
| 23 |
+
box-sizing: border-box;
|
| 24 |
margin: 0;
|
| 25 |
padding: 0;
|
| 26 |
}
|
| 27 |
+
|
| 28 |
+
body {
|
| 29 |
+
background-color: var(--bg-color);
|
| 30 |
+
color: var(--text-color);
|
| 31 |
+
font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
|
| 32 |
+
display: flex;
|
| 33 |
+
flex-direction: column;
|
| 34 |
+
min-height: 100vh;
|
| 35 |
}
|
| 36 |
+
|
| 37 |
+
nav {
|
| 38 |
+
background-color: var(--user-bg);
|
| 39 |
+
padding: 12px 20px;
|
| 40 |
+
border-bottom: 1px solid var(--border-color);
|
| 41 |
display: flex;
|
| 42 |
justify-content: space-between;
|
| 43 |
align-items: center;
|
|
|
|
| 44 |
}
|
| 45 |
+
|
| 46 |
+
.nav-title {
|
| 47 |
+
font-size: 1.2rem;
|
| 48 |
+
font-weight: 600;
|
| 49 |
}
|
| 50 |
+
|
| 51 |
+
.btn {
|
| 52 |
+
background-color: var(--primary);
|
| 53 |
+
color: white;
|
| 54 |
+
border: none;
|
| 55 |
+
border-radius: 4px;
|
| 56 |
padding: 8px 12px;
|
| 57 |
+
font-size: 0.9rem;
|
| 58 |
+
cursor: pointer;
|
| 59 |
+
display: flex;
|
| 60 |
+
align-items: center;
|
| 61 |
+
gap: 6px;
|
| 62 |
+
transition: background-color 0.2s;
|
| 63 |
text-decoration: none;
|
|
|
|
| 64 |
}
|
| 65 |
+
|
| 66 |
+
.btn:hover {
|
| 67 |
+
background-color: var(--primary-dark);
|
| 68 |
+
}
|
| 69 |
+
|
| 70 |
+
main {
|
| 71 |
+
flex: 1;
|
| 72 |
+
display: flex;
|
| 73 |
+
flex-direction: column;
|
| 74 |
+
align-items: center;
|
| 75 |
+
padding: 40px 20px;
|
| 76 |
}
|
| 77 |
+
|
| 78 |
+
.upload-container {
|
| 79 |
+
max-width: 600px;
|
| 80 |
+
width: 100%;
|
| 81 |
+
background-color: var(--chat-bg);
|
| 82 |
border-radius: 8px;
|
| 83 |
+
padding: 30px;
|
| 84 |
+
box-shadow: 0 4px 12px rgba(0,0,0,0.1);
|
| 85 |
}
|
| 86 |
+
|
| 87 |
+
.upload-header {
|
| 88 |
+
margin-bottom: 24px;
|
| 89 |
+
text-align: center;
|
| 90 |
+
}
|
| 91 |
+
|
| 92 |
+
.upload-header h1 {
|
| 93 |
+
font-size: 1.5rem;
|
| 94 |
+
margin-bottom: 8px;
|
| 95 |
}
|
| 96 |
+
|
| 97 |
+
.upload-header p {
|
| 98 |
+
color: var(--text-secondary);
|
| 99 |
+
font-size: 0.9rem;
|
| 100 |
+
}
|
| 101 |
+
|
| 102 |
+
.upload-icon {
|
| 103 |
+
font-size: 2.5rem;
|
| 104 |
+
color: var(--primary);
|
| 105 |
+
margin-bottom: 16px;
|
| 106 |
+
}
|
| 107 |
+
|
| 108 |
.form-group {
|
| 109 |
+
margin-bottom: 20px;
|
| 110 |
}
|
| 111 |
+
|
| 112 |
.form-group label {
|
| 113 |
display: block;
|
| 114 |
+
margin-bottom: 8px;
|
| 115 |
+
font-size: 0.9rem;
|
| 116 |
+
color: var(--text-secondary);
|
| 117 |
}
|
| 118 |
+
|
| 119 |
+
.file-input-wrapper {
|
| 120 |
+
position: relative;
|
| 121 |
+
margin-bottom: 20px;
|
|
|
|
|
|
|
|
|
|
|
|
|
| 122 |
}
|
| 123 |
+
|
| 124 |
+
.file-input-label {
|
| 125 |
+
display: flex;
|
| 126 |
+
flex-direction: column;
|
| 127 |
+
align-items: center;
|
| 128 |
+
justify-content: center;
|
| 129 |
+
padding: 40px 20px;
|
| 130 |
+
border: 2px dashed var(--border-color);
|
| 131 |
+
border-radius: 8px;
|
| 132 |
cursor: pointer;
|
| 133 |
+
transition: all 0.2s;
|
| 134 |
+
text-align: center;
|
| 135 |
+
}
|
| 136 |
+
|
| 137 |
+
.file-input-label:hover {
|
| 138 |
+
border-color: var(--primary);
|
| 139 |
+
background-color: rgba(16, 163, 127, 0.05);
|
| 140 |
}
|
| 141 |
+
|
| 142 |
+
.file-input-label i {
|
| 143 |
+
font-size: 2rem;
|
| 144 |
+
color: var(--primary);
|
| 145 |
+
margin-bottom: 12px;
|
| 146 |
}
|
| 147 |
|
| 148 |
+
.file-input-label span {
|
| 149 |
+
font-size: 0.9rem;
|
| 150 |
+
color: var(--text-secondary);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 151 |
}
|
| 152 |
|
| 153 |
+
.file-input-label strong {
|
| 154 |
+
color: var(--primary);
|
| 155 |
+
font-weight: 600;
|
| 156 |
+
}
|
| 157 |
+
|
| 158 |
+
.file-input {
|
| 159 |
+
position: absolute;
|
| 160 |
+
width: 0.1px;
|
| 161 |
+
height: 0.1px;
|
| 162 |
+
opacity: 0;
|
| 163 |
+
overflow: hidden;
|
| 164 |
+
z-index: -1;
|
| 165 |
+
}
|
| 166 |
+
|
| 167 |
+
.file-name {
|
| 168 |
+
margin-top: 8px;
|
| 169 |
+
font-size: 0.9rem;
|
| 170 |
+
color: var(--text-color);
|
| 171 |
+
display: none;
|
| 172 |
+
}
|
| 173 |
+
|
| 174 |
+
.submit-btn {
|
| 175 |
+
width: 100%;
|
| 176 |
+
padding: 12px;
|
| 177 |
+
font-size: 1rem;
|
| 178 |
+
font-weight: 500;
|
| 179 |
+
}
|
| 180 |
+
|
| 181 |
+
.submit-btn:disabled {
|
| 182 |
+
background-color: var(--border-color);
|
| 183 |
+
cursor: not-allowed;
|
| 184 |
+
}
|
| 185 |
+
|
| 186 |
+
.alert {
|
| 187 |
+
position: fixed;
|
| 188 |
+
top: 20px;
|
| 189 |
+
left: 50%;
|
| 190 |
+
transform: translateX(-50%);
|
| 191 |
+
padding: 12px 20px;
|
| 192 |
+
border-radius: 8px;
|
| 193 |
+
background-color: var(--error-color);
|
| 194 |
+
color: white;
|
| 195 |
+
z-index: 1000;
|
| 196 |
+
display: flex;
|
| 197 |
+
align-items: center;
|
| 198 |
+
gap: 8px;
|
| 199 |
+
box-shadow: 0 4px 12px rgba(0,0,0,0.15);
|
| 200 |
+
animation: slideIn 0.3s ease-out;
|
| 201 |
}
|
| 202 |
|
| 203 |
.alert-success {
|
| 204 |
+
background-color: var(--primary);
|
|
|
|
| 205 |
}
|
| 206 |
|
| 207 |
.alert-warning {
|
| 208 |
+
background-color: var(--warning-color);
|
| 209 |
+
}
|
| 210 |
+
|
| 211 |
+
@keyframes slideIn {
|
| 212 |
+
from { top: -50px; opacity: 0; }
|
| 213 |
+
to { top: 20px; opacity: 1; }
|
| 214 |
+
}
|
| 215 |
+
|
| 216 |
+
footer {
|
| 217 |
+
background-color: var(--user-bg);
|
| 218 |
+
padding: 12px 20px;
|
| 219 |
+
border-top: 1px solid var(--border-color);
|
| 220 |
+
font-size: 0.8rem;
|
| 221 |
+
color: var(--text-secondary);
|
| 222 |
+
text-align: center;
|
| 223 |
}
|
|
|
|
| 224 |
</style>
|
| 225 |
</head>
|
| 226 |
<body>
|
| 227 |
+
<nav>
|
| 228 |
+
<div class="nav-title">Agent Chat</div>
|
| 229 |
+
<a href="/" class="btn">
|
| 230 |
+
<i class="fas fa-arrow-left"></i> Back to Chat
|
| 231 |
+
</a>
|
| 232 |
+
</nav>
|
| 233 |
|
| 234 |
+
<main>
|
| 235 |
+
<div class="upload-container">
|
| 236 |
+
<div class="upload-header">
|
| 237 |
+
<div class="upload-icon">
|
| 238 |
+
<i class="fas fa-database"></i>
|
| 239 |
+
</div>
|
| 240 |
+
<h1>Upload Database</h1>
|
| 241 |
+
<p>Select a SQLite database file to upload (.db extension)</p>
|
| 242 |
+
</div>
|
| 243 |
+
|
| 244 |
+
<form method="POST" action="/upload" enctype="multipart/form-data" id="uploadForm">
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 245 |
<div class="form-group">
|
| 246 |
+
<div class="file-input-wrapper">
|
| 247 |
+
<input type="file" id="dbFile" name="file" accept=".db" class="file-input" required>
|
| 248 |
+
<label for="dbFile" class="file-input-label" id="fileInputLabel">
|
| 249 |
+
<i class="fas fa-cloud-upload-alt"></i>
|
| 250 |
+
<span>Drag & drop your file here or <strong>browse</strong></span>
|
| 251 |
+
<span class="file-name" id="fileName"></span>
|
| 252 |
+
</label>
|
| 253 |
+
</div>
|
| 254 |
</div>
|
| 255 |
<div class="form-group">
|
| 256 |
+
<button type="submit" class="btn submit-btn" id="submitBtn" disabled>
|
| 257 |
+
<i class="fas fa-upload"></i> Upload Database
|
| 258 |
+
</button>
|
| 259 |
</div>
|
| 260 |
</form>
|
| 261 |
</div>
|
| 262 |
+
</main>
|
| 263 |
+
|
| 264 |
+
<footer>
|
| 265 |
+
<div>Agent Chat v1.0 路 漏 2023</div>
|
| 266 |
+
</footer>
|
| 267 |
+
|
| 268 |
+
<div id="flash-message" class="alert" style="display: none;"></div>
|
| 269 |
+
|
| 270 |
<script>
|
| 271 |
+
const fileInput = document.getElementById('dbFile');
|
| 272 |
+
const fileInputLabel = document.getElementById('fileInputLabel');
|
| 273 |
+
const fileName = document.getElementById('fileName');
|
| 274 |
+
const submitBtn = document.getElementById('submitBtn');
|
| 275 |
+
const uploadForm = document.getElementById('uploadForm');
|
| 276 |
const flashMessage = document.getElementById('flash-message');
|
| 277 |
+
|
| 278 |
+
// Handle file selection
|
| 279 |
+
fileInput.addEventListener('change', function() {
|
| 280 |
+
if (this.files.length > 0) {
|
| 281 |
+
const file = this.files[0];
|
| 282 |
+
fileName.textContent = file.name;
|
| 283 |
+
fileName.style.display = 'block';
|
| 284 |
+
submitBtn.disabled = false;
|
| 285 |
+
|
| 286 |
+
// Update label text
|
| 287 |
+
fileInputLabel.querySelector('span').textContent = 'Selected file:';
|
| 288 |
+
fileInputLabel.querySelector('i').className = 'fas fa-check-circle';
|
| 289 |
+
fileInputLabel.querySelector('i').style.color = 'var(--primary)';
|
| 290 |
+
} else {
|
| 291 |
+
fileName.style.display = 'none';
|
| 292 |
+
submitBtn.disabled = true;
|
| 293 |
+
|
| 294 |
+
// Reset label text
|
| 295 |
+
fileInputLabel.querySelector('span').textContent = 'Drag & drop your file here or <strong>browse</strong>';
|
| 296 |
+
fileInputLabel.querySelector('i').className = 'fas fa-cloud-upload-alt';
|
| 297 |
+
}
|
| 298 |
+
});
|
| 299 |
+
|
| 300 |
+
// Handle drag and drop
|
| 301 |
+
fileInputLabel.addEventListener('dragover', (e) => {
|
| 302 |
+
e.preventDefault();
|
| 303 |
+
fileInputLabel.style.borderColor = 'var(--primary)';
|
| 304 |
+
fileInputLabel.style.backgroundColor = 'rgba(16, 163, 127, 0.1)';
|
| 305 |
+
});
|
| 306 |
+
|
| 307 |
+
fileInputLabel.addEventListener('dragleave', () => {
|
| 308 |
+
fileInputLabel.style.borderColor = 'var(--border-color)';
|
| 309 |
+
fileInputLabel.style.backgroundColor = 'transparent';
|
| 310 |
+
});
|
| 311 |
+
|
| 312 |
+
fileInputLabel.addEventListener('drop', (e) => {
|
| 313 |
+
e.preventDefault();
|
| 314 |
+
fileInputLabel.style.borderColor = 'var(--border-color)';
|
| 315 |
+
fileInputLabel.style.backgroundColor = 'transparent';
|
| 316 |
+
|
| 317 |
+
if (e.dataTransfer.files.length) {
|
| 318 |
+
fileInput.files = e.dataTransfer.files;
|
| 319 |
+
const event = new Event('change');
|
| 320 |
+
fileInput.dispatchEvent(event);
|
| 321 |
+
}
|
| 322 |
+
});
|
| 323 |
+
|
| 324 |
+
// Handle flash messages
|
| 325 |
+
if (flashMessage) {
|
| 326 |
+
setTimeout(() => {
|
| 327 |
+
flashMessage.style.display = 'none';
|
| 328 |
+
}, 3000);
|
| 329 |
+
}
|
| 330 |
</script>
|
| 331 |
+
</body>
|
| 332 |
</html>
|