Skip to content

Commit

Permalink
update
Browse files Browse the repository at this point in the history
  • Loading branch information
bobicloudvision committed Apr 22, 2024
1 parent 366f463 commit 71b9af4
Show file tree
Hide file tree
Showing 4 changed files with 64 additions and 0 deletions.
19 changes: 19 additions & 0 deletions web/app/Filament/Pages/Terminal.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
<?php

namespace app\Filament\Pages;

use Filament\Pages\Page;

class Terminal extends Page
{
protected static ?string $navigationIcon = 'heroicon-o-command-line';

protected static string $view = 'filament.pages.terminal';

protected static ?string $navigationGroup = 'Server Management';

protected static ?string $navigationLabel = 'Terminal';

protected static ?int $navigationSort = 1;

}
8 changes: 8 additions & 0 deletions web/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions web/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,5 +16,8 @@
"tailwindcss": "^3.4.3",
"tippy.js": "^6.3.7",
"vite": "^4.0.0"
},
"dependencies": {
"@xterm/xterm": "^5.5.0"
}
}
34 changes: 34 additions & 0 deletions web/resources/views/filament/pages/terminal.blade.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
<x-filament-panels::page>

<div>
<link rel="stylesheet" href="node_modules/@xterm/xterm/css/xterm.css" />
<script src="node_modules/@xterm/xterm/lib/xterm.js"></script>


<div id="js-web-terminal"></div>
<script>
const terminal = new Terminal();
terminal.open(document.getElementById('js-web-terminal'));
//terminal.resize(160, 30);
const socket = new WebSocket(`ws://49.13.166.115:3311`);
socket.addEventListener('open', (_) => {
terminal.onData((data) => socket.send(data));
socket.addEventListener('message', (evt) => terminal.write(evt.data));
});
socket.addEventListener('error', (_) => {
terminal.reset();
terminal.writeln('Connection error.');
});
socket.addEventListener('close', (evt) => {
if (evt.wasClean) {
terminal.reset();
terminal.writeln(evt.reason ?? 'Connection closed.');
}
});
</script>
</div>
</x-filament-panels::page>

0 comments on commit 71b9af4

Please sign in to comment.