Skip to content
This repository has been archived by the owner on May 20, 2023. It is now read-only.

Commit

Permalink
Adds notify event log for console.
Browse files Browse the repository at this point in the history
  • Loading branch information
butschster committed Nov 3, 2021
1 parent 6996eef commit 28ce352
Show file tree
Hide file tree
Showing 8 changed files with 49 additions and 13 deletions.
14 changes: 8 additions & 6 deletions app/Modules/Ray/Console/Handlers/DebugHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,15 @@

class DebugHandler extends AbstractHandler
{

protected function makeData(array $payload): array
{
return [];
}
public function handle(array $payload): void
{
dump($payload);
$len = strlen($payload['content']['value']);
return [
'message' => [
str_pad('', $len, '='),
$payload['content']['value'],
str_pad('', $len, '=')
]
];
}
}
19 changes: 19 additions & 0 deletions app/Modules/Ray/Console/Handlers/NotifyHandler.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
<?php
declare(strict_types=1);

namespace Modules\Ray\Console\Handlers;

class NotifyHandler extends AbstractHandler
{
protected function makeData(array $payload): array
{
$len = strlen($payload['content']['value']);
return [
'message' => [
str_pad('', $len, '.'),
$payload['content']['value'],
str_pad('', $len, '.')
]
];
}
}
2 changes: 1 addition & 1 deletion app/Modules/Ray/Console/StreamHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ public function handle(array $stream): void
if (!isset($this->payloadHandlers[$payload['type']])) {
continue;

//$handler = new DebugHandler($this->output);
//$handler = new DebugHandler($this->renderer);
} else {
$handler = $this->payloadHandlers[$payload['type']];
$handler = new $handler($this->renderer);
Expand Down
5 changes: 5 additions & 0 deletions app/Modules/Ray/resources/views/console/notify.blade.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
@foreach($message as $line)
<div class="bg-magenta text-white px-3">
{{ $line }}
</div>
@endforeach
1 change: 1 addition & 0 deletions config/server.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
'job_event' => Handlers\JobEventHandler::class,
'event' => Handlers\EventHandler::class,
'view' => Handlers\ViewHandler::class,
'notify' => Handlers\NotifyHandler::class
]
]
],
Expand Down
2 changes: 1 addition & 1 deletion public/js/app.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion public/mix-manifest.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{
"/js/app.js": "/js/app.js?id=b99e3b61ad7bb3362d67",
"/js/app.js": "/js/app.js?id=d762b709b0acee0bebf1",
"/css/app.css": "/css/app.css?id=2bf686066fc03b0cc56a"
}
17 changes: 13 additions & 4 deletions resources/js/Pages/Terminal/Index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -69,9 +69,10 @@ export default {
setup() {
const store = useStore();
const messages = computed(() => store.state.terminal.messages)
const terminalInit = false
return {
messages, store
messages, store, terminalInit
}
},
destroyed() {
Expand Down Expand Up @@ -106,7 +107,7 @@ export default {
this.prompt();
break;
case '\r': // Enter
this.runCommand( command);
this.runCommand(command);
command = '';
break;
case '\u007F': // Backspace (DEL)
Expand Down Expand Up @@ -150,8 +151,16 @@ export default {
this.term.write('\r\n$ ');
},
sendMessages(messages) {
messages.forEach(msg => this.term.writeln(msg))
this.prompt()
const isEmpty = messages.filter(line => line !== '').length === 0
messages.forEach(msg => {
this.term.write('\b\b')
this.term.writeln(msg)
})
if (!isEmpty) {
this.prompt()
}
}
}
}
Expand Down

0 comments on commit 28ce352

Please sign in to comment.