Skip to content

Commit

Permalink
Merge pull request #37 from techenby/amn/swap-pint-duster
Browse files Browse the repository at this point in the history
Swap pint for duster
  • Loading branch information
techenby authored May 1, 2023
2 parents 926323e + 2ed3fd2 commit 4fb6181
Show file tree
Hide file tree
Showing 44 changed files with 227 additions and 268 deletions.
17 changes: 17 additions & 0 deletions .github/workflows/duster-lint.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
name: Duster Lint

on:
push:
branches: [ main ]
pull_request:

jobs:
duster:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v3
- name: "Duster Lint"
uses: tighten/duster-action@v1
with:
args: lint
22 changes: 0 additions & 22 deletions .github/workflows/lint.yml

This file was deleted.

2 changes: 1 addition & 1 deletion app/Actions/Fortify/CreateNewUser.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ public function create(array $input)
'name' => ['required', 'string', 'max:255'],
'email' => ['required', 'string', 'email', 'max:255', 'unique:users'],
'password' => $this->passwordRules(),
'h-captcha-response' => ['required', new ValidHCaptcha()],
'h-captcha-response' => ['required', new ValidHCaptcha],
'terms' => Jetstream::hasTermsAndPrivacyPolicyFeature() ? ['accepted', 'required'] : '',
])->validate();

Expand Down
15 changes: 9 additions & 6 deletions app/Filament/Resources/JobResource.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,12 @@

namespace App\Filament\Resources;

