@@ -36,7 +40,7 @@
Api Key
diff --git a/src/app/integrations/list/hubspot-integration/hubspot-integration.component.scss b/src/app/integrations/list/hubspot-integration/hubspot-integration.component.scss
index 02d294f6d6a1..d99fe05cb4b6 100644
--- a/src/app/integrations/list/hubspot-integration/hubspot-integration.component.scss
+++ b/src/app/integrations/list/hubspot-integration/hubspot-integration.component.scss
@@ -10,7 +10,8 @@ p {
flex-direction: row;
align-items: center;
justify-content: space-between;
-
+ height: 50px;
+
.signup {
display: flex;
diff --git a/src/app/integrations/list/hubspot-integration/hubspot-integration.component.ts b/src/app/integrations/list/hubspot-integration/hubspot-integration.component.ts
index 1a71e0a9860a..6316dcf3e2bc 100644
--- a/src/app/integrations/list/hubspot-integration/hubspot-integration.component.ts
+++ b/src/app/integrations/list/hubspot-integration/hubspot-integration.component.ts
@@ -28,7 +28,7 @@ export class HubspotIntegrationComponent implements OnInit {
this.logger.debug("[INT-Hubspot] integration ", this.integration)
this.translateparams = { intname: 'Hubspot' };
if (this.integration.value.apikey) {
- this.checkKey(this.integration.value.apikey);
+ this.checkKey();
}
}
@@ -44,7 +44,7 @@ export class HubspotIntegrationComponent implements OnInit {
}
saveIntegration() {
- this.checkKey(this.integration.value.apikey).then((status) => {
+ this.checkKey().then((status) => {
let data = {
integration: this.integration,
isVerified: status
@@ -87,27 +87,29 @@ export class HubspotIntegrationComponent implements OnInit {
// })
// }
- checkKey(key: string) {
- return new Promise((resolve, reject) => {
- this.integrationService.checkKeyQapla(key).subscribe((resp: any) => {
- if (resp.getCouriers.result === 'OK') {
- this.isVerified = true;
- resolve(true);
+ checkKey() {
+ return new Promise((resolve) => {
+ let url = "https://api.hubapi.com/crm/v3/objects/contacts?limit=10";
+ let key = "Bearer " + this.integration.value.apikey;
+ this.integrationService.checkIntegrationKeyValidity(url, key).subscribe((resp: any) => {
+ this.isVerified = true;
+ resolve(true);
+ }, (error) => {
+ this.logger.error("[INT-Hubspot] Key verification failed: ", error);
+ if (error.status === 0) {
+ resolve(false);
} else {
this.isVerified = false;
resolve(false);
+
}
- }, (error) => {
- this.logger.error("[INT-Qapla] Key verification failed: ", error);
- this.isVerified = false;
- resolve(false);
})
})
}
resetValues() {
this.integration.value = {
- apikey: null,
+ apikey: null
}
}
diff --git a/src/app/integrations/list/make-integration/make-integration.component.scss b/src/app/integrations/list/make-integration/make-integration.component.scss
index de09e7606063..ed107d983bb3 100644
--- a/src/app/integrations/list/make-integration/make-integration.component.scss
+++ b/src/app/integrations/list/make-integration/make-integration.component.scss
@@ -10,6 +10,7 @@ p {
flex-direction: row;
align-items: center;
justify-content: space-between;
+ height: 50px;
.signup {
display: flex;
diff --git a/src/app/integrations/list/openai-integration/openai-integration.component.html b/src/app/integrations/list/openai-integration/openai-integration.component.html
index b1853778886e..f1a5ba980504 100644
--- a/src/app/integrations/list/openai-integration/openai-integration.component.html
+++ b/src/app/integrations/list/openai-integration/openai-integration.component.html
@@ -5,7 +5,7 @@
-
+
-
+
diff --git a/src/app/integrations/list/openai-integration/openai-integration.component.scss b/src/app/integrations/list/openai-integration/openai-integration.component.scss
index c7d6a88ab4cb..ca63642ce4d1 100644
--- a/src/app/integrations/list/openai-integration/openai-integration.component.scss
+++ b/src/app/integrations/list/openai-integration/openai-integration.component.scss
@@ -10,7 +10,8 @@ p {
flex-direction: row;
align-items: center;
justify-content: space-between;
-
+ height: 50px;
+
.signup {
display: flex;
diff --git a/src/app/integrations/list/openai-integration/openai-integration.component.ts b/src/app/integrations/list/openai-integration/openai-integration.component.ts
index d3d6eb245ef8..066f1445b607 100644
--- a/src/app/integrations/list/openai-integration/openai-integration.component.ts
+++ b/src/app/integrations/list/openai-integration/openai-integration.component.ts
@@ -1,4 +1,5 @@
import { Component, EventEmitter, Input, OnInit, Output } from '@angular/core';
+import { IntegrationService } from 'app/services/integration.service';
import { LoggerService } from 'app/services/logger/logger.service';
import { OpenaiService } from 'app/services/openai.service';
@@ -18,7 +19,7 @@ export class OpenaiIntegrationComponent implements OnInit {
translateparams: any;
constructor(
- private openaiService: OpenaiService,
+ private integrationService: IntegrationService,
private logger: LoggerService
) { }
@@ -26,7 +27,7 @@ export class OpenaiIntegrationComponent implements OnInit {
this.logger.debug("[INT-OpenAI] integration ", this.integration)
this.translateparams = { intname: 'OpenAI' };
if (this.integration.value.apikey) {
- this.checkKey(this.integration.value.apikey);
+ this.checkKey();
}
}
@@ -41,7 +42,7 @@ export class OpenaiIntegrationComponent implements OnInit {
}
saveIntegration() {
- this.checkKey(this.integration.value.apikey).then((status) => {
+ this.checkKey().then((status) => {
let data = {
integration: this.integration,
isVerified: status
@@ -55,9 +56,11 @@ export class OpenaiIntegrationComponent implements OnInit {
this.onDeleteIntegration.emit(this.integration);
}
- checkKey(key: string) {
- return new Promise((resolve, reject) => {
- this.openaiService.checkKeyValidity(key).subscribe((resp) => {
+ checkKey() {
+ return new Promise((resolve) => {
+ let url = "https://api.openai.com/v1/models";
+ let key = "Bearer " + this.integration.value.apikey;
+ this.integrationService.checkIntegrationKeyValidity(url, key).subscribe((resp) => {
this.isVerified = true;
resolve(true);
}, (error) => {
diff --git a/src/app/integrations/list/qapla-integration/qapla-integration.component.html b/src/app/integrations/list/qapla-integration/qapla-integration.component.html
index 69ee35733068..1aa2b0e09e2c 100644
--- a/src/app/integrations/list/qapla-integration/qapla-integration.component.html
+++ b/src/app/integrations/list/qapla-integration/qapla-integration.component.html
@@ -5,7 +5,7 @@
-
+
-
+
+
diff --git a/src/app/integrations/list/qapla-integration/qapla-integration.component.scss b/src/app/integrations/list/qapla-integration/qapla-integration.component.scss
index 7b3b6d55a487..0b414e30778c 100644
--- a/src/app/integrations/list/qapla-integration/qapla-integration.component.scss
+++ b/src/app/integrations/list/qapla-integration/qapla-integration.component.scss
@@ -10,7 +10,8 @@ p {
flex-direction: row;
align-items: center;
justify-content: space-between;
-
+ height: 50px;
+
.signup {
display: flex;
diff --git a/src/app/integrations/list/qapla-integration/qapla-integration.component.ts b/src/app/integrations/list/qapla-integration/qapla-integration.component.ts
index 801283d4c3cf..f2f90660ad32 100644
--- a/src/app/integrations/list/qapla-integration/qapla-integration.component.ts
+++ b/src/app/integrations/list/qapla-integration/qapla-integration.component.ts
@@ -27,7 +27,7 @@ export class QaplaIntegrationComponent implements OnInit {
this.logger.debug("[INT-Qapla] integration ", this.integration)
this.translateparams = { intname: "Qapla'" };
if (this.integration.value.apikey) {
- this.checkKey(this.integration.value.apikey);
+ this.checkKey();
}
}
@@ -42,7 +42,7 @@ export class QaplaIntegrationComponent implements OnInit {
}
saveIntegration() {
- this.checkKey(this.integration.value.apikey).then((status) => {
+ this.checkKey().then((status) => {
let data = {
integration: this.integration,
isVerified: status
@@ -56,9 +56,10 @@ export class QaplaIntegrationComponent implements OnInit {
this.onDeleteIntegration.emit(this.integration);
}
- checkKey(key: string) {
- return new Promise((resolve, reject) => {
- this.integrationService.checkKeyQapla(key).subscribe((resp: any) => {
+ checkKey() {
+ return new Promise((resolve) => {
+ let url = "https://api.qapla.it/1.2/getCouriers/?apiKey=" + this.integration.value.apikey;
+ this.integrationService.checkIntegrationKeyValidity(url).subscribe((resp: any) => {
if (resp.getCouriers.result === 'OK') {
this.isVerified = true;
resolve(true);
@@ -68,8 +69,13 @@ export class QaplaIntegrationComponent implements OnInit {
}
}, (error) => {
this.logger.error("[INT-Qapla] Key verification failed: ", error);
- this.isVerified = false;
- resolve(false);
+ // check for CORS policies errors
+ if (error.status == 0) {
+ resolve(false);
+ } else {
+ this.isVerified = false;
+ resolve(false);
+ }
})
})
}
diff --git a/src/app/integrations/utils.ts b/src/app/integrations/utils.ts
index 6b472f938382..e51df2f2998d 100644
--- a/src/app/integrations/utils.ts
+++ b/src/app/integrations/utils.ts
@@ -55,7 +55,7 @@ export const CATEGORIES_LIST = [
export const INTEGRATIONS_LIST: { [key: string]: { name: string, category: INTEGRATIONS_CATEGORIES, key: INTEGRATIONS_KEYS, src_icon: string, src_logo: string, pro?: boolean, plan: 'Sandbox' | 'Basic' | 'Premium' | 'Custom' } } = {
//BREVO: { name: "Brevo", category: INTEGRATIONS_CATEGORIES.CRM, key: INTEGRATIONS_KEYS.BREVO, src_icon: "assets/img/int/brevo.png", src_logo: "assets/img/int/brevo-logo.png", pro: true, plan: 'Premium' },
- //CUSTOMERIO: { name: "Customer.io", category: INTEGRATIONS_CATEGORIES.CRM, key: INTEGRATIONS_KEYS.CUSTOMERIO, src_icon: "assets/img/int/customer-io-logo-color.svg", src_logo: "assets/img/int/customerio-logo.svg", pro: true, plan: 'Premium' },
+ CUSTOMERIO: { name: "Customer.io", category: INTEGRATIONS_CATEGORIES.CRM, key: INTEGRATIONS_KEYS.CUSTOMERIO, src_icon: "assets/img/int/customer-io-logo-color.svg", src_logo: "assets/img/int/customerio-logo.svg", pro: true, plan: 'Premium' },
HUBSPOT: { name: "HubSpot", category: INTEGRATIONS_CATEGORIES.CRM, key: INTEGRATIONS_KEYS.HUBSPOT, src_icon: "assets/img/int/hubspot.png", src_logo: "assets/img/int/hubspot-logo.svg", pro: true, plan: 'Premium' },
OPENAI: { name: "OpenAI", category: INTEGRATIONS_CATEGORIES.AI, key: INTEGRATIONS_KEYS.OPENAI, src_icon: "assets/cds/images/actions/openai-icon.svg", src_logo: "assets/img/int/openai-logo.svg", pro: true, plan: 'Custom' },
QAPLA: { name: "Qapla'", category: INTEGRATIONS_CATEGORIES.ECOMMERCE, key: INTEGRATIONS_KEYS.QAPLA, src_icon: "assets/cds/images/actions/qapla.jpg", src_logo: "assets/img/int/qapla-logo.png", pro: true, plan: 'Premium' },
@@ -76,7 +76,7 @@ export const INTEGRATIONS_LIST: { [key: string]: { name: string, category: INTEG
export const INTEGRATION_LIST_ARRAY = [
//{ name: "Brevo", category: INTEGRATIONS_CATEGORIES.CRM, key: INTEGRATIONS_KEYS.BREVO, src_icon: "assets/img/int/brevo-icon.png", src_logo: "assets/img/int/brevo-logo.png", pro: true, plan: 'Premium' },
- //{ name: "Customer.io", category: INTEGRATIONS_CATEGORIES.CRM, key: INTEGRATIONS_KEYS.CUSTOMERIO, src_icon: "assets/img/int/customerio-icon.png", src_logo: "assets/img/int/customerio-logo.svg", pro: true, plan: 'Premium' },
+ { name: "Customer.io", category: INTEGRATIONS_CATEGORIES.CRM, key: INTEGRATIONS_KEYS.CUSTOMERIO, src_icon: "assets/img/int/customerio-icon.png", src_logo: "assets/img/int/customerio-logo.svg", pro: true, plan: 'Premium' },
{ name: "HubSpot", category: INTEGRATIONS_CATEGORIES.CRM, key: INTEGRATIONS_KEYS.HUBSPOT, src_icon: "assets/img/int/hubspot-icon.png", src_logo: "assets/img/int/hubspot-logo.svg", pro: true, plan: 'Premium' },
{ name: "OpenAI", category: INTEGRATIONS_CATEGORIES.AI, key: INTEGRATIONS_KEYS.OPENAI, src_icon: "assets/img/int/openai-icon.svg", src_logo: "assets/img/int/openai-logo.svg", pro: true, plan: 'Custom' },
{ name: "Qapla'", category: INTEGRATIONS_CATEGORIES.ECOMMERCE, key: INTEGRATIONS_KEYS.QAPLA, src_icon: "assets/img/int/qapla-icon.jpg", src_logo: "assets/img/int/qapla-logo.png", pro: true, plan: 'Premium' },
@@ -145,8 +145,9 @@ export class CustomerioIntegration extends Integration {
super();
this.name = INTEGRATIONS_KEYS.CUSTOMERIO;
this.value = {
- apikey: null,
- siteid: null
+ siteid: null,
+ key: null,
+ apikey: null //base64 format of siteid:key
}
}
}
diff --git a/src/app/knowledge-bases/knowledge-bases.component.html b/src/app/knowledge-bases/knowledge-bases.component.html
index fbba1a89c76d..f66fc40393e0 100644
--- a/src/app/knowledge-bases/knowledge-bases.component.html
+++ b/src/app/knowledge-bases/knowledge-bases.component.html
@@ -27,37 +27,32 @@
-
+
-
- {{ 'KbPage.Add' | translate }}
- add
+
+ {{ 'KbPage.Add' | translate }}
+
@@ -80,9 +75,16 @@
+
+
+
diff --git a/src/app/knowledge-bases/knowledge-bases.component.scss b/src/app/knowledge-bases/knowledge-bases.component.scss
index f11e39f0ab98..bea8ccc5b6cd 100644
--- a/src/app/knowledge-bases/knowledge-bases.component.scss
+++ b/src/app/knowledge-bases/knowledge-bases.component.scss
@@ -439,11 +439,35 @@ table {
display: inline-block;
vertical-align: middle;
line-height: 24px;
- font-size: medium;
+ // font-size: medium;
+ text-transform: none;
+ border-radius: 4px;
}
.icon-big-button {
padding: 0 14px;
font-weight: bold;
height: auto;
-}
\ No newline at end of file
+}
+
+
+// .mat-menu-panel {
+// margin-top: 6px !important;
+// border-radius: 8px !important;
+// background: #FFFFFF!important;
+// box-shadow: 0 40px 64px -32px #161a1e1f, 0 32px 40px -32px #161a1e1a, 0 24px 32px -32px #161a1e14, 0 16px 20px -32px #161a1e14, 0 10px 16px -32px #161a1e0f, 0 4px 8px -32px #161a1e0a, 0 1px 1px #161a1e0a, 0 0 0 1px #161a1e0f!important;
+// border-radius: 10px!important;
+// }
+
+
+
+ ::ng-deep.mat-elevation-z4{
+ background: #FFFFFF;
+ box-shadow: 0 40px 64px -32px #161a1e1f, 0 32px 40px -32px #161a1e1a, 0 24px 32px -32px #161a1e14, 0 16px 20px -32px #161a1e14, 0 10px 16px -32px #161a1e0f, 0 4px 8px -32px #161a1e0a, 0 1px 1px #161a1e0a, 0 0 0 1px #161a1e0f;
+ border-radius: 10px;
+ margin-top: 4px;
+}
+
+.btn {
+ text-transform: none;
+}
\ No newline at end of file
diff --git a/src/app/knowledge-bases/knowledge-bases.component.ts b/src/app/knowledge-bases/knowledge-bases.component.ts
index ea11bc0e334f..05c115f559ab 100644
--- a/src/app/knowledge-bases/knowledge-bases.component.ts
+++ b/src/app/knowledge-bases/knowledge-bases.component.ts
@@ -14,6 +14,8 @@ import { TranslateService } from '@ngx-translate/core';
import { Subject } from 'rxjs';
import { takeUntil } from 'rxjs/operators';
import { FaqKbService } from 'app/services/faq-kb.service';
+import { KB_DEFAULT_PARAMS } from 'app/utils/util';
+
//import { Router } from '@angular/router';
@Component({
@@ -44,6 +46,7 @@ export class KnowledgeBasesComponent implements OnInit, OnDestroy {
//analytics
+ // SHOW_TABLE: boolean = false;
CURRENT_USER: any;
project: Project;
project_name: string;
@@ -55,18 +58,13 @@ export class KnowledgeBasesComponent implements OnInit, OnDestroy {
kbFormUrl: FormGroup;
kbFormContent: FormGroup;
- kbs: any;
- kbsList = [];
+ // kbs: any;
+ kbsList: Array
;
kbsListCount: number = 0;
refreshKbsList: boolean = true;
+ numberPage: number = 0;
+
- // PREVIEW
- // question: string = "";
- // answer: string = "";
- // source_url: any;
- // searching: boolean = false;
- // error_answer: boolean = false;
- // show_answer: boolean = false;
kbid_selected: any;
interval_id;
ARE_NEW_KB: boolean
@@ -88,6 +86,7 @@ export class KnowledgeBasesComponent implements OnInit, OnDestroy {
customerSatisfactionBotsCount: number;
myChatbotOtherCount: number;
increaseSalesBotsCount: number;
+ listSitesOfSitemap: any = [];
private unsubscribe$: Subject = new Subject();
constructor(
@@ -105,11 +104,12 @@ export class KnowledgeBasesComponent implements OnInit, OnDestroy {
) { }
ngOnInit(): void {
-
+ this.kbsList = [];
this.getBrowserVersion();
this.getTranslations();
this.listenSidebarIsOpened();
- this.getListOfKb();
+ let paramsDefault = "?limit="+KB_DEFAULT_PARAMS.LIMIT+"&page="+KB_DEFAULT_PARAMS.NUMBER_PAGE+"&sortField="+KB_DEFAULT_PARAMS.SORT_FIELD+"&direction="+KB_DEFAULT_PARAMS.DIRECTION;
+ this.getListOfKb(paramsDefault);
this.kbFormUrl = this.createConditionGroupUrl();
this.kbFormContent = this.createConditionGroupContent();
this.trackPage();
@@ -393,17 +393,86 @@ export class KnowledgeBasesComponent implements OnInit, OnDestroy {
/**
* getListOfKb
*/
+ // getListOfKb() {
+ // this.logger.log("[KNOWLEDGE-BASES-COMP] getListOfKb ");
+ // this.kbService.getListOfKb().subscribe((kbList:[KB]) => {
+ // this.logger.log("[KNOWLEDGE-BASES-COMP] get kbList: ", kbList);
+ // this.kbsList = kbList;
+ // this.checkAllStatuses();
+ // }, (error) => {
+ // this.logger.error("[KNOWLEDGE-BASES-COMP] ERROR get kbSettings: ", error);
+ // }, () => {
+ // this.logger.log("[KNOWLEDGE-BASES-COMP] get kbSettings *COMPLETE*");
+ // this.showSpinner = false;
+ // })
+ // }
+
+ onLoadPage(searchParams){
+ // console.log('onLoadNextPage:',searchParams);
+ let params = "?limit="+KB_DEFAULT_PARAMS.LIMIT
+ //if(searchParams?.page){
+ let limitPage = Math.floor(this.kbsListCount/KB_DEFAULT_PARAMS.LIMIT);
+ this.numberPage++;
+ if(this.numberPage>limitPage)this.numberPage = limitPage;
+ params +="&page="+this.numberPage;
+ // } else {
+ // +"&page=0";
+ // }
+ if(searchParams?.status){
+ params +="&status="+searchParams.status;
+ }
+ if(searchParams?.search){
+ params +="&search="+searchParams.search;
+ }
+ if(searchParams?.sortField){
+ params +="&sortField="+searchParams.sortField;
+ } else {
+ params +="&sortField="+KB_DEFAULT_PARAMS.SORT_FIELD;
+ }
+ if(searchParams?.direction){
+ params +="&direction="+searchParams.direction;
+ } else {
+ params +="&direction="+KB_DEFAULT_PARAMS.DIRECTION;
+ }
+ this.getListOfKb(params);
+ }
+
+ onLoadByFilter(searchParams){
+ // console.log('onLoadByFilter:',searchParams);
+ // searchParams.page = 0;
+ this.numberPage = -1;
+ this.kbsList = [];
+ this.onLoadPage(searchParams);
+ }
+
+
getListOfKb(params?) {
this.logger.log("[KNOWLEDGE BASES COMP] getListOfKb ");
- let paramsDefault = "?limit=10&page=0";
- let urlParams = params?params:paramsDefault;
- this.kbService.getListOfKb(urlParams).subscribe((kbResp:any) => {
- this.logger.log("[KNOWLEDGE BASES COMP] get kbList: ", kbResp);
- this.kbs = kbResp;
- this.kbsList = kbResp.kbs;
- //this.kbsListCount = kbList.count;
- this.checkAllStatuses();
+ this.kbService.getListOfKb(params).subscribe((resp:any) => {
+ this.logger.log("[KNOWLEDGE BASES COMP] get kbList: ", resp);
+ //this.kbs = resp;
+ this.kbsListCount = resp.count;
+ resp.kbs.forEach(kb => {
+ // this.kbsList.push(kb);
+ const index = this.kbsList.findIndex(objA => objA._id === kb._id);
+ if (index !== -1) {
+ this.kbsList[index] = kb;
+ } else {
+ this.kbsList.push(kb);
+ }
+ //--> this.updateStatusOfKb(kb._id, 3);
+ });
+
+ // if(this.kbsList.length>0){
+ // this.SHOW_TABLE = true;
+ // this.checkAllStatuses();
+ // } else {
+ // this.SHOW_TABLE = false;
+ // }
+ //this.showSpinner = false;
+ //
this.refreshKbsList = !this.refreshKbsList;
+
}, (error) => {
this.logger.error("[KNOWLEDGE BASES COMP] ERROR get kbSettings: ", error);
//this.showSpinner = false;
@@ -429,6 +498,22 @@ export class KnowledgeBasesComponent implements OnInit, OnDestroy {
// })
// }
+ onSendSitemap(body){
+ // this.onCloseBaseModal();
+ let error = this.msgErrorAddUpdateKb;
+ this.kbService.addSitemap(body).subscribe((resp: any) => {
+ this.logger.log("onSendSitemap:", resp);
+ // let error = resp.error;
+ // let url = resp.url;
+ this.listSitesOfSitemap = resp.sites;
+ }, (err) => {
+ this.logger.error("[KNOWLEDGE-BASES-COMP] ERROR send sitemap: ", err);
+ this.onOpenErrorModal(error);
+ }, () => {
+ this.logger.log("[KNOWLEDGE-BASES-COMP] send sitemap *COMPLETED*");
+ })
+ }
+
/**
* onAddKb
*/
@@ -437,21 +522,33 @@ export class KnowledgeBasesComponent implements OnInit, OnDestroy {
this.onCloseBaseModal();
let error = this.msgErrorAddUpdateKb;
this.kbService.addKb(body).subscribe((resp: any) => {
+ this.logger.log("onAddKb:", resp);
let kb = resp.value;
- this.logger.log("onAddKb:", kb);
- if(kb.lastErrorObject && kb.lastErrorObject.updatedExisting === true){
+ if(resp.lastErrorObject && resp.lastErrorObject.updatedExisting === true){
+ //console.log("updatedExisting true:");
const index = this.kbsList.findIndex(item => item._id === kb._id);
if (index !== -1) {
this.kbsList[index] = kb;
- this.notify.showWidgetStyleUpdateNotification(this.msgSuccesUpdateKb, 2, 'done');
+ this.notify.showWidgetStyleUpdateNotification(this.msgSuccesUpdateKb, 3, 'warning');
}
} else {
- this.kbsList.push(kb);
+ //this.kbsList.push(kb);
this.notify.showWidgetStyleUpdateNotification(this.msgSuccesAddKb, 2, 'done');
+ // this.kbsListCount++;
+ this.kbsList.unshift(kb);
+ this.kbsListCount = this.kbsListCount+1;
+ this.refreshKbsList = !this.refreshKbsList;
+ // let searchParams = {
+ // "sortField": KB_DEFAULT_PARAMS.SORT_FIELD,
+ // "direction": KB_DEFAULT_PARAMS.DIRECTION,
+ // "status": '',
+ // "search": '',
+ // }
+ // this.onLoadByFilter(searchParams);
}
- this.updateStatusOfKb(kb._id, 3);
- this.refreshKbsList = !this.refreshKbsList;
- // this.logger.log("kbsList:",that.kbsList);
+ this.updateStatusOfKb(kb._id, -1);
+ // this.updateStatusOfKb(kb._id, 0);
+ // this.onLoadByFilter(searchParams);
// that.onRunIndexing(kb);
// setTimeout(() => {
// this.checkStatusWithRetry(kb);
@@ -466,6 +563,40 @@ export class KnowledgeBasesComponent implements OnInit, OnDestroy {
})
}
+
+
+ onAddMultiKb(body) {
+ this.onCloseBaseModal();
+ // console.log("onAddMultiKb");
+ let error = this.msgErrorAddUpdateKb;
+ this.kbService.addMultiKb(body).subscribe((kbs: any) => {
+ this.logger.log("onAddMultiKb:", kbs);
+ this.notify.showWidgetStyleUpdateNotification(this.msgSuccesAddKb, 2, 'done');
+
+ let paramsDefault = "?limit="+KB_DEFAULT_PARAMS.LIMIT+"&page="+KB_DEFAULT_PARAMS.NUMBER_PAGE+"&sortField="+KB_DEFAULT_PARAMS.SORT_FIELD+"&direction="+KB_DEFAULT_PARAMS.DIRECTION;
+ this.getListOfKb(paramsDefault);
+ // kbs.forEach(kb => {
+ // //this.kbsList.unshift(kb);
+ // // if(kb.status == -1 || kb.status == 0 || kb.status == 2) {
+ // // setTimeout(() => {
+ // // this.checkStatusWithRetry(kb);
+ // // }, 2000);
+ // // }
+ // // this.updateStatusOfKb(kb._id, 3);
+ // //this.updateStatusOfKb(kb._id, -1);
+ // });
+ this.kbsListCount = this.kbsListCount+kbs.length;
+ this.refreshKbsList = !this.refreshKbsList;
+ }, (err) => {
+ this.logger.error("[KNOWLEDGE-BASES-COMP] ERROR add new kb: ", err);
+ this.onOpenErrorModal(error);
+ }, () => {
+ this.logger.log("[KNOWLEDGE-BASES-COMP] add new kb *COMPLETED*");
+ //this.trackUserActioOnKB('Added Knowledge Base', gptkey)
+ })
+ }
+
+
/**
* onDeleteKb
*/
@@ -481,13 +612,22 @@ export class KnowledgeBasesComponent implements OnInit, OnDestroy {
//this.logger.log('onDeleteKb:: ', response);
kb.deleting = false;
if(!response || (response.success && response.success === false)){
- this.updateStatusOfKb(kb._id, 0);
+ // this.updateStatusOfKb(kb._id, 0);
this.onOpenErrorModal(error);
} else {
this.notify.showWidgetStyleUpdateNotification(this.msgSuccesDeleteKb, 2, 'done');
// let error = response.error?response.error:"Errore generico";
// this.onOpenErrorModal(error);
this.removeKb(kb._id);
+ this.kbsListCount = this.kbsListCount-1;
+ this.refreshKbsList = !this.refreshKbsList;
+ // let searchParams = {
+ // "sortField": KB_DEFAULT_PARAMS.SORT_FIELD,
+ // "direction": KB_DEFAULT_PARAMS.DIRECTION,
+ // "status": '',
+ // "search": '',
+ // }
+ // this.onLoadByFilter(searchParams);
}
}, (err) => {
this.logger.error("[KNOWLEDGE-BASES-COMP] ERROR delete kb: ", err);
@@ -501,8 +641,9 @@ export class KnowledgeBasesComponent implements OnInit, OnDestroy {
}
+ /** */
onUpdateKb(kb) {
- // console.log("onUpdateKb: ",kb);
+ this.logger.log('onUpdateKb: ', kb);
this.onCloseBaseModal();
let error = "update fallito"
let dataDelete = {
@@ -511,7 +652,7 @@ export class KnowledgeBasesComponent implements OnInit, OnDestroy {
}
let dataAdd = {
'name': kb.name,
- 'source': kb.url,
+ 'source': kb.source,
'content': '',
'type': 'url'
};
@@ -520,31 +661,36 @@ export class KnowledgeBasesComponent implements OnInit, OnDestroy {
dataAdd.content = kb.content,
dataAdd.type = 'text'
}
-
+ this.logger.log('dataAdd: ', dataAdd);
kb.deleting = true;
this.kbService.deleteKb(dataDelete).subscribe((response:any) => {
kb.deleting = false;
if(!response || (response.success && response.success === false)){
this.onOpenErrorModal(error);
} else {
-
this.kbService.addKb(dataAdd).subscribe((resp: any) => {
- let kb = resp.value;
- if(kb.lastErrorObject && kb.lastErrorObject.updatedExisting === true){
- const index = this.kbsList.findIndex(item => item._id === kb._id);
+ let kbNew = resp.value;
+ if(resp.lastErrorObject && resp.lastErrorObject.updatedExisting === true){
+ const index = this.kbsList.findIndex(item => item._id === kbNew._id);
if (index !== -1) {
- this.kbsList[index] = kb;
- this.notify.showWidgetStyleUpdateNotification(this.msgSuccesUpdateKb, 2, 'done');
+ this.kbsList[index] = kbNew;
+ this.notify.showWidgetStyleUpdateNotification(this.msgSuccesUpdateKb, 3, 'warning');
}
} else {
- this.kbsList.push(kb);
+ // this.kbsList.push(kb);
+ // this.kbsList.unshift(kbNew);
this.notify.showWidgetStyleUpdateNotification(this.msgSuccesAddKb, 2, 'done');
}
- this.removeKb(kb._id);
- this.updateStatusOfKb(kb._id, 0);
+
+ const index = this.kbsList.findIndex(item => item.id === kb._id);
+ if (index > -1) {
+ this.kbsList[index] = kbNew;
+ }
+ // this.removeKb(kb._id);
+ //-->this.updateStatusOfKb(kbNew._id, 0);
this.refreshKbsList = !this.refreshKbsList;
// setTimeout(() => {
- // this.checkStatusWithRetry(kb);
+ // this.checkStatusWithRetry(kbNew);
// }, 2000);
}, (err) => {
this.logger.error("[KNOWLEDGE BASES COMP] ERROR add new kb: ", err);
@@ -573,26 +719,79 @@ export class KnowledgeBasesComponent implements OnInit, OnDestroy {
"namespace": this.id_project,
"id": kb._id
}
+ var status_msg = "Indexing completed successfully!";
+ var status_code = 2;
+ var status_label = "done"
this.openaiService.checkScrapingStatus(data).subscribe((response: any) => {
+
// this.logger.log('Risposta ricevuta:', response);
- if(response.status_code && response.status_code == -1){
- // this.logger.log('risorsa non indicizzata');
- // this.onRunIndexing(kb);
- // this.checkStatusWithRetry(kb);
- } else if(response.status_code == -1 || response.status_code == 0 || response.status_code == 2){
+ // if(response.status_code && response.status_code == -1){
+ // // this.logger.log('risorsa non indicizzata');
+ // // this.onRunIndexing(kb);
+ // this.checkStatusWithRetry(kb);
+ // }
+
+
+ let resource_status: Number;
+ if (response.status) {
+ resource_status = response.status;
+ } else {
+ resource_status = response.status_code
+ }
+
+ if (response.status == -1) {
+ status_msg = "Indexing not yet started";
+ status_code = 3;
+ status_label = "warning";
+ } else if (response.status == 100 || response.status == 200) {
+ status_msg = "Indexing in progress";
+ status_code = 3;
+ status_label = "warning";
+ } else if (response.status = 300) {
+ // default message already seat
+ } else if (response.status == 400) {
+ status_code = 4;
+ status_label = "dangerous";
+ status_msg = "The resource could not be indexed";
+ } else {
+ this.logger.log("Unrecognized status")
+ }
+
+ /**
+ * OLD STATUSES - START
+ */
+ if(response.status_code == -1 || response.status_code == 0 || response.status_code == 2){
// this.logger.log('riprova tra 10 secondi...');
- this.updateStatusOfKb(kb._id, response.status_code);
- // timer(10000).subscribe(() => {
+ // this.updateStatusOfKb(kb._id, response.status_code);
+ // timer(20000).subscribe(() => {
// this.checkStatusWithRetry(kb);
// });
- } else { // status == 3 || status == 4
+
+ status_msg = "Indexing in progress: "+response.status_code;
+ status_code = 3;
+ status_label = "warning";
+ } else if(response.status_code == 4 ){ // status == 3 || status == 4
// this.logger.log('Risposta corretta:', response.status_code);
- this.updateStatusOfKb(kb._id, response.status_code);
+ status_code = 4;
+ status_label = "dangerous";
+ status_msg = "The resource could not be indexed "+response.status_code;
+ } else {
+ //status_msg = "Indicizzazione in corso stato: "+response.status_code;
}
+ /**
+ * OLD STATUSES - END
+ */
+
+ this.updateStatusOfKb(kb._id, resource_status);
+ this.notify.showWidgetStyleUpdateNotification(status_msg, status_code, status_label);
},
error => {
this.logger.error('Error: ', error);
- this.updateStatusOfKb(kb._id, -2);
+ //-->this.updateStatusOfKb(kb._id, -2);
+ status_code = 4;
+ status_label = "dangerous";
+ status_msg = "Error: "+error.message;
+ this.notify.showWidgetStyleUpdateNotification(status_msg, status_code, status_label);
});
}
@@ -606,13 +805,21 @@ export class KnowledgeBasesComponent implements OnInit, OnDestroy {
}
private removeKb(kb_id){
+ //this.kbs = this.kbs.filter(item => item._id !== kb_id);
this.kbsList = this.kbsList.filter(item => item._id !== kb_id);
- this.kbs.kbs = this.kbsList;
+ // this.logger.log('AGGIORNO kbsList:', this.kbsList);
this.refreshKbsList = !this.refreshKbsList;
// console.log('AGGIORNO kbsList:', this.kbsList);
}
+ /**
+ * onCheckStatus
+ */
+ onCheckStatus(kb){
+ this.checkStatusWithRetry(kb);
+ }
+
/**
* runIndexing
*/
@@ -624,7 +831,7 @@ export class KnowledgeBasesComponent implements OnInit, OnDestroy {
"content": kb.content?kb.content:'',
"namespace": this.id_project
}
- this.updateStatusOfKb(kb._id, 0);
+ this.updateStatusOfKb(kb._id, 100);
this.openaiService.startScraping(data).subscribe((response: any) => {
this.logger.log("start scraping response: ", response);
if (response.error) {
@@ -731,6 +938,7 @@ export class KnowledgeBasesComponent implements OnInit, OnDestroy {
*
*/
checkAllStatuses() {
+ this.logger.log('[KNOWLEDGE BASES COMP] checkAllStatuses: ', this.kbsList);
this.kbsList.forEach(kb => {
//if(kb.status == -1){
// this.onRunIndexing(kb);
@@ -797,10 +1005,6 @@ export class KnowledgeBasesComponent implements OnInit, OnDestroy {
// this.newKb = { name: '', url: '' }
}
-
-
-
-
closeSecretsModal() {
this.secretsModal = 'none';
}
@@ -809,7 +1013,6 @@ export class KnowledgeBasesComponent implements OnInit, OnDestroy {
this.missingGptkeyModal = 'none';
}
-
closeDeleteKnowledgeBaseModal() {
this.deleteKnowledgeBaseModal = 'none';
this.baseModalDelete = false;
@@ -854,9 +1057,9 @@ export class KnowledgeBasesComponent implements OnInit, OnDestroy {
}
-
// ************** CLOSE ALL MODAL **************** //
onCloseBaseModal(){
+ this.listSitesOfSitemap = [];
this.baseModalDelete = false;
this.baseModalPreview = false;
this.baseModalError = false;
diff --git a/src/app/knowledge-bases/menu/add-content-menu/add-content-menu.component.html b/src/app/knowledge-bases/menu/add-content-menu/add-content-menu.component.html
new file mode 100644
index 000000000000..e27f9f3eac13
--- /dev/null
+++ b/src/app/knowledge-bases/menu/add-content-menu/add-content-menu.component.html
@@ -0,0 +1,38 @@
+
\ No newline at end of file
diff --git a/src/app/knowledge-bases/menu/add-content-menu/add-content-menu.component.scss b/src/app/knowledge-bases/menu/add-content-menu/add-content-menu.component.scss
new file mode 100644
index 000000000000..178301166f45
--- /dev/null
+++ b/src/app/knowledge-bases/menu/add-content-menu/add-content-menu.component.scss
@@ -0,0 +1,120 @@
+// :host {
+// --text-color: #{var(--blu)};
+// --icon-color-menu: #{var(--gray-light-01)};
+// --text-hover-color: #{var(--blu)};
+// --icon-hover-color: #{var(--blu)};
+// --base-padding: 6px;
+// }
+
+// #menu_div{
+// padding: var(--base-padding) 0px;
+// }
+
+// .menu-title{
+// padding: 10px calc(var(--base-padding)*2);
+// font-weight: 500;
+// }
+
+// .menu-box{
+// padding: 0px var(--base-padding);
+// }
+
+// .menu-btns-wpr {
+// width: 100%;
+// height: 30px;
+// border-radius: 6px;
+// display: flex;
+// align-items: center;
+// justify-content: flex-start;
+// gap: 5px;
+// padding: 0px 2px;
+
+// &:hover{
+// cursor: pointer;
+// box-shadow: #1321440a 0 12px 24px, #1321440a 0 8px 12px, #13214405 0 4px 4px, #13214403 0 2px 2px, #13214403 0 1px 1px, #11316008 0 0, #1131600f 0 0 0 1px;
+// span.material-icons-outlined,
+// img{
+// color: var(--text-hover-color);
+// filter: brightness(0) saturate(100%) invert(35%) sepia(48%) saturate(441%) hue-rotate(183deg) brightness(97%) contrast(88%);
+// cursor: pointer;
+// }
+// .menu-btn-text{
+// color: var(--text-hover-color);
+// }
+// }
+
+// }
+
+
+// .truncate {
+// overflow: hidden;
+// white-space: nowrap;
+// text-overflow: ellipsis;
+// width: 100%
+// }
+
+// .menu-btn-icon{
+// display: flex;
+// align-items: center;
+// justify-content: center;
+// span.material-icons-outlined,
+// img{
+// width: 16px;
+// font-size: 16px;
+// color: var(--icon-color-menu);
+// filter: brightness(0) saturate(100%) invert(96%) sepia(0%) saturate(504%) hue-rotate(151deg) brightness(92%) contrast(88%);
+// }
+// }
+// .menu-btn-text{
+// color: var(--text-color);
+// padding: 0px var(--base-padding);
+// vertical-align: middle;
+// font-size: 11px;
+// font-weight: 400;
+// }
+
+// .external-link:hover{
+// text-decoration: underline;
+// }
+
+// .custom-divider {
+// margin-top: 5px;
+// margin-bottom: 5px;
+// border-top: 1px solid var(--blu);
+// }
+
+// .current-user{
+// color: var(--icon-color-menu);
+// }
+
+// ::ng-deep .custom-mat-tooltip-in-settings-sidebar {
+// background-color: #fff !important;
+// color: #555555 !important;
+// font-size: 12px !important;
+// border-radius: 2px !important;
+// font-family: var(--font-family-poppins) !important;
+// padding-top:8px!important;
+// padding-bottom:8px!important;
+// border: 1px solid #e5effe!important;
+// }
+
+.menu-btns-wpr {
+ display: block;
+ padding: 3px 20px;
+ clear: both;
+ font-weight: normal;
+ line-height: 1.42857143;
+ color: #333;
+ white-space: nowrap;
+ cursor: pointer;
+ font-size: 13px;
+ padding: 10px 20px;
+ margin: 0 5px;
+ border-radius: 2px;
+ transition: all 150ms linear;
+ &:hover{
+ background-color: #3ea9f5;
+ color: #FFFFFF;
+ box-shadow: 0 12px 20px -10px rgba(62, 169, 245, 0.28), 0 4px 20px 0px rgba(0, 0, 0, 0.12), 0 7px 8px -5px rgba(62, 169, 245, 0.2);
+ }
+}
\ No newline at end of file
diff --git a/src/app/knowledge-bases/menu/add-content-menu/add-content-menu.component.spec.ts b/src/app/knowledge-bases/menu/add-content-menu/add-content-menu.component.spec.ts
new file mode 100644
index 000000000000..c86b10e0e383
--- /dev/null
+++ b/src/app/knowledge-bases/menu/add-content-menu/add-content-menu.component.spec.ts
@@ -0,0 +1,23 @@
+import { ComponentFixture, TestBed } from '@angular/core/testing';
+
+import { AddContentMenuComponent } from './add-content-menu.component';
+
+describe('AddContentMenuComponent', () => {
+ let component: AddContentMenuComponent;
+ let fixture: ComponentFixture;
+
+ beforeEach(async () => {
+ await TestBed.configureTestingModule({
+ declarations: [ AddContentMenuComponent ]
+ })
+ .compileComponents();
+
+ fixture = TestBed.createComponent(AddContentMenuComponent);
+ component = fixture.componentInstance;
+ fixture.detectChanges();
+ });
+
+ it('should create', () => {
+ expect(component).toBeTruthy();
+ });
+});
diff --git a/src/app/knowledge-bases/menu/add-content-menu/add-content-menu.component.ts b/src/app/knowledge-bases/menu/add-content-menu/add-content-menu.component.ts
new file mode 100644
index 000000000000..a50ceca3a2a8
--- /dev/null
+++ b/src/app/knowledge-bases/menu/add-content-menu/add-content-menu.component.ts
@@ -0,0 +1,56 @@
+import { Component, EventEmitter, Input, OnInit, Output } from '@angular/core';
+import { TranslateService } from '@ngx-translate/core';
+
+@Component({
+ selector: 'add-content-menu',
+ templateUrl: './add-content-menu.component.html',
+ styleUrls: ['./add-content-menu.component.scss']
+})
+export class AddContentMenuComponent implements OnInit {
+ @Output() openAddKnowledgeBaseModal = new EventEmitter();
+
+
+
+ items = [];//[{"label": "Single URL", "type":"url-page"},{"label": "URL(s)", "type":"urls"}, {"label": "Plain Text", "type":"text-file"}];
+ menuTitle: string = "";
+
+ constructor(
+ public translate: TranslateService
+ ) { }
+
+ ngOnInit(): void {
+
+ // this.translate.get('KbPage.AddKbURL')
+ // .subscribe((text: any) => {
+ // let item = {"label": text, "type":"url-page"};
+ // this.items.push(item);
+ // });
+ this.translate.getBrowserLang();
+ this.translate.get('KbPage.AddKbURL')
+ .subscribe((text: any) => {
+ let item = {"label": text, "type":"urls"};
+ this.items.push(item);
+ });
+
+ this.translate.get('KbPage.AddKbText')
+ .subscribe((text: any) => {
+ let item = {"label": text, "type":"text-file"};
+ this.items.push(item);
+ });
+
+ this.translate.get('KbPage.AddKbSitemap')
+ .subscribe((text: any) => {
+ let item = {"label": text, "type":"site-map"};
+ this.items.push(item);
+ });
+
+ //this.items = [{"label": "Single URL", "type":"url-page"},{"label": "URL(s)", "type":"urls"}, {"label": "Plain Text", "type":"text-file"}];
+
+
+ }
+
+ onOpenAddKnowledgeBaseModal(event){
+ // console.log('onOpenAddKnowledgeBaseModal:', event);
+ this.openAddKnowledgeBaseModal.emit(event);
+ }
+}
\ No newline at end of file
diff --git a/src/app/knowledge-bases/modals/knowledge-base-table/knowledge-base-table.component.html b/src/app/knowledge-bases/modals/knowledge-base-table/knowledge-base-table.component.html
index 25abc2eb2201..13b63b90f339 100644
--- a/src/app/knowledge-bases/modals/knowledge-base-table/knowledge-base-table.component.html
+++ b/src/app/knowledge-bases/modals/knowledge-base-table/knowledge-base-table.component.html
@@ -1,36 +1,43 @@
-
-
-
-
+
+
+
-
+
+
+ play_arrow {{'Preview' | translate}}
+
+
+
+
+
+
+
+
+
+
+ {{ 'KbPage.Type' | translate }}
+
+
+ {{ 'KbPage.Status' | translate }}
+
+
+ {{'KbPage.UpdatedAt' | translate }}
+ expand_more
+ expand_less
+
+
+
+ {{'Name' | translate }}
+ expand_more
+ expand_less
+
+
+
+
+
+
+
+
+
+
+ {{'KbPage.NoKbMatchParams' | translate}}
+
+
+
+
+
+
+ description
+ link
+ lan
+
+
+
+
+
+ done
+ done_all
+ cached
+ done_all
+ error
+
+
+
+ {{ kb.createdAt | amTimeAgo }}
+
+
+
+ {{ kb.name }}
+ {{getSubtitle(kb)}}
+
+
+
+
+
+ more_vert
+
+
+
+
+
+
+
+
+
+
+ {{'KbPage.Loading' | translate}}
+ {{'KbPage.LoadMore' | translate}}
+
\ No newline at end of file
diff --git a/src/app/knowledge-bases/modals/knowledge-base-table/knowledge-base-table.component.scss b/src/app/knowledge-bases/modals/knowledge-base-table/knowledge-base-table.component.scss
index cddef8177166..011ce9215d0f 100644
--- a/src/app/knowledge-bases/modals/knowledge-base-table/knowledge-base-table.component.scss
+++ b/src/app/knowledge-bases/modals/knowledge-base-table/knowledge-base-table.component.scss
@@ -1,7 +1,3 @@
-td {
- cursor: pointer;
-}
-
select.select-status {
height: 30px;
background: #fff;
@@ -26,6 +22,27 @@ select.select-status {
}
}
+.preview-count {
+ display: flex;
+ width: calc(100% - 23px);
+ justify-content: space-between;
+ align-items: center;
+ padding: 8px 20px;
+ border-radius: 8px;
+ margin: 10px 16px 10px 10px;
+ box-shadow: 0px 0px 4px #c7c7c7;
+
+ .preview-count-left {
+ display: flex;
+ align-items: baseline;
+ }
+}
+
+.contents-count {
+ color: #8d8d8d;
+ margin-left: 16px;
+}
+
.custom-input {
background-color:#fff;
color:#333333;
@@ -52,6 +69,7 @@ table {
margin: 0;
font-size: 11px;
line-height: 11px;
+ color: #b2b2b2;
}
.mat-elevation-z8{
@@ -103,14 +121,20 @@ th.mat-header-cell:last-of-type, td.mat-cell:last-of-type, td.mat-footer-cell:la
padding-right: 0px;
}
+// .material-icons-outlined {
+// color: #647491;
+// }
.material-icons-outlined {
- color: #647491;
+ color: #adadad;
}
.material-icons-outlined.status-error{
color: #e50b0b;
}
+// .material-icons-outlined.status-done {
+// color: green;
+// }
.material-icons-outlined.status-done {
- color: green;
+ color: #00a8ff;
}
.material-icons-outlined.status-void{
color: gray;
@@ -123,30 +147,169 @@ table {
}
.ellipsis-text {
- max-width: 400px;
- width: 100%;
+ // max-width: calc(100% - 350px);
+ // max-width: 500px;
+ // width: 100%;
white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis;
+ width: 100%;
+ max-width: 100%;
+ display: table-column-group;
+ line-height: normal;
+}
+
+.loading-indicator {
+ text-align: center;
+ margin: 20px auto 10px;
+ display: block;
+ width: fit-content;
+ font-weight: normal;
+ // font-family: monospace;
+ font-size: 12px;
+ line-height: 24px;
+ clip-path: inset(0 1ch 0 0);
+ animation: l4 1s steps(4) infinite;
+}
+
+.loading-indicator::after {
+ content:"..."
+}
+@keyframes l4 {to{clip-path: inset(0 -1ch 0 0)}}
+
+.btn-more {
+ text-align: center;
+ margin: 20px auto 10px;
+ display: block;
+ width: fit-content;
+ font-weight: normal;
+ font-size: 12px;
+ line-height: 24px;
+ cursor: pointer;
+ border-radius: 4px;
+ padding: 2px 12px;
+ min-width: auto;
+}
+
+
+th {
+ display: table-cell;
}
+td {
+ cursor: pointer;
+}
-.orderBy {
+.column-th-span {
+ justify-content: space-between;
+ align-items: center;
+ width: 100%;
cursor: pointer;
+ .th-label {
+ display: inline-block;
+ opacity: 0;
+ transition: opacity 0.5s ease-in-out;
+ }
&:hover {
- .icon-direction{
+ .th-label {
+ display: inline-block;;
opacity: 1;
}
-
}
}
-.icon-direction {
- margin: 0 10px;
- opacity: 0;
+.column-th-span span {
+ display: inline-block;
+ font-size: 14px;
+ font-weight: 500;
+ margin: auto 4px;
+ color: #353f45;
+ vertical-align: middle;
+}
+
+.btn-actions {
+ width: 40px;
position: absolute;
- font-size: 20px;
+ right: 0;
+ margin-top: -5px;
+}
+
+.btn-preview {
+ display: flex;
+ flex-direction: row;
+ justify-content: flex-end;
+ // margin-bottom: -40px;
+}
+
+
+
+.lock-container {
+ width: 100%;
+ background-color: transparent;
+ display: flex;
+ flex-direction: column;
+ justify-content: center;
+ align-items: center;
+ img {
+ width: 300px;
+ height: auto;
+ margin: 50px 0px;
+ }
+ .upgrade-title {
+ font-size: 28px;
+ font-weight: 500;
+ margin-bottom: 20px;
+ display: block;
+ }
+ .upgrade-subtitle {
+ font-size: 16px;
+ margin-bottom: 10px;
+ max-width: 800px;
+ text-align: center;
+ display: block;
+ }
+}
+
+
+.custom-upgrade-primary-button {
+ color: white;
+ min-width: 80px;
+ background: linear-gradient(45deg, #3167e2, #3167e2, #a736ff);
+ border: none;
+ border-radius: 6px;
+ height: 30px;
+ font-weight: 500;
+ padding: 0px 8px;
+ opacity: 0.8;
+}
+
+.no-bot-msg {
+ font-size: 18px;
+ margin-bottom: 0px;
+ color: #353f45;
+ font-weight: 400;
+ // font-family: "Poppins";
+ margin-top: 25px;
+ text-align: center;
+}
+
+.btn-size-m {
+ border-radius: 4px;
+ font-size: 14px;
+ height: 34px;
+ line-height: 18px;
+ min-width: 64px;
+ padding: 0 14px;
+ text-transform: none;
+}
+
+.card {
+ border: none!important;
+ padding: 0px 15px 20px;
}
+.btn {
+ text-transform: none;
+}
\ No newline at end of file
diff --git a/src/app/knowledge-bases/modals/knowledge-base-table/knowledge-base-table.component.ts b/src/app/knowledge-bases/modals/knowledge-base-table/knowledge-base-table.component.ts
index e8e93b2fe1e4..702a1ef5807c 100644
--- a/src/app/knowledge-bases/modals/knowledge-base-table/knowledge-base-table.component.ts
+++ b/src/app/knowledge-bases/modals/knowledge-base-table/knowledge-base-table.component.ts
@@ -1,9 +1,10 @@
-import { Component, Input, OnInit, ViewChild, Output, EventEmitter, SimpleChanges } from '@angular/core';
-import { MatTableDataSource } from '@angular/material/table';
-import { MatSort, Sort } from '@angular/material/sort';
-import { MatPaginator, MatPaginatorIntl } from '@angular/material/paginator';
+import { Component, Input, OnInit, ViewChild, Output, EventEmitter, SimpleChanges, ElementRef, HostListener } from '@angular/core';
+// import { MatTableDataSource } from '@angular/material/table';
+// import { MatSort, Sort } from '@angular/material/sort';
+// import { MatPaginator, MatPaginatorIntl } from '@angular/material/paginator';
import { KB, KbSettings } from 'app/models/kbsettings-model';
-import { LiveAnnouncer } from '@angular/cdk/a11y';
+import {LiveAnnouncer} from '@angular/cdk/a11y';
+import { KB_DEFAULT_PARAMS } from 'app/utils/util';
@Component({
@@ -15,127 +16,147 @@ import { LiveAnnouncer } from '@angular/cdk/a11y';
export class KnowledgeBaseTableComponent implements OnInit {
@Input() refresh: boolean;
- @Input() kbs: any;
- //@Input() kbsList: KB[];
- //@Input() pagConfig: any;
+ @Input() kbsList: KB[];
+ @Input() kbsListCount: number;
@Output() openBaseModalDetail = new EventEmitter();
@Output() openBaseModalDelete = new EventEmitter();
@Output() openBaseModalPreview = new EventEmitter();
+ @Output() openAddKnowledgeBaseModal = new EventEmitter();
+ @Output() checkStatus = new EventEmitter();
@Output() runIndexing = new EventEmitter();
- @Output() reloadKbs = new EventEmitter();
+ @Output() loadPage = new EventEmitter();
+ @Output() loadByFilter = new EventEmitter();
+
- kbsList: KB[] = [];
- kbsListfilterTypeFilter: KB[] = [];
- dataSource: MatTableDataSource
;
- displayedColumns: string[] = ['type', 'status', 'createdAt', 'name', 'actions'];
+ timeoutId: any;
+ // kbsListfilterTypeFilter: KB[] = [];
filterType: string;
- // filterText: string;
- pagConfig: any;
- pageSize: number = 10;
- pageIndex: number = 0;
+ filterText: string;
+ @ViewChild('tableBody') tableBody: ElementRef;
- @ViewChild(MatSort) sort: MatSort;
- @ViewChild(MatPaginator) paginator: MatPaginator;
+ directionDesc: number = KB_DEFAULT_PARAMS.DIRECTION;
+ isLoading: boolean = false;
+ SHOW_MORE_BTN: boolean = true;
+ SHOW_TABLE: boolean = false;
+ searchParams: any;
+ numberPage: number = 0;
+ // kbsListCount: number = 0;
constructor(
- private _liveAnnouncer: LiveAnnouncer,
- public pag: MatPaginatorIntl
+ private _liveAnnouncer: LiveAnnouncer
) { }
ngOnInit(): void {
this.filterType = '';
- // this.filterText = '';
- this.pag.firstPageLabel = 'first page:';
- this.pag.itemsPerPageLabel = 'items per page';
- this.pag.lastPageLabel = 'last page';
- this.pag.nextPageLabel = 'next page';
- this.pag.previousPageLabel = 'previous page';
-
- this.pagConfig = {
- length: 0,
- pageSize: this.pageSize,
- pageIndex: 0,
- status: '',
- search: '',
- direction: -1,
- sortField: 'updatedAt'
+ this.filterText = '';
+ this.searchParams = {
+ "page":0,
+ "sortField": KB_DEFAULT_PARAMS.SORT_FIELD,
+ "direction": KB_DEFAULT_PARAMS.DIRECTION,
+ "status": '',
+ "search": '',
}
+ }
+
+ // @HostListener('window:scroll', ['$event'])
+ // onScroll(event) {
+ // if (this.isScrolledToBottom() && !this.isLoading && this.SHOW_MORE_BTN) {
+ // //this.loadData();
+ // }
+ // }
+
+ // onTableScroll(e) {
+ // console.log('onTableScroll', e);
+ // const tableViewHeight = e.target.offsetHeight // viewport
+ // const tableScrollHeight = e.target.scrollHeight // length of all table
+ // const scrollLocation = e.target.scrollTop; // how far user scrolled
+ // }
+
+
+
+ loadMoreData() {
+ this.isLoading = true;
+ this.numberPage++;
+ this.searchParams.page = this.numberPage;//Math.floor(this.kbsList.length/KB_DEFAULT_PARAMS.LIMIT);
+
+ this.loadPage.emit(this.searchParams);
}
- ngOnChanges(changes: SimpleChanges) {
- if (this.kbs) {
- this.kbsList = this.kbs.kbs;
- this.pagConfig = {
- length: this.kbs.count,
- pageSize: this.pageSize,
- pageIndex: 0,
- status: '',
- search: '',
- direction: -1,
- sortField: 'updatedAt'
- }
+ // isScrolledToBottom(): boolean {
+ // const tableBodyElement = this.tableBody.nativeElement;
+ // return tableBodyElement.scrollTop + tableBodyElement.clientHeight >= tableBodyElement.scrollHeight;
+ // }
+
+ ngOnChanges(changes: SimpleChanges){
+ // console.log('ngOnChanges start ------> ', this.kbsListCount, this.kbsList.length, changes);
+ if(this.kbsList.length>0){
+ this.SHOW_TABLE = true;
+ }
+ if(changes.kbsList?.currentValue?.length === changes.kbsList?.previousValue?.length){
+ // non è cambiato nulla ho solo rodinato la tab
+ } else {
+ // if(changes.kbsListCount && changes.kbsListCount.currentValue){
+ // this.kbsListCount = changes.kbsListCount.currentValue;
+ // } else if(changes.kbsList && changes.kbsList.currentValue){
+ // this.kbsListCount = changes.kbsList.currentValue.length;
+ // }
}
- this.dataSource = new MatTableDataSource(this.kbsList);
- if (this.kbsList) {
- this.dataSource = new MatTableDataSource(this.kbsList);
- // this.dataSource.sort = this.sort;
- // this.dataSource.paginator = this.paginator;
+ // if(this.kbsListCount==0){
+ // this.SHOW_MORE_BTN = false;
+ // }
+ if(this.kbsListCount > this.kbsList.length){
+ this.SHOW_MORE_BTN = true;
+ } else {
+ this.SHOW_MORE_BTN = false;
+ }
+ if(changes.refresh){
+ this.isLoading = false;
}
- if (this.pagConfig && this.kbs) {
- this.pagConfig.length = this.kbs.count;
+ if(this.kbsList?.length == 0){
+ this.SHOW_MORE_BTN = false;
}
- // Math.ceil(this.kbs.count/this.pagConfig.pageSize);
+
+ // console.log('ngOnChanges end -------> ', this.kbsListCount, this.kbsList.length);
}
ngAfterViewInit() {
//console.log('ngAfterViewInit!!!-->', this.kbsList);
- this.kbsList = [];
- if (this.kbs && this.kbs.kbs) {
- this.kbsList = this.kbs.kbs;
- }
- this.dataSource = new MatTableDataSource(this.kbsList);
-
- this.dataSource.sort = this.sort;
- this.sort.active = "updatedAt";
- this.sort.direction = "desc"
+ // this.dataSource = new MatTableDataSource(this.kbsList);
+ // this.dataSource.sort = this.sort;
+ // this.sort.active = "updatedAt";
+ // this.sort.direction = "desc"
+ // this.dataSource.sortData(this.dataSource.data, this.sort);
// this.dataSource.paginator = this.paginator;
- this.dataSource.sortData(this.dataSource.data, this.sort);
- this.dataSource.paginator = this.paginator;
// this.paginator.length = this.dataSource.data.length;
// this.paginator.pageSize = 20;
}
-
- applyFilter(filterValue: string, column: string) {
- //let params = "?limit="+this.pageSize+"&page="+this.pageIndex;
- if (column == 'type') {
- // this.filterType = filterValue;
- this.pagConfig.status = filterValue;
- } else if (column == 'name') {
- // this.filterText= filterValue;
- this.pagConfig.search = filterValue;
+ onOrderBy(type){
+ this.searchParams.sortField = type;
+ this.directionDesc = this.directionDesc*-1;
+ this.searchParams.direction = this.directionDesc;
+ this.isLoading = true;
+ this.loadByFilter.next(this.searchParams);
+ }
+
+ onLoadByFilter(filterValue: string, column: string) {
+ // let status = '';
+ // let search = '';
+ if( column == 'type'){
+ this.searchParams.status = filterValue;
+ } else if(column == 'name'){
+ this.searchParams.search = filterValue;
}
- this.onReloadKbs();
- //console.log('onOptionSelected:: ', filterValue, column, this.filterType, this.filterText);
- // this.dataSource.filterPredicate = (data: KB, filter: string) => {
- // if(this.filterType && this.filterText){
- // return data.name.toLowerCase().includes(this.filterText) && data.status.toString() === this.filterType;
- // }
- // if(this.filterText && this.filterText != ""){
- // return data.name.toLowerCase().includes(this.filterText);
- // }
- // if(this.filterType && this.filterType != ""){
- // return data.status.toString() === this.filterType;
- // }
- // return true;
-
- // }
- // this.dataSource.filter = filterValue;
- // if (this.dataSource.paginator) {
- // this.dataSource.paginator.firstPage();
- // }
+ console.log("this.searchParams ", this.searchParams);
+ if (this.timeoutId) {
+ clearTimeout(this.timeoutId);
+ }
+ this.timeoutId = setTimeout(() => {
+ this.isLoading = true;
+ this.loadByFilter.next(this.searchParams);
+ }, 1000);
}
@@ -148,17 +169,7 @@ export class KnowledgeBaseTableComponent implements OnInit {
// }
// }
- onShortBy(type) {
- if (type == 'createdAt') {
- this.pagConfig.sortField = type;
- } else if (type == 'name') {
- this.pagConfig.sortField = type;
- }
- this.pagConfig.direction = this.pagConfig.direction * -1;
- this.onReloadKbs();
- }
-
- onRunIndexing(kb) {
+ onRunIndexing(kb){
// console.log('onRunIndexing:: ', kb);
this.runIndexing.emit(kb);
}
@@ -191,38 +202,16 @@ export class KnowledgeBaseTableComponent implements OnInit {
return subtitle;
}
-
-
- handlePageChange(event: any) {
- // console.log('Page change event:', event);
- this.pagConfig.pageSize = event.pageSize;
- this.pagConfig.pageIndex = event.pageIndex,
- this.onReloadKbs();
+ onOpenAddKnowledgeBaseModal(type){
+ // console.log('onOpenAddKnowledgeBaseModal', type);
+ this.openAddKnowledgeBaseModal.emit(type);
}
- onReloadKbs() {
- let params = "?limit=" + this.pagConfig.pageSize + "&page=" + this.pagConfig.pageIndex + "&direction=" + this.pagConfig.direction + "&sortField=" + this.pagConfig.sortField + "&status=" + this.pagConfig.status + "&search=" + this.pagConfig.search;
- this.reloadKbs.emit(params);
+ onCheckStatus(kb){
+ // console.log('onCheckStatus:: ', kb);
+ this.checkStatus.emit(kb);
}
- // handlePageSizeChange(event: any) {
- // console.log('Page size change event:', event);n
- // }
- // handlePageSizeOptionsChange(event: any) {
- // console.log('Page size options change event:', event);
- // }
-
- // handleLengthChange(event: any) {
- // console.log('Length change event:', event);
- // }
-
- // handlePageIndexChange(event: any) {
- // console.log('Page index change event:', event);
- // }
-
- // handlePageEvent(event: any) {
- // console.log('Generic page event:', event);
- // }
}
diff --git a/src/app/knowledge-bases/modals/modal-delete-knowledge-base/modal-delete-knowledge-base.component.scss b/src/app/knowledge-bases/modals/modal-delete-knowledge-base/modal-delete-knowledge-base.component.scss
index 4f042fc46091..c6a121d23648 100644
--- a/src/app/knowledge-bases/modals/modal-delete-knowledge-base/modal-delete-knowledge-base.component.scss
+++ b/src/app/knowledge-bases/modals/modal-delete-knowledge-base/modal-delete-knowledge-base.component.scss
@@ -135,8 +135,8 @@
border: 2px solid #c6cdd4;
padding: 0px 15px;
color: #22272d;
- line-height: 35px;
- font-weight: 400;
+ // line-height: 35px;
+ // font-weight: 400;
margin-bottom: 10px;
// letter-spacing: 0.5px;
&.invalid {
@@ -151,8 +151,8 @@
border: 2px solid #c6cdd4;
padding: 0px 15px;
color: #22272d;
- line-height: 35px;
- font-weight: 400;
+ // line-height: 35px;
+ // font-weight: 400;
&.invalid {
border: 2px solid red !important;
outline: 0px solid red !important;
@@ -205,4 +205,8 @@
p {
margin-bottom: 0px;
}
-}
\ No newline at end of file
+}
+
+.btn {
+ text-transform: none;
+}
\ No newline at end of file
diff --git a/src/app/knowledge-bases/modals/modal-detail-knowledge-base/modal-detail-knowledge-base.component.html b/src/app/knowledge-bases/modals/modal-detail-knowledge-base/modal-detail-knowledge-base.component.html
index a0ed96d5d433..cf189efe67f8 100644
--- a/src/app/knowledge-bases/modals/modal-detail-knowledge-base/modal-detail-knowledge-base.component.html
+++ b/src/app/knowledge-bases/modals/modal-detail-knowledge-base/modal-detail-knowledge-base.component.html
@@ -27,16 +27,24 @@
diff --git a/src/app/knowledge-bases/modals/modal-detail-knowledge-base/modal-detail-knowledge-base.component.scss b/src/app/knowledge-bases/modals/modal-detail-knowledge-base/modal-detail-knowledge-base.component.scss
index 4f042fc46091..c08a0bfdf1b8 100644
--- a/src/app/knowledge-bases/modals/modal-detail-knowledge-base/modal-detail-knowledge-base.component.scss
+++ b/src/app/knowledge-bases/modals/modal-detail-knowledge-base/modal-detail-knowledge-base.component.scss
@@ -135,8 +135,8 @@
border: 2px solid #c6cdd4;
padding: 0px 15px;
color: #22272d;
- line-height: 35px;
- font-weight: 400;
+ // line-height: 35px;
+ // font-weight: 400;
margin-bottom: 10px;
// letter-spacing: 0.5px;
&.invalid {
@@ -149,10 +149,10 @@
width: 100%;
border-radius: 6px;
border: 2px solid #c6cdd4;
- padding: 0px 15px;
+ padding: 10px 15px;
color: #22272d;
- line-height: 35px;
- font-weight: 400;
+ // line-height: 35px;
+ // font-weight: 400;
&.invalid {
border: 2px solid red !important;
outline: 0px solid red !important;
@@ -205,4 +205,23 @@
p {
margin-bottom: 0px;
}
-}
\ No newline at end of file
+}
+
+.link-page{
+ font-size: 12px;
+ padding: 0 5px;
+ font-weight: normal;
+
+ vertical-align: middle;
+ display: inline-flex;
+ span {
+ font-size: 14px;
+ margin-top: 0px;
+ display: inline-block;
+ padding-top: 0px;
+ }
+}
+
+.btn {
+ text-transform: none;
+}
\ No newline at end of file
diff --git a/src/app/knowledge-bases/modals/modal-detail-knowledge-base/modal-detail-knowledge-base.component.ts b/src/app/knowledge-bases/modals/modal-detail-knowledge-base/modal-detail-knowledge-base.component.ts
index dd56d0b89526..4c76af8e1965 100644
--- a/src/app/knowledge-bases/modals/modal-detail-knowledge-base/modal-detail-knowledge-base.component.ts
+++ b/src/app/knowledge-bases/modals/modal-detail-knowledge-base/modal-detail-knowledge-base.component.ts
@@ -10,9 +10,17 @@ export class ModalDetailKnowledgeBaseComponent implements OnInit {
@Input() kb: KB;
@Output() closeBaseModal = new EventEmitter();
@Output() updateKnowledgeBase = new EventEmitter();
+
+ name: string;
+ source: string;
+ content: string;
+
constructor() { }
ngOnInit(): void {
+ this.name = this.kb.name;
+ this.source = this.kb.source;
+ this.content = this.kb.content;
}
@@ -29,9 +37,11 @@ export class ModalDetailKnowledgeBaseComponent implements OnInit {
}
onUpdateKnowledgeBase(){
- // console.log('onUpdateKnowledgeBase: ', this.kb);
+ this.kb.name = this.name;
+ this.kb.source = this.source;
+ this.kb.content = this.content;
+ //console.log('onUpdateKnowledgeBase: ', this.kb);
this.updateKnowledgeBase.emit(this.kb);
}
-
}
diff --git a/src/app/knowledge-bases/modals/modal-error/modal-error.component.scss b/src/app/knowledge-bases/modals/modal-error/modal-error.component.scss
index e69de29bb2d1..dd6f8d71db1a 100644
--- a/src/app/knowledge-bases/modals/modal-error/modal-error.component.scss
+++ b/src/app/knowledge-bases/modals/modal-error/modal-error.component.scss
@@ -0,0 +1,3 @@
+.btn {
+ text-transform: none;
+}
\ No newline at end of file
diff --git a/src/app/knowledge-bases/modals/modal-gpt-key/modal-gpt-key.component.scss b/src/app/knowledge-bases/modals/modal-gpt-key/modal-gpt-key.component.scss
index e69de29bb2d1..dd6f8d71db1a 100644
--- a/src/app/knowledge-bases/modals/modal-gpt-key/modal-gpt-key.component.scss
+++ b/src/app/knowledge-bases/modals/modal-gpt-key/modal-gpt-key.component.scss
@@ -0,0 +1,3 @@
+.btn {
+ text-transform: none;
+}
\ No newline at end of file
diff --git a/src/app/knowledge-bases/modals/modal-page-url/modal-page-url.component.html b/src/app/knowledge-bases/modals/modal-page-url/modal-page-url.component.html
index 18f7b1206929..9db1debc694e 100644
--- a/src/app/knowledge-bases/modals/modal-page-url/modal-page-url.component.html
+++ b/src/app/knowledge-bases/modals/modal-page-url/modal-page-url.component.html
@@ -44,7 +44,7 @@
{{ "Cancel" | translate }}
- {{ 'Add' | translate }}
+ {{ 'KbPage.Import' | translate }}
diff --git a/src/app/knowledge-bases/modals/modal-page-url/modal-page-url.component.scss b/src/app/knowledge-bases/modals/modal-page-url/modal-page-url.component.scss
index 4f042fc46091..c6a121d23648 100644
--- a/src/app/knowledge-bases/modals/modal-page-url/modal-page-url.component.scss
+++ b/src/app/knowledge-bases/modals/modal-page-url/modal-page-url.component.scss
@@ -135,8 +135,8 @@
border: 2px solid #c6cdd4;
padding: 0px 15px;
color: #22272d;
- line-height: 35px;
- font-weight: 400;
+ // line-height: 35px;
+ // font-weight: 400;
margin-bottom: 10px;
// letter-spacing: 0.5px;
&.invalid {
@@ -151,8 +151,8 @@
border: 2px solid #c6cdd4;
padding: 0px 15px;
color: #22272d;
- line-height: 35px;
- font-weight: 400;
+ // line-height: 35px;
+ // font-weight: 400;
&.invalid {
border: 2px solid red !important;
outline: 0px solid red !important;
@@ -205,4 +205,8 @@
p {
margin-bottom: 0px;
}
-}
\ No newline at end of file
+}
+
+.btn {
+ text-transform: none;
+}
\ No newline at end of file
diff --git a/src/app/knowledge-bases/modals/modal-preview-knowledge-base/modal-preview-knowledge-base.component.html b/src/app/knowledge-bases/modals/modal-preview-knowledge-base/modal-preview-knowledge-base.component.html
index 2697aff81251..2b46a7ea5d2b 100644
--- a/src/app/knowledge-bases/modals/modal-preview-knowledge-base/modal-preview-knowledge-base.component.html
+++ b/src/app/knowledge-bases/modals/modal-preview-knowledge-base/modal-preview-knowledge-base.component.html
@@ -81,7 +81,7 @@
{{ "Cancel" | translate }}
diff --git a/src/app/knowledge-bases/modals/modal-preview-knowledge-base/modal-preview-knowledge-base.component.scss b/src/app/knowledge-bases/modals/modal-preview-knowledge-base/modal-preview-knowledge-base.component.scss
index 4f042fc46091..7267bf43339e 100644
--- a/src/app/knowledge-bases/modals/modal-preview-knowledge-base/modal-preview-knowledge-base.component.scss
+++ b/src/app/knowledge-bases/modals/modal-preview-knowledge-base/modal-preview-knowledge-base.component.scss
@@ -205,4 +205,8 @@
p {
margin-bottom: 0px;
}
-}
\ No newline at end of file
+}
+
+.btn {
+ text-transform: none;
+}
\ No newline at end of file
diff --git a/src/app/knowledge-bases/modals/modal-site-map/modal-site-map.component.html b/src/app/knowledge-bases/modals/modal-site-map/modal-site-map.component.html
index 14ec332e2ebe..86f8335bf58f 100644
--- a/src/app/knowledge-bases/modals/modal-site-map/modal-site-map.component.html
+++ b/src/app/knowledge-bases/modals/modal-site-map/modal-site-map.component.html
@@ -1,38 +1,98 @@
+