Skip to content

Commit 2d87f7f

Browse files
committed
feat: add visible option to table controls
1 parent c34989d commit 2d87f7f

File tree

3 files changed

+47
-43
lines changed

3 files changed

+47
-43
lines changed

projects/distributed-tracing/src/shared/dashboard/widgets/table/table-widget-control.model.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,14 @@ export abstract class TableWidgetControlModel {
1818
})
1919
public uniqueValues: boolean = false;
2020

21+
@ModelProperty({
22+
key: 'visible',
23+
displayName: 'Visible',
24+
type: BOOLEAN_PROPERTY.type,
25+
required: false
26+
})
27+
public visible: boolean = true;
28+
2129
@ModelInject(MODEL_API)
2230
protected readonly api!: ModelApi;
2331

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

Lines changed: 31 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -161,38 +161,44 @@ export class TableWidgetRendererComponent
161161

162162
protected fetchAndPopulateSelectControls(): void {
163163
this.selectControls$ = forkJoinSafeEmpty(
164-
this.model.getSelectControlOptions().map(selectControlModel =>
165-
// Fetch the values for the selectFilter dropdown
166-
selectControlModel.getOptions().pipe(
167-
first(),
168-
map(options => {
169-
const selectOptions = options.map(option => ({
170-
label: option.label,
171-
value: option
172-
}));
173-
174-
return {
175-
placeholder: selectControlModel.placeholder,
176-
options: selectOptions
177-
};
178-
})
164+
this.model
165+
.getSelectControlOptions()
166+
.filter(checkboxControlModel => checkboxControlModel.visible)
167+
.map(selectControlModel =>
168+
// Fetch the values for the selectFilter dropdown
169+
selectControlModel.getOptions().pipe(
170+
first(),
171+
map(options => {
172+
const selectOptions = options.map(option => ({
173+
label: option.label,
174+
value: option
175+
}));
176+
177+
return {
178+
placeholder: selectControlModel.placeholder,
179+
options: selectOptions
180+
};
181+
})
182+
)
179183
)
180-
)
181184
);
182185
}
183186

184187
protected fetchAndPopulateCheckboxControls(): void {
185188
this.checkboxControls$ = forkJoinSafeEmpty(
186-
this.model.getCheckboxControlOptions().map(checkboxControlModel =>
187-
checkboxControlModel.getOptions().pipe(
188-
first(),
189-
map(options => ({
190-
label: checkboxControlModel.checked ? options[0].label : options[1].label,
191-
value: checkboxControlModel.checked,
192-
options: options
193-
}))
189+
this.model
190+
.getCheckboxControlOptions()
191+
.filter(checkboxControlModel => checkboxControlModel.visible)
192+
.map(checkboxControlModel =>
193+
checkboxControlModel.getOptions().pipe(
194+
first(),
195+
map(options => ({
196+
label: checkboxControlModel.checked ? options[0].label : options[1].label,
197+
value: checkboxControlModel.checked,
198+
options: options
199+
}))
200+
)
194201
)
195-
)
196202
).pipe(
197203
tap((checkboxControls: CheckboxControl[]) => {
198204
// Apply initial values for checkboxes
Lines changed: 8 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,5 @@
1-
import {
2-
FilterOperator,
3-
TableControlOptionType,
4-
TableFilterControlOption,
5-
TableUnsetFilterControlOption
6-
} from '@hypertrace/components';
1+
import { FilterOperator, TableControlOptionType } from '@hypertrace/components';
2+
import { LabeledTableControlOption } from '@hypertrace/distributed-tracing';
73
import { Model, ModelProperty, STRING_PROPERTY } from '@hypertrace/hyperdash';
84
import { Observable } from 'rxjs';
95
import { map } from 'rxjs/operators';
@@ -20,18 +16,14 @@ export class EntitiesAttributeOptionsDataSourceModel extends EntitiesAttributeDa
2016
})
2117
public unsetLabel: string = 'All';
2218

23-
private buildUnsetOption(attribute: string): Labeled<TableUnsetFilterControlOption> {
24-
return {
25-
type: TableControlOptionType.UnsetFilter,
26-
label: this.unsetLabel,
27-
metaValue: attribute
28-
};
29-
}
30-
31-
public getData(): Observable<(Labeled<TableUnsetFilterControlOption> | Labeled<TableFilterControlOption>)[]> {
19+
public getData(): Observable<LabeledTableControlOption[]> {
3220
return super.getData().pipe(
3321
map((values: unknown[]) => [
34-
this.buildUnsetOption(this.specification.name),
22+
{
23+
type: TableControlOptionType.UnsetFilter,
24+
label: this.unsetLabel,
25+
metaValue: this.specification.name
26+
},
3527
...values.map(value => ({
3628
type: TableControlOptionType.Filter as const,
3729
label: String(value),
@@ -46,5 +38,3 @@ export class EntitiesAttributeOptionsDataSourceModel extends EntitiesAttributeDa
4638
);
4739
}
4840
}
49-
50-
type Labeled<T> = T & { label: string };

0 commit comments

Comments
 (0)