Skip to content
Open
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: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
"require": {
"filament/filament": "^3.0",
"appstract/laravel-opcache": "^4.0.2",
"nesbot/carbon": "^2.0"
"nesbot/carbon": "^2.0|^3.0"
},
"extra": {
"laravel": {
Expand Down
15 changes: 15 additions & 0 deletions resources/lang/en/actions.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<?php

declare(strict_types=1);

return [

'compile' => [
'label' => 'Compile Scripts',
],

'clear' => [
'label' => 'Clear OPcache',
],

];
20 changes: 20 additions & 0 deletions resources/lang/en/notifications.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
<?php

declare(strict_types=1);

return [

'compiled' => [
'title' => 'Scripts Compiled',
'body' => ':compiled_count files compiled successfully.',
],

'cleared' => [
'title' => 'OPcache Cleared',
],

'Disabled' => [
'title' => 'OPcache Disabled',
],

];
17 changes: 17 additions & 0 deletions resources/lang/en/pages.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<?php

declare(strict_types=1);

return [

'config' => [
'title' => 'OPcache Config',
'navigation_label' => 'Config',
],

'status' => [
'title' => 'OPcache Status',
'navigation_label' => 'Status',
],

];
12 changes: 12 additions & 0 deletions resources/lang/en/table.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<?php

declare(strict_types=1);

return [

'headers' => [
'key' => 'Key',
'value' => 'Value',
],

];
16 changes: 16 additions & 0 deletions resources/lang/en/tabs.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
<?php

declare(strict_types=1);

return [

'blacklist' => 'Blacklist',
'directives' => 'Directives',
'jit' => 'JIT',
'lifecycle' => 'Lifecycle',
'memory' => 'Memory',
'statistics' => 'Statistics',
'strings' => 'Strings',
'version' => 'Version',

];
23 changes: 23 additions & 0 deletions resources/lang/en/widgets.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
<?php

declare(strict_types=1);

return [

'hits' => [
'heading' => 'OPcache Hits',
'categories' => [
'hits' => 'Hits',
'misses' => 'Misses',
],
],

'memory' => [
'heading' => 'OPcache Memory Usage',
'categories' => [
'used' => 'Used',
'free' => 'Free',
],
],

];
15 changes: 15 additions & 0 deletions resources/lang/ru/actions.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<?php

declare(strict_types=1);

return [

'compile' => [
'label' => 'Скомпилировать скрипты',
],

'clear' => [
'label' => 'Очистить OPcache',
],

];
20 changes: 20 additions & 0 deletions resources/lang/ru/notifications.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
<?php

declare(strict_types=1);

return [

'compiled' => [
'title' => 'Скрипты скомпилированы',
'body' => 'Успешно скомпилировано :compiled_count файлов.',
],

'cleared' => [
'title' => 'OPcache очищен',
],

'Disabled' => [
'title' => 'OPcache выключен',
],

];
17 changes: 17 additions & 0 deletions resources/lang/ru/pages.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<?php

declare(strict_types=1);

return [

'config' => [
'title' => 'Параметры OPcache',
'navigation_label' => 'Параметры',
],

'status' => [
'title' => 'Состояние OPcache',
'navigation_label' => 'Состояние',
],

];
12 changes: 12 additions & 0 deletions resources/lang/ru/table.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<?php

declare(strict_types=1);

return [

'headers' => [
'key' => 'Ключ',
'value' => 'Значение',
],

];
16 changes: 16 additions & 0 deletions resources/lang/ru/tabs.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
<?php

declare(strict_types=1);

return [

'blacklist' => 'Чёрный список',
'directives' => 'Директивы',
'jit' => 'JIT',
'lifecycle' => 'Жизненный цикл',
'memory' => 'Память',
'statistics' => 'Статистика',
'strings' => 'Строки',
'version' => 'Версия',

];
23 changes: 23 additions & 0 deletions resources/lang/ru/widgets.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
<?php

declare(strict_types=1);

return [

'hits' => [
'heading' => 'Попадания в OPcache',
'categories' => [
'hits' => 'Попадания',
'misses' => 'Промахи',
],
],

'memory' => [
'heading' => 'Использование памяти OPcache',
'categories' => [
'used' => 'Использовано',
'free' => 'Свободно',
],
],

];
6 changes: 3 additions & 3 deletions resources/views/status.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
:active="strtolower($tab) == $activeTab"
wire:click="$set('activeTab', '{{ strtolower($tab) }}')"
>
{{ $tab }}
{{ __("filament-opcache::tabs.$tab") }}
</x-filament::tabs.item>
@endforeach
</x-filament::tabs>
Expand All @@ -17,8 +17,8 @@
<x-filament-tables::container>
<x-filament-tables::table>
<x-slot name="header">
<x-filament-tables::header-cell>Key</x-filament-tables::header-cell>
<x-filament-tables::header-cell>Value</x-filament-tables::header-cell>
<x-filament-tables::header-cell>{{ __('filament-opcache::table.headers.key') }}</x-filament-tables::header-cell>
<x-filament-tables::header-cell>{{ __('filament-opcache::table.headers.value') }}</x-filament-tables::header-cell>
</x-slot>

@foreach($$activeTab as $key => $value)
Expand Down
2 changes: 2 additions & 0 deletions src/FilamentOpcachePlugin.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
<?php

declare(strict_types=1);

namespace STS\FilamentOpcache;

use Filament\Contracts\Plugin;
Expand Down
1 change: 1 addition & 0 deletions src/FilamentOpcacheServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ public function configurePackage(Package $package): void
{
$package
->name(static::$name)
->hasTranslations()
->hasViews();
}
}
36 changes: 1 addition & 35 deletions src/Pages/Config.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,9 @@
namespace STS\FilamentOpcache\Pages;

use Appstract\Opcache\OpcacheFacade;
use Filament\Actions\Action;
use Filament\Notifications\Notification;
use Filament\Pages\Page;

class Config extends Page
{
protected static ?string $title = 'OPcache Config';

protected static ?string $navigationLabel = 'Config';

protected static ?string $slug = 'opcache-config';

protected static ?string $navigationIcon = 'heroicon-o-cog';
Expand All @@ -23,37 +16,10 @@ class Config extends Page

protected static ?string $navigationGroup = 'OPcache';

public array $tabs = ['Directives', 'Version', 'Blacklist'];
public array $tabs = ['directives', 'version', 'blacklist'];

public string $activeTab = 'directives';

/** @noinspection DuplicatedCode */
protected function getActions(): array
{
return [
Action::make('compile')
->label('Compile Scripts')
->action(function () {
$result = OpcacheFacade::compile(true);

Notification::make()
->title('Scripts Compiled')
->body($result['compiled_count'] . ' files compiled successfully.')
->success()
->send();
}),
Action::make('clear')
->label('Clear OPcache')
->action(function () {
if (OpcacheFacade::clear()) {
Notification::make()->title('OPcache Cleared')->success()->send();
} else {
Notification::make()->title('OPcache Disabled')->warning()->send();
}
}),
];
}

protected function getViewData(): array
{
$config = OpcacheFacade::getConfig();
Expand Down
70 changes: 70 additions & 0 deletions src/Pages/Page.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
<?php

declare(strict_types=1);

namespace STS\FilamentOpcache\Pages;

use Appstract\Opcache\OpcacheFacade;
use Filament\Actions\Action;
use Filament\Notifications\Notification;
use Filament\Pages\Page as FilamentPage;
use Illuminate\Contracts\Support\Htmlable;

abstract class Page extends FilamentPage
{
public function getTitle(): string | Htmlable
{
$translations = static::getTranslations();

return $translations['title'] ?? parent::getTitle();
}

public static function getNavigationLabel(): string
{
$translations = static::getTranslations();

return $translations['navigation_label'] ?? parent::getNavigationLabel();
}

protected static function getTranslations(): ?array
{
$key = str(class_basename(static::class))->lower()->value();

$translations = __('filament-opcache::pages');

return $translations[$key] ?? null;
}

protected function getActions(): array
{
return [
Action::make('compile')
->label(__('filament-opcache::actions.compile.label'))
->action(function () {
$result = OpcacheFacade::compile(true);

Notification::make()
->title(__('filament-opcache::notifications.compiled.title'))
->body(__('filament-opcache::notifications.compiled.body', $result))
->success()
->send();
}),

Action::make('clear')
->label(__('filament-opcache::actions.clear.label'))
->action(function () {
if (OpcacheFacade::clear()) {
Notification::make()
->title(__('filament-opcache::notifications.cleared.title'))
->success()
->send();
} else {
Notification::make()
->title(__('filament-opcache::notifications.disabled.title'))
->warning()
->send();
}
}),
];
}
}
Loading