11import { ChangeDetectionStrategy , Component , EventEmitter , Input , OnChanges , Output } from '@angular/core' ;
2- import { TypedSimpleChanges } from '@hypertrace/common' ;
2+ import { Dictionary , TypedSimpleChanges } from '@hypertrace/common' ;
33import { Filter } from '@hypertrace/components' ;
44import { DashboardPersistenceService } from '@hypertrace/dashboards' ;
55import { Dashboard , ModelJson } from '@hypertrace/hyperdash' ;
@@ -37,10 +37,13 @@ import { GraphQlFilterDataSourceModel } from '../data/graphql/filter/graphql-fil
3737} )
3838export class NavigableDashboardComponent implements OnChanges {
3939 @Input ( )
40- public readonly defaultJson ?: ModelJson ;
40+ public navLocation ?: string | null ;
4141
4242 @Input ( )
43- public navLocation ?: string | null ;
43+ public defaultJson ?: ModelJson ;
44+
45+ @Input ( )
46+ public variables ?: Dictionary < unknown > ;
4447
4548 @Input ( )
4649 public filterConfig ?: NavigableDashboardFilterConfig ;
@@ -89,6 +92,7 @@ export class NavigableDashboardComponent implements OnChanges {
8992
9093 public onDashboardReady ( dashboard : Dashboard ) : void {
9194 this . dashboard = dashboard ;
95+ this . applyVariablesToDashboard ( this . dashboard , this . variables ) ;
9296 this . applyFiltersToDashboard ( dashboard , this . explicitFilters ) ;
9397 this . dashboardReady . emit ( dashboard ) ;
9498 }
@@ -100,6 +104,12 @@ export class NavigableDashboardComponent implements OnChanges {
100104 }
101105 }
102106
107+ public applyVariablesToDashboard ( dashboard : Dashboard , variables : Dictionary < unknown > = { } ) : void {
108+ for ( const key of Object . keys ( variables ) ) {
109+ dashboard . setVariable ( key , variables [ key ] ) ;
110+ }
111+ }
112+
103113 public applyFiltersToDashboard ( dashboard : Dashboard , explicitFilters : Filter [ ] ) : void {
104114 const rootDataSource = dashboard . getRootDataSource < GraphQlFilterDataSourceModel > ( ) ;
105115 rootDataSource
0 commit comments