Skip to content

Commit

Permalink
Merge branch 'CreditMutuelArkea-feature/faq/dercbot-621-merge-managem…
Browse files Browse the repository at this point in the history
…ent-and-training-in-a-single-main-menu-entry'
  • Loading branch information
vsct-jburet committed Jul 20, 2023
2 parents e614d01 + 612c3db commit 0c48e7d
Show file tree
Hide file tree
Showing 12 changed files with 116 additions and 52 deletions.
43 changes: 24 additions & 19 deletions bot/admin/web/src/app/bot-admin-app.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -92,34 +92,39 @@ export class BotAdminAppComponent implements AuthListener, OnInit, OnDestroy {
hidden: !this.state.hasRole(UserRole.nlpUser)
},
{
title: 'Settings',
icon: 'settings-outline',
link: '/configuration',
hidden: !this.state.hasRole(UserRole.admin)
title: 'FAQ',
icon: 'message-square-outline',
hidden: !this.state.hasRole(UserRole.faqBotUser),
children: [
{
link: '/faq/management',
title: 'Management',
icon: 'book-open-outline'
},
{
link: '/faq/training',
title: 'Training',
icon: 'checkmark-square-outline'
}
]
},
{
title: 'FAQ Training',
icon: {
icon: 'school',
pack: 'material-icons'
},
title: 'FAQ training',
icon: 'checkmark-square-outline',
link: '/faq/training',
hidden: !this.state.hasRole(UserRole.faqNlpUser)
},
{
title: 'FAQ Management',
icon: {
icon: 'question_answer',
pack: 'material-icons'
},
link: '/faq/management',
hidden: !this.state.hasRole(UserRole.faqBotUser)
hidden: !this.state.hasRole(UserRole.faqNlpUser) || this.state.hasRole(UserRole.faqBotUser)
},
{
title: 'Answers',
icon: 'color-palette-outline',
link: '/build/i18n',
hidden: this.state.hasRole(UserRole.botUser) || !this.state.hasRole(UserRole.faqBotUser)
},
{
title: 'Settings',
icon: 'settings-outline',
link: '/configuration',
hidden: !this.state.hasRole(UserRole.admin)
}
];
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,18 +1,4 @@
<nb-card class="mb-0">
<nb-card-header class="d-flex align-items-center justify-content-between">
Filters
<button
*ngIf="isFiltered"
nbButton
nbTooltip="Clear all filters"
ghost
shape="round"
(click)="clearFilters()"
data-testid="clear-button"
>
<nb-icon icon="close-outline"></nb-icon>
</button>
</nb-card-header>
<nb-card-body>
<form
class="grid"
Expand All @@ -27,7 +13,7 @@
nbInput
fullWidth
fieldSize="medium"
placeholder="Search"
placeholder="Search a faq"
type="text"
formControlName="search"
/>
Expand Down Expand Up @@ -56,6 +42,18 @@
>
Active
</nb-checkbox>

<button
*ngIf="isFiltered"
nbButton
nbTooltip="Clear all filters"
ghost
shape="round"
(click)="clearFilters()"
data-testid="clear-button"
>
<nb-icon icon="close-outline"></nb-icon>
</button>
</form>
</nb-card-body>
</nb-card>
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,12 @@

@include media-breakpoint-up(sm) {
.grid {
grid-template-columns: repeat(auto-fit, minmax(15rem, 1fr));
grid-template-columns: repeat(auto-fit, minmax(12rem, 1fr));
}
}

@include media-breakpoint-up(md) {
.grid {
grid-template-columns: 1fr 1fr 1fr 3rem;
}
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<div class="d-flex flex-wrap mb-2">
<div class="d-flex flex-wrap mt-3 mb-2">
<h1 class="flex-grow-1">FAQ Management</h1>

<section class="grid-actions">
Expand Down
25 changes: 14 additions & 11 deletions bot/admin/web/src/app/faq/faq-routing.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,24 +3,27 @@ import { RouterModule, Routes } from '@angular/router';
import { ApplicationResolver } from '../core-nlp/application.resolver';
import { AuthGuard } from '../core-nlp/auth/auth.guard';
import { FaqManagementComponent } from './faq-management/faq-management.component';
import { FaqTabsComponent } from './faq-tabs/faq-tabs.component';
import { FaqTrainingComponent } from './faq-training/faq-training.component';

const routes: Routes = [
{
path: 'training',
component: FaqTrainingComponent,
path: '',
canActivate: [AuthGuard],
component: FaqTabsComponent,
resolve: {
application: ApplicationResolver
}
},
{
path: 'management',
component: FaqManagementComponent,
canActivate: [AuthGuard],
resolve: {
application: ApplicationResolver
}
},
children: [
{
path: 'training',
component: FaqTrainingComponent
},
{
path: 'management',
component: FaqManagementComponent
}
]
}
];

