File tree Expand file tree Collapse file tree 3 files changed +27
-3
lines changed
components/server/subpages Expand file tree Collapse file tree 3 files changed +27
-3
lines changed Original file line number Diff line number Diff line change 4242 name: ' ServerConsole' ,
4343 mixins: [Socketio ],
4444 computed: {
45- ... mapState (' socket' , [' connected' ]),
45+ ... mapState (' socket' , [' connected' , ' outputBuffer ' ]),
4646 },
4747
4848 watch: {
6565 */
6666 sockets: {
6767 ' console output' : function (line : string ) {
68- this .terminal && this . terminal . writeln (line . replace ( / (?: \r\n | \r | \n ) $ / im , ' ' ) + ' \u001b [0m ' );
68+ this .writeLineToConsole (line );
6969 },
7070 },
7171
101101 // @ts-ignore
102102 this .terminal .fit ();
103103 this .terminal .clear ();
104+
105+ this .outputBuffer .forEach (this .writeLineToConsole );
104106 },
105107
106108 /**
113115 this .command = ' ' ;
114116 },
115117
118+ writeLineToConsole : function (line : string ) {
119+ this .terminal && this .terminal .writeln (line .replace (/ (?:\r\n | \r | \n )$ / im , ' ' ) + ' \u001b [0m' );
120+ },
121+
116122 /**
117123 * Handle a user pressing up/down arrows when in the command field to scroll through thier
118124 * command history for this server.
Original file line number Diff line number Diff line change @@ -7,6 +7,7 @@ export default {
77 connected : false ,
88 connectionError : false ,
99 status : Status . STATUS_OFF ,
10+ outputBuffer : [ ] ,
1011 } ,
1112 mutations : {
1213 SOCKET_CONNECT : ( state : SocketState ) => {
@@ -25,6 +26,22 @@ export default {
2526
2627 SOCKET_STATUS : ( state : SocketState , data : string ) => {
2728 state . status = data ;
28- }
29+ } ,
30+
31+ 'SOCKET_CONSOLE OUTPUT' : ( state : SocketState , data : string ) => {
32+ const { outputBuffer } = state ;
33+
34+ if ( outputBuffer . length >= 500 ) {
35+ // Pop all of the output buffer items off the front until we only have 499
36+ // items in the array.
37+ for ( let i = 0 ; i <= ( outputBuffer . length - 500 ) ; i ++ ) {
38+ outputBuffer . shift ( ) ;
39+ i ++ ;
40+ }
41+ }
42+
43+ outputBuffer . push ( data ) ;
44+ state . outputBuffer = outputBuffer ;
45+ } ,
2946 } ,
3047} ;
Original file line number Diff line number Diff line change @@ -12,6 +12,7 @@ export type SocketState = {
1212 connected : boolean ,
1313 connectionError : boolean | Error ,
1414 status : string ,
15+ outputBuffer : string [ ] ,
1516}
1617
1718export type ServerApplicationCredentials = {
You can’t perform that action at this time.
0 commit comments