WebashalarForML commited on
Commit
f08a653
·
verified ·
1 Parent(s): 3ee0a6f

Upload 8 files

Browse files
templates/chat.html CHANGED
@@ -22,6 +22,15 @@
22
  gap: 30px;
23
  }
24
 
 
 
 
 
 
 
 
 
 
25
  .card {
26
  background: #2c2c3e;
27
  border-radius: 10px;
@@ -94,6 +103,14 @@
94
  margin-bottom: 10px;
95
  }
96
 
 
 
 
 
 
 
 
 
97
  /* History Section */
98
  .history-section {
99
  overflow-y: auto;
@@ -110,17 +127,41 @@
110
  margin-bottom: 10px;
111
  }
112
 
 
 
 
 
 
 
 
 
 
 
 
113
  .alert-error {
114
- background-color: #ff4d4d;
115
- color: white;
116
  }
117
 
118
- .alert-table_selected {
119
- background-color: #4dff74;
120
- color: white;
121
  }
122
 
 
 
 
 
123
  </style>
 
 
 
 
 
 
 
 
 
124
 
125
  <div class="container">
126
  <!-- Left Pane -->
@@ -146,6 +187,7 @@
146
  <hr>
147
  {{ answer }}
148
  </div>
 
149
  </div>
150
  {% endif %}
151
  </div>
@@ -166,6 +208,12 @@
166
  </div>
167
 
168
  <script>
 
 
 
 
 
 
169
  function showLoader() {
170
  document.getElementById('loader').style.display = 'block';
171
  document.querySelector('.answer-section')?.classList.add('d-none');
 
22
  gap: 30px;
23
  }
24
 
25
+ .container-flash {
26
+ display: flex;
27
+ height: 10vh;
28
+ margin-top: 10px;
29
+ align-items: center;
30
+ justify-content: center;
31
+ gap: 30px;
32
+ }
33
+
34
  .card {
35
  background: #2c2c3e;
36
  border-radius: 10px;
 
103
  margin-bottom: 10px;
104
  }
105
 
106
+ .token-count {
107
+ font-size: 12px;
108
+ color: #b0b0b0;
109
+ text-align: right;
110
+ margin-top: 10px;
111
+ font-style: italic;
112
+ }
113
+
114
  /* History Section */
115
  .history-section {
116
  overflow-y: auto;
 
127
  margin-bottom: 10px;
128
  }
129
 
130
+ .alert {
131
+ padding: 10px;
132
+ margin-bottom: 10px;
133
+ border-radius: 5px;
134
+ text-align: center;
135
+ position: absolute;
136
+ position-area: top center;
137
+ top: 30px;
138
+ align-items: center;
139
+ }
140
+
141
  .alert-error {
142
+ background-color: #D84040;
143
+ color: #ffffff;
144
  }
145
 
146
+ .alert-success {
147
+ background-color: #D2DE32;
148
+ color: #ffffff;
149
  }
150
 
151
+ .alert-warning {
152
+ background-color: #FFC700;
153
+ color: #ffffff;
154
+ }
155
  </style>
156
+ <div class="container-flash">
157
+ {% with messages = get_flashed_messages(with_categories=true) %}
158
+ {% if messages %}
159
+ <div id="flash-message" class="alert alert-{{ messages[0][0] }}">
160
+ <strong>{{ messages[0][1] }}</strong>
161
+ </div>
162
+ {% endif %}
163
+ {% endwith %}
164
+ </div>
165
 
166
  <div class="container">
167
  <!-- Left Pane -->
 
187
  <hr>
188
  {{ answer }}
189
  </div>
190
+ <div class="token-count">Tokens Used: {{ token_count }}</div>
191
  </div>
192
  {% endif %}
193
  </div>
 
208
  </div>
209
 
210
  <script>
