@@ -24,8 +24,9 @@ var InitialLogSent = false;
2424
2525( function initConsole ( ) {
2626 window . TerminalQueue = [ ] ;
27+ window . ConsoleServerStatus = 0 ;
2728 window . Terminal = $ ( '#terminal' ) . terminal ( function ( command , term ) {
28- Socket . emit ( 'send command' , command ) ;
29+ Socket . emit ( ( ConsoleServerStatus !== 0 ) ? 'send command' : 'set status ', command ) ;
2930 } , {
3031 greetings : '' ,
3132 name : Pterodactyl . server . uuid ,
@@ -80,6 +81,7 @@ var InitialLogSent = false;
8081( function setupSocketListeners ( ) {
8182 // Update Listings on Initial Status
8283 Socket . on ( 'initial status' , function ( data ) {
84+ ConsoleServerStatus = data . status ;
8385 if ( ! InitialLogSent ) {
8486 updateServerPowerControls ( data . status ) ;
8587
@@ -91,6 +93,7 @@ var InitialLogSent = false;
9193
9294 // Update Listings on Status
9395 Socket . on ( 'status' , function ( data ) {
96+ ConsoleServerStatus = data . status ;
9497 updateServerPowerControls ( data . status ) ;
9598 } ) ;
9699
@@ -134,112 +137,117 @@ $(document).ready(function () {
134137 }
135138 } ) ;
136139
137- Socket . on ( 'proc' , function ( proc ) {
138- if ( CPUData . length > 10 ) {
139- CPUData . shift ( ) ;
140- MemoryData . shift ( ) ;
141- TimeLabels . shift ( ) ;
140+ ( function setupChartElements ( ) {
141+ if ( typeof SkipConsoleCharts !== 'undefined' ) {
142+ return ;
142143 }
143144
144- var cpuUse = ( Pterodactyl . server . cpu > 0 ) ? parseFloat ( ( ( proc . data . cpu . total / Pterodactyl . server . cpu ) * 100 ) . toFixed ( 3 ) . toString ( ) ) : proc . data . cpu . total ;
145- CPUData . push ( cpuUse ) ;
146- MemoryData . push ( parseInt ( proc . data . memory . total / ( 1024 * 1024 ) ) ) ;
147-
148- TimeLabels . push ( $ . format . date ( new Date ( ) , 'HH:mm:ss' ) ) ;
149-
150- CPUChart . update ( ) ;
151- MemoryChart . update ( ) ;
152- } ) ;
153-
154-
155- var ctc = $ ( '#chart_cpu' ) ;
156- var TimeLabels = [ ] ;
157- var CPUData = [ ] ;
158- var CPUChart = new Chart ( ctc , {
159- type : 'line' ,
160- data : {
161- labels : TimeLabels ,
162- datasets : [
163- {
164- label : "Percent Use" ,
165- fill : false ,
166- lineTension : 0.03 ,
167- backgroundColor : "#3c8dbc" ,
168- borderColor : "#3c8dbc" ,
169- borderCapStyle : 'butt' ,
170- borderDash : [ ] ,
171- borderDashOffset : 0.0 ,
172- borderJoinStyle : 'miter' ,
173- pointBorderColor : "#3c8dbc" ,
174- pointBackgroundColor : "#fff" ,
175- pointBorderWidth : 1 ,
176- pointHoverRadius : 5 ,
177- pointHoverBackgroundColor : "#3c8dbc" ,
178- pointHoverBorderColor : "rgba(220,220,220,1)" ,
179- pointHoverBorderWidth : 2 ,
180- pointRadius : 1 ,
181- pointHitRadius : 10 ,
182- data : CPUData ,
183- spanGaps : false ,
184- }
185- ]
186- } ,
187- options : {
188- title : {
189- display : true ,
190- text : 'CPU Usage (as Percent Total)'
191- } ,
192- legend : {
193- display : false ,
194- } ,
195- animation : {
196- duration : 1 ,
145+ Socket . on ( 'proc' , function ( proc ) {
146+ if ( CPUData . length > 10 ) {
147+ CPUData . shift ( ) ;
148+ MemoryData . shift ( ) ;
149+ TimeLabels . shift ( ) ;
197150 }
198- }
199- } ) ;
200151
201- var ctm = $ ( '#chart_memory' ) ;
202- MemoryData = [ ] ;
203- MemoryChart = new Chart ( ctm , {
204- type : 'line' ,
205- data : {
206- labels : TimeLabels ,
207- datasets : [
208- {
209- label : "Memory Use" ,
210- fill : false ,
211- lineTension : 0.03 ,
212- backgroundColor : "#3c8dbc" ,
213- borderColor : "#3c8dbc" ,
214- borderCapStyle : 'butt' ,
215- borderDash : [ ] ,
216- borderDashOffset : 0.0 ,
217- borderJoinStyle : 'miter' ,
218- pointBorderColor : "#3c8dbc" ,
219- pointBackgroundColor : "#fff" ,
220- pointBorderWidth : 1 ,
221- pointHoverRadius : 5 ,
222- pointHoverBackgroundColor : "#3c8dbc" ,
223- pointHoverBorderColor : "rgba(220,220,220,1)" ,
224- pointHoverBorderWidth : 2 ,
225- pointRadius : 1 ,
226- pointHitRadius : 10 ,
227- data : MemoryData ,
228- spanGaps : false ,
229- }
230- ]
231- } ,
232- options : {
233- title : {
234- display : true ,
235- text : 'Memory Usage (in Megabytes)'
152+ var cpuUse = ( Pterodactyl . server . cpu > 0 ) ? parseFloat ( ( ( proc . data . cpu . total / Pterodactyl . server . cpu ) * 100 ) . toFixed ( 3 ) . toString ( ) ) : proc . data . cpu . total ;
153+ CPUData . push ( cpuUse ) ;
154+ MemoryData . push ( parseInt ( proc . data . memory . total / ( 1024 * 1024 ) ) ) ;
155+
156+ TimeLabels . push ( $ . format . date ( new Date ( ) , 'HH:mm:ss' ) ) ;
157+
158+ CPUChart . update ( ) ;
159+ MemoryChart . update ( ) ;
160+ } ) ;
161+
162+ var ctc = $ ( '#chart_cpu' ) ;
163+ var TimeLabels = [ ] ;
164+ var CPUData = [ ] ;
165+ var CPUChart = new Chart ( ctc , {
166+ type : 'line' ,
167+ data : {
168+ labels : TimeLabels ,
169+ datasets : [
170+ {
171+ label : "Percent Use" ,
172+ fill : false ,
173+ lineTension : 0.03 ,
174+ backgroundColor : "#3c8dbc" ,
175+ borderColor : "#3c8dbc" ,
176+ borderCapStyle : 'butt' ,
177+ borderDash : [ ] ,
178+ borderDashOffset : 0.0 ,
179+ borderJoinStyle : 'miter' ,
180+ pointBorderColor : "#3c8dbc" ,
181+ pointBackgroundColor : "#fff" ,
182+ pointBorderWidth : 1 ,
183+ pointHoverRadius : 5 ,
184+ pointHoverBackgroundColor : "#3c8dbc" ,
185+ pointHoverBorderColor : "rgba(220,220,220,1)" ,
186+ pointHoverBorderWidth : 2 ,
187+ pointRadius : 1 ,
188+ pointHitRadius : 10 ,
189+ data : CPUData ,
190+ spanGaps : false ,
191+ }
192+ ]
236193 } ,
237- legend : {
238- display : false ,
194+ options : {
195+ title : {
196+ display : true ,
197+ text : 'CPU Usage (as Percent Total)'
198+ } ,
199+ legend : {
200+ display : false ,
201+ } ,
202+ animation : {
203+ duration : 1 ,
204+ }
205+ }
206+ } ) ;
207+
208+ var ctm = $ ( '#chart_memory' ) ;
209+ MemoryData = [ ] ;
210+ MemoryChart = new Chart ( ctm , {
211+ type : 'line' ,
212+ data : {
213+ labels : TimeLabels ,
214+ datasets : [
215+ {
216+ label : "Memory Use" ,
217+ fill : false ,
218+ lineTension : 0.03 ,
219+ backgroundColor : "#3c8dbc" ,
220+ borderColor : "#3c8dbc" ,
221+ borderCapStyle : 'butt' ,
222+ borderDash : [ ] ,
223+ borderDashOffset : 0.0 ,
224+ borderJoinStyle : 'miter' ,
225+ pointBorderColor : "#3c8dbc" ,
226+ pointBackgroundColor : "#fff" ,
227+ pointBorderWidth : 1 ,
228+ pointHoverRadius : 5 ,
229+ pointHoverBackgroundColor : "#3c8dbc" ,
230+ pointHoverBorderColor : "rgba(220,220,220,1)" ,
231+ pointHoverBorderWidth : 2 ,
232+ pointRadius : 1 ,
233+ pointHitRadius : 10 ,
234+ data : MemoryData ,
235+ spanGaps : false ,
236+ }
237+ ]
239238 } ,
240- animation : {
241- duration : 1 ,
239+ options : {
240+ title : {
241+ display : true ,
242+ text : 'Memory Usage (in Megabytes)'
243+ } ,
244+ legend : {
245+ display : false ,
246+ } ,
247+ animation : {
248+ duration : 1 ,
249+ }
242250 }
243- }
244- } ) ;
251+ } ) ;
252+ } ) ( ) ;
245253} ) ;
0 commit comments