use App\Filament\Resources\JobResource\Pages;
use App\Filament\Resources\JobResource\Pages\CreateJob;
use App\Filament\Resources\JobResource\Pages\EditJob;
use App\Filament\Resources\JobResource\Pages\ListJobs;
use App\Models\Job;
use Closure;
use Exception;
use Filament\Forms\Components\Builder as FormBuilder;
use Filament\Forms\Components\Builder\Block;
use Filament\Forms\Components\Card;
Expand Down Expand Up @@ -183,7 +186,7 @@ public static function table(Table $table): Table
->action(function (Job $record) {
try {
$record->print();
} catch (\Exception $e) {
} catch (Exception $e) {
Notification::make()
->title($e->getMessage())
->danger()
Expand All @@ -195,7 +198,7 @@ public static function table(Table $table): Table
->action(function (Job $record) {
try {
$record->markAsComplete();
} catch (\Exception $e) {
} catch (Exception $e) {
Notification::make()
->title($e->getMessage())
->danger()
Expand Down Expand Up @@ -251,9 +254,9 @@ public static function getRelations(): array
public static function getPages(): array
{
return [
'index' => Pages\ListJobs::route('/'),
'create' => Pages\CreateJob::route('/create'),
'edit' => Pages\EditJob::route('/{record}/edit'),
'index' => ListJobs::route('/'),
'create' => CreateJob::route('/create'),
'edit' => EditJob::route('/{record}/edit'),
];
}
}
20 changes: 10 additions & 10 deletions app/Filament/Resources/JobResource/Pages/CreateJob.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,16 @@ class CreateJob extends CreateRecord
{
protected static string $resource = JobResource::class;

public function getColorOptionsProperty()
{
return auth()->user()->currentTeam->materials->pluck('name', 'color_hex');
}

public function getPrintersProperty()
{
return auth()->user()->currentTeam->printers;
}

protected function handleRecordCreation(array $data): Model
{
$model = static::getModel()::create(array_merge($data, [
Expand All @@ -26,14 +36,4 @@ protected function handleRecordCreation(array $data): Model

return $model;
}

public function getColorOptionsProperty()
{
return auth()->user()->currentTeam->materials->pluck('name', 'color_hex');
}

public function getPrintersProperty()
{
return auth()->user()->currentTeam->printers;
}
}
16 changes: 8 additions & 8 deletions app/Filament/Resources/JobResource/Pages/EditJob.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,20 +3,13 @@
namespace App\Filament\Resources\JobResource\Pages;

use App\Filament\Resources\JobResource;
use Filament\Pages\Actions;
use Filament\Pages\Actions\DeleteAction;
use Filament\Resources\Pages\EditRecord;

class EditJob extends EditRecord
{
protected static string $resource = JobResource::class;

protected function getActions(): array
{
return [
Actions\DeleteAction::make(),
];
}

public function getColorOptionsProperty()
{
return auth()->user()->currentTeam->materials->pluck('name', 'color_hex');
Expand All @@ -26,4 +19,11 @@ public function getPrintersProperty()
{
return auth()->user()->currentTeam->printers;
}

protected function getActions(): array
{
return [
DeleteAction::make(),
];
}
}
4 changes: 2 additions & 2 deletions app/Filament/Resources/JobResource/Pages/ListJobs.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
namespace App\Filament\Resources\JobResource\Pages;

use App\Filament\Resources\JobResource;
use Filament\Pages\Actions;
use Filament\Pages\Actions\CreateAction;
use Filament\Resources\Pages\ListRecords;

class ListJobs extends ListRecords
Expand All @@ -13,7 +13,7 @@ class ListJobs extends ListRecords
protected function getActions(): array
{
return [
Actions\CreateAction::make(),
CreateAction::make(),
];
}
}
12 changes: 7 additions & 5 deletions app/Filament/Resources/MaterialResource.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,9 @@

namespace App\Filament\Resources;

use App\Filament\Resources\MaterialResource\Pages;
use App\Filament\Resources\MaterialResource\Pages\CreateMaterial;
use App\Filament\Resources\MaterialResource\Pages\EditMaterial;
use App\Filament\Resources\MaterialResource\Pages\ListMaterials;
use App\Models\Material;
use App\Models\Printer;
use Facades\App\Calculator;
Expand Down Expand Up @@ -132,7 +134,7 @@ public static function table(Table $table): Table
->sortable()
->toggleable(),
TextColumn::make('cost')
->formatStateUsing(fn (string $state) => "$$state")
->formatStateUsing(fn (string $state) => "\${$state}")
->searchable()
->sortable()
->toggleable(),
Expand Down Expand Up @@ -191,9 +193,9 @@ public static function getRelations(): array
public static function getPages(): array
{
return [
'index' => Pages\ListMaterials::route('/'),
'create' => Pages\CreateMaterial::route('/create'),
'edit' => Pages\EditMaterial::route('/{record}/edit'),
'index' => ListMaterials::route('/'),
'create' => CreateMaterial::route('/create'),
'edit' => EditMaterial::route('/{record}/edit'),
];
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
namespace App\Filament\Resources\MaterialResource\Pages;

use App\Filament\Resources\MaterialResource;
use Filament\Pages\Actions;
use Filament\Pages\Actions\CreateAction;
use Filament\Resources\Pages\ListRecords;

class ListMaterials extends ListRecords
Expand All @@ -13,7 +13,7 @@ class ListMaterials extends ListRecords
protected function getActions(): array
{
return [
Actions\CreateAction::make(),
CreateAction::make(),
];
}
}
4 changes: 2 additions & 2 deletions app/Filament/Resources/PrinterResource/Pages/EditPrinter.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
namespace App\Filament\Resources\PrinterResource\Pages;

use App\Filament\Resources\PrinterResource;
use Filament\Pages\Actions;
use Filament\Pages\Actions\DeleteAction;
use Filament\Resources\Pages\EditRecord;

class EditPrinter extends EditRecord
Expand All @@ -13,7 +13,7 @@ class EditPrinter extends EditRecord
protected function getActions(): array
{
return [
Actions\DeleteAction::make(),
DeleteAction::make(),
];
}
}
4 changes: 2 additions & 2 deletions app/Filament/Resources/PrinterResource/Pages/ListPrinters.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
namespace App\Filament\Resources\PrinterResource\Pages;

use App\Filament\Resources\PrinterResource;
use Filament\Pages\Actions;
use Filament\Pages\Actions\CreateAction;
use Filament\Resources\Pages\ListRecords;

class ListPrinters extends ListRecords
Expand All @@ -13,7 +13,7 @@ class ListPrinters extends ListRecords
protected function getActions(): array
{
return [
Actions\CreateAction::make(),
CreateAction::make(),
];
}
}
38 changes: 19 additions & 19 deletions app/Filament/Resources/PrinterResource/Pages/ViewPrinter.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,25 +22,6 @@ class ViewPrinter extends ViewRecord

protected static string $view = 'filament.resources.printer-resource.pages.view-printer';

protected function getActions(): array
{
return [
Action::make('fetch_status')
->action(fn () => FetchPrinterStatus::dispatch($this->record))
->color('secondary'),
EditAction::make()
->color('warning'),
Action::make('delete')
->action(function () {
$this->record->safeDelete();

return redirect()->route('filament.resources.printers.index');
})
->color('danger')
->requiresConfirmation(),
];
}

public function getTitle(): string
{
return $this->record->name ?? 'View Printer';
Expand All @@ -64,6 +45,25 @@ public function getFooterWidgets(): array
];
}

protected function getActions(): array
{
return [
Action::make('fetch_status')
->action(fn () => FetchPrinterStatus::dispatch($this->record))
->color('secondary'),
EditAction::make()
->color('warning'),
Action::make('delete')
->action(function () {
$this->record->safeDelete();

return redirect()->route('filament.resources.printers.index');
})
->color('danger')
->requiresConfirmation(),
];
}

protected function getFooterWidgetsColumns(): int|array
{
return [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,12 @@

class AxisControls extends Widget
{
protected static string $view = 'filament.resources.printer-resource.widgets.axis-controls';

public ?Model $record = null;

public $amount = 10;

protected static string $view = 'filament.resources.printer-resource.widgets.axis-controls';

public function home($axis)
{
$response = Http::octoPrint($this->record)->post('api/printer/printhead', [
Expand Down
4 changes: 2 additions & 2 deletions app/Filament/Resources/PrinterResource/Widgets/Camera.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

class Camera extends Widget
{
public ?Model $record = null;

protected static string $view = 'filament.resources.printer-resource.widgets.printer-camera';

public ?Model $record = null;
}
4 changes: 2 additions & 2 deletions app/Filament/Resources/PrinterResource/Widgets/Connection.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ class Connection extends Widget implements HasForms
{
use InteractsWithForms;

protected static string $view = 'filament.resources.printer-resource.widgets.connection';

public ?Model $record = null;

public $autoconnect;
Expand All @@ -30,8 +32,6 @@ class Connection extends Widget implements HasForms

public $save;

protected static string $view = 'filament.resources.printer-resource.widgets.connection';

public function mount()
{
parent::mount();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,10 @@

class GeneralControls extends Widget
{
public ?Model $record = null;

protected static string $view = 'filament.resources.printer-resource.widgets.general-controls';

public ?Model $record = null;

public function fansOff()
{
$this->manualCommand('M106 S0');
Expand Down
4 changes: 2 additions & 2 deletions app/Filament/Resources/PrinterResource/Widgets/Materials.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,10 @@

class Materials extends Widget
{
public ?Model $record = null;

protected static string $view = 'filament.resources.printer-resource.widgets.materials';

public ?Model $record = null;

protected $rules = [
'record.material_id' => 'nullable',
];
Expand Down
Loading

0 comments on commit 4fb6181

Please sign in to comment.