salix/front/core/components/debug-info/index.js

32 lines
827 B
JavaScript

import ngModule from '../../module';
import Component from '../../lib/component';
import './style.scss';
/**
* Floating box displaying debugging information.
* Enabled only in development environment.
*/
export default class Controller extends Component {
constructor($element, $) {
super($element, $);
this.env = process.env.NODE_ENV || 'development';
if (this.env == 'development')
this.interval = setInterval(() => $.$digest(), 2000);
else
$element[0].style.display = 'none';
$element[0].addEventListener('mouseover',
() => this.classList.toggle('right'));
}
$onDestroy() {
clearInterval(this.interval);
}
}
ngModule.vnComponent('vnDebugInfo', {
template: require('./index.html'),
controller: Controller
});