data['user'] = $this->server->ssh_user; } public function form(Form $form): Form { return $form ->statePath('data') ->schema([ Grid::make() ->columns(6) ->schema([ Select::make('user') ->options([ 'root' => 'root', 'vito' => 'vito', ]) ->maxWidth('sm') ->hiddenLabel(), TextInput::make('command') ->hiddenLabel() ->placeholder('Command') ->columnSpan(5) ->suffixActions( [ Action::make('run') ->label('Run') ->icon('heroicon-o-play') ->color('primary') ->visible(! $this->running) ->action(function () { $this->running = true; $ssh = $this->server->ssh($this->data['user']); $log = 'console-'.time(); defer(function () use ($ssh, $log) { $ssh->exec(command: $this->data['command'], log: $log, stream: true, streamCallback: function ($output) { $this->output .= $output; $this->stream( to: 'output', content: $output, ); }); })->name($log); }), Action::make('stop') ->view('web.components.dynamic-widget', [ 'widget' => StopCommand::class, 'params' => [], ]), ], ), ]), ]); } public function render(): string { return <<<'BLADE'
{{ $this->output }}
{{ $this->form }}
BLADE; } }