ranjith-dev #249
298
app/Filament/Resources/CncMonitorDataResource.php
Normal file
298
app/Filament/Resources/CncMonitorDataResource.php
Normal file
@@ -0,0 +1,298 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Resources;
|
||||
|
||||
use App\Filament\Resources\CncMonitorDataResource\Pages;
|
||||
use App\Filament\Resources\CncMonitorDataResource\RelationManagers;
|
||||
use App\Models\CncMonitorData;
|
||||
use Filament\Facades\Filament;
|
||||
use Filament\Forms;
|
||||
use Filament\Forms\Components\Hidden;
|
||||
use Filament\Forms\Form;
|
||||
use Filament\Resources\Resource;
|
||||
use Filament\Tables;
|
||||
use Filament\Tables\Table;
|
||||
use Illuminate\Database\Eloquent\Builder;
|
||||
use Illuminate\Database\Eloquent\SoftDeletingScope;
|
||||
|
||||
class CncMonitorDataResource extends Resource
|
||||
{
|
||||
protected static ?string $model = CncMonitorData::class;
|
||||
|
||||
protected static ?string $navigationIcon = 'heroicon-o-rectangle-stack';
|
||||
|
||||
protected static ?string $navigationGroup = 'CNC Monitoring';
|
||||
|
||||
public static function form(Form $form): Form
|
||||
{
|
||||
return $form
|
||||
->schema([
|
||||
Forms\Components\TextInput::make('machine_id')
|
||||
->label('Machine ID'),
|
||||
Forms\Components\DateTimePicker::make('ts')
|
||||
->label('TS'),
|
||||
Forms\Components\TextInput::make('state')
|
||||
->label('State'),
|
||||
Forms\Components\TextInput::make('mode')
|
||||
->label('Mode'),
|
||||
Forms\Components\TextInput::make('run_status')
|
||||
->label('Run Status'),
|
||||
Forms\Components\TextInput::make('state_duration_s')
|
||||
->label('Status Duration S'),
|
||||
Forms\Components\TextInput::make('program')
|
||||
->label('Program'),
|
||||
Forms\Components\TextInput::make('feed_rate')
|
||||
->label('Feed Rate'),
|
||||
Forms\Components\TextInput::make('feed_override')
|
||||
->label('Feed OverRide'),
|
||||
Forms\Components\TextInput::make('spindle_speed')
|
||||
->label('Spindle Speed'),
|
||||
Forms\Components\TextInput::make('spindle_override')
|
||||
->label('Spindle OverRide'),
|
||||
Forms\Components\TextInput::make('spindle_load')
|
||||
->label('Spindle Load'),
|
||||
Forms\Components\TextInput::make('axis_load_x')
|
||||
->label('Axis Load X'),
|
||||
Forms\Components\TextInput::make('axis_load_z')
|
||||
->label('Axis Load Z'),
|
||||
Forms\Components\TextInput::make('tool_no')
|
||||
->label('Tool No'),
|
||||
Forms\Components\TextInput::make('tool_offset_no')
|
||||
->label('Tool Offset No'),
|
||||
Forms\Components\TextInput::make('wear_x')
|
||||
->label('Wear X')
|
||||
->default(null),
|
||||
Forms\Components\TextInput::make('wear_z')
|
||||
->label('Wear Z')
|
||||
->default(null),
|
||||
Forms\Components\TextInput::make('geom_x')
|
||||
->label('Geom X')
|
||||
->default(null),
|
||||
Forms\Components\TextInput::make('geom_z')
|
||||
->label('Geom Z')
|
||||
->default(null),
|
||||
Forms\Components\TextInput::make('cycle_time_s')
|
||||
->label('Cycle Time S'),
|
||||
Forms\Components\TextInput::make('last_cycle_time_s')
|
||||
->label('Last Cycle Time S'),
|
||||
Forms\Components\TextInput::make('part_count')
|
||||
->label('Part Count'),
|
||||
Forms\Components\TextInput::make('alarm_no')
|
||||
->label('Alaram No'),
|
||||
Forms\Components\TextInput::make('alarm_msg')
|
||||
->label('Alaram Msg'),
|
||||
Forms\Components\TextInput::make('total_run_s')
|
||||
->label('Total Run S'),
|
||||
Forms\Components\TextInput::make('total_idle_s')
|
||||
->label('Total Idle S'),
|
||||
Forms\Components\TextInput::make('total_alarm_s')
|
||||
->label('Total Alaram S'),
|
||||
Forms\Components\Hidden::make('created_by')
|
||||
->label('Created By')
|
||||
->default(Filament::auth()->user()->name),
|
||||
Forms\Components\Hidden::make('updated_by')
|
||||
->label('Updated By')
|
||||
->default(Filament::auth()->user()->name),
|
||||
]);
|
||||
}
|
||||
|
||||
public static function table(Table $table): Table
|
||||
{
|
||||
return $table
|
||||
->columns([
|
||||
Tables\Columns\TextColumn::make('No.')
|
||||
->label('No.')
|
||||
->alignCenter()
|
||||
->getStateUsing(function ($record, $livewire, $column, $rowLoop) {
|
||||
$paginator = $livewire->getTableRecords();
|
||||
$perPage = method_exists($paginator, 'perPage') ? $paginator->perPage() : 10;
|
||||
$currentPage = method_exists($paginator, 'currentPage') ? $paginator->currentPage() : 1;
|
||||
|
||||
return ($currentPage - 1) * $perPage + $rowLoop->iteration;
|
||||
}),
|
||||
Tables\Columns\TextColumn::make('ts')
|
||||
->label('TS')
|
||||
->dateTime()
|
||||
->sortable(),
|
||||
Tables\Columns\TextColumn::make('state')
|
||||
->label('State')
|
||||
->alignCenter()
|
||||
->sortable(),
|
||||
Tables\Columns\TextColumn::make('mode')
|
||||
->label('Mode')
|
||||
->alignCenter()
|
||||
->sortable(),
|
||||
Tables\Columns\TextColumn::make('run_status')
|
||||
->label('Run Status')
|
||||
->alignCenter()
|
||||
->sortable(),
|
||||
Tables\Columns\TextColumn::make('state_duration_s')
|
||||
->label('State Duration S')
|
||||
->alignCenter()
|
||||
->sortable(),
|
||||
Tables\Columns\TextColumn::make('program')
|
||||
->label('Program')
|
||||
->alignCenter()
|
||||
->sortable(),
|
||||
Tables\Columns\TextColumn::make('feed_rate')
|
||||
->label('Feed Rate')
|
||||
->alignCenter()
|
||||
->numeric()
|
||||
->sortable(),
|
||||
Tables\Columns\TextColumn::make('feed_override')
|
||||
->label('Feed OverRide')
|
||||
->alignCenter()
|
||||
->numeric()
|
||||
->sortable(),
|
||||
Tables\Columns\TextColumn::make('spindle_speed')
|
||||
->label('Spindle Speed')
|
||||
->alignCenter()
|
||||
->numeric()
|
||||
->sortable(),
|
||||
Tables\Columns\TextColumn::make('spindle_override')
|
||||
->label('Spindle OverRide')
|
||||
->alignCenter()
|
||||
->numeric()
|
||||
->sortable(),
|
||||
Tables\Columns\TextColumn::make('spindle_load')
|
||||
->label('Spindle Load')
|
||||
->alignCenter()
|
||||
->numeric()
|
||||
->sortable(),
|
||||
Tables\Columns\TextColumn::make('axis_load_x')
|
||||
->label('Axis Load X')
|
||||
->alignCenter()
|
||||
->numeric()
|
||||
->sortable(),
|
||||
Tables\Columns\TextColumn::make('axis_load_z')
|
||||
->label('Axis Load Z')
|
||||
->alignCenter()
|
||||
->numeric()
|
||||
->sortable(),
|
||||
Tables\Columns\TextColumn::make('tool_no')
|
||||
->label('Tool No')
|
||||
->alignCenter()
|
||||
->numeric()
|
||||
->sortable(),
|
||||
Tables\Columns\TextColumn::make('tool_offset_no')
|
||||
->label('Tool OffSet No')
|
||||
->alignCenter()
|
||||
->numeric()
|
||||
->sortable(),
|
||||
Tables\Columns\TextColumn::make('wear_x')
|
||||
->label('Wear X')
|
||||
->alignCenter()
|
||||
->numeric()
|
||||
->sortable(),
|
||||
Tables\Columns\TextColumn::make('wear_z')
|
||||
->label('Wear Z')
|
||||
->alignCenter()
|
||||
->numeric()
|
||||
->sortable(),
|
||||
Tables\Columns\TextColumn::make('geom_x')
|
||||
->label('Geom X')
|
||||
->alignCenter()
|
||||
->numeric()
|
||||
->sortable(),
|
||||
Tables\Columns\TextColumn::make('geom_z')
|
||||
->label('Geom Z')
|
||||
->alignCenter()
|
||||
->numeric()
|
||||
->sortable(),
|
||||
Tables\Columns\TextColumn::make('cycle_time_s')
|
||||
->label('Cycle Time S')
|
||||
->alignCenter()
|
||||
->numeric()
|
||||
->sortable(),
|
||||
Tables\Columns\TextColumn::make('last_cycle_time_s')
|
||||
->label('Last Cycle Time S')
|
||||
->alignCenter()
|
||||
->numeric()
|
||||
->sortable(),
|
||||
Tables\Columns\TextColumn::make('part_count')
|
||||
->label('Part Count')
|
||||
->alignCenter()
|
||||
->numeric()
|
||||
->sortable(),
|
||||
Tables\Columns\TextColumn::make('total_run_s')
|
||||
->label('Total Run S')
|
||||
->alignCenter()
|
||||
->numeric()
|
||||
->sortable(),
|
||||
Tables\Columns\TextColumn::make('total_idle_s')
|
||||
->label('Total Idle S')
|
||||
->alignCenter()
|
||||
->numeric()
|
||||
->sortable(),
|
||||
Tables\Columns\TextColumn::make('total_alarm_s')
|
||||
->label('Total Alaram S')
|
||||
->alignCenter()
|
||||
->numeric()
|
||||
->sortable(),
|
||||
Tables\Columns\TextColumn::make('created_at')
|
||||
->label('Created At')
|
||||
->alignCenter()
|
||||
->dateTime()
|
||||
->sortable()
|
||||
->toggleable(isToggledHiddenByDefault: true),
|
||||
Tables\Columns\TextColumn::make('created_by')
|
||||
->label('Created By')
|
||||
->alignCenter()
|
||||
->sortable()
|
||||
->toggleable(isToggledHiddenByDefault: true),
|
||||
Tables\Columns\TextColumn::make('updated_at')
|
||||
->label('Updated At')
|
||||
->dateTime()
|
||||
->sortable()
|
||||
->toggleable(isToggledHiddenByDefault: true),
|
||||
Tables\Columns\TextColumn::make('updated_by')
|
||||
->label('Updated By')
|
||||
->alignCenter()
|
||||
->sortable()
|
||||
->toggleable(isToggledHiddenByDefault: true),
|
||||
Tables\Columns\TextColumn::make('deleted_at')
|
||||
->dateTime()
|
||||
->sortable()
|
||||
->toggleable(isToggledHiddenByDefault: true),
|
||||
])
|
||||
->filters([
|
||||
Tables\Filters\TrashedFilter::make(),
|
||||
])
|
||||
->actions([
|
||||
Tables\Actions\ViewAction::make(),
|
||||
Tables\Actions\EditAction::make(),
|
||||
])
|
||||
->bulkActions([
|
||||
Tables\Actions\BulkActionGroup::make([
|
||||
Tables\Actions\DeleteBulkAction::make(),
|
||||
Tables\Actions\ForceDeleteBulkAction::make(),
|
||||
Tables\Actions\RestoreBulkAction::make(),
|
||||
]),
|
||||
]);
|
||||
}
|
||||
|
||||
public static function getRelations(): array
|
||||
{
|
||||
return [
|
||||
//
|
||||
];
|
||||
}
|
||||
|
||||
public static function getPages(): array
|
||||
{
|
||||
return [
|
||||
'index' => Pages\ListCncMonitorData::route('/'),
|
||||
'create' => Pages\CreateCncMonitorData::route('/create'),
|
||||
'view' => Pages\ViewCncMonitorData::route('/{record}'),
|
||||
'edit' => Pages\EditCncMonitorData::route('/{record}/edit'),
|
||||
];
|
||||
}
|
||||
|
||||
public static function getEloquentQuery(): Builder
|
||||
{
|
||||
return parent::getEloquentQuery()
|
||||
->withoutGlobalScopes([
|
||||
SoftDeletingScope::class,
|
||||
]);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Resources\CncMonitorDataResource\Pages;
|
||||
|
||||
use App\Filament\Resources\CncMonitorDataResource;
|
||||
use Filament\Actions;
|
||||
use Filament\Resources\Pages\CreateRecord;
|
||||
|
||||
class CreateCncMonitorData extends CreateRecord
|
||||
{
|
||||
protected static string $resource = CncMonitorDataResource::class;
|
||||
}
|
||||
@@ -0,0 +1,22 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Resources\CncMonitorDataResource\Pages;
|
||||
|
||||
use App\Filament\Resources\CncMonitorDataResource;
|
||||
use Filament\Actions;
|
||||
use Filament\Resources\Pages\EditRecord;
|
||||
|
||||
class EditCncMonitorData extends EditRecord
|
||||
{
|
||||
protected static string $resource = CncMonitorDataResource::class;
|
||||
|
||||
protected function getHeaderActions(): array
|
||||
{
|
||||
return [
|
||||
Actions\ViewAction::make(),
|
||||
Actions\DeleteAction::make(),
|
||||
Actions\ForceDeleteAction::make(),
|
||||
Actions\RestoreAction::make(),
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Resources\CncMonitorDataResource\Pages;
|
||||
|
||||
use App\Filament\Resources\CncMonitorDataResource;
|
||||
use Filament\Actions;
|
||||
use Filament\Resources\Pages\ListRecords;
|
||||
|
||||
class ListCncMonitorData extends ListRecords
|
||||
{
|
||||
protected static string $resource = CncMonitorDataResource::class;
|
||||
|
||||
protected function getHeaderActions(): array
|
||||
{
|
||||
return [
|
||||
Actions\CreateAction::make(),
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Resources\CncMonitorDataResource\Pages;
|
||||
|
||||
use App\Filament\Resources\CncMonitorDataResource;
|
||||
use Filament\Actions;
|
||||
use Filament\Resources\Pages\ViewRecord;
|
||||
|
||||
class ViewCncMonitorData extends ViewRecord
|
||||
{
|
||||
protected static string $resource = CncMonitorDataResource::class;
|
||||
|
||||
protected function getHeaderActions(): array
|
||||
{
|
||||
return [
|
||||
Actions\EditAction::make(),
|
||||
];
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user