Skip to content

Commit 2a2e427

Browse files
authored
Allow configurable select or multiselect table controls (#1238)
* feat: add ability to choose regular or multi select table controls * style: prettier * test: fix
1 parent cf82f51 commit 2a2e427

File tree

8 files changed

+51
-16
lines changed

8 files changed

+51
-16
lines changed

projects/components/src/table/controls/table-controls-api.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ export interface TablePropertyControlOption {
3737

3838
export interface TableSelectControl {
3939
placeholder: string;
40+
isMultiSelect: boolean;
4041
options: TableSelectControlOption[];
4142
}
4243

projects/components/src/table/controls/table-controls.component.test.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,7 @@ describe('Table Controls component', () => {
6262
selectControls: [
6363
{
6464
placeholder: 'test1',
65+
isMultiSelect: true,
6566
options: [
6667
{
6768
label: 'first1',
@@ -88,6 +89,7 @@ describe('Table Controls component', () => {
8889
selectControls: [
8990
{
9091
placeholder: 'test1',
92+
isMultiSelect: true,
9193
options: [
9294
{
9395
label: 'first1',

projects/components/src/table/controls/table-controls.component.ts

Lines changed: 33 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -43,21 +43,39 @@ import {
4343
></ht-search-box>
4444
4545
<!-- Selects -->
46-
<ht-multi-select
47-
*ngFor="let selectControl of this.selectControls"
48-
[selected]="this.appliedFilters(selectControl)"
49-
[placeholder]="selectControl.placeholder"
50-
class="control select"
51-
showBorder="true"
52-
searchMode="${MultiSelectSearchMode.CaseInsensitive}"
53-
(selectedChange)="this.onMultiSelectChange(selectControl, $event)"
54-
>
55-
<ht-select-option
56-
*ngFor="let option of selectControl.options"
57-
[label]="option.label"
58-
[value]="option"
59-
></ht-select-option>
60-
</ht-multi-select>
46+
<ng-container *ngFor="let selectControl of this.selectControls">
47+
<ht-multi-select
48+
*ngIf="selectControl.isMultiSelect"
49+
[selected]="this.appliedFilters(selectControl)"
50+
[placeholder]="selectControl.placeholder"
51+
class="control select"
52+
showBorder="true"
53+
searchMode="${MultiSelectSearchMode.CaseInsensitive}"
54+
(selectedChange)="this.onMultiSelectChange(selectControl, $event)"
55+
>
56+
<ht-select-option
57+
*ngFor="let option of selectControl.options"
58+
[label]="option.label"
59+
[value]="option"
60+
></ht-select-option>
61+
</ht-multi-select>
62+
63+
<ht-select
64+
*ngIf="!selectControl.isMultiSelect"
65+
[selected]="this.appliedFilters(selectControl)"
66+
[placeholder]="selectControl.placeholder"
67+
class="control select"
68+
showBorder="true"
69+
searchMode="${MultiSelectSearchMode.CaseInsensitive}"
70+
(selectedChange)="this.onMultiSelectChange(selectControl, $event)"
71+
>
72+
<ht-select-option
73+
*ngFor="let option of selectControl.options"
74+
[label]="option.label"
75+
[value]="option"
76+
></ht-select-option>
77+
</ht-select>
78+
</ng-container>
6179
</div>
6280
6381
<!-- Right -->

projects/observability/src/pages/apis/endpoints/endpoint-list.dashboard.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ export const endpointListDashboard: DashboardDefaultConfiguration = {
2222
searchAttribute: 'name',
2323
'select-control-options': [
2424
{
25-
type: 'table-widget-select-option',
25+
type: 'table-widget-multi-select-option',
2626
'unique-values': true,
2727
placeholder: 'Services',
2828
data: {
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
import { Model } from '@hypertrace/hyperdash';
2+
import { TableWidgetControlSelectOptionModel } from './table-widget-control-select-option.model';
3+
4+
@Model({
5+
type: 'table-widget-multi-select-option'
6+
})
7+
export class TableWidgetControlMultiSelectOptionModel extends TableWidgetControlSelectOptionModel {
8+
public readonly isMultiselect: boolean = true;
9+
}

projects/observability/src/shared/dashboard/widgets/table/table-widget-control-select-option.model.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@ import { TableWidgetControlModel } from './table-widget-control.model';
88
type: 'table-widget-select-option'
99
})
1010
export class TableWidgetControlSelectOptionModel extends TableWidgetControlModel<TableSelectControlOption> {
11+
public readonly isMultiselect: boolean = false;
12+
1113
@ModelProperty({
1214
key: 'placeholder',
1315
displayName: 'Placeholder',

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -255,6 +255,7 @@ export class TableWidgetRendererComponent
255255
return (
256256
foundPreferences ?? {
257257
placeholder: selectControlModel.placeholder,
258+
isMultiSelect: selectControlModel.isMultiselect,
258259
options: options.map(option => ({
259260
...option,
260261
applied: this.isFilterApplied(option.metaValue, filters)

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ import { TracingTableCellRendererModule } from '../../../components/table/tracin
1414
import { TableWidgetRowInteractionModel } from './selections/table-widget-row-interaction.model';
1515
import { TableWidgetColumnModel } from './table-widget-column.model';
1616
import { TableWidgetControlCheckboxOptionModel } from './table-widget-control-checkbox-option.model';
17+
import { TableWidgetControlMultiSelectOptionModel } from './table-widget-control-multi-select-option.model';
1718
import { TableWidgetControlSelectOptionModel } from './table-widget-control-select-option.model';
1819
import { TableWidgetRendererComponent } from './table-widget-renderer.component';
1920
import { TableWidgetViewToggleModel } from './table-widget-view-toggle.model';
@@ -30,6 +31,7 @@ import { TableWidgetModel } from './table-widget.model';
3031
TableWidgetRowInteractionModel,
3132
TableWidgetControlCheckboxOptionModel,
3233
TableWidgetControlSelectOptionModel,
34+
TableWidgetControlMultiSelectOptionModel,
3335
WidgetHeaderModel,
3436
TableWidgetViewToggleModel,
3537
TableWidgetViewModel

0 commit comments

Comments
 (0)