1- import './devToolsView.less'
2-
31import $ from 'jquery' ;
42import "jquery-ui/draggable" ;
5-
63import esp from 'esp-js' ;
74import _ from 'lodash' ;
85import moment from 'moment' ;
96import vis from 'vis' ;
107import 'vis/dist/vis.css' ;
11- import UpdateType from './updateType' ;
8+ import './devToolsView.less'
9+ import UpdateType from '../model/updateType' ;
1210import template from './devToolsView.template.html' ;
1311
1412export default class DevToolsView extends esp . model . DisposableBase {
@@ -23,6 +21,7 @@ export default class DevToolsView extends esp.model.DisposableBase {
2321 this . _captureEventsCheckbox = null ;
2422 this . _logEventsConsoleCheckbox = null ;
2523 this . _resetChartButton = null ;
24+ this . _closeButton = null ;
2625 this . _eventDetailsDescriptionP = null ;
2726 this . _footer = null ;
2827 }
@@ -37,16 +36,15 @@ export default class DevToolsView extends esp.model.DisposableBase {
3736 var registeredModel = model . registeredModels [ i ] ;
3837 this . _timelineGroups . update ( {
3938 id : registeredModel . modelId ,
40- content : `Model id <span style="color:#97B0F8;">[ ${ registeredModel . modelId } ]</span>`
39+ content : registeredModel . modelId
4140 } ) ;
4241 }
4342 } else if ( model . updateType === UpdateType . eventsChanged ) {
4443 this . _timelineData . add ( {
4544 id : model . lastEvent . eventNumber ,
4645 group : model . lastEvent . modelId ,
4746 title : model . lastEvent . eventType ,
48- start : model . lastEvent . publishedTime ,
49- className : 'eventDot'
47+ start : model . lastEvent . publishedTime
5048 } ) ;
5149 } else if ( model . updateType === UpdateType . reset ) {
5250 this . _timelineGroups . clear ( ) ;
@@ -70,28 +68,42 @@ export default class DevToolsView extends esp.model.DisposableBase {
7068 } )
7169 ) ;
7270 }
73-
7471 _createDevToolsElements ( ) {
7572 let _this = this ;
7673 $ ( ( ) => {
7774 let container = $ ( template ) ;
75+
7876 // note use of function so 'this' is the checkbox
7977 this . _autoscrollCheckbox = container . find ( '#autoscrollCheckbox' ) ;
8078 this . _autoscrollCheckbox . change ( function ( ) {
8179 _this . _router . publishEvent ( 'autoscrollToggled' , { shouldAutoScroll : this . checked } ) ;
8280 } ) ;
81+ this . addDisposable ( ( ) => { this . _autoscrollCheckbox . off ( ) ; } ) ;
82+
8383 this . _captureEventsCheckbox = container . find ( '#captureEvents' ) ;
8484 this . _captureEventsCheckbox . change ( function ( ) {
8585 _this . _router . publishEvent ( 'captureEventsToggled' , { shouldCaptureEvents : this . checked } ) ;
8686 } ) ;
87+ this . addDisposable ( ( ) => { this . _captureEventsCheckbox . off ( ) ; } ) ;
88+
8789 this . _logEventsConsoleCheckbox = container . find ( '#logEventsConsole' ) ;
8890 this . _logEventsConsoleCheckbox . change ( function ( ) {
8991 _this . _router . publishEvent ( 'logEventsConsoleToggled' , { shouldLogToConsole : this . checked } ) ;
9092 } ) ;
93+ this . addDisposable ( ( ) => { this . _logEventsConsoleCheckbox . off ( ) ; } ) ;
94+
9195 this . _resetChartButton = container . find ( '#resetChart' ) ;
9296 this . _resetChartButton . click ( function ( ) {
9397 _this . _router . publishEvent ( 'resetChart' , { } ) ;
9498 } ) ;
99+ this . addDisposable ( ( ) => { this . _resetChartButton . off ( ) ; } ) ;
100+
101+ this . _closeButton = container . find ( '#closeButton' ) ;
102+ this . _closeButton . click ( function ( ) {
103+ _this . _router . publishEvent ( 'close' , { } ) ;
104+ } ) ;
105+ this . addDisposable ( ( ) => { this . _closeButton . off ( ) ; } ) ;
106+
95107 this . _eventDetailsDescriptionP = container . find ( '#eventDetailsDescription' ) ;
96108 this . _footer = container . find ( '#footer' ) ;
97109
@@ -102,13 +114,10 @@ export default class DevToolsView extends esp.model.DisposableBase {
102114 selectable : true ,
103115 stack : false ,
104116 min : moment ( ) . subtract ( 1 , 'm' ) ,
105- max : moment ( ) . add ( 10 , 'm' ) ,
106- //min: new Date(), // lower limit of visible range
107- ////max: new Date(2013, 0, 1), // upper limit of visible range
108- // zoomMin: 1000 * 60 * 60 * 24, // one day in milliseconds
109- //zoomMax: 1000 * 60 * 60 * 24 // one day in milliseconds
117+ max : moment ( ) . add ( 10 , 'm' )
110118 } ;
111119 this . _timeline = new vis . Timeline ( chartContainer [ 0 ] ) ;
120+ this . addDisposable ( ( ) => { this . _timeline . destroy ( ) ; } ) ; // also cleans up event listeners
112121 this . _timeline . setOptions ( options ) ;
113122 this . _timeline . setGroups ( this . _timelineGroups ) ;
114123 this . _timeline . setItems ( this . _timelineData ) ;
@@ -120,6 +129,9 @@ export default class DevToolsView extends esp.model.DisposableBase {
120129 cursor : 'move' ,
121130 handle : '#header'
122131 } ) ;
132+ this . addDisposable ( ( ) => {
133+ container . remove ( ) ;
134+ } ) ;
123135 } ) ;
124136 }
125137
0 commit comments