Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: switched to filament only #9

Merged
merged 2 commits into from
Jul 16, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ RUN apt-get update \
curl \
cron \
htop \
iputils-ping \
openssh-client \
# Install cron file
&& echo "MAILTO=\"\"\n* * * * * webuser /usr/bin/php /var/www/html/artisan schedule:run" > /etc/cron.d/laravel \
# Install node & npm
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ You can access the admin panel at `/admin`.

### Project Structure

The project is a pretty simple Laravel app. The admin panel is built using [Filament](https://github.com/filamentphp/filament). The rest of the site was scaffolded with [Laravel Jetstream](https://github.com/laravel/jetstream) and is using the [Inertia Stack](https://jetstream.laravel.com/2.x/stacks/inertia.html).
The project is a pretty simple Laravel app, built using [Filament](https://github.com/filamentphp/filament).

### Usage

Expand Down
42 changes: 0 additions & 42 deletions app/Actions/Fortify/CreateNewUser.php

This file was deleted.

18 changes: 0 additions & 18 deletions app/Actions/Fortify/PasswordValidationRules.php

This file was deleted.

29 changes: 0 additions & 29 deletions app/Actions/Fortify/ResetUserPassword.php

This file was deleted.

32 changes: 0 additions & 32 deletions app/Actions/Fortify/UpdateUserPassword.php

This file was deleted.

56 changes: 0 additions & 56 deletions app/Actions/Fortify/UpdateUserProfileInformation.php

This file was deleted.

19 changes: 0 additions & 19 deletions app/Actions/Jetstream/DeleteUser.php

This file was deleted.

16 changes: 11 additions & 5 deletions app/Actions/PingComputersAction.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,20 +5,21 @@
use App\Events\ComputerReachableStatusUpdated;
use App\Jobs\PingComputer;
use App\Models\Computer;
use App\Support\Concerns\InteractsWithBanner;
use Filament\Notifications\Notification;
use Illuminate\Bus\Batch;
use Illuminate\Support\Facades\Auth;
use Illuminate\Support\Facades\Bus;
use Throwable;

class PingComputersAction
{
use InteractsWithBanner;

public function execute()
{
if (! Auth::check()) {
flash('You have to be authenticated to ping computers.')->error();
Notification::make()
->title('You have to be authenticated to ping computers.')
->danger()
->send();

return back();
}
Expand All @@ -41,6 +42,11 @@ public function execute()
// The batch has finished executing...
})->dispatch();

flash('Pinging computers...');
Notification::make()
->title('Pinging computers...')
->icon('heroicon-o-information-circle')
// TODO: get this working
// ->iconColor('blue')
->send();
}
}
38 changes: 31 additions & 7 deletions app/Actions/ShutdownComputerAction.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,49 +4,73 @@

use App\Jobs\ShutdownComputer;
use App\Models\Computer;
use Filament\Notifications\Notification;
use Illuminate\Support\Facades\Auth;

class ShutdownComputerAction
{
public function execute(Computer $computer)
{
if (! Auth::check()) {
flash('You have to be authenticated to shutdown a computer.')->error();
Notification::make()
->title('You have to be authenticated to shutdown a computer.')
->danger()
->send();

return back();
}

if (! $computer->canBeShutdownBy(Auth::user())) {
if (! Auth::user()->can('shutdown_computer')) {
flash('You are not authorized to shutdown this computer.')->error();
Notification::make()
->title('You are not authorized to shutdown this computer.')
->danger()
->send();

return back();
}

if ($computer->isInUse()) {
flash('The computer can not shutdown because it is still in use.')->error();
Notification::make()
->title('The computer can not shutdown because it is still in use.')
->danger()
->send();

return back();
}

flash('The computer can not shutdown. Are you authorized to do this?')->error();
Notification::make()
->title('The computer can not shutdown. Are you authorized to do this?')
->danger()
->send();

return back();
}

if (! $computer->ssh_user || ! $computer->ssh_shutdown_command) {
flash('The computer can not shutdown. SSH configuration is missing.')->error();
Notification::make()
->title('The computer can not shutdown. SSH configuration is missing.')
->danger()
->send();

return back();
}

if ($computer->sSHKey()->count() == 0) {
flash('The computer can not shutdown. SSH key is missing.')->error();
Notification::make()
->title('The computer can not shutdown. SSH key is missing.')
->danger()
->send();

return back();
}

flash('Shutting down computer...');
Notification::make()
->title('Shutting down computer...')
->icon('heroicon-o-information-circle')
// TODO: get this working
// ->iconColor('blue')
->send();

ShutdownComputer::dispatch($computer, Auth::user());

Expand Down
11 changes: 9 additions & 2 deletions app/Actions/UnuseComputerAction.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,20 +3,27 @@
namespace App\Actions;

use App\Models\Computer;
use Filament\Notifications\Notification;
use Illuminate\Support\Facades\Auth;

class UnuseComputerAction
{
public function execute(Computer $computer)
{
if (! Auth::check()) {
flash('You have to be authenticated to use a computer.')->error();
Notification::make()
->title('You have to be authenticated to use a computer.')
->danger()
->send();

return back();
}

if (! $computer->canBeUnusedBy(Auth::user())) {
flash('You are not authorized to use a computer.')->error();
Notification::make()
->title('You are not authorized to use a computer.')
->danger()
->send();

return back();
}
Expand Down
11 changes: 9 additions & 2 deletions app/Actions/UseComputerAction.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,20 +3,27 @@
namespace App\Actions;

use App\Models\Computer;
use Filament\Notifications\Notification;
use Illuminate\Support\Facades\Auth;

class UseComputerAction
{
public function execute(Computer $computer)
{
if (! Auth::check()) {
flash('You have to be authenticated to use a computer.')->error();
Notification::make()
->title('You have to be authenticated to use a computer.')
->danger()
->send();

return back();
}

if (! $computer->canBeUsedBy(Auth::user())) {
flash('You are not authorized to use a computer.')->error();
Notification::make()
->title('You are not authorized to use a computer.')
->danger()
->send();

return back();
}
Expand Down
Loading