@@ -12,7 +12,7 @@ import DataPointType from '../model/dataPointType';
1212
1313export default class DevToolsView extends esp . model . DisposableBase {
1414
15- constructor ( router ) {
15+ constructor ( modelId , router ) {
1616 super ( ) ;
1717 this . _router = router ;
1818 this . _timelineGroups = new vis . DataSet ( ) ;
@@ -23,16 +23,19 @@ export default class DevToolsView extends esp.model.DisposableBase {
2323 this . _logEventsConsoleCheckbox = null ;
2424 this . _resetChartButton = null ;
2525 this . _closeButton = null ;
26+ this . _ringBufferSizeInput = null ;
2627 this . _eventDetailsDescriptionP = null ;
2728 this . _footer = null ;
29+ this . _modelId = modelId ;
2830 }
2931
3032 start ( ) {
3133 this . _createDevToolsElements ( ) ;
34+ let isStateOfTheWorld = true ;
3235 this . addDisposable (
33- this . _router . getModelObservable ( )
36+ this . _router . getModelObservable ( this . _modelId )
3437 . observe ( model => {
35- if ( model . updateType . indexOf ( UpdateType . modelsChanged ) >= 0 ) {
38+ if ( isStateOfTheWorld || model . updateType . indexOf ( UpdateType . modelsChanged ) >= 0 ) {
3639 for ( let i = 0 ; i < model . registeredModels . length ; i ++ ) {
3740 let registeredModel = model . registeredModels [ i ] ;
3841 let groupStyle = registeredModel . isHalted
@@ -45,9 +48,12 @@ export default class DevToolsView extends esp.model.DisposableBase {
4548 } ) ;
4649 }
4750 }
48- if ( model . updateType . indexOf ( UpdateType . eventsChanged ) >= 0 ) {
49- for ( var i = 0 ; i < model . newDataPoints . length ; i ++ ) {
50- var dataPoint = model . newDataPoints [ i ] ;
51+ if ( isStateOfTheWorld || model . updateType . indexOf ( UpdateType . eventsChanged ) >= 0 ) {
52+ let points = isStateOfTheWorld
53+ ? model . dataPoints
54+ : model . newDataPoints ;
55+ for ( var i = 0 ; i < points . length ; i ++ ) {
56+ var dataPoint = points [ i ] ;
5157 let pointStyle = dataPoint . pointType == DataPointType . routerHalted
5258 ? 'background:red'
5359 : '' ;
@@ -78,8 +84,12 @@ export default class DevToolsView extends esp.model.DisposableBase {
7884 if ( this . _eventDetailsDescriptionP && model . selectedDataPoint ) {
7985 this . _eventDetailsDescriptionP . html ( JSON . stringify ( model . selectedDataPoint ) ) ;
8086 }
87+ if ( this . _ringBufferSizeInput && ! this . _ringBufferSizeInput . is ( ":focus" ) ) {
88+ this . _ringBufferSizeInput . val ( model . dataPointBufferSize ) ;
89+ }
8190 this . _footer . html ( `Total events: ${ model . processedDataPointCount } ` ) ;
8291 }
92+ isStateOfTheWorld = false ;
8393 } )
8494 ) ;
8595 }
@@ -91,37 +101,43 @@ export default class DevToolsView extends esp.model.DisposableBase {
91101 // note use of function so 'this' is the checkbox
92102 this . _autoscrollCheckbox = container . find ( '#autoscrollCheckbox' ) ;
93103 this . _autoscrollCheckbox . change ( function ( ) {
94- _this . _router . publishEvent ( 'autoscrollToggled' , { shouldAutoScroll : this . checked } ) ;
104+ _this . _router . publishEvent ( _this . _modelId , 'autoscrollToggled' , { shouldAutoScroll : this . checked } ) ;
95105 } ) ;
96106 this . addDisposable ( ( ) => { this . _autoscrollCheckbox . off ( ) ; } ) ;
97107
98108 this . _captureEventsCheckbox = container . find ( '#captureEvents' ) ;
99109 this . _captureEventsCheckbox . change ( function ( ) {
100- _this . _router . publishEvent ( 'captureEventsToggled' , { shouldCaptureEvents : this . checked } ) ;
110+ _this . _router . publishEvent ( _this . _modelId , 'captureEventsToggled' , { shouldCaptureEvents : this . checked } ) ;
101111 } ) ;
102112 this . addDisposable ( ( ) => { this . _captureEventsCheckbox . off ( ) ; } ) ;
103113
104114 this . _logEventsConsoleCheckbox = container . find ( '#logEventsConsole' ) ;
105115 this . _logEventsConsoleCheckbox . change ( function ( ) {
106- _this . _router . publishEvent ( 'logEventsConsoleToggled' , { shouldLogToConsole : this . checked } ) ;
116+ _this . _router . publishEvent ( _this . _modelId , 'logEventsConsoleToggled' , { shouldLogToConsole : this . checked } ) ;
107117 } ) ;
108118 this . addDisposable ( ( ) => { this . _logEventsConsoleCheckbox . off ( ) ; } ) ;
109119
110120 this . _resetChartButton = container . find ( '#resetChart' ) ;
111121 this . _resetChartButton . click ( function ( ) {
112- _this . _router . publishEvent ( 'resetChart' , { } ) ;
122+ _this . _router . publishEvent ( _this . _modelId , 'resetChart' , { } ) ;
113123 } ) ;
114124 this . addDisposable ( ( ) => { this . _resetChartButton . off ( ) ; } ) ;
115125
116126 this . _closeButton = container . find ( '#closeButton' ) ;
117127 this . _closeButton . click ( function ( ) {
118- _this . _router . publishEvent ( 'close' , { } ) ;
128+ _this . dispose ( ) ;
119129 } ) ;
120130 this . addDisposable ( ( ) => { this . _closeButton . off ( ) ; } ) ;
121131
122132 this . _eventDetailsDescriptionP = container . find ( '#eventDetailsDescription' ) ;
123133 this . _footer = container . find ( '#footer' ) ;
124134
135+ this . _ringBufferSizeInput = container . find ( '#ringBufferSize' ) ;
136+ this . _ringBufferSizeInput . change ( function ( ) {
137+ _this . _router . publishEvent ( _this . _modelId , 'ringBufferSizeInputChanged' , this . value ) ;
138+ } ) ;
139+ this . addDisposable ( ( ) => { this . _ringBufferSizeInput . off ( ) ; } ) ;
140+
125141 let chartContainer = container . find ( '#chartContainer' ) ;
126142 let options = {
127143 groupOrder : 'content' ,
@@ -158,6 +174,7 @@ export default class DevToolsView extends esp.model.DisposableBase {
158174 timeline . on ( 'select' , properties => {
159175 let pointId = properties . items [ 0 ] ;
160176 this . _router . publishEvent (
177+ this . _modelId ,
161178 'pointSelected' , {
162179 pointId : pointId
163180 }
@@ -178,6 +195,6 @@ export default class DevToolsView extends esp.model.DisposableBase {
178195 }
179196
180197 _disableAutoScroll ( ) {
181- this . _router . publishEvent ( 'disableAutoScroll' , { } ) ;
198+ this . _router . publishEvent ( this . _modelId , 'disableAutoScroll' , { } ) ;
182199 }
183200}
0 commit comments