Skip to content

Commit c5ae452

Browse files
authored
Top level apis (#499)
* feat: top level apis navigation * fix: linting * fix: clean up the select filter input code in table widget renderer * fix: remove secondary entity spec and model * fix: change entities-attribute-data-source to return attributes array * fix: pr comments
1 parent 4002603 commit c5ae452

File tree

18 files changed

+394
-197
lines changed

18 files changed

+394
-197
lines changed

projects/common/src/utilities/types/types.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,3 +31,4 @@ export interface Json {
3131
}
3232

3333
export type JsonValue = Json | Json[] | string | number | boolean | null;
34+
export type PrimitiveValue = string | number | boolean;

projects/components/src/public-api.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -219,6 +219,7 @@ export * from './summary-value/summary-value.component';
219219
export * from './summary-value/summary-value.module';
220220

221221
// Table
222+
export * from './table/controls/table-controls-api';
222223
export * from './table/data/table-data-source';
223224
export * from './table/table.module';
224225
export * from './table/table.component';

projects/components/src/select/select.component.scss

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,7 @@
7878
.trigger-icon {
7979
padding: 0 8px;
8080
margin-left: auto;
81+
color: $gray-7;
8182
}
8283
}
8384
}

projects/components/src/select/select.component.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ import { SelectSize } from './select-size';
4444
<ht-icon *ngIf="this.icon" class="trigger-prefix-icon" [icon]="this.icon" size="${IconSize.Small}">
4545
</ht-icon>
4646
<ht-label class="trigger-label" [label]="selected?.label || this.placeholder"> </ht-label>
47-
<ht-icon class="trigger-icon" icon="${IconType.ChevronDown}" size="${IconSize.Small}"> </ht-icon>
47+
<ht-icon class="trigger-icon" icon="${IconType.ChevronDown}" size="${IconSize.ExtraSmall}"> </ht-icon>
4848
</div>
4949
</ht-popover-trigger>
5050
<ht-popover-content>
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
import { KeyValue } from '@angular/common';
2+
import { SelectOption } from '../../select/select-option';
3+
4+
export interface SelectFilter {
5+
placeholder?: string;
6+
options: SelectOption<KeyValue<string, unknown>>[];
7+
}
8+
9+
export interface SelectChange {
10+
select: SelectFilter;
11+
value: KeyValue<string, unknown>;
12+
}

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

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,12 @@
1+
import { KeyValue } from '@angular/common';
12
import { ChangeDetectionStrategy, Component, EventEmitter, Input, OnChanges, Output } from '@angular/core';
23
import { SubscriptionLifecycle, TypedSimpleChanges } from '@hypertrace/common';
34
import { isEmpty } from 'lodash-es';
45
import { Subject } from 'rxjs';
56
import { debounceTime } from 'rxjs/operators';
67
import { ToggleItem } from '../../toggle-group/toggle-item';
78
import { TableMode } from '../table-api';
9+
import { SelectChange, SelectFilter } from './table-controls-api';
810

