Spaces:
Sleeping
Sleeping
Update templates/dashboard.html
Browse files123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271<!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" /><link rel="stylesheet" href="/static/css/Dashboard1.css"></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/admin-lte@3.1/dist/js/adminlte.min.js"></script><script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0/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 immediatelyupdateSidepane(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 dataupdateRecordCounts(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 dashboarddocument.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 dropdowncompanies.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>123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271<!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" /><link rel="stylesheet" href="/static/css/dashboard1.css"></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/admin-lte@3.1/dist/js/adminlte.min.js"></script><script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0/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 immediatelyupdateSidepane(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 dataupdateRecordCounts(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 dashboarddocument.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 dropdowncompanies.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>
templates/dashboard.html+270-270