Skip to content

Commit

Permalink
Merge pull request #2 from mamitech/develop
Browse files Browse the repository at this point in the history
error visibility during exec command
  • Loading branch information
ahrezaldy authored May 6, 2024
2 parents efae449 + 2b6decf commit 859f72d
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 4 deletions.
2 changes: 1 addition & 1 deletion src/Events/BaseEvent.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ class BaseEvent
use InteractsWithSockets;
use Dispatchable;

public function __construct(public string $action, public string $command)
public function __construct(public string $action, public string $command, public bool $isSuccess = true)
{
}
}
4 changes: 2 additions & 2 deletions src/Events/ExecCommandEvent.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@

class ExecCommandEvent extends BaseEvent
{
public function __construct(string $command)
public function __construct(string $command, bool $isSuccess)
{
parent::__construct('exec_command', $command);
parent::__construct('exec_command', $command, $isSuccess);
}
}
3 changes: 2 additions & 1 deletion src/Http/Controllers/DashboardController.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

namespace Acdphp\SchedulePolice\Http\Controllers;

use Acdphp\SchedulePolice\Data\ExecResult;
use Acdphp\SchedulePolice\Events\ExecCommandEvent;
use Acdphp\SchedulePolice\Events\StartScheduleEvent;
use Acdphp\SchedulePolice\Events\StopScheduleEvent;
Expand Down Expand Up @@ -62,7 +63,7 @@ public function exec(ExecRequest $request): RedirectResponse
$command = $request->validated('command');
$output = $this->service->execCommand($command);

ExecCommandEvent::dispatch($command);
ExecCommandEvent::dispatch($command, !$output->isError);

return Redirect::route('schedule-police.index')
->withFragment('#v-execute')
Expand Down

0 comments on commit 859f72d

Please sign in to comment.