Skip to content

Commit e488cf4

Browse files
committed
Create page Service Details
1 parent 3df2967 commit e488cf4

File tree

31 files changed

+326
-7
lines changed

31 files changed

+326
-7
lines changed

.DS_Store

0 Bytes
Binary file not shown.

app/Filament/Resources/EnviromentResource.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,8 @@ class EnviromentResource extends Resource
3030
{
3131
protected static ?string $model = Enviroment::class;
3232

33+
protected static ?string $label = "Enviroment";
34+
3335
protected static ?string $navigationIcon = 'heroicon-c-cog';
3436

3537

app/Filament/Resources/ServiceProccessResource.php

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
namespace App\Filament\Resources;
44

55
use App\Filament\Resources\ServiceProccessResource\Pages;
6+
use App\Filament\Resources\ServiceProccessResource\Pages\ServiceDetails;
67
use App\Filament\Resources\ServiceProccessResource\RelationManagers;
78
use App\Models\Enviromet;
89
use App\Models\ServiceProccess;
@@ -25,6 +26,9 @@ class ServiceProccessResource extends Resource
2526
{
2627
protected static ?string $model = ServiceProccess::class;
2728

29+
protected static ?string $label = "Command service";
30+
31+
2832
protected static ?string $navigationIcon = 'heroicon-c-command-line';
2933

3034
public static function form(Form $form): Form
@@ -61,7 +65,9 @@ public static function table(Table $table): Table
6165
TextColumn::make('pid')->label('PID')->icon('heroicon-c-list-bullet'),
6266
TextColumn::make('command')->icon('heroicon-c-command-line')->limit(30),
6367
TextColumn::make('tag')->badge('primary')->icon('heroicon-s-tag'),
64-
TextColumn::make('uuid')->limit(20)->icon('heroicon-c-link'),
68+
TextColumn::make('uuid')->limit(20)->icon('heroicon-c-link')->url(function($record){
69+
return "/manager/service-proccesses/{$record->id}/details";
70+
}),
6571
TextColumn::make('interval')->icon('heroicon-s-clock')->suffix(' Sec.'),
6672
TextColumn::make('last_execution')->dateTime('d/m/Y H:i')
6773
])
@@ -85,6 +91,7 @@ public static function getPages(): array
8591
{
8692
return [
8793
'index' => Pages\ManageServiceProccesses::route('/'),
94+
'details' => ServiceDetails::route('/{record}/details')
8895
];
8996
}
9097
}
Lines changed: 144 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,144 @@
1+
<?php
2+
3+
namespace App\Filament\Resources\ServiceProccessResource\Pages;
4+
5+
use App\Filament\Resources\ServiceProccessResource;
6+
use Filament\Resources\Pages\Concerns\InteractsWithRecord;
7+
use Filament\Resources\Pages\Page;
8+
use Livewire\Attributes\On;
9+
10+
class ServiceDetails extends Page
11+
{
12+
use InteractsWithRecord;
13+
14+
protected static string $resource = ServiceProccessResource::class;
15+
16+
protected static string $view = 'filament.resources.service-proccess-resource.pages.service-details';
17+
18+
public object $commandSource;
19+
20+
public array $commandSOurceList = [
21+
'bash' => [
22+
'name' => "Bash",
23+
'fullname' => "Bourne-Again SHell",
24+
'image' => "/icons/bash.svg",
25+
'isDefault' => true,
26+
'commands' => null
27+
],
28+
'php' => [
29+
'name' => "PHP",
30+
'fullname' => "PHP: Hypertext Preprocessor",
31+
'image' => "/icons/php.svg",
32+
'isDefault' => false,
33+
'commands' => ['php']
34+
],
35+
'python' => [
36+
'name' => "Python",
37+
'fullname' => "Python",
38+
'image' => "/icons/python.svg",
39+
'isDefault' => false,
40+
'commands' => ['python', 'python2', 'python3', 'pip', 'py']
41+
42+
],
43+
'laravel' => [
44+
'name' => "Laravel",
45+
'fullname' => "Laravel",
46+
'image' => "/icons/laravel.svg",
47+
'isDefault' => false,
48+
'commands' => ['artisan']
49+
50+
],
51+
'nodejs' => [
52+
'name' => "NodeJs",
53+
'fullname' => "NodeJs",
54+
'image' => "/icons/node-js.svg",
55+
'isDefault' => false,
56+
'commands' => ['node', 'npm', 'npx']
57+
],
58+
'java' => [
59+
'name' => "Java",
60+
'fullname' => "Java enviroment",
61+
'image' => "/icons/java-original.svg",
62+
'isDefault' => false,
63+
'commands' => ['java', 'javac']
64+
],
65+
'git' => [
66+
'name' => "Git",
67+
'fullname' => "Git",
68+
'image' => "/icons/git.svg",
69+
'isDefault' => false,
70+
'commands' => ['git']
71+
],
72+
'golang' => [
73+
'name' => "Go",
74+
'fullname' => "Go Lang",
75+
'image' => "/icons/golang.svg",
76+
'isDefault' => false,
77+
'commands' => ['go']
78+
],
79+
'rust' => [
80+
'name' => "Rust",
81+
'fullname' => "Rust",
82+
'image' => "/icons/rust.svg",
83+
'isDefault' => false,
84+
'commands' => ['cargo', 'rustc']
85+
],
86+
'docker' => [
87+
'name' => "Docker",
88+
'fullname' => "Docker",
89+
'image' => "/icons/docker.svg",
90+
'isDefault' => false,
91+
'commands' => ['docker']
92+
],
93+
];
94+
95+
private static function determineSoftware($command) {
96+
// Define a list of patterns and corresponding software
97+
$patterns = [
98+
'bash' => '/^(ls|cd|mv|cp|rm|echo|cat|grep|find|chmod|chown|mkdir|rmdir|touch|sudo|apt|yum|\.\/)/',
99+
'laravel' => '/^php artisan/',
100+
'php' => '/^php( |$)/',
101+
'python' => '/^python[0-9]* /',
102+
'nodejs' => '/^(node|npm|npx) /',
103+
'ruby' => '/^(ruby|rails|rake|gem) /',
104+
'java' => '/^(java|javac) /',
105+
'golang' => '/^(go) /',
106+
'rust' => '/^(cargo|rustc) /',
107+
'docker' => '/^(docker|docker-compose) /',
108+
'git' => '/^git /',
109+
'composer' => '/^composer /',
110+
'make' => '/^make /',
111+
'perl' => '/^perl /',
112+
'curl' => '/^curl /',
113+
'wget' => '/^wget /',
114+
'powershell' => '/^(powershell|pwsh) /',
115+
'ansible' => '/^ansible /',
116+
'terraform' => '/^terraform /',
117+
];
118+
119+
// Iterate over the patterns and return the corresponding software if a match is found
120+
foreach ($patterns as $software => $pattern) {
121+
if (preg_match($pattern, $command)) {
122+
return $software;
123+
}
124+
}
125+
126+
// Return 'unknown' if no pattern matches
127+
return 'bash';
128+
}
129+
130+
public function mount(int | string $record): void
131+
{
132+
$this->record = $this->resolveRecord($record);
133+
$this->dispatch('page-process-details', record: $this->record);
134+
}
135+
136+
#[On('determine-command-type')]
137+
public function DetermineCommandType(string $command)
138+
{
139+
// dd($command);
140+
$type = static::determineSoftware($command);
141+
// dd($type);
142+
$this->commandSource = (object)$this->commandSOurceList[$type];
143+
}
144+
}

app/Providers/Filament/ManagerPanelProvider.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ class ManagerPanelProvider extends PanelProvider
2525
public function panel(Panel $panel): Panel
2626
{
2727
return $panel
28+
->spa()
2829
->default()
2930
->id('manager')
3031
->path('manager')

public/.DS_Store

8 KB
Binary file not shown.

public/build/assets/theme-CGJr3IGS.css renamed to public/build/assets/theme-ByeJgAuq.css

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

public/build/manifest.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
"isEntry": true
66
},
77
"resources/css/filament/manager/theme.css": {
8-
"file": "assets/theme-CGJr3IGS.css",
8+
"file": "assets/theme-ByeJgAuq.css",
99
"src": "resources/css/filament/manager/theme.css",
1010
"isEntry": true
1111
},

public/icons/ansible.svg

Lines changed: 1 addition & 0 deletions
Loading

public/icons/bash.svg

Lines changed: 1 addition & 0 deletions
Loading

0 commit comments

Comments
 (0)