Spaces:
Running
Running
| {% extends 'base.html' %} | |
| {% block content %} | |
| <style> | |
| html, body { | |
| height: 50%; | |
| margin: 0; | |
| } | |
| .container { | |
| display: flex; | |
| flex-direction: column; | |
| height: 80vh; /* Fill the viewport height */ | |
| } | |
| .card { | |
| margin: auto; | |
| background-color: #2c2c3e; | |
| color: #f5f5f5; | |
| border: none; | |
| width: 50%; | |
| height: 70%; /* Fixed height for the card */ | |
| display: flex; | |
| flex-direction: column; | |
| justify-content: space-between; | |
| padding: 1rem; | |
| } | |
| .card-header { | |
| background-color: #181831; | |
| border-bottom: 2px solid #444; | |
| padding: 1rem; | |
| text-align: center; | |
| } | |
| .form-label { | |
| font-weight: bold; | |
| color: #cfcfcf; | |
| } | |
| .form-control { | |
| background-color: #1e1e2f; | |
| color: #f5f5f5; | |
| border: 1px solid #444; | |
| } | |
| .form-control:focus { | |
| background-color: #1e1e2f; | |
| color: #f5f5f5; | |
| border-color: #4c4cff; | |
| box-shadow: 0 0 4px #4c4cff; | |
| } | |
| .btn-primary { | |
| background-color: #4c4cff; | |
| border-color: #4c4cff; | |
| display: flex; | |
| justify-content: center; | |
| align-items: center; | |
| } | |
| .btn-primary:hover { | |
| background-color: #3838e8; | |
| border-color: #3838e8; | |
| } | |
| .toggle-switch { | |
| margin: 1rem 0; | |
| display: flex; | |
| justify-content: center; | |
| align-items: center; | |
| } | |
| .toggle-switch input { | |
| display: none; | |
| } | |
| .toggle-label { | |
| background-color: #444; | |
| color: #cfcfcf; | |
| padding: 0.5rem 1.5rem; | |
| border: 1px solid #555; | |
| cursor: pointer; | |
| margin-right: 1rem; | |
| text-align: center; | |
| border-radius: 4px; | |
| } | |
| .toggle-label.active { | |
| background-color: #4c4cff; | |
| color: #fff; | |
| } | |
| .toggle-label:hover { | |
| background-color: #3838e8; | |
| color: #fff; | |
| } | |
| .hidden { | |
| display: none; | |
| } | |
| .text-center.d-flex { | |
| display: flex; | |
| justify-content: center; | |
| align-items: center; | |
| height: 100px; | |
| } | |
| .spinner { | |
| border: 4px solid #f3f3f3; /* Light grey */ | |
| border-top: 4px solid #4c4cff; /* Blue */ | |
| border-radius: 50%; | |
| width: 24px; | |
| height: 24px; | |
| animation: spin 1s linear infinite; | |
| margin-left: 10px; | |
| display: none; /* Initially hidden */ | |
| } | |
| @keyframes spin { | |
| 0% { transform: rotate(0deg); } | |
| 100% { transform: rotate(360deg); } | |
| } | |
| .alert { | |
| padding: 10px; | |
| margin-bottom: 10px; | |
| border-radius: 5px; | |
| text-align: center; | |
| position: absolute; | |
| position-area: top center; | |
| top: 30px; | |
| align-items: center; | |
| } | |
| .alert-error { | |
| background-color: #D84040; | |
| color: #ffffff; | |
| } | |
| .alert-success { | |
| background-color: #D2DE32; | |
| color: #ffffff; | |
| } | |
| .alert-warning { | |
| background-color: #FFC700; | |
| color: #ffffff; | |
| } | |
| </style> | |
| <div class="container-flash"> | |
| {% with messages = get_flashed_messages(with_categories=true) %} | |
| {% if messages %} | |
| <div id="flash-message" class="alert alert-{{ messages[0][0] }}"> | |
| <strong>{{ messages[0][1] }}</strong> | |
| </div> | |
| {% endif %} | |
| {% endwith %} | |
| </div> | |
| <div class="container mt-5"> | |
| <div class="card shadow"> | |
| <div class="card-header"> | |
| <h3>Create a New Vector Database</h3> | |
| </div> | |
| <div class="card-body"> | |
| <form id="db-form" method="post" enctype="multipart/form-data"> | |
| <!-- Database Name Input --> | |
| <div class="form-group"> | |
| <label for="db_name" class="form-label">Database Name</label> | |
| <input type="text" id="db_name" name="db_name" class="form-control" placeholder="Enter database name" required> | |
| </div> | |
| <!-- Toggle Upload Mode --> | |
| <div class="toggle-switch"> | |
| <label class="toggle-label active" id="folder-label" for="folder">Upload Folder</label> | |
| <label class="toggle-label" id="file-label" for="file">Upload Files</label> | |
| </div> | |
| <!-- Folder Upload Input --> | |
| <div id="folder-upload" class="form-group mt-3"> | |
| <label for="folder" class="form-label">Upload Folder</label> | |
| <input type="file" id="folder" name="folder" class="form-control" webkitdirectory directory multiple> | |
| <small class="text-muted">Note: You can upload a folder containing multiple files.</small> | |
| </div> | |
| <!-- Single File Upload Input --> | |
| <div id="file-upload" class="form-group mt-3 hidden"> | |
| <label for="file" class="form-label">Upload Files</label> | |
| <input type="file" id="file" name="file" class="form-control" multiple> | |
| <small class="text-muted">Note: You can upload one or more files.</small> | |
| </div> | |
| <!-- Submit Button --> | |
| <div class="mt-4 text-center d-flex justify-content-center align-items-center"> | |
| <button type="submit" class="btn btn-primary px-5" id="submit-btn"> | |
| <span class="btn-text">Create</span> | |
| <div class="spinner" id="spinner"></div> | |
| </button> | |
| </div> | |
| </form> | |
| </div> | |
| </div> | |
| </div> | |
| <script> | |
| const folderLabel = document.getElementById('folder-label'); | |
| const fileLabel = document.getElementById('file-label'); | |
| const folderUpload = document.getElementById('folder-upload'); | |
| const fileUpload = document.getElementById('file-upload'); | |
| const submitBtn = document.getElementById('submit-btn'); | |
| const spinner = document.getElementById('spinner'); | |
| const flashMessage = document.getElementById('flash-message'); | |
| //for flash message | |
| if (flashMessage) { | |
| setTimeout(function() { | |
| flashMessage.style.display = 'none'; | |
| }, 2000); // Hide after 2 seconds | |
| } | |
| // Toggle upload mode | |
| folderLabel.addEventListener('click', () => { | |
| folderLabel.classList.add('active'); | |
| fileLabel.classList.remove('active'); | |
| folderUpload.classList.remove('hidden'); | |
| fileUpload.classList.add('hidden'); | |
| }); | |
| fileLabel.addEventListener('click', () => { | |
| fileLabel.classList.add('active'); | |
| folderLabel.classList.remove('active'); | |
| fileUpload.classList.remove('hidden'); | |
| folderUpload.classList.add('hidden'); | |
| }); | |
| // Show loader when form is submitted | |
| document.getElementById('db-form').addEventListener('submit', function(event) { | |
| // Show the spinner and hide the text | |
| submitBtn.querySelector('.btn-text').style.display = 'none'; | |
| spinner.style.display = 'inline-block'; | |
| }); | |
| </script> | |
| {% endblock %} | |