Bozhidar Slaveykov 1 ano atrás
pai
commit
079a074256

+ 93 - 0
web/app/Filament/Resources/PhyreServerResource.php

@@ -0,0 +1,93 @@
+<?php
+
+namespace App\Filament\Resources;
+
+use App\Filament\Resources\PhyreServerResource\Pages;
+use App\Filament\Resources\PhyreServerResource\RelationManagers;
+use App\Models\PhyreServer;
+use Filament\Forms;
+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 PhyreServerResource extends Resource
+{
+    protected static ?string $model = PhyreServer::class;
+
+    protected static ?string $navigationIcon = 'heroicon-o-server-stack';
+
+    protected static ?string $navigationGroup = 'Server Management';
+
+    protected static ?int $navigationSort = 1;
+
+    public static function form(Form $form): Form
+    {
+        return $form
+            ->schema([
+
+                Forms\Components\TextInput::make('name')
+                    ->label('Name')
+                    ->placeholder('Enter the name of the server')
+                ->columnSpanFull(),
+
+                Forms\Components\TextInput::make('ip')
+                    ->label('IP Address')
+                    ->placeholder('Enter the IP address of the server')
+                    ->required(),
+
+                Forms\Components\TextInput::make('port')
+                    ->label('Port')
+                    ->placeholder('Enter the port of the server')
+                    ->required(),
+
+                Forms\Components\TextInput::make('username')
+                    ->label('Username')
+                    ->placeholder('Enter the username of the server')
+                    ->required(),
+
+                Forms\Components\TextInput::make('password')
+                    ->label('Password')
+                    ->placeholder('Enter the password of the server')
+                    ->required(),
+
+            ]);
+    }
+
+    public static function table(Table $table): Table
+    {
+        return $table
+            ->columns([
+                //
+            ])
+            ->filters([
+                //
+            ])
+            ->actions([
+                Tables\Actions\EditAction::make(),
+            ])
+            ->bulkActions([
+                Tables\Actions\BulkActionGroup::make([
+                    Tables\Actions\DeleteBulkAction::make(),
+                ]),
+            ]);
+    }
+
+    public static function getRelations(): array
+    {
+        return [
+            //
+        ];
+    }
+
+    public static function getPages(): array
+    {
+        return [
+            'index' => Pages\ListPhyreServers::route('/'),
+            'create' => Pages\CreatePhyreServer::route('/create'),
+            'edit' => Pages\EditPhyreServer::route('/{record}/edit'),
+        ];
+    }
+}

+ 12 - 0
web/app/Filament/Resources/PhyreServerResource/Pages/CreatePhyreServer.php

@@ -0,0 +1,12 @@
+<?php
+
+namespace App\Filament\Resources\PhyreServerResource\Pages;
+
+use App\Filament\Resources\PhyreServerResource;
+use Filament\Actions;
+use Filament\Resources\Pages\CreateRecord;
+
+class CreatePhyreServer extends CreateRecord
+{
+    protected static string $resource = PhyreServerResource::class;
+}

+ 19 - 0
web/app/Filament/Resources/PhyreServerResource/Pages/EditPhyreServer.php

@@ -0,0 +1,19 @@
+<?php
+
+namespace App\Filament\Resources\PhyreServerResource\Pages;
+
+use App\Filament\Resources\PhyreServerResource;
+use Filament\Actions;
+use Filament\Resources\Pages\EditRecord;
+
+class EditPhyreServer extends EditRecord
+{
+    protected static string $resource = PhyreServerResource::class;
+
+    protected function getHeaderActions(): array
+    {
+        return [
+            Actions\DeleteAction::make(),
+        ];
+    }
+}

+ 19 - 0
web/app/Filament/Resources/PhyreServerResource/Pages/ListPhyreServers.php

@@ -0,0 +1,19 @@
+<?php
+
+namespace App\Filament\Resources\PhyreServerResource\Pages;
+
+use App\Filament\Resources\PhyreServerResource;
+use Filament\Actions;
+use Filament\Resources\Pages\ListRecords;
+
+class ListPhyreServers extends ListRecords
+{
+    protected static string $resource = PhyreServerResource::class;
+
+    protected function getHeaderActions(): array
+    {
+        return [
+            Actions\CreateAction::make(),
+        ];
+    }
+}

+ 11 - 0
web/app/Models/PhyreServer.php

@@ -0,0 +1,11 @@
+<?php
+
+namespace App\Models;
+
+use Illuminate\Database\Eloquent\Factories\HasFactory;
+use Illuminate\Database\Eloquent\Model;
+
+class PhyreServer extends Model
+{
+    use HasFactory;
+}

+ 46 - 0
web/database/migrations/2024_04_06_144436_create_phyre_servers_table.php

@@ -0,0 +1,46 @@
+<?php
+
+use Illuminate\Database\Migrations\Migration;
+use Illuminate\Database\Schema\Blueprint;
+use Illuminate\Support\Facades\Schema;
+
+return new class extends Migration
+{
+    /**
+     * Run the migrations.
+     */
+    public function up(): void
+    {
+        Schema::create('phyre_servers', function (Blueprint $table) {
+            $table->id();
+
+            $table->string('name')->nullable();
+            $table->string('ip')->unique();
+            $table->string('port')->nullable();
+            $table->string('username')->nullable();
+            $table->string('password')->nullable();
+            $table->string('status')->default('offline');
+            $table->string('server_type')->nullable();
+            $table->string('server_version')->nullable();
+            $table->string('server_os')->nullable();
+            $table->string('server_arch')->nullable();
+            $table->string('server_uptime')->nullable();
+            $table->string('server_cpu')->nullable();
+            $table->string('server_ram')->nullable();
+            $table->string('server_disk')->nullable();
+            $table->string('server_swap')->nullable();
+            $table->string('server_load')->nullable();
+            $table->string('server_processes')->nullable();
+
+            $table->timestamps();
+        });
+    }
+
+    /**
+     * Reverse the migrations.
+     */
+    public function down(): void
+    {
+        Schema::dropIfExists('phyre_servers');
+    }
+};