Skip to content
Merged
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import {
} from '@angular/core';
import { IconType } from '@hypertrace/assets-library';
import { TypedSimpleChanges } from '@hypertrace/common';
import { isEqual } from 'lodash-es';
import { IconSize } from '../../icon/icon-size';
import { MultiSelectJustify } from '../../multi-select/multi-select-justify';
import { MultiSelectSearchMode, TriggerLabelDisplayMode } from '../../multi-select/multi-select.component';
Expand Down Expand Up @@ -101,6 +102,8 @@ import {
})
export class TableControlsComponent implements OnChanges {
public readonly DEFAULT_SEARCH_PLACEHOLDER: string = 'Search...';
@Input()
public persistenceId?: string;

@Input()
public searchEnabled?: boolean;
Expand Down Expand Up @@ -207,7 +210,7 @@ export class TableControlsComponent implements OnChanges {

private setActiveViewItem(): void {
if (this.viewItems !== undefined) {
this.activeViewItem = this.viewItems.find(item => item === this.activeViewItem) ?? this.viewItems[0];
this.activeViewItem = this.findViewItem(this.activeViewItem);
}
}

Expand Down Expand Up @@ -259,4 +262,8 @@ export class TableControlsComponent implements OnChanges {
public onViewChange(item: ToggleItem<string>): void {
this.viewChange.emit(item.value);
}

private findViewItem(viewItem?: ToggleItem): ToggleItem | undefined {
return this.viewItems?.find(item => isEqual(item, viewItem)) ?? this.viewItems![0];
}
}
4 changes: 4 additions & 0 deletions projects/dashboards/src/widgets/base.model.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,8 @@ export abstract class BaseModel {
type: STRING_PROPERTY.type
})
public id?: string;

public getId(): string | undefined {
return this.id;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,13 @@ import { TableWidgetControlCheckboxOptionModel } from './table-widget-control-ch
import { TableWidgetControlSelectOptionModel } from './table-widget-control-select-option.model';

export abstract class TableWidgetBaseModel extends BaseModel {
@ModelProperty({
key: 'viewId',
displayName: 'Model View ID',
type: STRING_PROPERTY.type
})
public viewId?: string;

@ModelProperty({
// tslint:disable-next-line: no-object-literal-type-assertion
type: {
Expand Down Expand Up @@ -126,6 +133,11 @@ export abstract class TableWidgetBaseModel extends BaseModel {
return [];
}

public getViewId(): string | undefined {
// No-op here, but can be overridden
return this.viewId;
}

public setView(_view: string): void {
// No-op here, but can be overridden
return;
Expand Down
Loading