Redmind commited on
Commit
c51df2c
·
verified ·
1 Parent(s): 5fdaf55

Delete templates/knowledgebase.html

Browse files
Files changed (1) hide show
  1. templates/knowledgebase.html +0 -467
templates/knowledgebase.html DELETED
@@ -1,467 +0,0 @@
1
- <!DOCTYPE html>
2
- <html>
3
-
4
- <head>
5
- <title>Knowledge Base</title>
6
- <script src="https://code.jquery.com/jquery-3.6.0.min.js"></script>
7
- <script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/js/bootstrap.bundle.min.js"></script>
8
- <!-- Include AdminLTE CSS -->
9
- <link rel="stylesheet" type="text/css" href="https://cdn.jsdelivr.net/npm/[email protected]/dist/css/adminlte.min.css">
10
- <!-- Include DataTables CSS -->
11
- <link rel="stylesheet" type="text/css" href="https://cdn.datatables.net/1.10.25/css/dataTables.bootstrap4.min.css">
12
- <!-- Include AdminLTE JS -->
13
- <script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/js/adminlte.min.js"></script>
14
- <!-- Include DataTables JS -->
15
- <script src="https://cdn.datatables.net/1.10.25/js/jquery.dataTables.min.js"></script>
16
- <script src="https://cdn.datatables.net/1.10.25/js/dataTables.bootstrap4.min.js"></script>
17
- <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.0.0-beta3/css/all.min.css" />
18
- <style>
19
- body {
20
- background-color: transparent !important;
21
- }
22
- .wrapper {
23
- display: flex;
24
- flex-direction: column;
25
- height: 100vh;
26
- }
27
- .content-wrapper {
28
- flex: 1;
29
- overflow-y: auto;
30
- }
31
-
32
-
33
-
34
- .modal-content {
35
- background-color: #fff;
36
- }
37
- .content-header {
38
- padding: 1rem;
39
- }
40
- h1 {
41
- text-align: center;
42
- margin-bottom: 30px;
43
- }
44
-
45
- .card-body {
46
- padding: 0;
47
- margin: 0;
48
- }
49
-
50
- .table-responsive {
51
- width: 100%;
52
- overflow-x: auto;
53
- /*overflow-y: scroll;*/
54
- /* Allows horizontal scrolling if necessary */
55
- }
56
-
57
- .table {
58
- width: 100%;
59
- border-collapse: collapse;
60
- }
61
- /* .table {
62
- table-layout: fixed;
63
- width: 100%;
64
- } */
65
-
66
- .text-wrap {
67
- white-space: normal !important;
68
- word-break: break-word;
69
- }
70
-
71
- .center-align {
72
- padding-top: 20px;
73
- display: flex;
74
- justify-content: center;
75
- align-items: center;
76
- width: 100%;
77
- }
78
-
79
- .reduced-width {
80
- width: 25%;
81
- /* Adjust the percentage as needed */
82
- }
83
-
84
- th
85
- {
86
- white-space: nowrap;
87
- }
88
-
89
- th:nth-child(1),
90
- td:nth-child(1) {
91
- /* Sno column */
92
- width: 5%;
93
- }
94
-
95
- th:nth-child(2),
96
- td:nth-child(2) {
97
- /* Document Name column */
98
- width: auto;
99
- }
100
-
101
- th:nth-child(3),
102
- td:nth-child(3) {
103
- /* Document Description column */
104
- width: auto;
105
- }
106
-
107
- th:nth-child(4),
108
- td:nth-child(4) {
109
- /* Document Version column */
110
- width: 20%;
111
- }
112
-
113
- th:nth-child(5),
114
- td:nth-child(5) {
115
- /* VectorDB Flag column */
116
- width: 10%;
117
- }
118
-
119
- th:nth-child(6),
120
- td:nth-child(6) {
121
- /* View column */
122
- width: 10%;
123
- }
124
-
125
- </style>
126
- </head>
127
-
128
- <body>
129
- {% include 'sidepane.html' %}
130
-
131
- <div class="wrapper">
132
- <div class="content-wrapper">
133
- <div class="content-header">
134
- <div class="container-fluid">
135
- <div class="container mt-2">
136
- <div class="form-group center-align">
137
- <label for="company" class="mr-2">Company Name <span class="text-danger">*</span></label>
138
- <select type="text" id="company" name="company" class="form-control reduced-width" required>
139
- <option value="" selected>Select</option>
140
- </select>
141
- <div class="col-8 d-flex justify-content-end mb-3">
142
- <button class="btn btn-primary" style="margin-top: 20px;" id="add">Add</button>
143
- </div>
144
- </div>
145
- <div class="row">
146
- <div id="message-container" style="margin-left: 200px;"></div>
147
-
148
- </div>
149
- </div>
150
- </div>
151
- </div>
152
- <section class="content" id="contentSection" style="display: none;">
153
- <div class="container-fluid">
154
- <div class="form-group">
155
- <!-- <label for="company_id">company_id</label>--->
156
- <input type="hidden" id="company_id" name="company_id" class="form-control" required>
157
- </div>
158
- <div class="row">
159
- <div class="col-12">
160
- <div class="card">
161
- <div id="message-container">
162
- <div class="card-body table-container">
163
- <table id="knowledgeTable" class="table table-bordered table-striped">
164
- <thead>
165
- <tr>
166
- <th>Sno</th>
167
- <th>Document Name</th>
168
- <th>Document Description</th>
169
- <th>Document Version</th>
170
- <th>VectorDB Flag</th>
171
- <th>View</th>
172
- </tr>
173
- </thead>
174
- <tbody>
175
-
176
- </tbody>
177
- </table>
178
- </div>
179
- </div>
180
- </div>
181
- </div>
182
- </div>
183
- </section>
184
- </div>
185
-
186
- <div class="modal fade" id="addModal" tabindex="-1" role="dialog" aria-labelledby="addModalLabel"
187
- aria-hidden="true">
188
- <div class="modal-dialog" role="document">
189
- <div class="modal-content">
190
- <div class="modal-header">
191
- <h5 class="modal-title" id="addModalLabel">Add Document Details</h5>
192
- <button type="button" class="btn-close" data-dismiss="modal" aria-label="Close">
193
- <span aria-hidden="true" data-backdrop="static" data-keyboard="false">&times;</span>
194
- </button>
195
- </div>
196
- <div class="modal-body">
197
- <div class="form-group">
198
- <!-- <label for="company_id">company_id</label>--->
199
- <input type="hidden" id="company_id" name="company_id" class="form-control" required>
200
- </div>
201
- <form id="documentForm">
202
- <div class="form-group">
203
- <label for="uploadFile">Upload File<span class="text-danger">*</span></label>
204
- <input type="file" class="form-control-file" id="uploadFile" name="uploadFile" required
205
- accept=".pdf,.doc,.docx">
206
- <small class="form-text text-muted">Accepted formats: .pdf, .doc, .docx</small>
207
- </div>
208
- <div class="form-group">
209
- <label for="documentName">Document Name<span class="text-danger">*</span></label>
210
- <input type="text" class="form-control" id="documentName" name="documentName" required>
211
- </div>
212
- <div class="form-group">
213
- <label for="documentDescription">Document Description<span
214
- class="text-danger">*</span></label>
215
- <textarea class="form-control" id="documentDescription" name="documentDescription"
216
- rows="3" required></textarea>
217
- </div>
218
- <div class="form-group">
219
- <label for="department">Department<span class="text-danger">*</span></label>
220
- <input type="text" class="form-control" id="department" name="department" required>
221
- </div>
222
- <div class="form-group">
223
- <label for="version">Version<span class="text-danger">*</span></label>
224
- <input type="text" class="form-control" id="version" name="version" required>
225
- </div>
226
- <div class="form-group">
227
- <label for="lastUpdated">Last Updated<span class="text-danger">*</span></label>
228
- <input type="text" class="form-control" id="lastUpdated" name="lastUpdated" required>
229
- </div>
230
- </form>
231
- </div>
232
- <div class="modal-footer">
233
- <!-- <button type="button" class="btn btn-secondary" data-dismiss="modal">Close</button> -->
234
- <button type="button" id="save" onclick="save_file()" class="btn btn-primary">Save</button>
235
- </div>
236
- </div>
237
- </div>
238
- </div>
239
- </div>
240
- <!-- JavaScript to handle modal display -->
241
- <script>
242
- document.addEventListener("DOMContentLoaded", function () {
243
- now = new Date().toISOString().substr(0, 10);
244
- document.getElementById('lastUpdated').value = now;
245
- const inputs = document.querySelectorAll("#documentForm input, textarea");
246
-
247
- inputs.forEach((input, index) => {
248
- input.addEventListener("keydown", function(event) {
249
- if (event.key === "Enter") {
250
- event.preventDefault();
251
- moveToNextInput(inputs, index);
252
- }
253
- });
254
- });
255
-
256
- function moveToNextInput(inputs, currentIndex) {
257
- const nextInput = inputs[currentIndex + 1];
258
- if (nextInput) {
259
- nextInput.focus();
260
- } else {
261
- // Optionally, submit the form or trigger the save button
262
- document.getElementById("save").focus();
263
- }
264
- }
265
- fetchCompanies();
266
-
267
- const companySelect = document.getElementById('company');
268
- const documentForm = document.getElementById('documentForm');
269
- const table = $('#knowledgeTable').DataTable(); // Initialize DataTable at the start
270
-
271
- companySelect.addEventListener('change', async function () {
272
- $("#message-container").empty();
273
- const selectedCompanyName = companySelect.options[companySelect.selectedIndex].text;
274
- console.log(`Selected Company Name: ${selectedCompanyName}`);
275
-
276
- if (selectedCompanyName !== "Select") {
277
- try {
278
- const response = await fetch(`/api/company_id?company_name=${encodeURIComponent(selectedCompanyName)}`);
279
- if (!response.ok) {
280
- contentSection.style.display = 'none';
281
- displayErrorMessage("Document details do not exist for this company. Please fill in the details.");
282
- throw new Error('Network response was not ok');
283
- }
284
- const data = await response.json();
285
- console.log('data returned', data);
286
- const companyId = data.company_id;
287
- document.getElementById('company_id').value = companyId;
288
-
289
- if (companyId) {
290
- try {
291
- const Response = await fetch(`/api/document_upload?company_id=${companyId}&company_name=${selectedCompanyName}`);
292
- const connectorsResponse = await Response.json();
293
- console.log("knowledge data table after connecting to table", connectorsResponse);
294
- table.clear();
295
- if (!Array.isArray(connectorsResponse) || connectorsResponse.length === 0) {
296
- //displayEmptyTable();
297
-
298
- displayErrorMessage("Document details do not exist for this company. Please fill in the details.");
299
- contentSection.style.display = 'none';
300
- } else {
301
-
302
- connectorsResponse.forEach((company, index) => {
303
- table.row.add([
304
- index + 1,
305
- company.document_name,
306
- company.document_desc,
307
- company.version,
308
- company.vectorDBflag,
309
- "<a href='#' class='btn btn-info btn-sm'><i class='fas fa-eye'></i></a>",
310
- ]).draw(false);
311
- });
312
- contentSection.style.display = 'block';
313
- }
314
- } catch (error) {
315
- console.error('Error fetching company documents:', error);
316
- //displayEmptyTable();
317
-
318
- displayErrorMessage("Document details1 do not exist for this company. Please fill in the details.");
319
- contentSection.style.display = 'none';
320
- }
321
- } else {
322
- // displayEmptyTable();
323
-
324
- displayErrorMessage("Document details2 for knowledge do not exist for this company. Please fill in the details.");
325
- }
326
- } catch (error) {
327
- console.error('No details for this company ID or data documents:', error);
328
- // displayEmptyTable();
329
-
330
- displayErrorMessage("Document details3 do not exist for this company. Please fill in the details.");
331
- contentSection.style.display = 'none';
332
- }
333
- } else {
334
- table.clear().draw();
335
- document.getElementById('contentSection').style.display = 'none';
336
- clearFormFields();
337
- }
338
- });
339
-
340
- function displayErrorMessage(message) {
341
- const messageContainer = document.getElementById('message-container');
342
- if (messageContainer) {
343
- messageContainer.innerHTML = `<div class='alert alert-danger'>${message}</div>`;
344
- }
345
- }
346
-
347
- // function displayEmptyTable() {
348
- // table.clear().draw();
349
- // contentSection.style.display = 'block'; // Ensure the table section is visible even if empty
350
- // }
351
- });
352
-
353
- function clearFormFields() {
354
- document.getElementById('uploadFile').value = "";
355
- document.getElementById('documentName').value = "";
356
- document.getElementById('documentDescription').value = "";
357
- document.getElementById('department').value = "";
358
- document.getElementById('version').value = "";
359
- //document.getElementById('lastUpdated').value = "";
360
- }
361
-
362
-
363
- $(document).ready(function () {
364
- // Show modal function
365
- $('#add').on('click', function () {
366
-
367
- clearFormFields();
368
- $('#message-container').empty(); // Clear the message container
369
- $('#addModal').modal('show');
370
- });
371
-
372
-
373
- $('.modal-footer .btn-secondary, .modal-header .btn-close').on('click', function () {
374
- $('#addModal').modal('hide');
375
- });
376
- $('#KnowledgeTable').DataTable({
377
- autoWidth: false
378
- });
379
-
380
- });
381
- function save_file() {
382
- const form = document.getElementById('documentForm');
383
-
384
- // Check if the form is valid
385
- if (!form.checkValidity()) {
386
- // If the form is invalid, show validation messages and stop the submission
387
- form.reportValidity();
388
- return;
389
- }
390
- const uploadFile = document.getElementById("uploadFile").files[0];
391
- const documentName = document.getElementById("documentName").value;
392
- const documentDescription = document.getElementById("documentDescription").value;
393
- const department = document.getElementById("department").value;
394
- const version = document.getElementById("version").value;
395
- const lastUpdated = document.getElementById("lastUpdated").value;
396
- const company_id = document.getElementById("company_id").value;
397
-
398
- //const formData = new FormData();
399
- var formData = new FormData($('#documentForm')[0]);
400
- const vectorDBFlag = "NO"; // Example value
401
- const view= "<a href='#' class='btn btn-info btn-sm'><i class='fas fa-eye'></i></a>";
402
-
403
-
404
- formData.append("uploadFile", uploadFile);
405
- formData.append("documentName", documentName);
406
- formData.append("documentDescription", documentDescription);
407
- formData.append("department", department);
408
- formData.append("version", version);
409
- formData.append("lastUpdated", lastUpdated);
410
- formData.append("vectorDBflag", vectorDBFlag);
411
- formData.append("company_id", company_id);
412
-
413
- fetch('/upload_document', {
414
- method: 'POST',
415
- body: formData
416
- })
417
- .then(response => {
418
- if (!response.ok) {
419
- throw new Error('Network response was not ok');
420
- }
421
- return response.text();
422
- })
423
- .then(data => {
424
- var table = $('#knowledgeTable').DataTable();
425
- var rowCount = table.rows().count();
426
- table.row.add([
427
- rowCount + 1,
428
- documentName,
429
- documentDescription,
430
- version,
431
- vectorDBFlag,
432
- view
433
- ]).draw(false);
434
-
435
- alert('Document saved successfully');
436
- $('#addModal').modal('hide');
437
- document.getElementById('contentSection').style.display = 'block'; // Show the table section
438
- })
439
- .catch(error => console.error('Error:', error));
440
- }
441
- async function fetchCompanies() {
442
- try {
443
- const response = await fetch('/api/companies');
444
- if (!response.ok) {
445
- throw new Error('Network response was not ok');
446
- }
447
- const data = await response.json();
448
- displayCompanies(data.companies);
449
- } catch (error) {
450
- console.error('Error fetching companies:', error);
451
- }
452
- }
453
-
454
- function displayCompanies(companies) {
455
- const companySelect = document.getElementById('company');
456
- companySelect.innerHTML = '<option value="" selected>Select</option>'; // Reset the dropdown
457
- companies.forEach(company => {
458
- const option = document.createElement('option');
459
- option.value = company.name;
460
- option.textContent = company.name;
461
- companySelect.appendChild(option);
462
- });
463
- }
464
- </script>
465
- </body>
466
-
467
- </html>