Spaces:
Runtime error
Runtime error
lakshmivairamani
commited on
Upload 14 files
Browse files- templates/API_connectors.html +443 -0
- templates/chatbot.html +81 -0
- templates/company_profile.html +312 -0
- templates/company_profile2.html +315 -0
- templates/dashboard.html +156 -0
- templates/data_connectors.html +463 -0
- templates/footer.html +26 -0
- templates/index.html +117 -0
- templates/knowledgebase.html +467 -0
- templates/knowledgebase2.html +360 -0
- templates/prompt_template.html +435 -0
- templates/redmindlogo2.jpg +0 -0
- templates/redmindlogo3.jpg +0 -0
- templates/sidepane.html +105 -0
templates/API_connectors.html
ADDED
@@ -0,0 +1,443 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<!DOCTYPE html>
|
2 |
+
<html>
|
3 |
+
|
4 |
+
<head>
|
5 |
+
<title>API Connectors</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 |
+
<script src="https://cdn.datatables.net/1.10.25/js/jquery.dataTables.min.js"></script>
|
13 |
+
<script src="https://cdn.datatables.net/1.10.25/js/dataTables.bootstrap4.min.js"></script>
|
14 |
+
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.0.0-beta3/css/all.min.css" />
|
15 |
+
<style>
|
16 |
+
.form-group{
|
17 |
+
margin-top: -10px;
|
18 |
+
}
|
19 |
+
.header-row {
|
20 |
+
display: flex;
|
21 |
+
justify-content: space-between;
|
22 |
+
align-items: center;
|
23 |
+
}
|
24 |
+
|
25 |
+
|
26 |
+
.table-container {
|
27 |
+
width: 100%;
|
28 |
+
overflow-x: auto;
|
29 |
+
}
|
30 |
+
|
31 |
+
.wrapper {
|
32 |
+
display: flex;
|
33 |
+
flex-direction: column;
|
34 |
+
height: 100vh;
|
35 |
+
}
|
36 |
+
|
37 |
+
.content-wrapper {
|
38 |
+
flex: 1;
|
39 |
+
overflow-y: auto;
|
40 |
+
}
|
41 |
+
|
42 |
+
.content-header {
|
43 |
+
padding: 1rem;
|
44 |
+
}
|
45 |
+
|
46 |
+
.footer {
|
47 |
+
text-align: right;
|
48 |
+
padding: 10px;
|
49 |
+
}
|
50 |
+
.center-align {
|
51 |
+
padding-top: 20px;
|
52 |
+
display: flex;
|
53 |
+
justify-content: center;
|
54 |
+
align-items: center;
|
55 |
+
width: 100%;
|
56 |
+
}
|
57 |
+
th,
|
58 |
+
td {
|
59 |
+
white-space: nowrap;
|
60 |
+
}
|
61 |
+
|
62 |
+
th:nth-child(1),
|
63 |
+
td:nth-child(1) {
|
64 |
+
/* Sno column */
|
65 |
+
width: 5%;
|
66 |
+
}
|
67 |
+
|
68 |
+
th:nth-child(2),
|
69 |
+
td:nth-child(2) {
|
70 |
+
/* API Name column */
|
71 |
+
width: 20%;
|
72 |
+
}
|
73 |
+
|
74 |
+
th:nth-child(3),
|
75 |
+
td:nth-child(3) {
|
76 |
+
/* API Endpoint column */
|
77 |
+
width: 40%;
|
78 |
+
}
|
79 |
+
|
80 |
+
th:nth-child(4),
|
81 |
+
td:nth-child(4) {
|
82 |
+
/* Auth/Bearer token column */
|
83 |
+
width: 20%;
|
84 |
+
}
|
85 |
+
|
86 |
+
th:nth-child(5),
|
87 |
+
td:nth-child(5) {
|
88 |
+
/* View column */
|
89 |
+
width: 15%;
|
90 |
+
}
|
91 |
+
.reduced-width{
|
92 |
+
width:25%;
|
93 |
+
}
|
94 |
+
</style>
|
95 |
+
</head>
|
96 |
+
|
97 |
+
<body>
|
98 |
+
{% include 'sidepane.html' %}
|
99 |
+
|
100 |
+
<div class="wrapper">
|
101 |
+
<div class="content-wrapper">
|
102 |
+
<!-- Content Header (Page header) -->
|
103 |
+
<div class="content-header">
|
104 |
+
<div class="container-fluid">
|
105 |
+
<div class="container mt-2">
|
106 |
+
<div class="form-group center-align">
|
107 |
+
<label for="company" class="mr-2">Company Name <span class="text-danger">*</span></label>
|
108 |
+
<select type="text" id="company" name="company" class="form-control reduced-width" required>
|
109 |
+
<option value="" selected>Select</option>
|
110 |
+
</select>
|
111 |
+
<div class="col-8 d-flex justify-content-end mb-3">
|
112 |
+
<button class="btn btn-primary" style="margin-top: 20px;" id="add">Add</button>
|
113 |
+
</div>
|
114 |
+
</div>
|
115 |
+
<div class="row">
|
116 |
+
<div id="message-container" style="margin-left: 200px;"></div>
|
117 |
+
|
118 |
+
</div>
|
119 |
+
</div>
|
120 |
+
</div>
|
121 |
+
</div>
|
122 |
+
<section class="content" id="contentSection" style="display: none;">
|
123 |
+
<div class="container-fluid">
|
124 |
+
<div class="form-group">
|
125 |
+
<!-- <label for="company_id">company_id</label>--->
|
126 |
+
<input type="hidden" id="company_id" name="company_id" class="form-control" required>
|
127 |
+
</div>
|
128 |
+
</div>
|
129 |
+
<!-- Main content -->
|
130 |
+
<section class="content">
|
131 |
+
<div class="container-fluid">
|
132 |
+
<div class="row">
|
133 |
+
<div class="col-12">
|
134 |
+
<div class="card">
|
135 |
+
<div class="card-body table-container">
|
136 |
+
<table id="apiTable" class="table table-bordered table-striped">
|
137 |
+
<thead>
|
138 |
+
<tr>
|
139 |
+
<th>Sno</th>
|
140 |
+
<th>API Name</th>
|
141 |
+
<th>API Endpoint</th>
|
142 |
+
<th>View</th>
|
143 |
+
</tr>
|
144 |
+
</thead>
|
145 |
+
<tbody>
|
146 |
+
<!-- <tr>
|
147 |
+
<td>1</td>
|
148 |
+
<td>Warehouse</td>
|
149 |
+
<td>http://193.203.162.39:9090/nxt-wms/userWarehouse/fetchWarehouseForUserId
|
150 |
+
</td>
|
151 |
+
<td><button class="btn btn-primary viewButton">View</button></td>
|
152 |
+
</tr>
|
153 |
+
<tr>
|
154 |
+
<td>2</td>
|
155 |
+
<td>customer</td>
|
156 |
+
<td>http://193.203.162.39:9090/nxt-wms/userCustomer/fetchCustomerForUserId
|
157 |
+
</td>
|
158 |
+
<td><button class="btn btn-primary viewButton">View</button></td>
|
159 |
+
</tr>
|
160 |
+
<tr>
|
161 |
+
<td>3</td>
|
162 |
+
<td>SKU</td>
|
163 |
+
<td>http://193.203.162.39:9090/nxt-wms/sku/autoComplete?</td>
|
164 |
+
<td><button class="btn btn-primary viewButton">View</button></td>
|
165 |
+
</tr>
|
166 |
+
<tr>
|
167 |
+
<td>4</td>
|
168 |
+
<td>ASN</td>
|
169 |
+
<td>http://193.203.162.39:9090/nxt-wms/trnHeader</td>
|
170 |
+
<td><button class="btn btn-primary viewButton">View</button></td>
|
171 |
+
</tr> -->
|
172 |
+
</tbody>
|
173 |
+
</table>
|
174 |
+
</div>
|
175 |
+
</div>
|
176 |
+
</div>
|
177 |
+
</div>
|
178 |
+
</div>
|
179 |
+
</section>
|
180 |
+
</div>
|
181 |
+
|
182 |
+
</div>
|
183 |
+
|
184 |
+
<!-- Modal -->
|
185 |
+
<div class="modal fade" id="addModal" tabindex="-1" role="dialog" aria-labelledby="addModalLabel"
|
186 |
+
aria-hidden="true">
|
187 |
+
<div class="modal-dialog" style="margin-top: -10px;" role="document">
|
188 |
+
<div class="modal-content" >
|
189 |
+
<div class="modal-header">
|
190 |
+
<h5 class="modal-title" id="addModalLabel">Add API Details</h5>
|
191 |
+
<button type="button" class="close" data-dismiss="modal" aria-label="Close">
|
192 |
+
<span aria-hidden="true" data-backdrop="static" data-keyboard="false">×</span>
|
193 |
+
</button>
|
194 |
+
</div>
|
195 |
+
<div class="modal-body">
|
196 |
+
<div class="form-group">
|
197 |
+
<!-- <label for="company_id">company_id</label>--->
|
198 |
+
<input type="hidden" id="company_id" name="company_id" class="form-control" required>
|
199 |
+
</div>
|
200 |
+
<form id="documentForm">
|
201 |
+
<div class="form-group">
|
202 |
+
<label for="APIName">API Name <span class="text-danger">*</span></label>
|
203 |
+
<input type="text" class="form-control" id="APIName" name="APIName" required>
|
204 |
+
</div>
|
205 |
+
<div class="form-group">
|
206 |
+
<label for="APIEndpoint">API Endpoint <span class="text-danger">*</span></label>
|
207 |
+
<input type="text" class="form-control" id="APIEndpoint" name="APIEndpoint" required>
|
208 |
+
</div>
|
209 |
+
<div class="form-group">
|
210 |
+
<label for="Auth_Bearer">Auth/Bearer token <span class="text-danger">*</span></label>
|
211 |
+
<input type="text" class="form-control" id="Auth_Bearer" name="Auth_Bearer" required>
|
212 |
+
</div>
|
213 |
+
<div class="form-group">
|
214 |
+
<label for="Inputjson">Input parameter <span class="text-danger">*</span></label>
|
215 |
+
<input type="text" class="form-control" id="Inputjson" name="Inputjson" required>
|
216 |
+
</div>
|
217 |
+
<div class="form-group">
|
218 |
+
<label for="OutputJson">Output Json <span class="text-danger">*</span></label>
|
219 |
+
<input type="text" class="form-control" id="OutputJson" name="OutputJson" required>
|
220 |
+
</div>
|
221 |
+
<div class="form-group">
|
222 |
+
<label for="Description">Description <span class="text-danger">*</span></label>
|
223 |
+
<textarea class="form-control" id="Description" name="Description" rows="3"
|
224 |
+
required></textarea>
|
225 |
+
</div>
|
226 |
+
</form>
|
227 |
+
</div>
|
228 |
+
<div class="modal-footer">
|
229 |
+
<!-- <button type="button" class="btn btn-secondary" data-bs-dismiss="modal">Close</button> -->
|
230 |
+
<button type="button" id="save" onclick="save_file()" class="btn btn-primary">Save</button>
|
231 |
+
</div>
|
232 |
+
</div>
|
233 |
+
</div>
|
234 |
+
</div>
|
235 |
+
|
236 |
+
<!-- Include DataTables JS and your custom script -->
|
237 |
+
<script src="https://cdn.datatables.net/1.10.25/js/jquery.dataTables.min.js"></script>
|
238 |
+
<script src="https://cdn.datatables.net/1.10.25/js/dataTables.bootstrap4.min.js"></script>
|
239 |
+
<script>
|
240 |
+
$(document).ready(function () {
|
241 |
+
// Show modal function
|
242 |
+
$('#add').on('click', function () {
|
243 |
+
clearFormFields();
|
244 |
+
$('#message-container').empty(); // Clear the message container
|
245 |
+
$('#addModal').modal('show');
|
246 |
+
});
|
247 |
+
$('.modal-footer .btn-secondary, .modal-header .close').on('click', function () {
|
248 |
+
$('#addModal').modal('hide');
|
249 |
+
});
|
250 |
+
// $('#apiTable').DataTable({
|
251 |
+
// autoWidth: false
|
252 |
+
// });
|
253 |
+
|
254 |
+
});
|
255 |
+
document.addEventListener("DOMContentLoaded", function () {
|
256 |
+
|
257 |
+
// clearFormFields();
|
258 |
+
fetchCompanies();
|
259 |
+
|
260 |
+
const companySelect = document.getElementById('company');
|
261 |
+
const documentForm = document.getElementById('documentForm');
|
262 |
+
const table = $('#apiTable').DataTable();
|
263 |
+
// Initialize DataTable at the start
|
264 |
+
companySelect.addEventListener('change', async function () {
|
265 |
+
$("#message-container").empty();
|
266 |
+
const selectedCompanyName = companySelect.options[companySelect.selectedIndex].text;
|
267 |
+
console.log(`Selected Company Name: ${selectedCompanyName}`);
|
268 |
+
|
269 |
+
if (selectedCompanyName !== "Select") {
|
270 |
+
|
271 |
+
try {
|
272 |
+
const response = await fetch(`/api/company_id?company_name=${encodeURIComponent(selectedCompanyName)}`);
|
273 |
+
if (!response.ok) {
|
274 |
+
contentSection.style.display = 'none';
|
275 |
+
("Document details does not exist for name does not exist. Please fill in the details.");
|
276 |
+
const messageContainer = document.getElementById('message-container');
|
277 |
+
if (messageContainer) {
|
278 |
+
messageContainer.innerHTML = "<div class='alert alert-danger'>Document details do not exist for this company. Please fill in the details.</div>";
|
279 |
+
}
|
280 |
+
throw new Error('Network response was not ok');
|
281 |
+
}
|
282 |
+
const data = await response.json();
|
283 |
+
console.log('data returned', data);
|
284 |
+
console.log(`Company ID: ${data.company_id}`);
|
285 |
+
const companyId = data.company_id;
|
286 |
+
document.getElementById('company_id').value = companyId;
|
287 |
+
|
288 |
+
if (companyId) {
|
289 |
+
try {
|
290 |
+
const Response = await fetch(`/api/get_api_connectors?company_id=${companyId}&company_name=${selectedCompanyName}`);
|
291 |
+
const connectorsResponse = await Response.json();
|
292 |
+
console.log("api connector data table after connecting to table", connectorsResponse);
|
293 |
+
table.clear();
|
294 |
+
if (!Array.isArray(connectorsResponse)) {
|
295 |
+
throw new TypeError('Expected an array of companies');
|
296 |
+
|
297 |
+
displayErrorMessage("Document details do not exist for this company. Please fill in the details.");
|
298 |
+
contentSection.style.display = 'none';
|
299 |
+
} else {
|
300 |
+
|
301 |
+
connectorsResponse.forEach((company, index) => {
|
302 |
+
table.row.add([
|
303 |
+
index+1,
|
304 |
+
company.APIName,
|
305 |
+
company.APIEndpoint,
|
306 |
+
"<a href='#' class='btn btn-info btn-sm'><i class='fas fa-eye' fa-eye'></i></a>",
|
307 |
+
]).draw(false);
|
308 |
+
});
|
309 |
+
contentSection.style.display = 'block';
|
310 |
+
}
|
311 |
+
|
312 |
+
} catch (error) {
|
313 |
+
console.error('Error fetching company documents:', error);
|
314 |
+
//displayEmptyTable();
|
315 |
+
|
316 |
+
displayErrorMessage("Document details1 do not exist for this company. Please fill in the details.");
|
317 |
+
contentSection.style.display = 'none';
|
318 |
+
}
|
319 |
+
}
|
320 |
+
else {
|
321 |
+
// displayEmptyTable();
|
322 |
+
|
323 |
+
displayErrorMessage("Document details2 for knowledge do not exist for this company. Please fill in the details.");
|
324 |
+
}
|
325 |
+
} catch (error) {
|
326 |
+
console.error('No details for this company ID or data documents:', error);
|
327 |
+
// displayEmptyTable();
|
328 |
+
|
329 |
+
displayErrorMessage("Document details3 do not exist for this company. Please fill in the details.");
|
330 |
+
contentSection.style.display = 'none';
|
331 |
+
}
|
332 |
+
} else {
|
333 |
+
|
334 |
+
table.clear().draw();
|
335 |
+
document.getElementById('contentSection').style.display = 'none';
|
336 |
+
// Optionally, you might want to clear the form fields as well
|
337 |
+
clearFormFields();
|
338 |
+
|
339 |
+
}
|
340 |
+
});
|
341 |
+
function displayErrorMessage(message) {
|
342 |
+
const messageContainer = document.getElementById('message-container');
|
343 |
+
if (messageContainer) {
|
344 |
+
messageContainer.innerHTML = `<div class='alert alert-danger'>${message}</div>`;
|
345 |
+
}
|
346 |
+
}
|
347 |
+
|
348 |
+
});
|
349 |
+
function save_file() {
|
350 |
+
const form = document.getElementById('documentForm');
|
351 |
+
|
352 |
+
// Check if the form is valid
|
353 |
+
if (!form.checkValidity()) {
|
354 |
+
// If the form is invalid, show validation messages and stop the submission
|
355 |
+
form.reportValidity();
|
356 |
+
return;
|
357 |
+
}
|
358 |
+
const company_id=$('#company_id').val();
|
359 |
+
const APIName = $('#APIName').val();
|
360 |
+
const APIEndpoint = $('#APIEndpoint').val();
|
361 |
+
const Auth_Bearer = $('#Auth_Bearer').val();
|
362 |
+
const Inputjson = $('#Inputjson').val();
|
363 |
+
const OutputJson = $('#OutputJson').val();
|
364 |
+
const Description = $('#Description').val();
|
365 |
+
const view= "<a href='#' class='btn btn-info btn-sm'><i class='fas fa-eye'></i></a>";
|
366 |
+
var formData = new FormData($('#documentForm')[0]);
|
367 |
+
|
368 |
+
formData.append("company_id",company_id),
|
369 |
+
formData.append("api_name", APIName),
|
370 |
+
formData.append("api_endpoint", APIEndpoint),
|
371 |
+
formData.append("auth_bearer", Auth_Bearer),
|
372 |
+
formData.append("input_json", Inputjson),
|
373 |
+
formData.append("output_json", OutputJson),
|
374 |
+
formData.append("description", Description)
|
375 |
+
|
376 |
+
//const formData = new FormData();
|
377 |
+
fetch('/api/save_api_details', {
|
378 |
+
method: 'POST',
|
379 |
+
body: formData
|
380 |
+
})
|
381 |
+
.then(response => {
|
382 |
+
if (!response.ok) {
|
383 |
+
throw new Error('Network response was not ok');
|
384 |
+
}
|
385 |
+
return response.text();
|
386 |
+
})
|
387 |
+
.then(data => {
|
388 |
+
var table = $('#apiTable').DataTable();
|
389 |
+
var rowCount = table.rows().count();
|
390 |
+
table.row.add([
|
391 |
+
rowCount + 1,
|
392 |
+
APIName,
|
393 |
+
APIEndpoint,
|
394 |
+
Auth_Bearer,
|
395 |
+
Inputjson,
|
396 |
+
OutputJson,
|
397 |
+
Description,
|
398 |
+
view
|
399 |
+
]).draw(false);
|
400 |
+
|
401 |
+
alert('Document saved successfully');
|
402 |
+
$('#addModal').modal('hide');
|
403 |
+
document.getElementById('contentSection').style.display = 'block'; // Show the table section
|
404 |
+
})
|
405 |
+
.catch(error => console.error('Error:', error));
|
406 |
+
}
|
407 |
+
async function fetchCompanies() {
|
408 |
+
try {
|
409 |
+
const response = await fetch('/api/companies');
|
410 |
+
if (!response.ok) {
|
411 |
+
throw new Error('Network response was not ok');
|
412 |
+
}
|
413 |
+
const data = await response.json();
|
414 |
+
displayCompanies(data.companies);
|
415 |
+
} catch (error) {
|
416 |
+
console.error('Error fetching companies:', error);
|
417 |
+
}
|
418 |
+
}
|
419 |
+
|
420 |
+
function displayCompanies(companies) {
|
421 |
+
const companySelect = document.getElementById('company');
|
422 |
+
companySelect.innerHTML = '<option value="" selected>Select</option>'; // Reset the dropdown
|
423 |
+
companies.forEach(company => {
|
424 |
+
const option = document.createElement('option');
|
425 |
+
option.value = company.name;
|
426 |
+
option.textContent = company.name;
|
427 |
+
companySelect.appendChild(option);
|
428 |
+
});
|
429 |
+
}
|
430 |
+
function clearFormFields() {
|
431 |
+
document.getElementById('APIName').value = "";
|
432 |
+
document.getElementById('APIEndpoint').value = "";
|
433 |
+
document.getElementById('Auth_Bearer').value = "";
|
434 |
+
document.getElementById('Inputjson').value = "";
|
435 |
+
document.getElementById('OutputJson').value = "";
|
436 |
+
document.getElementById('Description').value = "";
|
437 |
+
}
|
438 |
+
|
439 |
+
|
440 |
+
</script>
|
441 |
+
</body>
|
442 |
+
|
443 |
+
</html>
|
templates/chatbot.html
ADDED
@@ -0,0 +1,81 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
# jinja2 html page with chatbot functionality using adminlte3 theme
|
2 |
+
<html>
|
3 |
+
<body>
|
4 |
+
<form id="myform">
|
5 |
+
<div class="content-wrapper">
|
6 |
+
<section class="content-header">
|
7 |
+
<div class="container-fluid">
|
8 |
+
<div class="row mb-2">
|
9 |
+
<div class="col-sm-6">
|
10 |
+
<h1>Chatbot</h1>
|
11 |
+
</div>
|
12 |
+
<div class="col-sm-6">
|
13 |
+
<ol class="breadcrumb float-sm-right">
|
14 |
+
<li class="breadcrumb-item"><a href="#">Home</a></li>
|
15 |
+
<li class="breadcrumb-item active">Chatbot</li>
|
16 |
+
</ol>
|
17 |
+
</div>
|
18 |
+
</div>
|
19 |
+
</div>
|
20 |
+
</section>
|
21 |
+
|
22 |
+
<section class="content">
|
23 |
+
<div class="container-fluid">
|
24 |
+
<div class="row">
|
25 |
+
<div class="col-md-8 offset-md-2">
|
26 |
+
<div class="card card-primary">
|
27 |
+
<div class="card-header">
|
28 |
+
<h3 class="card-title">Chat with our AI</h3>
|
29 |
+
</div>
|
30 |
+
<div class="card-body">
|
31 |
+
<div id="chat-container">
|
32 |
+
<div class="chat-messages">
|
33 |
+
<!-- Chat messages will be dynamically added here -->
|
34 |
+
</div>
|
35 |
+
<div class="chat-input">
|
36 |
+
<input type="text" id="user_question" placeholder="Type your message...">
|
37 |
+
<button id="send-button" onclick="clickform()">Send</button>
|
38 |
+
</div>
|
39 |
+
</div>
|
40 |
+
</div>
|
41 |
+
</div>
|
42 |
+
</div>
|
43 |
+
</div>
|
44 |
+
</div>
|
45 |
+
</section>
|
46 |
+
</div>
|
47 |
+
</form>
|
48 |
+
<script>
|
49 |
+
const chatContainer = document.getElementById('chat-container');
|
50 |
+
const userInput = document.getElementById('user_question');
|
51 |
+
const sendButton = document.getElementById('send-button');
|
52 |
+
|
53 |
+
function clickform() {
|
54 |
+
alert('Please enter');
|
55 |
+
var formElement = document.getElementById('myForm');
|
56 |
+
var user_question = document.getElementById('user_question').value;
|
57 |
+
alert(user_question);
|
58 |
+
//var data = new FormData(formElement);
|
59 |
+
//alert(data);
|
60 |
+
fetch('/chat_with_agent', {
|
61 |
+
method: 'POST',
|
62 |
+
//body: data,
|
63 |
+
})
|
64 |
+
.then(resp => resp.text()) // or, resp.json(), etc.
|
65 |
+
.then(data => {
|
66 |
+
//document.getElementById("responseArea").innerHTML = data;
|
67 |
+
alert(data);
|
68 |
+
const chatMessage = document.createElement('div');
|
69 |
+
chatMessage.classList.add('chat-message');
|
70 |
+
chatMessage.innerHTML = '<strong>You:</strong> ${user_question}<br><strong>AI:</strong> ${data}';
|
71 |
+
chatContainer.appendChild(chatMessage);
|
72 |
+
|
73 |
+
userInput.value = '';
|
74 |
+
userInput.focus();
|
75 |
+
})
|
76 |
+
.catch(error => {
|
77 |
+
console.error(error);
|
78 |
+
});
|
79 |
+
}
|
80 |
+
</script>
|
81 |
+
</body></html>
|
templates/company_profile.html
ADDED
@@ -0,0 +1,312 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<!DOCTYPE html>
|
2 |
+
<html lang="en">
|
3 |
+
|
4 |
+
<head>
|
5 |
+
<meta charset="UTF-8">
|
6 |
+
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
7 |
+
<title>Company Profile</title>
|
8 |
+
<script src="https://code.jquery.com/jquery-3.6.0.min.js"></script>
|
9 |
+
<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/js/bootstrap.bundle.min.js"></script>
|
10 |
+
<!-- Include AdminLTE CSS -->
|
11 |
+
<link rel="stylesheet" type="text/css" href="https://cdn.jsdelivr.net/npm/[email protected]/dist/css/adminlte.min.css">
|
12 |
+
<!-- Include DataTables CSS -->
|
13 |
+
<link rel="stylesheet" type="text/css" href="https://cdn.datatables.net/1.10.25/css/dataTables.bootstrap4.min.css">
|
14 |
+
<link href="https://cdn.jsdelivr.net/npm/[email protected]/dist/css/select2.min.css" rel="stylesheet" />
|
15 |
+
<link href="https://cdn.jsdelivr.net/npm/@ttskch/[email protected]/dist/select2-bootstrap4.min.css"
|
16 |
+
rel="stylesheet" />
|
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 |
+
|
23 |
+
.content-wrapper {
|
24 |
+
background-color: transparent !important;
|
25 |
+
text-align: center;
|
26 |
+
}
|
27 |
+
.table-container{
|
28 |
+
margin-top: 0px !important;
|
29 |
+
|
30 |
+
}
|
31 |
+
.wrapper {
|
32 |
+
background-color: transparent !important;
|
33 |
+
}
|
34 |
+
|
35 |
+
.modal-content {
|
36 |
+
background-color: #fff;
|
37 |
+
}
|
38 |
+
|
39 |
+
h1 {
|
40 |
+
text-align: center;
|
41 |
+
margin-bottom: 30px;
|
42 |
+
}
|
43 |
+
|
44 |
+
.card-body {
|
45 |
+
padding: 0;
|
46 |
+
margin: 0;
|
47 |
+
}
|
48 |
+
|
49 |
+
.table-responsive {
|
50 |
+
width: 100%;
|
51 |
+
overflow-x: auto;
|
52 |
+
}
|
53 |
+
|
54 |
+
.table {
|
55 |
+
width: 100%;
|
56 |
+
}
|
57 |
+
|
58 |
+
.text-wrap {
|
59 |
+
white-space: normal !important;
|
60 |
+
word-break: break-word;
|
61 |
+
}
|
62 |
+
|
63 |
+
.center-align {
|
64 |
+
padding-top: 20px;
|
65 |
+
display: flex;
|
66 |
+
justify-content: center;
|
67 |
+
align-items: center;
|
68 |
+
width: 100%;
|
69 |
+
}
|
70 |
+
|
71 |
+
.reduced-width {
|
72 |
+
width: 50%;
|
73 |
+
}
|
74 |
+
|
75 |
+
th,
|
76 |
+
td {
|
77 |
+
white-space: nowrap;
|
78 |
+
}
|
79 |
+
|
80 |
+
th:nth-child(1),
|
81 |
+
td:nth-child(1) {
|
82 |
+
width: 5%;
|
83 |
+
}
|
84 |
+
|
85 |
+
th:nth-child(2),
|
86 |
+
td:nth-child(2) {
|
87 |
+
width: 20%;
|
88 |
+
}
|
89 |
+
|
90 |
+
th:nth-child(3),
|
91 |
+
td:nth-child(3) {
|
92 |
+
width: 20%;
|
93 |
+
}
|
94 |
+
|
95 |
+
th:nth-child(4),
|
96 |
+
td:nth-child(4) {
|
97 |
+
width: 20%;
|
98 |
+
}
|
99 |
+
|
100 |
+
th:nth-child(5),
|
101 |
+
td:nth-child(5) {
|
102 |
+
width: 20%;
|
103 |
+
}
|
104 |
+
|
105 |
+
th:nth-child(6),
|
106 |
+
td:nth-child(6) {
|
107 |
+
width: 15%;
|
108 |
+
}
|
109 |
+
|
110 |
+
th:nth-child(7),
|
111 |
+
td:nth-child(7) {
|
112 |
+
width: 20%;
|
113 |
+
}
|
114 |
+
</style>
|
115 |
+
</head>
|
116 |
+
|
117 |
+
<body>
|
118 |
+
{% include 'sidepane.html' %}
|
119 |
+
|
120 |
+
<div class="wrapper">
|
121 |
+
<div class="content-wrapper">
|
122 |
+
<!-- Content Header (Page header) -->
|
123 |
+
<div class="content-header">
|
124 |
+
<div class="container-fluid">
|
125 |
+
<div class="row mb-2">
|
126 |
+
<div class="col-12">
|
127 |
+
<div class="col-12 d-flex justify-content-end mb-3">
|
128 |
+
<button class="btn btn-primary" id="add">Add</button>
|
129 |
+
</div>
|
130 |
+
</div>
|
131 |
+
</div>
|
132 |
+
</div>
|
133 |
+
</div>
|
134 |
+
<!-- Main content -->
|
135 |
+
<section class="content">
|
136 |
+
<div class="container-fluid">
|
137 |
+
<div class="row">
|
138 |
+
<div class="col-12">
|
139 |
+
<div class="card">
|
140 |
+
<div class="card-body table-container">
|
141 |
+
<table id="companyTable" class="table table-bordered table-striped">
|
142 |
+
<thead>
|
143 |
+
<tr>
|
144 |
+
<th>Sno</th>
|
145 |
+
<th>Company Name</th>
|
146 |
+
<th>Company code</th>
|
147 |
+
<th>Domain</th>
|
148 |
+
<th>LLM Tools</th>
|
149 |
+
<th>View</th>
|
150 |
+
<th>Edit</th>
|
151 |
+
<th>Delete</th>
|
152 |
+
</tr>
|
153 |
+
</thead>
|
154 |
+
<tbody>
|
155 |
+
</tbody>
|
156 |
+
</table>
|
157 |
+
</div>
|
158 |
+
</div>
|
159 |
+
</div>
|
160 |
+
</div>
|
161 |
+
</div>
|
162 |
+
</section>
|
163 |
+
</div>
|
164 |
+
</div>
|
165 |
+
<!-- Modal -->
|
166 |
+
<div class="modal fade" id="addModal" tabindex="-1" role="dialog" aria-labelledby="addModalLabel"
|
167 |
+
aria-hidden="true">
|
168 |
+
<div class="modal-dialog" role="document">
|
169 |
+
<div class="modal-content">
|
170 |
+
<div class="modal-header">
|
171 |
+
<h5 class="modal-title" id="addModalLabel">Add Company Profile</h5>
|
172 |
+
<button type="button" class="close" data-dismiss="modal" aria-label="Close">
|
173 |
+
<span aria-hidden="true" data-backdrop="static" data-keyboard="false">×</span>
|
174 |
+
</button>
|
175 |
+
</div>
|
176 |
+
<div class="modal-body">
|
177 |
+
<form id="companyForm">
|
178 |
+
<div class="form-group">
|
179 |
+
<label for="companyName">Company Name<span class="text-danger">*</span></label>
|
180 |
+
<input type="text" class="form-control" id="company_name" name="company_name" required>
|
181 |
+
</div>
|
182 |
+
<div class="form-group">
|
183 |
+
<label for="companyCode">Company Code<span class="text-danger">*</span></label>
|
184 |
+
<input type="text" class="form-control" id="company_code" name="company_code" required>
|
185 |
+
</div>
|
186 |
+
<div class="form-group">
|
187 |
+
<label for="domain">Domain<span class="text-danger">*</span></label>
|
188 |
+
<input type="text" class="form-control" id="domain" name="domain" required>
|
189 |
+
</div>
|
190 |
+
<div class="form-group">
|
191 |
+
<label for="llm_tools">LLM Tools<span class="text-danger">*</span></label>
|
192 |
+
<select class="form-control" id="llm_tools" name="llm_tools" multiple required>
|
193 |
+
<option value="Database">Database</option>
|
194 |
+
<option value="Static Documents">Static Documents</option>
|
195 |
+
<option value="API">API</option>
|
196 |
+
</select>
|
197 |
+
<div class="invalid-feedback">
|
198 |
+
Please select at least one LLM tool.
|
199 |
+
</div>
|
200 |
+
</div>
|
201 |
+
</form>
|
202 |
+
</div>
|
203 |
+
<div class="modal-footer">
|
204 |
+
<button type="button" id="save" onclick="saveProfile()" class="btn btn-primary">Save</button>
|
205 |
+
</div>
|
206 |
+
</div>
|
207 |
+
</div>
|
208 |
+
</div>
|
209 |
+
|
210 |
+
<script src="https://cdn.datatables.net/1.10.25/js/jquery.dataTables.min.js"></script>
|
211 |
+
<script src="https://cdn.datatables.net/1.10.25/js/dataTables.bootstrap4.min.js"></script>
|
212 |
+
<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/js/select2.min.js"></script>
|
213 |
+
<script>
|
214 |
+
document.addEventListener('DOMContentLoaded', function () {
|
215 |
+
fetchCompanies();
|
216 |
+
});
|
217 |
+
|
218 |
+
$(document).ready(function () {
|
219 |
+
// Initialize DataTable
|
220 |
+
$('#companyTable').DataTable();
|
221 |
+
|
222 |
+
// Show modal function
|
223 |
+
$('#add').on('click', function () {
|
224 |
+
$('#addModal').modal('show');
|
225 |
+
});
|
226 |
+
$('.modal-footer .btn-secondary, .modal-header .close').on('click', function () {
|
227 |
+
$('#addModal').modal('hide');
|
228 |
+
});
|
229 |
+
// Initialize Select2
|
230 |
+
$('#llm_tools').select2({
|
231 |
+
theme: 'bootstrap4',
|
232 |
+
placeholder: 'Select',
|
233 |
+
allowClear: true
|
234 |
+
});
|
235 |
+
});
|
236 |
+
|
237 |
+
function saveProfile() {
|
238 |
+
const form = document.getElementById('companyForm');
|
239 |
+
|
240 |
+
// Check if the form is valid
|
241 |
+
if (!form.checkValidity()) {
|
242 |
+
// If the form is invalid, show validation messages and stop the submission
|
243 |
+
form.reportValidity();
|
244 |
+
return;
|
245 |
+
}
|
246 |
+
// Gather form data
|
247 |
+
const company_name = document.getElementById('company_name').value;
|
248 |
+
const company_code = document.getElementById('company_code').value;
|
249 |
+
const domain = document.getElementById('domain').value;
|
250 |
+
const llm_tools = $('#llm_tools').val(); // Get selected values from Select2
|
251 |
+
|
252 |
+
// Prepare FormData
|
253 |
+
let formData = new FormData();
|
254 |
+
formData.append("company_name", company_name);
|
255 |
+
formData.append("company_code", company_code);
|
256 |
+
formData.append("domain", domain);
|
257 |
+
formData.append("llm_tools", llm_tools.join(','));
|
258 |
+
|
259 |
+
$.ajax({
|
260 |
+
type: "POST",
|
261 |
+
url: "/submit_company_profile",
|
262 |
+
data: formData,
|
263 |
+
processData: false,
|
264 |
+
contentType: false,
|
265 |
+
success: function (response) {
|
266 |
+
alert("Data saved successfully"); // Show success message
|
267 |
+
fetchCompanies(); // Refresh table data
|
268 |
+
|
269 |
+
// Clear the form and close the modal
|
270 |
+
$('#companyForm')[0].reset();
|
271 |
+
$('#addModal').modal('hide');
|
272 |
+
},
|
273 |
+
error: function (xhr) {
|
274 |
+
alert("An error occurred: " + xhr.responseJSON.detail); // Show error message
|
275 |
+
}
|
276 |
+
});
|
277 |
+
}
|
278 |
+
|
279 |
+
async function fetchCompanies() {
|
280 |
+
try {
|
281 |
+
console.log("Fetching companies...");
|
282 |
+
const response = await fetch(`/api/companydetails`);
|
283 |
+
const companies = await response.json();
|
284 |
+
console.log(companies); // Inspect the data here
|
285 |
+
|
286 |
+
if (!Array.isArray(companies)) {
|
287 |
+
throw new TypeError('Expected an array of companies');
|
288 |
+
}
|
289 |
+
|
290 |
+
const table = $('#companyTable').DataTable();
|
291 |
+
table.clear(); // Clear existing table data
|
292 |
+
|
293 |
+
companies.forEach((company, index) => {
|
294 |
+
table.row.add([
|
295 |
+
index + 1,
|
296 |
+
company.company_name,
|
297 |
+
company.company_code,
|
298 |
+
company.domain,
|
299 |
+
company.llm_tools, // Join array of tools into a string
|
300 |
+
"<a href='#' class='btn btn-info btn-sm'><i class='fas fa-eye'></i></a>",
|
301 |
+
"<a href='#' class='btn btn-warning btn-sm'><i class='fas fa-edit'></i></a>",
|
302 |
+
"<a href='#' class='btn btn-danger btn-sm'><i class='fas fa-trash'></i></button>"
|
303 |
+
]).draw(false);
|
304 |
+
});
|
305 |
+
} catch (error) {
|
306 |
+
console.error('Error fetching companies:', error);
|
307 |
+
}
|
308 |
+
}
|
309 |
+
</script>
|
310 |
+
</body>
|
311 |
+
|
312 |
+
</html>
|
templates/company_profile2.html
ADDED
@@ -0,0 +1,315 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<!DOCTYPE html>
|
2 |
+
<html lang="en">
|
3 |
+
|
4 |
+
<head>
|
5 |
+
<meta charset="UTF-8">
|
6 |
+
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
7 |
+
<title>Company Profile</title>
|
8 |
+
<script src="https://code.jquery.com/jquery-3.6.0.min.js"></script>
|
9 |
+
<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/js/bootstrap.bundle.min.js"></script>
|
10 |
+
<!-- Include AdminLTE CSS -->
|
11 |
+
<link rel="stylesheet" type="text/css" href="https://cdn.jsdelivr.net/npm/[email protected]/dist/css/adminlte.min.css">
|
12 |
+
<!-- Include DataTables CSS -->
|
13 |
+
<link rel="stylesheet" type="text/css" href="https://cdn.datatables.net/1.10.25/css/dataTables.bootstrap4.min.css">
|
14 |
+
<link href="https://cdn.jsdelivr.net/npm/[email protected]/dist/css/select2.min.css" rel="stylesheet" />
|
15 |
+
<link href="https://cdn.jsdelivr.net/npm/@ttskch/[email protected]/dist/select2-bootstrap4.min.css"
|
16 |
+
rel="stylesheet" />
|
17 |
+
|
18 |
+
<style>
|
19 |
+
body {
|
20 |
+
font-family: Arial, sans-serif;
|
21 |
+
padding: 20px;
|
22 |
+
}
|
23 |
+
|
24 |
+
.form-wrapper {
|
25 |
+
max-width: 600px; /* Set maximum width for the form */
|
26 |
+
margin-left:380px; /* Center the form horizontally */
|
27 |
+
}
|
28 |
+
|
29 |
+
.form-group {
|
30 |
+
margin-bottom: 20px;
|
31 |
+
}
|
32 |
+
|
33 |
+
.form-group label {
|
34 |
+
font-weight: bold;
|
35 |
+
margin-bottom: 5px;
|
36 |
+
padding-top: 20px;
|
37 |
+
margin-left: 90px;
|
38 |
+
display: block;
|
39 |
+
}
|
40 |
+
|
41 |
+
.form-group input,
|
42 |
+
.form-group select {
|
43 |
+
width: calc(100% - 90px)!important;
|
44 |
+
padding: 10px;
|
45 |
+
margin-left: 90px;
|
46 |
+
border: 1px solid #ccc;
|
47 |
+
border-radius: 4px;
|
48 |
+
}
|
49 |
+
|
50 |
+
/* .form-group select.select2-container--bootstrap4 .select2-selection--multiple {
|
51 |
+
height: 10px !important;
|
52 |
+
align-content: center!important;
|
53 |
+
align-items: center !important;
|
54 |
+
} */
|
55 |
+
.selection{
|
56 |
+
margin-left: 90px !important;
|
57 |
+
width: calc(100% - 95px)!important;
|
58 |
+
min-height:0px!important;
|
59 |
+
padding-top: 20px !important;
|
60 |
+
margin-bottom: -20px!important;
|
61 |
+
|
62 |
+
}
|
63 |
+
.select2-container{
|
64 |
+
text-align: center !important;
|
65 |
+
height: 0px !important;
|
66 |
+
margin: -25px 5px!important;
|
67 |
+
|
68 |
+
}
|
69 |
+
select.form-control[multiple], select.form-control[size]{
|
70 |
+
height: 10px !important;
|
71 |
+
}
|
72 |
+
/* .select2-selection select2-selection--multiple{
|
73 |
+
margin-top: 10px;
|
74 |
+
margin: -25px!important;
|
75 |
+
} */
|
76 |
+
.btn-primary {
|
77 |
+
margin-right: 10px;
|
78 |
+
margin-left: 40px;
|
79 |
+
color: white;
|
80 |
+
background-color: #007bff;
|
81 |
+
font-size: 16px;
|
82 |
+
font-weight: bold;
|
83 |
+
border: none;
|
84 |
+
padding: 10px 20px;
|
85 |
+
border-radius: 4px;
|
86 |
+
}
|
87 |
+
|
88 |
+
.btn-container {
|
89 |
+
text-align: center;
|
90 |
+
margin-top: 20px;
|
91 |
+
margin-left: 20px;
|
92 |
+
}
|
93 |
+
|
94 |
+
footer {
|
95 |
+
position: fixed;
|
96 |
+
bottom: 0;
|
97 |
+
width: 100%;
|
98 |
+
color: black;
|
99 |
+
text-align: right;
|
100 |
+
padding-right: 20px;
|
101 |
+
padding-top: 10px;
|
102 |
+
background-color: #f8f9fa;
|
103 |
+
border: none !important;
|
104 |
+
}
|
105 |
+
|
106 |
+
#llm_tools {
|
107 |
+
|
108 |
+
text-align: center;
|
109 |
+
font-weight: bold;
|
110 |
+
}
|
111 |
+
.form-control1{
|
112 |
+
|
113 |
+
margin-top: 0px !important;
|
114 |
+
}
|
115 |
+
</style>
|
116 |
+
</head>
|
117 |
+
|
118 |
+
<body>
|
119 |
+
{% include 'sidepane.html' %}
|
120 |
+
<div class="form-wrapper">
|
121 |
+
<div id="message-container"></div>
|
122 |
+
<form id="roleform">
|
123 |
+
<div id="roleform" class="form-group ",style="display:none;">
|
124 |
+
<label for="company">Company Name <span class="text-danger">*</span></label>
|
125 |
+
<select type="text" id="company" name="company" class="form-control" required>
|
126 |
+
<option value="" selected>Select</option>
|
127 |
+
</select>
|
128 |
+
</div>
|
129 |
+
<input type="hidden" id="company_id" name="company_id" class="form-control" required>
|
130 |
+
</form>
|
131 |
+
<form id="companyProfileForm" class="needs-validation" novalidate action="/submit_company_profile"
|
132 |
+
method="post">
|
133 |
+
<div class="row">
|
134 |
+
<div class="col-md-6">
|
135 |
+
<div class="form-group">
|
136 |
+
<input type="hidden" id="userRole" name="userRole" value={{userRole}}>
|
137 |
+
<label for="company_name">Company Name <span class="text-danger">*</span></label>
|
138 |
+
<input type="text" id="company_name" name="company_name" class="form-control" required>
|
139 |
+
<div class="invalid-feedback">
|
140 |
+
Please enter the company name.
|
141 |
+
</div>
|
142 |
+
</div>
|
143 |
+
</div>
|
144 |
+
<div class="col-md-6">
|
145 |
+
<div class="form-group">
|
146 |
+
<label for="company_code">Company Code <span class="text-danger">*</span></label>
|
147 |
+
<input type="text" id="company_code" name="company_code" class="form-control" required>
|
148 |
+
<div class="invalid-feedback">
|
149 |
+
Please enter the company code.
|
150 |
+
</div>
|
151 |
+
</div>
|
152 |
+
</div>
|
153 |
+
</div>
|
154 |
+
<div class="row">
|
155 |
+
<div class="col-md-6">
|
156 |
+
<div class="form-group">
|
157 |
+
<label for="domain">Domain/Business <span class="text-danger">*</span></label>
|
158 |
+
<input type="text" id="domain" name="domain" class="form-control" required>
|
159 |
+
<div class="invalid-feedback">
|
160 |
+
Please enter the domain/business.
|
161 |
+
</div>
|
162 |
+
</div>
|
163 |
+
</div>
|
164 |
+
<div class="col-md-6">
|
165 |
+
<div class="selection">
|
166 |
+
<label for="llm_tools">LLM Tools <span class="text-danger">*</span></label>
|
167 |
+
<select type='text' id="llm_tools" name="llm_tools" class="form-control" multiple required>
|
168 |
+
<option value="Database">Database</option>
|
169 |
+
<option value="Static Documents">Static Documents</option>
|
170 |
+
<option value="API">API</option>
|
171 |
+
</select>
|
172 |
+
<div class="invalid-feedback">
|
173 |
+
Please select at least one LLM tool.
|
174 |
+
</div>
|
175 |
+
</div>
|
176 |
+
</div>
|
177 |
+
</div>
|
178 |
+
<div class="btn-container">
|
179 |
+
<button type="submit" class="btn btn-primary">Save</button>
|
180 |
+
<button type="reset" class="btn btn-primary">Clear</button>
|
181 |
+
</div>
|
182 |
+
</form>
|
183 |
+
</div>
|
184 |
+
|
185 |
+
<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/js/select2.min.js"></script>
|
186 |
+
<script>
|
187 |
+
document.addEventListener("DOMContentLoaded", function() {
|
188 |
+
// // Retrieve user role from sessionStorage
|
189 |
+
// var role = sessionStorage.getItem('userRole');
|
190 |
+
// console.log("Retrieved user role from sessionStorage:", role); // Debugging
|
191 |
+
// if (role) {
|
192 |
+
// document.getElementById('userRole').value = role;
|
193 |
+
// console.log("role is set");
|
194 |
+
fetchCompanies();
|
195 |
+
const companySelect = document.getElementById('company');
|
196 |
+
const companyProfileForm = document.getElementById('companyProfileForm');
|
197 |
+
|
198 |
+
companySelect.addEventListener('change', async function () {
|
199 |
+
const selectedCompanyName = companySelect.options[companySelect.selectedIndex].text;
|
200 |
+
console.log(`Selected Company Name: ${selectedCompanyName}`);
|
201 |
+
|
202 |
+
if (selectedCompanyName !== "Select") {
|
203 |
+
try {
|
204 |
+
const response = await fetch(`/api/company_id?company_name=${encodeURIComponent(selectedCompanyName)}`);
|
205 |
+
if (!response.ok) {
|
206 |
+
throw new Error('Network response was not ok');
|
207 |
+
}
|
208 |
+
const data = await response.json();
|
209 |
+
console.log(`Company ID: ${data.company_id}`);
|
210 |
+
const companyId = data.company_id;
|
211 |
+
document.getElementById('company_id').value = companyId;
|
212 |
+
|
213 |
+
if (companyId) {
|
214 |
+
//setMultiSelectValues(document.getElementById('database'), connectorsData.databasetype); // Ensure this is an array
|
215 |
+
//setMultiSelectValues(document.getElementById('databaseName'), connectorsData.database_name); // Ensure this is an array
|
216 |
+
document.getElementById('company_name').value =data.company_name;
|
217 |
+
document.getElementById('company_code').value = data.company_code;
|
218 |
+
document.getElementById('domain').value = data.domain;
|
219 |
+
//document.getElementById('llm_tools').value = data.llm_tools;
|
220 |
+
$('#llm_tools').val(data.llm_tools).trigger('change');
|
221 |
+
}
|
222 |
+
else {
|
223 |
+
console.log(`Company ID does not exist, you can create and save data: ${data.company_id}`);
|
224 |
+
companyProfileForm.style.display = 'none';
|
225 |
+
}
|
226 |
+
}catch (error) {
|
227 |
+
document.getElementById('company_name').value = " ";
|
228 |
+
document.getElementById('company_code').value = " ";
|
229 |
+
document.getElementById('domain').value = " ";
|
230 |
+
//document.getElementById('llm_tools').value = " ";
|
231 |
+
$('#llm_tools').val([]).trigger('change'); // Clear the multi-select dropdown
|
232 |
+
|
233 |
+
console.error('Error fetching data from data connectors:', error);
|
234 |
+
("Company name does not exist. Please fill in the details.");
|
235 |
+
|
236 |
+
// Optionally, you can insert a message into the DOM
|
237 |
+
const messageContainer = document.getElementById('message-container');
|
238 |
+
if (messageContainer) {
|
239 |
+
messageContainer.innerHTML = "<div class='alert alert-danger'>Database details does not exist for this Company name.. Please fill in the details.</div>";
|
240 |
+
}
|
241 |
+
|
242 |
+
companyProfileForm.style.display = 'block';
|
243 |
+
}
|
244 |
+
}
|
245 |
+
});
|
246 |
+
|
247 |
+
// }
|
248 |
+
});
|
249 |
+
$(document).ready(function () {
|
250 |
+
// Initialize Select2 for multi-select dropdown
|
251 |
+
$('#llm_tools').select2({
|
252 |
+
theme: 'bootstrap4',
|
253 |
+
placeholder: 'Select',
|
254 |
+
allowClear: true
|
255 |
+
});
|
256 |
+
});
|
257 |
+
async function fetchCompanies() {
|
258 |
+
try {
|
259 |
+
// const roledata=document.getElementById("userRole").value;
|
260 |
+
// console.log("Role data before fetch:", roledata); // Debugging
|
261 |
+
// if(roledata==='admin')
|
262 |
+
// {
|
263 |
+
// console.log("Admin role detected"); // Debugging
|
264 |
+
// $('#roleform').show();
|
265 |
+
const response = await fetch('/api/companies');
|
266 |
+
if (!response.ok) {
|
267 |
+
throw new Error('Network response was not ok');
|
268 |
+
}
|
269 |
+
const data = await response.json();
|
270 |
+
displayCompanies(data.companies);
|
271 |
+
}
|
272 |
+
catch (error) {
|
273 |
+
console.error('Error fetching companies:', error);
|
274 |
+
}
|
275 |
+
|
276 |
+
}
|
277 |
+
|
278 |
+
function displayCompanies(companies) {
|
279 |
+
const companySelect = document.getElementById('company');
|
280 |
+
companySelect.innerHTML = '<option value="" selected>Select</option>'; // Reset the dropdown
|
281 |
+
companies.forEach(company => {
|
282 |
+
const option = document.createElement('option');
|
283 |
+
option.value = company.name;
|
284 |
+
option.textContent = company.name;
|
285 |
+
companySelect.appendChild(option);
|
286 |
+
});
|
287 |
+
}
|
288 |
+
|
289 |
+
$('#companyProfileForm').on('submit', function (event) {
|
290 |
+
event.preventDefault(); // Prevent default form submission
|
291 |
+
|
292 |
+
// Gather form data
|
293 |
+
var formData = $(this).serialize();
|
294 |
+
|
295 |
+
$.ajax({
|
296 |
+
type: "POST",
|
297 |
+
url: "/submit_company_profile",
|
298 |
+
data: formData,
|
299 |
+
success: function (response) {
|
300 |
+
alert("Data saved successfully"); // Show success message
|
301 |
+
setTimeout(function () {
|
302 |
+
window.location.href = '/company_profile'; // Redirect to the desired page after a delay
|
303 |
+
}, 2000); // Delay for 2 seconds (2000 milliseconds)
|
304 |
+
},
|
305 |
+
error: function (xhr) {
|
306 |
+
alert("An error occurred: " + xhr.responseJSON.detail); // Show error message
|
307 |
+
}
|
308 |
+
});
|
309 |
+
});
|
310 |
+
|
311 |
+
</script>
|
312 |
+
|
313 |
+
</body>
|
314 |
+
|
315 |
+
</html>
|
templates/dashboard.html
ADDED
@@ -0,0 +1,156 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<!DOCTYPE html>
|
2 |
+
<html>
|
3 |
+
<head>
|
4 |
+
<meta charset="UTF-8">
|
5 |
+
<title>Dashboard</title>
|
6 |
+
<!-- AdminLTE CSS -->
|
7 |
+
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/admin-lte/3.1.0/css/adminlte.min.css">
|
8 |
+
</head>
|
9 |
+
|
10 |
+
<body class="hold-transition sidebar-mini">
|
11 |
+
<div class="wrapper">
|
12 |
+
<!-- Main Sidebar -->
|
13 |
+
<aside class="main-sidebar sidebar-dark-primary elevation-4">
|
14 |
+
<!-- Sidebar -->
|
15 |
+
<div class="sidebar">
|
16 |
+
<!-- Sidebar Menu -->
|
17 |
+
<nav class="mt-2">
|
18 |
+
<ul class="nav nav-pills nav-sidebar flex-column" data-widget="treeview" role="menu" data-accordion="false">
|
19 |
+
<!-- Navigation Links -->
|
20 |
+
<li class="nav-item">
|
21 |
+
<a href="{{url_for('dashboard')}}" class="nav-link">
|
22 |
+
<i class="nav-icon fas fa-home"></i>
|
23 |
+
<p>Dashboard</p>
|
24 |
+
</a>
|
25 |
+
</li>
|
26 |
+
<li class="nav-item">
|
27 |
+
<a href="{{ url_for('company_profile') }}" class="nav-link">
|
28 |
+
<i class="nav-icon fas fa-cogs"></i>
|
29 |
+
<p>Company Profile</p>
|
30 |
+
</a>
|
31 |
+
</li>
|
32 |
+
<li class="nav-item">
|
33 |
+
<a href="{{ url_for('knowledgebase') }}" class="nav-link">
|
34 |
+
<i class="nav-icon fas fa-cogs"></i>
|
35 |
+
<p>KnowledgeBase</p>
|
36 |
+
</a>
|
37 |
+
</li>
|
38 |
+
<li class="nav-item">
|
39 |
+
<a href="{{ url_for('data_connectors') }}" class="nav-link">
|
40 |
+
<i class="nav-icon fas fa-home"></i>
|
41 |
+
<p>Data Connectors</p>
|
42 |
+
</a>
|
43 |
+
</li>
|
44 |
+
<li class="nav-item">
|
45 |
+
<a href="{{ url_for('API_connectors') }}" class="nav-link">
|
46 |
+
<i class="nav-icon fas fa-users"></i>
|
47 |
+
<p>API Connectors</p>
|
48 |
+
</a>
|
49 |
+
</li>
|
50 |
+
<li class="nav-item">
|
51 |
+
<a href="{{url_for('prompt_template')}}" class="nav-link">
|
52 |
+
<i class="nav-icon fas fa-cogs"></i>
|
53 |
+
<p>Prompt Templates</p>
|
54 |
+
</a>
|
55 |
+
</li>
|
56 |
+
<!-- <li class="nav-item">
|
57 |
+
<a href="#" class="nav-link">
|
58 |
+
<i class="nav-icon fas fa-cogs"></i>
|
59 |
+
<p>LLM Settings</p>
|
60 |
+
</a>
|
61 |
+
|
62 |
+
</li>-->
|
63 |
+
<li class="nav-item">
|
64 |
+
<a href="{{ url_for('chatbot') }}" class="nav-link">
|
65 |
+
<i class="nav-icon fas fa-cogs"></i>
|
66 |
+
<p>Chat</p>
|
67 |
+
</a>
|
68 |
+
</li>
|
69 |
+
|
70 |
+
<!-- Add more navigation links here -->
|
71 |
+
</ul>
|
72 |
+
</nav>
|
73 |
+
<!-- /.sidebar-menu -->
|
74 |
+
</div>
|
75 |
+
<!-- /.sidebar -->
|
76 |
+
</aside>
|
77 |
+
|
78 |
+
<!-- Content Wrapper -->
|
79 |
+
<div class="content-wrapper">
|
80 |
+
<!-- Main content -->
|
81 |
+
<section class="content">
|
82 |
+
<!-- Project Information -->
|
83 |
+
<div class="container-fluid">
|
84 |
+
<h3 style="text-align: center; margin-bottom:40px;">RedMindGPT</h>
|
85 |
+
</div>
|
86 |
+
</section>
|
87 |
+
<section class="content">
|
88 |
+
<div class="container-fluid">
|
89 |
+
|
90 |
+
<div class="row">
|
91 |
+
<div class="col-lg-4 col-6">
|
92 |
+
|
93 |
+
<div class="small-box bg-info">
|
94 |
+
<div class="inner">
|
95 |
+
<h3>4 </h3>
|
96 |
+
<h4> KnowledgeBase</h4>
|
97 |
+
</div>
|
98 |
+
<div class="icon">
|
99 |
+
<i class="ion ion-bag"></i>
|
100 |
+
</div>
|
101 |
+
</div>
|
102 |
+
</div>
|
103 |
+
|
104 |
+
<div class="col-lg-4 col-6">
|
105 |
+
|
106 |
+
<div class="small-box bg-success">
|
107 |
+
<div class="inner">
|
108 |
+
<h3>1</h3>
|
109 |
+
<h4>Data connectors</h4>
|
110 |
+
</div>
|
111 |
+
<div class="icon">
|
112 |
+
<i class="ion ion-stats-bars"></i>
|
113 |
+
</div>
|
114 |
+
|
115 |
+
</div>
|
116 |
+
</div>
|
117 |
+
|
118 |
+
<div class="col-lg-4 col-6">
|
119 |
+
|
120 |
+
<div class="small-box bg-warning">
|
121 |
+
<div class="inner">
|
122 |
+
<h3>4 </h3>
|
123 |
+
<h4>API Connectors</h4>
|
124 |
+
</div>
|
125 |
+
<div class="icon">
|
126 |
+
<i class="ion ion-person-add"></i>
|
127 |
+
</div>
|
128 |
+
|
129 |
+
</div>
|
130 |
+
</div>
|
131 |
+
|
132 |
+
<div class="col-lg-4 col-6">
|
133 |
+
|
134 |
+
<div class="small-box bg-warning">
|
135 |
+
<div class="inner">
|
136 |
+
<h3>5 </h3>
|
137 |
+
<h4>Prompt_Templates</h4>
|
138 |
+
</div>
|
139 |
+
<div class="icon">
|
140 |
+
<i class="ion ion-person-add"></i>
|
141 |
+
</div>
|
142 |
+
|
143 |
+
</div>
|
144 |
+
</div>
|
145 |
+
<!-- /.content -->
|
146 |
+
</div>
|
147 |
+
<!-- /.content-wrapper -->
|
148 |
+
</div>
|
149 |
+
<!-- ./wrapper -->
|
150 |
+
|
151 |
+
<!-- AdminLTE JS -->
|
152 |
+
<script src="https://cdnjs.cloudflare.com/ajax/libs/admin-lte/3.1.0/js/adminlte.min.js"></script>
|
153 |
+
|
154 |
+
</body>
|
155 |
+
|
156 |
+
</html>
|
templates/data_connectors.html
ADDED
@@ -0,0 +1,463 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<!DOCTYPE html>
|
2 |
+
<html lang="en">
|
3 |
+
|
4 |
+
<head>
|
5 |
+
<meta charset="UTF-8">
|
6 |
+
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
7 |
+
<title>Data Connectors</title>
|
8 |
+
<script src="https://code.jquery.com/jquery-3.6.0.min.js"></script>
|
9 |
+
<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/js/bootstrap.bundle.min.js"></script>
|
10 |
+
<link rel="stylesheet" type="text/css" href="https://cdn.jsdelivr.net/npm/[email protected]/dist/css/adminlte.min.css">
|
11 |
+
<link rel="stylesheet" type="text/css" href="https://cdn.datatables.net/1.10.25/css/dataTables.bootstrap4.min.css">
|
12 |
+
|
13 |
+
<style>
|
14 |
+
html,
|
15 |
+
body {
|
16 |
+
height: 90%;
|
17 |
+
margin: 0;
|
18 |
+
display: flex;
|
19 |
+
flex-direction: column;
|
20 |
+
}
|
21 |
+
|
22 |
+
body {
|
23 |
+
display: inline-flex;
|
24 |
+
flex-direction: column;
|
25 |
+
min-height: 90%;
|
26 |
+
}
|
27 |
+
|
28 |
+
.main-content {
|
29 |
+
flex: 1;
|
30 |
+
display:inline-flex;
|
31 |
+
flex-direction: column;
|
32 |
+
align-items: center;
|
33 |
+
justify-content: flex-start;
|
34 |
+
padding: 40px;
|
35 |
+
}
|
36 |
+
|
37 |
+
/* .container {
|
38 |
+
margin-top: 50px;
|
39 |
+
margin-left: 320px;
|
40 |
+
max-width: 800px;
|
41 |
+
padding: 10px;
|
42 |
+
border: 1px solid #ccc;
|
43 |
+
border-radius: 5px;
|
44 |
+
background-color: #fff;
|
45 |
+
position: relative;
|
46 |
+
z-index: 1;
|
47 |
+
} */
|
48 |
+
|
49 |
+
.form-group {
|
50 |
+
margin-bottom: 20px;
|
51 |
+
}
|
52 |
+
|
53 |
+
.form-group label {
|
54 |
+
font-weight: bold;
|
55 |
+
margin-left: 50px;
|
56 |
+
display: block;
|
57 |
+
}
|
58 |
+
|
59 |
+
.form-group input,
|
60 |
+
.form-group select,
|
61 |
+
.form-group textarea {
|
62 |
+
width: 100%;
|
63 |
+
margin-left: 50px;
|
64 |
+
padding: 5px;
|
65 |
+
border: 1px solid #ccc;
|
66 |
+
border-radius: 4px;
|
67 |
+
}
|
68 |
+
|
69 |
+
.btn-primary {
|
70 |
+
margin-right: 10px;
|
71 |
+
color: black;
|
72 |
+
font-size: 16px;
|
73 |
+
font-weight: bold;
|
74 |
+
}
|
75 |
+
|
76 |
+
/* .btn-container {
|
77 |
+
text-align: center;
|
78 |
+
margin-top: 20px;
|
79 |
+
margin-bottom: 10px;
|
80 |
+
} */
|
81 |
+
.btn-primary {
|
82 |
+
margin-right: 10px;
|
83 |
+
color: black;
|
84 |
+
font-size: 16px;
|
85 |
+
font-weight: bold;
|
86 |
+
}
|
87 |
+
|
88 |
+
|
89 |
+
.btn-container {
|
90 |
+
text-align: center;
|
91 |
+
margin-top: 30px;
|
92 |
+
margin-left: 90px;
|
93 |
+
margin-right: 0px;
|
94 |
+
margin-bottom: 10px;
|
95 |
+
/* color: white; */
|
96 |
+
}
|
97 |
+
.btn-container1 {
|
98 |
+
text-align: center;
|
99 |
+
margin-top: 30px;
|
100 |
+
margin-left: 80px;
|
101 |
+
margin-right: 30px;
|
102 |
+
margin-bottom: 10px;
|
103 |
+
color: white;
|
104 |
+
}
|
105 |
+
/* #selectedTables,
|
106 |
+
#labelselected {
|
107 |
+
display: none;
|
108 |
+
} */
|
109 |
+
.btn-primary:focus,
|
110 |
+
.btn-primary:active {
|
111 |
+
color: black;
|
112 |
+
background-color: #007bff;
|
113 |
+
border-color: #007bff;
|
114 |
+
box-shadow: none;
|
115 |
+
}
|
116 |
+
#saveBtn1 {
|
117 |
+
|
118 |
+
margin: 0 auto;
|
119 |
+
}
|
120 |
+
|
121 |
+
footer {
|
122 |
+
position: relative;
|
123 |
+
margin-top: auto;
|
124 |
+
width: 100%;
|
125 |
+
color: black;
|
126 |
+
text-align: right;
|
127 |
+
padding-right: 245px;
|
128 |
+
padding-top: 20px;
|
129 |
+
background-color: #f8f9fa;
|
130 |
+
border: none !important;
|
131 |
+
}
|
132 |
+
|
133 |
+
.small-select {
|
134 |
+
width: 200px; /* Adjust the width as needed */
|
135 |
+
}
|
136 |
+
.custom-dropdown {
|
137 |
+
width: 230px; /* Adjust the width as needed */
|
138 |
+
}
|
139 |
+
</style>
|
140 |
+
|
141 |
+
</style>
|
142 |
+
</head>
|
143 |
+
|
144 |
+
<body>
|
145 |
+
{% include 'sidepane.html' %}
|
146 |
+
<div class="main-content">
|
147 |
+
<div id="message-container"></div>
|
148 |
+
<div class="mt-2">
|
149 |
+
<div class="form-group small-select">
|
150 |
+
<label for="company">Company Name <span class="text-danger">*</span></label>
|
151 |
+
<select type="text" id="company" name="company" class="form-control " required>
|
152 |
+
<option value="" selected>Select</option>
|
153 |
+
</select>
|
154 |
+
</div>
|
155 |
+
<form id="databaseconnectorForm" class="needs-validation" novalidate action="/save_data_connectors" method="post" style="display:none;">
|
156 |
+
<div class="form-group">
|
157 |
+
<!-- <label for="company_id">company_id</label>--->
|
158 |
+
<input type="hidden" id="company_id" name="company_id" class="form-control" required>
|
159 |
+
</div>
|
160 |
+
<div class="row">
|
161 |
+
<div class="col-md-3">
|
162 |
+
<div class="form-group">
|
163 |
+
<label for="database">Database Type<span class="text-danger">*</span></label>
|
164 |
+
<select type="text" id="database" name="database" class="form-control" required>
|
165 |
+
<option value="" selected>Select</option>
|
166 |
+
<option value="Postgress">Postgres</option>
|
167 |
+
<option value="mysql">Mysql</option>
|
168 |
+
</select>
|
169 |
+
</div>
|
170 |
+
</div>
|
171 |
+
<div class="col-md-3">
|
172 |
+
<div class="form-group">
|
173 |
+
<label for="server">Server IP <span class="text-danger">*</span></label>
|
174 |
+
<input type="text" id="server" name="server" class="form-control" required>
|
175 |
+
</div>
|
176 |
+
</div>
|
177 |
+
<div class="col-md-3">
|
178 |
+
<div class="form-group">
|
179 |
+
<label for="port">Port <span class="text-danger">*</span></label>
|
180 |
+
<input type="text" id="port" name="port" class="form-control" required>
|
181 |
+
</div>
|
182 |
+
</div>
|
183 |
+
<div class="col-md-3">
|
184 |
+
<div class="form-group">
|
185 |
+
<label for="databaseName">Database Name <span class="text-danger">*</span></label>
|
186 |
+
<input type="text" id="databaseName" name="databaseName" class="form-control" required>
|
187 |
+
</div>
|
188 |
+
</div>
|
189 |
+
</div>
|
190 |
+
<div class="row">
|
191 |
+
<div class="col-md-3">
|
192 |
+
<div class="form-group">
|
193 |
+
<label for="userame">UserName <span class="text-danger">*</span></label>
|
194 |
+
<input type="text" id="username" name="username" class="form-control" required>
|
195 |
+
</div>
|
196 |
+
</div>
|
197 |
+
<div class="col-md-3">
|
198 |
+
<div class="form-group">
|
199 |
+
<label for="password">Password <span class="text-danger">*</span></label>
|
200 |
+
<input type="password" id="password" name="password" class="form-control" required>
|
201 |
+
</div>
|
202 |
+
</div>
|
203 |
+
|
204 |
+
<div class="col-md-6">
|
205 |
+
<div class="form-group d-flex justify-content-between">
|
206 |
+
<div class="form-group btn-container">
|
207 |
+
<button type="button" id="connectBtn" class="btn btn-primary">Connect</button>
|
208 |
+
<button type="reset" class="btn btn-primary">Clear</button>
|
209 |
+
</div>
|
210 |
+
</div>
|
211 |
+
</div>
|
212 |
+
</div>
|
213 |
+
<div id="schema-table-section" style="display: none;">
|
214 |
+
<div class="row">
|
215 |
+
<div class="col-md-3">
|
216 |
+
<div class="form-group">
|
217 |
+
<label for="schemas" >Select Schemas <span class="text-danger">*</span></label>
|
218 |
+
<select type="text" id="schemas" name="schemas" class="form-control" required>
|
219 |
+
<option value="" selected>Select</option>
|
220 |
+
<option value="schema1">Lookup</option>
|
221 |
+
<option value="schema2">Public</option>
|
222 |
+
<option value="schema3" selected>tenant_default</option>
|
223 |
+
</select>
|
224 |
+
</div>
|
225 |
+
</div>
|
226 |
+
|
227 |
+
<div class="co-md-3" >
|
228 |
+
<div class="formgroup">
|
229 |
+
<label for="tableschema" style="margin-left: 90px;margin-right: 30px;">Select Tables <span class="text-danger">*</span></label>
|
230 |
+
<div class="dropdown custom-dropdown">
|
231 |
+
<button class="btn btn-secondary dropdown-toggle" style="margin-left: 90px;margin-right: 30px;" type="button" id="tablesDropdown" data-bs-toggle="dropdown" aria-expanded="false">
|
232 |
+
Select Tables
|
233 |
+
</button>
|
234 |
+
<ul class="dropdown-menu" aria-labelledby="tablesDropdown">
|
235 |
+
<li>
|
236 |
+
<select type="text" id="tableschema" name="tableschema" class="form-control" multiple required>
|
237 |
+
<option value="customer_master">customer_master</option>
|
238 |
+
<option value="efs_company_master">efs_company_master</option>
|
239 |
+
<option value="efs_group_company_master">efs_group_company_master</option>
|
240 |
+
<option value="efs_region_master">efs_region_master</option>
|
241 |
+
<option value="party_address_detail">party_address_detail</option>
|
242 |
+
<option value="wms_warehouse_master">wms_warehouse_master</option>
|
243 |
+
</select>
|
244 |
+
</li>
|
245 |
+
</ul>
|
246 |
+
</div>
|
247 |
+
</div>
|
248 |
+
</div>
|
249 |
+
<!-- <div class="col-md-3">
|
250 |
+
<div class="btn-container1">
|
251 |
+
<button type="button" id="saveBtn" class="btn btn-primary">Save</button>
|
252 |
+
</div>
|
253 |
+
</div>
|
254 |
+
</div>
|
255 |
+
<div class="row">-->
|
256 |
+
<div class="col-md-3">
|
257 |
+
<div class="form-group">
|
258 |
+
<label for="selectedTables" id="labelselected">Selected Tables</label>
|
259 |
+
<textarea type="text" id="selectedTables" name="selectedTables" class="form-control" rows="4"
|
260 |
+
readonly></textarea>
|
261 |
+
</div>
|
262 |
+
</div>
|
263 |
+
|
264 |
+
<div class="col-md-3">
|
265 |
+
<div class="form-group">
|
266 |
+
<div class="btn-container1">
|
267 |
+
<button type="submit" id="saveBtn" class="btn btn-primary">Save</button>
|
268 |
+
</div>
|
269 |
+
</div>
|
270 |
+
</div>
|
271 |
+
</div>
|
272 |
+
</div>
|
273 |
+
</form>
|
274 |
+
</div>
|
275 |
+
</div>
|
276 |
+
</div>
|
277 |
+
<footer>
|
278 |
+
<p></p>
|
279 |
+
</footer>
|
280 |
+
<script>
|
281 |
+
|
282 |
+
document.addEventListener('DOMContentLoaded', function () {
|
283 |
+
fetchCompanies();
|
284 |
+
const companySelect = document.getElementById('company');
|
285 |
+
const databaseconnectorForm = document.getElementById('databaseconnectorForm');
|
286 |
+
|
287 |
+
companySelect.addEventListener('change', async function () {
|
288 |
+
$("#message-container").empty();
|
289 |
+
const selectedCompanyName = companySelect.options[companySelect.selectedIndex].text;
|
290 |
+
console.log(`Selected Company Name: ${selectedCompanyName}`);
|
291 |
+
|
292 |
+
if (selectedCompanyName !== "Select") {
|
293 |
+
$("#schema-table-section").hide();
|
294 |
+
try {
|
295 |
+
const response = await fetch(`/api/company_id?company_name=${encodeURIComponent(selectedCompanyName)}`);
|
296 |
+
if (!response.ok) {
|
297 |
+
throw new Error('Network response was not ok');
|
298 |
+
}
|
299 |
+
const data = await response.json();
|
300 |
+
console.log(`Company ID: ${data.company_id}`);
|
301 |
+
const companyId = data.company_id;
|
302 |
+
document.getElementById('company_id').value = companyId;
|
303 |
+
|
304 |
+
if (companyId) {
|
305 |
+
try {
|
306 |
+
const connectorsResponse = await fetch(`/api/check_data_connectors?company_id=${companyId}&company_name=${selectedCompanyName}`);
|
307 |
+
if (!connectorsResponse.ok) {
|
308 |
+
throw new Error('data connector Network response was not ok');
|
309 |
+
}
|
310 |
+
const connectorsData = await connectorsResponse.json();
|
311 |
+
//setMultiSelectValues(document.getElementById('database'), connectorsData.databasetype); // Ensure this is an array
|
312 |
+
//setMultiSelectValues(document.getElementById('databaseName'), connectorsData.database_name); // Ensure this is an array
|
313 |
+
document.getElementById('database').value = connectorsData.databasetype;
|
314 |
+
document.getElementById('server').value = connectorsData.serverip;
|
315 |
+
document.getElementById('port').value = connectorsData.port;
|
316 |
+
document.getElementById('databaseName').value = connectorsData.database_name;
|
317 |
+
document.getElementById('username').value = connectorsData.username;
|
318 |
+
document.getElementById('password').value = connectorsData.password;
|
319 |
+
document.getElementById('selectedTables').value = connectorsData.dbtablename;
|
320 |
+
databaseconnectorForm.style.display = 'block';
|
321 |
+
|
322 |
+
} catch (error) {
|
323 |
+
document.getElementById('database').value = " ";
|
324 |
+
document.getElementById('server').value = " ";
|
325 |
+
document.getElementById('port').value = " ";
|
326 |
+
document.getElementById('databaseName').value = " ";
|
327 |
+
document.getElementById('username').value = " ";
|
328 |
+
document.getElementById('password').value = " ";
|
329 |
+
document.getElementById('selectedTables').value = " ";
|
330 |
+
console.error('Error fetching data from data connectors:', error);
|
331 |
+
("Company name does not exist. Please fill in the details.");
|
332 |
+
|
333 |
+
// Optionally, you can insert a message into the DOM
|
334 |
+
const messageContainer = document.getElementById('message-container');
|
335 |
+
if (messageContainer) {
|
336 |
+
messageContainer.innerHTML = "<div class='alert alert-danger'>Database details does not exist for this Company name.. Please fill in the details.</div>";
|
337 |
+
}
|
338 |
+
|
339 |
+
databaseconnectorForm.style.display = 'block';
|
340 |
+
}
|
341 |
+
} else {
|
342 |
+
console.log(`Company ID does not exist, you can create and save data: ${data.company_id}`);
|
343 |
+
databaseconnectorForm.style.display = 'none';
|
344 |
+
}
|
345 |
+
|
346 |
+
} catch (error) {
|
347 |
+
|
348 |
+
console.error('Error fetching company ID or data connectors:', error);
|
349 |
+
databaseconnectorForm.style.display = 'none';
|
350 |
+
}
|
351 |
+
} else {
|
352 |
+
databaseconnectorForm.style.display = 'none';
|
353 |
+
}
|
354 |
+
});
|
355 |
+
|
356 |
+
document.getElementById("connectBtn").addEventListener("click", function (event) {
|
357 |
+
var database = document.getElementById("database").value;
|
358 |
+
var server = document.getElementById("server").value;
|
359 |
+
var port = document.getElementById("port").value;
|
360 |
+
var databaseName = document.getElementById("databaseName").value;
|
361 |
+
var username = document.getElementById("username").value;
|
362 |
+
var password = document.getElementById("password").value;
|
363 |
+
|
364 |
+
if (!database || !server || !port || !databaseName || !username || !password) {
|
365 |
+
alert("Please fill in all required fields.");
|
366 |
+
return;
|
367 |
+
}
|
368 |
+
|
369 |
+
document.getElementById("schema-table-section").style.display = "block";
|
370 |
+
});
|
371 |
+
$("#tableschema").change(function () {
|
372 |
+
var selectedTables = $(this).val();
|
373 |
+
var currentText = $("#selectedTables").val();
|
374 |
+
selectedTables.forEach(function (table) {
|
375 |
+
if (!currentText.includes(table)) {
|
376 |
+
if (currentText.length > 0) {
|
377 |
+
currentText += ", " + table;
|
378 |
+
} else {
|
379 |
+
currentText = table;
|
380 |
+
}
|
381 |
+
}
|
382 |
+
});
|
383 |
+
$("#selectedTables").val(currentText);
|
384 |
+
});
|
385 |
+
// document.getElementById("saveBtn").addEventListener("click", function (event) {
|
386 |
+
// var tables = Array.from(document.getElementById("tableschema").selectedOptions).map(option => option.value);
|
387 |
+
// if (tables.length === 0) {
|
388 |
+
// alert("Please select at least one table.");
|
389 |
+
// return;
|
390 |
+
// }
|
391 |
+
|
392 |
+
// var selectedTables = document.getElementById("selectedTables");
|
393 |
+
// selectedTables.value = tables.join(", ");
|
394 |
+
// selectedTables.style.display = "block";
|
395 |
+
// document.getElementById("labelselected").style.display = "block";
|
396 |
+
// document.getElementById("saveBtn1").style.display = "block";
|
397 |
+
// });
|
398 |
+
document.getElementById("saveBtn").addEventListener("click", async function(event) {
|
399 |
+
event.preventDefault(); // Prevent default form submission
|
400 |
+
|
401 |
+
const form = document.getElementById('databaseconnectorForm');
|
402 |
+
const formData = new FormData(form);
|
403 |
+
|
404 |
+
try {
|
405 |
+
const response = await fetch(form.action, {
|
406 |
+
method: form.method,
|
407 |
+
body: formData
|
408 |
+
});
|
409 |
+
|
410 |
+
if (!response.ok) {
|
411 |
+
throw new Error('Network response was not ok');
|
412 |
+
}
|
413 |
+
|
414 |
+
const result = await response.json();
|
415 |
+
// Optionally, handle the response from the server
|
416 |
+
if (result.success) {
|
417 |
+
alert('Data saved successfully');
|
418 |
+
} else {
|
419 |
+
alert('Error saving data: ' + result.message);
|
420 |
+
}
|
421 |
+
} catch (error) {
|
422 |
+
console.error('Error saving data:', error);
|
423 |
+
alert('An error occurred while saving data');
|
424 |
+
}
|
425 |
+
});
|
426 |
+
});
|
427 |
+
async function fetchCompanies() {
|
428 |
+
try {
|
429 |
+
const response = await fetch('/api/companies');
|
430 |
+
if (!response.ok) {
|
431 |
+
throw new Error('Network response was not ok');
|
432 |
+
}
|
433 |
+
const data = await response.json();
|
434 |
+
displayCompanies(data.companies);
|
435 |
+
} catch (error) {
|
436 |
+
console.error('Error fetching companies:', error);
|
437 |
+
}
|
438 |
+
}
|
439 |
+
|
440 |
+
function displayCompanies(companies) {
|
441 |
+
const companySelect = document.getElementById('company');
|
442 |
+
companySelect.innerHTML = '<option value="" selected>Select</option>'; // Reset the dropdown
|
443 |
+
companies.forEach(company => {
|
444 |
+
const option = document.createElement('option');
|
445 |
+
option.value = company.name;
|
446 |
+
option.textContent = company.name;
|
447 |
+
companySelect.appendChild(option);
|
448 |
+
});
|
449 |
+
}
|
450 |
+
|
451 |
+
function setMultiSelectValues(selectElement, values) {
|
452 |
+
// Ensure values is an array
|
453 |
+
if (!Array.isArray(values)) {
|
454 |
+
values = [values];
|
455 |
+
}
|
456 |
+
Array.from(selectElement.options).forEach(option => {
|
457 |
+
option.selected = values.includes(option.value);
|
458 |
+
});
|
459 |
+
}
|
460 |
+
</script>
|
461 |
+
</body>
|
462 |
+
|
463 |
+
</html>
|
templates/footer.html
ADDED
@@ -0,0 +1,26 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<!-- footer.html -->
|
2 |
+
|
3 |
+
<!--
|
4 |
+
This is the HTML code for the footer section of a web page.
|
5 |
+
It displays the version number and copyright information.
|
6 |
+
|
7 |
+
HTML Structure:
|
8 |
+
- The footer element has a class of "main-footer".
|
9 |
+
- Inside the footer, there is a div element with classes "float-right" and "d-none d-sm-block".
|
10 |
+
- Inside the div, there is a bold tag (<b>) displaying the version number.
|
11 |
+
- After the div, there is a strong tag (<strong>) displaying the copyright information.
|
12 |
+
- The copyright information includes the year and a link to the company's website.
|
13 |
+
|
14 |
+
Example Usage:
|
15 |
+
<footer class="main-footer">
|
16 |
+
<div class="float-right d-none d-sm-block">
|
17 |
+
<b>Version</b> 3.0.5
|
18 |
+
</div>
|
19 |
+
<strong>© 2023 <a href="https://yourcompany.com">Your Company</a>.</strong> All rights reserved.
|
20 |
+
</footer>
|
21 |
+
-->
|
22 |
+
<footer class="main-footer" style="position: absolute; bottom: 0; width: 100%; color: black; text-align: right; padding-right:245px ;">
|
23 |
+
<div class="container-fluid">
|
24 |
+
<a href="https://redmindtechnologies.com" target="_blank" style="color: black; text-decoration: none;">Visit Redmind Technologies at https://redmindtechnologies.com</a>
|
25 |
+
</div>
|
26 |
+
</footer>
|
templates/index.html
ADDED
@@ -0,0 +1,117 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<!--
|
2 |
+
This is the login page template for the RedMindGPT application.
|
3 |
+
It contains a login form where users can enter their username and password to sign in.
|
4 |
+
The form includes validation to ensure that both fields are filled out before submission.
|
5 |
+
The page also includes styling using CSS and utilizes the AdminLTE and Font Awesome libraries for additional design elements.
|
6 |
+
-->
|
7 |
+
|
8 |
+
<!DOCTYPE html>
|
9 |
+
<html lang="en">
|
10 |
+
<head>
|
11 |
+
<meta charset="UTF-8">
|
12 |
+
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
13 |
+
<style>
|
14 |
+
/* CSS styles for the login page */
|
15 |
+
.login-box-msg {
|
16 |
+
color: grey;
|
17 |
+
font-size: larger;
|
18 |
+
font-weight: bold;
|
19 |
+
}
|
20 |
+
|
21 |
+
.remember-me {
|
22 |
+
text-align: center;
|
23 |
+
}
|
24 |
+
</style>
|
25 |
+
<title>RedMindGPT</title>
|
26 |
+
<!-- AdminLTE CSS -->
|
27 |
+
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/[email protected]/dist/css/adminlte.min.css">
|
28 |
+
<!-- Font Awesome -->
|
29 |
+
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.15.3/css/all.min.css">
|
30 |
+
</head>
|
31 |
+
<body class="hold-transition login-page" style="background-image: url('static/img/AI.jpg'); background-size: cover;">
|
32 |
+
<div class="login-box">
|
33 |
+
<div class="card">
|
34 |
+
<!-- Logo -->
|
35 |
+
<div style="align-items: center;">
|
36 |
+
<a href="#" style="color: blue;
|
37 |
+
font-size: 30px;
|
38 |
+
font-weight: bold;
|
39 |
+
margin-left: 80px;
|
40 |
+
margin-top: 20px;
|
41 |
+
"><b>RedMindGPT</b></a>
|
42 |
+
</div>
|
43 |
+
<form action='/validate-user' name='loginForm' method="post" onsubmit="return validateForm()">
|
44 |
+
<div class="card-body login-card-body">
|
45 |
+
<p class="login-box-msg">Sign in</p>
|
46 |
+
<div class="input-group mb-3">
|
47 |
+
<input type="text" class="form-control" placeholder="Username" name="username" required>
|
48 |
+
<div class="input-group-append">
|
49 |
+
<div class="input-group-text">
|
50 |
+
<span class="fas fa-user"></span>
|
51 |
+
</div>
|
52 |
+
</div>
|
53 |
+
</div>
|
54 |
+
<div class="input-group mb-3">
|
55 |
+
<input type="password" class="form-control" placeholder="Password" name="password" required>
|
56 |
+
<div class="input-group-append">
|
57 |
+
<div class="input-group-text">
|
58 |
+
<span class="fas fa-lock"></span>
|
59 |
+
</div>
|
60 |
+
</div>
|
61 |
+
</div>
|
62 |
+
<div class="row" style="align-content: center;">
|
63 |
+
<div class="col-8">
|
64 |
+
<div class="icheck-primary">
|
65 |
+
<input type="checkbox" id="remember">
|
66 |
+
<label for="remember">
|
67 |
+
Remember Me
|
68 |
+
</label>
|
69 |
+
</div>
|
70 |
+
</div>
|
71 |
+
</div>
|
72 |
+
<div class="row" style="align-content: center;">
|
73 |
+
<div class="col-4">
|
74 |
+
<button type="submit" class="btn btn-primary btn-block">Sign In</button>
|
75 |
+
</div>
|
76 |
+
<div class="col-4">
|
77 |
+
<button type="reset" class="btn btn-secondary btn-block">Clear</button>
|
78 |
+
</div>
|
79 |
+
</div>
|
80 |
+
</div>
|
81 |
+
<input type="hidden" id="userRole" name="userRole" value="{{ role }}">
|
82 |
+
</form>
|
83 |
+
</div>
|
84 |
+
</div>
|
85 |
+
<!-- jQuery -->
|
86 |
+
<script src="https://code.jquery.com/jquery-3.6.0.min.js"></script>
|
87 |
+
<!-- Bootstrap 4 -->
|
88 |
+
<script src="https://stackpath.bootstrapcdn.com/bootstrap/4.5.2/js/bootstrap.bundle.min.js"></script>
|
89 |
+
<!-- AdminLTE App -->
|
90 |
+
<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/js/adminlte.min.js"></script>
|
91 |
+
<script>
|
92 |
+
// JavaScript function to validate the login form
|
93 |
+
function validateForm() {
|
94 |
+
//alert("Validating form");
|
95 |
+
var username = document.forms["loginForm"]["username"].value;
|
96 |
+
var password = document.forms["loginForm"]["password"].value;
|
97 |
+
if (username == "" || password == "") {
|
98 |
+
alert("Username and Password must be filled out");
|
99 |
+
return false;
|
100 |
+
}
|
101 |
+
}
|
102 |
+
function storeUserRole() {
|
103 |
+
// Store user role in localStorage or sessionStorage
|
104 |
+
var role1 = document.getElementById('userRole').value;
|
105 |
+
//Salert("Role retrieved: " + role1); // Alert to confirm retrieval
|
106 |
+
console.log("Retrieved user role from sessionStorage in index:", role1); // Debugging
|
107 |
+
sessionStorage.setItem('userRole', role1);
|
108 |
+
console.log("Role set in sessionStorage:", sessionStorage.getItem('userRole'));
|
109 |
+
console.log("role",role1);
|
110 |
+
}
|
111 |
+
document.querySelector('input[name="username"]').addEventListener('change', function(event) {
|
112 |
+
storeUserRole(); // Call this function before form submission
|
113 |
+
});
|
114 |
+
|
115 |
+
</script>
|
116 |
+
</body>
|
117 |
+
</html>
|
templates/knowledgebase.html
ADDED
@@ -0,0 +1,467 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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">×</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>
|
templates/knowledgebase2.html
ADDED
@@ -0,0 +1,360 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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 |
+
<style>
|
18 |
+
body {
|
19 |
+
background-color: transparent !important;
|
20 |
+
}
|
21 |
+
|
22 |
+
.content-wrapper {
|
23 |
+
background-color: transparent !important;
|
24 |
+
text-align: center;
|
25 |
+
}
|
26 |
+
|
27 |
+
.wrapper {
|
28 |
+
background-color: transparent !important;
|
29 |
+
}
|
30 |
+
|
31 |
+
.modal-content {
|
32 |
+
background-color: #fff;
|
33 |
+
}
|
34 |
+
|
35 |
+
h1 {
|
36 |
+
text-align: center;
|
37 |
+
margin-bottom: 30px;
|
38 |
+
}
|
39 |
+
|
40 |
+
/* Adjust table width to full container width */
|
41 |
+
.card-body {
|
42 |
+
padding: 0;
|
43 |
+
}
|
44 |
+
|
45 |
+
.table {
|
46 |
+
width: 100%;
|
47 |
+
}
|
48 |
+
|
49 |
+
.text-wrap {
|
50 |
+
white-space: normal !important;
|
51 |
+
word-break: break-word;
|
52 |
+
}
|
53 |
+
|
54 |
+
.center-align {
|
55 |
+
padding-top: 20px;
|
56 |
+
display: flex;
|
57 |
+
justify-content: center;
|
58 |
+
align-items: center;
|
59 |
+
width: 100%;
|
60 |
+
}
|
61 |
+
|
62 |
+
.reduced-width {
|
63 |
+
width: 50%;
|
64 |
+
/* Adjust the percentage as needed */
|
65 |
+
}
|
66 |
+
</style>
|
67 |
+
</head>
|
68 |
+
|
69 |
+
<body>
|
70 |
+
{% include 'sidepane.html' %}
|
71 |
+
|
72 |
+
|
73 |
+
<div class="wrapper" style="position: relative; top: 0;">
|
74 |
+
<div class="content-wrapper">
|
75 |
+
<div class="content-header">
|
76 |
+
<div class="container-fluid">
|
77 |
+
<div class="container mt-2">
|
78 |
+
<h1 class="m-0 text-center" style="flex-grow: 1;">Knowledge Base</h1>
|
79 |
+
<div class="form-group center-align">
|
80 |
+
<label for="company" class="mr-2">Company Name <span class="text-danger">*</span></label>
|
81 |
+
<select type="text" id="company" name="company" class="form-control reduced-width" required>
|
82 |
+
<option value="" selected>Select</option>
|
83 |
+
</select>
|
84 |
+
</div>
|
85 |
+
</div>
|
86 |
+
</div>
|
87 |
+
</div>
|
88 |
+
<section class="content" id="contentSection" style="display: none;">
|
89 |
+
<div class="container-fluid">
|
90 |
+
<div class="form-group">
|
91 |
+
<!-- <label for="company_id">company_id</label>--->
|
92 |
+
<input type="hidden" id="company_id" name="company_id" class="form-control" required>
|
93 |
+
</div>
|
94 |
+
<div class="row">
|
95 |
+
<div class="col-12 d-flex justify-content-end mb-3">
|
96 |
+
<button class="btn btn-primary" id="add">Add</button>
|
97 |
+
</div>
|
98 |
+
<div class="row mb-2">
|
99 |
+
<div class="col-12">
|
100 |
+
<div class="col-12">
|
101 |
+
<div class="card">
|
102 |
+
<div class="card-body">
|
103 |
+
<div class="table-responsive">
|
104 |
+
<div id="message-container">
|
105 |
+
<table id="knowledgeTable" class="table table-bordered table-striped">
|
106 |
+
<thead>
|
107 |
+
<tr>
|
108 |
+
<th>Sno</th>
|
109 |
+
<th>Document Name</th>
|
110 |
+
<th>Document Description</th>
|
111 |
+
<th>Document Version</th>
|
112 |
+
<th>VectorDB Flag</th>
|
113 |
+
<th>View</th>
|
114 |
+
</tr>
|
115 |
+
</thead>
|
116 |
+
<tbody>
|
117 |
+
<tr>
|
118 |
+
<td>1</td>
|
119 |
+
<td>NewAge eWMS BusinessRequirementsDocument_V1.9 - Inbound
|
120 |
+
</td>
|
121 |
+
<td>GRN Inbound</td>
|
122 |
+
<td>1.9</td>
|
123 |
+
<td>Yes</td>
|
124 |
+
<td>
|
125 |
+
<button class="btn btn-primary viewButton">View</button>
|
126 |
+
</td>
|
127 |
+
</tr>
|
128 |
+
<tr>
|
129 |
+
<td>2</td>
|
130 |
+
<td>NewAge eWMS BusinessRequirementsDocument_V2.3 - Inbound
|
131 |
+
</td>
|
132 |
+
<td>GRN Inbound</td>
|
133 |
+
<td>2.3</td>
|
134 |
+
<td>No</td>
|
135 |
+
<td>
|
136 |
+
<button class="btn btn-primary viewButton">View</button>
|
137 |
+
</td>
|
138 |
+
</tr>
|
139 |
+
<tr>
|
140 |
+
<td>3</td>
|
141 |
+
<td>NewAge eWMS BusinessRequirementsDocument_V1.9 - Outbound
|
142 |
+
</td>
|
143 |
+
<td>GRN Outbound</td>
|
144 |
+
<td>1.9</td>
|
145 |
+
<td>Yes</td>
|
146 |
+
<td>
|
147 |
+
<button class="btn btn-primary viewButton">View</button>
|
148 |
+
</td>
|
149 |
+
</tr>
|
150 |
+
<tr>
|
151 |
+
<td>4</td>
|
152 |
+
<td class="text-wrap">NewAge eWMS
|
153 |
+
BusinessRequirementsDocument_V2.2 - Outbound</td>
|
154 |
+
<td>ASN Outbound</td>
|
155 |
+
<td>2.2</td>
|
156 |
+
<td>No</td>
|
157 |
+
<td>
|
158 |
+
<button class="btn btn-primary viewButton">View</button>
|
159 |
+
</td>
|
160 |
+
</tr>
|
161 |
+
</tbody>
|
162 |
+
</table>
|
163 |
+
</div>
|
164 |
+
</div>
|
165 |
+
</div>
|
166 |
+
</div>
|
167 |
+
</div>
|
168 |
+
</div>
|
169 |
+
</div>
|
170 |
+
</section>
|
171 |
+
</div>
|
172 |
+
|
173 |
+
<div class="modal fade" id="addModal" tabindex="-1" role="dialog" aria-labelledby="addModalLabel"
|
174 |
+
aria-hidden="true">
|
175 |
+
<div class="modal-dialog" role="document">
|
176 |
+
<div class="modal-content">
|
177 |
+
<div class="modal-header">
|
178 |
+
<h5 class="modal-title" id="addModalLabel">Add Document</h5>
|
179 |
+
<button type="button" class="close" data-dismiss="modal" aria-label="Close">
|
180 |
+
<span aria-hidden="true">×</span>
|
181 |
+
</button>
|
182 |
+
</div>
|
183 |
+
<div class="modal-body">
|
184 |
+
<div class="form-group">
|
185 |
+
<!-- <label for="company_id">company_id</label>--->
|
186 |
+
<input type="hidden" id="company_id" name="company_id" class="form-control" required>
|
187 |
+
</div>
|
188 |
+
<form id="documentForm">
|
189 |
+
<div class="form-group">
|
190 |
+
<label for="uploadFile">Upload File<span class="text-danger">*</span></label>
|
191 |
+
<input type="file" class="form-control-file" id="uploadFile" name="uploadFile" required accept=".pdf,.doc,.docx">
|
192 |
+
<small class="form-text text-muted">Accepted formats: .pdf, .doc, .docx</small>
|
193 |
+
</div>
|
194 |
+
<div class="form-group">
|
195 |
+
<label for="documentName">Document Name<span class="text-danger">*</span></label>
|
196 |
+
<input type="text" class="form-control" id="documentName" name="documentName" required>
|
197 |
+
</div>
|
198 |
+
<div class="form-group">
|
199 |
+
<label for="documentDescription">Document Description<span class="text-danger">*</span></label>
|
200 |
+
<textarea class="form-control" id="documentDescription" name="documentDescription"
|
201 |
+
rows="3" required></textarea>
|
202 |
+
</div>
|
203 |
+
<div class="form-group">
|
204 |
+
<label for="department">Department<span class="text-danger">*</span></label>
|
205 |
+
<input type="text" class="form-control" id="department" name="department" required>
|
206 |
+
</div>
|
207 |
+
<div class="form-group">
|
208 |
+
<label for="version">Version<span class="text-danger">*</span></label>
|
209 |
+
<input type="text" class="form-control" id="version" name="version" required>
|
210 |
+
</div>
|
211 |
+
<div class="form-group">
|
212 |
+
<label for="lastUpdated">Last Updated<span class="text-danger">*</span></label>
|
213 |
+
<input type="text" class="form-control" id="lastUpdated" name="lastUpdated" required>
|
214 |
+
</div>
|
215 |
+
</form>
|
216 |
+
</div>
|
217 |
+
<div class="modal-footer">
|
218 |
+
<button type="button" class="btn btn-secondary" data-dismiss="modal">Close</button>
|
219 |
+
<button type="button" id="save" onclick="save_file()" class="btn btn-primary">Save</button>
|
220 |
+
</div>
|
221 |
+
</div>
|
222 |
+
</div>
|
223 |
+
</div>
|
224 |
+
</div>
|
225 |
+
<!-- JavaScript to handle modal display -->
|
226 |
+
<script>
|
227 |
+
document.addEventListener("DOMContentLoaded", function () {
|
228 |
+
now = new Date().toISOString().substr(0, 10);
|
229 |
+
document.getElementById('lastUpdated').value = now
|
230 |
+
// clearFormFields();
|
231 |
+
});
|
232 |
+
document.addEventListener('DOMContentLoaded', function () {
|
233 |
+
|
234 |
+
fetchCompanies();
|
235 |
+
|
236 |
+
const companySelect = document.getElementById('company');
|
237 |
+
const documentForm = document.getElementById('documentForm');
|
238 |
+
|
239 |
+
companySelect.addEventListener('change', async function () {
|
240 |
+
const selectedCompanyName = companySelect.options[companySelect.selectedIndex].text;
|
241 |
+
console.log(`Selected Company Name: ${selectedCompanyName}`);
|
242 |
+
|
243 |
+
if (selectedCompanyName !== "Select") {
|
244 |
+
|
245 |
+
try {
|
246 |
+
const response = await fetch(`/api/company_id?company_name=${encodeURIComponent(selectedCompanyName)}`);
|
247 |
+
if (!response.ok) {
|
248 |
+
contentSection.style.display='none';
|
249 |
+
const messageContainer = document.getElementById('message-container');
|
250 |
+
if (messageContainer) {
|
251 |
+
messageContainer.innerHTML = "<div class='alert alert-danger'>Document details do not exist for this company. Please fill in the details.</div>";
|
252 |
+
}
|
253 |
+
throw new Error('Network response was not ok');
|
254 |
+
}
|
255 |
+
const data = await response.json();
|
256 |
+
console.log(`Company ID: ${data.company_id}`);
|
257 |
+
const companyId = data.company_id;
|
258 |
+
document.getElementById('company_id').value = companyId;
|
259 |
+
|
260 |
+
if (companyId) {
|
261 |
+
contentSection.style.display = 'block';
|
262 |
+
}
|
263 |
+
|
264 |
+
|
265 |
+
} catch (error) {
|
266 |
+
console.error('Error fetching company ID or data documents:', error);
|
267 |
+
documentForm.style.display = 'none';
|
268 |
+
}
|
269 |
+
} else {
|
270 |
+
//clearFormFields();
|
271 |
+
documentForm.style.display = 'block';
|
272 |
+
}
|
273 |
+
});
|
274 |
+
});
|
275 |
+
function clearFormFields() {
|
276 |
+
document.getElementById('uploadFile').value = "";
|
277 |
+
document.getElementById('documentName').value = "";
|
278 |
+
document.getElementById('documentDescription').value = "";
|
279 |
+
document.getElementById('department').value = "";
|
280 |
+
document.getElementById('version').value = "";
|
281 |
+
//document.getElementById('lastUpdated').value = "";
|
282 |
+
}
|
283 |
+
|
284 |
+
|
285 |
+
$(document).ready(function () {
|
286 |
+
// Show modal function
|
287 |
+
$('#add').on('click', function () {
|
288 |
+
clearFormFields();
|
289 |
+
$('#addModal').modal('show');
|
290 |
+
});
|
291 |
+
$('.modal-footer .btn-secondary').on('click', function () {
|
292 |
+
$('#addModal').modal('hide');
|
293 |
+
});
|
294 |
+
// Your save file function here
|
295 |
+
// async function save_file() {
|
296 |
+
// alert('Save button clicked');
|
297 |
+
// // Your save file logic goes here
|
298 |
+
// }
|
299 |
+
});
|
300 |
+
function save_file() {
|
301 |
+
const uploadFile = document.getElementById("uploadFile").files[0];
|
302 |
+
const documentName = document.getElementById("documentName").value;
|
303 |
+
const documentDescription = document.getElementById("documentDescription").value;
|
304 |
+
const department = document.getElementById("department").value;
|
305 |
+
const version = document.getElementById("version").value;
|
306 |
+
const lastUpdated = document.getElementById("lastUpdated").value;
|
307 |
+
const company_id = document.getElementById("company_id").value;
|
308 |
+
|
309 |
+
const formData = new FormData();
|
310 |
+
formData.append("uploadFile", uploadFile);
|
311 |
+
formData.append("documentName", documentName);
|
312 |
+
formData.append("documentDescription", documentDescription);
|
313 |
+
formData.append("department", department);
|
314 |
+
formData.append("version", version);
|
315 |
+
formData.append("lastUpdated", lastUpdated);
|
316 |
+
formData.append("company_id", company_id);
|
317 |
+
|
318 |
+
fetch('/upload_document', {
|
319 |
+
method: 'POST',
|
320 |
+
body: formData
|
321 |
+
})
|
322 |
+
.then(response => {
|
323 |
+
if (!response.ok) {
|
324 |
+
throw new Error('Network response was not ok');
|
325 |
+
}
|
326 |
+
return response.text();
|
327 |
+
})
|
328 |
+
.then(data => {
|
329 |
+
alert('Document saved successfully');
|
330 |
+
// $('#addModal').modal('hide');
|
331 |
+
})
|
332 |
+
.catch(error => console.error('Error:', error));
|
333 |
+
}
|
334 |
+
async function fetchCompanies() {
|
335 |
+
try {
|
336 |
+
const response = await fetch('/api/companies');
|
337 |
+
if (!response.ok) {
|
338 |
+
throw new Error('Network response was not ok');
|
339 |
+
}
|
340 |
+
const data = await response.json();
|
341 |
+
displayCompanies(data.companies);
|
342 |
+
} catch (error) {
|
343 |
+
console.error('Error fetching companies:', error);
|
344 |
+
}
|
345 |
+
}
|
346 |
+
|
347 |
+
function displayCompanies(companies) {
|
348 |
+
const companySelect = document.getElementById('company');
|
349 |
+
companySelect.innerHTML = '<option value="" selected>Select</option>'; // Reset the dropdown
|
350 |
+
companies.forEach(company => {
|
351 |
+
const option = document.createElement('option');
|
352 |
+
option.value = company.name;
|
353 |
+
option.textContent = company.name;
|
354 |
+
companySelect.appendChild(option);
|
355 |
+
});
|
356 |
+
}
|
357 |
+
</script>
|
358 |
+
</body>
|
359 |
+
|
360 |
+
</html>
|
templates/prompt_template.html
ADDED
@@ -0,0 +1,435 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<!DOCTYPE html>
|
2 |
+
<html>
|
3 |
+
|
4 |
+
<head>
|
5 |
+
<title>Prompt Template</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 |
+
<script src="https://cdn.datatables.net/1.10.25/js/jquery.dataTables.min.js"></script>
|
13 |
+
<script src="https://cdn.datatables.net/1.10.25/js/dataTables.bootstrap4.min.js"></script>
|
14 |
+
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.0.0-beta3/css/all.min.css" />
|
15 |
+
<style>
|
16 |
+
.header-row {
|
17 |
+
display: flex;
|
18 |
+
justify-content: space-between;
|
19 |
+
align-items: center;
|
20 |
+
}
|
21 |
+
|
22 |
+
.table-container {
|
23 |
+
width: 100%;
|
24 |
+
overflow-x: auto;
|
25 |
+
}
|
26 |
+
|
27 |
+
.wrapper {
|
28 |
+
display: flex;
|
29 |
+
flex-direction: column;
|
30 |
+
height: 100vh;
|
31 |
+
}
|
32 |
+
|
33 |
+
.content-wrapper {
|
34 |
+
flex: 1;
|
35 |
+
overflow-y: auto;
|
36 |
+
}
|
37 |
+
|
38 |
+
.content-header {
|
39 |
+
padding: 5px;
|
40 |
+
|
41 |
+
}
|
42 |
+
|
43 |
+
.footer {
|
44 |
+
text-align: right;
|
45 |
+
padding: 10px;
|
46 |
+
}
|
47 |
+
.center-align {
|
48 |
+
padding-top: 20px;
|
49 |
+
display: flex;
|
50 |
+
justify-content: center;
|
51 |
+
align-items: center;
|
52 |
+
width: 100%;
|
53 |
+
}
|
54 |
+
th,
|
55 |
+
td {
|
56 |
+
white-space: nowrap;
|
57 |
+
}
|
58 |
+
|
59 |
+
th:nth-child(1),
|
60 |
+
td:nth-child(1) {
|
61 |
+
/* Sno column */
|
62 |
+
width: 1%;
|
63 |
+
}
|
64 |
+
|
65 |
+
th:nth-child(2),
|
66 |
+
td:nth-child(2) {
|
67 |
+
/* API Name column */
|
68 |
+
width: 20%;
|
69 |
+
}
|
70 |
+
|
71 |
+
th:nth-child(3),
|
72 |
+
td:nth-child(3) {
|
73 |
+
/* API Endpoint column */
|
74 |
+
width: 35%;
|
75 |
+
}
|
76 |
+
|
77 |
+
th:nth-child(4),
|
78 |
+
td:nth-child(4) {
|
79 |
+
/* view column*/
|
80 |
+
width: 15%;
|
81 |
+
}
|
82 |
+
.reduced-width{
|
83 |
+
width:25%;
|
84 |
+
}
|
85 |
+
|
86 |
+
.viewButton{
|
87 |
+
size:2px;
|
88 |
+
}
|
89 |
+
</style>
|
90 |
+
</head>
|
91 |
+
|
92 |
+
<body>
|
93 |
+
{% include 'sidepane.html' %}
|
94 |
+
|
95 |
+
<div class="wrapper">
|
96 |
+
<div class="content-wrapper">
|
97 |
+
<!-- Content Header (Page header) -->
|
98 |
+
<div class="content-header">
|
99 |
+
<div class="container-fluid">
|
100 |
+
<div class="container mt-2">
|
101 |
+
<div class="form-group center-align">
|
102 |
+
<label for="company" class="mr-2">Company Name <span class="text-danger">*</span></label>
|
103 |
+
<select type="text" id="company" name="company" class="form-control reduced-width" required>
|
104 |
+
<option value="" selected>Select</option>
|
105 |
+
</select>
|
106 |
+
<div class="col-8 d-flex justify-content-end mb-3">
|
107 |
+
<button class="btn btn-primary" style="margin-top: 20px;" id="add">Add</button>
|
108 |
+
|
109 |
+
<!-- <button class="btn btn-primary" style="margin-top: 20px;" id="add">Add</button> -->
|
110 |
+
</div>
|
111 |
+
</div>
|
112 |
+
<div class="row">
|
113 |
+
<div id="message-container" style="margin-left: 200px;"></div>
|
114 |
+
</div>
|
115 |
+
</div>
|
116 |
+
</div>
|
117 |
+
</div>
|
118 |
+
<section class="content" id="contentSection" style="display: none;">
|
119 |
+
<div class="container-fluid">
|
120 |
+
<div class="form-group">
|
121 |
+
<!-- <label for="company_id">company_id</label>--->
|
122 |
+
<input type="hidden" id="company_id" name="company_id" class="form-control" required>
|
123 |
+
</div>
|
124 |
+
</div>
|
125 |
+
<!-- Main content-->
|
126 |
+
<section class="content">
|
127 |
+
<div class="container-fluid">
|
128 |
+
<div class="row">
|
129 |
+
<div class="col-12">
|
130 |
+
<div class="card">
|
131 |
+
<div class="card-body table-container">
|
132 |
+
<table id="promptTable" class="table table-bordered table-striped">
|
133 |
+
<thead>
|
134 |
+
<tr>
|
135 |
+
<th>Sno</th>
|
136 |
+
<th>Datasource</th>
|
137 |
+
<th>Sample Prompt</th>
|
138 |
+
<th>View</th>
|
139 |
+
</tr>
|
140 |
+
</thead>
|
141 |
+
<tbody>
|
142 |
+
<!-- <tr>
|
143 |
+
<td>1</td>
|
144 |
+
<td>API</td>
|
145 |
+
<td>What are the details of ASN24080200002?</td>
|
146 |
+
<td><button class="btn btn-primary viewButton">View</button></td>
|
147 |
+
</tr>
|
148 |
+
<tr>
|
149 |
+
<td>2</td>
|
150 |
+
<td>API</td>
|
151 |
+
<td>What is the expected receiving date of ASN24080200002</td>
|
152 |
+
<td><button class="btn btn-primary viewButton">View</button></td>
|
153 |
+
</tr>
|
154 |
+
<tr>
|
155 |
+
<td>3</td>
|
156 |
+
<td>Document</td>
|
157 |
+
<td>Explain Pre-Receiving Yard Management</td>
|
158 |
+
<td><button class="btn btn-primary viewButton">View</button></td>
|
159 |
+
</tr>
|
160 |
+
<tr>
|
161 |
+
<td>4</td>
|
162 |
+
<td>Document</td>
|
163 |
+
<td>Can you explain the process of unloading a vehicle in more detail?</td>
|
164 |
+
<td><button class="btn btn-primary viewButton">View</button></td>
|
165 |
+
</tr>
|
166 |
+
<tr>
|
167 |
+
<td>5</td>
|
168 |
+
<td>Visual Analysis</td>
|
169 |
+
<td>I want to analyze item name and quantity in a bar chart in warehouse Allcargo Logistics</td>
|
170 |
+
<td><button class="btn btn-primary viewButton">View</button></td>
|
171 |
+
</tr>
|
172 |
+
<tr>
|
173 |
+
<td>6</td>
|
174 |
+
<td>Visual Analysis</td>
|
175 |
+
<td>Can you generate a pie chart with item names and quantities in warehouse Allcargo Logistics</td>
|
176 |
+
<td><button class="btn btn-primary viewButton">View</button></td>
|
177 |
+
</tr>
|
178 |
+
<tr>
|
179 |
+
<td>7</td>
|
180 |
+
<td>Database</td>
|
181 |
+
<td>What are the active warehouses available</td>
|
182 |
+
<td><button class="btn btn-primary viewButton">View</button></td>
|
183 |
+
</tr>
|
184 |
+
<tr>
|
185 |
+
<td>8</td>
|
186 |
+
<td>Database</td>
|
187 |
+
<td>What are the warehouses available</td>
|
188 |
+
<td><button class="btn btn-primary viewButton">View</button></td>
|
189 |
+
</tr>
|
190 |
+
-->
|
191 |
+
</tbody>
|
192 |
+
</table>
|
193 |
+
</div>
|
194 |
+
</div>
|
195 |
+
</div>
|
196 |
+
</div>
|
197 |
+
</div>
|
198 |
+
</section>
|
199 |
+
</section>
|
200 |
+
</div>
|
201 |
+
|
202 |
+
</div>
|
203 |
+
|
204 |
+
</div>
|
205 |
+
|
206 |
+
<!-- Modal -->
|
207 |
+
<div class="modal fade" id="addModal" tabindex="-1" role="dialog" aria-labelledby="addModalLabel"
|
208 |
+
aria-hidden="true">
|
209 |
+
<div class="modal-dialog" role="document">
|
210 |
+
<div class="modal-content">
|
211 |
+
<div class="modal-header">
|
212 |
+
<h5 class="modal-title" id="addModalLabel">Add Prompt</h5>
|
213 |
+
<button type="button" class="close" data-dismiss="modal" aria-label="Close"></button>
|
214 |
+
<span aria-hidden="true" data-backdrop="static" data-keyboard="false">×</span>
|
215 |
+
</div>
|
216 |
+
<div class="modal-body">
|
217 |
+
<div class="form-group">
|
218 |
+
<!-- <label for="company_id">company_id</label>--->
|
219 |
+
<input type="hidden" id="company_id" name="company_id" class="form-control" required>
|
220 |
+
</div>
|
221 |
+
<form id="addPromptForm">
|
222 |
+
<div class="form-group">
|
223 |
+
<label for="scenario">Scenario <span class="text-danger">*</span></label>
|
224 |
+
<input type="text" class="form-control" id="scenario" name="scenario" required>
|
225 |
+
</div>
|
226 |
+
<div class="form-group">
|
227 |
+
<label for="prompt">Sample Prompt <span class="text-danger">*</span></label>
|
228 |
+
<input type="text" class="form-control" id="prompt" name="sampleprompt" required>
|
229 |
+
</div>
|
230 |
+
<div class="form-group">
|
231 |
+
<label for="comments">Comments <span class="text-danger">*</span></label>
|
232 |
+
<input type="text" class="form-control" id="comments" name="comments" required>
|
233 |
+
</div>
|
234 |
+
</form>
|
235 |
+
</div>
|
236 |
+
<div class="modal-footer">
|
237 |
+
<!-- <button type="button" class="btn btn-secondary" data-bs-dismiss="modal">Close</button> -->
|
238 |
+
<button type="button" id="save" onclick="save_file()" class="btn btn-primary">Save</button>
|
239 |
+
</div>
|
240 |
+
</div>
|
241 |
+
</div>
|
242 |
+
</div>
|
243 |
+
|
244 |
+
<!-- Include DataTables JS and your custom script -->
|
245 |
+
<script src="https://cdn.datatables.net/1.10.25/js/jquery.dataTables.min.js"></script>
|
246 |
+
<script src="https://cdn.datatables.net/1.10.25/js/dataTables.bootstrap4.min.js"></script>
|
247 |
+
<script>
|
248 |
+
$(document).ready(function () {
|
249 |
+
$('#add').on('click', function () {
|
250 |
+
clearFormFields();
|
251 |
+
$('#message-container').empty(); // Clear the message container
|
252 |
+
$('#addModal').modal('show');
|
253 |
+
});
|
254 |
+
$('.modal-footer .btn-secondary, .modal-header .close').on('click', function () {
|
255 |
+
$('#addModal').modal('hide');
|
256 |
+
});
|
257 |
+
|
258 |
+
});
|
259 |
+
document.addEventListener("DOMContentLoaded", function () {
|
260 |
+
|
261 |
+
// clearFormFields();
|
262 |
+
fetchCompanies();
|
263 |
+
|
264 |
+
const companySelect = document.getElementById('company');
|
265 |
+
const addPromptForm = document.getElementById('addPromptForm');
|
266 |
+
const table = $('#promptTable').DataTable();
|
267 |
+
// Initialize DataTable at the start
|
268 |
+
companySelect.addEventListener('change', async function () {
|
269 |
+
$("#message-container").empty();
|
270 |
+
const selectedCompanyName = companySelect.options[companySelect.selectedIndex].text;
|
271 |
+
console.log(`Selected Company Name: ${selectedCompanyName}`);
|
272 |
+
|
273 |
+
if (selectedCompanyName !== "Select") {
|
274 |
+
|
275 |
+
try {
|
276 |
+
const response = await fetch(`/api/company_id?company_name=${encodeURIComponent(selectedCompanyName)}`);
|
277 |
+
if (!response.ok) {
|
278 |
+
contentSection.style.display = 'none';
|
279 |
+
("Document details does not exist for name does not exist. Please fill in the details.");
|
280 |
+
const messageContainer = document.getElementById('message-container');
|
281 |
+
if (messageContainer) {
|
282 |
+
messageContainer.innerHTML = "<div class='alert alert-danger'>Document details do not exist for this company. Please fill in the details.</div>";
|
283 |
+
}
|
284 |
+
throw new Error('Network response was not ok');
|
285 |
+
}
|
286 |
+
const data = await response.json();
|
287 |
+
console.log('data returned', data);
|
288 |
+
console.log(`Company ID: ${data.company_id}`);
|
289 |
+
const companyId = data.company_id;
|
290 |
+
document.getElementById('company_id').value = companyId;
|
291 |
+
|
292 |
+
if (companyId) {
|
293 |
+
try {
|
294 |
+
const Response = await fetch(`/api/get_prompt_templates?company_id=${companyId}&company_name=${selectedCompanyName}`);
|
295 |
+
const connectorsResponse = await Response.json();
|
296 |
+
console.log("prompt template data table after connecting to table", connectorsResponse);
|
297 |
+
table.clear();
|
298 |
+
if (!Array.isArray(connectorsResponse)) {
|
299 |
+
throw new TypeError('Expected an array of companies');
|
300 |
+
|
301 |
+
displayErrorMessage("template details do not exist for this company. Please fill in the details.");
|
302 |
+
contentSection.style.display = 'none';
|
303 |
+
} else {
|
304 |
+
|
305 |
+
connectorsResponse.forEach((company, index) => {
|
306 |
+
table.row.add([
|
307 |
+
index+1,
|
308 |
+
company.scenario,
|
309 |
+
company.prompt,
|
310 |
+
"<a href='#' class='btn btn-info btn-sm'><i class='fas fa-eye' fa-eye'></i></a>",
|
311 |
+
]).draw(false);
|
312 |
+
});
|
313 |
+
contentSection.style.display = 'block';
|
314 |
+
}
|
315 |
+
|
316 |
+
} catch (error) {
|
317 |
+
console.error('Error fetching company documents:', error);
|
318 |
+
//displayEmptyTable();
|
319 |
+
|
320 |
+
displayErrorMessage("Document details1 do not exist for this company. Please fill in the details.");
|
321 |
+
contentSection.style.display = 'none';
|
322 |
+
}
|
323 |
+
}
|
324 |
+
else {
|
325 |
+
// displayEmptyTable();
|
326 |
+
|
327 |
+
displayErrorMessage("Document details2 for knowledge do not exist for this company. Please fill in the details.");
|
328 |
+
}
|
329 |
+
} catch (error) {
|
330 |
+
console.error('No details for this company ID or data documents:', error);
|
331 |
+
// displayEmptyTable();
|
332 |
+
|
333 |
+
displayErrorMessage("Document details3 do not exist for this company. Please fill in the details.");
|
334 |
+
contentSection.style.display = 'none';
|
335 |
+
}
|
336 |
+
} else {
|
337 |
+
|
338 |
+
table.clear().draw();
|
339 |
+
document.getElementById('contentSection').style.display = 'none';
|
340 |
+
// Optionally, you might want to clear the form fields as well
|
341 |
+
clearFormFields();
|
342 |
+
|
343 |
+
}
|
344 |
+
});
|
345 |
+
function displayErrorMessage(message) {
|
346 |
+
const messageContainer = document.getElementById('message-container');
|
347 |
+
if (messageContainer) {
|
348 |
+
messageContainer.innerHTML = `<div class='alert alert-danger'>${message}</div>`;
|
349 |
+
}
|
350 |
+
}
|
351 |
+
|
352 |
+
});
|
353 |
+
function save_file() {
|
354 |
+
const form = document.getElementById('addPromptForm');
|
355 |
+
|
356 |
+
// Check if the form is valid
|
357 |
+
if (!form.checkValidity()) {
|
358 |
+
// If the form is invalid, show validation messages and stop the submission
|
359 |
+
form.reportValidity();
|
360 |
+
return;
|
361 |
+
}
|
362 |
+
const company_id=$('#company_id').val();
|
363 |
+
const scenario= $('#scenario').val();
|
364 |
+
const prompt = $('#prompt').val();
|
365 |
+
const comments=$('#comments').val();
|
366 |
+
const view= "<a href='#' class='btn btn-info btn-sm'><i class='fas fa-eye'></i></a>";
|
367 |
+
var formData = new FormData($('#addPromptForm')[0]);
|
368 |
+
|
369 |
+
formData.append("company_id",company_id),
|
370 |
+
formData.append("scenario", scenario),
|
371 |
+
formData.append("prompt", prompt),
|
372 |
+
formData.append("comments",comments),
|
373 |
+
|
374 |
+
//const formData = new FormData();
|
375 |
+
fetch('/api/save_prompt_details', {
|
376 |
+
method: 'POST',
|
377 |
+
body: formData
|
378 |
+
})
|
379 |
+
.then(response => {
|
380 |
+
if (!response.ok) {
|
381 |
+
throw new Error('Network response was not ok');
|
382 |
+
}
|
383 |
+
return response.text();
|
384 |
+
})
|
385 |
+
.then(data => {
|
386 |
+
var table = $('#promptTable').DataTable();
|
387 |
+
var rowCount = table.rows().count();
|
388 |
+
table.row.add([
|
389 |
+
rowCount + 1,
|
390 |
+
scenario,
|
391 |
+
prompt,
|
392 |
+
view
|
393 |
+
]).draw(false);
|
394 |
+
|
395 |
+
alert('Document saved successfully');
|
396 |
+
$('#addModal').modal('hide');
|
397 |
+
document.getElementById('contentSection').style.display = 'block'; // Show the table section
|
398 |
+
})
|
399 |
+
.catch(error => console.error('Error:', error));
|
400 |
+
}
|
401 |
+
async function fetchCompanies() {
|
402 |
+
try {
|
403 |
+
const response = await fetch('/api/companies');
|
404 |
+
if (!response.ok) {
|
405 |
+
throw new Error('Network response was not ok');
|
406 |
+
}
|
407 |
+
const data = await response.json();
|
408 |
+
displayCompanies(data.companies);
|
409 |
+
} catch (error) {
|
410 |
+
console.error('Error fetching companies:', error);
|
411 |
+
}
|
412 |
+
}
|
413 |
+
|
414 |
+
function displayCompanies(companies) {
|
415 |
+
const companySelect = document.getElementById('company');
|
416 |
+
companySelect.innerHTML = '<option value="" selected>Select</option>'; // Reset the dropdown
|
417 |
+
companies.forEach(company => {
|
418 |
+
const option = document.createElement('option');
|
419 |
+
option.value = company.name;
|
420 |
+
option.textContent = company.name;
|
421 |
+
companySelect.appendChild(option);
|
422 |
+
});
|
423 |
+
}
|
424 |
+
function clearFormFields() {
|
425 |
+
document.getElementById('scenario').value = "";
|
426 |
+
document.getElementById('prompt').value = "";
|
427 |
+
document.getElementById('comments').value = "";
|
428 |
+
|
429 |
+
}
|
430 |
+
|
431 |
+
|
432 |
+
</script>
|
433 |
+
</body>
|
434 |
+
|
435 |
+
</html>
|
templates/redmindlogo2.jpg
ADDED
templates/redmindlogo3.jpg
ADDED
templates/sidepane.html
ADDED
@@ -0,0 +1,105 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<!-- sidepane.html -->
|
2 |
+
|
3 |
+
<!-- This file represents the sidepane component of a web application. It contains the navigation menu and sidebar. -->
|
4 |
+
|
5 |
+
<nav class="main-header navbar navbar-expand navbar-white navbar-light" style="text-align: center;">
|
6 |
+
<div class="container-fluid d-flex justify-content-center align-items-center">
|
7 |
+
<img src="..\static\img\redmindlogo3.jpg" alt="Logo" style="width: 80px; height: auto; margin-right: 10px;">
|
8 |
+
|
9 |
+
<h3 style="text-align: center; margin-bottom: 0;">Redmind GPT - {{title}}</h3>
|
10 |
+
<button class="btn btn-primary" style="margin-left: 180px;margin-right:-270px;" onclick="logout()">Logout</button>
|
11 |
+
|
12 |
+
</div>
|
13 |
+
<!-- Left navbar links -->
|
14 |
+
<!-- <ul class="navbar-nav">
|
15 |
+
<li class="nav-item">
|
16 |
+
<a class="nav-link" data-widget="pushmenu" href="#" role="button"><i class="fas fa-bars"></i></a>
|
17 |
+
</li>
|
18 |
+
</ul> -->
|
19 |
+
</nav>
|
20 |
+
|
21 |
+
<!-- Main Sidebar Container -->
|
22 |
+
<aside class="main-sidebar sidebar-dark-primary elevation-4" style="width: 200px;">
|
23 |
+
<!-- Sidebar -->
|
24 |
+
<div class="sidebar">
|
25 |
+
<!-- Sidebar Menu -->
|
26 |
+
<nav class="mt-2">
|
27 |
+
<ul class="nav nav-pills nav-sidebar flex-column" data-widget="treeview" role="menu" data-accordion="false">
|
28 |
+
<!-- Navigation Links -->
|
29 |
+
<li class="nav-item">
|
30 |
+
<a href="{{url_for('dashboard')}}" class="nav-link">
|
31 |
+
<i class="nav-icon fas fa-home"></i>
|
32 |
+
<p>Dashboard</p>
|
33 |
+
</a>
|
34 |
+
</li>
|
35 |
+
<li class="nav-item">
|
36 |
+
<a href="{{ url_for('company_profile') }}" class="nav-link">
|
37 |
+
<i class="nav-icon fas fa-users"></i>
|
38 |
+
<p>Company Profile</p>
|
39 |
+
</a>
|
40 |
+
</li>
|
41 |
+
<li class="nav-item">
|
42 |
+
<a href="{{ url_for('knowledgebase') }}" class="nav-link">
|
43 |
+
<i class="nav-icon fas fa-cogs"></i>
|
44 |
+
<p>KnowledgeBase</p>
|
45 |
+
</a>
|
46 |
+
</li>
|
47 |
+
<li class="nav-item">
|
48 |
+
<a href="{{ url_for('data_connectors') }}" class="nav-link">
|
49 |
+
<i class="nav-icon fas fa-home"></i>
|
50 |
+
<p>Data Connectors</p>
|
51 |
+
</a>
|
52 |
+
</li>
|
53 |
+
<li class="nav-item">
|
54 |
+
<a href="{{ url_for('API_connectors') }}" class="nav-link">
|
55 |
+
<i class="nav-icon fas fa-users"></i>
|
56 |
+
<p>API Connectors</p>
|
57 |
+
</a>
|
58 |
+
</li>
|
59 |
+
<li class="nav-item">
|
60 |
+
<a href="{{url_for('prompt_template')}}" class="nav-link">
|
61 |
+
<i class="nav-icon fas fa-cogs"></i>
|
62 |
+
<p>Prompt Templates</p>
|
63 |
+
</a>
|
64 |
+
</li>
|
65 |
+
<!--<li class="nav-item">
|
66 |
+
<a href="#" class="nav-link">
|
67 |
+
<i class="nav-icon fas fa-cogs"></i>
|
68 |
+
<p>LLM Settings</p>
|
69 |
+
</a>
|
70 |
+
<ul class="nav nav-treeview">
|
71 |
+
<li class="nav-item">
|
72 |
+
<a href="#" class="nav-link">
|
73 |
+
<i class="far fa-circle nav-icon"></i>
|
74 |
+
<p>Sublink 1</p>
|
75 |
+
</a>
|
76 |
+
</li>
|
77 |
+
<li class="nav-item">
|
78 |
+
<a href="#" class="nav-link">
|
79 |
+
<i class="far fa-circle nav-icon"></i>
|
80 |
+
<p>Sublink 2</p>
|
81 |
+
</a>
|
82 |
+
</li>
|
83 |
+
<!-- Add more sublinks here -->
|
84 |
+
</ul>
|
85 |
+
</li> -->
|
86 |
+
|
87 |
+
<!-- Add more navigation links here -->
|
88 |
+
</ul>
|
89 |
+
</nav>
|
90 |
+
<!-- /.sidebar-menu -->
|
91 |
+
</div>
|
92 |
+
<!-- /.sidebar -->
|
93 |
+
</aside>
|
94 |
+
|
95 |
+
|
96 |
+
<!-- AdminLTE JS -->
|
97 |
+
<script >
|
98 |
+
function logout() {
|
99 |
+
// Clear session storage
|
100 |
+
sessionStorage.clear();
|
101 |
+
|
102 |
+
// Redirect to the login page
|
103 |
+
window.location.href = '/';
|
104 |
+
}
|
105 |
+
</script>
|