Skip to content

feat: tag search or filter in explorer #1079

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 27 commits into from
Sep 1, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
8bf3da5
fix: donut chart fixes
itssharmasandeep Jul 13, 2021
5599c6a
Revert "fix: donut chart fixes"
itssharmasandeep Jul 13, 2021
88d3bd4
Merge branch 'main' of github.com:hypertrace/hypertrace-ui
itssharmasandeep Jul 15, 2021
cd18474
Merge branch 'main' of github.com:hypertrace/hypertrace-ui
itssharmasandeep Jul 19, 2021
2aa1a9b
Merge branch 'main' of github.com:hypertrace/hypertrace-ui
itssharmasandeep Jul 20, 2021
111e41d
Merge branch 'main' of github.com:hypertrace/hypertrace-ui
itssharmasandeep Jul 26, 2021
9b40fc4
Merge branch 'main' of github.com:hypertrace/hypertrace-ui
itssharmasandeep Jul 28, 2021
00b1e07
Merge branch 'main' of github.com:hypertrace/hypertrace-ui
itssharmasandeep Jul 29, 2021
f81b19d
Merge branch 'main' of github.com:hypertrace/hypertrace-ui
itssharmasandeep Jul 30, 2021
423dc6d
Merge branch 'main' of github.com:hypertrace/hypertrace-ui
itssharmasandeep Aug 9, 2021
9466514
Merge branch 'main' of github.com:hypertrace/hypertrace-ui
itssharmasandeep Aug 11, 2021
b2b04ba
Merge branch 'main' of github.com:hypertrace/hypertrace-ui
itssharmasandeep Aug 18, 2021
1e2e570
Merge remote-tracking branch 'origin/main'
itssharmasandeep Aug 19, 2021
403a9d4
Merge branch 'main' of github.com:hypertrace/hypertrace-ui
itssharmasandeep Aug 20, 2021
a74bd5d
Merge remote-tracking branch 'origin/main'
itssharmasandeep Aug 23, 2021
e67e48a
feat: tag search or filter in explorer
itssharmasandeep Aug 23, 2021
7f2e9c4
Merge remote-tracking branch 'origin/main' into tags-search
itssharmasandeep Aug 30, 2021
3487f87
fix: using template and existing filter link
itssharmasandeep Aug 30, 2021
ff921fa
fix: test errors
itssharmasandeep Aug 30, 2021
76ae62e
refactor: code
itssharmasandeep Aug 30, 2021
c016b25
fix: lint errors
itssharmasandeep Aug 30, 2021
3406b4a
Merge remote-tracking branch 'origin/main' into tags-search
itssharmasandeep Sep 1, 2021
c0395a8
fix: using renderer directive
itssharmasandeep Sep 1, 2021
7292585
fix: test cases
itssharmasandeep Sep 1, 2021
ae8177a
Merge remote-tracking branch 'origin/main' into tags-search
itssharmasandeep Sep 1, 2021
4ffe783
fix: addressing review comments
itssharmasandeep Sep 1, 2021
be39e5e
Merge remote-tracking branch 'origin/main' into tags-search
itssharmasandeep Sep 1, 2021
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
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import { Directive, TemplateRef } from '@angular/core';

@Directive({
selector: '[htListViewValueRenderer]'
})
export class ListViewValueRendererDirective {
public constructor(private readonly templateRef: TemplateRef<unknown>) {}

public getTemplateRef(): TemplateRef<unknown> {
return this.templateRef;
}
}
5 changes: 2 additions & 3 deletions projects/components/src/list-view/list-view.component.scss
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
@import 'font';
@import 'color-palette';
@import 'mixins';

$key-width: 40%;
$value-width: 60%;
$value-width: auto;
$horizontal-offset: 12px;

