|
68 | 68 | .search-form .form-check { |
69 | 69 | margin-top: 0.5rem; |
70 | 70 | } |
| 71 | + .config-button { |
| 72 | + position: fixed; |
| 73 | + top: 10px; |
| 74 | + right: 10px; |
| 75 | + z-index: 1000; |
| 76 | + } |
71 | 77 | </style> |
72 | 78 | <style> |
73 | 79 | #filesNavigator { |
|
88 | 94 | </style> |
89 | 95 | </head> |
90 | 96 | <body> |
| 97 | + <!-- Configuration Button --> |
| 98 | + <button class="btn btn-outline-secondary btn-sm config-button" onclick="showConfigModal()" title="Configure API URL"> |
| 99 | + <i class="fa-solid fa-cog"></i> |
| 100 | + </button> |
| 101 | + |
91 | 102 | <div class="sidebar"> |
92 | 103 | <h4 class="mb-4">CSV File Manager</h4> |
93 | 104 |
|
@@ -164,6 +175,29 @@ <h4>${filename}</h4> |
164 | 175 | </template> |
165 | 176 | </div> |
166 | 177 |
|
| 178 | + <!-- Configuration Modal --> |
| 179 | + <div class="modal fade" id="configModal" tabindex="-1"> |
| 180 | + <div class="modal-dialog"> |
| 181 | + <div class="modal-content"> |
| 182 | + <div class="modal-header"> |
| 183 | + <h5 class="modal-title">API Configuration</h5> |
| 184 | + <button type="button" class="btn-close" data-bs-dismiss="modal"></button> |
| 185 | + </div> |
| 186 | + <div class="modal-body"> |
| 187 | + <div class="form-group mb-3"> |
| 188 | + <label for="apiUrl" class="form-label">API URL</label> |
| 189 | + <input type="url" class="form-control" id="apiUrl" placeholder="https://example.com/api.php"> |
| 190 | + <div class="form-text">Enter the full URL to your CSV API endpoint</div> |
| 191 | + </div> |
| 192 | + </div> |
| 193 | + <div class="modal-footer"> |
| 194 | + <button type="button" class="btn btn-secondary" data-bs-dismiss="modal">Cancel</button> |
| 195 | + <button type="button" class="btn btn-primary" onclick="saveConfig()">Save</button> |
| 196 | + </div> |
| 197 | + </div> |
| 198 | + </div> |
| 199 | + </div> |
| 200 | + |
167 | 201 | <!-- Edit Modal --> |
168 | 202 | <div class="modal fade" id="editModal" tabindex="-1"> |
169 | 203 | <div class="modal-dialog"> |
@@ -199,12 +233,50 @@ <h5 class="modal-title">New Record</h5> |
199 | 233 | </div> |
200 | 234 |
|
201 | 235 | <script> |
202 | | - const API_URL = 'api.php'; |
| 236 | + let API_URL = 'api.php'; |
203 | 237 | let currentFile = null; |
204 | 238 | let currentPage = 0; |
205 | 239 | let pageSize = 50; |
206 | 240 | let authToken = null; |
207 | 241 |
|
| 242 | + // Configuration functions |
| 243 | + function loadConfig() { |
| 244 | + const savedApiUrl = localStorage.getItem('csvApiUrl'); |
| 245 | + if (savedApiUrl) { |
| 246 | + API_URL = savedApiUrl; |
| 247 | + } |
| 248 | + } |
| 249 | + |
| 250 | + function showConfigModal() { |
| 251 | + document.getElementById('apiUrl').value = API_URL; |
| 252 | + new bootstrap.Modal(document.getElementById('configModal')).show(); |
| 253 | + } |
| 254 | + |
| 255 | + function saveConfig() { |
| 256 | + const newApiUrl = document.getElementById('apiUrl').value.trim(); |
| 257 | + if (!newApiUrl) { |
| 258 | + alert('Please enter a valid API URL'); |
| 259 | + return; |
| 260 | + } |
| 261 | + |
| 262 | + // Validate URL format |
| 263 | + try { |
| 264 | + new URL(newApiUrl); |
| 265 | + } catch (e) { |
| 266 | + alert('Please enter a valid URL'); |
| 267 | + return; |
| 268 | + } |
| 269 | + |
| 270 | + API_URL = newApiUrl; |
| 271 | + localStorage.setItem('csvApiUrl', newApiUrl); |
| 272 | + |
| 273 | + // Close modal |
| 274 | + bootstrap.Modal.getInstance(document.getElementById('configModal')).hide(); |
| 275 | + |
| 276 | + // Show success message |
| 277 | + alert('API URL saved successfully!'); |
| 278 | + } |
| 279 | + |
208 | 280 | // Input sanitization functions |
209 | 281 | function sanitizeInput(input) { |
210 | 282 | if (typeof input !== 'string') return input; |
@@ -504,8 +576,9 @@ <h5 class="modal-title">New Record</h5> |
504 | 576 | }); |
505 | 577 | } |
506 | 578 |
|
507 | | - // Check for existing token on page load |
| 579 | + // Initialize on page load |
508 | 580 | $(document).ready(function() { |
| 581 | + loadConfig(); |
509 | 582 | checkExistingToken(); |
510 | 583 | }); |
511 | 584 | </script> |
|
0 commit comments