211
+ const flashMessage = document.getElementById('flash-message');
212
+ if (flashMessage) {
213
+ setTimeout(function() {
214
+ flashMessage.style.display = 'none';
215
+ }, 2000); // Hide after 2 seconds
216
+ }
217
  function showLoader() {
218
  document.getElementById('loader').style.display = 'block';
219
  document.querySelector('.answer-section')?.classList.add('d-none');
templates/create_db.html CHANGED
@@ -122,7 +122,42 @@
122
  0% { transform: rotate(0deg); }
123
  100% { transform: rotate(360deg); }
124
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
125
  </style>
 
 
 
 
 
 
 
 
 
126
 
127
  <div class="container mt-5">
128
  <div class="card shadow">
@@ -176,7 +211,13 @@
176
  const fileUpload = document.getElementById('file-upload');
177
  const submitBtn = document.getElementById('submit-btn');
178
  const spinner = document.getElementById('spinner');
179
-
 
 
 
 
 
 
180
  // Toggle upload mode
181
  folderLabel.addEventListener('click', () => {
182
  folderLabel.classList.add('active');
 
122
  0% { transform: rotate(0deg); }
123
  100% { transform: rotate(360deg); }
124
  }
125
+
126
+ .alert {
127
+ padding: 10px;
128
+ margin-bottom: 10px;
129
+ border-radius: 5px;
130
+ text-align: center;
131
+ position: absolute;
132
+ position-area: top center;
133
+ top: 30px;
134
+ align-items: center;
135
+ }
136
+
137
+ .alert-error {
138
+ background-color: #D84040;
139
+ color: #ffffff;
140
+ }
141
+
142
+ .alert-success {
143
+ background-color: #D2DE32;
144
+ color: #ffffff;
145
+ }
146
+
147
+ .alert-warning {
148
+ background-color: #FFC700;
149
+ color: #ffffff;
150
+ }
151
  </style>
152
+ <div class="container-flash">
153
+ {% with messages = get_flashed_messages(with_categories=true) %}
154
+ {% if messages %}
155
+ <div id="flash-message" class="alert alert-{{ messages[0][0] }}">
156
+ <strong>{{ messages[0][1] }}</strong>
157
+ </div>
158
+ {% endif %}
159
+ {% endwith %}
160
+ </div>
161
 
162
  <div class="container mt-5">
163
  <div class="card shadow">
 
211
  const fileUpload = document.getElementById('file-upload');
212
  const submitBtn = document.getElementById('submit-btn');
213
  const spinner = document.getElementById('spinner');
214
+ const flashMessage = document.getElementById('flash-message');
215
+ //for flash message
216
+ if (flashMessage) {
217
+ setTimeout(function() {
218
+ flashMessage.style.display = 'none';
219
+ }, 2000); // Hide after 2 seconds
220
+ }
221
  // Toggle upload mode
222
  folderLabel.addEventListener('click', () => {
223
  folderLabel.classList.add('active');
templates/delete_doc.html ADDED
@@ -0,0 +1,273 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {% extends 'base.html' %}
2
+
3
+ {% block content %}
4
+ <style>
5
+ html, body {
6
+ height: 100%;
7
+ margin: 0;
8
+ }
9
+
10
+ .container {
11
+ display: flex;
12
+ flex-direction: column;
13
+ height: 75vh; /* Fill the viewport height */
14
+ }
15
+
16
+ .card {
17
+ margin: auto;
18
+ background-color: #2c2c3e;
19
+ color: #f5f5f5;
20
+ border: none;
21
+ width: 50%;
22
+ height: 70%; /* Fixed height for the card */
23
+ display: flex;
24
+ flex-direction: column;
25
+ justify-content: space-between;
26
+ padding: 1rem;
27
+ }
28
+
29
+ .card-header {
30
+ background-color: #181831;
31
+ border-bottom: 2px solid #444;
32
+ padding: 1rem;
33
+ text-align: center;
34
+ }
35
+
36
+ .form-label {
37
+ font-weight: bold;
38
+ color: #cfcfcf;
39
+ }
40
+
41
+ /* Custom style for the dropdown with an arrow */
42
+ .form-control {
43
+ position: relative;
44
+ appearance: none;
45
+ background-color: #1e1e2f;
46
+ color: #f5f5f5;
47
+ border: 1px solid #444;
48
+ padding-right: 2rem; /* Space for the arrow */
49
+ }
50
+
51
+ .form-control:focus {
52
+ border-color: #4c4cff;
53
+ box-shadow: 0 0 4px #4c4cff;
54
+ }
55
+
56
+ .form-control::after {
57
+ content: '▼'; /* Down arrow */
58
+ position: absolute;
59
+ right: 1rem;
60
+ top: 50%;
61
+ transform: translateY(-50%);
62
+ pointer-events: none;
63
+ font-size: 0.8rem;
64
+ color: #4b4b74;
65
+ }
66
+
67
+ #list_doc {
68
+ 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>');
69
+ background-repeat: no-repeat;
70
+ background-position: right 1rem center;
71
+ background-size: 1rem;
72
+ }
73
+
74
+ .btn-primary {
75
+ background-color: #4c4cff;
76
+ border-color: #4c4cff;
77
+ display: flex;
78
+ justify-content: center;
79
+ align-items: center;
80
+ position: relative;
81
+ }
82
+
83
+ .btn-primary:hover {
84
+ background-color: #3838e8;
85
+ border-color: #3838e8;
86
+ }
87
+
88
+ .toggle-switch {
89
+ margin: 1rem 0;
90
+ display: flex;
91
+ justify-content: center;
92
+ align-items: center;
93
+ }
94
+
95
+ .toggle-switch input {
96
+ display: none;
97
+ }
98
+
99
+ .toggle-label {
100
+ background-color: #444;
101
+ color: #cfcfcf;
102
+ padding: 0.5rem 1.5rem;
103
+ border: 1px solid #555;
104
+ cursor: pointer;
105
+ margin-right: 1rem;
106
+ text-align: center;
107
+ border-radius: 4px;
108
+ }
109
+
110
+ .toggle-label.active {
111
+ background-color: #4c4cff;
112
+ color: #fff;
113
+ }
114
+
115
+ .hidden {
116
+ display: none;
117
+ }
118
+
119
+ .text-center.d-flex {
120
+ display: flex;
121
+ justify-content: center;
122
+ align-items: center;
123
+ height: 100px;
124
+ }
125
+
126
+ /* Spinner style */
127
+ .button-spinner {
128
+ position: absolute;
129
+ width: 24px;
130
+ height: 24px;
131
+ border: 4px solid #f5f5f5;
132
+ border-top: 4px solid #4c4cff;
133
+ border-radius: 50%;
134
+ animation: spin 1s linear infinite;
135
+ display: none;
136
+ }
137
+
138
+ /* Animation for the spinner */
139
+ @keyframes spin {
140
+ 0% { transform: rotate(0deg); }
141
+ 100% { transform: rotate(360deg); }
142
+ }
143
+
144
+ /* Hide spinner when not loading */
145
+ .btn-loading .button-spinner {
146
+ display: inline-block;
147
+ }
148
+
149
+ .btn-loading .btn-text {
150
+ display: none;
151
+ }
152
+
153
+ .alert {
154
+ padding: 10px;
155
+ margin-bottom: 10px;
156
+ border-radius: 5px;
157
+ text-align: center;
158
+ position: absolute;
159
+ position-area: top center;
160
+ top: 30px;
161
+ align-items: center;
162
+ }
163
+
164
+ .alert-error {
165
+ background-color: #D84040;
166
+ color: #ffffff;
167
+ }
168
+
169
+ .alert-success {
170
+ background-color: #D2DE32;
171
+ color: #ffffff;
172
+ }
173
+
174
+ .alert-warning {
175
+ background-color: #FFC700;
176
+ color: #ffffff;
177
+ }
178
+
179
+ </style>
180
+
181
+ <div class="container-flash">
182
+ {% with messages = get_flashed_messages(with_categories=true) %}
183
+ {% if messages %}
184
+ <div id="flash-message" class="alert alert-{{ messages[0][0] }}">
185
+ <strong>{{ messages[0][1] }}</strong>
186
+ </div>
187
+ {% endif %}
188
+ {% endwith %}
189
+ </div>
190
+
191
+ <div class="container mt-5">
192
+ <div class="card shadow">
193
+ <div class="card-header">
194
+ <h3>Manage Database</h3>
195
+ </div>
196
+ <div class="card-body">
197
+ <form id="db-form" method="post" action="{{ url_for('delete_doc',db_name=db_name) }}">
198
+ <!-- Database Name (Read-Only) -->
199
+ <div class="form-group">
200
+ <label for="db_name" class="form-label">Database Name</label>
201
+ <input type="text" id="db_name" name="db_name" class="form-control" value="{{ db_name }}" readonly>
202
+ </div>
203
+
204
+ <!-- File Selection -->
205
+ <div class="form-group mt-3">
206
+ <label for="list_doc" class="form-label">Select a File to delete from menu</label>
207
+ <select id="list_doc" name="list_doc" class="form-control" required>
208
+ {% for file in file_list %}
209
+ <option value="{{ file }}">{{ file }}</option>
210
+ {% endfor %}
211
+ </select>
212
+ </div>
213
+
214
+ <!-- Buttons -->
215
+ <!-- <div class="text-center">
216
+ <button type="submit" class="btn btn-danger">Delete</button>
217
+ </div> -->
218
+ <!-- Submit Button -->
219
+ <div class="mt-4 text-center d-flex justify-content-center align-items-center">
220
+ <button type="submit" class="btn btn-danger px-5" id="delete-button">
221
+ <span class="btn-text">Delete Document</span>
222
+ <div class="button-spinner"></div>
223
+ </button>
224
+ </div>
225
+ </form>
226
+ </div>
227
+ </div>
228
+ </div>
229
+
230
+ <script>
231
+ const folderLabel = document.getElementById('folder-label');
232
+ const fileLabel = document.getElementById('file-label');
233
+ const folderUpload = document.getElementById('folder-upload');
234
+ const fileUpload = document.getElementById('file-upload');
235
+ const submitButton = document.getElementById('delete-button');
236
+ const buttonSpinner = submitButton.querySelector('.button-spinner');
237
+ const flashMessage = document.getElementById('flash-message');
238
+
239
+ //flash message
240
+ if (flashMessage) {
241
+ setTimeout(function() {
242
+ flashMessage.style.display = 'none';
243
+ }, 2000); // Hide after 2 seconds
244
+ }
245
+ // Toggle upload mode
246
+ folderLabel.addEventListener('click', () => {
247
+ folderLabel.classList.add('active');
248
+ fileLabel.classList.remove('active');
249
+ folderUpload.classList.remove('hidden');
250
+ fileUpload.classList.add('hidden');
251
+ });
252
+
253
+ fileLabel.addEventListener('click', () => {
254
+ fileLabel.classList.add('active');
255
+ folderLabel.classList.remove('active');
256
+ fileUpload.classList.remove('hidden');
257
+ folderUpload.classList.add('hidden');
258
+ });
259
+
260
+ // Handle form submission
261
+ document.getElementById('db-form').addEventListener('submit', function(event) {
262
+ event.preventDefault(); // Prevent form submission for demonstration
263
+ submitButton.classList.add('btn-loading');
264
+ // Simulate loading
265
+ setTimeout(() => {
266
+ // After form is "submitted" and loading is complete
267
+ submitButton.classList.remove('btn-loading');
268
+ alert("Form submitted successfully!"); // Simulate success
269
+ }, 2000); // 2 seconds for loading simulation
270
+ });
271
+ </script>
272
+
273
+ {% endblock %}
templates/list_dbs.html CHANGED
@@ -106,44 +106,52 @@
106
  margin-bottom: 10px;
107
  border-radius: 5px;
108
  text-align: center;
 
 
 
 
109
  }
110
 
111
  .alert-error {
112
- background-color: #ff4d4d;
113
- color: white;
 
 
 
 
 
114
  }
115
 
116
- .alert-table_selected {
117
- background-color: #4dff74;
118
- color: white;
119
  }
 
120
  </style>
121
 
122
  {% with messages = get_flashed_messages(with_categories=true) %}
123
  {% if messages %}
124
- {% for category, message in messages %}
125
- <div class="alert alert-{{ category }}">
126
- {{ message }}
127
- </div>
128
- {% endfor %}
129
  {% endif %}
130
  {% endwith %}
131
 
132
  <div class="container">
133
  <div class="card shadow">
134
  <div class="card-header">
135
- <h3>Available Vector Databases</h3>
136
  </div>
137
  <div class="card-body">
138
- <h4 class="text-center mb-4">Select a Vector Database</h4>
139
  <ul class="list-group">
140
  {% for db in vector_dbs %}
141
  <li class="list-group-item">
142
  <span>{{ db }}</span>
143
  <div class="button-container">
144
- <!-- <form method="post" action="{{ url_for('update_db', db_name=db) }}" class="mb-0">
145
- <button type="submit" class="btn btn-primary btn-sm">Update</button>
146
- </form> -->
147
  <form method="post" action="{{ url_for('select_db', db_name=db) }}" class="mb-0">
148
  <button type="submit" class="btn btn-primary btn-sm">Select</button>
149
  </form>
@@ -154,4 +162,12 @@
154
  </div>
155
  </div>
156
  </div>
 
 
 
 
 
 
 
 
157
  {% endblock %}
 
106
  margin-bottom: 10px;
107
  border-radius: 5px;
108
  text-align: center;
109
+ position: absolute;
110
+ position-area: top center;
111
+ top: 30px;
112
+ align-items: center;
113
  }
114
 
115
  .alert-error {
116
+ background-color: #D84040;
117
+ color: #ffffff;
118
+ }
119
+
120
+ .alert-success {
121
+ background-color: #D2DE32;
122
+ color: #ffffff;
123
  }
124
 
125
+ .alert-warning {
126
+ background-color: #FFC700;
127
+ color: #ffffff;
128
  }
129
+
130
  </style>
131
 
132
  {% with messages = get_flashed_messages(with_categories=true) %}
133
  {% if messages %}
134
+ <div id="flash-message" class="alert alert-{{ messages[0][0] }}">
135
+ <strong>{{ messages[0][1] }}</strong>
136
+ </div>
 
 
137
  {% endif %}
138
  {% endwith %}
139
 
140
  <div class="container">
141
  <div class="card shadow">
142
  <div class="card-header">
143
+ <h3><strong>Available Vector Databases</strong></h3>
144
  </div>
145
  <div class="card-body">
146
+ <h3 class="text-center mb-4"><strong>Select a Vector Database</strong></h3>
147
  <ul class="list-group">
148
  {% for db in vector_dbs %}
149
  <li class="list-group-item">
150
  <span>{{ db }}</span>
151
  <div class="button-container">
152
+ <form method="post" action="{{ url_for('modify_db', db_name=db) }}" class="mb-0">
153
+ <button type="submit" class="btn btn-primary btn-sm">Modify</button>
154
+ </form>
155
  <form method="post" action="{{ url_for('select_db', db_name=db) }}" class="mb-0">
156
  <button type="submit" class="btn btn-primary btn-sm">Select</button>
157
  </form>
 
162
  </div>
163
  </div>
164
  </div>
165
+ <script>
166
+ const flashMessage = document.getElementById('flash-message');
167
+ if (flashMessage) {
168
+ setTimeout(function() {
169
+ flashMessage.style.display = 'none';
170
+ }, 2000); // Hide after 2 seconds
171
+ }
172
+ </script>
173
  {% endblock %}
templates/modify_dbs.html ADDED
@@ -0,0 +1,95 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {% extends 'base.html' %}
2
+
3
+ {% block content %}
4
+ <style>
5
+ .alert {
6
+ padding: 10px;
7
+ margin-bottom: 10px;
8
+ border-radius: 5px;
9
+ text-align: center;
10
+ position: absolute;
11
+ position-area: top center;
12
+ top: 30px;
13
+ align-items: center;
14
+ }
15
+
16
+ .alert-error {
17
+ background-color: #D84040;
18
+ color: #ffffff;
19
+ }
20
+
21
+ .alert-success {
22
+ background-color: #D2DE32;
23
+ color: #ffffff;
24
+ }
25
+
26
+ .alert-warning {
27
+ background-color: #FFC700;
28
+ color: #ffffff;
29
+ }
30
+
31
+ </style>
32
+ {% with messages = get_flashed_messages(with_categories=true) %}
33
+ {% if messages %}
34
+ <div id="flash-message" class="alert alert-{{ messages[0][0] }}">
35
+ <strong>{{ messages[0][1] }}</strong>
36
+ </div>
37
+ {% endif %}
38
+ {% endwith %}
39
+
40
+ <div class="container">
41
+ <div class="row justify-content-center mb-4">
42
+ <div class="col-md-6">
43
+ <div class="card">
44
+ <div class="card-body">
45
+ <h5 class="card-title">Update Database</h5>
46
+ <p class="card-text">Upload the new document in existing DB. Currently selected DB: </p>
47
+ <p class="card-text"><strong>{{ db_name }}</strong></p>
48
+ <a href="/update-dbs/{{ db_name }}" class="btn btn-primary">Go to Update DB</a>
49
+ </div>
50
+ </div>
51
+ </div>
52
+ <div class="col-md-6">
53
+ <div class="card">
54
+ <div class="card-body">
55
+ <h5 class="card-title">Chat with AI</h5>
56
+ <p class="card-text">Ask questions and get answers based on your vector database.</p>
57
+ <p class="card-text"><strong>{{ db_name }}</strong></p>
58
+ <a href="/list-dbs" class="btn btn-primary">Go to List of DB</a>
59
+ </div>
60
+ </div>
61
+ </div>
62
+ </div>
63
+
64
+ <div class="row justify-content-center">
65
+ <div class="col-md-6 mb-4">
66
+ <div class="card">
67
+ <div class="card-body">
68
+ <h5 class="card-title">Remove DB</h5>
69
+ <p class="card-text">Remove the entire DB. Currently selected DB: </p>
70
+ <p class="card-text"><strong>{{ db_name }}</strong></p>
71
+ <a href="/remove-dbs/{{ db_name }}" class="btn btn-danger">Go to Remove DB</a>
72
+ </div>
73
+ </div>
74
+ </div>
75
+ <div class="col-md-6 mb-4">
76
+ <div class="card">
77
+ <div class="card-body">
78
+ <h5 class="card-title">Delete Document</h5>
79
+ <p class="card-text">Delete a document by specific file name. Currently selected DB: </p>
80
+ <p class="card-text"><strong>{{ db_name }}</strong></p>
81
+ <a href="/delete-doc/{{ db_name }}" class="btn btn-danger">Go to Delete Document</a>
82
+ </div>
83
+ </div>
84
+ </div>
85
+ </div>
86
+ </div>
87
+ <script>
88
+ const flashMessage = document.getElementById('flash-message');
89
+ if (flashMessage) {
90
+ setTimeout(function() {
91
+ flashMessage.style.display = 'none';
92
+ }, 2000); // Hide after 2 seconds
93
+ }
94
+ </script>
95
+ {% endblock %}
templates/update_db.html CHANGED
@@ -3,15 +3,14 @@
3
  {% block content %}
4
  <style>
5
  html, body {
6
- height: 100%;
7
  margin: 0;
8
  }
9
 
10
  .container {
11
  display: flex;
12
  flex-direction: column;
13
- height: 50vh;
14
- overflow: hidden;
15
  }
16
 
17
  .card {
@@ -20,8 +19,11 @@
20
  color: #f5f5f5;
21
  border: none;
22
  width: 50%;
23
- max-height: calc(50vh - 50px);
24
- overflow-y: auto;
 
 
 
25
  }
26
 
27
  .card-header {
@@ -29,13 +31,6 @@
29
  border-bottom: 2px solid #444;
30
  padding: 1rem;
31
  text-align: center;
32
- position: sticky;
33
- top: 0;
34
- z-index: 1000;
35
- }
36
-
37
- .text-muted {
38
- color: rgb(121 136 151 / 75%) !important;
39
  }
40
 
41
  .form-label {
@@ -59,6 +54,9 @@
59
  .btn-primary {
60
  background-color: #4c4cff;
61
  border-color: #4c4cff;
 
 
 
62
  }
63
 
64
  .btn-primary:hover {
@@ -66,15 +64,101 @@
66
  border-color: #3838e8;
67
  }
68
 
69
- .card::-webkit-scrollbar {
70
- width: 8px;
 
 
 
 
 
 
 
71
  }
72
 
73
- .card::-webkit-scrollbar-thumb {
74
  background-color: #444;
 
 
 
 
 
 
75
  border-radius: 4px;
76
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
77
  </style>
 
 
 
 
 
 
 
 
 
78
 
79
  <div class="container mt-5">
80
  <div class="card shadow">
@@ -82,26 +166,80 @@
82
  <h3>Update the Vector Database</h3>
83
  </div>
84
  <div class="card-body">
85
- <form method="post" enctype="multipart/form-data">
86
- <!-- Database Name Display -->
87
  <div class="form-group">
88
  <label for="db_name" class="form-label">Database Name</label>
89
  <input type="text" id="db_name" name="db_name" class="form-control" value="{{ db_name }}" readonly>
90
  </div>
91
-
92
- <!-- File or Folder Upload -->
93
- <div class="form-group mt-3">
94
- <label for="files" class="form-label">Upload Files or Folder</label>
95
- <input type="file" id="files" name="files" class="form-control" webkitdirectory directory multiple>
96
- <small class="text-muted">Note: You can upload multiple files, a folder, or a single file.</small>
 
 
 
 
 
 
 
 
 
 
 
 
 
97
  </div>
98
-
99
  <!-- Submit Button -->
100
- <div class="mt-4 text-center">
101
- <button type="submit" class="btn btn-primary px-5">Update</button>
 
 
 
102
  </div>
103
  </form>
104
  </div>
105
  </div>
106
  </div>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
107
  {% endblock %}
 
3
  {% block content %}
4
  <style>
5
  html, body {
6
+ height: 50%;
7
  margin: 0;
8
  }
9
 
10
  .container {
11
  display: flex;
12
  flex-direction: column;
13
+ height: 80vh; /* Fill the viewport height */
 
14
  }
15
 
16
  .card {
 
19
  color: #f5f5f5;
20
  border: none;
21
  width: 50%;
22
+ height: 70%; /* Fixed height for the card */
23
+ display: flex;
24
+ flex-direction: column;
25
+ justify-content: space-between;
26
+ padding: 1rem;
27
  }
28
 
29
  .card-header {
 
31
  border-bottom: 2px solid #444;
32
  padding: 1rem;
33
  text-align: center;
 
 
 
 
 
 
 
34
  }
35
 
36
  .form-label {
 
54
  .btn-primary {
55
  background-color: #4c4cff;
56
  border-color: #4c4cff;
57
+ display: flex;
58
+ justify-content: center;
59
+ align-items: center;
60
  }
61
 
62
  .btn-primary:hover {
 
64
  border-color: #3838e8;
65
  }
66
 
67
+ .toggle-switch {
68
+ margin: 1rem 0;
69
+ display: flex;
70
+ justify-content: center;
71
+ align-items: center;
72
+ }
73
+
74
+ .toggle-switch input {
75
+ display: none;
76
  }
77
 
78
+ .toggle-label {
79
  background-color: #444;
80
+ color: #cfcfcf;
81
+ padding: 0.5rem 1.5rem;
82
+ border: 1px solid #555;
83
+ cursor: pointer;
84
+ margin-right: 1rem;
85
+ text-align: center;
86
  border-radius: 4px;
87
  }
88
+
89
+ .toggle-label.active {
90
+ background-color: #4c4cff;
91
+ color: #fff;
92
+ }
93
+
94
+ .toggle-label:hover {
95
+ background-color: #3838e8;
96
+ color: #fff;
97
+ }
98
+
99
+ .hidden {
100
+ display: none;
101
+ }
102
+
103
+ .text-center.d-flex {
104
+ display: flex;
105
+ justify-content: center;
106
+ align-items: center;
107
+ height: 100px;
108
+ }
109
+
110
+ .spinner {
111
+ border: 4px solid #f3f3f3; /* Light grey */
112
+ border-top: 4px solid #4c4cff; /* Blue */
113
+ border-radius: 50%;
114
+ width: 24px;
115
+ height: 24px;
116
+ animation: spin 1s linear infinite;
117
+ margin-left: 10px;
118
+ display: none; /* Initially hidden */
119
+ }
120
+
121
+ @keyframes spin {
122
+ 0% { transform: rotate(0deg); }
123
+ 100% { transform: rotate(360deg); }
124
+ }
125
+
126
+ .alert {
127
+ padding: 10px;
128
+ margin-bottom: 10px;
129
+ border-radius: 5px;
130
+ text-align: center;
131
+ position: absolute;
132
+ position-area: top center;
133
+ top: 30px;
134
+ align-items: center;
135
+ }
136
+
137
+ .alert-error {
138
+ background-color: #D84040;
139
+ color: #ffffff;
140
+ }
141
+
142
+ .alert-success {
143
+ background-color: #D2DE32;
144
+ color: #ffffff;
145
+ }
146
+
147
+ .alert-warning {
148
+ background-color: #FFC700;
149
+ color: #ffffff;
150
+ }
151
+
152
  </style>
153
+ <div class="container-flash">
154
+ {% with messages = get_flashed_messages(with_categories=true) %}
155
+ {% if messages %}
156
+ <div id="flash-message" class="alert alert-{{ messages[0][0] }}">
157
+ <strong>{{ messages[0][1] }}</strong>
158
+ </div>
159
+ {% endif %}
160
+ {% endwith %}
161
+ </div>
162
 
163
  <div class="container mt-5">
164
  <div class="card shadow">
 
166
  <h3>Update the Vector Database</h3>
167
  </div>
168
  <div class="card-body">
169
+ <form id="db-form" method="post" enctype="multipart/form-data">
170
+ <!-- Database Name Input -->
171
  <div class="form-group">
172
  <label for="db_name" class="form-label">Database Name</label>
173
  <input type="text" id="db_name" name="db_name" class="form-control" value="{{ db_name }}" readonly>
174
  </div>
175
+
176
+ <!-- Toggle Upload Mode -->
177
+ <div class="toggle-switch">
178
+ <label class="toggle-label active" id="folder-label" for="folder">Upload Folder</label>
179
+ <label class="toggle-label" id="file-label" for="file">Upload Files</label>
180
+ </div>
181
+
182
+ <!-- Folder Upload Input -->
183
+ <div id="folder-upload" class="form-group mt-3">
184
+ <label for="folder" class="form-label">Upload Folder</label>
185
+ <input type="file" id="folder" name="folder" class="form-control" webkitdirectory directory multiple>
186
+ <small class="text-muted">Note: You can upload a folder containing multiple files.</small>
187
+ </div>
188
+
189
+ <!-- Single File Upload Input -->
190
+ <div id="file-upload" class="form-group mt-3 hidden">
191
+ <label for="file" class="form-label">Upload Files</label>
192
+ <input type="file" id="file" name="file" class="form-control" multiple>
193
+ <small class="text-muted">Note: You can upload one or more files.</small>
194
  </div>
195
+
196
  <!-- Submit Button -->
197
+ <div class="mt-4 text-center d-flex justify-content-center align-items-center">
198
+ <button type="submit" class="btn btn-primary px-5" id="submit-btn">
199
+ <span class="btn-text">Create</span>
200
+ <div class="spinner" id="spinner"></div>
201
+ </button>
202
  </div>
203
  </form>
204
  </div>
205
  </div>
206
  </div>
207
+
208
+ <script>
209
+ const folderLabel = document.getElementById('folder-label');
210
+ const fileLabel = document.getElementById('file-label');
211
+ const folderUpload = document.getElementById('folder-upload');
212
+ const fileUpload = document.getElementById('file-upload');
213
+ const submitBtn = document.getElementById('submit-btn');
214
+ const spinner = document.getElementById('spinner');
215
+ const flashMessage = document.getElementById('flash-message');
216
+ //for flash message
217
+ if (flashMessage) {
218
+ setTimeout(function() {
219
+ flashMessage.style.display = 'none';
220
+ }, 2000); // Hide after 2 seconds
221
+ }
222
+ // Toggle upload mode
223
+ folderLabel.addEventListener('click', () => {
224
+ folderLabel.classList.add('active');
225
+ fileLabel.classList.remove('active');
226
+ folderUpload.classList.remove('hidden');
227
+ fileUpload.classList.add('hidden');
228
+ });
229
+
230
+ fileLabel.addEventListener('click', () => {
231
+ fileLabel.classList.add('active');
232
+ folderLabel.classList.remove('active');
233
+ fileUpload.classList.remove('hidden');
234
+ folderUpload.classList.add('hidden');
235
+ });
236
+
237
+ // Show loader when form is submitted
238
+ document.getElementById('db-form').addEventListener('submit', function(event) {
239
+ // Show the spinner and hide the text
240
+ submitBtn.querySelector('.btn-text').style.display = 'none';
241
+ spinner.style.display = 'inline-block';
242
+ });
243
+ </script>
244
+
245
  {% endblock %}