diff --git a/CHANGELOG.md b/CHANGELOG.md index 3d294126ae78..9959715aefcd 100755 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,13 @@ # tiledesk-dashboard + +### 2.6.0 +- Deploys in production +- Improves Knowledge Bases +- Adds the ability to create Knowledge Bases by adding a sitemap +- Adds the customer.io integration +- Fixes the bug: app cards are not all the same height + ### 2.5.21 - Deploys in production - Adds the ability to sort chatbot by name diff --git a/package-lock.json b/package-lock.json index 060df5df8285..21eec17cbc81 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,6 +1,6 @@ { "name": "@tiledesk/tiledesk-dashboard", - "version": "2.5.21", + "version": "2.6.0", "lockfileVersion": 1, "requires": true, "dependencies": { diff --git a/package.json b/package.json index 2af2719027ef..f398a84cd5bf 100755 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@tiledesk/tiledesk-dashboard", - "version": "2.5.21", + "version": "2.6.0", "scripts": { "ng": "ng", "start": "ng serve --aot", diff --git a/src/app/app-store/app-store.component.html b/src/app/app-store/app-store.component.html index f2533823b3ce..d1ce91e2f514 100644 --- a/src/app/app-store/app-store.component.html +++ b/src/app/app-store/app-store.component.html @@ -520,7 +520,7 @@

-

+
External
diff --git a/src/app/app.module.ts b/src/app/app.module.ts index a0e5531043f2..e73f224a7323 100755 --- a/src/app/app.module.ts +++ b/src/app/app.module.ts @@ -393,6 +393,8 @@ import { ModalDetailKnowledgeBaseComponent } from './knowledge-bases/modals/moda import { KnowledgeBaseTableComponent } from './knowledge-bases/modals/knowledge-base-table/knowledge-base-table.component'; import { ModalErrorComponent } from './knowledge-bases/modals/modal-error/modal-error.component'; import { KnowledgeBasesPreviousComponent } from './knowledge-bases-previous/knowledge-bases-previous.component'; +import { ModalUrlsKnowledgeBaseComponent } from './knowledge-bases/modals/modal-urls-knowledge-base/modal-urls-knowledge-base.component'; +import { AddContentMenuComponent } from './knowledge-bases/menu/add-content-menu/add-content-menu.component'; import { UserModalComponent } from './users/user-modal/user-modal.component'; import { MessagesStatsModalComponent } from './components/modals/messages-stats-modal/messages-stats-modal.component'; @@ -700,6 +702,8 @@ const appInitializerFn = (appConfig: AppConfigService, brandService: BrandServic KnowledgeBaseTableComponent, ModalErrorComponent, KnowledgeBasesPreviousComponent, + ModalUrlsKnowledgeBaseComponent, + AddContentMenuComponent, UserModalComponent, MessagesStatsModalComponent ], diff --git a/src/app/bots/bots-list/bots-list.component.ts b/src/app/bots/bots-list/bots-list.component.ts index d49f1966d7d3..8705e8d8b39b 100755 --- a/src/app/bots/bots-list/bots-list.component.ts +++ b/src/app/bots/bots-list/bots-list.component.ts @@ -607,6 +607,19 @@ export class BotListComponent extends PricingBaseComponent implements OnInit, On }); } + if (this.orderByChatbotName) { + this.logger.log('[BOTS-LIST] - orderByChatbotName Here yes'); + this.faqkbList.sort(function compare(a: Chatbot, b: Chatbot) { + if (a['name'].toLowerCase() < b['name'].toLowerCase()) { + return -1; + } + if (a['name'].toLowerCase() > b['name'].toLowerCase()) { + return 1; + } + return 0; + }); + } + this.faqkbList.forEach(bot => { this.logger.log('[BOTS-LIST] getFaqKbByProjectId bot ', bot) if (bot && bot.url) { diff --git a/src/app/chatbot-design-studio/utils.ts b/src/app/chatbot-design-studio/utils.ts index 6df1db856a69..5f61285e0704 100644 --- a/src/app/chatbot-design-studio/utils.ts +++ b/src/app/chatbot-design-studio/utils.ts @@ -315,6 +315,7 @@ export function patchActionId(action) { return action; } + // export function retriveListOfVariables(intents: Array) { // variableList.userDefined = [] // intents.forEach(intent => { diff --git a/src/app/core/notify.service.ts b/src/app/core/notify.service.ts index 879f96e5f2a2..62e25426b854 100755 --- a/src/app/core/notify.service.ts +++ b/src/app/core/notify.service.ts @@ -513,6 +513,8 @@ export class NotifyService { icon_bckgrnd_color = '#d2291c' } else if (notificationColor === 2) { icon_bckgrnd_color = '#449d48' + } else if(notificationColor === 3){ + icon_bckgrnd_color = '#ffecb5' } this.notify = $.notify({ // icon: 'glyphicon glyphicon-warning-sign', diff --git a/src/app/integrations/list/brevo-integration/brevo-integration.component.ts b/src/app/integrations/list/brevo-integration/brevo-integration.component.ts index 7108cae8481e..ebd2641986f9 100644 --- a/src/app/integrations/list/brevo-integration/brevo-integration.component.ts +++ b/src/app/integrations/list/brevo-integration/brevo-integration.component.ts @@ -41,13 +41,13 @@ export class BrevoIntegrationComponent implements OnInit { } saveIntegration() { - this.checkKey(this.integration.value.apikey).then((status) => { - let data = { - integration: this.integration, - isVerified: status - } - this.onUpdateIntegration.emit(data); - }) + // this.checkKey(this.integration.value.apikey).then((status) => { + // let data = { + // integration: this.integration, + // isVerified: status + // } + // this.onUpdateIntegration.emit(data); + // }) } deleteIntegration() { @@ -56,21 +56,6 @@ export class BrevoIntegrationComponent 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); - } else { - this.isVerified = false; - resolve(false); - } - }, (error) => { - this.logger.error("[INT-Qapla] Key verification failed: ", error); - this.isVerified = false; - resolve(false); - }) - }) } resetValues() { diff --git a/src/app/integrations/list/customerio-integration/customerio-integration.component.html b/src/app/integrations/list/customerio-integration/customerio-integration.component.html index 3dfac51cfe54..53614ed5d9fb 100644 --- a/src/app/integrations/list/customerio-integration/customerio-integration.component.html +++ b/src/app/integrations/list/customerio-integration/customerio-integration.component.html @@ -1,7 +1,11 @@
-

