Spaces:
Sleeping
Sleeping
File size: 15,089 Bytes
e0ede30 7284c69 e0ede30 7284c69 e0ede30 7284c69 e0ede30 07e7e0f 6761873 e4c3752 804014b 49ccecc 804014b 49ccecc 8e5ee5f 07cd7e4 49ccecc 07cd7e4 4155428 47a8fbd 7284c69 e0ede30 7284c69 edb2c20 e0ede30 8e5ee5f e0ede30 3356ed3 edb2c20 e0ede30 3356ed3 e0ede30 3356ed3 7284c69 e0ede30 670c74c e0ede30 670c74c ee5e190 e0ede30 ee5e190 670c74c 81e3d38 e0ede30 670c74c 81e3d38 e0ede30 670c74c e0ede30 81e3d38 e0ede30 670c74c 81e3d38 e0ede30 670c74c e0ede30 670c74c ee5e190 e0ede30 670c74c e0ede30 ee5e190 670c74c ee5e190 670c74c ee5e190 e0ede30 670c74c ee5e190 670c74c ee5e190 e0ede30 ee5e190 670c74c ee5e190 e0ede30 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 |
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Dashboard</title>
<!-- CSS -->
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.0.0-beta3/css/all.min.css" />
<link rel="stylesheet" type="text/css" href="../static/css/style.css" />
<link rel="stylesheet" type="text/css" href="../static/css/dashboard.css" />
<link rel="stylesheet" type="text/css" href="../static/css/perfect-scrollbar.css" />
<style>
.btn-primary {
background-color: #0d6efd;
border-radius:5px;
border-color: #0d6efd;
}
#sidebarToggle
{
border-radius:4px;
margin-left:250px;
}
.main-sidebar.toggled .menu-text {
display: none;
}
#selectedCompany.toggled .menu-text {
display: none;
}
.wrapper {
flex: 1;
padding: 10px;
margin-left: 300px; /* Default sidebar width */
transition: margin-left 0.3s ease;
}
.main-header {
border-bottom: none;
border-top: none;
}
.card {
margin-bottom: 15px;
border-radius: 8px;
overflow: hidden;
transition: background-color 0.3s ease;
}
.card-body {
padding: 15px;
}
.feature-icon {
display: inline-flex;
align-items: center;
justify-content: center;
width: 50px;
height: 50px;
background: rgba(255, 255, 255, 0.1);
border-radius: 50%;
}
.sidebarPanel
{
display:none;
}
.media-body {
text-align: right;
}
.fs-30 {
font-size: 1.875rem;
}
.fs-48 {
font-size: 3rem;
}
/* Responsive Styles */
@media (max-width: 992px) {
.wrapper {
margin-left: 200px;
}
.main-header {
padding: 15px;
}
}
@media (max-width: 768px) {
.feature-icon {
width: 40px;
height: 40px;
}
.fs-30 {
font-size: 1.5rem;
}
.fs-48 {
font-size: 2.5rem;
}
}
</style>
</head>
<body>
{% set company_name = company_name %}
{% include 'sidepane.html' %}
<div class="wrapper">
<section class="main-header">
<div class="container-fluid">
<div id="company-block" class="form-group left-align" style="display: none;">
<label for="company" class="ml-3" style="display: inline-block; margin-right: 10px;">
Select the Company Name to view the details <span class="text-danger">*</span>
</label>
<select type="text" id="company" name="company" class="ml-3 form-control"
style="display: inline-block; width: 20%;" required>
<option value="" selected>Select</option>
</select>
</div>
<div class="row">
<div class="col-md-6">
<div class="card bg-primary">
<div class="card-body">
<div class="media align-items-center">
<span class="p-3 mr-3 feature-icon rounded">
<img src="../static/logos/calendar-silhouette.svg" />
</span>
<div class="media-body">
<p class="fs-30 text-white mb-2">KnowledgeBase</p>
<span id="knowledgeBaseCount" class="fs-48 text-white font-w600">{{table_count_of_each_table.knowledge_base}}</span>
</div>
</div>
</div>
</div>
</div>
<div class="col-md-6">
<div class="card bg-info">
<div class="card-body">
<div class="media align-items-center">
<span class="p-3 mr-3 feature-icon rounded">
<img src="../static/logos/calendar-silhouette.svg" />
</span>
<div class="media-body">
<p class="fs-30 text-white mb-2">Data connectors</p>
<span id="dataConnectorsCount" class="fs-48 text-white font-w600">{{table_count_of_each_table.data_connectors}}</span>
</div>
</div>
</div>
</div>
</div>
</div>
<div class="row">
<div class="col-md-6 ">
<div class="card bg-success">
<div class="card-body">
<div class="media align-items-center">
<span class="p-3 mr-3 feature-icon rounded">
<img src="../static/logos/email.svg" />
</span>
<div class="media-body">
<p class="fs-30 text-white mb-2">API Connectors</p>
<span id="apiConnectorsCount" class="fs-48 text-white font-w600">{{table_count_of_each_table.api_connectors}}</span>
</div>
</div>
</div>
</div>
</div>
<div class="col-md-6 ">
<div class="card bg-secondary">
<div class="card-body">
<div class="media align-items-center">
<span class="p-3 mr-3 feature-icon rounded">
<img src="../static/logos/dots.svg" />
</span>
<div class="media-body">
<p class="fs-30 text-white mb-2">Prompt_Templates</p>
<span id="promptTemplatesCount" class="fs-48 text-white font-w600">{{table_count_of_each_table.prompt_templates}}</span>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</section>
<input type="hidden" id="userRole" name="userRole" value={{role}}>
<input type="hidden" id="company_id" name="company_id" value={{company_id}}>
<input type="hidden" id="username" name="username" value={{username}}>
<input type="hidden" id="company_name" name="company_name" value={{company_name}}>
</div>
{% include 'footer.html' %}
<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/js/adminlte.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/js/bootstrap.bundle.min.js"></script>
<script>
document.getElementById("add").style.display = "none";
// function updateCompanyName(newCompanyName) {
// sessionStorage.setItem('company_name', newCompanyName);
// document.getElementById('selectedCompany').innerText = `Company name: ${newCompanyName}`;
// const sidePaneCompanyName = document.querySelector('.sidebar .company-name');
// if (sidePaneCompanyName) {
// sidePaneCompanyName.innerText = newCompanyName;
// }
// }
function updateSidepane(companyName) {
const sidepaneCompanyElement = document.getElementById('selectedCompany');
if (sidepaneCompanyElement) {
sidepaneCompanyElement.innerText = `Company Name: ${companyName}`;
}
}
window.addEventListener('pageshow', function (event) {
if (event.persisted || (window.performance && window.performance.navigation.type === 2)) {
window.location.reload();
}
});
document.addEventListener('DOMContentLoaded', function () {
var role1 = document.getElementById("userRole").value;
var company_id1 = document.getElementById("company_id").value;
var company_name1=document.getElementById("company_name").value;
var username1=document.getElementById("username").value;
console.log("companyid in dasshboard",username1);
sessionStorage.setItem('userRole', role1);
// sessionStorage.setItem('siderole',role1);
// sessionStorage.setItem('sidecompanyId',company_id1);
sessionStorage.setItem('company_id', company_id1);
sessionStorage.setItem('company_name',company_name1);
sessionStorage.setItem('username',username1);
const companyName = sessionStorage.getItem('company_name');
if (companyName) {
updateSidepane(companyName);
}
else{
document.getElementById(selectedCompany).value="Select a company";
}
if (!role1) {
var roleFromInput = sessionStorage.getItem('userRole');
sessionStorage.setItem('userRole', roleFromInput);
console.log("Role set in sessionStorage:", roleFromInput);
} else {
sessionStorage.setItem('userRole', role1);
console.log("Retrieved user role from input:", role1); // Debugging
}
if (role1 === "superadmin") {
document.getElementById('company-block').style.display = 'block';
fetchCompanies();
}
});
document.getElementById('company').addEventListener('change', async function () {
const selectedCompany = this.value;
sessionStorage.setItem("company_name",selectedCompany);
// Update the sidepane immediately
updateSidepane(selectedCompany);
if (selectedCompany!== "Select") {
try {
const response = await fetch(`/api/company_id?company_name=${encodeURIComponent(selectedCompany)}`);
if (!response.ok) {
contentSection.style.display = 'none';
displayErrorMessage("Document details do not exist for this company. Please fill in the details.");
throw new Error('Network response was not ok');
}
const data = await response.json();
console.log('data returned', data);
const companyId = data.company_id;
sessionStorage.setItem("company_id",companyId);
console.log("company id for superadmin", company_id);
//document.getElementById('company_id').value = companyId;
if (companyId) {
try {
const countResponse = await fetch(`/api/company_record_count/${companyId}`);
if (!countResponse.ok) {
throw new Error('Network response was not ok');
}
const countData = await countResponse.json();
console.log('Count data:', countData); // Log the response data
updateRecordCounts(countData.table_counts);
} catch (error) {
console.error('Error fetching record counts:', error);
}
} else {
clearRecordCounts();
}
} catch (error) {
console.error('No details for this company ID or data documents:', error);
// displayEmptyTable();
displayErrorMessage("company details do not exist for this company.");
}
}
});
function updateRecordCounts(counts) {
// Update the counts displayed in the dashboard
document.getElementById('knowledgeBaseCount').textContent = counts.knowledge_base || 0;
document.getElementById('dataConnectorsCount').textContent = counts.data_connectors || 0;
document.getElementById('apiConnectorsCount').textContent = counts.api_connectors || 0;
document.getElementById('promptTemplatesCount').textContent = counts.prompt_templates || 0;
}
function clearRecordCounts() {
document.getElementById('knowledgeBaseCount').textContent = 0;
document.getElementById('dataConnectorsCount').textContent = 0;
document.getElementById('apiConnectorsCount').textContent = 0;
document.getElementById('promptTemplatesCount').textContent = 0;
}
async function fetchCompanies() {
try {
const response = await fetch('/api/companies');
if (!response.ok) {
throw new Error('Network response was not ok');
}
const data = await response.json();
displayCompanies(data.companies);
} catch (error) {
console.error('Error fetching companies:', error);
}
}
function displayCompanies(companies) {
const companySelect = document.getElementById('company');
companySelect.innerHTML = '<option value="" selected>Select</option>'; // Reset the dropdown
companies.forEach(company => {
const option = document.createElement('option');
option.value = company.name;
option.textContent = company.name;
companySelect.appendChild(option);
});
}
function clearFormFields() {
document.getElementById('APIName').value = "";
document.getElementById('APIEndpoint').value = "";
document.getElementById('Auth_Bearer').value = "";
document.getElementById('Inputjson').value = "";
document.getElementById('OutputJson').value = "";
document.getElementById('Description').value = "";
}
</script>
</body>
</html>
|