Spaces:
Sleeping
Sleeping
Delete templates/company_profile2.html
Browse files- templates/company_profile2.html +0 -315
templates/company_profile2.html
DELETED
@@ -1,315 +0,0 @@
|
|
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.det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