Skip to content

Commit

Permalink
Improves the kb page
Browse files Browse the repository at this point in the history
  • Loading branch information
Nicola Lanzilotto committed Jul 2, 2024
1 parent 94ab471 commit 6187677
Show file tree
Hide file tree
Showing 32 changed files with 807 additions and 139 deletions.
2 changes: 1 addition & 1 deletion src/app/bots/bot-create/bot-create.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -334,7 +334,7 @@ export class BotCreateComponent extends PricingBaseComponent implements OnInit {
// this.router.navigate(['project/' + this.project._id + '/tilebot/intents/', this.importedChatbotid, 'tilebot']);
// this.router.navigate(['project/' + this.project._id + '/cds/', this.importedChatbotid, 'intent', '0'])

// goToCDSVersion(this.router, faqkb, this.project._id, this.appConfigService.getConfig().cdsBaseUrl)
goToCDSVersion(this.router, faqkb, this.project._id, this.appConfigService.getConfig().cdsBaseUrl)
}

}, (error) => {
Expand Down
3 changes: 2 additions & 1 deletion src/app/components/sidebar/sidebar.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,8 @@
TMPLT_CMNT_ROUTE_IS_ACTIVE ||
TMPLT_IS_ROUTE_IS_ACTIVE ||
TMPLT_CS_ROUTE_IS_ACTIVE ||
KB_ROUTE_IS_ACTIVE} ">
KB_ROUTE_IS_ACTIVE ||
CREATE_BOT_ROUTE_IS_ACTIVE} ">
<a id="bot-anchor" #botbtn class="customAncor" (click)="goToAllMyChatbot()"
style="height: 40px;">
<span class="bot-icon-wpr">
Expand Down
23 changes: 18 additions & 5 deletions src/app/components/sidebar/sidebar.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -207,6 +207,7 @@ export class SidebarComponent implements OnInit, AfterViewInit {
TMPLT_CS_ROUTE_IS_ACTIVE: boolean;
OLD_KB_ROUTE_IS_ACTIVE: boolean;
KB_ROUTE_IS_ACTIVE: boolean;
CREATE_BOT_ROUTE_IS_ACTIVE: boolean;



Expand Down Expand Up @@ -1163,22 +1164,34 @@ export class SidebarComponent implements OnInit, AfterViewInit {
// if (event.url.indexOf('/knowledge-bases-pre') ) {
if (event.url.substring(event.url.lastIndexOf('/') + 1) === 'knowledge-bases-pre') {
this.OLD_KB_ROUTE_IS_ACTIVE = true;
this.logger.log('[SIDEBAR] NavigationEnd - OLD_KB_ROUTE_IS_ACTIVE ', this.OLD_KB_ROUTE_IS_ACTIVE);
console.log('[SIDEBAR] NavigationEnd - OLD_KB_ROUTE_IS_ACTIVE ', this.OLD_KB_ROUTE_IS_ACTIVE);
} else {
this.OLD_KB_ROUTE_IS_ACTIVE = false;
this.logger.log('[SIDEBAR] NavigationEnd - OLD_KB_ROUTE_IS_ACTIVE ', this.OLD_KB_ROUTE_IS_ACTIVE);
console.log('[SIDEBAR] NavigationEnd - OLD_KB_ROUTE_IS_ACTIVE ', this.OLD_KB_ROUTE_IS_ACTIVE);
}


// if (event.url.match('/knowledge-bases')) {
if (event.url.substring(event.url.lastIndexOf('/') + 1) === 'knowledge-bases') {
// if (event.url.substring(event.url.lastIndexOf('/') + 1) === 'knowledge-bases') {
if (event.url.indexOf('/knowledge-bases') !== -1) {
this.KB_ROUTE_IS_ACTIVE = true;
this.logger.log('[SIDEBAR] NavigationEnd - KB_ROUTE_IS_ACTIVE ', this.KB_ROUTE_IS_ACTIVE);
console.log('[SIDEBAR] NavigationEnd - KB_ROUTE_IS_ACTIVE ', this.KB_ROUTE_IS_ACTIVE);
} else {
this.KB_ROUTE_IS_ACTIVE = false;
this.logger.log('[SIDEBAR] NavigationEnd - KB_ROUTE_IS_ACTIVE ', this.KB_ROUTE_IS_ACTIVE);
console.log('[SIDEBAR] NavigationEnd - KB_ROUTE_IS_ACTIVE ', this.KB_ROUTE_IS_ACTIVE);
}

if (event.url.indexOf('/bots/create/tilebot/blank') !== -1) {
this.CREATE_BOT_ROUTE_IS_ACTIVE = true;
console.log('[SIDEBAR] NavigationEnd - CREATE_BOT_ROUTE_IS_ACTIVE ', this.CREATE_BOT_ROUTE_IS_ACTIVE);
} else {
this.CREATE_BOT_ROUTE_IS_ACTIVE = false;
console.log('[SIDEBAR] NavigationEnd - CREATE_BOT_ROUTE_IS_ACTIVE ', this.CREATE_BOT_ROUTE_IS_ACTIVE);
}






}
Expand Down
20 changes: 15 additions & 5 deletions src/app/knowledge-bases/knowledge-bases.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -51,10 +51,10 @@
</appdashboard-bots-sidebar>


<div class="template-content">
<div class="kb-content">
<!-- <appdashboard-knowledge-bases-alert [kbsListCount]="kbsListCount" *ngIf="kbsListCount && kbsListCount > kbLimit"> </appdashboard-knowledge-bases-alert> -->

<div class="template-content-container">
<div class="kb-content-container">
<loading-spinner *ngIf="showSpinner"></loading-spinner>

<div class="card-content" *ngIf="!showSpinner">
Expand Down Expand Up @@ -88,7 +88,12 @@
</button> -->

<!-- ----------- MAT-MENU ----------- -->
<button mat-icon-button [matMenuTriggerFor]="namespaceList" aria-label="namespaceList">
<button mat-icon-button [matMenuTriggerFor]="namespaceList" aria-label="namespaceList"
matTooltipClass="kb-custom-mat-tooltip"
matTooltip="{{ 'KbPage.AddNewKbOrSelectExistingOne' | translate }}"
#tooltip="matTooltip"
matTooltipPosition='below'
matTooltipHideDelay="100">
<mat-icon>unfold_more</mat-icon>
</button>

Expand Down Expand Up @@ -135,7 +140,12 @@
</button>

<button class="custom-button preview" aria-label="Preview"
(click)="$event.stopPropagation(); onOpenBaseModalPreview()">
(click)="$event.stopPropagation(); onOpenBaseModalPreview()" [disabled]="kbsListCount === 0" [ngClass]="{'preview-btn-disabled': kbsListCount === 0}"
matTooltipClass="kb-custom-mat-tooltip"
[matTooltip]="kbsListCount === 0 ? ( 'KbPage.AddContentsToUseTheKBPreview' | translate ) : ( 'KbPage.KBpreview' | translate ) "
#tooltip="matTooltip"
matTooltipPosition='below'
matTooltipHideDelay="100">
<span class="material-icons-round">play_arrow</span>
<span class=""> {{'Preview' | translate}} </span>
</button>
Expand All @@ -144,7 +154,7 @@
<!-- width: 150px; -->
<button class="custom-button add-content" [disabled]="addButtonDisabled" [matMenuTriggerFor]="menu"
aria-label="Actions">
<span class="material-icons-round">add</span>
<!-- <span class="material-icons-round">add</span> -->
<span class=""> {{ 'KbPage.Add' | translate }} </span>
</button>
<mat-menu #menu="matMenu" xPosition="before" class="custom-menu" style="width: 150px;">
Expand Down
28 changes: 21 additions & 7 deletions src/app/knowledge-bases/knowledge-bases.component.scss
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
// margin: 0 60px;
}

.template-content {
.kb-content {
flex: 1 1 auto;
margin: 0 20px;
display: flex;
Expand Down Expand Up @@ -46,14 +46,21 @@
}

.custom-button.xs {
background: var(--blue-light);
// background: var(--blue-light);
// height: 24px;
// font-size: 12px;
// padding: 1px 8px;
color: var(--blue-light);
height: 24px;
font-size: 12px;
padding: 1px 8px;
font-size: 14px;
background: transparent;
position: relative;
top: 1px;
left: -5px;

&:hover {
// background: #256ffd;
opacity: .8;
// opacity: .8;
text-decoration: underline;
}
}

Expand Down Expand Up @@ -100,6 +107,8 @@
}
}



