Skip to content

Commit 953a291

Browse files
rkufferassouktim
authored andcommitted
resolves #1965: Feedback display and stats + date and time filters
# Conflicts: # bot/admin/web/src/app/metrics/metrics-board/metrics-board.component.html # bot/admin/web/src/app/metrics/metrics-board/metrics-board.component.ts
1 parent a40df97 commit 953a291

File tree

19 files changed

+701
-385
lines changed

19 files changed

+701
-385
lines changed

.pre-commit-config.yaml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,4 +43,6 @@ repos:
4343
rev: v2.9.0
4444
hooks:
4545
- id: pip-audit
46-
additional_dependencies: ["pip>=25.3"]
46+
additional_dependencies:
47+
- "pip>=25.3"
48+
- "filelock>=3.20.1"

bot/admin/web/src/app/analytics/analytics.module.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ import {
3131
NbCheckboxModule,
3232
NbContextMenuModule,
3333
NbDatepickerModule,
34+
NbTimepickerModule,
3435
NbInputModule,
3536
NbListModule,
3637
NbMenuModule,
@@ -87,6 +88,7 @@ import { DialogsListFiltersComponent } from './dialogs/dialogs-list/dialogs-list
8788
NbCalendarModule,
8889
NbUserModule,
8990
NbDatepickerModule,
91+
NbTimepickerModule.forRoot(),
9092
NbListModule,
9193
NbAccordionModule,
9294
NbContextMenuModule,

bot/admin/web/src/app/analytics/dialogs/dialogs-list/dialogs-list-filters/dialogs-list-filters.component.html

Lines changed: 74 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@
109109
fullWidth
110110
fieldSize="small"
111111
placeholder="Data collected after"
112-
nbTooltip="Show dialogs created after this date"
112+
nbTooltip="Show dialogs containing messages created after this date"
113113
[nbDatepicker]="from_date"
114114
formControlName="dialogCreationDateFrom"
115115
/>
@@ -125,7 +125,14 @@
125125
<nb-icon icon="x"></nb-icon>
126126
</button>
127127
</nb-form-field>
128-
<nb-datepicker #from_date></nb-datepicker>
128+
129+
<nb-date-timepicker
130+
#from_date
131+
[step]="10"
132+
singleColumn
133+
format="y/MM/dd HH:mm"
134+
[showCurrentTimeButton]="false"
135+
></nb-date-timepicker>
129136
</div>
130137

131138
<div class="col-6 col-lg-3">
@@ -139,7 +146,7 @@
139146
fullWidth
140147
fieldSize="small"
141148
placeholder="Data collected before"
142-
nbTooltip="Show dialogs created before this date"
149+
nbTooltip="Show dialogs containing messages created before this date"
143150
[nbDatepicker]="to_date"
144151
formControlName="dialogCreationDateTo"
145152
/>
@@ -155,7 +162,14 @@
155162
<nb-icon icon="x"></nb-icon>
156163
</button>
157164
</nb-form-field>
158-
<nb-datepicker #to_date></nb-datepicker>
165+
166+
<nb-date-timepicker
167+
#to_date
168+
[step]="10"
169+
singleColumn
170+
format="y/MM/dd HH:mm"
171+
[showCurrentTimeButton]="false"
172+
></nb-date-timepicker>
159173
</div>
160174

161175
<div class="col-6 col-lg-3">
@@ -291,6 +305,48 @@
291305
</nb-form-field>
292306
</div>
293307

308+
<!-- Feedback filters -->
309+
<div class="col-6 col-lg-3">
310+
<nb-form-field class="mb-2">
311+
<nb-icon
312+
nbPrefix
313+
icon="hand-thumbs-up"
314+
*ngIf="!getFormControl('feedback').value"
315+
></nb-icon>
316+
<nb-icon
317+
nbPrefix
318+
icon="hand-thumbs-up"
319+
*ngIf="getFormControl('feedback').value === 'UP'"
320+
class="text-success"
321+
></nb-icon>
322+
<nb-icon
323+
nbPrefix
324+
icon="hand-thumbs-down"
325+
*ngIf="getFormControl('feedback').value === 'DOWN'"
326+
class="text-danger"
327+
></nb-icon>
328+
<nb-select
329+
fullWidth
330+
size="small"
331+
nbTooltip="Dialogues containing messages with feedback."
332+
placeholder="Feedback"
333+
formControlName="feedback"
334+
>
335+
<nb-option>Clear filter</nb-option>
336+
<nb-option
337+
*ngFor="let vote of feedbackVotes"
338+
[value]="vote.value"
339+
>
340+
<nb-icon
341+
icon="hand-thumbs-{{ vote.value.toLowerCase() }}"
342+
class="select-icon align-self-center mr-2 font-size-small"
343+
></nb-icon>
344+
{{ vote.label }}
345+
</nb-option>
346+
</nb-select>
347+
</nb-form-field>
348+
</div>
349+
294350
<div class="col-6 col-lg-3 pt-1">
295351
<nb-checkbox
296352
nbTooltip="Display dialogues held from the studio test view"
@@ -406,7 +462,13 @@
406462
<nb-icon icon="x"></nb-icon>
407463
</button>
408464
</nb-form-field>
409-
<nb-datepicker #from_date_annotation></nb-datepicker>
465+
<nb-date-timepicker
466+
#from_date_annotation
467+
[step]="10"
468+
singleColumn
469+
format="y/MM/dd HH:mm"
470+
[showCurrentTimeButton]="false"
471+
></nb-date-timepicker>
410472
</div>
411473

412474
<div
@@ -439,7 +501,13 @@
439501
<nb-icon icon="x"></nb-icon>
440502
</button>
441503
</nb-form-field>
442-
<nb-datepicker #to_date_annotation></nb-datepicker>
504+
<nb-date-timepicker
505+
#to_date_annotation
506+
[step]="10"
507+
singleColumn
508+
format="y/MM/dd HH:mm"
509+
[showCurrentTimeButton]="false"
510+
></nb-date-timepicker>
443511
</div>
444512

445513
<div

bot/admin/web/src/app/analytics/dialogs/dialogs-list/dialogs-list-filters/dialogs-list-filters.component.ts

Lines changed: 22 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,12 @@ import {
3030
AnnotationStates
3131
} from '../../../../shared/components/annotation/annotations';
3232
import { SortOrder, SortOrders } from '../../../../shared/model/misc';
33+
import { FeedbackVote } from '../../dialogs';
34+
35+
export const FeedbackVotes = [
36+
{ label: 'Positive feedback', value: FeedbackVote.UP },
37+
{ label: 'Negative feedback', value: FeedbackVote.DOWN }
38+
] as const;
3339

3440
interface DialogListFiltersForm {
3541
exactMatch: FormControl<boolean>;
@@ -51,6 +57,7 @@ interface DialogListFiltersForm {
5157
annotationSort?: FormControl<SortOrder>;
5258
annotationCreationDateFrom?: FormControl<Date>;
5359
annotationCreationDateTo?: FormControl<Date>;
60+
feedback?: FormControl<FeedbackVote>;
5461
}
5562

5663
export type DialogListFilters = ExtractFormControlTyping<DialogListFiltersForm>;
@@ -62,6 +69,7 @@ export type DialogListFilters = ExtractFormControlTyping<DialogListFiltersForm>;
6269
})
6370
export class DialogsListFiltersComponent implements OnInit {
6471
private readonly destroy$: Subject<boolean> = new Subject();
72+
private lastEmittedValue: Partial<DialogListFilters> | null = null;
6573

6674
advanced: boolean = false;
6775
connectorTypes: ConnectorType[] = [];
@@ -70,6 +78,7 @@ export class DialogsListFiltersComponent implements OnInit {
7078
annotationStates = AnnotationStates;
7179
annotationReasons = AnnotationReasons;
7280
sortOrders = SortOrders;
81+
feedbackVotes = FeedbackVotes;
7382

7483
@Input() initialFilters: Partial<DialogListFilters>;
7584
@Output() onFilter = new EventEmitter<Partial<DialogListFilters>>();
@@ -93,11 +102,16 @@ export class DialogsListFiltersComponent implements OnInit {
93102
});
94103
});
95104

