-
Notifications
You must be signed in to change notification settings - Fork 11
Page level time range #1441
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
Page level time range #1441
Changes from 3 commits
dd20f13
a8523ab
4bfa6d6
63a665e
b81ae1a
6e84fbe
ab466fe
3043f45
56c574b
c1be553
8eb3a52
ffe3d6b
3f98a99
f0d9ffe
e1bea69
b359fcd
ab36992
cd870bc
7a92d50
b241e0e
7e279e4
10e8225
1738b10
c44b03b
bd1cbbd
3adc661
6e78e54
c225cf9
c2d0287
7bc71c7
b4b4722
a528987
63c4bd0
8742a2b
b795d39
9ed2b22
67c8bfe
0854000
62d1041
5037200
11b0991
50153f9
12ab84d
ea6357a
b558d41
0989a6a
3845357
a37a477
00f785a
82a9612
9714df8
4b0b74e
44a67b6
bfcb9b8
38c5e82
efd4d15
5e5dcf5
7172091
505d5d7
748743e
09cf639
5c0cfe6
541555f
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,7 +1,7 @@ | ||
| import { ChangeDetectionStrategy, Component, EventEmitter, Input, OnChanges, Output } from '@angular/core'; | ||
| import { ActivatedRoute } from '@angular/router'; | ||
| import { IconType } from '@hypertrace/assets-library'; | ||
| import { NavigationService, TimeRangeService, TypedSimpleChanges } from '@hypertrace/common'; | ||
| import { NavigationService, TypedSimpleChanges } from '@hypertrace/common'; | ||
| import { Observable } from 'rxjs'; | ||
| import { map, startWith } from 'rxjs/operators'; | ||
| import { IconSize } from '../icon/icon-size'; | ||
|
|
@@ -76,28 +76,26 @@ export class NavigationListComponent implements OnChanges { | |
| @Output() | ||
| public readonly navItemSelected: EventEmitter<NavItemLinkConfig> = new EventEmitter(); | ||
|
|
||
| @Output() | ||
| public readonly activeItemChange: EventEmitter<NavItemLinkConfig> = new EventEmitter(); | ||
|
|
||
| public activeItem$?: Observable<NavItemLinkConfig | undefined>; | ||
|
|
||
| public constructor( | ||
| private readonly navigationService: NavigationService, | ||
| private readonly activatedRoute: ActivatedRoute, | ||
| private readonly navListComponentService: NavigationListComponentService, | ||
| private readonly timeRangeService: TimeRangeService | ||
| private readonly navListComponentService: NavigationListComponentService | ||
| ) {} | ||
|
|
||
| public ngOnChanges(changes: TypedSimpleChanges<this>): void { | ||
| if (changes.navItems) { | ||
| this.navItems = this.navListComponentService.resolveFeaturesAndUpdateVisibilityForNavItems(this.navItems); | ||
|
|
||
| // Initialize the time range service | ||
| // Depending on FF status, the TR will be either global or page level for the init | ||
| this.activeItem$ = this.navigationService.navigation$.pipe( | ||
| startWith(this.navigationService.getCurrentActivatedRoute()), | ||
| map(() => { | ||
| const activeItem = this.findActiveItem(this.navItems); | ||
| if (!this.timeRangeService.isInitialized() && activeItem?.timeRangeResolver) { | ||
| this.timeRangeService.setDefaultTimeRange(activeItem.timeRangeResolver()); | ||
| } | ||
| this.activeItemChange.emit(activeItem); | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'm ok with it but would be remiss not to point out - we're using this observable for side effects. If we happened to not read activeItem$ in this component because we didn't need to use it for our own template, it would create a bug where we also stopped emitting. The alternative however is also not great, since it means we need to subscribe in the component and handle unsubscribing on destroy.
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yeah fair concern, i've made a code comment about it for anyone that sees this in the future. |
||
|
|
||
| return activeItem; | ||
| }) | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,7 +1,8 @@ | ||
| import { ChangeDetectionStrategy, Component, OnInit } from '@angular/core'; | ||
| import { IconType } from '@hypertrace/assets-library'; | ||
| import { LayoutChangeService } from '@hypertrace/common'; | ||
| import { LayoutChangeService, TimeRange, TimeRangeService } from '@hypertrace/common'; | ||
| import { IconSize } from '@hypertrace/components'; | ||
| import { Observable } from 'rxjs'; | ||
| import { UserTelemetryOrchestrationService } from '../shared/telemetry/user-telemetry-orchestration.service'; | ||
| @Component({ | ||
| selector: 'ht-application-frame', | ||
|
|
@@ -16,14 +17,21 @@ import { UserTelemetryOrchestrationService } from '../shared/telemetry/user-tele | |
| </ht-application-header> | ||
| <div class="app-body"> | ||
| <ht-navigation class="left-nav"></ht-navigation> | ||
| <div class="app-content"> | ||
| <div class="app-content" *ngIf="this.timeRangeHasInit$ | async"> | ||
| <router-outlet></router-outlet> | ||
| </div> | ||
| </div> | ||
| ` | ||
| }) | ||
| export class ApplicationFrameComponent implements OnInit { | ||
| public constructor(private readonly userTelemetryOrchestrationService: UserTelemetryOrchestrationService) {} | ||
| public readonly timeRangeHasInit$: Observable<TimeRange>; | ||
|
|
||
| public constructor( | ||
| private readonly userTelemetryOrchestrationService: UserTelemetryOrchestrationService, | ||
| private readonly timeRangeService: TimeRangeService | ||
| ) { | ||
| this.timeRangeHasInit$ = this.timeRangeService.getTimeRangeAndChanges(); | ||
|
||
| } | ||
|
|
||
| public ngOnInit(): void { | ||
| this.userTelemetryOrchestrationService.initialize(); | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.