.custom-button.preview {
background-color: #38414a;
padding: 0 12px;
Expand All @@ -113,7 +122,12 @@
}
}

.template-content-container {
.custom-button.preview-btn-disabled {
cursor: not-allowed;
// opacity: .8;
}

.kb-content-container {
width: 80%;
max-width: 1600px;
min-width: 900px;
Expand Down
21 changes: 12 additions & 9 deletions src/app/knowledge-bases/knowledge-bases.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -922,10 +922,6 @@ export class KnowledgeBasesComponent extends PricingBaseComponent implements OnI
// ------------------------------------------------------------------------
// @ Modals Windows
// ------------------------------------------------------------------------




presentModalAddNewNamespace() {
this.logger.log('[KNOWLEDGE-BASES-COMP] - presentModalAddNewNamespace ');

Expand All @@ -952,14 +948,19 @@ export class KnowledgeBasesComponent extends PricingBaseComponent implements OnI
const dialogRef = this.dialog.open(ModalPreviewKnowledgeBaseComponent, {
backdropClass: 'cdk-overlay-transparent-backdrop',
hasBackdrop: true,
width: '600px',
width: '400px',
id: 'kb-test',
data: {
selectedNaspace: this.selectedNamespace,
selectedNamespace: this.selectedNamespace,
askBody: previedata
},
});
dialogRef.afterClosed().subscribe(result => {
this.logger.log('[ModalPreview] Dialog AFTER CLOSED result : ', result);
console.log('[ModalPreview] Dialog AFTER CLOSED result : ', result);
if (result === undefined) {
this.kbService.modalPreviewKbHasBeenClosed()
}

if (result) {
if (result.action === 'open-settings-modal' && result.data) {
this.onOpenBaseModalPreviewSettings(result.data)
Expand All @@ -978,7 +979,7 @@ export class KnowledgeBasesComponent extends PricingBaseComponent implements OnI
hasBackdrop: true,
width: '360px',
data: {
selectedNaspace: this.selectedNamespace,
selectedNamespace: this.selectedNamespace,
},
});
dialogRef.afterClosed().subscribe(result => {
Expand Down Expand Up @@ -1540,7 +1541,7 @@ export class KnowledgeBasesComponent extends PricingBaseComponent implements OnI
this.logger.log("[KNOWLEDGE BASES COMP] get kbList resp: ", resp);
//this.kbs = resp;
this.kbsListCount = resp.count;
this.logger.log('[KNOWLEDGE BASES COMP] kbsListCount ', this.kbsListCount)
console.log('[KNOWLEDGE BASES COMP] kbsListCount ', this.kbsListCount)
this.logger.log('[KNOWLEDGE BASES COMP] resp.kbs ', resp.kbs)
resp.kbs.forEach((kb: any, i: number) => {
// this.kbsList.push(kb);
Expand Down Expand Up @@ -2199,7 +2200,9 @@ export class KnowledgeBasesComponent extends PricingBaseComponent implements OnI
"content": kb.content ? kb.content : '',
"namespace": this.id_project
}

this.updateStatusOfKb(kb._id, 100);

this.openaiService.startScraping(data).subscribe((response: any) => {
this.logger.log("start scraping response: ", response);
if (response.error) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
<div class="add-content-btn-wpr">
<button class="btn custom-button add-content center" style="box-shadow: unset;"
[matMenuTriggerFor]="menu">
<span class="material-icons-round">add</span>
<!-- <span class="material-icons-round">add</span> -->
{{ 'KbPage.Add' | translate }}
</button>
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -311,7 +311,7 @@ td {
// box-shadow: rgb(212, 217, 230) 0px 1px 0px;



// background: linear-gradient(rgba(239, 245, 246, 0.64) 0%, rgb(98, 119, 140) 100%), rgb(98, 119, 140);
// box-shadow: rgb(98, 119, 140) 0px 1px 0px;

Expand Down Expand Up @@ -342,9 +342,12 @@ td {
}

.upgrade-title {
font-size: 28px;
font-weight: 500;
margin-bottom: 20px;
// font-size: 28px;
// font-weight: 500;
// margin-bottom: 20px;
font-size: 16px;
font-weight: 600;
margin-bottom: 6px;
display: block;
}

Expand All @@ -363,7 +366,7 @@ td {
}

.upgrade-subtitle-learn-how:hover {
text-decoration: underline;
text-decoration: underline;
}
}

Expand Down Expand Up @@ -546,5 +549,5 @@ td {
}

.imported-file {
margin-top: 8px ;
margin-top: 8px;
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,16 @@
<h1 mat-dialog-title> {{ 'Preview' | translate }} </h1>
<div class="m-top-right-icon" >

<span id="settings" class="material-icons-outlined" (click)="closePreviewKBAndOpenSettingsModal()">
<span *ngIf="!isopenasetting" id="settings" class="material-icons-outlined" (click)="presentDialogAiSettings(isopenasetting = !isopenasetting)">
settings
</span>
<span *ngIf="isopenasetting" id="settings" class="material-icons-outlined close-ai-settings" (click)="closeDialogAiSettings(isopenasetting = !isopenasetting)">
remove
</span>

<!-- <span id="settings" class="material-icons-outlined" (click)="closePreviewKBAndOpenSettingsModal()">
settings
</span> -->

<span id="close" class="material-icons-outlined" (click)="onCloseBaseModal()">
close
Expand Down Expand Up @@ -34,7 +41,12 @@ <h1 mat-dialog-title> {{ 'Preview' | translate }} </h1>
<div *ngIf="show_answer" class="form-container" style="margin-bottom: 0px;">
<div id="answer" class="answer">
<p *ngIf="answer" class="answer-title">{{ 'KbPage.Answer' | translate }}</p>
{{ answer }}
<!-- <span *ngIf="!aiQuotaExceeded"> -->
{{ answer }}
<!-- </span> -->
<!-- <span *ngIf="aiQuotaExceeded">
-> {{ answer }}
</span> -->
<span *ngIf="qa && (!qa.answer || qa.answer == '')">{{ 'KbPage.NoAnswerFound' | translate }}</span>
<hr *ngIf="qa && qa.source">
<!-- <span *ngIf="qa.source">{{ 'KbPage.Source' | translate }}: {{ qa.source }}</span> -->
Expand All @@ -44,13 +56,41 @@ <h1 mat-dialog-title> {{ 'Preview' | translate }} </h1>
</span>

</div>
<label class="control-label" style="margin-top: 10px;">
<label *ngIf="!aiQuotaExceeded" class="control-label" style="margin-top: 10px;">
{{ 'KbPage.LabelResponseTime' | translate: translateparam }}
</label>
</div>


</div>

<div mat-dialog-actions style="justify-content: center;">


<button class="mat-dialog-reuse-last-question-btn" mat-button
(click)="reuseLastQuestion()" [disabled]="!hasStoredQuestion">
<!-- Re-use last question -->
{{"KbPage.ReUseLastQuestion" | translate }}

</button>

</div>
<!-- <div>
selectedModel > {{ selectedModel}}
</div>
<div>
maxTokens > {{ maxTokens}}
</div>
<div>
temperature > {{ temperature}}
</div>
<div>
topK > {{ topK}}
</div>
<div>
context > {{ context}}
</div> -->

<!-- style="justify-content: center;" -->
<!-- <div mat-dialog-actions style="justify-content: center;">
<button class="mat-dialog-close-btn" mat-button (click)="onCloseBaseModal()">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -154,10 +154,10 @@

.answer {
min-height: 37px;
max-height: auto;
// max-height: auto;
border-radius: 6px;
border: solid 1px #ccc;
padding: 6px 12px 20px;
padding: 6px 12px 6px;
cursor: text;
overflow: hidden;
transition: max-height 0.5s ease-out;
Expand Down Expand Up @@ -283,4 +283,14 @@
background-color: var(--blue-light);
color: #fff;

}

.mat-dialog-reuse-last-question-btn {
background-color: #647491;
color: #fff;
}


.close-ai-settings {
color: var(--blue-light) !important;
}
Loading

0 comments on commit 6187677

Please sign in to comment.