Start for free with Customer.io. Sign up now!

+ - +
@@ -36,7 +40,7 @@
+ [(ngModel)]="integration.value.key">
visibility diff --git a/src/app/integrations/list/customerio-integration/customerio-integration.component.scss b/src/app/integrations/list/customerio-integration/customerio-integration.component.scss index 47308f735c85..2d4bec11b8d7 100644 --- a/src/app/integrations/list/customerio-integration/customerio-integration.component.scss +++ b/src/app/integrations/list/customerio-integration/customerio-integration.component.scss @@ -10,7 +10,16 @@ p { flex-direction: row; align-items: center; justify-content: space-between; + height: 50px; + + .signup { + display: flex; + p { + margin: 0 0 0 5px; + } + } + .status { display: flex; align-items: center; diff --git a/src/app/integrations/list/customerio-integration/customerio-integration.component.ts b/src/app/integrations/list/customerio-integration/customerio-integration.component.ts index acc9da0fc0e4..f77c2e790838 100644 --- a/src/app/integrations/list/customerio-integration/customerio-integration.component.ts +++ b/src/app/integrations/list/customerio-integration/customerio-integration.component.ts @@ -16,16 +16,18 @@ export class CustomerioIntegrationComponent implements OnInit { keyVisibile: boolean = false; isVerified: boolean; + translateparams: any; + constructor( private integrationService: IntegrationService, private logger: LoggerService ) { } ngOnInit(): void { - this.logger.log("[INT-Customer.io] integration ", this.integration) this.logger.debug("[INT-Customer.io] integration ", this.integration) + this.translateparams = { intname: "Customer.io" }; if (this.integration.value.apikey) { - this.checkKey(this.integration.value.apikey); + this.checkKey(); } } @@ -41,7 +43,9 @@ export class CustomerioIntegrationComponent implements OnInit { } saveIntegration() { - this.checkKey(this.integration.value.apikey).then((status) => { + let apikey = btoa(this.integration.value.siteid + ":" + this.integration.value.key); + this.integration.value.apikey = apikey; + this.checkKey().then((status) => { let data = { integration: this.integration, isVerified: status @@ -55,16 +59,13 @@ export class CustomerioIntegrationComponent implements OnInit { this.onDeleteIntegration.emit(this.integration); } - 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); - } else { - this.isVerified = false; - resolve(false); - } + checkKey() { + return new Promise((resolve) => { + let url = "https://track.customer.io/api/v1/accounts/region"; + let apikey = 'Basic ' + this.integration.value.apikey; + this.integrationService.checkIntegrationKeyValidity(url, apikey).subscribe((resp: any) => { + this.isVerified = true; + resolve(true); }, (error) => { this.logger.error("[INT-Customer.io] Key verification failed: ", error); this.isVerified = false; @@ -75,8 +76,9 @@ export class CustomerioIntegrationComponent implements OnInit { resetValues() { this.integration.value = { - apikey: null, - siteid: null + siteid: null, + key: null, + apikey: null } } diff --git a/src/app/integrations/list/hubspot-integration/hubspot-integration.component.html b/src/app/integrations/list/hubspot-integration/hubspot-integration.component.html index 489947e62447..feab5e11230f 100644 --- a/src/app/integrations/list/hubspot-integration/hubspot-integration.component.html +++ b/src/app/integrations/list/hubspot-integration/hubspot-integration.component.html @@ -3,8 +3,7 @@ {{ 'Integration.Signup' | translate }}

- - +
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 @@
- +
- - - - + +
@@ -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..7fbc028ecac3 100644 --- a/src/app/knowledge-bases/knowledge-bases.component.scss +++ b/src/app/knowledge-bases/knowledge-bases.component.scss @@ -439,11 +439,40 @@ 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; +} + + +// .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; +} + +.title-class { + color: black; + font-weight: 500; } \ 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..2520b72b435c 100644 --- a/src/app/knowledge-bases/knowledge-bases.component.ts +++ b/src/app/knowledge-bases/knowledge-bases.component.ts @@ -1,6 +1,6 @@ import { Component, OnDestroy, OnInit, isDevMode } from '@angular/core'; import { FormBuilder, FormGroup, Validators } from '@angular/forms'; -import { ActivatedRoute } from '@angular/router'; +import { ActivatedRoute, Router } from '@angular/router'; import { AuthService } from 'app/core/auth.service'; import { NotifyService } from 'app/core/notify.service'; import { KB, KbSettings } from 'app/models/kbsettings-model'; @@ -14,6 +14,10 @@ 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 { AppConfigService } from 'app/services/app-config.service'; +const swal = require('sweetalert'); + //import { Router } from '@angular/router'; @Component({ @@ -44,6 +48,7 @@ export class KnowledgeBasesComponent implements OnInit, OnDestroy { //analytics + // SHOW_TABLE: boolean = false; CURRENT_USER: any; project: Project; project_name: string; @@ -55,18 +60,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 @@ -79,7 +79,8 @@ export class KnowledgeBasesComponent implements OnInit, OnDestroy { msgErrorIndexingKb: string; // = 'Indicizzazione non riuscita'; msgSuccesIndexingKb: string; // = 'Indicizzazione terminata con successo'; msgErrorAddUpdateKb: string; // = 'Non è stato possibile aggiungere o modificare il kb'; - + msgErrorAddUpdateKbLimit: string // = "Non è possibile superare il numero di risorse previste nel piano corrente"; + warningTitle: string; allTemplatesCount: number; allCommunityTemplatesCount: number; @@ -88,6 +89,9 @@ export class KnowledgeBasesComponent implements OnInit, OnDestroy { customerSatisfactionBotsCount: number; myChatbotOtherCount: number; increaseSalesBotsCount: number; + listSitesOfSitemap: any = []; + + payIsVisible: boolean = false; private unsubscribe$: Subject = new Subject(); constructor( @@ -97,19 +101,22 @@ export class KnowledgeBasesComponent implements OnInit, OnDestroy { private openaiService: OpenaiService, private kbService: KnowledgeBaseService, private projectService: ProjectService, + private router: Router, public route: ActivatedRoute, //private router: Router, private notify: NotifyService, private translate: TranslateService, private faqKbService: FaqKbService, + public appConfigService: AppConfigService, ) { } 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(); @@ -120,6 +127,7 @@ export class KnowledgeBasesComponent implements OnInit, OnDestroy { this.getTemplates(); this.getCommunityTemplates() this.getFaqKbByProjectId(); + this.getOSCODE(); } @@ -272,6 +280,27 @@ export class KnowledgeBasesComponent implements OnInit, OnDestroy { } + getOSCODE() { + + let public_Key = this.appConfigService.getConfig().t2y12PruGU9wUtEGzBJfolMIgK; + + let keys = public_Key.split("-"); + + keys.forEach(key => { + if (key.includes("PAY")) { + let pay = key.split(":"); + // this.logger.log('PUBLIC-KEY (Navbar) - pay key&value', pay); + if (pay[1] === "F") { + this.payIsVisible = false; + console.log("payIsVisible: ", this.payIsVisible) + } else { + this.payIsVisible = true; + console.log("payIsVisible: ", this.payIsVisible) + } + } + }) + } + // loadKbSettings(){ @@ -299,6 +328,18 @@ export class KnowledgeBasesComponent implements OnInit, OnDestroy { this.msgSuccesIndexingKb = KbPage['msgSuccesIndexingKb']; this.msgErrorAddUpdateKb = KbPage['msgErrorAddUpdateKb']; }); + + this.translate.get('Warning') + .subscribe((text: string) => { + // this.deleteContact_msg = text; + // this.logger.log('+ + + BotsPage translation: ', text) + this.warningTitle = text; + }); + } + + getTranslatedStringKbLimitReached(max_num) { + this.translate.get('KbPage.msgErrorAddUpdateKbLimit', { max_number: max_num }) + .subscribe((text: string) => { this.msgErrorAddUpdateKbLimit = text; }); } @@ -393,17 +434,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 +539,44 @@ 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); + console.log("onSendSitemap:", resp); + if (resp.errors && resp.errors[0]) { + swal({ + title: this.warningTitle, + text: error, + icon: "warning", + className: "custom-swal", + buttons: [null, "Cancel"], + dangerMode: false + }) + } else { + this.listSitesOfSitemap = resp.sites; + } + + }, (err) => { + this.logger.error("[KNOWLEDGE-BASES-COMP] ERROR send sitemap: ", err); + + //this.onOpenErrorModal(error); + + swal({ + title: this.warningTitle, + text: error, + icon: "warning", + className: "custom-swal", + buttons: [null, "Cancel"], + dangerMode: false + }) + + }, () => { + this.logger.log("[KNOWLEDGE-BASES-COMP] send sitemap *COMPLETED*"); + }) + } + /** * onAddKb */ @@ -437,21 +585,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); @@ -459,13 +619,110 @@ export class KnowledgeBasesComponent implements OnInit, OnDestroy { //that.onCloseBaseModal(); }, (err) => { this.logger.error("[KNOWLEDGE-BASES-COMP] ERROR add new kb: ", err); - this.onOpenErrorModal(error); + // this.onOpenErrorModal(error); + if (err.error && err.error.plan_limit) { + this.getTranslatedStringKbLimitReached(err.error.plan_limit); + error = this.msgErrorAddUpdateKbLimit + } + + if (this.payIsVisible === true) { + swal({ + title: this.warningTitle, + text: error, + icon: "warning", + className: "custom-swal", + buttons: ["Cancel", "Upgrade Plan"], + dangerMode: false + }).then((willUpgradePlan: any) => { + + if (willUpgradePlan) { + this.router.navigate(['project/' + this.id_project + '/pricing']); + } + }) + } else { + swal({ + title: this.warningTitle, + text: error, + icon: "warning", + className: "custom-swal", + buttons: [null, "Cancel"], + dangerMode: false + }) + } + }, () => { this.logger.log("[KNOWLEDGE-BASES-COMP] add new kb *COMPLETED*"); //this.trackUserActioOnKB('Added Knowledge Base', gptkey) }) } + + + 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); + if (err.error && err.error.plan_limit) { + this.getTranslatedStringKbLimitReached(err.error.plan_limit); + error = this.msgErrorAddUpdateKbLimit + } + + if (this.payIsVisible === true) { + swal({ + title: this.warningTitle, + text: error, + icon: "warning", + className: "custom-swal", + buttons: ["Cancel", "Upgrade Plan"], + dangerMode: false + }).then((willUpgradePlan: any) => { + + if (willUpgradePlan) { + this.router.navigate(['project/' + this.id_project + '/pricing']); + } + }) + } else { + swal({ + title: this.warningTitle, + text: error, + icon: "warning", + className: "custom-swal", + buttons: [null, "Cancel"], + dangerMode: false + }) + } + + + + }, () => { + this.logger.log("[KNOWLEDGE-BASES-COMP] add new kb *COMPLETED*"); + //this.trackUserActioOnKB('Added Knowledge Base', gptkey) + }) + } + + /** * onDeleteKb */ @@ -481,19 +738,49 @@ 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.onOpenErrorModal(error); + // this.updateStatusOfKb(kb._id, 0); + + // this.onOpenErrorModal(error); + swal({ + title: this.warningTitle, + text: error, + icon: "warning", + className: "custom-swal", + buttons: [null, "Cancel"], + dangerMode: false + }) + + } 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); kb.deleting = false; //this.kbid_selected.deleting = false; - this.onOpenErrorModal(error); + + // this.onOpenErrorModal(error); + swal({ + title: this.warningTitle, + text: error, + icon: "warning", + className: "custom-swal", + buttons: [null, "Cancel"], + dangerMode: false + }) + }, () => { this.logger.log("[KNOWLEDGE-BASES-COMP] delete kb *COMPLETE*"); //this.trackUserActioOnKB('Deleted Knowledge Base', gptkey) @@ -501,8 +788,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 +799,7 @@ export class KnowledgeBasesComponent implements OnInit, OnDestroy { } let dataAdd = { 'name': kb.name, - 'source': kb.url, + 'source': kb.source, 'content': '', 'type': 'url' }; @@ -520,35 +808,60 @@ 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.onOpenErrorModal(error); + swal({ + title: this.warningTitle, + text: error, + icon: "warning", + className: "custom-swal", + buttons: [null, "Cancel"], + dangerMode: false + }) + + } 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); - this.onOpenErrorModal(error); + + //this.onOpenErrorModal(error); + swal({ + title: this.warningTitle, + text: error, + icon: "warning", + className: "custom-swal", + buttons: [null, "Cancel"], + dangerMode: false + }) + }, () => { this.logger.log("[KNOWLEDGE BASES COMP] add new kb *COMPLETED*"); }) @@ -556,7 +869,17 @@ export class KnowledgeBasesComponent implements OnInit, OnDestroy { }, (err) => { this.logger.error("[KNOWLEDGE BASES COMP] ERROR delete kb: ", err); kb.deleting = false; - this.onOpenErrorModal(error); + + // this.onOpenErrorModal(error); + swal({ + title: this.warningTitle, + text: error, + icon: "warning", + className: "custom-swal", + buttons: [null, "Cancel"], + dangerMode: false + }) + }, () => { this.logger.log("[KNOWLEDGE BASES COMP] delete kb *COMPLETE*"); kb.deleting = false; @@ -573,26 +896,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 +982,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 +1008,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 +1115,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 +1182,6 @@ export class KnowledgeBasesComponent implements OnInit, OnDestroy { // this.newKb = { name: '', url: '' } } - - - - closeSecretsModal() { this.secretsModal = 'none'; } @@ -809,7 +1190,6 @@ export class KnowledgeBasesComponent implements OnInit, OnDestroy { this.missingGptkeyModal = 'none'; } - closeDeleteKnowledgeBaseModal() { this.deleteKnowledgeBaseModal = 'none'; this.baseModalDelete = false; @@ -854,9 +1234,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 @@ -
- - - +
+ +
-
+ +
+ +
- +
@@ -40,109 +47,150 @@
+ (ngModelChange)="onLoadByFilter($event, 'type')"> {{ 'KbPage.StatusAll' | translate }} - {{ 'KbPage.StatusNotStarted' | translate }} + + + + {{ 'KbPage.StatusNotStarted' | translate }} + {{ 'KbPage.StatusQueued' | translate }} + {{ 'KbPage.StatusStarted' | translate }} + {{ 'KbPage.StatusFinished' | translate }} + {{ 'KbPage.StatusError' | translate }}
-
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
{{ 'KbPage.Type' | translate }} - description - link - lan - {{ 'KbPage.Status' | translate }} - - - schedule - cached - check - error - {{'KbPage.CreatedAt' | translate }}expand_moreexpand_less{{ kb.createdAt | amTimeAgo }}{{'Name' | translate }}expand_moreexpand_less
{{ kb.name }}
-
{{getSubtitle(kb)}}
-
- - - - - -
- - - - -
-
- - - - - +
{{ kbsListCount }} total resources
+
+
+ +
+
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ {{ '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)}}
+
+
+ + + + + + + +
+
+ +
+
{{'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-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 @@
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 @@ +