diff --git a/projects/observability/src/shared/components/explore-query-editor/explore-query-editor.component.ts b/projects/observability/src/shared/components/explore-query-editor/explore-query-editor.component.ts index dbb4607e9..9e6ee13d5 100644 --- a/projects/observability/src/shared/components/explore-query-editor/explore-query-editor.component.ts +++ b/projects/observability/src/shared/components/explore-query-editor/explore-query-editor.component.ts @@ -4,6 +4,7 @@ import { Filter } from '@hypertrace/components'; import { Observable } from 'rxjs'; import { AttributeExpression } from '../../graphql/model/attribute/attribute-expression'; import { GraphQlGroupBy } from '../../graphql/model/schema/groupby/graphql-group-by'; +import { GraphQlSortDirection } from '../../graphql/model/schema/sort/graphql-sort-direction'; import { IntervalValue } from '../interval-select/interval-select.component'; import { ExploreRequestContext, @@ -37,6 +38,7 @@ import { [interval]="currentVisualization.interval" (intervalChange)="this.setInterval($event)" > + + + +
+ Order +
+ + + +
+
+ + ` +}) +export class ExploreQueryOrderByEditorComponent { + @Output() + public readonly orderByDirectionChange: EventEmitter = new EventEmitter(); + + public readonly orderOptions: SelectOption[] = this.getOrderByOptions(); + private readonly orderByExpressionsToEmit: Subject = new Subject(); + + public readonly currentOrderOption: string | undefined = this.orderOptions[0].value; + + public constructor() { + this.orderByExpressionsToEmit.pipe(debounceTime(500)).subscribe(this.orderByDirectionChange); + } + + public onOrderByDirectionChange(newDirection?: GraphQlSortDirection): void { + this.orderByExpressionsToEmit.next(newDirection); + } + + private getOrderByOptions(): SelectOption[] { + return [ + this.getEmptyOrderByOption(), + ...['Asc', 'Desc'].map(order => ({ + label: order, + value: order.toUpperCase() + })) + ]; + } + + private getEmptyOrderByOption(): SelectOption { + return { + value: undefined, + label: 'None' + }; + } +}