Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions projects/components/src/summary-list/summary-list-api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,5 @@ import { PrimitiveValue } from '@hypertrace/common';
export interface SummaryItem {
label: string;
value: PrimitiveValue | PrimitiveValue[];
clickable?: boolean;
}
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,10 @@
@include body-2-regular($gray-7);
padding-top: 3px;

&.clickable {
@include link();
}

&:first-child {
padding-top: 6px;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ describe('Summary List component', () => {
});

test('gets value array', () => {
const values = spectator.queryAll('li').map(e => e.textContent);
const values = spectator.queryAll('li').map(e => e.textContent?.trim());
expect(values).toEqual(['0', '0', '1', '2', 'zero', 'zero', 'one', 'two', 'three', 'true', 'true', 'false']);
});
});
18 changes: 16 additions & 2 deletions projects/components/src/summary-list/summary-list.component.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { ChangeDetectionStrategy, Component, Input } from '@angular/core';
import { ChangeDetectionStrategy, Component, EventEmitter, Input, Output } from '@angular/core';
import { IconType } from '@hypertrace/assets-library';
import { PrimitiveValue } from '@hypertrace/common';
import { startCase } from 'lodash-es';
Expand All @@ -18,7 +18,14 @@ import { SummaryItem } from './summary-list-api';
<ht-label class="summary-value-title" [label]="this.getFormattedLabel(item.label)"></ht-label>
<ul class="summary-value-list">
<li class="summary-value" *ngIf="this.getValuesArray(item.value).length === 0">None</li>
<li class="summary-value" *ngFor="let value of this.getValuesArray(item.value)">{{ value }}</li>
<li
class="summary-value"
[class.clickable]="item.clickable"
*ngFor="let value of this.getValuesArray(item.value)"
(click)="this.onItemCLick(item)"
>
{{ value }}
</li>
</ul>
</ng-container>
</div>
Expand All @@ -34,11 +41,18 @@ export class SummaryListComponent {
@Input()
public items?: SummaryItem[] = [];

@Output()
public readonly itemClick: EventEmitter<SummaryItem> = new EventEmitter();

public getFormattedLabel(label: string): string {
return startCase(label.toLowerCase());
}

public getValuesArray(value: PrimitiveValue | PrimitiveValue[]): PrimitiveValue[] {
return Array.isArray(value) ? value : [value];
}

public onItemCLick(item: SummaryItem): void {
item.clickable && this.itemClick.emit(item);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ import { CheckboxChange, CheckboxControl, SelectChange, SelectControl, TableCont
<ht-search-box
*ngIf="this.searchEnabled"
class="control search-box"
[placeholder]="this.searchPlaceholder"
[placeholder]="this.searchPlaceholder || this.DEFAULT_SEARCH_PLACEHOLDER"
(valueChange)="this.onSearchChange($event)"
></ht-search-box>

Expand Down Expand Up @@ -85,11 +85,12 @@ import { CheckboxChange, CheckboxControl, SelectChange, SelectControl, TableCont
`
})
export class TableControlsComponent implements OnChanges {
public readonly DEFAULT_SEARCH_PLACEHOLDER: string = 'Search...';
@Input()
public searchEnabled?: boolean;

@Input()
public searchPlaceholder?: string = 'Search...';
public searchPlaceholder?: string;

@Input()
public selectControls?: SelectControl[] = [];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,13 @@ export abstract class TableWidgetBaseModel extends BaseModel {
})
public searchAttribute?: string;

@ModelProperty({
key: 'search-placeholder',
displayName: 'Search Placeholder',
type: STRING_PROPERTY.type
})
public searchPlaceholder?: string;

@ModelProperty({
key: 'select-control-options',
displayName: 'Select Options',
Expand Down Expand Up @@ -139,6 +146,10 @@ export abstract class TableWidgetBaseModel extends BaseModel {
return this.searchAttribute;
}

public getSearchPlaceholder(): string | undefined {
return this.searchPlaceholder;
}

public getSelectControlOptions(): TableWidgetControlSelectOptionModel[] {
return this.selectOptions;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ import { TableWidgetModel } from './table-widget.model';
<ht-table-controls
class="table-controls"
[searchEnabled]="!!this.api.model.getSearchAttribute()"
[searchPlaceholder]="this.api.model.getSearchPlaceholder()"
[selectControls]="this.selectControls$ | async"
[checkboxControls]="this.checkboxControls$ | async"
[viewItems]="this.viewItems"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,10 @@ export class TableWidgetViewToggleModel extends TableWidgetModel implements Mode
return this.delegateModel?.getSearchAttribute() ?? this.searchAttribute;
}

public getSearchPlaceholder(): string | undefined {
return this.delegateModel?.getSearchPlaceholder() ?? this.searchPlaceholder;
}

public getCheckboxControlOptions(): TableWidgetControlCheckboxOptionModel[] {
return this.delegateModel?.getCheckboxControlOptions() ?? this.checkboxOptions;
}
Expand Down