Skip to content

Commit 82a8bd2

Browse files
authored
Merge branch 'main' into page-header-alignment-input
2 parents 5e4cd27 + 8817a28 commit 82a8bd2

File tree

4 files changed

+86
-14
lines changed

4 files changed

+86
-14
lines changed

projects/components/src/datetime-picker/datetime-picker.component.ts

Lines changed: 42 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,19 @@
11
import { ChangeDetectionStrategy, Component, EventEmitter, Input, OnChanges, Output } from '@angular/core';
2+
import { ControlValueAccessor, NG_VALUE_ACCESSOR } from '@angular/forms';
23
import { Time, TypedSimpleChanges } from '@hypertrace/common';
34
import { InputAppearance } from '../input/input-appearance';
45

56
@Component({
67
selector: 'ht-datetime-picker',
78
styleUrls: ['./datetime-picker.component.scss'],
89
changeDetection: ChangeDetectionStrategy.OnPush,
10+
providers: [
11+
{
12+
provide: NG_VALUE_ACCESSOR,
13+
multi: true,
14+
useExisting: DatetimePickerComponent
15+
}
16+
],
917
template: `
1018
<div class="datetime-picker">
1119
<ht-label *ngIf="this.label" [label]="this.label" class="datetime-label"></ht-label>
@@ -21,17 +29,19 @@ import { InputAppearance } from '../input/input-appearance';
2129
>
2230
</ht-input>
2331
24-
<ht-time-picker
25-
class="time-selector"
26-
[time]="this.time"
27-
[showTimeTriggerIcon]="this.showTimeTriggerIcon"
28-
(timeChange)="this.onTimeChange($event)"
29-
></ht-time-picker>
32+
<ng-container *ngIf="!this.showDateOnly"
33+
><ht-time-picker
34+
class="time-selector"
35+
[time]="this.time"
36+
[showTimeTriggerIcon]="this.showTimeTriggerIcon"
37+
(timeChange)="this.onTimeChange($event)"
38+
></ht-time-picker
39+
></ng-container>
3040
</div>
3141
</div>
3242
`
3343
})
34-
export class DatetimePickerComponent implements OnChanges {
44+
export class DatetimePickerComponent implements ControlValueAccessor, OnChanges {
3545
@Input()
3646
public label?: string;
3747

@@ -41,6 +51,9 @@ export class DatetimePickerComponent implements OnChanges {
4151
@Input()
4252
public date?: Date = new Date();
4353

54+
@Input()
55+
public showDateOnly: boolean = false;
56+
4457
@Output()
4558
public readonly dateChange: EventEmitter<Date> = new EventEmitter();
4659

@@ -52,10 +65,30 @@ export class DatetimePickerComponent implements OnChanges {
5265
}
5366
}
5467

68+
private propagateControlValueChange?: (value?: Date) => void;
69+
private propagateControlValueChangeOnTouch?: (value?: Date) => void;
70+
5571
public getInputDate(): string {
5672
return this.date?.toISOString().slice(0, 10) ?? '';
5773
}
5874

75+
public writeValue(value?: Date): void {
76+
this.date = value;
77+
}
78+
79+
public registerOnChange(onChange: (value?: Date) => void): void {
80+
this.propagateControlValueChange = onChange;
81+
}
82+
83+
public registerOnTouched(onTouch: (value?: Date) => void): void {
84+
this.propagateControlValueChangeOnTouch = onTouch;
85+
}
86+
87+
private propagateValueChangeToFormControl(value?: Date): void {
88+
this.propagateControlValueChange?.(value);
89+
this.propagateControlValueChangeOnTouch?.(value);
90+
}
91+
5992
private getInputTime(date: Date): Time {
6093
return new Time(date.getHours(), date.getMinutes());
6194
}
@@ -67,11 +100,13 @@ export class DatetimePickerComponent implements OnChanges {
67100
d.setFullYear(Number(yearMonthDay[0]), Number(yearMonthDay[1]) - 1, Number(yearMonthDay[2]));
68101
this.date = d;
69102
this.dateChange.emit(d);
103+
this.propagateValueChangeToFormControl(d);
70104
}
71105

72106
public onTimeChange(time: Time): void {
73107
this.time = time;
74108
this.date?.setUTCHours(time.hours, time.minutes, time.seconds, time.milliseconds);
75109
this.dateChange.emit(this.date);
110+
this.propagateValueChangeToFormControl(this.date);
76111
}
77112
}

projects/components/src/textarea/textarea.component.ts

Lines changed: 30 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,18 @@
11
import { ChangeDetectionStrategy, Component, EventEmitter, Input, OnInit, Output } from '@angular/core';
2+
import { ControlValueAccessor, NG_VALUE_ACCESSOR } from '@angular/forms';
23
import { LoggerService } from '@hypertrace/common';
34

45
@Component({
56
selector: 'ht-textarea',
67
styleUrls: ['./textarea.component.scss'],
78
changeDetection: ChangeDetectionStrategy.OnPush,
9+
providers: [
10+
{
11+
provide: NG_VALUE_ACCESSOR,
12+
multi: true,
13+
useExisting: TextareaComponent
14+
}
15+
],
816
template: `
917
<mat-form-field class="fill-container" floatLabel="never">
1018
<textarea
@@ -20,7 +28,7 @@ import { LoggerService } from '@hypertrace/common';
2028
</mat-form-field>
2129
`
2230
})
23-
export class TextareaComponent implements OnInit {
31+
export class TextareaComponent implements ControlValueAccessor, OnInit {
2432
@Input()
2533
public placeholder!: string;
2634

@@ -45,8 +53,29 @@ export class TextareaComponent implements OnInit {
4553
}
4654
}
4755

56+
private propagateControlValueChange?: (value?: string) => void;
57+
private propagateControlValueChangeOnTouch?: (value?: string) => void;
58+
4859
public onValueChange(value: string): void {
4960
this.value = value;
5061
this.valueChange.emit(value);
62+
this.propagateValueChangeToFormControl(value);
63+
}
64+
65+
public writeValue(value?: string): void {
66+
this.value = value;
67+
}
68+
69+
public registerOnChange(onChange: (value?: string) => void): void {
70+
this.propagateControlValueChange = onChange;
71+
}
72+
73+
public registerOnTouched(onTouch: (value?: string) => void): void {
74+
this.propagateControlValueChangeOnTouch = onTouch;
75+
}
76+
77+
private propagateValueChangeToFormControl(value?: string): void {
78+
this.propagateControlValueChange?.(value);
79+
this.propagateControlValueChangeOnTouch?.(value);
5180
}
5281
}

projects/components/src/time-picker/time-picker.component.scss

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828
height: 32px;
2929
padding: 0 8px;
3030
cursor: pointer;
31+
min-width: 108px;
3132

3233
.trigger-icon {
3334
padding: 0 8px;
@@ -48,6 +49,7 @@
4849
background: white;
4950
overflow: auto;
5051
max-height: 320px;
52+
min-width: 108px;
5153

5254
.popover-item {
5355
@include list-hover;

projects/observability/src/shared/dashboard/widgets/table/table-widget-renderer.component.ts

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -470,12 +470,18 @@ export class TableWidgetRendererComponent
470470
}
471471

472472
public onSearchChange(text: string): void {
473-
const searchFilter: TableFilter = {
474-
field: this.api.model.getSearchAttribute()!,
475-
operator: FilterOperator.Like,
476-
value: text
477-
};
478-
this.searchFilterSubject.next([searchFilter]);
473+
let searchFilters: TableFilter[] = [];
474+
// In case of empty string, avoid sending LIKE operator with empty value
475+
if (isNonEmptyString(text)) {
476+
searchFilters = [
477+
{
478+
field: this.api.model.getSearchAttribute()!,
479+
operator: FilterOperator.Like,
480+
value: text
481+
}
482+
];
483+
}
484+
this.searchFilterSubject.next(searchFilters);
479485
}
480486

481487
public onViewChange(view: string): void {

0 commit comments

Comments
 (0)