911
@Component({
1012
selector: 'ht-table-controls',
@@ -23,6 +25,20 @@ import { TableMode } from '../table-api';
2325
(valueChange)="this.onSearchChange($event)"
2426
></ht-search-box>
2527
28+
<!-- Selects -->
29+
<ht-select
30+
*ngFor="let selectFilterItem of this.selectFilterItems"
31+
[placeholder]="selectFilterItem.placeholder"
32+
class="control select"
33+
(selectedChange)="this.onSelectChange(selectFilterItem, $event)"
34+
>
35+
<ht-select-option
36+
*ngFor="let option of selectFilterItem.options"
37+
[label]="option.label"
38+
[value]="option.value"
39+
></ht-select-option>
40+
</ht-select>
41+
2642
<!-- Filter Toggle -->
2743
<ht-toggle-group
2844
*ngIf="this.filterItemsEnabled"
@@ -60,6 +76,9 @@ export class TableControlsComponent implements OnChanges {
6076
@Input()
6177
public searchPlaceholder?: string = 'Search...';
6278

79+
@Input()
80+
public selectFilterItems?: SelectFilter[] = [];
81+
6382
@Input()
6483
public filterItems?: ToggleItem[] = [];
6584

@@ -79,6 +98,9 @@ export class TableControlsComponent implements OnChanges {
7998
@Input()
8099
public checkboxChecked?: boolean;
81100

101+
@Output()
102+
public readonly selectChange: EventEmitter<SelectChange> = new EventEmitter<SelectChange>();
103+
82104
@Output()
83105
public readonly checkboxCheckedChange: EventEmitter<boolean> = new EventEmitter<boolean>();
84106

@@ -137,6 +159,13 @@ export class TableControlsComponent implements OnChanges {
137159
}
138160
}
139161

162+
public onSelectChange(select: SelectFilter, keyValue: KeyValue<string, unknown>): void {
163+
this.selectChange.emit({
164+
select: select,
165+
value: keyValue
166+
});
167+
}
168+
140169
public onFilterChange(item: ToggleItem): void {
141170
this.filterChange.emit(item);
142171
}

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,13 @@ import { CommonModule } from '@angular/common';
22
import { NgModule } from '@angular/core';
33
import { TraceCheckboxModule } from '../../checkbox/checkbox.module';
44
import { TraceSearchBoxModule } from '../../search-box/search-box.module';
5+
import { SelectModule } from '../../select/select.module';
56
import { ToggleGroupModule } from '../../toggle-group/toggle-group.module';
67
import { TooltipModule } from '../../tooltip/tooltip.module';
78
import { TableControlsComponent } from './table-controls.component';
89

910
@NgModule({
10-
imports: [CommonModule, TooltipModule, TraceSearchBoxModule, ToggleGroupModule, TraceCheckboxModule],
11+
imports: [CommonModule, TooltipModule, TraceSearchBoxModule, ToggleGroupModule, TraceCheckboxModule, SelectModule],
1112
declarations: [TableControlsComponent],
1213
exports: [TableControlsComponent]
1314
})

projects/distributed-tracing/src/shared/dashboard/data/graphql/graphql-data-source.module.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ import { AttributeSpecificationModel } from './specifiers/attribute-specificatio
1313
import { CompositeSpecificationModel } from './specifiers/composite-specification.model';
1414
import { EnrichedAttributeSpecificationModel } from './specifiers/enriched-attribute-specification.model';
1515
import { FieldSpecificationModel } from './specifiers/field-specification.model';
16-
import { MappedAttributeSpecificationModel } from './specifiers/mapped-attribute-specification-model';
16+
import { MappedAttributeSpecificationModel } from './specifiers/mapped-attribute-specification.model';
1717
import { TraceStatusSpecificationModel } from './specifiers/trace-status-specification.model';
1818
import { SpansTableDataSourceModel } from './table/spans/spans-table-data-source.model';
1919
import { TracesTableDataSourceModel } from './table/traces/traces-table-data-source.model';

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

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ import { TableWidgetRowSelectionModel } from './selections/table-widget-row-sele
2121
import { TableWidgetCheckboxFilterModel } from './table-widget-checkbox-filter-model';
2222
import { SpecificationBackedTableColumnDef } from './table-widget-column.model';
2323
import { TableWidgetFilterModel } from './table-widget-filter-model';
24+
import { TableWidgetSelectFilterModel } from './table-widget-select-filter.model';
2425

2526
export abstract class TableWidgetBaseModel extends BaseModel {
2627
@ModelProperty({
@@ -62,6 +63,20 @@ export abstract class TableWidgetBaseModel extends BaseModel {
6263
})
6364
public filterOptions: TableWidgetFilterModel[] = [];
6465

66+
@ModelProperty({
67+
key: 'selectFilterOptions',
68+
displayName: 'Filter Select Options',
69+
// tslint:disable-next-line: no-object-literal-type-assertion
70+
type: {
71+
key: ARRAY_PROPERTY.type,
72+
subtype: {
73+
key: ModelPropertyType.TYPE,
74+
defaultModelClass: TableWidgetSelectFilterModel
75+
}
76+
} as ArrayPropertyTypeInstance
77+
})
78+
public selectFilterOptions: TableWidgetSelectFilterModel[] = [];
79+
6580
@ModelProperty({
6681
key: 'checkbox-filter-option',
6782
displayName: 'Checkbox Filter Option',
@@ -141,6 +156,10 @@ export abstract class TableWidgetBaseModel extends BaseModel {
141156
return this.checkboxFilterOption;
142157
}
143158

159+
public getSelectFilterOptions(): TableWidgetSelectFilterModel[] {
160+
return this.selectFilterOptions;
161+
}
162+
144163
public isPageable(): boolean {
145164
return this.pageable;
146165
}

0 commit comments

Comments
 (0)