105+
this.lastEmittedValue = { ...this.form.value };
106+
96107
if (this.initialFilters) {
97108
this.form.patchValue(this.initialFilters);
109+
this.lastEmittedValue = { ...this.form.value };
98110
}
99111

100-
this.form.valueChanges.pipe(debounceTime(500), takeUntil(this.destroy$)).subscribe(() => this.submitFiltersChange());
112+
this.form.valueChanges.pipe(debounceTime(800), takeUntil(this.destroy$)).subscribe(() => {
113+
this.submitFiltersChange();
114+
});
101115
}
102116

103117
form = new FormGroup<DialogListFiltersForm>({
@@ -119,7 +133,8 @@ export class DialogsListFiltersComponent implements OnInit {
119133
annotationReasons: new FormControl([]),
120134
annotationSort: new FormControl(),
121135
annotationCreationDateFrom: new FormControl(),
122-
annotationCreationDateTo: new FormControl()
136+
annotationCreationDateTo: new FormControl(),
137+
feedback: new FormControl()
123138
});
124139

125140
getFormControl(formControlName: string): FormControl {
@@ -128,8 +143,10 @@ export class DialogsListFiltersComponent implements OnInit {
128143

129144
submitFiltersChange(): void {
130145
const formValue = this.form.value;
131-
132-
this.onFilter.emit(formValue);
146+
if (JSON.stringify(formValue) !== JSON.stringify(this.lastEmittedValue)) {
147+
this.onFilter.emit(formValue);
148+
this.lastEmittedValue = { ...formValue };
149+
}
133150
}
134151

135152
resetControl(ctrl: FormControl, input?: HTMLInputElement): void {
@@ -139,7 +156,7 @@ export class DialogsListFiltersComponent implements OnInit {
139156
}
140157
}
141158

142-
patchControl(ctrl: FormControl, value: any): void {
159+
patchControl(ctrl: FormControl, value: boolean): void {
143160
ctrl.patchValue(value);
144161
}
145162

bot/admin/web/src/app/analytics/dialogs/dialogs-list/dialogs-list.component.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,6 @@ export class DialogsListComponent implements OnInit, OnChanges, OnDestroy {
9090
...this.filters,
9191
...filters
9292
};
93-
9493
this.search();
9594
}
9695

@@ -157,7 +156,8 @@ export class DialogsListComponent implements OnInit, OnChanges, OnDestroy {
157156
this.filters.annotationReasons,
158157
this.filters.annotationSort,
159158
this.filters.annotationCreationDateFrom,
160-
this.filters.annotationCreationDateTo
159+
this.filters.annotationCreationDateTo,
160+
this.filters.feedback
161161
);
162162

163163
this.analytics.dialogs(this.dialogReportQuery).subscribe((result) => {

bot/admin/web/src/app/analytics/dialogs/dialogs.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,10 @@ import { ConnectorType } from '../../core/model/configuration';
2020
import { AnnotationReason, AnnotationState } from '../../shared/components/annotation/annotations';
2121
import { SortOrder } from '../../shared/model/misc';
2222

23+
export enum FeedbackVote {
24+
UP = 'UP',
25+
DOWN = 'DOWN'
26+
}
2327
export class DialogReportQuery extends PaginatedQuery {
2428
constructor(
2529
public override namespace: string,
@@ -46,7 +50,8 @@ export class DialogReportQuery extends PaginatedQuery {
4650
public annotationReasons?: AnnotationReason[],
4751
public annotationSort?: SortOrder,
4852
public annotationCreationDateFrom?: Date,
49-
public annotationCreationDateTo?: Date
53+
public annotationCreationDateTo?: Date,
54+
public feedback?: FeedbackVote
5055
) {
5156
super(namespace, applicationName, language, start, size);
5257
}

0 commit comments

Comments
 (0)