module VORLON { declare var $: any; declare var Chartist: any; export class NodejsDashboard extends DashboardPlugin { //Do any setup you need, call super to configure //the plugin with html and css for the dashboard constructor() { // name , html for dash css for dash super("nodejs", "control.html", ["control.css", "tree.css"], ["chart.js", "chart-legend.js"]); this._ready = true; this.__MEGA_BYTE = 1048576; console.log('Started'); } //Return unique id for your plugin public getID(): string { return "NODEJS"; } // This code will run on the dashboard ////////////////////// // Start dashboard code // uses _insertHtmlContentAsync to insert the control.html content // into the dashboard private _inputField: HTMLInputElement private _outputDiv: HTMLElement private _time: any private _chart: any private __html: any private __MEGA_BYTE: number private _set_chart: any private _chart_data: any private _chart_container: any public startDashboardSide(div: HTMLDivElement = null): void { this._insertHtmlContentAsync(div, (filledDiv) => { var _that = this; this.toogleMenu(); this._time = 5; this._chart = false; this._chart_data = {labels: [0], series: [[0], [0], [0]]}; this._set_chart = setInterval(function() { _that.chart(); }, 500); this.__html = []; this.sendToClient('infos'); this.sendToClient('memory'); this.sendToClient('modules'); }) } public chart(): void { if (typeof Chartist !== 'object') { return; } this._chart = true; clearInterval(this._set_chart); console.log('stating chart'); new Chartist.Line('#memory-chart', this._chart_data, { plugins: [ Chartist.plugins.legend({ legendNames: ['HEAP Used', 'HEAP Total', 'RSS'], }) ], fullWidth: true, chartPadding: { right: 40 }, axisY: { labelInterpolationFnc: function(value) { return value + 'MB'; } } }); } public jstree(): void { $( '.tree li' ).each( function() { if( $( this ).find('ul').children( 'li' ).length > 0 ) { $( this ).addClass( 'parent' ); } }); $( '.tree li.parent > a' ).click( function( ) { $( this ).parent().toggleClass( 'active' ); $( this ).parent().children( 'ul' ).slideToggle( 'fast' ); }); } public toogleMenu(): void { $('.plugin-nodejs .open-menu').click(function() { $('.plugin-nodejs .open-menu').removeClass('active-menu'); $('.plugin-nodejs #searchlist').val(''); $('.plugin-nodejs .explorer-menu').hide(); $('.plugin-nodejs #' + $(this).data('menu')).show(); $('.plugin-nodejs .new-entry').fadeOut(); $(this).addClass('active-menu'); }); } public renderTree(arr: any): void { var __that = this; __that.__html.push('