@@ -18,7 +18,7 @@ interface PanelState {
1818 controller : ServiceDependencyGraphPanelController ;
1919 cy ?: cytoscape . Core | undefined ;
2020 graphCanvas ?: CanvasDrawer | undefined ;
21- animateButton ?: string ;
21+ animateButtonClass ?: string ,
2222 showStatistics : boolean ;
2323 data : any ;
2424}
@@ -45,15 +45,23 @@ export class ServiceDependencyGraph extends PureComponent<PanelState, PanelState
4545
4646 initResize = true ;
4747
48- constructor ( props : PanelState ) {
49- super ( props ) ;
50- this . state = {
51- ...props ,
52- animateButton : 'fa fa-play-circle' ,
53- showStatistics : false ,
54- } ;
55- this . ref = React . createRef ( ) ;
56- this . templateSrv = getTemplateSrv ( ) ;
48+ constructor ( props : PanelState ) {
49+ super ( props ) ;
50+
51+ var animateButtonClass = "fa fa-play-circle" ;
52+ if ( props . animate ) {
53+ animateButtonClass = "fa fa-pause-circle" ;
54+ }
55+
56+ this . state = {
57+ ...props ,
58+ showStatistics : false ,
59+ animateButtonClass : animateButtonClass ,
60+ animate : false
61+ } ;
62+
63+ this . ref = React . createRef ( ) ;
64+ this . templateSrv = getTemplateSrv ( ) ;
5765 }
5866
5967 componentDidMount ( ) {
@@ -210,19 +218,18 @@ export class ServiceDependencyGraph extends PureComponent<PanelState, PanelState
210218 }
211219
212220 toggleAnimation ( ) {
213- this . props . controller . state . options . animate = ! this . state . controller . state . options . animate ;
214-
215- if ( this . state . controller . state . options . animate ) {
221+ var newValue = ! this . state . animate
222+ var animateButtonClass = "fa fa-play-circle"
223+ if ( newValue ) {
216224 this . state . graphCanvas . startAnimation ( ) ;
217- this . setState ( {
218- animateButton : 'fa fa-pause-circle' ,
219- } ) ;
225+ animateButtonClass = "fa fa-pause-circle"
220226 } else {
221227 this . state . graphCanvas . stopAnimation ( ) ;
222- this . setState ( {
223- animateButton : 'fa fa-play-circle' ,
224- } ) ;
225228 }
229+ this . setState ( {
230+ animate : newValue ,
231+ animateButtonClass : animateButtonClass
232+ } ) ;
226233 }
227234
228235 runLayout ( unlockNodes = false ) {
@@ -268,7 +275,6 @@ export class ServiceDependencyGraph extends PureComponent<PanelState, PanelState
268275 zoom : zoomLevel ,
269276 } ) ;
270277 this . state . cy . zoom ( zoomLevel ) ;
271- this . state . cy . center ( )
272278 }
273279
274280 updateStatisticTable ( ) {
@@ -366,42 +372,38 @@ export class ServiceDependencyGraph extends PureComponent<PanelState, PanelState
366372 this . _updateGraph ( this . props . data ) ;
367373 }
368374 return (
369- < div className = "graph-container" ng-show = "!ctrl.getError()" >
370- < div className = "service-dependency-graph" >
371- < div
372- className = "canvas-container"
373- ref = { ref => ( this . ref = ref ) }
374- style = { { height : '100%' , width : '100%' } }
375- > </ div >
376- < div className = "zoom-button-container" >
377- < button className = "btn navbar-button width-100" onClick = { ( ) => this . toggleAnimation ( ) } >
378- < i className = { this . state . animateButton } > </ i >
379- </ button >
380- < button className = "btn navbar-button width-100" onClick = { ( ) => this . runLayout ( ) } >
381- < i className = "fa fa-sitemap" > </ i >
382- </ button >
383- < button className = "btn navbar-button width-100" onClick = { ( ) => this . fit ( ) } >
384- < i className = "fa fa-dot-circle-o" > </ i >
385- </ button >
386- < button className = "btn navbar-button width-100" onClick = { ( ) => this . zoom ( + 1 ) } >
387- < i className = "fa fa-plus" > </ i >
388- </ button >
389- < button className = "btn navbar-button width-100" onClick = { ( ) => this . zoom ( - 1 ) } >
390- < i className = "fa fa-minus" > </ i >
391- </ button >
392- </ div >
375+ < div className = "graph-container" >
376+ < div className = "service-dependency-graph" >
377+ < div className = "canvas-container" ref = { ref => this . ref = ref } >
378+
379+ </ div >
380+ < div className = "zoom-button-container" >
381+ < button className = "btn navbar-button width-100" onClick = { ( ) => this . toggleAnimation ( ) } >
382+ < i className = { this . state . animateButtonClass } > </ i >
383+ </ button >
384+ < button className = "btn navbar-button width-100" onClick = { ( ) => this . runLayout ( ) } >
385+ < i className = "fa fa-sitemap" > </ i >
386+ </ button >
387+ < button className = "btn navbar-button width-100" onClick = { ( ) => this . fit ( ) } >
388+ < i className = "fa fa-dot-circle-o" > </ i >
389+ </ button >
390+ < button className = "btn navbar-button width-100" onClick = { ( ) => this . zoom ( + 1 ) } >
391+ < i className = "fa fa-plus" > </ i >
392+ </ button >
393+ < button className = "btn navbar-button width-100" onClick = { ( ) => this . zoom ( - 1 ) } >
394+ < i className = "fa fa-minus" > </ i >
395+ </ button >
396+ </ div >
397+ </ div >
398+ < Statistics show = { this . state . showStatistics }
399+ selectionId = { this . selectionId }
400+ resolvedDrillDownLink = { this . resolvedDrillDownLink }
401+ selectionStatistics = { this . selectionStatistics }
402+ currentType = { this . currentType }
403+ showBaselines = { false }
404+ receiving = { this . receiving }
405+ sending = { this . sending } />
393406 </ div >
394- < Statistics
395- show = { this . state . showStatistics }
396- selectionId = { this . selectionId }
397- resolvedDrillDownLink = { this . resolvedDrillDownLink }
398- selectionStatistics = { this . selectionStatistics }
399- currentType = { this . currentType }
400- showBaselines = { false }
401- receiving = { this . receiving }
402- sending = { this . sending }
403- />
404- </ div >
405407 ) ;
406408 }
407409}
0 commit comments