Expand Down
1 change: 1 addition & 0 deletions bot/admin/web/src/app/faq/faq-tabs/faq-tabs.component.html
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
<nb-route-tabset [tabs]="tabLinks"></nb-route-tabset>
Empty file.
23 changes: 23 additions & 0 deletions bot/admin/web/src/app/faq/faq-tabs/faq-tabs.component.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
import { ComponentFixture, TestBed } from '@angular/core/testing';

import { FaqTabsComponent } from './faq-tabs.component';

describe('FaqTabsComponent', () => {
let component: FaqTabsComponent;
let fixture: ComponentFixture<FaqTabsComponent>;

beforeEach(async () => {
await TestBed.configureTestingModule({
declarations: [ FaqTabsComponent ]
})
.compileComponents();

fixture = TestBed.createComponent(FaqTabsComponent);
component = fixture.componentInstance;
fixture.detectChanges();
});

it('should create', () => {
expect(component).toBeTruthy();
});
});
25 changes: 25 additions & 0 deletions bot/admin/web/src/app/faq/faq-tabs/faq-tabs.component.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
import { Component, OnInit } from '@angular/core';
import { Router } from '@angular/router';
import { StateService } from '../../core-nlp/state.service';
import { UserRole } from '../../model/auth';
import { TabLink } from '../../shared/utils';

const managementTab = new TabLink('management', 'Faq management', 'book-open-outline');
const trainingTab = new TabLink('training', 'Faq training', 'checkmark-square-outline');

@Component({
selector: 'tock-faq-tabs',
templateUrl: './faq-tabs.component.html',
styleUrls: ['./faq-tabs.component.scss']
})
export class FaqTabsComponent implements OnInit {
UserRole = UserRole;
tabLinks = [];

constructor(private router: Router, public state: StateService) {}

ngOnInit() {
if (this.state.hasRole(UserRole.faqBotUser)) this.tabLinks.push(managementTab);
if (this.state.hasRole(UserRole.faqNlpUser)) this.tabLinks.push(trainingTab);
}
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
<nb-card class="mb-0">
<nb-card-header>Filters</nb-card-header>
<nb-card-body>
<form
class="grid"
Expand All @@ -14,7 +13,7 @@
nbInput
fullWidth
fieldSize="medium"
placeholder="Search"
placeholder="Search a sentence"
type="text"
formControlName="search"
/>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<header class="mb-2">
<header class="mt-3 mb-2">
<h1>FAQ Training</h1>
</header>

Expand Down
8 changes: 6 additions & 2 deletions bot/admin/web/src/app/faq/faq.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import {
NbFormFieldModule,
NbIconModule,
NbInputModule,
NbRouteTabsetModule,
NbSelectModule,
NbSpinnerModule,
NbTabsetModule,
Expand All @@ -36,6 +37,7 @@ import { FaqManagementSettingsComponent } from './faq-management/faq-management-
import { InfiniteScrollModule } from 'ngx-infinite-scroll';
import { FaqService } from './services/faq.service';
import { BotAnalyticsModule } from '../analytics/analytics.module';
import { FaqTabsComponent } from './faq-tabs/faq-tabs.component';

@NgModule({
imports: [
Expand All @@ -62,7 +64,8 @@ import { BotAnalyticsModule } from '../analytics/analytics.module';
NbAlertModule,
NbChatModule,
InfiniteScrollModule,
BotAnalyticsModule
BotAnalyticsModule,
NbRouteTabsetModule
],
declarations: [
FaqManagementComponent,
Expand All @@ -73,7 +76,8 @@ import { BotAnalyticsModule } from '../analytics/analytics.module';
FaqManagementFiltersComponent,
FaqManagementListComponent,
FaqManagementEditComponent,
FaqManagementSettingsComponent
FaqManagementSettingsComponent,
FaqTabsComponent
],
exports: [],
providers: [FaqService]
Expand Down

0 comments on commit 0c48e7d

Please sign in to comment.