@mixin grid-view {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
import { CommonModule } from '@angular/common';
import { Component } from '@angular/core';
import { ComponentFixture, TestBed } from '@angular/core/testing';
import { NavigationService } from '@hypertrace/common';
import { mockProvider } from '@ngneat/spectator/jest';
import { ListViewComponent, ListViewHeader, ListViewRecord } from './list-view.component';

describe('List View Component', () => {
Expand Down Expand Up @@ -32,7 +34,8 @@ describe('List View Component', () => {
beforeEach(() => {
TestBed.configureTestingModule({
declarations: [TestHostComponent, ListViewComponent],
imports: [CommonModule]
imports: [CommonModule],
providers: [mockProvider(NavigationService)]
});

fixture = TestBed.createComponent(TestHostComponent);
Expand Down
17 changes: 14 additions & 3 deletions projects/components/src/list-view/list-view.component.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,13 @@
import { ChangeDetectionStrategy, Component, Input } from '@angular/core';

import { ChangeDetectionStrategy, Component, ContentChild, Input } from '@angular/core';
import { ListViewValueRendererDirective } from './list-view-value-renderer.directive';
@Component({
selector: 'ht-list-view',
styleUrls: ['./list-view.component.scss'],
changeDetection: ChangeDetectionStrategy.OnPush,
template: `
<ng-template #defaultValueRenderer let-record
><span>{{ record.value }}</span></ng-template
>
<div class="list-view">
<div *ngIf="this.header" class="header-row">
<div class="header-key-label">
Expand All @@ -19,7 +22,12 @@ import { ChangeDetectionStrategy, Component, Input } from '@angular/core';
<span>{{ record.key }}</span>
</div>
<div class="value">
<span>{{ record.value }}</span>
<ng-container
*ngTemplateOutlet="
this.valueRenderer ? this.valueRenderer!.getTemplateRef() : defaultValueRenderer;
context: { $implicit: record }
"
></ng-container>
</div>
</div>
</div>
Expand All @@ -31,6 +39,9 @@ export class ListViewComponent {

@Input()
public records?: ListViewRecord[];

@ContentChild(ListViewValueRendererDirective)
public valueRenderer?: ListViewValueRendererDirective;
}

export interface ListViewHeader {
Expand Down
5 changes: 3 additions & 2 deletions projects/components/src/list-view/list-view.module.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
import { CommonModule } from '@angular/common';
import { NgModule } from '@angular/core';
import { ListViewValueRendererDirective } from './list-view-value-renderer.directive';
import { ListViewComponent } from './list-view.component';

@NgModule({
declarations: [ListViewComponent],
exports: [ListViewComponent],
declarations: [ListViewComponent, ListViewValueRendererDirective],
exports: [ListViewComponent, ListViewValueRendererDirective],
imports: [CommonModule]
})
export class ListViewModule {}
4 changes: 2 additions & 2 deletions projects/components/src/public-api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -167,8 +167,8 @@ export * from './link/link.component';
export * from './link/link.module';

// List View
export { ListViewComponent, ListViewHeader, ListViewRecord } from './list-view/list-view.component';
export { ListViewModule } from './list-view/list-view.module';
export * from './list-view/list-view.component';
export * from './list-view/list-view.module';

// Load Async
export { LoadAsyncDirective } from './load-async/load-async.directive';
Expand Down
Original file line number Diff line number Diff line change
@@ -1,20 +1,14 @@
import { HttpClientTestingModule } from '@angular/common/http/testing';
import { fakeAsync } from '@angular/core/testing';
import { IconLibraryTestingModule } from '@hypertrace/assets-library';
import { NavigationService } from '@hypertrace/common';
import { createHostFactory, mockProvider, Spectator } from '@ngneat/spectator/jest';
import { createHostFactory, Spectator } from '@ngneat/spectator/jest';
import { SpanData } from './span-data';
import { SpanDetailComponent } from './span-detail.component';
import { SpanDetailModule } from './span-detail.module';

describe('Span detail component', () => {
let spectator: Spectator<SpanDetailComponent>;

const createHost = createHostFactory({
component: SpanDetailComponent,
imports: [SpanDetailModule, HttpClientTestingModule, IconLibraryTestingModule],
declareComponent: false,
providers: [mockProvider(NavigationService)]
shallow: true
});

test('should display child components', () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,19 @@
height: 100%;
width: 100%;
overflow: auto;

.tag-value {
width: 100%;
display: grid;
grid-template-columns: auto min-content;

.filter-link {
visibility: hidden;
margin-left: 12px;
}

&:hover .filter-link {
visibility: visible;
}
}
}
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import { CommonModule } from '@angular/common';
import { HttpClientTestingModule } from '@angular/common/http/testing';
import { createHostFactory, Spectator } from '@ngneat/spectator/jest';

import { MemoizeModule } from '@hypertrace/common';
import {
JsonViewerModule,
LabelModule,
Expand All @@ -10,6 +9,10 @@ import {
LoadAsyncModule,
ToggleButtonModule
} from '@hypertrace/components';
import { createHostFactory, mockProvider, Spectator } from '@ngneat/spectator/jest';
import { MockComponent } from 'ng-mocks';
import { ExplorerService } from '../../../../pages/explorer/explorer-service';
import { ExploreFilterLinkComponent } from '../../explore-filter-link/explore-filter-link.component';
import { SpanTagsDetailComponent } from './span-tags-detail.component';

describe('Span Tags Detail Component', () => {
Expand All @@ -24,8 +27,11 @@ describe('Span Tags Detail Component', () => {
JsonViewerModule,
LabelModule,
LoadAsyncModule,
HttpClientTestingModule
]
HttpClientTestingModule,
MemoizeModule
],
declarations: [MockComponent(ExploreFilterLinkComponent)],
providers: [mockProvider(ExplorerService)]
});

test('should display tag records', () => {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
import { ChangeDetectionStrategy, Component, Input, OnChanges } from '@angular/core';
import { Dictionary, TypedSimpleChanges } from '@hypertrace/common';
import { ListViewRecord } from '@hypertrace/components';
import { Dictionary, NavigationParams, TypedSimpleChanges } from '@hypertrace/common';
import { FilterOperator, ListViewRecord } from '@hypertrace/components';
import { isNil } from 'lodash-es';
import { EMPTY, Observable, of } from 'rxjs';
import { ExplorerService } from '../../../../pages/explorer/explorer-service';
import { ScopeQueryParam } from '../../../../pages/explorer/explorer.component';

@Component({
selector: 'ht-span-tags-detail',
Expand All @@ -11,7 +13,16 @@ import { EMPTY, Observable, of } from 'rxjs';
template: `
<div class="tags-details">
<ng-container *htLoadAsync="this.tagRecords$ as tagRecords">
<ht-list-view [records]="tagRecords" data-sensitive-pii></ht-list-view>
<ht-list-view [records]="tagRecords" data-sensitive-pii
><div class="tag-value" *htListViewValueRenderer="let record">
<div class="value">{{ record.value }}</div>
<ht-explore-filter-link
class="filter-link"
[paramsOrUrl]="this.getExploreNavigationParams | htMemoize: record | async"
htTooltip="See traces in Explorer"
>
</ht-explore-filter-link></div
></ht-list-view>
</ng-container>
</div>
`
Expand All @@ -22,12 +33,19 @@ export class SpanTagsDetailComponent implements OnChanges {

public tagRecords$?: Observable<ListViewRecord[]>;

public constructor(private readonly explorerService: ExplorerService) {}

public ngOnChanges(changes: TypedSimpleChanges<this>): void {
if (changes.tags && this.tags) {
this.buildTagRecords();
}
}

public getExploreNavigationParams = (tag: ListViewRecord): Observable<NavigationParams> =>
this.explorerService.buildNavParamsWithFilters(ScopeQueryParam.EndpointTraces, [
{ field: 'tags', operator: FilterOperator.ContainsKeyValue, value: [tag.key, tag.value] }
]);

private buildTagRecords(): void {
if (isNil(this.tags)) {
this.tagRecords$ = EMPTY;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,21 @@
import { CommonModule } from '@angular/common';
import { NgModule } from '@angular/core';

import { LabelModule, ListViewModule, LoadAsyncModule } from '@hypertrace/components';
import { MemoizeModule } from '@hypertrace/common';
import { LabelModule, ListViewModule, LoadAsyncModule, TooltipModule } from '@hypertrace/components';
import { ExploreFilterLinkModule } from '../../explore-filter-link/explore-filter-link.module';
import { SpanTagsDetailComponent } from './span-tags-detail.component';

@NgModule({
imports: [CommonModule, ListViewModule, LabelModule, LoadAsyncModule],
imports: [
CommonModule,
ExploreFilterLinkModule,
ListViewModule,
LabelModule,
LoadAsyncModule,
MemoizeModule,
TooltipModule
],
declarations: [SpanTagsDetailComponent],
exports: [SpanTagsDetailComponent]
})
Expand Down