Spaces:
Running
Running
| {% extends 'base.html' %} | |
| {% block content %} | |
| <style> | |
| html, body { | |
| height: 100%; | |
| margin: 0; | |
| } | |
| .container { | |
| display: flex; | |
| flex-direction: column; | |
| height: 75vh; /* 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; | |
| } | |
| /* Custom style for the dropdown with an arrow */ | |
| .form-control { | |
| position: relative; | |
| appearance: none; | |
| background-color: #1e1e2f; | |
| color: #f5f5f5; | |
| border: 1px solid #444; | |
| padding-right: 2rem; /* Space for the arrow */ | |
| } | |
| .form-control:focus { | |
| border-color: #4c4cff; | |
| box-shadow: 0 0 4px #4c4cff; | |
| } | |
| .form-control::after { | |
| content: '▼'; /* Down arrow */ | |
| position: absolute; | |
| right: 1rem; | |
| top: 50%; | |
| transform: translateY(-50%); | |
| pointer-events: none; | |
| font-size: 0.8rem; | |
| color: #4b4b74; | |
| } | |
| #list_doc { | |
| background-image: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="%23cfcfcf" class="bi bi-chevron-down" viewBox="0 0 16 16"><path fill-rule="evenodd" d="M1.646 4.646a.5.5 0 0 1 .708 0L8 10.293l5.646-5.647a.5.5 0 0 1 .708.708l-6 6a.5.5 0 0 1-.708 0l-6-6a.5.5 0 0 1 0-.708z"/></svg>'); | |
| background-repeat: no-repeat; | |
| background-position: right 1rem center; | |
| background-size: 1rem; | |
| } | |
| .btn-primary { | |
| background-color: #4c4cff; | |
| border-color: #4c4cff; | |
| display: flex; | |
| justify-content: center; | |
| align-items: center; | |
| position: relative; | |
| } | |
| .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; | |
| } | |
| .hidden { | |
| display: none; | |
| } | |
| .text-center.d-flex { | |
| display: flex; | |
| justify-content: center; | |
| align-items: center; | |
| height: 100px; | |
| } | |
| /* Spinner style */ | |
| .button-spinner { | |
| position: absolute; | |
| width: 24px; | |
| height: 24px; | |
| border: 4px solid #f5f5f5; | |
| border-top: 4px solid #4c4cff; | |
| border-radius: 50%; | |
| animation: spin 1s linear infinite; | |
| display: none; | |
| } | |
| /* Animation for the spinner */ | |
| @keyframes spin { | |
| 0% { transform: rotate(0deg); } | |
| 100% { transform: rotate(360deg); } | |
| } | |
| /* Hide spinner when not loading */ | |
| .btn-loading .button-spinner { | |
| display: inline-block; | |
| } | |
| .btn-loading .btn-text { | |
| display: none; | |
| } | |
| .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>Manage Database</h3> | |
| </div> | |
| <div class="card-body"> | |
| <form id="db-form" method="post" action="{{ url_for('delete_doc',db_name=db_name) }}"> | |
| <!-- Database Name (Read-Only) --> | |
| <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" value="{{ db_name }}" readonly> | |
| </div> | |
| <!-- File Selection --> | |
| <div class="form-group mt-3"> | |
| <label for="list_doc" class="form-label">Select a File to delete from menu</label> | |
| <select id="list_doc" name="list_doc" class="form-control" required> | |
| {% for file in file_list %} | |
| <option value="{{ file }}">{{ file }}</option> | |
| {% endfor %} | |
| </select> | |
| </div> | |
| <!-- Buttons --> | |
| <!-- <div class="text-center"> | |
| <button type="submit" class="btn btn-danger">Delete</button> | |
| </div> --> | |
| <!-- Submit Button --> | |
| <div class="mt-4 text-center d-flex justify-content-center align-items-center"> | |
| <button type="submit" class="btn btn-danger px-5" id="delete-button"> | |
| <span class="btn-text">Delete Document</span> | |
| <div class="button-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 submitButton = document.getElementById('delete-button'); | |
| const buttonSpinner = submitButton.querySelector('.button-spinner'); | |
| const flashMessage = document.getElementById('flash-message'); | |
| //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'); | |
| }); | |
| // Handle form submission | |
| document.getElementById('db-form').addEventListener('submit', function(event) { | |
| event.preventDefault(); // Prevent form submission for demonstration | |
| submitButton.classList.add('btn-loading'); | |
| // Simulate loading | |
| setTimeout(() => { | |
| // After form is "submitted" and loading is complete | |
| submitButton.classList.remove('btn-loading'); | |
| alert("Form submitted successfully!"); // Simulate success | |
| }, 2000); // 2 seconds for loading simulation | |
| }); | |
| </script> | |
| {% endblock %} | |