mirror of
https://github.com/pelican-dev/panel.git
synced 2026-02-21 03:10:43 +03:00
Compare commits
61 Commits
v1.0.0-bet
...
chore/shif
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
1d6f490c77 | ||
|
|
e2851f28ca | ||
|
|
de14e54931 | ||
|
|
f02b58c320 | ||
|
|
8aa0fc7fc2 | ||
|
|
2fc30e14fd | ||
|
|
ec5fd3262a | ||
|
|
81178f81b4 | ||
|
|
5373f1e30a | ||
|
|
9f35f1c3ee | ||
|
|
a5858a6d9b | ||
|
|
e3b3c92dcb | ||
|
|
42c84c2df5 | ||
|
|
4792542f20 | ||
|
|
bb40a5273f | ||
|
|
e5c24fe8b6 | ||
|
|
c10280af4b | ||
|
|
6db1d82738 | ||
|
|
68f8244298 | ||
|
|
ce393af7a6 | ||
|
|
932809fec5 | ||
|
|
3d2390dbcc | ||
|
|
d5d50d4150 | ||
|
|
cba8717188 | ||
|
|
df4543a079 | ||
|
|
8dc99e6390 | ||
|
|
8f1ec20e96 | ||
|
|
61dcb9a3ba | ||
|
|
0e34886d7e | ||
|
|
806820592f | ||
|
|
1900c04b71 | ||
|
|
32eb1abd4a | ||
|
|
47557021fd | ||
|
|
2ef81eae1a | ||
|
|
420730ba1f | ||
|
|
925ab26fb4 | ||
|
|
2952e22619 | ||
|
|
079eaed010 | ||
|
|
6671d45651 | ||
|
|
3543b4773a | ||
|
|
02f788a659 | ||
|
|
7ace3978d8 | ||
|
|
8f277aaca0 | ||
|
|
76451fa0ad | ||
|
|
0104a08ba4 | ||
|
|
5eff006843 | ||
|
|
a8241bf9f3 | ||
|
|
4aae2562ea | ||
|
|
42db5b328a | ||
|
|
bc4dfb3e92 | ||
|
|
3b9c81534f | ||
|
|
f31aa78f6f | ||
|
|
b5ebd544f4 | ||
|
|
c77a37ec89 | ||
|
|
4d78e5dcd1 | ||
|
|
15075b6ab8 | ||
|
|
a8f233e204 | ||
|
|
795cad43b9 | ||
|
|
46934d7a85 | ||
|
|
06067f375c | ||
|
|
d1df53c683 |
7
.github/ISSUE_TEMPLATE/bug-report.yml
vendored
7
.github/ISSUE_TEMPLATE/bug-report.yml
vendored
@@ -64,10 +64,9 @@ body:
|
||||
label: Error Logs
|
||||
description: |
|
||||
Run the following command to collect logs on your system.
|
||||
|
||||
Wings: `sudo wings diagnostics`
|
||||
Panel: `tail -n 150 /var/www/pelican/storage/logs/laravel-$(date +%F).log | curl -X POST -F 'c=@-' paste.pelistuff.com`
|
||||
placeholder: "https://pelipaste.com/a1h6z"
|
||||
Wings: `sudo wings diagnostics --hastebin-url=https://logs.pelican.dev`
|
||||
Panel: `tail -n 300 /var/www/pelican/storage/logs/laravel-$(date +%F).log | curl --data-binary @- https://logs.pelican.dev`
|
||||
placeholder: "https://logs.pelican.dev/c17f750e"
|
||||
render: bash
|
||||
validations:
|
||||
required: false
|
||||
|
||||
4
.github/workflows/build.yaml
vendored
4
.github/workflows/build.yaml
vendored
@@ -11,9 +11,9 @@ jobs:
|
||||
name: UI
|
||||
runs-on: ubuntu-latest
|
||||
strategy:
|
||||
fail-fast: false
|
||||
fail-fast: true
|
||||
matrix:
|
||||
node-version: [18, 20]
|
||||
node-version: [20, 22]
|
||||
steps:
|
||||
- name: Code Checkout
|
||||
uses: actions/checkout@v4
|
||||
|
||||
163
.github/workflows/ci.yaml
vendored
163
.github/workflows/ci.yaml
vendored
@@ -6,12 +6,75 @@ on:
|
||||
- main
|
||||
pull_request:
|
||||
|
||||
env:
|
||||
APP_ENV: testing
|
||||
APP_DEBUG: "false"
|
||||
APP_KEY: ThisIsARandomStringForTests12345
|
||||
APP_TIMEZONE: UTC
|
||||
APP_URL: http://localhost/
|
||||
CACHE_DRIVER: array
|
||||
MAIL_MAILER: array
|
||||
SESSION_DRIVER: array
|
||||
QUEUE_CONNECTION: sync
|
||||
GUZZLE_TIMEOUT: 60
|
||||
GUZZLE_CONNECT_TIMEOUT: 60
|
||||
|
||||
jobs:
|
||||
sqlite:
|
||||
name: SQLite
|
||||
runs-on: ubuntu-latest
|
||||
strategy:
|
||||
fail-fast: true
|
||||
matrix:
|
||||
php: [8.2, 8.3, 8.4]
|
||||
env:
|
||||
DB_CONNECTION: sqlite
|
||||
DB_DATABASE: testing.sqlite
|
||||
steps:
|
||||
- name: Code Checkout
|
||||
uses: actions/checkout@v4
|
||||
|
||||
- name: Get cache directory
|
||||
id: composer-cache
|
||||
run: |
|
||||
echo "dir=$(composer config cache-files-dir)" >> $GITHUB_OUTPUT
|
||||
|
||||
- name: Cache
|
||||
uses: actions/cache@v4
|
||||
with:
|
||||
path: ${{ steps.composer-cache.outputs.dir }}
|
||||
key: ${{ runner.os }}-composer-${{ matrix.php }}-${{ hashFiles('**/composer.lock') }}
|
||||
restore-keys: |
|
||||
${{ runner.os }}-composer-${{ matrix.php }}-
|
||||
|
||||
- name: Setup PHP
|
||||
uses: shivammathur/setup-php@v2
|
||||
with:
|
||||
php-version: ${{ matrix.php }}
|
||||
extensions: bcmath, curl, gd, mbstring, mysql, openssl, pdo, tokenizer, xml, zip
|
||||
tools: composer:v2
|
||||
coverage: none
|
||||
|
||||
- name: Install dependencies
|
||||
run: composer install --no-interaction --no-suggest --no-progress --no-scripts
|
||||
|
||||
- name: Create SQLite file
|
||||
run: touch database/testing.sqlite
|
||||
|
||||
- name: Unit tests
|
||||
run: vendor/bin/pest tests/Unit
|
||||
env:
|
||||
DB_HOST: UNIT_NO_DB
|
||||
SKIP_MIGRATIONS: true
|
||||
|
||||
- name: Integration tests
|
||||
run: vendor/bin/pest tests/Integration
|
||||
|
||||
mysql:
|
||||
name: MySQL
|
||||
runs-on: ubuntu-latest
|
||||
strategy:
|
||||
fail-fast: false
|
||||
fail-fast: true
|
||||
matrix:
|
||||
php: [8.2, 8.3, 8.4]
|
||||
database: ["mysql:8"]
|
||||
@@ -25,21 +88,10 @@ jobs:
|
||||
- 3306
|
||||
options: --health-cmd="mysqladmin ping" --health-interval=10s --health-timeout=5s --health-retries=3
|
||||
env:
|
||||
APP_ENV: testing
|
||||
APP_DEBUG: "false"
|
||||
APP_KEY: ThisIsARandomStringForTests12345
|
||||
APP_TIMEZONE: UTC
|
||||
APP_URL: http://localhost/
|
||||
CACHE_DRIVER: array
|
||||
MAIL_MAILER: array
|
||||
SESSION_DRIVER: array
|
||||
QUEUE_CONNECTION: sync
|
||||
DB_CONNECTION: mysql
|
||||
DB_HOST: 127.0.0.1
|
||||
DB_DATABASE: testing
|
||||
DB_USERNAME: root
|
||||
GUZZLE_TIMEOUT: 60
|
||||
GUZZLE_CONNECT_TIMEOUT: 60
|
||||
steps:
|
||||
- name: Code Checkout
|
||||
uses: actions/checkout@v4
|
||||
@@ -84,7 +136,7 @@ jobs:
|
||||
name: MariaDB
|
||||
runs-on: ubuntu-latest
|
||||
strategy:
|
||||
fail-fast: false
|
||||
fail-fast: true
|
||||
matrix:
|
||||
php: [8.2, 8.3, 8.4]
|
||||
database: ["mariadb:10.6", "mariadb:10.11", "mariadb:11.4"]
|
||||
@@ -98,21 +150,10 @@ jobs:
|
||||
- 3306
|
||||
options: --health-cmd="mariadb-admin ping || mysqladmin ping" --health-interval=10s --health-timeout=5s --health-retries=3
|
||||
env:
|
||||
APP_ENV: testing
|
||||
APP_DEBUG: "false"
|
||||
APP_KEY: ThisIsARandomStringForTests12345
|
||||
APP_TIMEZONE: UTC
|
||||
APP_URL: http://localhost/
|
||||
CACHE_DRIVER: array
|
||||
MAIL_MAILER: array
|
||||
SESSION_DRIVER: array
|
||||
QUEUE_CONNECTION: sync
|
||||
DB_CONNECTION: mariadb
|
||||
DB_HOST: 127.0.0.1
|
||||
DB_DATABASE: testing
|
||||
DB_USERNAME: root
|
||||
GUZZLE_TIMEOUT: 60
|
||||
GUZZLE_CONNECT_TIMEOUT: 60
|
||||
steps:
|
||||
- name: Code Checkout
|
||||
uses: actions/checkout@v4
|
||||
@@ -153,72 +194,11 @@ jobs:
|
||||
DB_PORT: ${{ job.services.database.ports[3306] }}
|
||||
DB_USERNAME: root
|
||||
|
||||
sqlite:
|
||||
name: SQLite
|
||||
runs-on: ubuntu-latest
|
||||
strategy:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
php: [8.2, 8.3, 8.4]
|
||||
env:
|
||||
APP_ENV: testing
|
||||
APP_DEBUG: "false"
|
||||
APP_KEY: ThisIsARandomStringForTests12345
|
||||
APP_TIMEZONE: UTC
|
||||
APP_URL: http://localhost/
|
||||
CACHE_DRIVER: array
|
||||
MAIL_MAILER: array
|
||||
SESSION_DRIVER: array
|
||||
QUEUE_CONNECTION: sync
|
||||
DB_CONNECTION: sqlite
|
||||
DB_DATABASE: testing.sqlite
|
||||
GUZZLE_TIMEOUT: 60
|
||||
GUZZLE_CONNECT_TIMEOUT: 60
|
||||
steps:
|
||||
- name: Code Checkout
|
||||
uses: actions/checkout@v4
|
||||
|
||||
- name: Get cache directory
|
||||
id: composer-cache
|
||||
run: |
|
||||
echo "dir=$(composer config cache-files-dir)" >> $GITHUB_OUTPUT
|
||||
|
||||
- name: Cache
|
||||
uses: actions/cache@v4
|
||||
with:
|
||||
path: ${{ steps.composer-cache.outputs.dir }}
|
||||
key: ${{ runner.os }}-composer-${{ matrix.php }}-${{ hashFiles('**/composer.lock') }}
|
||||
restore-keys: |
|
||||
${{ runner.os }}-composer-${{ matrix.php }}-
|
||||
|
||||
- name: Setup PHP
|
||||
uses: shivammathur/setup-php@v2
|
||||
with:
|
||||
php-version: ${{ matrix.php }}
|
||||
extensions: bcmath, curl, gd, mbstring, mysql, openssl, pdo, tokenizer, xml, zip
|
||||
tools: composer:v2
|
||||
coverage: none
|
||||
|
||||
- name: Install dependencies
|
||||
run: composer install --no-interaction --no-suggest --no-progress --no-scripts
|
||||
|
||||
- name: Create SQLite file
|
||||
run: touch database/testing.sqlite
|
||||
|
||||
- name: Unit tests
|
||||
run: vendor/bin/pest tests/Unit
|
||||
env:
|
||||
DB_HOST: UNIT_NO_DB
|
||||
SKIP_MIGRATIONS: true
|
||||
|
||||
- name: Integration tests
|
||||
run: vendor/bin/pest tests/Integration
|
||||
|
||||
postgresql:
|
||||
name: PostgreSQL
|
||||
runs-on: ubuntu-latest
|
||||
strategy:
|
||||
fail-fast: false
|
||||
fail-fast: true
|
||||
matrix:
|
||||
php: [8.2, 8.3, 8.4]
|
||||
database: ["postgres:14"]
|
||||
@@ -238,22 +218,11 @@ jobs:
|
||||
--health-timeout 5s
|
||||
--health-retries 5
|
||||
env:
|
||||
APP_ENV: testing
|
||||
APP_DEBUG: "false"
|
||||
APP_KEY: ThisIsARandomStringForTests12345
|
||||
APP_TIMEZONE: UTC
|
||||
APP_URL: http://localhost/
|
||||
CACHE_DRIVER: array
|
||||
MAIL_MAILER: array
|
||||
SESSION_DRIVER: array
|
||||
QUEUE_CONNECTION: sync
|
||||
DB_CONNECTION: pgsql
|
||||
DB_HOST: 127.0.0.1
|
||||
DB_DATABASE: testing
|
||||
DB_USERNAME: postgres
|
||||
DB_PASSWORD: postgres
|
||||
GUZZLE_TIMEOUT: 60
|
||||
GUZZLE_CONNECT_TIMEOUT: 60
|
||||
steps:
|
||||
- name: Code Checkout
|
||||
uses: actions/checkout@v4
|
||||
|
||||
7
.github/workflows/docker-publish.yml
vendored
7
.github/workflows/docker-publish.yml
vendored
@@ -66,8 +66,6 @@ jobs:
|
||||
permissions:
|
||||
contents: read
|
||||
packages: write
|
||||
strategy:
|
||||
fail-fast: false
|
||||
# Start a temp local registry because workflow can not pull from localy loaded images
|
||||
services:
|
||||
registry:
|
||||
@@ -134,6 +132,11 @@ jobs:
|
||||
docker push localhost:5000/base-php:arm64
|
||||
rm base-php-arm64.tar base-php-amd64.tar
|
||||
|
||||
- name: Update version in config/app.php (tag)
|
||||
if: "github.event_name == 'release' && github.event.action == 'published'"
|
||||
run: |
|
||||
sed -i "s/'version' => 'canary',/'version' => '${{ steps.build_info.outputs.version_tag }}',/" config/app.php
|
||||
|
||||
- name: Build and Push (tag)
|
||||
uses: docker/build-push-action@v6
|
||||
if: "github.event_name == 'release' && github.event.action == 'published'"
|
||||
|
||||
2
.github/workflows/lint.yaml
vendored
2
.github/workflows/lint.yaml
vendored
@@ -33,7 +33,7 @@ jobs:
|
||||
name: PHPStan
|
||||
runs-on: ubuntu-latest
|
||||
strategy:
|
||||
fail-fast: false
|
||||
fail-fast: true
|
||||
matrix:
|
||||
php: [ 8.2, 8.3, 8.4 ]
|
||||
steps:
|
||||
|
||||
20
.github/workflows/shift.yaml
vendored
Normal file
20
.github/workflows/shift.yaml
vendored
Normal file
@@ -0,0 +1,20 @@
|
||||
name: Shift
|
||||
|
||||
on:
|
||||
workflow_dispatch:
|
||||
schedule:
|
||||
- cron: "0 0 * * 5"
|
||||
|
||||
jobs:
|
||||
shift:
|
||||
runs-on: ubuntu-latest
|
||||
timeout-minutes: 5
|
||||
steps:
|
||||
- name: Shift
|
||||
run: |
|
||||
curl -X POST -s -retry 5 -m 60 --fail-with-body \
|
||||
https://laravelshift.com/api/run \
|
||||
-H "Accept: application/json" \
|
||||
-d "api_token=${{ secrets.SHIFT_TOKEN }}" \
|
||||
-d "code=${{ secrets.SHIFT_CODE }}" \
|
||||
-d "scs=github:${{ github.repository }}:${{ github.ref_name }}"
|
||||
1
.gitignore
vendored
1
.gitignore
vendored
@@ -24,6 +24,5 @@ yarn-error.log
|
||||
|
||||
public/assets/manifest.json
|
||||
/database/*.sqlite*
|
||||
filament-monaco-editor/
|
||||
_ide_helper*
|
||||
/.phpstorm.meta.php
|
||||
|
||||
@@ -64,7 +64,7 @@ WORKDIR /var/www/html
|
||||
|
||||
# Install additional required libraries
|
||||
RUN apk add --no-cache \
|
||||
caddy ca-certificates supervisor supercronic
|
||||
caddy ca-certificates supervisor supercronic fcgi
|
||||
|
||||
COPY --chown=root:www-data --chmod=640 --from=composerbuild /build .
|
||||
COPY --chown=root:www-data --chmod=640 --from=yarnbuild /build/public ./public
|
||||
@@ -85,7 +85,8 @@ RUN chown root:www-data ./ \
|
||||
&& ln -s /pelican-data/storage/fonts /var/www/html/storage/app/public/fonts \
|
||||
# Allow www-data write permissions where necessary
|
||||
&& chown -R www-data:www-data /pelican-data ./storage ./bootstrap/cache /var/run/supervisord /var/www/html/public/storage \
|
||||
&& chmod -R u+rwX,g+rwX,o-rwx /pelican-data ./storage ./bootstrap/cache /var/run/supervisord
|
||||
&& chmod -R u+rwX,g+rwX,o-rwx /pelican-data ./storage ./bootstrap/cache /var/run/supervisord \
|
||||
&& chown -R www-data: /usr/local/etc/php/
|
||||
|
||||
# Configure Supervisor
|
||||
COPY docker/supervisord.conf /etc/supervisord.conf
|
||||
|
||||
@@ -68,7 +68,7 @@ WORKDIR /var/www/html
|
||||
|
||||
# Install additional required libraries
|
||||
RUN apk add --no-cache \
|
||||
caddy ca-certificates supervisor supercronic coreutils
|
||||
caddy ca-certificates supervisor supercronic fcgi coreutils
|
||||
|
||||
COPY --chown=root:www-data --chmod=640 --from=composerbuild /build .
|
||||
COPY --chown=root:www-data --chmod=640 --from=yarnbuild /build/public ./public
|
||||
@@ -89,7 +89,8 @@ RUN chown root:www-data ./ \
|
||||
&& ln -s /pelican-data/storage/fonts /var/www/html/storage/app/public/fonts \
|
||||
# Allow www-data write permissions where necessary
|
||||
&& chown -R www-data:www-data /pelican-data ./storage ./bootstrap/cache /var/run/supervisord /var/www/html/public/storage \
|
||||
&& chmod -R u+rwX,g+rwX,o-rwx /pelican-data ./storage ./bootstrap/cache /var/run/supervisord
|
||||
&& chmod -R u+rwX,g+rwX,o-rwx /pelican-data ./storage ./bootstrap/cache /var/run/supervisord \
|
||||
&& chown -R www-data: /usr/local/etc/php/
|
||||
|
||||
# Configure Supervisor
|
||||
COPY docker/supervisord.conf /etc/supervisord.conf
|
||||
|
||||
@@ -6,6 +6,7 @@ use App\Traits\EnvironmentWriterTrait;
|
||||
use Illuminate\Console\Command;
|
||||
use Illuminate\Contracts\Console\Kernel;
|
||||
use Illuminate\Database\DatabaseManager;
|
||||
use PDOException;
|
||||
|
||||
class DatabaseSettingsCommand extends Command
|
||||
{
|
||||
@@ -105,7 +106,7 @@ class DatabaseSettingsCommand extends Command
|
||||
]);
|
||||
|
||||
$this->database->connection('_panel_command_test')->getPdo();
|
||||
} catch (\PDOException $exception) {
|
||||
} catch (PDOException $exception) {
|
||||
$this->output->error(sprintf('Unable to connect to the MySQL server using the provided credentials. The error returned was "%s".', $exception->getMessage()));
|
||||
$this->output->error(trans('commands.database_settings.DB_error_2'));
|
||||
|
||||
@@ -165,7 +166,7 @@ class DatabaseSettingsCommand extends Command
|
||||
]);
|
||||
|
||||
$this->database->connection('_panel_command_test')->getPdo();
|
||||
} catch (\PDOException $exception) {
|
||||
} catch (PDOException $exception) {
|
||||
$this->output->error(sprintf('Unable to connect to the MariaDB server using the provided credentials. The error returned was "%s".', $exception->getMessage()));
|
||||
$this->output->error(trans('commands.database_settings.DB_error_2'));
|
||||
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
|
||||
namespace App\Console\Commands\Environment;
|
||||
|
||||
use App\Exceptions\PanelException;
|
||||
use App\Traits\EnvironmentWriterTrait;
|
||||
use Illuminate\Console\Command;
|
||||
|
||||
@@ -28,7 +29,7 @@ class EmailSettingsCommand extends Command
|
||||
/**
|
||||
* Handle command execution.
|
||||
*
|
||||
* @throws \App\Exceptions\PanelException
|
||||
* @throws PanelException
|
||||
*/
|
||||
public function handle(): void
|
||||
{
|
||||
|
||||
@@ -4,8 +4,8 @@ namespace App\Console\Commands\Maintenance;
|
||||
|
||||
use Carbon\Carbon;
|
||||
use Illuminate\Console\Command;
|
||||
use Illuminate\Contracts\Filesystem\Filesystem;
|
||||
use Illuminate\Contracts\Filesystem\Factory as FilesystemFactory;
|
||||
use Illuminate\Contracts\Filesystem\Filesystem;
|
||||
use SplFileInfo;
|
||||
|
||||
class CleanServiceBackupFilesCommand extends Command
|
||||
|
||||
@@ -5,6 +5,7 @@ namespace App\Console\Commands\Maintenance;
|
||||
use App\Models\Backup;
|
||||
use Carbon\CarbonImmutable;
|
||||
use Illuminate\Console\Command;
|
||||
use InvalidArgumentException;
|
||||
|
||||
class PruneOrphanedBackupsCommand extends Command
|
||||
{
|
||||
@@ -16,7 +17,7 @@ class PruneOrphanedBackupsCommand extends Command
|
||||
{
|
||||
$since = $this->option('prune-age') ?? config('backups.prune_age', 360);
|
||||
if (!$since || !is_digit($since)) {
|
||||
throw new \InvalidArgumentException('The "--prune-age" argument must be a value greater than 0.');
|
||||
throw new InvalidArgumentException('The "--prune-age" argument must be a value greater than 0.');
|
||||
}
|
||||
|
||||
$query = Backup::query()
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
|
||||
namespace App\Console\Commands\Node;
|
||||
|
||||
use App\Exceptions\Model\DataValidationException;
|
||||
use App\Models\Node;
|
||||
use Illuminate\Console\Command;
|
||||
|
||||
@@ -34,7 +35,7 @@ class MakeNodeCommand extends Command
|
||||
/**
|
||||
* Handle the command execution process.
|
||||
*
|
||||
* @throws \App\Exceptions\Model\DataValidationException
|
||||
* @throws DataValidationException
|
||||
*/
|
||||
public function handle(): void
|
||||
{
|
||||
|
||||
@@ -17,7 +17,7 @@ class NodeConfigurationCommand extends Command
|
||||
{
|
||||
$column = ctype_digit((string) $this->argument('node')) ? 'id' : 'uuid';
|
||||
|
||||
/** @var \App\Models\Node $node */
|
||||
/** @var Node $node */
|
||||
$node = Node::query()->where($column, $this->argument('node'))->firstOr(function () {
|
||||
$this->error(trans('commands.node_config.error_not_exist'));
|
||||
|
||||
|
||||
@@ -2,10 +2,10 @@
|
||||
|
||||
namespace App\Console\Commands\Schedule;
|
||||
|
||||
use Illuminate\Console\Command;
|
||||
use App\Models\Schedule;
|
||||
use Illuminate\Database\Eloquent\Builder;
|
||||
use App\Services\Schedules\ProcessScheduleService;
|
||||
use Illuminate\Console\Command;
|
||||
use Illuminate\Database\Eloquent\Builder;
|
||||
use Throwable;
|
||||
|
||||
class ProcessRunnableCommand extends Command
|
||||
@@ -64,7 +64,7 @@ class ProcessRunnableCommand extends Command
|
||||
} catch (Throwable $exception) {
|
||||
logger()->error($exception, ['schedule_id' => $schedule->id]);
|
||||
|
||||
$this->error(trans('commands.schedule.process.no_tasks') . " #$schedule->id: " . $exception->getMessage());
|
||||
$this->error(trans('commands.schedule.process.error_message', ['schedules' => " #$schedule->id: " . $exception->getMessage()]));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,12 +3,12 @@
|
||||
namespace App\Console\Commands\Server;
|
||||
|
||||
use App\Models\Server;
|
||||
use App\Repositories\Daemon\DaemonServerRepository;
|
||||
use Exception;
|
||||
use Illuminate\Console\Command;
|
||||
use Illuminate\Database\Eloquent\Builder;
|
||||
use Illuminate\Validation\ValidationException;
|
||||
use Illuminate\Validation\Factory as ValidatorFactory;
|
||||
use App\Repositories\Daemon\DaemonPowerRepository;
|
||||
use Exception;
|
||||
use Illuminate\Validation\ValidationException;
|
||||
|
||||
class BulkPowerActionCommand extends Command
|
||||
{
|
||||
@@ -19,7 +19,7 @@ class BulkPowerActionCommand extends Command
|
||||
|
||||
protected $description = 'Perform bulk power management on large groupings of servers or nodes at once.';
|
||||
|
||||
public function handle(DaemonPowerRepository $powerRepository, ValidatorFactory $validator): void
|
||||
public function handle(DaemonServerRepository $serverRepository, ValidatorFactory $validator): void
|
||||
{
|
||||
$action = $this->argument('action');
|
||||
$nodes = empty($this->option('nodes')) ? [] : explode(',', $this->option('nodes'));
|
||||
@@ -52,7 +52,7 @@ class BulkPowerActionCommand extends Command
|
||||
|
||||
$bar = $this->output->createProgressBar($count);
|
||||
|
||||
$this->getQueryBuilder($servers, $nodes)->get()->each(function ($server, int $index) use ($action, $powerRepository, &$bar): mixed {
|
||||
$this->getQueryBuilder($servers, $nodes)->get()->each(function ($server, int $index) use ($action, $serverRepository, &$bar): mixed {
|
||||
$bar->clear();
|
||||
|
||||
if (!$server instanceof Server) {
|
||||
@@ -60,7 +60,7 @@ class BulkPowerActionCommand extends Command
|
||||
}
|
||||
|
||||
try {
|
||||
$powerRepository->setServer($server)->send($action);
|
||||
$serverRepository->setServer($server)->power($action);
|
||||
} catch (Exception $exception) {
|
||||
$this->output->error(trans('command/messages.server.power.action_failed', [
|
||||
'name' => $server->name,
|
||||
|
||||
@@ -2,10 +2,13 @@
|
||||
|
||||
namespace App\Console\Commands;
|
||||
|
||||
use Illuminate\Console\Command;
|
||||
use App\Console\Kernel;
|
||||
use Symfony\Component\Process\Process;
|
||||
use Closure;
|
||||
use Exception;
|
||||
use Illuminate\Console\Command;
|
||||
use Illuminate\Foundation\Application;
|
||||
use Symfony\Component\Console\Helper\ProgressBar;
|
||||
use Symfony\Component\Process\Process;
|
||||
|
||||
class UpgradeCommand extends Command
|
||||
{
|
||||
@@ -28,7 +31,7 @@ class UpgradeCommand extends Command
|
||||
* This places the application in maintenance mode as well while the commands
|
||||
* are being executed.
|
||||
*
|
||||
* @throws \Exception
|
||||
* @throws Exception
|
||||
*/
|
||||
public function handle(): void
|
||||
{
|
||||
@@ -129,9 +132,9 @@ class UpgradeCommand extends Command
|
||||
});
|
||||
});
|
||||
|
||||
/** @var \Illuminate\Foundation\Application $app */
|
||||
/** @var Application $app */
|
||||
$app = require __DIR__ . '/../../../bootstrap/app.php';
|
||||
/** @var \App\Console\Kernel $kernel */
|
||||
/** @var Kernel $kernel */
|
||||
$kernel = $app->make(Kernel::class);
|
||||
$kernel->bootstrap();
|
||||
$this->setLaravel($app);
|
||||
@@ -174,7 +177,7 @@ class UpgradeCommand extends Command
|
||||
$this->info(trans('commands.upgrade.success'));
|
||||
}
|
||||
|
||||
protected function withProgress(ProgressBar $bar, \Closure $callback): void
|
||||
protected function withProgress(ProgressBar $bar, Closure $callback): void
|
||||
{
|
||||
$bar->clear();
|
||||
$callback();
|
||||
|
||||
@@ -3,8 +3,8 @@
|
||||
namespace App\Console\Commands\User;
|
||||
|
||||
use App\Models\User;
|
||||
use Webmozart\Assert\Assert;
|
||||
use Illuminate\Console\Command;
|
||||
use Webmozart\Assert\Assert;
|
||||
|
||||
class DeleteUserCommand extends Command
|
||||
{
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
|
||||
namespace App\Console\Commands\User;
|
||||
|
||||
use App\Exceptions\Model\DataValidationException;
|
||||
use App\Models\User;
|
||||
use Illuminate\Console\Command;
|
||||
|
||||
@@ -14,20 +15,22 @@ class DisableTwoFactorCommand extends Command
|
||||
/**
|
||||
* Handle command execution process.
|
||||
*
|
||||
* @throws \App\Exceptions\Model\DataValidationException
|
||||
* @throws DataValidationException
|
||||
*/
|
||||
public function handle(): void
|
||||
{
|
||||
if ($this->input->isInteractive()) {
|
||||
$this->output->warning(trans('command/messages.user.2fa_help_text.0') . trans('command/messages.user.2fa_help_text.1'));
|
||||
$this->output->warning(trans('command/messages.user.2fa_help_text'));
|
||||
}
|
||||
|
||||
$email = $this->option('email') ?? $this->ask(trans('command/messages.user.ask_email'));
|
||||
|
||||
$user = User::query()->where('email', $email)->firstOrFail();
|
||||
$user->use_totp = false;
|
||||
$user->totp_secret = null;
|
||||
$user->save();
|
||||
$user = User::where('email', $email)->firstOrFail();
|
||||
$user->update([
|
||||
'mfa_app_secret' => null,
|
||||
'mfa_app_recovery_codes' => null,
|
||||
'mfa_email_enabled' => false,
|
||||
]);
|
||||
|
||||
$this->info(trans('command/messages.user.2fa_disabled', ['email' => $user->email]));
|
||||
}
|
||||
|
||||
@@ -2,9 +2,10 @@
|
||||
|
||||
namespace App\Console\Commands\User;
|
||||
|
||||
use App\Exceptions\Model\DataValidationException;
|
||||
use App\Services\Users\UserCreationService;
|
||||
use Exception;
|
||||
use Illuminate\Console\Command;
|
||||
use App\Services\Users\UserCreationService;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
|
||||
class MakeUserCommand extends Command
|
||||
@@ -25,7 +26,7 @@ class MakeUserCommand extends Command
|
||||
* Handle command request to create a new user.
|
||||
*
|
||||
* @throws Exception
|
||||
* @throws \App\Exceptions\Model\DataValidationException
|
||||
* @throws DataValidationException
|
||||
*/
|
||||
public function handle(): int
|
||||
{
|
||||
|
||||
@@ -32,6 +32,6 @@ enum BackupStatus: string implements HasColor, HasIcon, HasLabel
|
||||
|
||||
public function getLabel(): string
|
||||
{
|
||||
return trans('server/backup.backup_status.' . strtolower($this->value));
|
||||
return trans('server/backup.backup_status.' . $this->value);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -68,7 +68,7 @@ enum ContainerStatus: string implements HasColor, HasIcon, HasLabel
|
||||
|
||||
public function getLabel(): string
|
||||
{
|
||||
return trans('server/console.status.' . strtolower($this->value));
|
||||
return trans('server/console.status.' . $this->value);
|
||||
}
|
||||
|
||||
public function isOffline(): bool
|
||||
|
||||
37
app/Enums/CustomizationKey.php
Normal file
37
app/Enums/CustomizationKey.php
Normal file
@@ -0,0 +1,37 @@
|
||||
<?php
|
||||
|
||||
namespace App\Enums;
|
||||
|
||||
enum CustomizationKey: string
|
||||
{
|
||||
case ConsoleRows = 'console_rows';
|
||||
case ConsoleFont = 'console_font';
|
||||
case ConsoleFontSize = 'console_font_size';
|
||||
case ConsoleGraphPeriod = 'console_graph_period';
|
||||
case TopNavigation = 'top_navigation';
|
||||
case DashboardLayout = 'dashboard_layout';
|
||||
|
||||
public function getDefaultValue(): string|int|bool
|
||||
{
|
||||
return match ($this) {
|
||||
self::ConsoleRows => 30,
|
||||
self::ConsoleFont => 'monospace',
|
||||
self::ConsoleFontSize => 14,
|
||||
self::ConsoleGraphPeriod => 30,
|
||||
self::TopNavigation => false,
|
||||
self::DashboardLayout => 'grid',
|
||||
};
|
||||
}
|
||||
|
||||
/** @return array<string, string|int|bool> */
|
||||
public static function getDefaultCustomization(): array
|
||||
{
|
||||
$default = [];
|
||||
|
||||
foreach (self::cases() as $key) {
|
||||
$default[$key->value] = $key->getDefaultValue();
|
||||
}
|
||||
|
||||
return $default;
|
||||
}
|
||||
}
|
||||
@@ -1,141 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Enums;
|
||||
|
||||
use Filament\Support\Contracts\HasLabel;
|
||||
|
||||
enum EditorLanguages: string implements HasLabel
|
||||
{
|
||||
case plaintext = 'plaintext';
|
||||
case abap = 'abap';
|
||||
case apex = 'apex';
|
||||
case azcali = 'azcali';
|
||||
case bat = 'bat';
|
||||
case bicep = 'bicep';
|
||||
case cameligo = 'cameligo';
|
||||
case coljure = 'coljure';
|
||||
case coffeescript = 'coffeescript';
|
||||
case c = 'c';
|
||||
case cpp = 'cpp';
|
||||
case csharp = 'csharp';
|
||||
case csp = 'csp';
|
||||
case css = 'css';
|
||||
case cypher = 'cypher';
|
||||
case dart = 'dart';
|
||||
case dockerfile = 'dockerfile';
|
||||
case ecl = 'ecl';
|
||||
case elixir = 'elixir';
|
||||
case flow9 = 'flow9';
|
||||
case fsharp = 'fsharp';
|
||||
case go = 'go';
|
||||
case graphql = 'graphql';
|
||||
case handlebars = 'handlebars';
|
||||
case hcl = 'hcl';
|
||||
case html = 'html';
|
||||
case ini = 'ini';
|
||||
case java = 'java';
|
||||
case javascript = 'javascript';
|
||||
case julia = 'julia';
|
||||
case json = 'json';
|
||||
case kotlin = 'kotlin';
|
||||
case less = 'less';
|
||||
case lexon = 'lexon';
|
||||
case lua = 'lua';
|
||||
case liquid = 'liquid';
|
||||
case m3 = 'm3';
|
||||
case markdown = 'markdown';
|
||||
case mdx = 'mdx';
|
||||
case mips = 'mips';
|
||||
case msdax = 'msdax';
|
||||
case mysql = 'mysql';
|
||||
case objectivec = 'objective-c';
|
||||
case pascal = 'pascal';
|
||||
case pascaligo = 'pascaligo';
|
||||
case perl = 'perl';
|
||||
case pgsql = 'pgsql';
|
||||
case php = 'php';
|
||||
case pla = 'pla';
|
||||
case postiats = 'postiats';
|
||||
case powerquery = 'powerquery';
|
||||
case powershell = 'powershell';
|
||||
case proto = 'proto';
|
||||
case pug = 'pug';
|
||||
case python = 'python';
|
||||
case qsharp = 'qsharp';
|
||||
case r = 'r';
|
||||
case razor = 'razor';
|
||||
case redis = 'redis';
|
||||
case redshift = 'redshift';
|
||||
case restructuredtext = 'restructuredtext';
|
||||
case ruby = 'ruby';
|
||||
case rust = 'rust';
|
||||
case sb = 'sb';
|
||||
case scala = 'scala';
|
||||
case scheme = 'scheme';
|
||||
case scss = 'scss';
|
||||
case shell = 'shell';
|
||||
case sol = 'sol';
|
||||
case aes = 'aes';
|
||||
case sparql = 'sparql';
|
||||
case sql = 'sql';
|
||||
case st = 'st';
|
||||
case swift = 'swift';
|
||||
case systemverilog = 'systemverilog';
|
||||
case verilog = 'verilog';
|
||||
case tcl = 'tcl';
|
||||
case twig = 'twig';
|
||||
case typescript = 'typescript';
|
||||
case typespec = 'typespec';
|
||||
case vb = 'vb';
|
||||
case wgsl = 'wgsl';
|
||||
case xml = 'xml';
|
||||
case yaml = 'yaml';
|
||||
|
||||
public static function fromWithAlias(string $match): self
|
||||
{
|
||||
return match ($match) {
|
||||
'h' => self::c,
|
||||
|
||||
'cc', 'hpp' => self::cpp,
|
||||
|
||||
'cs' => self::csharp,
|
||||
|
||||
'class' => self::java,
|
||||
|
||||
'htm' => self::html,
|
||||
|
||||
'js', 'mjs', 'cjs' => self::javascript,
|
||||
|
||||
'kt', 'kts' => self::kotlin,
|
||||
|
||||
'md' => self::markdown,
|
||||
|
||||
'm' => self::objectivec,
|
||||
|
||||
'pl', 'pm' => self::perl,
|
||||
|
||||
'php3', 'php4', 'php5', 'phtml' => self::php,
|
||||
|
||||
'py', 'pyc', 'pyo', 'pyi' => self::python,
|
||||
|
||||
'rdata', 'rds' => self::r,
|
||||
|
||||
'rb', 'erb' => self::ruby,
|
||||
|
||||
'sc' => self::scala,
|
||||
|
||||
'sh', 'zsh' => self::shell,
|
||||
|
||||
'ts', 'tsx' => self::typescript,
|
||||
|
||||
'yml' => self::yaml,
|
||||
|
||||
default => self::tryFrom($match) ?? self::plaintext,
|
||||
};
|
||||
}
|
||||
|
||||
public function getLabel(): string
|
||||
{
|
||||
return $this->name;
|
||||
}
|
||||
}
|
||||
27
app/Enums/ScheduleStatus.php
Normal file
27
app/Enums/ScheduleStatus.php
Normal file
@@ -0,0 +1,27 @@
|
||||
<?php
|
||||
|
||||
namespace App\Enums;
|
||||
|
||||
use Filament\Support\Contracts\HasColor;
|
||||
use Filament\Support\Contracts\HasLabel;
|
||||
|
||||
enum ScheduleStatus: string implements HasColor, HasLabel
|
||||
{
|
||||
case Inactive = 'inactive';
|
||||
case Processing = 'processing';
|
||||
case Active = 'active';
|
||||
|
||||
public function getColor(): string
|
||||
{
|
||||
return match ($this) {
|
||||
self::Inactive => 'danger',
|
||||
self::Processing => 'warning',
|
||||
self::Active => 'success',
|
||||
};
|
||||
}
|
||||
|
||||
public function getLabel(): string
|
||||
{
|
||||
return trans('server/schedule.schedule_status.' . $this->value);
|
||||
}
|
||||
}
|
||||
11
app/Enums/StartupVariableType.php
Normal file
11
app/Enums/StartupVariableType.php
Normal file
@@ -0,0 +1,11 @@
|
||||
<?php
|
||||
|
||||
namespace App\Enums;
|
||||
|
||||
enum StartupVariableType: string
|
||||
{
|
||||
case Text = 'text';
|
||||
case Number = 'number';
|
||||
case Select = 'select';
|
||||
case Toggle = 'toggle';
|
||||
}
|
||||
@@ -2,9 +2,9 @@
|
||||
|
||||
namespace App\Enums;
|
||||
|
||||
use Filament\Support\Contracts\HasLabel;
|
||||
use Filament\Support\Contracts\HasColor;
|
||||
use Filament\Support\Contracts\HasIcon;
|
||||
use Filament\Support\Contracts\HasLabel;
|
||||
|
||||
enum WebhookType: string implements HasColor, HasIcon, HasLabel
|
||||
{
|
||||
|
||||
@@ -2,9 +2,9 @@
|
||||
|
||||
namespace App\Events;
|
||||
|
||||
use Illuminate\Support\Str;
|
||||
use App\Models\ActivityLog;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Support\Str;
|
||||
|
||||
class ActivityLogged extends Event
|
||||
{
|
||||
|
||||
@@ -2,8 +2,8 @@
|
||||
|
||||
namespace App\Events\Auth;
|
||||
|
||||
use App\Models\User;
|
||||
use App\Events\Event;
|
||||
use App\Models\User;
|
||||
|
||||
class ProvidedAuthenticationToken extends Event
|
||||
{
|
||||
|
||||
@@ -4,13 +4,14 @@ namespace App\Exceptions;
|
||||
|
||||
use Exception;
|
||||
use Filament\Notifications\Notification;
|
||||
use Illuminate\Container\Container;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use Illuminate\Http\RedirectResponse;
|
||||
use Illuminate\Http\Request;
|
||||
use Psr\Log\LoggerInterface;
|
||||
use Illuminate\Http\Response;
|
||||
use Illuminate\Container\Container;
|
||||
use Psr\Log\LoggerInterface;
|
||||
use Symfony\Component\HttpKernel\Exception\HttpExceptionInterface;
|
||||
use Throwable;
|
||||
|
||||
/**
|
||||
* @deprecated
|
||||
@@ -28,7 +29,7 @@ class DisplayException extends PanelException implements HttpExceptionInterface
|
||||
/**
|
||||
* DisplayException constructor.
|
||||
*/
|
||||
public function __construct(string $message, ?\Throwable $previous = null, protected string $level = self::LEVEL_ERROR, int $code = 0)
|
||||
public function __construct(string $message, ?Throwable $previous = null, protected string $level = self::LEVEL_ERROR, int $code = 0)
|
||||
{
|
||||
parent::__construct($message, $code, $previous);
|
||||
}
|
||||
@@ -79,11 +80,11 @@ class DisplayException extends PanelException implements HttpExceptionInterface
|
||||
* Log the exception to the logs using the defined error level only if the previous
|
||||
* exception is set.
|
||||
*
|
||||
* @throws \Throwable
|
||||
* @throws Throwable
|
||||
*/
|
||||
public function report(): void
|
||||
{
|
||||
if (!$this->getPrevious() instanceof \Exception || !Handler::isReportable($this->getPrevious())) {
|
||||
if (!$this->getPrevious() instanceof Exception || !Handler::isReportable($this->getPrevious())) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
@@ -2,24 +2,27 @@
|
||||
|
||||
namespace App\Exceptions;
|
||||
|
||||
use Illuminate\Support\Arr;
|
||||
use Illuminate\Support\Str;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use Illuminate\Support\Collection;
|
||||
use Exception;
|
||||
use Illuminate\Auth\Access\AuthorizationException;
|
||||
use Illuminate\Auth\AuthenticationException;
|
||||
use Illuminate\Container\Container;
|
||||
use Illuminate\Database\Connection;
|
||||
use Illuminate\Http\RedirectResponse;
|
||||
use Illuminate\Foundation\Application;
|
||||
use Illuminate\Auth\AuthenticationException;
|
||||
use Illuminate\Session\TokenMismatchException;
|
||||
use Illuminate\Validation\ValidationException;
|
||||
use Symfony\Component\HttpFoundation\Response;
|
||||
use Illuminate\Auth\Access\AuthorizationException;
|
||||
use Illuminate\Database\Eloquent\ModelNotFoundException;
|
||||
use Symfony\Component\HttpKernel\Exception\HttpException;
|
||||
use Symfony\Component\Mailer\Exception\TransportException;
|
||||
use Illuminate\Foundation\Application;
|
||||
use Illuminate\Foundation\Exceptions\Handler as ExceptionHandler;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use Illuminate\Http\RedirectResponse;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Session\TokenMismatchException;
|
||||
use Illuminate\Support\Arr;
|
||||
use Illuminate\Support\Collection;
|
||||
use Illuminate\Support\Str;
|
||||
use Illuminate\Validation\ValidationException;
|
||||
use PDOException;
|
||||
use Symfony\Component\HttpFoundation\Response;
|
||||
use Symfony\Component\HttpKernel\Exception\HttpException;
|
||||
use Symfony\Component\HttpKernel\Exception\HttpExceptionInterface;
|
||||
use Symfony\Component\Mailer\Exception\TransportException;
|
||||
use Throwable;
|
||||
|
||||
class Handler extends ExceptionHandler
|
||||
@@ -79,7 +82,7 @@ class Handler extends ExceptionHandler
|
||||
$this->dontReport = [];
|
||||
}
|
||||
|
||||
$this->reportable(function (\PDOException $ex) {
|
||||
$this->reportable(function (PDOException $ex) {
|
||||
$ex = $this->generateCleanedExceptionStack($ex);
|
||||
});
|
||||
|
||||
@@ -88,7 +91,7 @@ class Handler extends ExceptionHandler
|
||||
});
|
||||
}
|
||||
|
||||
private function generateCleanedExceptionStack(\Throwable $exception): string
|
||||
private function generateCleanedExceptionStack(Throwable $exception): string
|
||||
{
|
||||
$cleanedStack = '';
|
||||
foreach ($exception->getTrace() as $index => $item) {
|
||||
@@ -117,11 +120,11 @@ class Handler extends ExceptionHandler
|
||||
/**
|
||||
* Render an exception into an HTTP response.
|
||||
*
|
||||
* @param \Illuminate\Http\Request $request
|
||||
* @param Request $request
|
||||
*
|
||||
* @throws \Throwable
|
||||
* @throws Throwable
|
||||
*/
|
||||
public function render($request, \Throwable $e): Response
|
||||
public function render($request, Throwable $e): Response
|
||||
{
|
||||
$connections = $this->container->make(Connection::class);
|
||||
|
||||
@@ -143,7 +146,7 @@ class Handler extends ExceptionHandler
|
||||
* Transform a validation exception into a consistent format to be returned for
|
||||
* calls to the API.
|
||||
*
|
||||
* @param \Illuminate\Http\Request $request
|
||||
* @param Request $request
|
||||
*/
|
||||
public function invalidJson($request, ValidationException $exception): JsonResponse
|
||||
{
|
||||
@@ -249,7 +252,7 @@ class Handler extends ExceptionHandler
|
||||
/**
|
||||
* Return an array of exceptions that should not be reported.
|
||||
*/
|
||||
public static function isReportable(\Exception $exception): bool
|
||||
public static function isReportable(Exception $exception): bool
|
||||
{
|
||||
return (new self(Container::getInstance()))->shouldReport($exception);
|
||||
}
|
||||
@@ -257,7 +260,7 @@ class Handler extends ExceptionHandler
|
||||
/**
|
||||
* Convert an authentication exception into an unauthenticated response.
|
||||
*
|
||||
* @param \Illuminate\Http\Request $request
|
||||
* @param Request $request
|
||||
*/
|
||||
protected function unauthenticated($request, AuthenticationException $exception): JsonResponse|RedirectResponse
|
||||
{
|
||||
@@ -291,7 +294,7 @@ class Handler extends ExceptionHandler
|
||||
*
|
||||
* @return array<mixed>
|
||||
*/
|
||||
public static function toArray(\Throwable $e): array
|
||||
public static function toArray(Throwable $e): array
|
||||
{
|
||||
return self::exceptionToArray($e);
|
||||
}
|
||||
|
||||
@@ -4,13 +4,14 @@ namespace App\Exceptions\Http;
|
||||
|
||||
use Illuminate\Http\Response;
|
||||
use Symfony\Component\HttpKernel\Exception\HttpException;
|
||||
use Throwable;
|
||||
|
||||
class HttpForbiddenException extends HttpException
|
||||
{
|
||||
/**
|
||||
* HttpForbiddenException constructor.
|
||||
*/
|
||||
public function __construct(?string $message = null, ?\Throwable $previous = null)
|
||||
public function __construct(?string $message = null, ?Throwable $previous = null)
|
||||
{
|
||||
parent::__construct(Response::HTTP_FORBIDDEN, $message, $previous);
|
||||
}
|
||||
|
||||
@@ -5,6 +5,7 @@ namespace App\Exceptions\Http\Server;
|
||||
use App\Enums\ServerState;
|
||||
use App\Models\Server;
|
||||
use Symfony\Component\HttpKernel\Exception\ConflictHttpException;
|
||||
use Throwable;
|
||||
|
||||
class ServerStateConflictException extends ConflictHttpException
|
||||
{
|
||||
@@ -12,7 +13,7 @@ class ServerStateConflictException extends ConflictHttpException
|
||||
* Exception thrown when the server is in an unsupported state for API access or
|
||||
* certain operations within the codebase.
|
||||
*/
|
||||
public function __construct(Server $server, ?\Throwable $previous = null)
|
||||
public function __construct(Server $server, ?Throwable $previous = null)
|
||||
{
|
||||
$message = 'This server is currently in an unsupported state, please try again later.';
|
||||
if ($server->isSuspended()) {
|
||||
|
||||
@@ -1,18 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Exceptions\Http;
|
||||
|
||||
use Illuminate\Http\Response;
|
||||
use Symfony\Component\HttpKernel\Exception\HttpException;
|
||||
use Symfony\Component\HttpKernel\Exception\HttpExceptionInterface;
|
||||
|
||||
class TwoFactorAuthRequiredException extends HttpException implements HttpExceptionInterface
|
||||
{
|
||||
/**
|
||||
* TwoFactorAuthRequiredException constructor.
|
||||
*/
|
||||
public function __construct(?\Throwable $previous = null)
|
||||
{
|
||||
parent::__construct(Response::HTTP_BAD_REQUEST, 'Two-factor authentication is required on this account in order to access this endpoint.', $previous);
|
||||
}
|
||||
}
|
||||
@@ -2,13 +2,15 @@
|
||||
|
||||
namespace App\Exceptions;
|
||||
|
||||
use Spatie\Ignition\Contracts\Solution;
|
||||
use App\Exceptions\Solutions\ManifestDoesNotExistSolution;
|
||||
use Exception;
|
||||
use Spatie\Ignition\Contracts\ProvidesSolution;
|
||||
use Spatie\Ignition\Contracts\Solution;
|
||||
|
||||
class ManifestDoesNotExistException extends \Exception implements ProvidesSolution
|
||||
class ManifestDoesNotExistException extends Exception implements ProvidesSolution
|
||||
{
|
||||
public function getSolution(): Solution
|
||||
{
|
||||
return new Solutions\ManifestDoesNotExistSolution();
|
||||
return new ManifestDoesNotExistSolution();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,11 +2,11 @@
|
||||
|
||||
namespace App\Exceptions\Model;
|
||||
|
||||
use Illuminate\Support\MessageBag;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Contracts\Validation\Validator;
|
||||
use App\Exceptions\PanelException;
|
||||
use Illuminate\Contracts\Support\MessageProvider;
|
||||
use Illuminate\Contracts\Validation\Validator;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Support\MessageBag;
|
||||
use Symfony\Component\HttpKernel\Exception\HttpExceptionInterface;
|
||||
|
||||
class DataValidationException extends PanelException implements HttpExceptionInterface, MessageProvider
|
||||
|
||||
@@ -2,4 +2,6 @@
|
||||
|
||||
namespace App\Exceptions;
|
||||
|
||||
class PanelException extends \Exception {}
|
||||
use Exception;
|
||||
|
||||
class PanelException extends Exception {}
|
||||
|
||||
@@ -2,8 +2,8 @@
|
||||
|
||||
namespace App\Exceptions\Service;
|
||||
|
||||
use Illuminate\Http\Response;
|
||||
use App\Exceptions\DisplayException;
|
||||
use Illuminate\Http\Response;
|
||||
|
||||
class HasActiveServersException extends DisplayException
|
||||
{
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
namespace App\Exceptions\Service;
|
||||
|
||||
use App\Exceptions\DisplayException;
|
||||
use Throwable;
|
||||
|
||||
class ServiceLimitExceededException extends DisplayException
|
||||
{
|
||||
@@ -10,7 +11,7 @@ class ServiceLimitExceededException extends DisplayException
|
||||
* Exception thrown when something goes over a defined limit, such as allocated
|
||||
* ports, tasks, databases, etc.
|
||||
*/
|
||||
public function __construct(string $message, ?\Throwable $previous = null)
|
||||
public function __construct(string $message, ?Throwable $previous = null)
|
||||
{
|
||||
parent::__construct($message, $previous, self::LEVEL_WARNING);
|
||||
}
|
||||
|
||||
@@ -1,17 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Exceptions\Service\User;
|
||||
|
||||
use App\Exceptions\DisplayException;
|
||||
|
||||
class TwoFactorAuthenticationTokenInvalid extends DisplayException
|
||||
{
|
||||
public string $title = 'Invalid 2FA Code';
|
||||
|
||||
public string $icon = 'tabler-2fa';
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct('The provided two-factor authentication token was not valid.');
|
||||
}
|
||||
}
|
||||
@@ -2,15 +2,16 @@
|
||||
|
||||
namespace App\Extensions\Backups;
|
||||
|
||||
use Closure;
|
||||
use App\Extensions\Filesystem\S3Filesystem;
|
||||
use Aws\S3\S3Client;
|
||||
use Closure;
|
||||
use Illuminate\Foundation\Application;
|
||||
use Illuminate\Support\Arr;
|
||||
use Illuminate\Support\Str;
|
||||
use Webmozart\Assert\Assert;
|
||||
use Illuminate\Foundation\Application;
|
||||
use InvalidArgumentException;
|
||||
use League\Flysystem\FilesystemAdapter;
|
||||
use App\Extensions\Filesystem\S3Filesystem;
|
||||
use League\Flysystem\InMemory\InMemoryFilesystemAdapter;
|
||||
use Webmozart\Assert\Assert;
|
||||
|
||||
class BackupManager
|
||||
{
|
||||
@@ -64,7 +65,7 @@ class BackupManager
|
||||
$config = $this->getConfig($name);
|
||||
|
||||
if (empty($config['adapter'])) {
|
||||
throw new \InvalidArgumentException("Backup disk [$name] does not have a configured adapter.");
|
||||
throw new InvalidArgumentException("Backup disk [$name] does not have a configured adapter.");
|
||||
}
|
||||
|
||||
$adapter = $config['adapter'];
|
||||
@@ -82,7 +83,7 @@ class BackupManager
|
||||
return $instance;
|
||||
}
|
||||
|
||||
throw new \InvalidArgumentException("Adapter [$adapter] is not supported.");
|
||||
throw new InvalidArgumentException("Adapter [$adapter] is not supported.");
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -2,8 +2,8 @@
|
||||
|
||||
namespace App\Extensions\Captcha\Schemas;
|
||||
|
||||
use Filament\Forms\Components\Component;
|
||||
use Filament\Forms\Components\TextInput;
|
||||
use Filament\Schemas\Components\Component;
|
||||
use Illuminate\Support\Str;
|
||||
|
||||
abstract class BaseSchema
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
|
||||
namespace App\Extensions\Captcha\Schemas;
|
||||
|
||||
use Filament\Forms\Components\Component;
|
||||
use Filament\Schemas\Components\Component;
|
||||
|
||||
interface CaptchaSchemaInterface
|
||||
{
|
||||
|
||||
@@ -2,12 +2,11 @@
|
||||
|
||||
namespace App\Extensions\Captcha\Schemas\Turnstile;
|
||||
|
||||
use App\Extensions\Captcha\Schemas\CaptchaSchemaInterface;
|
||||
use App\Extensions\Captcha\Schemas\BaseSchema;
|
||||
use App\Extensions\Captcha\Schemas\CaptchaSchemaInterface;
|
||||
use Exception;
|
||||
use Filament\Forms\Components\Component as BaseComponent;
|
||||
use Filament\Forms\Components\Placeholder;
|
||||
use Filament\Forms\Components\Toggle;
|
||||
use Filament\Infolists\Components\TextEntry;
|
||||
use Illuminate\Support\Facades\Http;
|
||||
use Illuminate\Support\HtmlString;
|
||||
|
||||
@@ -23,7 +22,7 @@ class TurnstileSchema extends BaseSchema implements CaptchaSchemaInterface
|
||||
return env('CAPTCHA_TURNSTILE_ENABLED', false);
|
||||
}
|
||||
|
||||
public function getFormComponent(): BaseComponent
|
||||
public function getFormComponent(): Component
|
||||
{
|
||||
return Component::make('turnstile');
|
||||
}
|
||||
@@ -39,7 +38,9 @@ class TurnstileSchema extends BaseSchema implements CaptchaSchemaInterface
|
||||
}
|
||||
|
||||
/**
|
||||
* @return BaseComponent[]
|
||||
* @return \Filament\Support\Components\Component[]
|
||||
*
|
||||
* @throws Exception
|
||||
*/
|
||||
public function getSettingsForm(): array
|
||||
{
|
||||
@@ -53,10 +54,10 @@ class TurnstileSchema extends BaseSchema implements CaptchaSchemaInterface
|
||||
->onColor('success')
|
||||
->offColor('danger')
|
||||
->default(env('CAPTCHA_TURNSTILE_VERIFY_DOMAIN', true)),
|
||||
Placeholder::make('info')
|
||||
TextEntry::make('info')
|
||||
->label(trans('admin/setting.captcha.info_label'))
|
||||
->columnSpan(2)
|
||||
->content(new HtmlString(trans('admin/setting.captcha.info'))),
|
||||
->state(new HtmlString(trans('admin/setting.captcha.info'))),
|
||||
]);
|
||||
}
|
||||
|
||||
|
||||
@@ -7,13 +7,13 @@ use App\Facades\Activity;
|
||||
use App\Models\Permission;
|
||||
use App\Models\Server;
|
||||
use App\Models\ServerVariable;
|
||||
use App\Repositories\Daemon\DaemonPowerRepository;
|
||||
use App\Repositories\Daemon\DaemonServerRepository;
|
||||
use Closure;
|
||||
use Exception;
|
||||
use Filament\Actions\Action;
|
||||
use Filament\Facades\Filament;
|
||||
use Filament\Forms\Components\Placeholder;
|
||||
use Filament\Forms\Components\TextInput;
|
||||
use Filament\Infolists\Components\TextEntry;
|
||||
use Filament\Notifications\Notification;
|
||||
use Illuminate\Database\Eloquent\Builder;
|
||||
use Illuminate\Support\Facades\Blade;
|
||||
@@ -36,6 +36,9 @@ class GSLTokenSchema implements FeatureSchemaInterface
|
||||
return 'gsl_token';
|
||||
}
|
||||
|
||||
/**
|
||||
* @throws Exception
|
||||
*/
|
||||
public function getAction(): Action
|
||||
{
|
||||
/** @var Server $server */
|
||||
@@ -51,9 +54,9 @@ class GSLTokenSchema implements FeatureSchemaInterface
|
||||
->modalHeading('Invalid GSL token')
|
||||
->modalDescription('It seems like your Gameserver Login Token (GSL token) is invalid or has expired.')
|
||||
->modalSubmitActionLabel('Update GSL Token')
|
||||
->disabledForm(fn () => !auth()->user()->can(Permission::ACTION_STARTUP_UPDATE, $server))
|
||||
->form([
|
||||
Placeholder::make('info')
|
||||
->disabledSchema(fn () => !auth()->user()->can(Permission::ACTION_STARTUP_UPDATE, $server))
|
||||
->schema([
|
||||
TextEntry::make('info')
|
||||
->label(new HtmlString(Blade::render('You can either <x-filament::link href="https://steamcommunity.com/dev/managegameservers" target="_blank">generate a new one</x-filament::link> and enter it below or leave the field blank to remove it completely.'))),
|
||||
TextInput::make('gsltoken')
|
||||
->label('GSL Token')
|
||||
@@ -70,13 +73,12 @@ class GSLTokenSchema implements FeatureSchemaInterface
|
||||
}
|
||||
},
|
||||
])
|
||||
->hintIcon('tabler-code')
|
||||
->hintIcon('tabler-code', fn () => implode('|', $serverVariable->variable->rules))
|
||||
->label(fn () => $serverVariable->variable->name)
|
||||
->hintIconTooltip(fn () => implode('|', $serverVariable->variable->rules))
|
||||
->prefix(fn () => '{{' . $serverVariable->variable->env_variable . '}}')
|
||||
->helperText(fn () => empty($serverVariable->variable->description) ? '—' : $serverVariable->variable->description),
|
||||
])
|
||||
->action(function (array $data, DaemonPowerRepository $powerRepository) use ($server, $serverVariable) {
|
||||
->action(function (array $data, DaemonServerRepository $serverRepository) use ($server, $serverVariable) {
|
||||
/** @var Server $server */
|
||||
$server = Filament::getTenant();
|
||||
try {
|
||||
@@ -98,7 +100,7 @@ class GSLTokenSchema implements FeatureSchemaInterface
|
||||
->log();
|
||||
}
|
||||
|
||||
$powerRepository->setServer($server)->send('restart');
|
||||
$serverRepository->setServer($server)->power('restart');
|
||||
|
||||
Notification::make()
|
||||
->title('GSL Token updated')
|
||||
|
||||
@@ -6,12 +6,12 @@ use App\Extensions\Features\FeatureSchemaInterface;
|
||||
use App\Facades\Activity;
|
||||
use App\Models\Permission;
|
||||
use App\Models\Server;
|
||||
use App\Repositories\Daemon\DaemonPowerRepository;
|
||||
use App\Repositories\Daemon\DaemonServerRepository;
|
||||
use Exception;
|
||||
use Filament\Actions\Action;
|
||||
use Filament\Facades\Filament;
|
||||
use Filament\Forms\Components\Placeholder;
|
||||
use Filament\Forms\Components\Select;
|
||||
use Filament\Infolists\Components\TextEntry;
|
||||
use Filament\Notifications\Notification;
|
||||
|
||||
class JavaVersionSchema implements FeatureSchemaInterface
|
||||
@@ -44,9 +44,9 @@ class JavaVersionSchema implements FeatureSchemaInterface
|
||||
->modalHeading('Unsupported Java Version')
|
||||
->modalDescription('This server is currently running an unsupported version of Java and cannot be started.')
|
||||
->modalSubmitActionLabel('Update Docker Image')
|
||||
->disabledForm(fn () => !auth()->user()->can(Permission::ACTION_STARTUP_DOCKER_IMAGE, $server))
|
||||
->form([
|
||||
Placeholder::make('java')
|
||||
->disabledSchema(fn () => !auth()->user()->can(Permission::ACTION_STARTUP_DOCKER_IMAGE, $server))
|
||||
->schema([
|
||||
TextEntry::make('java')
|
||||
->label('Please select a supported version from the list below to continue starting the server.'),
|
||||
Select::make('image')
|
||||
->label('Docker Image')
|
||||
@@ -59,7 +59,7 @@ class JavaVersionSchema implements FeatureSchemaInterface
|
||||
->preload()
|
||||
->native(false),
|
||||
])
|
||||
->action(function (array $data, DaemonPowerRepository $powerRepository) use ($server) {
|
||||
->action(function (array $data, DaemonServerRepository $serverRepository) use ($server) {
|
||||
try {
|
||||
$new = $data['image'];
|
||||
$original = $server->image;
|
||||
@@ -71,7 +71,7 @@ class JavaVersionSchema implements FeatureSchemaInterface
|
||||
->log();
|
||||
}
|
||||
|
||||
$powerRepository->setServer($server)->send('restart');
|
||||
$serverRepository->setServer($server)->power('restart');
|
||||
|
||||
Notification::make()
|
||||
->title('Docker image updated')
|
||||
|
||||
@@ -5,7 +5,7 @@ namespace App\Extensions\Features\Schemas;
|
||||
use App\Extensions\Features\FeatureSchemaInterface;
|
||||
use App\Models\Server;
|
||||
use App\Repositories\Daemon\DaemonFileRepository;
|
||||
use App\Repositories\Daemon\DaemonPowerRepository;
|
||||
use App\Repositories\Daemon\DaemonServerRepository;
|
||||
use Exception;
|
||||
use Filament\Actions\Action;
|
||||
use Filament\Facades\Filament;
|
||||
@@ -35,14 +35,14 @@ class MinecraftEulaSchema implements FeatureSchemaInterface
|
||||
->modalHeading('Minecraft EULA')
|
||||
->modalDescription(new HtmlString(Blade::render('By pressing "I Accept" below you are indicating your agreement to the <x-filament::link href="https://minecraft.net/eula" target="_blank">Minecraft EULA </x-filament::link>.')))
|
||||
->modalSubmitActionLabel('I Accept')
|
||||
->action(function (DaemonFileRepository $fileRepository, DaemonPowerRepository $powerRepository) {
|
||||
->action(function (DaemonFileRepository $fileRepository, DaemonServerRepository $serverRepository) {
|
||||
try {
|
||||
/** @var Server $server */
|
||||
$server = Filament::getTenant();
|
||||
|
||||
$fileRepository->setServer($server)->putContent('eula.txt', 'eula=true');
|
||||
|
||||
$powerRepository->setServer($server)->send('restart');
|
||||
$serverRepository->setServer($server)->power('restart');
|
||||
|
||||
Notification::make()
|
||||
->title('Minecraft EULA accepted')
|
||||
|
||||
@@ -6,7 +6,7 @@ use App\Models\ApiKey;
|
||||
use Laravel\Sanctum\NewAccessToken as SanctumAccessToken;
|
||||
|
||||
/**
|
||||
* @property \App\Models\ApiKey $accessToken
|
||||
* @property ApiKey $accessToken
|
||||
*/
|
||||
class NewAccessToken extends SanctumAccessToken
|
||||
{
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
|
||||
namespace App\Extensions\Lcobucci\JWT\Encoding;
|
||||
|
||||
use DateTimeImmutable;
|
||||
use Lcobucci\JWT\ClaimsFormatter;
|
||||
use Lcobucci\JWT\Token\RegisteredClaims;
|
||||
|
||||
@@ -20,7 +21,7 @@ final class TimestampDates implements ClaimsFormatter
|
||||
continue;
|
||||
}
|
||||
|
||||
assert($claims[$claim] instanceof \DateTimeImmutable);
|
||||
assert($claims[$claim] instanceof DateTimeImmutable);
|
||||
$claims[$claim] = $claims[$claim]->getTimestamp();
|
||||
}
|
||||
|
||||
|
||||
@@ -2,8 +2,8 @@
|
||||
|
||||
namespace App\Extensions\OAuth;
|
||||
|
||||
use Filament\Forms\Components\Component;
|
||||
use Filament\Forms\Components\Wizard\Step;
|
||||
use Filament\Schemas\Components\Component;
|
||||
use Filament\Schemas\Components\Wizard\Step;
|
||||
|
||||
interface OAuthSchemaInterface
|
||||
{
|
||||
@@ -34,4 +34,6 @@ interface OAuthSchemaInterface
|
||||
public function isEnabled(): bool;
|
||||
|
||||
public function shouldCreateMissingUsers(): bool;
|
||||
|
||||
public function shouldLinkMissingUsers(): bool;
|
||||
}
|
||||
|
||||
@@ -2,13 +2,12 @@
|
||||
|
||||
namespace App\Extensions\OAuth\Schemas;
|
||||
|
||||
use Filament\Forms\Components\Placeholder;
|
||||
use Filament\Forms\Components\TextInput;
|
||||
use Filament\Forms\Components\Wizard\Step;
|
||||
use Filament\Infolists\Components\TextEntry;
|
||||
use Filament\Schemas\Components\Wizard\Step;
|
||||
use Illuminate\Support\Facades\Blade;
|
||||
use Illuminate\Support\HtmlString;
|
||||
use SocialiteProviders\Discord\Provider;
|
||||
use Webbingbrasil\FilamentCopyActions\Forms\Actions\CopyAction;
|
||||
|
||||
final class DiscordSchema extends OAuthSchema
|
||||
{
|
||||
@@ -27,15 +26,17 @@ final class DiscordSchema extends OAuthSchema
|
||||
return array_merge([
|
||||
Step::make('Register new Discord OAuth App')
|
||||
->schema([
|
||||
Placeholder::make('')
|
||||
->content(new HtmlString(Blade::render('<p>Visit the <x-filament::link href="https://discord.com/developers/applications" target="_blank">Discord Developer Portal</x-filament::link> and click on <b>New Application</b>. Enter a <b>Name</b> (e.g. your panel name) and click on <b>Create</b>.</p><p>Copy the <b>Client ID</b> and the <b>Client Secret</b> from the OAuth2 tab, you will need them in the final step.</p>'))),
|
||||
Placeholder::make('')
|
||||
->content(new HtmlString('<p>Under <b>Redirects</b> add the below URL.</p>')),
|
||||
TextEntry::make('create_application')
|
||||
->hiddenLabel()
|
||||
->state(new HtmlString(Blade::render('<p>Visit the <x-filament::link href="https://discord.com/developers/applications" target="_blank">Discord Developer Portal</x-filament::link> and click on <b>New Application</b>. Enter a <b>Name</b> (e.g. your panel name) and click on <b>Create</b>.</p><p>Copy the <b>Client ID</b> and the <b>Client Secret</b> from the OAuth2 tab, you will need them in the final step.</p>'))),
|
||||
TextEntry::make('set_redirect')
|
||||
->hiddenLabel()
|
||||
->state(new HtmlString('<p>Under <b>Redirects</b> add the below URL.</p>')),
|
||||
TextInput::make('_noenv_callback')
|
||||
->label('Redirect URL')
|
||||
->dehydrated()
|
||||
->disabled()
|
||||
->hintAction(fn (string $state) => request()->isSecure() ? CopyAction::make()->copyable($state) : null)
|
||||
->hintCopy()
|
||||
->formatStateUsing(fn () => url('/auth/oauth/callback/discord')),
|
||||
]),
|
||||
], parent::getSetupSteps());
|
||||
|
||||
@@ -2,12 +2,11 @@
|
||||
|
||||
namespace App\Extensions\OAuth\Schemas;
|
||||
|
||||
use Filament\Forms\Components\Placeholder;
|
||||
use Filament\Forms\Components\TextInput;
|
||||
use Filament\Forms\Components\Wizard\Step;
|
||||
use Filament\Infolists\Components\TextEntry;
|
||||
use Filament\Schemas\Components\Wizard\Step;
|
||||
use Illuminate\Support\Facades\Blade;
|
||||
use Illuminate\Support\HtmlString;
|
||||
use Webbingbrasil\FilamentCopyActions\Forms\Actions\CopyAction;
|
||||
|
||||
final class GithubSchema extends OAuthSchema
|
||||
{
|
||||
@@ -21,21 +20,24 @@ final class GithubSchema extends OAuthSchema
|
||||
return array_merge([
|
||||
Step::make('Register new Github OAuth App')
|
||||
->schema([
|
||||
Placeholder::make('')
|
||||
->content(new HtmlString(Blade::render('<p>Visit the <x-filament::link href="https://github.com/settings/developers" target="_blank">Github Developer Dashboard</x-filament::link>, go to <b>OAuth Apps</b> and click on <b>New OAuth App</b>.</p><p>Enter an <b>Application name</b> (e.g. your panel name), set <b>Homepage URL</b> to your panel url and enter the below url as <b>Authorization callback URL</b>.</p>'))),
|
||||
TextEntry::make('create_application')
|
||||
->hiddenLabel()
|
||||
->state(new HtmlString(Blade::render('<p>Visit the <x-filament::link href="https://github.com/settings/developers" target="_blank">Github Developer Dashboard</x-filament::link>, go to <b>OAuth Apps</b> and click on <b>New OAuth App</b>.</p><p>Enter an <b>Application name</b> (e.g. your panel name), set <b>Homepage URL</b> to your panel url and enter the below url as <b>Authorization callback URL</b>.</p>'))),
|
||||
TextInput::make('_noenv_callback')
|
||||
->label('Authorization callback URL')
|
||||
->dehydrated()
|
||||
->disabled()
|
||||
->hintAction(fn (string $state) => request()->isSecure() ? CopyAction::make()->copyable($state) : null)
|
||||
->hintCopy()
|
||||
->default(fn () => url('/auth/oauth/callback/github')),
|
||||
Placeholder::make('')
|
||||
->content(new HtmlString('<p>When you filled all fields click on <b>Register application</b>.</p>')),
|
||||
TextEntry::make('register_application')
|
||||
->hiddenLabel()
|
||||
->state(new HtmlString('<p>When you filled all fields click on <b>Register application</b>.</p>')),
|
||||
]),
|
||||
Step::make('Create Client Secret')
|
||||
->schema([
|
||||
Placeholder::make('')
|
||||
->content(new HtmlString('<p>Once you registered your app, generate a new <b>Client Secret</b>.</p><p>You will also need the <b>Client ID</b>.</p>')),
|
||||
TextEntry::make('create_client_secret')
|
||||
->hiddenLabel()
|
||||
->state(new HtmlString('<p>Once you registered your app, generate a new <b>Client Secret</b>.</p><p>You will also need the <b>Client ID</b>.</p>')),
|
||||
]),
|
||||
], parent::getSetupSteps());
|
||||
}
|
||||
|
||||
@@ -2,12 +2,11 @@
|
||||
|
||||
namespace App\Extensions\OAuth\Schemas;
|
||||
|
||||
use Filament\Forms\Components\Placeholder;
|
||||
use Filament\Forms\Components\TextInput;
|
||||
use Filament\Forms\Components\Wizard\Step;
|
||||
use Filament\Infolists\Components\TextEntry;
|
||||
use Filament\Schemas\Components\Wizard\Step;
|
||||
use Illuminate\Support\Facades\Blade;
|
||||
use Illuminate\Support\HtmlString;
|
||||
use Webbingbrasil\FilamentCopyActions\Forms\Actions\CopyAction;
|
||||
|
||||
final class GitlabSchema extends OAuthSchema
|
||||
{
|
||||
@@ -41,13 +40,14 @@ final class GitlabSchema extends OAuthSchema
|
||||
return array_merge([
|
||||
Step::make('Register new Gitlab OAuth App')
|
||||
->schema([
|
||||
Placeholder::make('')
|
||||
->content(new HtmlString(Blade::render('Check out the <x-filament::link href="https://docs.gitlab.com/integration/oauth_provider/" target="_blank">Gitlab docs</x-filament::link> on how to create the oauth app.'))),
|
||||
TextEntry::make('register_application')
|
||||
->hiddenLabel()
|
||||
->state(new HtmlString(Blade::render('Check out the <x-filament::link href="https://docs.gitlab.com/integration/oauth_provider/" target="_blank">Gitlab docs</x-filament::link> on how to create the oauth app.'))),
|
||||
TextInput::make('_noenv_callback')
|
||||
->label('Redirect URI')
|
||||
->dehydrated()
|
||||
->disabled()
|
||||
->hintAction(fn (string $state) => request()->isSecure() ? CopyAction::make()->copyable($state) : null)
|
||||
->hintCopy()
|
||||
->default(fn () => url('/auth/oauth/callback/gitlab')),
|
||||
]),
|
||||
], parent::getSetupSteps());
|
||||
|
||||
@@ -3,11 +3,11 @@
|
||||
namespace App\Extensions\OAuth\Schemas;
|
||||
|
||||
use App\Extensions\OAuth\OAuthSchemaInterface;
|
||||
use Filament\Forms\Components\Component;
|
||||
use Filament\Forms\Components\TextInput;
|
||||
use Filament\Forms\Components\Toggle;
|
||||
use Filament\Forms\Components\Wizard\Step;
|
||||
use Filament\Forms\Set;
|
||||
use Filament\Schemas\Components\Component;
|
||||
use Filament\Schemas\Components\Utilities\Set;
|
||||
use Filament\Schemas\Components\Wizard\Step;
|
||||
use Illuminate\Support\Str;
|
||||
|
||||
abstract class OAuthSchema implements OAuthSchemaInterface
|
||||
@@ -57,15 +57,26 @@ abstract class OAuthSchema implements OAuthSchemaInterface
|
||||
->default(env("OAUTH_{$id}_CLIENT_SECRET")),
|
||||
Toggle::make("OAUTH_{$id}_SHOULD_CREATE_MISSING_USERS")
|
||||
->label(trans('admin/setting.oauth.create_missing_users'))
|
||||
->columnSpanFull()
|
||||
->columnSpan(2)
|
||||
->inline(false)
|
||||
->onIcon('tabler-check')
|
||||
->offIcon('tabler-x')
|
||||
->onColor('success')
|
||||
->offColor('danger')
|
||||
->formatStateUsing(fn ($state): bool => (bool) $state)
|
||||
->formatStateUsing(fn ($state) => (bool) $state)
|
||||
->afterStateUpdated(fn ($state, Set $set) => $set("OAUTH_{$id}_SHOULD_CREATE_MISSING_USERS", (bool) $state))
|
||||
->default(env("OAUTH_{$id}_SHOULD_CREATE_MISSING_USERS")),
|
||||
Toggle::make("OAUTH_{$id}_SHOULD_LINK_MISSING_USERS")
|
||||
->label(trans('admin/setting.oauth.link_missing_users'))
|
||||
->columnSpan(2)
|
||||
->inline(false)
|
||||
->onIcon('tabler-check')
|
||||
->offIcon('tabler-x')
|
||||
->onColor('success')
|
||||
->offColor('danger')
|
||||
->formatStateUsing(fn ($state) => (bool) $state)
|
||||
->afterStateUpdated(fn ($state, Set $set) => $set("OAUTH_{$id}_SHOULD_LINK_MISSING_USERS", (bool) $state))
|
||||
->default(env("OAUTH_{$id}_SHOULD_LINK_MISSING_USERS")),
|
||||
];
|
||||
}
|
||||
|
||||
@@ -116,4 +127,11 @@ abstract class OAuthSchema implements OAuthSchemaInterface
|
||||
|
||||
return env("OAUTH_{$id}_SHOULD_CREATE_MISSING_USERS", false);
|
||||
}
|
||||
|
||||
public function shouldLinkMissingUsers(): bool
|
||||
{
|
||||
$id = Str::upper($this->getId());
|
||||
|
||||
return env("OAUTH_{$id}_SHOULD_LINK_MISSING_USERS", false);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,9 +2,9 @@
|
||||
|
||||
namespace App\Extensions\OAuth\Schemas;
|
||||
|
||||
use Filament\Forms\Components\Placeholder;
|
||||
use Filament\Forms\Components\TextInput;
|
||||
use Filament\Forms\Components\Wizard\Step;
|
||||
use Filament\Infolists\Components\TextEntry;
|
||||
use Filament\Schemas\Components\Wizard\Step;
|
||||
use Illuminate\Support\Facades\Blade;
|
||||
use Illuminate\Support\HtmlString;
|
||||
use SocialiteProviders\Steam\Provider;
|
||||
@@ -52,8 +52,9 @@ final class SteamSchema extends OAuthSchema
|
||||
return array_merge([
|
||||
Step::make('Create API Key')
|
||||
->schema([
|
||||
Placeholder::make('')
|
||||
->content(new HtmlString(Blade::render('Visit <x-filament::link href="https://steamcommunity.com/dev/apikey" target="_blank">https://steamcommunity.com/dev/apikey</x-filament::link> to generate an API key.'))),
|
||||
TextEntry::make('create_api_key')
|
||||
->hiddenLabel()
|
||||
->state(new HtmlString(Blade::render('Visit <x-filament::link href="https://steamcommunity.com/dev/apikey" target="_blank">https://steamcommunity.com/dev/apikey</x-filament::link> to generate an API key.'))),
|
||||
]),
|
||||
], parent::getSetupSteps());
|
||||
}
|
||||
|
||||
@@ -2,20 +2,22 @@
|
||||
|
||||
namespace App\Extensions\Spatie\Fractalistic;
|
||||
|
||||
use App\Extensions\League\Fractal\Serializers\PanelSerializer;
|
||||
use Illuminate\Contracts\Pagination\LengthAwarePaginator;
|
||||
use League\Fractal\Pagination\IlluminatePaginatorAdapter;
|
||||
use League\Fractal\Scope;
|
||||
use League\Fractal\TransformerAbstract;
|
||||
use Spatie\Fractal\Fractal as SpatieFractal;
|
||||
use Illuminate\Contracts\Pagination\LengthAwarePaginator;
|
||||
use League\Fractal\Pagination\IlluminatePaginatorAdapter;
|
||||
use App\Extensions\League\Fractal\Serializers\PanelSerializer;
|
||||
use Spatie\Fractalistic\Exceptions\InvalidTransformation;
|
||||
use Spatie\Fractalistic\Exceptions\NoTransformerSpecified;
|
||||
|
||||
class Fractal extends SpatieFractal
|
||||
{
|
||||
/**
|
||||
* Create fractal data.
|
||||
*
|
||||
* @throws \Spatie\Fractalistic\Exceptions\InvalidTransformation
|
||||
* @throws \Spatie\Fractalistic\Exceptions\NoTransformerSpecified
|
||||
* @throws InvalidTransformation
|
||||
* @throws NoTransformerSpecified
|
||||
*/
|
||||
public function createData(): Scope
|
||||
{
|
||||
|
||||
@@ -2,8 +2,8 @@
|
||||
|
||||
namespace App\Facades;
|
||||
|
||||
use Illuminate\Support\Facades\Facade;
|
||||
use App\Services\Activity\ActivityLogService;
|
||||
use Illuminate\Support\Facades\Facade;
|
||||
|
||||
class Activity extends Facade
|
||||
{
|
||||
|
||||
@@ -2,8 +2,8 @@
|
||||
|
||||
namespace App\Facades;
|
||||
|
||||
use Illuminate\Support\Facades\Facade;
|
||||
use App\Services\Activity\ActivityLogTargetableService;
|
||||
use Illuminate\Support\Facades\Facade;
|
||||
|
||||
class LogTarget extends Facade
|
||||
{
|
||||
|
||||
@@ -7,7 +7,7 @@ use Filament\Pages\Dashboard as BaseDashboard;
|
||||
|
||||
class Dashboard extends BaseDashboard
|
||||
{
|
||||
protected static ?string $navigationIcon = 'tabler-layout-dashboard';
|
||||
protected static string|\BackedEnum|null $navigationIcon = 'tabler-layout-dashboard';
|
||||
|
||||
private SoftwareVersionService $softwareVersionService;
|
||||
|
||||
@@ -16,7 +16,7 @@ class Dashboard extends BaseDashboard
|
||||
$this->softwareVersionService = $softwareVersionService;
|
||||
}
|
||||
|
||||
public function getColumns(): int
|
||||
public function getColumns(): int|array
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
@@ -13,9 +13,9 @@ use Spatie\Health\ResultStores\ResultStore;
|
||||
|
||||
class Health extends Page
|
||||
{
|
||||
protected static ?string $navigationIcon = 'tabler-heart';
|
||||
protected static string|\BackedEnum|null $navigationIcon = 'tabler-heart';
|
||||
|
||||
protected static string $view = 'filament.pages.health';
|
||||
protected string $view = 'filament.pages.health';
|
||||
|
||||
/** @var array<string, string> */
|
||||
protected $listeners = [
|
||||
@@ -123,7 +123,7 @@ class Health extends Page
|
||||
return $carry;
|
||||
}, []);
|
||||
|
||||
return trans('admin/health.checks.failed') . implode(', ', $failedNames);
|
||||
return trans('admin/health.checks.failed', ['checks' => implode(', ', $failedNames)]);
|
||||
}
|
||||
|
||||
public static function getNavigationIcon(): string
|
||||
|
||||
@@ -10,32 +10,33 @@ use App\Notifications\MailTested;
|
||||
use App\Traits\EnvironmentWriterTrait;
|
||||
use App\Traits\Filament\CanCustomizeHeaderActions;
|
||||
use App\Traits\Filament\CanCustomizeHeaderWidgets;
|
||||
use BackedEnum;
|
||||
use Exception;
|
||||
use Filament\Actions\Action;
|
||||
use Filament\Actions\ActionGroup;
|
||||
use Filament\Forms\Components\Actions;
|
||||
use Filament\Forms\Components\Actions\Action as FormAction;
|
||||
use Filament\Forms\Components\Component;
|
||||
use Filament\Forms\Components\FileUpload;
|
||||
use Filament\Forms\Components\Group;
|
||||
use Filament\Forms\Components\Hidden;
|
||||
use Filament\Forms\Components\Section;
|
||||
use Filament\Forms\Components\Select;
|
||||
use Filament\Forms\Components\Tabs;
|
||||
use Filament\Forms\Components\Tabs\Tab;
|
||||
use Filament\Forms\Components\TagsInput;
|
||||
use Filament\Forms\Components\TextInput;
|
||||
use Filament\Forms\Components\Toggle;
|
||||
use Filament\Forms\Components\ToggleButtons;
|
||||
use Filament\Forms\Concerns\InteractsWithForms;
|
||||
use Filament\Forms\Contracts\HasForms;
|
||||
use Filament\Forms\Form;
|
||||
use Filament\Forms\Get;
|
||||
use Filament\Forms\Set;
|
||||
use Filament\Notifications\Notification;
|
||||
use Filament\Pages\Concerns\InteractsWithHeaderActions;
|
||||
use Filament\Pages\Page;
|
||||
use Filament\Support\Enums\MaxWidth;
|
||||
use Filament\Schemas\Components\Actions;
|
||||
use Filament\Schemas\Components\Component;
|
||||
use Filament\Schemas\Components\Group;
|
||||
use Filament\Schemas\Components\Section;
|
||||
use Filament\Schemas\Components\StateCasts\BooleanStateCast;
|
||||
use Filament\Schemas\Components\Tabs;
|
||||
use Filament\Schemas\Components\Tabs\Tab;
|
||||
use Filament\Schemas\Components\Utilities\Get;
|
||||
use Filament\Schemas\Components\Utilities\Set;
|
||||
use Filament\Schemas\Contracts\HasSchemas;
|
||||
use Filament\Schemas\Schema;
|
||||
use Filament\Support\Enums\Width;
|
||||
use Illuminate\Http\Client\Factory;
|
||||
use Illuminate\Support\Arr;
|
||||
use Illuminate\Support\Facades\Artisan;
|
||||
@@ -43,9 +44,9 @@ use Illuminate\Support\Facades\Notification as MailNotification;
|
||||
use Illuminate\Support\Str;
|
||||
|
||||
/**
|
||||
* @property Form $form
|
||||
* @property Schema $form
|
||||
*/
|
||||
class Settings extends Page implements HasForms
|
||||
class Settings extends Page implements HasSchemas
|
||||
{
|
||||
use CanCustomizeHeaderActions, InteractsWithHeaderActions {
|
||||
CanCustomizeHeaderActions::getHeaderActions insteadof InteractsWithHeaderActions;
|
||||
@@ -54,9 +55,9 @@ class Settings extends Page implements HasForms
|
||||
use EnvironmentWriterTrait;
|
||||
use InteractsWithForms;
|
||||
|
||||
protected static ?string $navigationIcon = 'tabler-settings';
|
||||
protected static string|\BackedEnum|null $navigationIcon = 'tabler-settings';
|
||||
|
||||
protected static string $view = 'filament.pages.settings';
|
||||
protected string $view = 'filament.pages.settings';
|
||||
|
||||
protected OAuthService $oauthService;
|
||||
|
||||
@@ -94,6 +95,11 @@ class Settings extends Page implements HasForms
|
||||
return trans('admin/setting.title');
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array<Component>
|
||||
*
|
||||
* @throws Exception
|
||||
*/
|
||||
protected function getFormSchema(): array
|
||||
{
|
||||
return [
|
||||
@@ -110,7 +116,7 @@ class Settings extends Page implements HasForms
|
||||
->label(trans('admin/setting.navigation.captcha'))
|
||||
->icon('tabler-shield')
|
||||
->schema($this->captchaSettings())
|
||||
->columns(3),
|
||||
->columns(1),
|
||||
Tab::make('mail')
|
||||
->label(trans('admin/setting.navigation.mail'))
|
||||
->icon('tabler-mail')
|
||||
@@ -119,10 +125,11 @@ class Settings extends Page implements HasForms
|
||||
->label(trans('admin/setting.navigation.backup'))
|
||||
->icon('tabler-box')
|
||||
->schema($this->backupSettings()),
|
||||
Tab::make('OAuth')
|
||||
Tab::make('oauth')
|
||||
->label(trans('admin/setting.navigation.oauth'))
|
||||
->icon('tabler-brand-oauth')
|
||||
->schema($this->oauthSettings()),
|
||||
->schema($this->oauthSettings())
|
||||
->columns(1),
|
||||
Tab::make('misc')
|
||||
->label(trans('admin/setting.navigation.misc'))
|
||||
->icon('tabler-tool')
|
||||
@@ -131,7 +138,9 @@ class Settings extends Page implements HasForms
|
||||
];
|
||||
}
|
||||
|
||||
/** @return Component[] */
|
||||
/** @return Component[]
|
||||
* @throws Exception
|
||||
*/
|
||||
private function generalSettings(): array
|
||||
{
|
||||
return [
|
||||
@@ -144,14 +153,12 @@ class Settings extends Page implements HasForms
|
||||
->schema([
|
||||
TextInput::make('APP_LOGO')
|
||||
->label(trans('admin/setting.general.app_logo'))
|
||||
->hintIcon('tabler-question-mark')
|
||||
->hintIconTooltip(trans('admin/setting.general.app_logo_help'))
|
||||
->hintIcon('tabler-question-mark', trans('admin/setting.general.app_logo_help'))
|
||||
->default(env('APP_LOGO'))
|
||||
->placeholder('/pelican.svg'),
|
||||
TextInput::make('APP_FAVICON')
|
||||
->label(trans('admin/setting.general.app_favicon'))
|
||||
->hintIcon('tabler-question-mark')
|
||||
->hintIconTooltip(trans('admin/setting.general.app_favicon_help'))
|
||||
->hintIcon('tabler-question-mark', trans('admin/setting.general.app_favicon_help'))
|
||||
->required()
|
||||
->default(env('APP_FAVICON', '/pelican.ico'))
|
||||
->placeholder('/pelican.ico'),
|
||||
@@ -166,8 +173,7 @@ class Settings extends Page implements HasForms
|
||||
->offIcon('tabler-x')
|
||||
->onColor('success')
|
||||
->offColor('danger')
|
||||
->formatStateUsing(fn ($state): bool => (bool) $state)
|
||||
->afterStateUpdated(fn ($state, Set $set) => $set('APP_DEBUG', (bool) $state))
|
||||
->stateCast(new BooleanStateCast(false))
|
||||
->default(env('APP_DEBUG', config('app.debug'))),
|
||||
]),
|
||||
Group::make()
|
||||
@@ -186,19 +192,17 @@ class Settings extends Page implements HasForms
|
||||
->offIcon('tabler-x')
|
||||
->onColor('success')
|
||||
->offColor('danger')
|
||||
->formatStateUsing(fn ($state) => (bool) $state)
|
||||
->afterStateUpdated(fn ($state, Set $set) => $set('FILAMENT_UPLOADABLE_AVATARS', (bool) $state))
|
||||
->stateCast(new BooleanStateCast(false))
|
||||
->default(env('FILAMENT_UPLOADABLE_AVATARS', config('panel.filament.uploadable-avatars'))),
|
||||
]),
|
||||
ToggleButtons::make('PANEL_USE_BINARY_PREFIX')
|
||||
->label(trans('admin/setting.general.unit_prefix'))
|
||||
->inline()
|
||||
->options([
|
||||
false => trans('admin/setting.general.decimal_prefix'),
|
||||
true => trans('admin/setting.general.binary_prefix'),
|
||||
0 => trans('admin/setting.general.decimal_prefix'),
|
||||
1 => trans('admin/setting.general.binary_prefix'),
|
||||
])
|
||||
->formatStateUsing(fn ($state): bool => (bool) $state)
|
||||
->afterStateUpdated(fn ($state, Set $set) => $set('PANEL_USE_BINARY_PREFIX', (bool) $state))
|
||||
->stateCast(new BooleanStateCast(false, true))
|
||||
->default(env('PANEL_USE_BINARY_PREFIX', config('panel.use_binary_prefix'))),
|
||||
ToggleButtons::make('APP_2FA_REQUIRED')
|
||||
->label(trans('admin/setting.general.2fa_requirement'))
|
||||
@@ -214,7 +218,7 @@ class Settings extends Page implements HasForms
|
||||
Select::make('FILAMENT_WIDTH')
|
||||
->label(trans('admin/setting.general.display_width'))
|
||||
->native(false)
|
||||
->options(MaxWidth::class)
|
||||
->options(Width::class)
|
||||
->selectablePlaceholder(false)
|
||||
->default(env('FILAMENT_WIDTH', config('panel.filament.display-width'))),
|
||||
TagsInput::make('TRUSTED_PROXIES')
|
||||
@@ -224,14 +228,14 @@ class Settings extends Page implements HasForms
|
||||
->placeholder(trans('admin/setting.general.trusted_proxies_help'))
|
||||
->default(env('TRUSTED_PROXIES', implode(',', Arr::wrap(config('trustedproxy.proxies')))))
|
||||
->hintActions([
|
||||
FormAction::make('clear')
|
||||
Action::make('clear')
|
||||
->label(trans('admin/setting.general.clear'))
|
||||
->color('danger')
|
||||
->icon('tabler-trash')
|
||||
->requiresConfirmation()
|
||||
->authorize(fn () => auth()->user()->can('update settings'))
|
||||
->action(fn (Set $set) => $set('TRUSTED_PROXIES', [])),
|
||||
FormAction::make('cloudflare')
|
||||
Action::make('cloudflare')
|
||||
->label(trans('admin/setting.general.set_to_cf'))
|
||||
->icon('tabler-brand-cloudflare')
|
||||
->authorize(fn () => auth()->user()->can('update settings'))
|
||||
@@ -262,6 +266,8 @@ class Settings extends Page implements HasForms
|
||||
|
||||
/**
|
||||
* @return Component[]
|
||||
*
|
||||
* @throws Exception
|
||||
*/
|
||||
private function captchaSettings(): array
|
||||
{
|
||||
@@ -281,12 +287,12 @@ class Settings extends Page implements HasForms
|
||||
->live()
|
||||
->default(env("CAPTCHA_{$id}_ENABLED")),
|
||||
Actions::make([
|
||||
FormAction::make("disable_captcha_$id")
|
||||
Action::make("disable_captcha_$id")
|
||||
->visible(fn (Get $get) => $get("CAPTCHA_{$id}_ENABLED"))
|
||||
->label(trans('admin/setting.captcha.disable'))
|
||||
->color('danger')
|
||||
->action(fn (Set $set) => $set("CAPTCHA_{$id}_ENABLED", false)),
|
||||
FormAction::make("enable_captcha_$id")
|
||||
Action::make("enable_captcha_$id")
|
||||
->visible(fn (Get $get) => !$get("CAPTCHA_{$id}_ENABLED"))
|
||||
->label(trans('admin/setting.captcha.enable'))
|
||||
->color('success')
|
||||
@@ -304,6 +310,8 @@ class Settings extends Page implements HasForms
|
||||
|
||||
/**
|
||||
* @return Component[]
|
||||
*
|
||||
* @throws Exception
|
||||
*/
|
||||
private function mailSettings(): array
|
||||
{
|
||||
@@ -323,7 +331,7 @@ class Settings extends Page implements HasForms
|
||||
->live()
|
||||
->default(env('MAIL_MAILER', config('mail.default')))
|
||||
->hintAction(
|
||||
FormAction::make('test')
|
||||
Action::make('test')
|
||||
->label(trans('admin/setting.mail.test_mail'))
|
||||
->icon('tabler-send')
|
||||
->hidden(fn (Get $get) => $get('MAIL_MAILER') === 'log')
|
||||
@@ -381,6 +389,7 @@ class Settings extends Page implements HasForms
|
||||
Section::make(trans('admin/setting.mail.from_settings'))
|
||||
->description(trans('admin/setting.mail.from_settings_help'))
|
||||
->columns()
|
||||
->columnSpanFull()
|
||||
->schema([
|
||||
TextInput::make('MAIL_FROM_ADDRESS')
|
||||
->label(trans('admin/setting.mail.from_address'))
|
||||
@@ -394,6 +403,7 @@ class Settings extends Page implements HasForms
|
||||
]),
|
||||
Section::make(trans('admin/setting.mail.smtp.smtp_title'))
|
||||
->columns()
|
||||
->columnSpanFull()
|
||||
->visible(fn (Get $get) => $get('MAIL_MAILER') === 'smtp')
|
||||
->schema([
|
||||
TextInput::make('MAIL_HOST')
|
||||
@@ -430,6 +440,7 @@ class Settings extends Page implements HasForms
|
||||
]),
|
||||
Section::make(trans('admin/setting.mail.mailgun.mailgun_title'))
|
||||
->columns()
|
||||
->columnSpanFull()
|
||||
->visible(fn (Get $get) => $get('MAIL_MAILER') === 'mailgun')
|
||||
->schema([
|
||||
TextInput::make('MAILGUN_DOMAIN')
|
||||
@@ -450,6 +461,8 @@ class Settings extends Page implements HasForms
|
||||
|
||||
/**
|
||||
* @return Component[]
|
||||
*
|
||||
* @throws Exception
|
||||
*/
|
||||
private function backupSettings(): array
|
||||
{
|
||||
@@ -467,6 +480,7 @@ class Settings extends Page implements HasForms
|
||||
Section::make(trans('admin/setting.backup.throttle'))
|
||||
->description(trans('admin/setting.backup.throttle_help'))
|
||||
->columns()
|
||||
->columnSpanFull()
|
||||
->schema([
|
||||
TextInput::make('BACKUP_THROTTLE_LIMIT')
|
||||
->label(trans('admin/setting.backup.limit'))
|
||||
@@ -514,8 +528,7 @@ class Settings extends Page implements HasForms
|
||||
->onColor('success')
|
||||
->offColor('danger')
|
||||
->live()
|
||||
->formatStateUsing(fn ($state): bool => (bool) $state)
|
||||
->afterStateUpdated(fn ($state, Set $set) => $set('AWS_USE_PATH_STYLE_ENDPOINT', (bool) $state))
|
||||
->stateCast(new BooleanStateCast(false))
|
||||
->default(env('AWS_USE_PATH_STYLE_ENDPOINT', config('backups.disks.s3.use_path_style_endpoint'))),
|
||||
]),
|
||||
];
|
||||
@@ -523,6 +536,8 @@ class Settings extends Page implements HasForms
|
||||
|
||||
/**
|
||||
* @return Component[]
|
||||
*
|
||||
* @throws Exception
|
||||
*/
|
||||
private function oauthSettings(): array
|
||||
{
|
||||
@@ -543,17 +558,17 @@ class Settings extends Page implements HasForms
|
||||
->live()
|
||||
->default(env($key)),
|
||||
Actions::make([
|
||||
FormAction::make("disable_oauth_$id")
|
||||
Action::make("disable_oauth_$id")
|
||||
->visible(fn (Get $get) => $get($key))
|
||||
->label(trans('admin/setting.oauth.disable'))
|
||||
->color('danger')
|
||||
->action(fn (Set $set) => $set($key, false)),
|
||||
FormAction::make("enable_oauth_$id")
|
||||
Action::make("enable_oauth_$id")
|
||||
->visible(fn (Get $get) => !$get($key))
|
||||
->label(trans('admin/setting.oauth.enable'))
|
||||
->color('success')
|
||||
->steps($schema->getSetupSteps())
|
||||
->modalHeading(trans('admin/setting.oauth.enable') . ' ' . $schema->getName())
|
||||
->modalHeading(trans('admin/setting.oauth.enable_schema', ['schema' => $schema->getName()]))
|
||||
->modalSubmitActionLabel(trans('admin/setting.oauth.enable'))
|
||||
->modalCancelAction(false)
|
||||
->action(function ($data, Set $set) use ($key) {
|
||||
@@ -578,6 +593,8 @@ class Settings extends Page implements HasForms
|
||||
|
||||
/**
|
||||
* @return Component[]
|
||||
*
|
||||
* @throws Exception
|
||||
*/
|
||||
private function miscSettings(): array
|
||||
{
|
||||
@@ -596,8 +613,7 @@ class Settings extends Page implements HasForms
|
||||
->offColor('danger')
|
||||
->live()
|
||||
->columnSpanFull()
|
||||
->formatStateUsing(fn ($state): bool => (bool) $state)
|
||||
->afterStateUpdated(fn ($state, Set $set) => $set('PANEL_CLIENT_ALLOCATIONS_ENABLED', (bool) $state))
|
||||
->stateCast(new BooleanStateCast(false))
|
||||
->default(env('PANEL_CLIENT_ALLOCATIONS_ENABLED', config('panel.client_features.allocations.enabled'))),
|
||||
TextInput::make('PANEL_CLIENT_ALLOCATIONS_RANGE_START')
|
||||
->label(trans('admin/setting.misc.auto_allocation.start'))
|
||||
@@ -688,8 +704,7 @@ class Settings extends Page implements HasForms
|
||||
->onColor('success')
|
||||
->offColor('danger')
|
||||
->live()
|
||||
->formatStateUsing(fn ($state): bool => (bool) $state)
|
||||
->afterStateUpdated(fn ($state, Set $set) => $set('APP_ACTIVITY_HIDE_ADMIN', (bool) $state))
|
||||
->stateCast(new BooleanStateCast(false))
|
||||
->default(env('APP_ACTIVITY_HIDE_ADMIN', config('activity.hide_admin_activity'))),
|
||||
]),
|
||||
Section::make(trans('admin/setting.misc.api.title'))
|
||||
@@ -767,8 +782,19 @@ class Settings extends Page implements HasForms
|
||||
$data = $this->form->getState();
|
||||
unset($data['ConsoleFonts']);
|
||||
|
||||
// Convert bools to a string, so they are correctly written to the .env file
|
||||
$data = array_map(fn ($value) => is_bool($value) ? ($value ? 'true' : 'false') : $value, $data);
|
||||
$data = array_map(function ($value) {
|
||||
// Convert bools to a string, so they are correctly written to the .env file
|
||||
if (is_bool($value)) {
|
||||
return $value ? 'true' : 'false';
|
||||
}
|
||||
|
||||
// Convert enum to its value
|
||||
if ($value instanceof BackedEnum) {
|
||||
return $value->value;
|
||||
}
|
||||
|
||||
return $value;
|
||||
}, $data);
|
||||
|
||||
$this->writeToEnvironment($data);
|
||||
|
||||
|
||||
@@ -1,24 +1,26 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Admin\Resources;
|
||||
namespace App\Filament\Admin\Resources\ApiKeys;
|
||||
|
||||
use App\Filament\Admin\Resources\ApiKeyResource\Pages;
|
||||
use App\Filament\Admin\Resources\UserResource\Pages\EditUser;
|
||||
use App\Filament\Admin\Resources\ApiKeys\Pages\CreateApiKey;
|
||||
use App\Filament\Admin\Resources\ApiKeys\Pages\ListApiKeys;
|
||||
use App\Filament\Admin\Resources\Users\Pages\EditUser;
|
||||
use App\Filament\Components\Tables\Columns\DateTimeColumn;
|
||||
use App\Models\ApiKey;
|
||||
use App\Traits\Filament\CanCustomizePages;
|
||||
use App\Traits\Filament\CanCustomizeRelations;
|
||||
use App\Traits\Filament\CanModifyForm;
|
||||
use App\Traits\Filament\CanModifyTable;
|
||||
use Filament\Forms\Components\Fieldset;
|
||||
use Exception;
|
||||
use Filament\Actions\CreateAction;
|
||||
use Filament\Actions\DeleteAction;
|
||||
use Filament\Forms\Components\TagsInput;
|
||||
use Filament\Forms\Components\Textarea;
|
||||
use Filament\Forms\Components\ToggleButtons;
|
||||
use Filament\Forms\Form;
|
||||
use Filament\Resources\Pages\PageRegistration;
|
||||
use Filament\Resources\Resource;
|
||||
use Filament\Tables\Actions\CreateAction;
|
||||
use Filament\Tables\Actions\DeleteAction;
|
||||
use Filament\Schemas\Components\Fieldset;
|
||||
use Filament\Schemas\Schema;
|
||||
use Filament\Tables\Columns\TextColumn;
|
||||
use Filament\Tables\Table;
|
||||
use Illuminate\Database\Eloquent\Builder;
|
||||
@@ -32,7 +34,7 @@ class ApiKeyResource extends Resource
|
||||
|
||||
protected static ?string $model = ApiKey::class;
|
||||
|
||||
protected static ?string $navigationIcon = 'tabler-key';
|
||||
protected static string|\BackedEnum|null $navigationIcon = 'tabler-key';
|
||||
|
||||
public static function getNavigationLabel(): string
|
||||
{
|
||||
@@ -66,6 +68,9 @@ class ApiKeyResource extends Resource
|
||||
return trans('admin/dashboard.advanced');
|
||||
}
|
||||
|
||||
/**
|
||||
* @throws Exception
|
||||
*/
|
||||
public static function defaultTable(Table $table): Table
|
||||
{
|
||||
return $table
|
||||
@@ -88,30 +93,28 @@ class ApiKeyResource extends Resource
|
||||
->sortable(),
|
||||
TextColumn::make('user.username')
|
||||
->label(trans('admin/apikey.table.created_by'))
|
||||
->icon('tabler-user')
|
||||
->url(fn (ApiKey $apiKey) => auth()->user()->can('update', $apiKey->user) ? EditUser::getUrl(['record' => $apiKey->user]) : null),
|
||||
])
|
||||
->actions([
|
||||
->recordActions([
|
||||
DeleteAction::make(),
|
||||
])
|
||||
->emptyStateIcon('tabler-key')
|
||||
->emptyStateDescription('')
|
||||
->emptyStateHeading(trans('admin/apikey.empty_table'))
|
||||
->emptyStateHeading(trans('admin/apikey.empty'))
|
||||
->emptyStateActions([
|
||||
CreateAction::make(),
|
||||
]);
|
||||
}
|
||||
|
||||
public static function defaultForm(Form $form): Form
|
||||
/**
|
||||
* @throws Exception
|
||||
*/
|
||||
public static function defaultForm(Schema $schema): Schema
|
||||
{
|
||||
return $form
|
||||
->schema([
|
||||
return $schema
|
||||
->components([
|
||||
Fieldset::make('Permissions')
|
||||
->columns([
|
||||
'default' => 1,
|
||||
'sm' => 1,
|
||||
'md' => 2,
|
||||
])
|
||||
->columnSpanFull()
|
||||
->schema(
|
||||
collect(ApiKey::getPermissionList())->map(fn ($resource) => ToggleButtons::make('permissions_' . $resource)
|
||||
->label(str($resource)->replace('_', ' ')->title())->inline()
|
||||
@@ -156,8 +159,8 @@ class ApiKeyResource extends Resource
|
||||
public static function getDefaultPages(): array
|
||||
{
|
||||
return [
|
||||
'index' => Pages\ListApiKeys::route('/'),
|
||||
'create' => Pages\CreateApiKey::route('/create'),
|
||||
'index' => ListApiKeys::route('/'),
|
||||
'create' => CreateApiKey::route('/create'),
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -1,8 +1,8 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Admin\Resources\ApiKeyResource\Pages;
|
||||
namespace App\Filament\Admin\Resources\ApiKeys\Pages;
|
||||
|
||||
use App\Filament\Admin\Resources\ApiKeyResource;
|
||||
use App\Filament\Admin\Resources\ApiKeys\ApiKeyResource;
|
||||
use App\Models\ApiKey;
|
||||
use App\Traits\Filament\CanCustomizeHeaderActions;
|
||||
use App\Traits\Filament\CanCustomizeHeaderWidgets;
|
||||
@@ -10,6 +10,7 @@ use Filament\Actions\Action;
|
||||
use Filament\Actions\ActionGroup;
|
||||
use Filament\Resources\Pages\CreateRecord;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Support\Str;
|
||||
|
||||
class CreateApiKey extends CreateRecord
|
||||
{
|
||||
@@ -36,7 +37,7 @@ class CreateApiKey extends CreateRecord
|
||||
protected function handleRecordCreation(array $data): Model
|
||||
{
|
||||
$data['identifier'] = ApiKey::generateTokenIdentifier(ApiKey::TYPE_APPLICATION);
|
||||
$data['token'] = str_random(ApiKey::KEY_LENGTH);
|
||||
$data['token'] = Str::random(ApiKey::KEY_LENGTH);
|
||||
$data['user_id'] = auth()->user()->id;
|
||||
$data['key_type'] = ApiKey::TYPE_APPLICATION;
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Admin\Resources\ApiKeyResource\Pages;
|
||||
namespace App\Filament\Admin\Resources\ApiKeys\Pages;
|
||||
|
||||
use App\Filament\Admin\Resources\ApiKeyResource;
|
||||
use App\Filament\Admin\Resources\ApiKeys\ApiKeyResource;
|
||||
use App\Models\ApiKey;
|
||||
use App\Traits\Filament\CanCustomizeHeaderActions;
|
||||
use App\Traits\Filament\CanCustomizeHeaderWidgets;
|
||||
@@ -1,26 +1,30 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Admin\Resources;
|
||||
namespace App\Filament\Admin\Resources\DatabaseHosts;
|
||||
|
||||
use App\Filament\Admin\Resources\DatabaseHostResource\Pages;
|
||||
use App\Filament\Admin\Resources\DatabaseHostResource\RelationManagers;
|
||||
use App\Filament\Admin\Resources\DatabaseHosts\Pages\CreateDatabaseHost;
|
||||
use App\Filament\Admin\Resources\DatabaseHosts\Pages\EditDatabaseHost;
|
||||
use App\Filament\Admin\Resources\DatabaseHosts\Pages\ListDatabaseHosts;
|
||||
use App\Filament\Admin\Resources\DatabaseHosts\Pages\ViewDatabaseHost;
|
||||
use App\Filament\Admin\Resources\DatabaseHosts\RelationManagers\DatabasesRelationManager;
|
||||
use App\Models\DatabaseHost;
|
||||
use App\Traits\Filament\CanCustomizePages;
|
||||
use App\Traits\Filament\CanCustomizeRelations;
|
||||
use App\Traits\Filament\CanModifyForm;
|
||||
use App\Traits\Filament\CanModifyTable;
|
||||
use Filament\Forms\Components\Section;
|
||||
use Exception;
|
||||
use Filament\Actions\CreateAction;
|
||||
use Filament\Actions\DeleteBulkAction;
|
||||
use Filament\Actions\EditAction;
|
||||
use Filament\Actions\ViewAction;
|
||||
use Filament\Forms\Components\Select;
|
||||
use Filament\Forms\Components\TextInput;
|
||||
use Filament\Forms\Form;
|
||||
use Filament\Forms\Set;
|
||||
use Filament\Resources\Pages\PageRegistration;
|
||||
use Filament\Resources\RelationManagers\RelationManager;
|
||||
use Filament\Resources\Resource;
|
||||
use Filament\Tables\Actions\CreateAction;
|
||||
use Filament\Tables\Actions\DeleteBulkAction;
|
||||
use Filament\Tables\Actions\EditAction;
|
||||
use Filament\Tables\Actions\ViewAction;
|
||||
use Filament\Schemas\Components\Section;
|
||||
use Filament\Schemas\Components\Utilities\Set;
|
||||
use Filament\Schemas\Schema;
|
||||
use Filament\Tables\Columns\TextColumn;
|
||||
use Filament\Tables\Table;
|
||||
use Illuminate\Database\Eloquent\Builder;
|
||||
@@ -34,7 +38,7 @@ class DatabaseHostResource extends Resource
|
||||
|
||||
protected static ?string $model = DatabaseHost::class;
|
||||
|
||||
protected static ?string $navigationIcon = 'tabler-database';
|
||||
protected static string|\BackedEnum|null $navigationIcon = 'tabler-database';
|
||||
|
||||
protected static ?string $recordTitleAttribute = 'name';
|
||||
|
||||
@@ -63,6 +67,9 @@ class DatabaseHostResource extends Resource
|
||||
return trans('admin/dashboard.advanced');
|
||||
}
|
||||
|
||||
/**
|
||||
* @throws Exception
|
||||
*/
|
||||
public static function defaultTable(Table $table): Table
|
||||
{
|
||||
return $table
|
||||
@@ -77,15 +84,13 @@ class DatabaseHostResource extends Resource
|
||||
->label(trans('admin/databasehost.table.username')),
|
||||
TextColumn::make('databases_count')
|
||||
->counts('databases')
|
||||
->icon('tabler-database')
|
||||
->label(trans('admin/databasehost.databases')),
|
||||
TextColumn::make('nodes.name')
|
||||
->icon('tabler-server-2')
|
||||
->badge()
|
||||
->placeholder(trans('admin/databasehost.no_nodes')),
|
||||
])
|
||||
->checkIfRecordIsSelectableUsing(fn (DatabaseHost $databaseHost) => !$databaseHost->databases_count)
|
||||
->actions([
|
||||
->recordActions([
|
||||
ViewAction::make()
|
||||
->hidden(fn ($record) => static::canEdit($record)),
|
||||
EditAction::make(),
|
||||
@@ -101,11 +106,15 @@ class DatabaseHostResource extends Resource
|
||||
]);
|
||||
}
|
||||
|
||||
public static function defaultForm(Form $form): Form
|
||||
/**
|
||||
* @throws Exception
|
||||
*/
|
||||
public static function defaultForm(Schema $schema): Schema
|
||||
{
|
||||
return $form
|
||||
->schema([
|
||||
return $schema
|
||||
->components([
|
||||
Section::make()
|
||||
->columnSpanFull()
|
||||
->columns([
|
||||
'default' => 2,
|
||||
'sm' => 3,
|
||||
@@ -132,7 +141,7 @@ class DatabaseHostResource extends Resource
|
||||
->maxValue(65535),
|
||||
TextInput::make('max_databases')
|
||||
->label(trans('admin/databasehost.max_database'))
|
||||
->helpertext(trans('admin/databasehost.max_databases_help'))
|
||||
->helperText(trans('admin/databasehost.max_databases_help'))
|
||||
->numeric(),
|
||||
TextInput::make('name')
|
||||
->label(trans('admin/databasehost.display_name'))
|
||||
@@ -166,7 +175,7 @@ class DatabaseHostResource extends Resource
|
||||
public static function getDefaultRelations(): array
|
||||
{
|
||||
return [
|
||||
RelationManagers\DatabasesRelationManager::class,
|
||||
DatabasesRelationManager::class,
|
||||
];
|
||||
}
|
||||
|
||||
@@ -174,10 +183,10 @@ class DatabaseHostResource extends Resource
|
||||
public static function getDefaultPages(): array
|
||||
{
|
||||
return [
|
||||
'index' => Pages\ListDatabaseHosts::route('/'),
|
||||
'create' => Pages\CreateDatabaseHost::route('/create'),
|
||||
'view' => Pages\ViewDatabaseHost::route('/{record}'),
|
||||
'edit' => Pages\EditDatabaseHost::route('/{record}/edit'),
|
||||
'index' => ListDatabaseHosts::route('/'),
|
||||
'create' => CreateDatabaseHost::route('/create'),
|
||||
'view' => ViewDatabaseHost::route('/{record}'),
|
||||
'edit' => EditDatabaseHost::route('/{record}/edit'),
|
||||
];
|
||||
}
|
||||
|
||||
@@ -1,30 +1,31 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Admin\Resources\DatabaseHostResource\Pages;
|
||||
namespace App\Filament\Admin\Resources\DatabaseHosts\Pages;
|
||||
|
||||
use App\Filament\Admin\Resources\DatabaseHostResource;
|
||||
use App\Filament\Admin\Resources\DatabaseHosts\DatabaseHostResource;
|
||||
use App\Services\Databases\Hosts\HostCreationService;
|
||||
use App\Traits\Filament\CanCustomizeHeaderActions;
|
||||
use App\Traits\Filament\CanCustomizeHeaderWidgets;
|
||||
use Filament\Forms\Components\Fieldset;
|
||||
use Exception;
|
||||
use Filament\Forms\Components\Hidden;
|
||||
use Filament\Forms\Components\Placeholder;
|
||||
use Filament\Forms\Components\Select;
|
||||
use Filament\Forms\Components\TextInput;
|
||||
use Filament\Forms\Components\Toggle;
|
||||
use Filament\Forms\Components\Wizard\Step;
|
||||
use Filament\Forms\Get;
|
||||
use Filament\Forms\Set;
|
||||
use Filament\Infolists\Components\TextEntry;
|
||||
use Filament\Notifications\Notification;
|
||||
use Filament\Resources\Pages\CreateRecord;
|
||||
use Filament\Resources\Pages\CreateRecord\Concerns\HasWizard;
|
||||
use Filament\Schemas\Components\Fieldset;
|
||||
use Filament\Schemas\Components\Utilities\Get;
|
||||
use Filament\Schemas\Components\Utilities\Set;
|
||||
use Filament\Schemas\Components\Wizard\Step;
|
||||
use Filament\Support\Exceptions\Halt;
|
||||
use Illuminate\Database\Eloquent\Builder;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Support\HtmlString;
|
||||
use Illuminate\Support\Str;
|
||||
use PDOException;
|
||||
use Webbingbrasil\FilamentCopyActions\Forms\Actions\CopyAction;
|
||||
use Throwable;
|
||||
|
||||
class CreateDatabaseHost extends CreateRecord
|
||||
{
|
||||
@@ -43,15 +44,18 @@ class CreateDatabaseHost extends CreateRecord
|
||||
$this->service = $service;
|
||||
}
|
||||
|
||||
/** @return Step[] */
|
||||
/** @return Step[]
|
||||
* @throws Exception
|
||||
*/
|
||||
public function getSteps(): array
|
||||
{
|
||||
return [
|
||||
Step::make(trans('admin/databasehost.setup.preparations'))
|
||||
->columns()
|
||||
->schema([
|
||||
Placeholder::make('')
|
||||
->content(trans('admin/databasehost.setup.note')),
|
||||
TextEntry::make('setup')
|
||||
->hiddenLabel()
|
||||
->state(trans('admin/databasehost.setup.note')),
|
||||
Toggle::make('different_server')
|
||||
->label(new HtmlString(trans('admin/databasehost.setup.different_server')))
|
||||
->dehydrated(false)
|
||||
@@ -84,31 +88,34 @@ class CreateDatabaseHost extends CreateRecord
|
||||
->schema([
|
||||
Fieldset::make(trans('admin/databasehost.setup.database_user'))
|
||||
->schema([
|
||||
Placeholder::make('')
|
||||
->content(new HtmlString(trans('admin/databasehost.setup.cli_login')))
|
||||
TextEntry::make('cli_login')
|
||||
->hiddenLabel()
|
||||
->state(new HtmlString(trans('admin/databasehost.setup.cli_login')))
|
||||
->columnSpanFull(),
|
||||
TextInput::make('create_user')
|
||||
->label(trans('admin/databasehost.setup.command_create_user'))
|
||||
->default(fn (Get $get) => "CREATE USER '{$get('username')}'@'{$get('panel_ip')}' IDENTIFIED BY '{$get('password')}';")
|
||||
->disabled()
|
||||
->dehydrated(false)
|
||||
->suffixAction(fn (string $state) => request()->isSecure() ? CopyAction::make()->copyable($state) : null)
|
||||
->copyable()
|
||||
->columnSpanFull(),
|
||||
TextInput::make('assign_permissions')
|
||||
->label(trans('admin/databasehost.setup.command_assign_permissions'))
|
||||
->default(fn (Get $get) => "GRANT ALL PRIVILEGES ON *.* TO '{$get('username')}'@'{$get('panel_ip')}' WITH GRANT OPTION;")
|
||||
->disabled()
|
||||
->dehydrated(false)
|
||||
->suffixAction(fn (string $state) => request()->isSecure() ? CopyAction::make()->copyable($state) : null)
|
||||
->copyable()
|
||||
->columnSpanFull(),
|
||||
Placeholder::make('')
|
||||
->content(new HtmlString(trans('admin/databasehost.setup.cli_exit')))
|
||||
TextEntry::make('cli_exit')
|
||||
->hiddenLabel()
|
||||
->state(new HtmlString(trans('admin/databasehost.setup.cli_exit')))
|
||||
->columnSpanFull(),
|
||||
]),
|
||||
Fieldset::make(trans('admin/databasehost.setup.external_access'))
|
||||
->schema([
|
||||
Placeholder::make('')
|
||||
->content(new HtmlString(trans('admin/databasehost.setup.allow_external_access')))
|
||||
TextEntry::make('allow_external_access')
|
||||
->hiddenLabel()
|
||||
->state(new HtmlString(trans('admin/databasehost.setup.allow_external_access')))
|
||||
->columnSpanFull(),
|
||||
]),
|
||||
]),
|
||||
@@ -136,7 +143,7 @@ class CreateDatabaseHost extends CreateRecord
|
||||
->maxValue(65535),
|
||||
TextInput::make('max_databases')
|
||||
->label(trans('admin/databasehost.max_database'))
|
||||
->helpertext(trans('admin/databasehost.max_databases_help'))
|
||||
->helperText(trans('admin/databasehost.max_databases_help'))
|
||||
->placeholder(trans('admin/databasehost.unlimited'))
|
||||
->numeric(),
|
||||
TextInput::make('name')
|
||||
@@ -155,6 +162,10 @@ class CreateDatabaseHost extends CreateRecord
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* @throws Halt
|
||||
* @throws Throwable
|
||||
*/
|
||||
protected function handleRecordCreation(array $data): Model
|
||||
{
|
||||
try {
|
||||
@@ -1,8 +1,8 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Admin\Resources\DatabaseHostResource\Pages;
|
||||
namespace App\Filament\Admin\Resources\DatabaseHosts\Pages;
|
||||
|
||||
use App\Filament\Admin\Resources\DatabaseHostResource;
|
||||
use App\Filament\Admin\Resources\DatabaseHosts\DatabaseHostResource;
|
||||
use App\Models\DatabaseHost;
|
||||
use App\Services\Databases\Hosts\HostUpdateService;
|
||||
use App\Traits\Filament\CanCustomizeHeaderActions;
|
||||
@@ -1,8 +1,8 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Admin\Resources\DatabaseHostResource\Pages;
|
||||
namespace App\Filament\Admin\Resources\DatabaseHosts\Pages;
|
||||
|
||||
use App\Filament\Admin\Resources\DatabaseHostResource;
|
||||
use App\Filament\Admin\Resources\DatabaseHosts\DatabaseHostResource;
|
||||
use App\Models\DatabaseHost;
|
||||
use App\Traits\Filament\CanCustomizeHeaderActions;
|
||||
use App\Traits\Filament\CanCustomizeHeaderWidgets;
|
||||
@@ -1,8 +1,8 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Admin\Resources\DatabaseHostResource\Pages;
|
||||
namespace App\Filament\Admin\Resources\DatabaseHosts\Pages;
|
||||
|
||||
use App\Filament\Admin\Resources\DatabaseHostResource;
|
||||
use App\Filament\Admin\Resources\DatabaseHosts\DatabaseHostResource;
|
||||
use App\Traits\Filament\CanCustomizeHeaderActions;
|
||||
use App\Traits\Filament\CanCustomizeHeaderWidgets;
|
||||
use Filament\Actions\Action;
|
||||
@@ -1,15 +1,15 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Admin\Resources\DatabaseHostResource\RelationManagers;
|
||||
namespace App\Filament\Admin\Resources\DatabaseHosts\RelationManagers;
|
||||
|
||||
use App\Filament\Components\Forms\Actions\RotateDatabasePasswordAction;
|
||||
use App\Filament\Components\Actions\RotateDatabasePasswordAction;
|
||||
use App\Filament\Components\Tables\Columns\DateTimeColumn;
|
||||
use App\Models\Database;
|
||||
use Filament\Actions\DeleteAction;
|
||||
use Filament\Actions\ViewAction;
|
||||
use Filament\Forms\Components\TextInput;
|
||||
use Filament\Forms\Form;
|
||||
use Filament\Resources\RelationManagers\RelationManager;
|
||||
use Filament\Tables\Actions\DeleteAction;
|
||||
use Filament\Tables\Actions\ViewAction;
|
||||
use Filament\Schemas\Schema;
|
||||
use Filament\Tables\Columns\TextColumn;
|
||||
use Filament\Tables\Table;
|
||||
|
||||
@@ -17,10 +17,10 @@ class DatabasesRelationManager extends RelationManager
|
||||
{
|
||||
protected static string $relationship = 'databases';
|
||||
|
||||
public function form(Form $form): Form
|
||||
public function form(Schema $schema): Schema
|
||||
{
|
||||
return $form
|
||||
->schema([
|
||||
return $schema
|
||||
->components([
|
||||
TextInput::make('database')
|
||||
->columnSpanFull(),
|
||||
TextInput::make('username')
|
||||
@@ -49,19 +49,16 @@ class DatabasesRelationManager extends RelationManager
|
||||
public function table(Table $table): Table
|
||||
{
|
||||
return $table
|
||||
->recordTitleAttribute('servers')
|
||||
->recordTitleAttribute('database')
|
||||
->heading('')
|
||||
->columns([
|
||||
TextColumn::make('database')
|
||||
->icon('tabler-database'),
|
||||
TextColumn::make('database'),
|
||||
TextColumn::make('username')
|
||||
->label(trans('admin/databasehost.table.username'))
|
||||
->icon('tabler-user'),
|
||||
->label(trans('admin/databasehost.table.username')),
|
||||
TextColumn::make('remote')
|
||||
->label(trans('admin/databasehost.table.remote'))
|
||||
->formatStateUsing(fn (Database $record) => $record->remote === '%' ? trans('admin/databasehost.anywhere'). ' ( % )' : $record->remote),
|
||||
TextColumn::make('server.name')
|
||||
->icon('tabler-brand-docker')
|
||||
->url(fn (Database $database) => route('filament.admin.resources.servers.edit', ['record' => $database->server_id])),
|
||||
TextColumn::make('max_connections')
|
||||
->label(trans('admin/databasehost.table.max_connections'))
|
||||
@@ -69,12 +66,10 @@ class DatabasesRelationManager extends RelationManager
|
||||
DateTimeColumn::make('created_at')
|
||||
->label(trans('admin/databasehost.table.created_at')),
|
||||
])
|
||||
->actions([
|
||||
DeleteAction::make()
|
||||
->authorize(fn (Database $database) => auth()->user()->can('delete', $database)),
|
||||
->recordActions([
|
||||
ViewAction::make()
|
||||
->color('primary')
|
||||
->hidden(fn () => !auth()->user()->can('viewAny', Database::class)),
|
||||
->color('primary'),
|
||||
DeleteAction::make(),
|
||||
]);
|
||||
}
|
||||
}
|
||||
@@ -1,9 +1,12 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Admin\Resources;
|
||||
namespace App\Filament\Admin\Resources\Eggs;
|
||||
|
||||
use App\Filament\Admin\Resources\EggResource\Pages;
|
||||
use App\Filament\Admin\Resources\EggResource\RelationManagers;
|
||||
use App\Enums\CustomizationKey;
|
||||
use App\Filament\Admin\Resources\Eggs\Pages\CreateEgg;
|
||||
use App\Filament\Admin\Resources\Eggs\Pages\EditEgg;
|
||||
use App\Filament\Admin\Resources\Eggs\Pages\ListEggs;
|
||||
use App\Filament\Admin\Resources\Eggs\RelationManagers\ServersRelationManager;
|
||||
use App\Models\Egg;
|
||||
use App\Traits\Filament\CanCustomizePages;
|
||||
use App\Traits\Filament\CanCustomizeRelations;
|
||||
@@ -18,18 +21,18 @@ class EggResource extends Resource
|
||||
|
||||
protected static ?string $model = Egg::class;
|
||||
|
||||
protected static ?string $navigationIcon = 'tabler-eggs';
|
||||
protected static string|\BackedEnum|null $navigationIcon = 'tabler-eggs';
|
||||
|
||||
protected static ?string $recordTitleAttribute = 'name';
|
||||
|
||||
public static function getNavigationBadge(): ?string
|
||||
{
|
||||
return static::getModel()::count() ?: null;
|
||||
return ($count = static::getModel()::count()) > 0 ? (string) $count : null;
|
||||
}
|
||||
|
||||
public static function getNavigationGroup(): ?string
|
||||
{
|
||||
return !empty(auth()->user()->getCustomization()['top_navigation']) ? false : trans('admin/dashboard.server');
|
||||
return auth()->user()->getCustomization(CustomizationKey::TopNavigation) ? false : trans('admin/dashboard.server');
|
||||
}
|
||||
|
||||
public static function getNavigationLabel(): string
|
||||
@@ -56,7 +59,7 @@ class EggResource extends Resource
|
||||
public static function getDefaultRelations(): array
|
||||
{
|
||||
return [
|
||||
RelationManagers\ServersRelationManager::class,
|
||||
ServersRelationManager::class,
|
||||
];
|
||||
}
|
||||
|
||||
@@ -64,9 +67,9 @@ class EggResource extends Resource
|
||||
public static function getDefaultPages(): array
|
||||
{
|
||||
return [
|
||||
'index' => Pages\ListEggs::route('/'),
|
||||
'create' => Pages\CreateEgg::route('/create'),
|
||||
'edit' => Pages\EditEgg::route('/{record}/edit'),
|
||||
'index' => ListEggs::route('/'),
|
||||
'create' => CreateEgg::route('/create'),
|
||||
'edit' => EditEgg::route('/{record}/edit'),
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -1,31 +1,32 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Admin\Resources\EggResource\Pages;
|
||||
namespace App\Filament\Admin\Resources\Eggs\Pages;
|
||||
|
||||
use AbdelhamidErrahmouni\FilamentMonacoEditor\MonacoEditor;
|
||||
use App\Filament\Admin\Resources\EggResource;
|
||||
use App\Filament\Admin\Resources\Eggs\EggResource;
|
||||
use App\Filament\Components\Forms\Fields\CopyFrom;
|
||||
use App\Models\EggVariable;
|
||||
use App\Traits\Filament\CanCustomizeHeaderActions;
|
||||
use App\Traits\Filament\CanCustomizeHeaderWidgets;
|
||||
use Exception;
|
||||
use Filament\Actions\Action;
|
||||
use Filament\Actions\ActionGroup;
|
||||
use Filament\Forms\Components\Checkbox;
|
||||
use Filament\Forms\Components\Fieldset;
|
||||
use Filament\Forms\Components\CodeEditor;
|
||||
use Filament\Forms\Components\Hidden;
|
||||
use Filament\Forms\Components\KeyValue;
|
||||
use Filament\Forms\Components\Repeater;
|
||||
use Filament\Forms\Components\Select;
|
||||
use Filament\Forms\Components\Tabs;
|
||||
use Filament\Forms\Components\Tabs\Tab;
|
||||
use Filament\Forms\Components\TagsInput;
|
||||
use Filament\Forms\Components\Textarea;
|
||||
use Filament\Forms\Components\TextInput;
|
||||
use Filament\Forms\Components\Toggle;
|
||||
use Filament\Forms\Form;
|
||||
use Filament\Forms\Get;
|
||||
use Filament\Forms\Set;
|
||||
use Filament\Resources\Pages\CreateRecord;
|
||||
use Filament\Schemas\Components\Fieldset;
|
||||
use Filament\Schemas\Components\Tabs;
|
||||
use Filament\Schemas\Components\Tabs\Tab;
|
||||
use Filament\Schemas\Components\Utilities\Get;
|
||||
use Filament\Schemas\Components\Utilities\Set;
|
||||
use Filament\Schemas\Schema;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Support\Str;
|
||||
use Illuminate\Validation\Rules\Unique;
|
||||
@@ -52,12 +53,16 @@ class CreateEgg extends CreateRecord
|
||||
return [];
|
||||
}
|
||||
|
||||
public function form(Form $form): Form
|
||||
/**
|
||||
* @throws Exception
|
||||
*/
|
||||
public function form(Schema $schema): Schema
|
||||
{
|
||||
return $form
|
||||
->schema([
|
||||
return $schema
|
||||
->components([
|
||||
Tabs::make()->tabs([
|
||||
Tab::make(trans('admin/egg.tabs.configuration'))
|
||||
Tab::make('configuration')
|
||||
->label(trans('admin/egg.tabs.configuration'))
|
||||
->columns(['default' => 1, 'sm' => 1, 'md' => 2, 'lg' => 4])
|
||||
->schema([
|
||||
TextInput::make('name')
|
||||
@@ -97,8 +102,7 @@ class CreateEgg extends CreateRecord
|
||||
->columnSpan(['default' => 1, 'sm' => 1, 'md' => 1, 'lg' => 1]),
|
||||
Toggle::make('force_outgoing_ip')
|
||||
->label(trans('admin/egg.force_ip'))
|
||||
->hintIcon('tabler-question-mark')
|
||||
->hintIconTooltip(trans('admin/egg.force_ip_help')),
|
||||
->hintIcon('tabler-question-mark', trans('admin/egg.force_ip_help')),
|
||||
Hidden::make('script_is_privileged')
|
||||
->default(1),
|
||||
TagsInput::make('tags')
|
||||
@@ -106,8 +110,7 @@ class CreateEgg extends CreateRecord
|
||||
->columnSpan(['default' => 1, 'sm' => 1, 'md' => 2, 'lg' => 2]),
|
||||
TextInput::make('update_url')
|
||||
->label(trans('admin/egg.update_url'))
|
||||
->hintIcon('tabler-question-mark')
|
||||
->hintIconTooltip(trans('admin/egg.update_url_help'))
|
||||
->hintIcon('tabler-question-mark', trans('admin/egg.update_url_help'))
|
||||
->columnSpan(['default' => 1, 'sm' => 1, 'md' => 2, 'lg' => 2])
|
||||
->url(),
|
||||
KeyValue::make('docker_images')
|
||||
@@ -123,7 +126,8 @@ class CreateEgg extends CreateRecord
|
||||
->helperText(trans('admin/egg.docker_help')),
|
||||
]),
|
||||
|
||||
Tab::make(trans('admin/egg.tabs.process_management'))
|
||||
Tab::make('process_management')
|
||||
->label(trans('admin/egg.tabs.process_management'))
|
||||
->columns()
|
||||
->schema([
|
||||
CopyFrom::make('copy_process_from')
|
||||
@@ -146,15 +150,15 @@ class CreateEgg extends CreateRecord
|
||||
->default('{}')
|
||||
->helperText(trans('admin/egg.log_config_help')),
|
||||
]),
|
||||
Tab::make(trans('admin/egg.tabs.egg_variables'))
|
||||
Tab::make('egg_variables')
|
||||
->label(trans('admin/egg.tabs.egg_variables'))
|
||||
->columnSpanFull()
|
||||
->schema([
|
||||
Repeater::make('variables')
|
||||
->label('')
|
||||
->hiddenLabel()
|
||||
->addActionLabel(trans('admin/egg.add_new_variable'))
|
||||
->grid()
|
||||
->relationship('variables')
|
||||
->name('name')
|
||||
->reorderable()->orderColumn()
|
||||
->collapsible()->collapsed()
|
||||
->columnSpan(2)
|
||||
@@ -186,7 +190,7 @@ class CreateEgg extends CreateRecord
|
||||
->maxLength(255)
|
||||
->columnSpanFull()
|
||||
->afterStateUpdated(fn (Set $set, $state) => $set('env_variable', str($state)->trim()->snake()->upper()->toString()))
|
||||
->unique(modifyRuleUsing: fn (Unique $rule, Get $get) => $rule->where('egg_id', $get('../../id')), ignoreRecord: true)
|
||||
->unique(modifyRuleUsing: fn (Unique $rule, Get $get) => $rule->where('egg_id', $get('../../id')))
|
||||
->validationMessages([
|
||||
'unique' => trans('admin/egg.error_unique'),
|
||||
])
|
||||
@@ -197,9 +201,8 @@ class CreateEgg extends CreateRecord
|
||||
->maxLength(255)
|
||||
->prefix('{{')
|
||||
->suffix('}}')
|
||||
->hintIcon('tabler-code')
|
||||
->hintIconTooltip(fn ($state) => "{{{$state}}}")
|
||||
->unique(modifyRuleUsing: fn (Unique $rule, Get $get) => $rule->where('egg_id', $get('../../id')), ignoreRecord: true)
|
||||
->hintIcon('tabler-code', fn ($state) => "{{{$state}}}")
|
||||
->unique(modifyRuleUsing: fn (Unique $rule, Get $get) => $rule->where('egg_id', $get('../../id')))
|
||||
->rules(EggVariable::getRulesForField('env_variable'))
|
||||
->validationMessages([
|
||||
'unique' => trans('admin/egg.error_unique'),
|
||||
@@ -239,7 +242,8 @@ class CreateEgg extends CreateRecord
|
||||
]),
|
||||
]),
|
||||
]),
|
||||
Tab::make(trans('admin/egg.tabs.install_script'))
|
||||
Tab::make('install_script')
|
||||
->label(trans('admin/egg.tabs.install_script'))
|
||||
->columns(3)
|
||||
->schema([
|
||||
CopyFrom::make('copy_script_from')
|
||||
@@ -260,13 +264,10 @@ class CreateEgg extends CreateRecord
|
||||
'/bin/bash' => '/bin/bash',
|
||||
])
|
||||
->required(),
|
||||
MonacoEditor::make('script_install')
|
||||
CodeEditor::make('script_install')
|
||||
->label(trans('admin/egg.script_install'))
|
||||
->columnSpanFull()
|
||||
->fontSize('16px')
|
||||
->language('shell')
|
||||
->lazy()
|
||||
->view('filament.plugins.monaco-editor'),
|
||||
->lazy(),
|
||||
]),
|
||||
|
||||
])->columnSpanFull()->persistTabInQueryString(),
|
||||
@@ -1,9 +1,8 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Admin\Resources\EggResource\Pages;
|
||||
namespace App\Filament\Admin\Resources\Eggs\Pages;
|
||||
|
||||
use AbdelhamidErrahmouni\FilamentMonacoEditor\MonacoEditor;
|
||||
use App\Filament\Admin\Resources\EggResource;
|
||||
use App\Filament\Admin\Resources\Eggs\EggResource;
|
||||
use App\Filament\Components\Actions\ExportEggAction;
|
||||
use App\Filament\Components\Actions\ImportEggAction;
|
||||
use App\Filament\Components\Forms\Fields\CopyFrom;
|
||||
@@ -11,25 +10,27 @@ use App\Models\Egg;
|
||||
use App\Models\EggVariable;
|
||||
use App\Traits\Filament\CanCustomizeHeaderActions;
|
||||
use App\Traits\Filament\CanCustomizeHeaderWidgets;
|
||||
use Exception;
|
||||
use Filament\Actions\Action;
|
||||
use Filament\Actions\ActionGroup;
|
||||
use Filament\Actions\DeleteAction;
|
||||
use Filament\Forms\Components\Checkbox;
|
||||
use Filament\Forms\Components\Fieldset;
|
||||
use Filament\Forms\Components\CodeEditor;
|
||||
use Filament\Forms\Components\Hidden;
|
||||
use Filament\Forms\Components\KeyValue;
|
||||
use Filament\Forms\Components\Repeater;
|
||||
use Filament\Forms\Components\Select;
|
||||
use Filament\Forms\Components\Tabs;
|
||||
use Filament\Forms\Components\Tabs\Tab;
|
||||
use Filament\Forms\Components\TagsInput;
|
||||
use Filament\Forms\Components\Textarea;
|
||||
use Filament\Forms\Components\TextInput;
|
||||
use Filament\Forms\Components\Toggle;
|
||||
use Filament\Forms\Form;
|
||||
use Filament\Forms\Get;
|
||||
use Filament\Forms\Set;
|
||||
use Filament\Resources\Pages\EditRecord;
|
||||
use Filament\Schemas\Components\Fieldset;
|
||||
use Filament\Schemas\Components\Tabs;
|
||||
use Filament\Schemas\Components\Tabs\Tab;
|
||||
use Filament\Schemas\Components\Utilities\Get;
|
||||
use Filament\Schemas\Components\Utilities\Set;
|
||||
use Filament\Schemas\Schema;
|
||||
use Illuminate\Validation\Rules\Unique;
|
||||
|
||||
class EditEgg extends EditRecord
|
||||
@@ -39,12 +40,16 @@ class EditEgg extends EditRecord
|
||||
|
||||
protected static string $resource = EggResource::class;
|
||||
|
||||
public function form(Form $form): Form
|
||||
/**
|
||||
* @throws Exception
|
||||
*/
|
||||
public function form(Schema $schema): Schema
|
||||
{
|
||||
return $form
|
||||
->schema([
|
||||
return $schema
|
||||
->components([
|
||||
Tabs::make()->tabs([
|
||||
Tab::make(trans('admin/egg.tabs.configuration'))
|
||||
Tab::make('configuration')
|
||||
->label(trans('admin/egg.tabs.configuration'))
|
||||
->columns(['default' => 1, 'sm' => 1, 'md' => 2, 'lg' => 4])
|
||||
->icon('tabler-egg')
|
||||
->schema([
|
||||
@@ -92,8 +97,7 @@ class EditEgg extends EditRecord
|
||||
Toggle::make('force_outgoing_ip')
|
||||
->inline(false)
|
||||
->label(trans('admin/egg.force_ip'))
|
||||
->hintIcon('tabler-question-mark')
|
||||
->hintIconTooltip(trans('admin/egg.force_ip_help')),
|
||||
->hintIcon('tabler-question-mark', trans('admin/egg.force_ip_help')),
|
||||
Hidden::make('script_is_privileged')
|
||||
->helperText('The docker images available to servers using this egg.'),
|
||||
TagsInput::make('tags')
|
||||
@@ -102,8 +106,7 @@ class EditEgg extends EditRecord
|
||||
TextInput::make('update_url')
|
||||
->label(trans('admin/egg.update_url'))
|
||||
->url()
|
||||
->hintIcon('tabler-question-mark')
|
||||
->hintIconTooltip(trans('admin/egg.update_url_help'))
|
||||
->hintIcon('tabler-question-mark', trans('admin/egg.update_url_help'))
|
||||
->columnSpan(['default' => 1, 'sm' => 1, 'md' => 2, 'lg' => 2]),
|
||||
KeyValue::make('docker_images')
|
||||
->label(trans('admin/egg.docker_images'))
|
||||
@@ -115,7 +118,8 @@ class EditEgg extends EditRecord
|
||||
->valueLabel(trans('admin/egg.docker_uri'))
|
||||
->helperText(trans('admin/egg.docker_help')),
|
||||
]),
|
||||
Tab::make(trans('admin/egg.tabs.process_management'))
|
||||
Tab::make('process_management')
|
||||
->label(trans('admin/egg.tabs.process_management'))
|
||||
->columns()
|
||||
->icon('tabler-server-cog')
|
||||
->schema([
|
||||
@@ -135,15 +139,15 @@ class EditEgg extends EditRecord
|
||||
->label(trans('admin/egg.log_config'))
|
||||
->helperText(trans('admin/egg.log_config_help')),
|
||||
]),
|
||||
Tab::make(trans('admin/egg.tabs.egg_variables'))
|
||||
Tab::make('egg_variables')
|
||||
->label(trans('admin/egg.tabs.egg_variables'))
|
||||
->columnSpanFull()
|
||||
->icon('tabler-variable')
|
||||
->schema([
|
||||
Repeater::make('variables')
|
||||
->label('')
|
||||
->hiddenLabel()
|
||||
->grid()
|
||||
->relationship('variables')
|
||||
->name('name')
|
||||
->reorderable()
|
||||
->collapsible()->collapsed()
|
||||
->orderColumn()
|
||||
@@ -175,7 +179,7 @@ class EditEgg extends EditRecord
|
||||
->maxLength(255)
|
||||
->columnSpanFull()
|
||||
->afterStateUpdated(fn (Set $set, $state) => $set('env_variable', str($state)->trim()->snake()->upper()->toString()))
|
||||
->unique(modifyRuleUsing: fn (Unique $rule, Get $get) => $rule->where('egg_id', $get('../../id')), ignoreRecord: true)
|
||||
->unique(modifyRuleUsing: fn (Unique $rule, Get $get) => $rule->where('egg_id', $get('../../id')))
|
||||
->validationMessages([
|
||||
'unique' => trans('admin/egg.error_unique'),
|
||||
])
|
||||
@@ -186,9 +190,8 @@ class EditEgg extends EditRecord
|
||||
->maxLength(255)
|
||||
->prefix('{{')
|
||||
->suffix('}}')
|
||||
->hintIcon('tabler-code')
|
||||
->hintIconTooltip(fn ($state) => "{{{$state}}}")
|
||||
->unique(modifyRuleUsing: fn (Unique $rule, Get $get) => $rule->where('egg_id', $get('../../id')), ignoreRecord: true)
|
||||
->hintIcon('tabler-code', fn ($state) => "{{{$state}}}")
|
||||
->unique(modifyRuleUsing: fn (Unique $rule, Get $get) => $rule->where('egg_id', $get('../../id')))
|
||||
->rules(EggVariable::getRulesForField('env_variable'))
|
||||
->validationMessages([
|
||||
'unique' => trans('admin/egg.error_unique'),
|
||||
@@ -228,7 +231,8 @@ class EditEgg extends EditRecord
|
||||
]),
|
||||
]),
|
||||
]),
|
||||
Tab::make(trans('admin/egg.tabs.install_script'))
|
||||
Tab::make('install_script')
|
||||
->label(trans('admin/egg.tabs.install_script'))
|
||||
->columns(3)
|
||||
->icon('tabler-file-download')
|
||||
->schema([
|
||||
@@ -249,13 +253,9 @@ class EditEgg extends EditRecord
|
||||
'/bin/bash' => '/bin/bash',
|
||||
])
|
||||
->required(),
|
||||
MonacoEditor::make('script_install')
|
||||
->label(trans('admin/egg.script_install'))
|
||||
->placeholderText('')
|
||||
->columnSpanFull()
|
||||
->fontSize('16px')
|
||||
->language('shell')
|
||||
->view('filament.plugins.monaco-editor'),
|
||||
CodeEditor::make('script_install')
|
||||
->hiddenLabel()
|
||||
->columnSpanFull(),
|
||||
]),
|
||||
])->columnSpanFull()->persistTabInQueryString(),
|
||||
]);
|
||||
@@ -1,28 +1,26 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Admin\Resources\EggResource\Pages;
|
||||
namespace App\Filament\Admin\Resources\Eggs\Pages;
|
||||
|
||||
use App\Filament\Admin\Resources\EggResource;
|
||||
use App\Filament\Components\Actions\ImportEggAction as ImportEggHeaderAction;
|
||||
use App\Filament\Components\Tables\Actions\ExportEggAction;
|
||||
use App\Filament\Components\Tables\Actions\ImportEggAction;
|
||||
use App\Filament\Components\Tables\Actions\UpdateEggAction;
|
||||
use App\Filament\Components\Tables\Actions\UpdateEggBulkAction;
|
||||
use App\Filament\Admin\Resources\Eggs\EggResource;
|
||||
use App\Filament\Components\Actions\ExportEggAction;
|
||||
use App\Filament\Components\Actions\ImportEggAction;
|
||||
use App\Filament\Components\Actions\UpdateEggAction;
|
||||
use App\Filament\Components\Actions\UpdateEggBulkAction;
|
||||
use App\Filament\Components\Tables\Filters\TagsFilter;
|
||||
use App\Models\Egg;
|
||||
use App\Traits\Filament\CanCustomizeHeaderActions;
|
||||
use App\Traits\Filament\CanCustomizeHeaderWidgets;
|
||||
use Exception;
|
||||
use Filament\Actions\Action;
|
||||
use Filament\Actions\ActionGroup;
|
||||
use Filament\Actions\CreateAction as CreateHeaderAction;
|
||||
use Filament\Actions\CreateAction;
|
||||
use Filament\Actions\DeleteBulkAction;
|
||||
use Filament\Actions\EditAction;
|
||||
use Filament\Actions\ReplicateAction;
|
||||
use Filament\Resources\Pages\ListRecords;
|
||||
use Filament\Tables\Actions\CreateAction;
|
||||
use Filament\Tables\Actions\DeleteBulkAction;
|
||||
use Filament\Tables\Actions\EditAction;
|
||||
use Filament\Tables\Actions\ReplicateAction;
|
||||
use Filament\Tables\Columns\TextColumn;
|
||||
use Filament\Tables\Table;
|
||||
use Illuminate\Database\Eloquent\Collection;
|
||||
use Illuminate\Support\Str;
|
||||
|
||||
class ListEggs extends ListRecords
|
||||
@@ -32,6 +30,9 @@ class ListEggs extends ListRecords
|
||||
|
||||
protected static string $resource = EggResource::class;
|
||||
|
||||
/**
|
||||
* @throws Exception
|
||||
*/
|
||||
public function table(Table $table): Table
|
||||
{
|
||||
return $table
|
||||
@@ -43,17 +44,15 @@ class ListEggs extends ListRecords
|
||||
->hidden(),
|
||||
TextColumn::make('name')
|
||||
->label(trans('admin/egg.name'))
|
||||
->icon('tabler-egg')
|
||||
->description(fn ($record): ?string => (strlen($record->description) > 120) ? substr($record->description, 0, 120).'...' : $record->description)
|
||||
->wrap()
|
||||
->searchable()
|
||||
->sortable(),
|
||||
TextColumn::make('servers_count')
|
||||
->counts('servers')
|
||||
->icon('tabler-server')
|
||||
->label(trans('admin/egg.servers')),
|
||||
])
|
||||
->actions([
|
||||
->recordActions([
|
||||
EditAction::make()
|
||||
->iconButton()
|
||||
->tooltip(trans('filament-actions::edit.single.label')),
|
||||
@@ -62,7 +61,7 @@ class ListEggs extends ListRecords
|
||||
->tooltip(trans('filament-actions::export.modal.actions.export.label')),
|
||||
UpdateEggAction::make()
|
||||
->iconButton()
|
||||
->tooltip(trans('admin/egg.update')),
|
||||
->tooltip(trans_choice('admin/egg.update', 1)),
|
||||
ReplicateAction::make()
|
||||
->iconButton()
|
||||
->tooltip(trans('filament-actions::replicate.single.label'))
|
||||
@@ -78,15 +77,15 @@ class ListEggs extends ListRecords
|
||||
])
|
||||
->groupedBulkActions([
|
||||
DeleteBulkAction::make()
|
||||
->before(fn (DeleteBulkAction $action, Collection $records) => $action->records($records->filter(function ($egg) {
|
||||
->before(fn (&$records) => $records = $records->filter(function ($egg) {
|
||||
/** @var Egg $egg */
|
||||
return $egg->servers_count <= 0;
|
||||
}))),
|
||||
})),
|
||||
UpdateEggBulkAction::make()
|
||||
->before(fn (UpdateEggBulkAction $action, Collection $records) => $action->records($records->filter(function ($egg) {
|
||||
->before(fn (&$records) => $records = $records->filter(function ($egg) {
|
||||
/** @var Egg $egg */
|
||||
return cache()->get("eggs.$egg->uuid.update", false);
|
||||
}))),
|
||||
})),
|
||||
])
|
||||
->emptyStateIcon('tabler-eggs')
|
||||
->emptyStateDescription('')
|
||||
@@ -102,13 +101,15 @@ class ListEggs extends ListRecords
|
||||
]);
|
||||
}
|
||||
|
||||
/** @return array<Action|ActionGroup> */
|
||||
/** @return array<Action|ActionGroup>
|
||||
* @throws Exception
|
||||
*/
|
||||
protected function getDefaultHeaderActions(): array
|
||||
{
|
||||
return [
|
||||
ImportEggHeaderAction::make()
|
||||
ImportEggAction::make()
|
||||
->multiple(),
|
||||
CreateHeaderAction::make(),
|
||||
CreateAction::make(),
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -1,6 +1,6 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Admin\Resources\EggResource\RelationManagers;
|
||||
namespace App\Filament\Admin\Resources\Eggs\RelationManagers;
|
||||
|
||||
use App\Models\Server;
|
||||
use Filament\Resources\RelationManagers\RelationManager;
|
||||
@@ -22,17 +22,14 @@ class ServersRelationManager extends RelationManager
|
||||
->heading(trans('admin/egg.servers'))
|
||||
->columns([
|
||||
TextColumn::make('user.username')
|
||||
->label('Owner')
|
||||
->icon('tabler-user')
|
||||
->label(trans('admin/server.owner'))
|
||||
->url(fn (Server $server): string => route('filament.admin.resources.users.edit', ['record' => $server->user]))
|
||||
->sortable(),
|
||||
TextColumn::make('name')
|
||||
->label(trans('admin/server.name'))
|
||||
->icon('tabler-brand-docker')
|
||||
->url(fn (Server $server): string => route('filament.admin.resources.servers.edit', ['record' => $server]))
|
||||
->sortable(),
|
||||
TextColumn::make('node.name')
|
||||
->icon('tabler-server-2')
|
||||
->url(fn (Server $server): string => route('filament.admin.resources.nodes.edit', ['record' => $server->node])),
|
||||
TextColumn::make('image')
|
||||
->label(trans('admin/server.docker_image')),
|
||||
@@ -40,7 +37,7 @@ class ServersRelationManager extends RelationManager
|
||||
->label(trans('admin/server.primary_allocation'))
|
||||
->disabled()
|
||||
->options(fn (Server $server) => $server->allocations->take(1)->mapWithKeys(fn ($allocation) => [$allocation->id => $allocation->address]))
|
||||
->placeholder('None')
|
||||
->placeholder(trans('admin/server.none'))
|
||||
->sortable(),
|
||||
]);
|
||||
}
|
||||
@@ -1,26 +1,30 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Admin\Resources;
|
||||
namespace App\Filament\Admin\Resources\Mounts;
|
||||
|
||||
use App\Filament\Admin\Resources\MountResource\Pages;
|
||||
use App\Filament\Admin\Resources\Mounts\Pages\CreateMount;
|
||||
use App\Filament\Admin\Resources\Mounts\Pages\EditMount;
|
||||
use App\Filament\Admin\Resources\Mounts\Pages\ListMounts;
|
||||
use App\Filament\Admin\Resources\Mounts\Pages\ViewMount;
|
||||
use App\Models\Mount;
|
||||
use App\Traits\Filament\CanCustomizePages;
|
||||
use App\Traits\Filament\CanCustomizeRelations;
|
||||
use App\Traits\Filament\CanModifyForm;
|
||||
use App\Traits\Filament\CanModifyTable;
|
||||
use Filament\Forms\Components\Group;
|
||||
use Filament\Forms\Components\Section;
|
||||
use Exception;
|
||||
use Filament\Actions\CreateAction;
|
||||
use Filament\Actions\DeleteBulkAction;
|
||||
use Filament\Actions\EditAction;
|
||||
use Filament\Actions\ViewAction;
|
||||
use Filament\Forms\Components\Select;
|
||||
use Filament\Forms\Components\Textarea;
|
||||
use Filament\Forms\Components\TextInput;
|
||||
use Filament\Forms\Components\ToggleButtons;
|
||||
use Filament\Forms\Form;
|
||||
use Filament\Resources\Pages\PageRegistration;
|
||||
use Filament\Resources\Resource;
|
||||
use Filament\Tables\Actions\CreateAction;
|
||||
use Filament\Tables\Actions\DeleteBulkAction;
|
||||
use Filament\Tables\Actions\EditAction;
|
||||
use Filament\Tables\Actions\ViewAction;
|
||||
use Filament\Schemas\Components\Group;
|
||||
use Filament\Schemas\Components\Section;
|
||||
use Filament\Schemas\Schema;
|
||||
use Filament\Tables\Columns\TextColumn;
|
||||
use Filament\Tables\Table;
|
||||
use Illuminate\Database\Eloquent\Builder;
|
||||
@@ -34,7 +38,7 @@ class MountResource extends Resource
|
||||
|
||||
protected static ?string $model = Mount::class;
|
||||
|
||||
protected static ?string $navigationIcon = 'tabler-layers-linked';
|
||||
protected static string|\BackedEnum|null $navigationIcon = 'tabler-layers-linked';
|
||||
|
||||
protected static ?string $recordTitleAttribute = 'name';
|
||||
|
||||
@@ -63,6 +67,9 @@ class MountResource extends Resource
|
||||
return trans('admin/dashboard.advanced');
|
||||
}
|
||||
|
||||
/**
|
||||
* @throws Exception
|
||||
*/
|
||||
public static function defaultTable(Table $table): Table
|
||||
{
|
||||
return $table
|
||||
@@ -72,12 +79,10 @@ class MountResource extends Resource
|
||||
->description(fn (Mount $mount) => "$mount->source -> $mount->target")
|
||||
->sortable(),
|
||||
TextColumn::make('eggs.name')
|
||||
->icon('tabler-eggs')
|
||||
->label(trans('admin/mount.eggs'))
|
||||
->badge()
|
||||
->placeholder(trans('admin/mount.table.all_eggs')),
|
||||
TextColumn::make('nodes.name')
|
||||
->icon('tabler-server-2')
|
||||
->label(trans('admin/mount.nodes'))
|
||||
->badge()
|
||||
->placeholder(trans('admin/mount.table.all_nodes')),
|
||||
@@ -88,7 +93,7 @@ class MountResource extends Resource
|
||||
->color(fn ($state) => $state ? 'success' : 'warning')
|
||||
->formatStateUsing(fn ($state) => $state ? trans('admin/mount.toggles.read_only') : trans('admin/mount.toggles.writable')),
|
||||
])
|
||||
->actions([
|
||||
->recordActions([
|
||||
ViewAction::make()
|
||||
->hidden(fn ($record) => static::canEdit($record)),
|
||||
EditAction::make(),
|
||||
@@ -104,10 +109,13 @@ class MountResource extends Resource
|
||||
]);
|
||||
}
|
||||
|
||||
public static function defaultForm(Form $form): Form
|
||||
/**
|
||||
* @throws Exception
|
||||
*/
|
||||
public static function defaultForm(Schema $schema): Schema
|
||||
{
|
||||
return $form
|
||||
->schema([
|
||||
return $schema
|
||||
->components([
|
||||
Section::make()->schema([
|
||||
TextInput::make('name')
|
||||
->label(trans('admin/mount.name'))
|
||||
@@ -176,10 +184,10 @@ class MountResource extends Resource
|
||||
public static function getDefaultPages(): array
|
||||
{
|
||||
return [
|
||||
'index' => Pages\ListMounts::route('/'),
|
||||
'create' => Pages\CreateMount::route('/create'),
|
||||
'view' => Pages\ViewMount::route('/{record}'),
|
||||
'edit' => Pages\EditMount::route('/{record}/edit'),
|
||||
'index' => ListMounts::route('/'),
|
||||
'create' => CreateMount::route('/create'),
|
||||
'view' => ViewMount::route('/{record}'),
|
||||
'edit' => EditMount::route('/{record}/edit'),
|
||||
];
|
||||
}
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Admin\Resources\MountResource\Pages;
|
||||
namespace App\Filament\Admin\Resources\Mounts\Pages;
|
||||
|
||||
use App\Filament\Admin\Resources\MountResource;
|
||||
use App\Filament\Admin\Resources\Mounts\MountResource;
|
||||
use App\Traits\Filament\CanCustomizeHeaderActions;
|
||||
use App\Traits\Filament\CanCustomizeHeaderWidgets;
|
||||
use Filament\Actions\Action;
|
||||
@@ -1,8 +1,8 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Admin\Resources\MountResource\Pages;
|
||||
namespace App\Filament\Admin\Resources\Mounts\Pages;
|
||||
|
||||
use App\Filament\Admin\Resources\MountResource;
|
||||
use App\Filament\Admin\Resources\Mounts\MountResource;
|
||||
use App\Traits\Filament\CanCustomizeHeaderActions;
|
||||
use App\Traits\Filament\CanCustomizeHeaderWidgets;
|
||||
use Filament\Actions\Action;
|
||||
@@ -1,8 +1,8 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Admin\Resources\MountResource\Pages;
|
||||
namespace App\Filament\Admin\Resources\Mounts\Pages;
|
||||
|
||||
use App\Filament\Admin\Resources\MountResource;
|
||||
use App\Filament\Admin\Resources\Mounts\MountResource;
|
||||
use App\Models\Mount;
|
||||
use App\Traits\Filament\CanCustomizeHeaderActions;
|
||||
use App\Traits\Filament\CanCustomizeHeaderWidgets;
|
||||
@@ -1,8 +1,8 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Admin\Resources\MountResource\Pages;
|
||||
namespace App\Filament\Admin\Resources\Mounts\Pages;
|
||||
|
||||
use App\Filament\Admin\Resources\MountResource;
|
||||
use App\Filament\Admin\Resources\Mounts\MountResource;
|
||||
use App\Traits\Filament\CanCustomizeHeaderActions;
|
||||
use App\Traits\Filament\CanCustomizeHeaderWidgets;
|
||||
use Filament\Actions\Action;
|
||||
@@ -1,9 +1,13 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Admin\Resources;
|
||||
namespace App\Filament\Admin\Resources\Nodes;
|
||||
|
||||
use App\Filament\Admin\Resources\NodeResource\Pages;
|
||||
use App\Filament\Admin\Resources\NodeResource\RelationManagers;
|
||||
use App\Enums\CustomizationKey;
|
||||
use App\Filament\Admin\Resources\Nodes\Pages\CreateNode;
|
||||
use App\Filament\Admin\Resources\Nodes\Pages\EditNode;
|
||||
use App\Filament\Admin\Resources\Nodes\Pages\ListNodes;
|
||||
use App\Filament\Admin\Resources\Nodes\RelationManagers\AllocationsRelationManager;
|
||||
use App\Filament\Admin\Resources\Nodes\RelationManagers\NodesRelationManager;
|
||||
use App\Models\Node;
|
||||
use App\Traits\Filament\CanCustomizePages;
|
||||
use App\Traits\Filament\CanCustomizeRelations;
|
||||
@@ -19,7 +23,7 @@ class NodeResource extends Resource
|
||||
|
||||
protected static ?string $model = Node::class;
|
||||
|
||||
protected static ?string $navigationIcon = 'tabler-server-2';
|
||||
protected static string|\BackedEnum|null $navigationIcon = 'tabler-server-2';
|
||||
|
||||
protected static ?string $recordTitleAttribute = 'name';
|
||||
|
||||
@@ -40,8 +44,7 @@ class NodeResource extends Resource
|
||||
|
||||
public static function getNavigationGroup(): ?string
|
||||
{
|
||||
return !empty(auth()->user()->getCustomization()['top_navigation']) ? false : trans('admin/dashboard.server');
|
||||
|
||||
return auth()->user()->getCustomization(CustomizationKey::TopNavigation) ? false : trans('admin/dashboard.server');
|
||||
}
|
||||
|
||||
public static function getNavigationBadge(): ?string
|
||||
@@ -53,8 +56,8 @@ class NodeResource extends Resource
|
||||
public static function getDefaultRelations(): array
|
||||
{
|
||||
return [
|
||||
RelationManagers\AllocationsRelationManager::class,
|
||||
RelationManagers\NodesRelationManager::class,
|
||||
AllocationsRelationManager::class,
|
||||
NodesRelationManager::class,
|
||||
];
|
||||
}
|
||||
|
||||
@@ -62,9 +65,9 @@ class NodeResource extends Resource
|
||||
public static function getDefaultPages(): array
|
||||
{
|
||||
return [
|
||||
'index' => Pages\ListNodes::route('/'),
|
||||
'create' => Pages\CreateNode::route('/create'),
|
||||
'edit' => Pages\EditNode::route('/{record}/edit'),
|
||||
'index' => ListNodes::route('/'),
|
||||
'create' => CreateNode::route('/create'),
|
||||
'edit' => EditNode::route('/{record}/edit'),
|
||||
];
|
||||
}
|
||||
|
||||
@@ -1,23 +1,24 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Admin\Resources\NodeResource\Pages;
|
||||
namespace App\Filament\Admin\Resources\Nodes\Pages;
|
||||
|
||||
use App\Filament\Admin\Resources\NodeResource;
|
||||
use App\Filament\Admin\Resources\Nodes\NodeResource;
|
||||
use App\Models\Node;
|
||||
use App\Traits\Filament\CanCustomizeHeaderActions;
|
||||
use App\Traits\Filament\CanCustomizeHeaderWidgets;
|
||||
use Filament\Forms;
|
||||
use Filament\Forms\Components\Actions\Action;
|
||||
use Filament\Forms\Components\Grid;
|
||||
use Exception;
|
||||
use Filament\Actions\Action;
|
||||
use Filament\Forms\Components\Hidden;
|
||||
use Filament\Forms\Components\TagsInput;
|
||||
use Filament\Forms\Components\TextInput;
|
||||
use Filament\Forms\Components\ToggleButtons;
|
||||
use Filament\Forms\Components\Wizard;
|
||||
use Filament\Forms\Components\Wizard\Step;
|
||||
use Filament\Forms\Get;
|
||||
use Filament\Forms\Set;
|
||||
use Filament\Resources\Pages\CreateRecord;
|
||||
use Filament\Schemas\Components\Grid;
|
||||
use Filament\Schemas\Components\Utilities\Get;
|
||||
use Filament\Schemas\Components\Utilities\Set;
|
||||
use Filament\Schemas\Components\Wizard;
|
||||
use Filament\Schemas\Components\Wizard\Step;
|
||||
use Filament\Schemas\Schema;
|
||||
use Illuminate\Support\Facades\Blade;
|
||||
use Illuminate\Support\HtmlString;
|
||||
|
||||
@@ -30,10 +31,13 @@ class CreateNode extends CreateRecord
|
||||
|
||||
protected static bool $canCreateAnother = false;
|
||||
|
||||
public function form(Forms\Form $form): Forms\Form
|
||||
/**
|
||||
* @throws Exception
|
||||
*/
|
||||
public function form(Schema $schema): Schema
|
||||
{
|
||||
return $form
|
||||
->schema([
|
||||
return $schema
|
||||
->components([
|
||||
Wizard::make([
|
||||
Step::make('basic')
|
||||
->label(trans('admin/node.tabs.basic_settings'))
|
||||
@@ -222,8 +226,7 @@ class CreateNode extends CreateRecord
|
||||
->label(trans('admin/node.maintenance_mode'))->inline()
|
||||
->columnSpan(1)
|
||||
->default(false)
|
||||
->hinticon('tabler-question-mark')
|
||||
->hintIconTooltip(trans('admin/node.maintenance_mode_help'))
|
||||
->hintIcon('tabler-question-mark', trans('admin/node.maintenance_mode_help'))
|
||||
->options([
|
||||
true => trans('admin/node.enabled'),
|
||||
false => trans('admin/node.disabled'),
|
||||
@@ -250,8 +253,7 @@ class CreateNode extends CreateRecord
|
||||
TextInput::make('upload_size')
|
||||
->label(trans('admin/node.upload_limit'))
|
||||
->helperText(trans('admin/node.upload_limit_help.0'))
|
||||
->hintIcon('tabler-question-mark')
|
||||
->hintIconTooltip(trans('admin/node.upload_limit_help.1'))
|
||||
->hintIcon('tabler-question-mark', trans('admin/node.upload_limit_help.1'))
|
||||
->columnSpan(1)
|
||||
->numeric()->required()
|
||||
->default(256)
|
||||
@@ -404,7 +406,7 @@ class CreateNode extends CreateRecord
|
||||
type="submit"
|
||||
size="sm"
|
||||
>
|
||||
Create Node
|
||||
{{ trans('admin/node.create') }}
|
||||
</x-filament::button>
|
||||
BLADE))),
|
||||
]);
|
||||
@@ -413,7 +415,7 @@ class CreateNode extends CreateRecord
|
||||
protected function getRedirectUrlParameters(): array
|
||||
{
|
||||
return [
|
||||
'tab' => '-configuration-file-tab',
|
||||
'tab' => 'configuration-file::data::tab',
|
||||
];
|
||||
}
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Admin\Resources\NodeResource\Pages;
|
||||
namespace App\Filament\Admin\Resources\Nodes\Pages;
|
||||
|
||||
use App\Filament\Admin\Resources\NodeResource;
|
||||
use App\Filament\Admin\Resources\Nodes\NodeResource;
|
||||
use App\Models\Node;
|
||||
use App\Repositories\Daemon\DaemonConfigurationRepository;
|
||||
use App\Services\Helpers\SoftwareVersionService;
|
||||
@@ -11,28 +11,30 @@ use App\Services\Nodes\NodeUpdateService;
|
||||
use App\Traits\Filament\CanCustomizeHeaderActions;
|
||||
use App\Traits\Filament\CanCustomizeHeaderWidgets;
|
||||
use Exception;
|
||||
use Filament\Actions;
|
||||
use Filament\Forms;
|
||||
use Filament\Forms\Components\Actions as FormActions;
|
||||
use Filament\Forms\Components\Fieldset;
|
||||
use Filament\Forms\Components\Grid;
|
||||
use Filament\Actions\Action;
|
||||
use Filament\Actions\DeleteAction;
|
||||
use Filament\Forms\Components\Hidden;
|
||||
use Filament\Forms\Components\Placeholder;
|
||||
use Filament\Forms\Components\Tabs;
|
||||
use Filament\Forms\Components\Tabs\Tab;
|
||||
use Filament\Forms\Components\TagsInput;
|
||||
use Filament\Forms\Components\Textarea;
|
||||
use Filament\Forms\Components\TextInput;
|
||||
use Filament\Forms\Components\ToggleButtons;
|
||||
use Filament\Forms\Components\View;
|
||||
use Filament\Forms\Get;
|
||||
use Filament\Forms\Set;
|
||||
use Filament\Infolists\Components\TextEntry;
|
||||
use Filament\Notifications\Notification;
|
||||
use Filament\Resources\Pages\EditRecord;
|
||||
use Filament\Schemas\Components\Actions;
|
||||
use Filament\Schemas\Components\Fieldset;
|
||||
use Filament\Schemas\Components\Grid;
|
||||
use Filament\Schemas\Components\StateCasts\BooleanStateCast;
|
||||
use Filament\Schemas\Components\Tabs;
|
||||
use Filament\Schemas\Components\Tabs\Tab;
|
||||
use Filament\Schemas\Components\Utilities\Get;
|
||||
use Filament\Schemas\Components\Utilities\Set;
|
||||
use Filament\Schemas\Components\View;
|
||||
use Filament\Schemas\Schema;
|
||||
use Filament\Support\Enums\Alignment;
|
||||
use Illuminate\Http\Client\ConnectionException;
|
||||
use Illuminate\Support\HtmlString;
|
||||
use Webbingbrasil\FilamentCopyActions\Forms\Actions\CopyAction;
|
||||
use Throwable;
|
||||
|
||||
class EditNode extends EditRecord
|
||||
{
|
||||
@@ -51,9 +53,12 @@ class EditNode extends EditRecord
|
||||
$this->nodeUpdateService = $nodeUpdateService;
|
||||
}
|
||||
|
||||
public function form(Forms\Form $form): Forms\Form
|
||||
/**
|
||||
* @throws Throwable
|
||||
*/
|
||||
public function form(Schema $schema): Schema
|
||||
{
|
||||
return $form->schema([
|
||||
return $schema->components([
|
||||
Tabs::make('Tabs')
|
||||
->columns([
|
||||
'default' => 2,
|
||||
@@ -64,7 +69,7 @@ class EditNode extends EditRecord
|
||||
->persistTabInQueryString()
|
||||
->columnSpanFull()
|
||||
->tabs([
|
||||
Tab::make('')
|
||||
Tab::make('overview')
|
||||
->label(trans('admin/node.tabs.overview'))
|
||||
->icon('tabler-chart-area-line-filled')
|
||||
->columns([
|
||||
@@ -77,19 +82,20 @@ class EditNode extends EditRecord
|
||||
Fieldset::make()
|
||||
->label(trans('admin/node.node_info'))
|
||||
->columns(4)
|
||||
->columnSpanFull()
|
||||
->schema([
|
||||
Placeholder::make('')
|
||||
TextEntry::make('wings_version')
|
||||
->label(trans('admin/node.wings_version'))
|
||||
->content(fn (Node $node, SoftwareVersionService $versionService) => ($node->systemInformation()['version'] ?? trans('admin/node.unknown')) . ' (' . trans('admin/node.latest') . ': ' . $versionService->latestWingsVersion() . ')'),
|
||||
Placeholder::make('')
|
||||
->state(fn (Node $node, SoftwareVersionService $versionService) => ($node->systemInformation()['version'] ?? trans('admin/node.unknown')) . ' ' . trans('admin/node.latest', ['version' => $versionService->latestWingsVersion()])),
|
||||
TextEntry::make('cpu_threads')
|
||||
->label(trans('admin/node.cpu_threads'))
|
||||
->content(fn (Node $node) => $node->systemInformation()['cpu_count'] ?? 0),
|
||||
Placeholder::make('')
|
||||
->state(fn (Node $node) => $node->systemInformation()['cpu_count'] ?? 0),
|
||||
TextEntry::make('architecture')
|
||||
->label(trans('admin/node.architecture'))
|
||||
->content(fn (Node $node) => $node->systemInformation()['architecture'] ?? trans('admin/node.unknown')),
|
||||
Placeholder::make('')
|
||||
->state(fn (Node $node) => $node->systemInformation()['architecture'] ?? trans('admin/node.unknown')),
|
||||
TextEntry::make('kernel')
|
||||
->label(trans('admin/node.kernel'))
|
||||
->content(fn (Node $node) => $node->systemInformation()['kernel_version'] ?? trans('admin/node.unknown')),
|
||||
->state(fn (Node $node) => $node->systemInformation()['kernel_version'] ?? trans('admin/node.unknown')),
|
||||
]),
|
||||
View::make('filament.components.node-cpu-chart')
|
||||
->columnSpan([
|
||||
@@ -108,7 +114,8 @@ class EditNode extends EditRecord
|
||||
View::make('filament.components.node-storage-chart')
|
||||
->columnSpanFull(),
|
||||
]),
|
||||
Tab::make(trans('admin/node.tabs.basic_settings'))
|
||||
Tab::make('basic_settings')
|
||||
->label(trans('admin/node.tabs.basic_settings'))
|
||||
->icon('tabler-server')
|
||||
->schema([
|
||||
TextInput::make('fqdn')
|
||||
@@ -175,13 +182,14 @@ class EditNode extends EditRecord
|
||||
->default(null)
|
||||
->hint(fn (Get $get) => $get('ip'))
|
||||
->hintColor('success')
|
||||
->stateCast(new BooleanStateCast(false, true))
|
||||
->options([
|
||||
true => trans('admin/node.valid'),
|
||||
false => trans('admin/node.invalid'),
|
||||
1 => trans('admin/node.valid'),
|
||||
0 => trans('admin/node.invalid'),
|
||||
])
|
||||
->colors([
|
||||
true => 'success',
|
||||
false => 'danger',
|
||||
1 => 'success',
|
||||
0 => 'danger',
|
||||
])
|
||||
->columnSpan(1),
|
||||
TextInput::make('daemon_connect')
|
||||
@@ -257,7 +265,7 @@ class EditNode extends EditRecord
|
||||
->integer()
|
||||
->visible(fn (Get $get) => $get('connection') === 'https_proxy'),
|
||||
]),
|
||||
Tab::make('adv')
|
||||
Tab::make('advanced_settings')
|
||||
->label(trans('admin/node.tabs.advanced_settings'))
|
||||
->columns([
|
||||
'default' => 1,
|
||||
@@ -284,7 +292,7 @@ class EditNode extends EditRecord
|
||||
'lg' => 2,
|
||||
])
|
||||
->label(trans('admin/node.node_uuid'))
|
||||
->hintAction(fn () => request()->isSecure() ? CopyAction::make() : null)
|
||||
->hintCopy()
|
||||
->disabled(),
|
||||
TagsInput::make('tags')
|
||||
->label(trans('admin/node.tags'))
|
||||
@@ -303,8 +311,7 @@ class EditNode extends EditRecord
|
||||
'lg' => 1,
|
||||
])
|
||||
->label(trans('admin/node.upload_limit'))
|
||||
->hintIcon('tabler-question-mark')
|
||||
->hintIconTooltip(trans('admin/node.upload_limit_help.0') . trans('admin/node.upload_limit_help.1'))
|
||||
->hintIcon('tabler-question-mark', trans('admin/node.upload_limit_help.0') . trans('admin/node.upload_limit_help.1'))
|
||||
->numeric()->required()
|
||||
->minValue(1)
|
||||
->maxValue(1024)
|
||||
@@ -338,14 +345,16 @@ class EditNode extends EditRecord
|
||||
'md' => 1,
|
||||
'lg' => 3,
|
||||
])
|
||||
->label(trans('admin/node.use_for_deploy'))->inline()
|
||||
->label(trans('admin/node.use_for_deploy'))
|
||||
->inline()
|
||||
->stateCast(new BooleanStateCast(false, true))
|
||||
->options([
|
||||
true => trans('admin/node.yes'),
|
||||
false => trans('admin/node.no'),
|
||||
1 => trans('admin/node.yes'),
|
||||
0 => trans('admin/node.no'),
|
||||
])
|
||||
->colors([
|
||||
true => 'success',
|
||||
false => 'danger',
|
||||
1 => 'success',
|
||||
0 => 'danger',
|
||||
]),
|
||||
ToggleButtons::make('maintenance_mode')
|
||||
->columnSpan([
|
||||
@@ -354,16 +363,17 @@ class EditNode extends EditRecord
|
||||
'md' => 1,
|
||||
'lg' => 3,
|
||||
])
|
||||
->label(trans('admin/node.maintenance_mode'))->inline()
|
||||
->hinticon('tabler-question-mark')
|
||||
->hintIconTooltip(trans('admin/node.maintenance_mode_help'))
|
||||
->label(trans('admin/node.maintenance_mode'))
|
||||
->inline()
|
||||
->hintIcon('tabler-question-mark', trans('admin/node.maintenance_mode_help'))
|
||||
->stateCast(new BooleanStateCast(false, true))
|
||||
->options([
|
||||
true => trans('admin/node.enabled'),
|
||||
false => trans('admin/node.disabled'),
|
||||
1 => trans('admin/node.enabled'),
|
||||
0 => trans('admin/node.disabled'),
|
||||
])
|
||||
->colors([
|
||||
false => 'success',
|
||||
true => 'danger',
|
||||
1 => 'danger',
|
||||
0 => 'success',
|
||||
]),
|
||||
Grid::make()
|
||||
->columns([
|
||||
@@ -381,13 +391,14 @@ class EditNode extends EditRecord
|
||||
->afterStateUpdated(fn (Set $set) => $set('memory_overallocate', 0))
|
||||
->formatStateUsing(fn (Get $get) => $get('memory') == 0)
|
||||
->live()
|
||||
->stateCast(new BooleanStateCast(false, true))
|
||||
->options([
|
||||
true => trans('admin/node.unlimited'),
|
||||
false => trans('admin/node.limited'),
|
||||
1 => trans('admin/node.unlimited'),
|
||||
0 => trans('admin/node.limited'),
|
||||
])
|
||||
->colors([
|
||||
true => 'primary',
|
||||
false => 'warning',
|
||||
1 => 'primary',
|
||||
0 => 'warning',
|
||||
])
|
||||
->columnSpan([
|
||||
'default' => 1,
|
||||
@@ -426,6 +437,7 @@ class EditNode extends EditRecord
|
||||
->suffix('%'),
|
||||
]),
|
||||
Grid::make()
|
||||
->columnSpanFull()
|
||||
->columns([
|
||||
'default' => 1,
|
||||
'sm' => 1,
|
||||
@@ -440,13 +452,14 @@ class EditNode extends EditRecord
|
||||
->afterStateUpdated(fn (Set $set) => $set('disk', 0))
|
||||
->afterStateUpdated(fn (Set $set) => $set('disk_overallocate', 0))
|
||||
->formatStateUsing(fn (Get $get) => $get('disk') == 0)
|
||||
->stateCast(new BooleanStateCast(false, true))
|
||||
->options([
|
||||
true => trans('admin/node.unlimited'),
|
||||
false => trans('admin/node.limited'),
|
||||
1 => trans('admin/node.unlimited'),
|
||||
0 => trans('admin/node.limited'),
|
||||
])
|
||||
->colors([
|
||||
true => 'primary',
|
||||
false => 'warning',
|
||||
1 => 'primary',
|
||||
0 => 'warning',
|
||||
])
|
||||
->columnSpan([
|
||||
'default' => 1,
|
||||
@@ -495,13 +508,14 @@ class EditNode extends EditRecord
|
||||
->afterStateUpdated(fn (Set $set) => $set('cpu', 0))
|
||||
->afterStateUpdated(fn (Set $set) => $set('cpu_overallocate', 0))
|
||||
->formatStateUsing(fn (Get $get) => $get('cpu') == 0)
|
||||
->stateCast(new BooleanStateCast(false, true))
|
||||
->options([
|
||||
true => trans('admin/node.unlimited'),
|
||||
false => trans('admin/node.limited'),
|
||||
1 => trans('admin/node.unlimited'),
|
||||
0 => trans('admin/node.limited'),
|
||||
])
|
||||
->colors([
|
||||
true => 'primary',
|
||||
false => 'warning',
|
||||
1 => 'primary',
|
||||
0 => 'warning',
|
||||
])
|
||||
->columnSpan(2),
|
||||
TextInput::make('cpu')
|
||||
@@ -525,25 +539,26 @@ class EditNode extends EditRecord
|
||||
->suffix('%'),
|
||||
]),
|
||||
]),
|
||||
Tab::make('Config')
|
||||
Tab::make('config_file')
|
||||
->label(trans('admin/node.tabs.config_file'))
|
||||
->icon('tabler-code')
|
||||
->schema([
|
||||
Placeholder::make('instructions')
|
||||
TextEntry::make('instructions')
|
||||
->label(trans('admin/node.instructions'))
|
||||
->columnSpanFull()
|
||||
->content(new HtmlString(trans('admin/node.instructions_help'))),
|
||||
->state(new HtmlString(trans('admin/node.instructions_help'))),
|
||||
Textarea::make('config')
|
||||
->label('/etc/pelican/config.yml')
|
||||
->disabled()
|
||||
->rows(19)
|
||||
->hintAction(fn () => request()->isSecure() ? CopyAction::make() : null)
|
||||
->hintCopy()
|
||||
->columnSpanFull(),
|
||||
Grid::make()
|
||||
->columns()
|
||||
->columnSpanFull()
|
||||
->schema([
|
||||
FormActions::make([
|
||||
FormActions\Action::make('autoDeploy')
|
||||
Actions::make([
|
||||
Action::make('autoDeploy')
|
||||
->label(trans('admin/node.auto_deploy'))
|
||||
->color('primary')
|
||||
->modalHeading(trans('admin/node.auto_deploy'))
|
||||
@@ -551,36 +566,37 @@ class EditNode extends EditRecord
|
||||
->modalSubmitAction(false)
|
||||
->modalCancelAction(false)
|
||||
->modalFooterActionsAlignment(Alignment::Center)
|
||||
->form([
|
||||
->schema([
|
||||
ToggleButtons::make('docker')
|
||||
->label('Type')
|
||||
->label(trans('admin/node.auto_label'))
|
||||
->live()
|
||||
->helperText(trans('admin/node.auto_question'))
|
||||
->inline()
|
||||
->default(false)
|
||||
->afterStateUpdated(fn (bool $state, NodeAutoDeployService $service, Node $node, Set $set) => $set('generatedToken', $service->handle(request(), $node, $state)))
|
||||
->stateCast(new BooleanStateCast(false, true))
|
||||
->options([
|
||||
false => trans('admin/node.standalone'),
|
||||
true => trans('admin/node.docker'),
|
||||
0 => trans('admin/node.standalone'),
|
||||
1 => trans('admin/node.docker'),
|
||||
])
|
||||
->colors([
|
||||
false => 'primary',
|
||||
true => 'success',
|
||||
0 => 'primary',
|
||||
1 => 'success',
|
||||
])
|
||||
->columnSpan(1),
|
||||
Textarea::make('generatedToken')
|
||||
->label(trans('admin/node.auto_command'))
|
||||
->readOnly()
|
||||
->autosize()
|
||||
->hintAction(fn (string $state) => request()->isSecure() ? CopyAction::make()->copyable($state) : null)
|
||||
->hintCopy()
|
||||
->formatStateUsing(fn (NodeAutoDeployService $service, Node $node, Set $set, Get $get) => $set('generatedToken', $service->handle(request(), $node, $get('docker')))),
|
||||
])
|
||||
->mountUsing(function (Forms\Form $form) {
|
||||
$form->fill();
|
||||
->mountUsing(function (Schema $schema) {
|
||||
$schema->fill();
|
||||
}),
|
||||
])->fullWidth(),
|
||||
FormActions::make([
|
||||
FormActions\Action::make('resetKey')
|
||||
Actions::make([
|
||||
Action::make('resetKey')
|
||||
->label(trans('admin/node.reset_token'))
|
||||
->color('danger')
|
||||
->requiresConfirmation()
|
||||
@@ -633,11 +649,11 @@ class EditNode extends EditRecord
|
||||
return [];
|
||||
}
|
||||
|
||||
/** @return array<Actions\Action|Actions\ActionGroup> */
|
||||
/** @return array<Action|Actions> */
|
||||
protected function getDefaultHeaderActions(): array
|
||||
{
|
||||
return [
|
||||
Actions\DeleteAction::make()
|
||||
DeleteAction::make()
|
||||
->disabled(fn (Node $node) => $node->servers()->count() > 0)
|
||||
->label(fn (Node $node) => $node->servers()->count() > 0 ? trans('admin/node.node_has_servers') : trans('filament-actions::delete.single.label')),
|
||||
$this->getSaveFormAction()->formId('form'),
|
||||
@@ -1,17 +1,18 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Admin\Resources\NodeResource\Pages;
|
||||
namespace App\Filament\Admin\Resources\Nodes\Pages;
|
||||
|
||||
use App\Filament\Admin\Resources\NodeResource;
|
||||
use App\Filament\Admin\Resources\Nodes\NodeResource;
|
||||
use App\Filament\Components\Tables\Columns\NodeHealthColumn;
|
||||
use App\Filament\Components\Tables\Filters\TagsFilter;
|
||||
use App\Models\Node;
|
||||
use App\Traits\Filament\CanCustomizeHeaderActions;
|
||||
use App\Traits\Filament\CanCustomizeHeaderWidgets;
|
||||
use Filament\Actions;
|
||||
use Filament\Actions\Action;
|
||||
use Filament\Actions\ActionGroup;
|
||||
use Filament\Actions\CreateAction;
|
||||
use Filament\Actions\EditAction;
|
||||
use Filament\Resources\Pages\ListRecords;
|
||||
use Filament\Tables\Actions\CreateAction;
|
||||
use Filament\Tables\Actions\EditAction;
|
||||
use Filament\Tables\Columns\IconColumn;
|
||||
use Filament\Tables\Columns\TextColumn;
|
||||
use Filament\Tables\Table;
|
||||
@@ -36,13 +37,11 @@ class ListNodes extends ListRecords
|
||||
NodeHealthColumn::make('health'),
|
||||
TextColumn::make('name')
|
||||
->label(trans('admin/node.table.name'))
|
||||
->icon('tabler-server-2')
|
||||
->sortable()
|
||||
->searchable(),
|
||||
TextColumn::make('fqdn')
|
||||
->visibleFrom('md')
|
||||
->label(trans('admin/node.table.address'))
|
||||
->icon('tabler-network')
|
||||
->sortable()
|
||||
->searchable(),
|
||||
IconColumn::make('scheme')
|
||||
@@ -60,10 +59,9 @@ class ListNodes extends ListRecords
|
||||
->visibleFrom('sm')
|
||||
->counts('servers')
|
||||
->label(trans('admin/node.table.servers'))
|
||||
->sortable()
|
||||
->icon('tabler-brand-docker'),
|
||||
->sortable(),
|
||||
])
|
||||
->actions([
|
||||
->recordActions([
|
||||
EditAction::make(),
|
||||
])
|
||||
->emptyStateIcon('tabler-server-2')
|
||||
@@ -78,11 +76,11 @@ class ListNodes extends ListRecords
|
||||
]);
|
||||
}
|
||||
|
||||
/** @return array<Actions\Action|Actions\ActionGroup> */
|
||||
/** @return array<Action|ActionGroup> */
|
||||
protected function getDefaultHeaderActions(): array
|
||||
{
|
||||
return [
|
||||
Actions\CreateAction::make()
|
||||
CreateAction::make()
|
||||
->hidden(fn () => Node::count() <= 0),
|
||||
];
|
||||
}
|
||||
@@ -1,19 +1,20 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Admin\Resources\NodeResource\RelationManagers;
|
||||
namespace App\Filament\Admin\Resources\Nodes\RelationManagers;
|
||||
|
||||
use App\Filament\Admin\Resources\ServerResource\Pages\CreateServer;
|
||||
use App\Filament\Admin\Resources\Servers\Pages\CreateServer;
|
||||
use App\Models\Allocation;
|
||||
use App\Models\Node;
|
||||
use App\Services\Allocations\AssignmentService;
|
||||
use Exception;
|
||||
use Filament\Actions\Action;
|
||||
use Filament\Actions\DeleteBulkAction;
|
||||
use Filament\Forms\Components\Select;
|
||||
use Filament\Forms\Components\TagsInput;
|
||||
use Filament\Forms\Components\TextInput;
|
||||
use Filament\Forms\Get;
|
||||
use Filament\Forms\Set;
|
||||
use Filament\Resources\RelationManagers\RelationManager;
|
||||
use Filament\Tables\Actions\Action;
|
||||
use Filament\Tables\Actions\DeleteBulkAction;
|
||||
use Filament\Schemas\Components\Utilities\Get;
|
||||
use Filament\Schemas\Components\Utilities\Set;
|
||||
use Filament\Tables\Columns\SelectColumn;
|
||||
use Filament\Tables\Columns\TextColumn;
|
||||
use Filament\Tables\Columns\TextInputColumn;
|
||||
@@ -26,19 +27,22 @@ class AllocationsRelationManager extends RelationManager
|
||||
{
|
||||
protected static string $relationship = 'allocations';
|
||||
|
||||
protected static ?string $icon = 'tabler-plug-connected';
|
||||
protected static string|\BackedEnum|null $icon = 'tabler-plug-connected';
|
||||
|
||||
public function setTitle(): string
|
||||
{
|
||||
return trans('admin/server.allocations');
|
||||
}
|
||||
|
||||
/**
|
||||
* @throws Exception
|
||||
*/
|
||||
public function table(Table $table): Table
|
||||
{
|
||||
return $table
|
||||
->recordTitleAttribute('address')
|
||||
->checkIfRecordIsSelectableUsing(fn (Allocation $allocation) => $allocation->server_id === null)
|
||||
->paginationPageOptions(['10', '20', '50', '100', '200', '500'])
|
||||
->paginationPageOptions([10, 20, 50, 100, 200, 500])
|
||||
->searchable()
|
||||
->heading('')
|
||||
->selectCurrentPageOnly() //Prevent people from trying to nuke 30,000 ports at once.... -,-
|
||||
@@ -79,15 +83,24 @@ class AllocationsRelationManager extends RelationManager
|
||||
->headerActions([
|
||||
Action::make('create new allocation')
|
||||
->label(trans('admin/node.create_allocation'))
|
||||
->form(fn () => [
|
||||
->schema(fn () => [
|
||||
Select::make('allocation_ip')
|
||||
->options(collect($this->getOwnerRecord()->ipAddresses())->mapWithKeys(fn (string $ip) => [$ip => $ip]))
|
||||
->options(fn () => collect($this->getOwnerRecord()->ipAddresses())->mapWithKeys(fn (string $ip) => [$ip => $ip]))
|
||||
->label(trans('admin/node.ip_address'))
|
||||
->inlineLabel()
|
||||
->ip()
|
||||
->helperText(trans('admin/node.ip_help'))
|
||||
->afterStateUpdated(fn (Set $set) => $set('allocation_ports', []))
|
||||
->live()
|
||||
->hintAction(
|
||||
Action::make('refresh')
|
||||
->iconButton()
|
||||
->icon('tabler-refresh')
|
||||
->tooltip(trans('admin/node.refresh'))
|
||||
->action(function () {
|
||||
cache()->forget("nodes.{$this->getOwnerRecord()->id}.ips");
|
||||
})
|
||||
)
|
||||
->required(),
|
||||
TextInput::make('allocation_alias')
|
||||
->label(trans('admin/node.table.alias'))
|
||||
@@ -1,6 +1,6 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Admin\Resources\NodeResource\RelationManagers;
|
||||
namespace App\Filament\Admin\Resources\Nodes\RelationManagers;
|
||||
|
||||
use App\Models\Server;
|
||||
use Filament\Resources\RelationManagers\RelationManager;
|
||||
@@ -12,7 +12,7 @@ class NodesRelationManager extends RelationManager
|
||||
{
|
||||
protected static string $relationship = 'servers';
|
||||
|
||||
protected static ?string $icon = 'tabler-brand-docker';
|
||||
protected static string|\BackedEnum|null $icon = 'tabler-brand-docker';
|
||||
|
||||
public function setTitle(): string
|
||||
{
|
||||
@@ -27,18 +27,15 @@ class NodesRelationManager extends RelationManager
|
||||
->columns([
|
||||
TextColumn::make('user.username')
|
||||
->label(trans('admin/node.table.owner'))
|
||||
->icon('tabler-user')
|
||||
->url(fn (Server $server): string => route('filament.admin.resources.users.edit', ['record' => $server->user]))
|
||||
->searchable(),
|
||||
TextColumn::make('name')
|
||||
->label(trans('admin/node.table.name'))
|
||||
->icon('tabler-brand-docker')
|
||||
->url(fn (Server $server): string => route('filament.admin.resources.servers.edit', ['record' => $server]))
|
||||
->searchable()
|
||||
->sortable(),
|
||||
TextColumn::make('egg.name')
|
||||
->label(trans('admin/node.table.egg'))
|
||||
->icon('tabler-egg')
|
||||
->url(fn (Server $server): string => route('filament.admin.resources.eggs.edit', ['record' => $server->user]))
|
||||
->sortable(),
|
||||
SelectColumn::make('allocation.id')
|
||||
@@ -46,20 +43,18 @@ class NodesRelationManager extends RelationManager
|
||||
->disabled(fn (Server $server) => $server->allocations->count() <= 1)
|
||||
->options(fn (Server $server) => $server->allocations->take(1)->mapWithKeys(fn ($allocation) => [$allocation->id => $allocation->address]))
|
||||
->selectablePlaceholder(fn (SelectColumn $select) => !$select->isDisabled())
|
||||
->placeholder('None')
|
||||
->placeholder(trans('admin/node.none'))
|
||||
->sortable(),
|
||||
TextColumn::make('memory')->label(trans('admin/node.memory'))->icon('tabler-device-desktop-analytics'),
|
||||
TextColumn::make('cpu')->label(trans('admin/node.cpu'))->icon('tabler-cpu'),
|
||||
TextColumn::make('memory')->label(trans('admin/node.memory')),
|
||||
TextColumn::make('cpu')->label(trans('admin/node.cpu')),
|
||||
TextColumn::make('databases_count')
|
||||
->counts('databases')
|
||||
->label(trans('admin/node.databases'))
|
||||
->icon('tabler-database')
|
||||
->numeric()
|
||||
->sortable(),
|
||||
TextColumn::make('backups_count')
|
||||
->counts('backups')
|
||||
->label(trans('admin/node.backups'))
|
||||
->icon('tabler-file-download')
|
||||
->numeric()
|
||||
->sortable(),
|
||||
]);
|
||||
@@ -1,17 +1,16 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Admin\Resources\NodeResource\Widgets;
|
||||
namespace App\Filament\Admin\Resources\Nodes\Widgets;
|
||||
|
||||
use App\Models\Node;
|
||||
use Filament\Support\RawJs;
|
||||
use Filament\Widgets\ChartWidget;
|
||||
use Illuminate\Support\Number;
|
||||
|
||||
class NodeCpuChart extends ChartWidget
|
||||
{
|
||||
protected static ?string $pollingInterval = '5s';
|
||||
protected ?string $pollingInterval = '5s';
|
||||
|
||||
protected static ?string $maxHeight = '300px';
|
||||
protected ?string $maxHeight = '300px';
|
||||
|
||||
public Node $node;
|
||||
|
||||
@@ -82,8 +81,8 @@ class NodeCpuChart extends ChartWidget
|
||||
{
|
||||
$data = array_slice(end($this->cpuHistory), -60);
|
||||
|
||||
$cpu = Number::format($data['cpu'], maxPrecision: 2, locale: auth()->user()->language);
|
||||
$max = Number::format($this->threads * 100, locale: auth()->user()->language);
|
||||
$cpu = format_number($data['cpu'], maxPrecision: 2);
|
||||
$max = format_number($this->threads * 100);
|
||||
|
||||
return trans('admin/node.cpu_chart', ['cpu' => $cpu, 'max' => $max]);
|
||||
}
|
||||
@@ -1,17 +1,16 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Admin\Resources\NodeResource\Widgets;
|
||||
namespace App\Filament\Admin\Resources\Nodes\Widgets;
|
||||
|
||||
use App\Models\Node;
|
||||
use Filament\Support\RawJs;
|
||||
use Filament\Widgets\ChartWidget;
|
||||
use Illuminate\Support\Number;
|
||||
|
||||
class NodeMemoryChart extends ChartWidget
|
||||
{
|
||||
protected static ?string $pollingInterval = '5s';
|
||||
protected ?string $pollingInterval = '5s';
|
||||
|
||||
protected static ?string $maxHeight = '300px';
|
||||
protected ?string $maxHeight = '300px';
|
||||
|
||||
public Node $node;
|
||||
|
||||
@@ -85,12 +84,12 @@ class NodeMemoryChart extends ChartWidget
|
||||
$latestMemoryUsed = array_slice(end($this->memoryHistory), -60);
|
||||
|
||||
$used = config('panel.use_binary_prefix')
|
||||
? Number::format($latestMemoryUsed['memory'], maxPrecision: 2, locale: auth()->user()->language) .' GiB'
|
||||
: Number::format($latestMemoryUsed['memory'], maxPrecision: 2, locale: auth()->user()->language) . ' GB';
|
||||
? format_number($latestMemoryUsed['memory'], maxPrecision: 2) .' GiB'
|
||||
: format_number($latestMemoryUsed['memory'], maxPrecision: 2) . ' GB';
|
||||
|
||||
$total = config('panel.use_binary_prefix')
|
||||
? Number::format($this->totalMemory / 1024 / 1024 / 1024, maxPrecision: 2, locale: auth()->user()->language) .' GiB'
|
||||
: Number::format($this->totalMemory / 1000 / 1000 / 1000, maxPrecision: 2, locale: auth()->user()->language) . ' GB';
|
||||
? format_number($this->totalMemory / 1024 / 1024 / 1024, maxPrecision: 2) .' GiB'
|
||||
: format_number($this->totalMemory / 1000 / 1000 / 1000, maxPrecision: 2) . ' GB';
|
||||
|
||||
return trans('admin/node.memory_chart', ['used' => $used, 'total' => $total]);
|
||||
}
|
||||
@@ -1,19 +1,19 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Admin\Resources\NodeResource\Widgets;
|
||||
namespace App\Filament\Admin\Resources\Nodes\Widgets;
|
||||
|
||||
use App\Models\Node;
|
||||
use Filament\Widgets\ChartWidget;
|
||||
|
||||
class NodeStorageChart extends ChartWidget
|
||||
{
|
||||
protected static ?string $pollingInterval = '360s';
|
||||
protected ?string $pollingInterval = '360s';
|
||||
|
||||
protected static ?string $maxHeight = '200px';
|
||||
protected ?string $maxHeight = '200px';
|
||||
|
||||
public Node $node;
|
||||
|
||||
protected static ?array $options = [
|
||||
protected ?array $options = [
|
||||
'scales' => [
|
||||
'x' => [
|
||||
'grid' => [
|
||||
@@ -1,8 +1,8 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Admin\Resources\RoleResource\Pages;
|
||||
namespace App\Filament\Admin\Resources\Roles\Pages;
|
||||
|
||||
use App\Filament\Admin\Resources\RoleResource;
|
||||
use App\Filament\Admin\Resources\Roles\RoleResource;
|
||||
use App\Models\Role;
|
||||
use App\Traits\Filament\CanCustomizeHeaderActions;
|
||||
use App\Traits\Filament\CanCustomizeHeaderWidgets;
|
||||
@@ -1,8 +1,8 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Admin\Resources\RoleResource\Pages;
|
||||
namespace App\Filament\Admin\Resources\Roles\Pages;
|
||||
|
||||
use App\Filament\Admin\Resources\RoleResource;
|
||||
use App\Filament\Admin\Resources\Roles\RoleResource;
|
||||
use App\Models\Role;
|
||||
use App\Traits\Filament\CanCustomizeHeaderActions;
|
||||
use App\Traits\Filament\CanCustomizeHeaderWidgets;
|
||||
@@ -1,8 +1,8 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Admin\Resources\RoleResource\Pages;
|
||||
namespace App\Filament\Admin\Resources\Roles\Pages;
|
||||
|
||||
use App\Filament\Admin\Resources\RoleResource;
|
||||
use App\Filament\Admin\Resources\Roles\RoleResource;
|
||||
use App\Traits\Filament\CanCustomizeHeaderActions;
|
||||
use App\Traits\Filament\CanCustomizeHeaderWidgets;
|
||||
use Filament\Actions\Action;
|
||||
@@ -1,8 +1,8 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Admin\Resources\RoleResource\Pages;
|
||||
namespace App\Filament\Admin\Resources\Roles\Pages;
|
||||
|
||||
use App\Filament\Admin\Resources\RoleResource;
|
||||
use App\Filament\Admin\Resources\Roles\RoleResource;
|
||||
use App\Traits\Filament\CanCustomizeHeaderActions;
|
||||
use App\Traits\Filament\CanCustomizeHeaderWidgets;
|
||||
use Filament\Actions\Action;
|
||||
@@ -1,29 +1,35 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Admin\Resources;
|
||||
namespace App\Filament\Admin\Resources\Roles;
|
||||
|
||||
use App\Filament\Admin\Resources\RoleResource\Pages;
|
||||
use App\Enums\CustomizationKey;
|
||||
use App\Filament\Admin\Resources\Roles\Pages\CreateRole;
|
||||
use App\Filament\Admin\Resources\Roles\Pages\EditRole;
|
||||
use App\Filament\Admin\Resources\Roles\Pages\ListRoles;
|
||||
use App\Filament\Admin\Resources\Roles\Pages\ViewRole;
|
||||
use App\Models\Role;
|
||||
use App\Traits\Filament\CanCustomizePages;
|
||||
use App\Traits\Filament\CanCustomizeRelations;
|
||||
use App\Traits\Filament\CanModifyForm;
|
||||
use App\Traits\Filament\CanModifyTable;
|
||||
use Filament\Forms\Components\Actions\Action;
|
||||
use BackedEnum;
|
||||
use Exception;
|
||||
use Filament\Actions\Action;
|
||||
use Filament\Actions\CreateAction;
|
||||
use Filament\Actions\DeleteBulkAction;
|
||||
use Filament\Actions\EditAction;
|
||||
use Filament\Actions\ViewAction;
|
||||
use Filament\Forms\Components\CheckboxList;
|
||||
use Filament\Forms\Components\Component;
|
||||
use Filament\Forms\Components\Fieldset;
|
||||
use Filament\Forms\Components\Placeholder;
|
||||
use Filament\Forms\Components\Section;
|
||||
use Filament\Forms\Components\Select;
|
||||
use Filament\Forms\Components\TextInput;
|
||||
use Filament\Forms\Form;
|
||||
use Filament\Forms\Get;
|
||||
use Filament\Infolists\Components\TextEntry;
|
||||
use Filament\Resources\Pages\PageRegistration;
|
||||
use Filament\Resources\Resource;
|
||||
use Filament\Tables\Actions\CreateAction;
|
||||
use Filament\Tables\Actions\DeleteBulkAction;
|
||||
use Filament\Tables\Actions\EditAction;
|
||||
use Filament\Tables\Actions\ViewAction;
|
||||
use Filament\Schemas\Components\Component;
|
||||
use Filament\Schemas\Components\Fieldset;
|
||||
use Filament\Schemas\Components\Section;
|
||||
use Filament\Schemas\Components\Utilities\Get;
|
||||
use Filament\Schemas\Schema;
|
||||
use Filament\Tables\Columns\TextColumn;
|
||||
use Filament\Tables\Table;
|
||||
use Illuminate\Support\Str;
|
||||
@@ -38,7 +44,7 @@ class RoleResource extends Resource
|
||||
|
||||
protected static ?string $model = Role::class;
|
||||
|
||||
protected static ?string $navigationIcon = 'tabler-users-group';
|
||||
protected static string|\BackedEnum|null $navigationIcon = 'tabler-users-group';
|
||||
|
||||
protected static ?string $recordTitleAttribute = 'name';
|
||||
|
||||
@@ -59,38 +65,38 @@ class RoleResource extends Resource
|
||||
|
||||
public static function getNavigationGroup(): ?string
|
||||
{
|
||||
return !empty(auth()->user()->getCustomization()['top_navigation']) ? trans('admin/dashboard.advanced') : trans('admin/dashboard.user');
|
||||
return auth()->user()->getCustomization(CustomizationKey::TopNavigation) ? trans('admin/dashboard.advanced') : trans('admin/dashboard.user');
|
||||
}
|
||||
|
||||
public static function getNavigationBadge(): ?string
|
||||
{
|
||||
return static::getModel()::count() ?: null;
|
||||
return ($count = static::getModel()::count()) > 0 ? (string) $count : null;
|
||||
}
|
||||
|
||||
/**
|
||||
* @throws Exception
|
||||
*/
|
||||
public static function defaultTable(Table $table): Table
|
||||
{
|
||||
return $table
|
||||
->columns([
|
||||
TextColumn::make('name')
|
||||
->label(trans('admin/role.name'))
|
||||
->sortable()
|
||||
->searchable(),
|
||||
->sortable(),
|
||||
TextColumn::make('permissions_count')
|
||||
->label(trans('admin/role.permissions'))
|
||||
->badge()
|
||||
->counts('permissions')
|
||||
->formatStateUsing(fn (Role $role, $state) => $role->isRootAdmin() ? trans('admin/role.all') : $state),
|
||||
TextColumn::make('nodes.name')
|
||||
->icon('tabler-server-2')
|
||||
->label(trans('admin/role.nodes'))
|
||||
->badge()
|
||||
->placeholder(trans('admin/role.all')),
|
||||
TextColumn::make('users_count')
|
||||
->label(trans('admin/role.users'))
|
||||
->counts('users')
|
||||
->icon('tabler-users'),
|
||||
->counts('users'),
|
||||
])
|
||||
->actions([
|
||||
->recordActions([
|
||||
ViewAction::make()
|
||||
->hidden(fn ($record) => static::canEdit($record)),
|
||||
EditAction::make(),
|
||||
@@ -107,7 +113,10 @@ class RoleResource extends Resource
|
||||
]);
|
||||
}
|
||||
|
||||
public static function defaultForm(Form $form): Form
|
||||
/**
|
||||
* @throws Exception
|
||||
*/
|
||||
public static function defaultForm(Schema $schema): Schema
|
||||
{
|
||||
$permissionSections = [];
|
||||
|
||||
@@ -121,15 +130,14 @@ class RoleResource extends Resource
|
||||
$permissionSections[] = self::makeSection($model, $options);
|
||||
}
|
||||
|
||||
return $form
|
||||
return $schema
|
||||
->columns(1)
|
||||
->schema([
|
||||
->components([
|
||||
TextInput::make('name')
|
||||
->label(trans('admin/role.name'))
|
||||
->required()
|
||||
->disabled(fn (Get $get) => $get('name') === Role::ROOT_ADMIN),
|
||||
TextInput::make('guard_name')
|
||||
->label('Guard Name')
|
||||
->default(Role::DEFAULT_GUARD_NAME)
|
||||
->nullable()
|
||||
->hidden(),
|
||||
@@ -137,9 +145,9 @@ class RoleResource extends Resource
|
||||
->columns(3)
|
||||
->schema($permissionSections)
|
||||
->hidden(fn (Get $get) => $get('name') === Role::ROOT_ADMIN),
|
||||
Placeholder::make('permissions')
|
||||
TextEntry::make('permissions')
|
||||
->label(trans('admin/role.permissions'))
|
||||
->content(trans('admin/role.root_admin', ['role' => Role::ROOT_ADMIN]))
|
||||
->state(trans('admin/role.root_admin', ['role' => Role::ROOT_ADMIN]))
|
||||
->visible(fn (Get $get) => $get('name') === Role::ROOT_ADMIN),
|
||||
Select::make('nodes')
|
||||
->label(trans('admin/role.nodes'))
|
||||
@@ -153,7 +161,9 @@ class RoleResource extends Resource
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string[]|int[]|Permission[]|\BackedEnum[] $options
|
||||
* @param string[]|int[]|Permission[]|BackedEnum[] $options
|
||||
*
|
||||
* @throws Exception
|
||||
*/
|
||||
private static function makeSection(string $model, array $options): Section
|
||||
{
|
||||
@@ -181,7 +191,7 @@ class RoleResource extends Resource
|
||||
])
|
||||
->schema([
|
||||
CheckboxList::make(strtolower($model) . '_list')
|
||||
->label('')
|
||||
->hiddenLabel()
|
||||
->options($options)
|
||||
->columns()
|
||||
->gridDirection('row')
|
||||
@@ -214,10 +224,10 @@ class RoleResource extends Resource
|
||||
public static function getDefaultPages(): array
|
||||
{
|
||||
return [
|
||||
'index' => Pages\ListRoles::route('/'),
|
||||
'create' => Pages\CreateRole::route('/create'),
|
||||
'view' => Pages\ViewRole::route('/{record}'),
|
||||
'edit' => Pages\EditRole::route('/{record}/edit'),
|
||||
'index' => ListRoles::route('/'),
|
||||
'create' => CreateRole::route('/create'),
|
||||
'view' => ViewRole::route('/{record}'),
|
||||
'edit' => EditRole::route('/{record}/edit'),
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -1,8 +1,9 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Admin\Resources\ServerResource\Pages;
|
||||
namespace App\Filament\Admin\Resources\Servers\Pages;
|
||||
|
||||
use App\Filament\Admin\Resources\ServerResource;
|
||||
use App\Filament\Admin\Resources\Servers\ServerResource;
|
||||
use App\Filament\Components\Forms\Fields\StartupVariable;
|
||||
use App\Models\Allocation;
|
||||
use App\Models\Egg;
|
||||
use App\Models\Node;
|
||||
@@ -13,37 +14,34 @@ use App\Services\Servers\ServerCreationService;
|
||||
use App\Services\Users\UserCreationService;
|
||||
use App\Traits\Filament\CanCustomizeHeaderActions;
|
||||
use App\Traits\Filament\CanCustomizeHeaderWidgets;
|
||||
use Closure;
|
||||
use Exception;
|
||||
use Filament\Forms;
|
||||
use Filament\Forms\Components\Actions\Action;
|
||||
use Filament\Forms\Components\Component;
|
||||
use Filament\Forms\Components\Fieldset;
|
||||
use Filament\Forms\Components\Grid;
|
||||
use Filament\Actions\Action;
|
||||
use Filament\Forms\Components\Hidden;
|
||||
use Filament\Forms\Components\KeyValue;
|
||||
use Filament\Forms\Components\Placeholder;
|
||||
use Filament\Forms\Components\Repeater;
|
||||
use Filament\Forms\Components\Section;
|
||||
use Filament\Forms\Components\Select;
|
||||
use Filament\Forms\Components\TagsInput;
|
||||
use Filament\Forms\Components\Textarea;
|
||||
use Filament\Forms\Components\TextInput;
|
||||
use Filament\Forms\Components\ToggleButtons;
|
||||
use Filament\Forms\Components\Wizard;
|
||||
use Filament\Forms\Components\Wizard\Step;
|
||||
use Filament\Forms\Form;
|
||||
use Filament\Forms\Get;
|
||||
use Filament\Forms\Set;
|
||||
use Filament\Infolists\Components\TextEntry;
|
||||
use Filament\Notifications\Notification;
|
||||
use Filament\Resources\Pages\CreateRecord;
|
||||
use Filament\Schemas\Components\Fieldset;
|
||||
use Filament\Schemas\Components\Grid;
|
||||
use Filament\Schemas\Components\Section;
|
||||
use Filament\Schemas\Components\Utilities\Get;
|
||||
use Filament\Schemas\Components\Utilities\Set;
|
||||
use Filament\Schemas\Components\Wizard;
|
||||
use Filament\Schemas\Components\Wizard\Step;
|
||||
use Filament\Schemas\Schema;
|
||||
use Filament\Support\Exceptions\Halt;
|
||||
use Illuminate\Database\Eloquent\Builder;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Support\Facades\Blade;
|
||||
use Illuminate\Support\Facades\Validator;
|
||||
use Illuminate\Support\HtmlString;
|
||||
use LogicException;
|
||||
use Random\RandomException;
|
||||
|
||||
class CreateServer extends CreateRecord
|
||||
{
|
||||
@@ -63,10 +61,14 @@ class CreateServer extends CreateRecord
|
||||
$this->serverCreationService = $serverCreationService;
|
||||
}
|
||||
|
||||
public function form(Form $form): Form
|
||||
/**
|
||||
* @throws RandomException
|
||||
* @throws Exception
|
||||
*/
|
||||
public function form(Schema $schema): Schema
|
||||
{
|
||||
return $form
|
||||
->schema([
|
||||
return $schema
|
||||
->components([
|
||||
Wizard::make([
|
||||
Step::make('Information')
|
||||
->label(trans('admin/server.tabs.information'))
|
||||
@@ -81,7 +83,7 @@ class CreateServer extends CreateRecord
|
||||
TextInput::make('name')
|
||||
->prefixIcon('tabler-server')
|
||||
->label(trans('admin/server.name'))
|
||||
->suffixAction(Forms\Components\Actions\Action::make('random')
|
||||
->suffixAction(Action::make('random')
|
||||
->icon('tabler-dice-' . random_int(1, 6))
|
||||
->action(function (Set $set, Get $get) {
|
||||
$egg = Egg::find($get('egg_id'));
|
||||
@@ -106,7 +108,7 @@ class CreateServer extends CreateRecord
|
||||
'sm' => 2,
|
||||
'md' => 2,
|
||||
])
|
||||
->unique(ignoreRecord: true)
|
||||
->unique()
|
||||
->maxLength(255),
|
||||
|
||||
Select::make('node_id')
|
||||
@@ -167,8 +169,7 @@ class CreateServer extends CreateRecord
|
||||
|
||||
TextInput::make('password')
|
||||
->label(trans('admin/user.password'))
|
||||
->hintIcon('tabler-question-mark')
|
||||
->hintIconTooltip(trans('admin/user.password_help'))
|
||||
->hintIcon('tabler-question-mark', trans('admin/user.password_help'))
|
||||
->password(),
|
||||
])
|
||||
->createOptionUsing(function ($data, UserCreationService $service) {
|
||||
@@ -217,12 +218,21 @@ class CreateServer extends CreateRecord
|
||||
|
||||
return [
|
||||
Select::make('allocation_ip')
|
||||
->options(collect(Node::find($get('node_id'))?->ipAddresses())->mapWithKeys(fn (string $ip) => [$ip => $ip]))
|
||||
->options(fn () => collect(Node::find($get('node_id'))?->ipAddresses())->mapWithKeys(fn (string $ip) => [$ip => $ip]))
|
||||
->label(trans('admin/server.ip_address'))->inlineLabel()
|
||||
->helperText(trans('admin/server.ip_address_helper'))
|
||||
->afterStateUpdated(fn (Set $set) => $set('allocation_ports', []))
|
||||
->ip()
|
||||
->live()
|
||||
->hintAction(
|
||||
Action::make('refresh')
|
||||
->iconButton()
|
||||
->icon('tabler-refresh')
|
||||
->tooltip(trans('admin/node.refresh'))
|
||||
->action(function () use ($get) {
|
||||
cache()->forget("nodes.{$get('node_id')}.ips");
|
||||
})
|
||||
)
|
||||
->required(),
|
||||
TextInput::make('allocation_alias')
|
||||
->label(trans('admin/server.alias'))->inlineLabel()
|
||||
@@ -266,7 +276,7 @@ class CreateServer extends CreateRecord
|
||||
->preload()
|
||||
->disableOptionsWhenSelectedInSiblingRepeaterItems()
|
||||
->prefixIcon('tabler-network')
|
||||
->label('Additional Allocations')
|
||||
->label(trans('admin/server.additional_allocations'))
|
||||
->columnSpan(2)
|
||||
->disabled(fn (Get $get) => $get('../../allocation_id') === null || $get('../../node_id') === null)
|
||||
->searchable(['ip', 'port', 'ip_alias'])
|
||||
@@ -420,16 +430,14 @@ class CreateServer extends CreateRecord
|
||||
->collapsible()
|
||||
->columnSpanFull()
|
||||
->schema([
|
||||
Placeholder::make(trans('admin/server.select_egg'))
|
||||
TextEntry::make(trans('admin/server.select_egg'))
|
||||
->hidden(fn (Get $get) => $get('egg_id')),
|
||||
|
||||
Placeholder::make(trans('admin/server.no_variables'))
|
||||
TextEntry::make(trans('admin/server.no_variables'))
|
||||
->hidden(fn (Get $get) => !$get('egg_id') ||
|
||||
Egg::query()->find($get('egg_id'))?->variables()?->count()
|
||||
),
|
||||
|
||||
Repeater::make('server_variables')
|
||||
->label('')
|
||||
->hiddenLabel()
|
||||
->relationship('serverVariables', fn (Builder $query) => $query->orderByPowerJoins('variable.sort'))
|
||||
->saveRelationshipsBeforeChildrenUsing(null)
|
||||
->saveRelationshipsUsing(null)
|
||||
@@ -439,51 +447,15 @@ class CreateServer extends CreateRecord
|
||||
->deletable(false)
|
||||
->default([])
|
||||
->hidden(fn ($state) => empty($state))
|
||||
->schema(function () {
|
||||
|
||||
$text = TextInput::make('variable_value')
|
||||
->hidden($this->shouldHideComponent(...))
|
||||
->dehydratedWhenHidden()
|
||||
->required(fn (Get $get) => in_array('required', $get('rules')))
|
||||
->rules(
|
||||
fn (Get $get): Closure => function (string $attribute, $value, Closure $fail) use ($get) {
|
||||
$validator = Validator::make(['validatorkey' => $value], [
|
||||
'validatorkey' => $get('rules'),
|
||||
]);
|
||||
|
||||
if ($validator->fails()) {
|
||||
$message = str($validator->errors()->first())->replace('validatorkey', $get('name'))->toString();
|
||||
|
||||
$fail($message);
|
||||
}
|
||||
},
|
||||
);
|
||||
|
||||
$select = Select::make('variable_value')
|
||||
->hidden($this->shouldHideComponent(...))
|
||||
->dehydratedWhenHidden()
|
||||
->options($this->getSelectOptionsFromRules(...))
|
||||
->selectablePlaceholder(false);
|
||||
|
||||
$components = [$text, $select];
|
||||
|
||||
foreach ($components as &$component) {
|
||||
$component = $component
|
||||
->live(onBlur: true)
|
||||
->hintIcon('tabler-code')
|
||||
->label(fn (Get $get) => $get('name'))
|
||||
->hintIconTooltip(fn (Get $get) => implode('|', $get('rules')))
|
||||
->prefix(fn (Get $get) => '{{' . $get('env_variable') . '}}')
|
||||
->helperText(fn (Get $get) => empty($get('description')) ? '—' : $get('description'))
|
||||
->afterStateUpdated(function (Set $set, Get $get, $state) {
|
||||
$environment = $get($envPath = '../../environment');
|
||||
$environment[$get('env_variable')] = $state;
|
||||
$set($envPath, $environment);
|
||||
});
|
||||
}
|
||||
|
||||
return $components;
|
||||
})
|
||||
->schema([
|
||||
StartupVariable::make('variable_value')
|
||||
->fromForm()
|
||||
->afterStateUpdated(function (Set $set, Get $get, $state) {
|
||||
$environment = $get($envPath = '../../environment');
|
||||
$environment[$get('env_variable')] = $state;
|
||||
$set($envPath, $environment);
|
||||
}),
|
||||
])
|
||||
->columnSpan(2),
|
||||
]),
|
||||
]),
|
||||
@@ -557,8 +529,7 @@ class CreateServer extends CreateRecord
|
||||
->hidden(fn (Get $get) => $get('unlimited_mem'))
|
||||
->label(trans('admin/server.memory_limit'))->inlineLabel()
|
||||
->suffix(config('panel.use_binary_prefix') ? 'MiB' : 'MB')
|
||||
->hintIcon('tabler-question-mark')
|
||||
->hintIconToolTip(trans('admin/server.memory_helper'))
|
||||
->hintIcon('tabler-question-mark', trans('admin/server.memory_helper'))
|
||||
->default(0)
|
||||
->required()
|
||||
->columnSpan(2)
|
||||
@@ -799,7 +770,7 @@ class CreateServer extends CreateRecord
|
||||
|
||||
KeyValue::make('docker_labels')
|
||||
->live()
|
||||
->label('Container Labels')
|
||||
->label(trans('admin/server.container_labels'))
|
||||
->keyLabel(trans('admin/server.title'))
|
||||
->valueLabel(trans('admin/server.description'))
|
||||
->columnSpanFull(),
|
||||
@@ -815,7 +786,7 @@ class CreateServer extends CreateRecord
|
||||
type="submit"
|
||||
size="sm"
|
||||
>
|
||||
Create Server
|
||||
{{ trans('admin/server.create') }}
|
||||
</x-filament::button>
|
||||
BLADE))),
|
||||
]);
|
||||
@@ -851,40 +822,6 @@ class CreateServer extends CreateRecord
|
||||
}
|
||||
}
|
||||
|
||||
private function shouldHideComponent(Get $get, Component $component): bool
|
||||
{
|
||||
$containsRuleIn = collect($get('rules'))->reduce(
|
||||
fn ($result, $value) => $result === true && !str($value)->startsWith('in:'), true
|
||||
);
|
||||
|
||||
if ($component instanceof Select) {
|
||||
return $containsRuleIn;
|
||||
}
|
||||
|
||||
if ($component instanceof TextInput) {
|
||||
return !$containsRuleIn;
|
||||
}
|
||||
|
||||
throw new Exception('Component type not supported: ' . $component::class);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array<array-key, string>
|
||||
*/
|
||||
private function getSelectOptionsFromRules(Get $get): array
|
||||
{
|
||||
$inRule = collect($get('rules'))->reduce(
|
||||
fn ($result, $value) => str($value)->startsWith('in:') ? $value : $result, ''
|
||||
);
|
||||
|
||||
return str($inRule)
|
||||
->after('in:')
|
||||
->explode(',')
|
||||
->each(fn ($value) => str($value)->trim())
|
||||
->mapWithKeys(fn ($value) => [$value => $value])
|
||||
->all();
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string[] $portEntries
|
||||
* @return array<int>
|
||||
@@ -1,23 +1,21 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Admin\Resources\ServerResource\Pages;
|
||||
namespace App\Filament\Admin\Resources\Servers\Pages;
|
||||
|
||||
use AbdelhamidErrahmouni\FilamentMonacoEditor\MonacoEditor;
|
||||
use App\Enums\SuspendAction;
|
||||
use App\Filament\Admin\Resources\ServerResource;
|
||||
use App\Filament\Components\Forms\Actions\PreviewStartupAction;
|
||||
use App\Filament\Components\Forms\Actions\RotateDatabasePasswordAction;
|
||||
use App\Filament\Admin\Resources\Servers\RelationManagers\AllocationsRelationManager;
|
||||
use App\Filament\Admin\Resources\Servers\RelationManagers\DatabasesRelationManager;
|
||||
use App\Filament\Admin\Resources\Servers\ServerResource;
|
||||
use App\Filament\Components\Actions\PreviewStartupAction;
|
||||
use App\Filament\Components\Forms\Fields\StartupVariable;
|
||||
use App\Filament\Components\StateCasts\ServerConditionStateCast;
|
||||
use App\Filament\Server\Pages\Console;
|
||||
use App\Models\Allocation;
|
||||
use App\Models\Database;
|
||||
use App\Models\DatabaseHost;
|
||||
use App\Models\Egg;
|
||||
use App\Models\Node;
|
||||
use App\Models\Server;
|
||||
use App\Models\ServerVariable;
|
||||
use App\Models\User;
|
||||
use App\Repositories\Daemon\DaemonServerRepository;
|
||||
use App\Services\Databases\DatabaseManagementService;
|
||||
use App\Services\Eggs\EggChangerService;
|
||||
use App\Services\Servers\RandomWordService;
|
||||
use App\Services\Servers\ReinstallServerService;
|
||||
@@ -27,39 +25,38 @@ use App\Services\Servers\ToggleInstallService;
|
||||
use App\Services\Servers\TransferServerService;
|
||||
use App\Traits\Filament\CanCustomizeHeaderActions;
|
||||
use App\Traits\Filament\CanCustomizeHeaderWidgets;
|
||||
use Closure;
|
||||
use Exception;
|
||||
use Filament\Actions;
|
||||
use Filament\Forms;
|
||||
use Filament\Forms\Components\Actions as FormActions;
|
||||
use Filament\Forms\Components\Actions\Action;
|
||||
use Filament\Forms\Components\Component;
|
||||
use Filament\Forms\Components\Fieldset;
|
||||
use Filament\Forms\Components\Grid;
|
||||
use Filament\Actions\Action;
|
||||
use Filament\Actions\ActionGroup;
|
||||
use Filament\Forms\Components\CodeEditor;
|
||||
use Filament\Forms\Components\Hidden;
|
||||
use Filament\Forms\Components\KeyValue;
|
||||
use Filament\Forms\Components\Repeater;
|
||||
use Filament\Forms\Components\Select;
|
||||
use Filament\Forms\Components\Tabs;
|
||||
use Filament\Forms\Components\Tabs\Tab;
|
||||
use Filament\Forms\Components\TagsInput;
|
||||
use Filament\Forms\Components\Textarea;
|
||||
use Filament\Forms\Components\TextInput;
|
||||
use Filament\Forms\Components\Toggle;
|
||||
use Filament\Forms\Components\ToggleButtons;
|
||||
use Filament\Forms\Form;
|
||||
use Filament\Forms\Get;
|
||||
use Filament\Forms\Set;
|
||||
use Filament\Notifications\Notification;
|
||||
use Filament\Resources\Pages\EditRecord;
|
||||
use Filament\Schemas\Components\Actions;
|
||||
use Filament\Schemas\Components\Component;
|
||||
use Filament\Schemas\Components\Fieldset;
|
||||
use Filament\Schemas\Components\Grid;
|
||||
use Filament\Schemas\Components\StateCasts\BooleanStateCast;
|
||||
use Filament\Schemas\Components\Tabs;
|
||||
use Filament\Schemas\Components\Tabs\Tab;
|
||||
use Filament\Schemas\Components\Utilities\Get;
|
||||
use Filament\Schemas\Components\Utilities\Set;
|
||||
use Filament\Schemas\Schema;
|
||||
use Filament\Support\Enums\Alignment;
|
||||
use Illuminate\Database\Eloquent\Builder;
|
||||
use Illuminate\Http\Client\ConnectionException;
|
||||
use Illuminate\Support\Arr;
|
||||
use Illuminate\Support\Facades\Validator;
|
||||
use Illuminate\Support\HtmlString;
|
||||
use LogicException;
|
||||
use Webbingbrasil\FilamentCopyActions\Forms\Actions\CopyAction;
|
||||
use Random\RandomException;
|
||||
|
||||
class EditServer extends EditRecord
|
||||
{
|
||||
@@ -75,10 +72,14 @@ class EditServer extends EditRecord
|
||||
$this->daemonServerRepository = $daemonServerRepository;
|
||||
}
|
||||
|
||||
public function form(Form $form): Form
|
||||
/**
|
||||
* @throws RandomException
|
||||
* @throws Exception
|
||||
*/
|
||||
public function form(Schema $schema): Schema
|
||||
{
|
||||
return $form
|
||||
->schema([
|
||||
return $schema
|
||||
->components([
|
||||
Tabs::make('Tabs')
|
||||
->persistTabInQueryString()
|
||||
->columns([
|
||||
@@ -89,7 +90,8 @@ class EditServer extends EditRecord
|
||||
])
|
||||
->columnSpanFull()
|
||||
->tabs([
|
||||
Tab::make(trans('admin/server.tabs.information'))
|
||||
Tab::make('information')
|
||||
->label(trans('admin/server.tabs.information'))
|
||||
->icon('tabler-info-circle')
|
||||
->schema([
|
||||
TextInput::make('name')
|
||||
@@ -113,7 +115,6 @@ class EditServer extends EditRecord
|
||||
])
|
||||
->required()
|
||||
->maxLength(255),
|
||||
|
||||
Select::make('owner_id')
|
||||
->prefixIcon('tabler-user')
|
||||
->label(trans('admin/server.owner'))
|
||||
@@ -128,13 +129,13 @@ class EditServer extends EditRecord
|
||||
->getOptionLabelFromRecordUsing(fn (User $user) => "$user->username ($user->email)")
|
||||
->preload()
|
||||
->required(),
|
||||
|
||||
ToggleButtons::make('condition')
|
||||
->label(trans('admin/server.server_status'))
|
||||
->formatStateUsing(fn (Server $server) => $server->condition)
|
||||
->options(fn ($state) => [$state->value => $state->getLabel()])
|
||||
->colors(fn ($state) => [$state->value => $state->getColor()])
|
||||
->icons(fn ($state) => [$state->value => $state->getIcon()])
|
||||
->stateCast(new ServerConditionStateCast())
|
||||
->columnSpan([
|
||||
'default' => 2,
|
||||
'sm' => 1,
|
||||
@@ -149,10 +150,9 @@ class EditServer extends EditRecord
|
||||
->modalSubmitAction(false)
|
||||
->modalFooterActionsAlignment(Alignment::Right)
|
||||
->modalCancelActionLabel(trans('filament::components/modal.actions.close.label'))
|
||||
->form([
|
||||
MonacoEditor::make('logs')
|
||||
->schema([
|
||||
CodeEditor::make('logs')
|
||||
->hiddenLabel()
|
||||
->placeholderText(trans('admin/server.no_log'))
|
||||
->formatStateUsing(function (Server $server, DaemonServerRepository $serverRepository) {
|
||||
try {
|
||||
return $serverRepository->setServer($server)->getInstallLogs();
|
||||
@@ -168,9 +168,7 @@ class EditServer extends EditRecord
|
||||
}
|
||||
|
||||
return '';
|
||||
})
|
||||
->language('shell')
|
||||
->view('filament.plugins.monaco-editor-logs'),
|
||||
}),
|
||||
])
|
||||
),
|
||||
|
||||
@@ -180,7 +178,7 @@ class EditServer extends EditRecord
|
||||
|
||||
TextInput::make('uuid')
|
||||
->label(trans('admin/server.uuid'))
|
||||
->suffixAction(fn () => request()->isSecure() ? CopyAction::make() : null)
|
||||
->copyable()
|
||||
->columnSpan([
|
||||
'default' => 2,
|
||||
'sm' => 1,
|
||||
@@ -191,7 +189,7 @@ class EditServer extends EditRecord
|
||||
->dehydrated(false),
|
||||
TextInput::make('uuid_short')
|
||||
->label(trans('admin/server.short_uuid'))
|
||||
->suffixAction(fn () => request()->isSecure() ? CopyAction::make() : null)
|
||||
->copyable()
|
||||
->columnSpan([
|
||||
'default' => 2,
|
||||
'sm' => 1,
|
||||
@@ -208,7 +206,7 @@ class EditServer extends EditRecord
|
||||
'md' => 2,
|
||||
'lg' => 3,
|
||||
])
|
||||
->unique(ignoreRecord: true)
|
||||
->unique()
|
||||
->maxLength(255),
|
||||
Select::make('node_id')
|
||||
->label(trans('admin/server.node'))
|
||||
@@ -221,10 +219,12 @@ class EditServer extends EditRecord
|
||||
])
|
||||
->disabled(),
|
||||
]),
|
||||
Tab::make(trans('admin/server.tabs.environment_configuration'))
|
||||
Tab::make('environment_configuration')
|
||||
->label(trans('admin/server.tabs.environment_configuration'))
|
||||
->icon('tabler-brand-docker')
|
||||
->schema([
|
||||
Fieldset::make(trans('admin/server.resource_limits'))
|
||||
->columnSpanFull()
|
||||
->columns([
|
||||
'default' => 1,
|
||||
'sm' => 2,
|
||||
@@ -242,13 +242,14 @@ class EditServer extends EditRecord
|
||||
->afterStateUpdated(fn (Set $set) => $set('cpu', 0))
|
||||
->formatStateUsing(fn (Get $get) => $get('cpu') == 0)
|
||||
->live()
|
||||
->stateCast(new BooleanStateCast(false, true))
|
||||
->options([
|
||||
true => trans('admin/server.unlimited'),
|
||||
false => trans('admin/server.limited'),
|
||||
1 => trans('admin/server.unlimited'),
|
||||
0 => trans('admin/server.limited'),
|
||||
])
|
||||
->colors([
|
||||
true => 'primary',
|
||||
false => 'warning',
|
||||
1 => 'primary',
|
||||
0 => 'warning',
|
||||
])
|
||||
->columnSpan(2),
|
||||
|
||||
@@ -272,13 +273,14 @@ class EditServer extends EditRecord
|
||||
->afterStateUpdated(fn (Set $set) => $set('memory', 0))
|
||||
->formatStateUsing(fn (Get $get) => $get('memory') == 0)
|
||||
->live()
|
||||
->stateCast(new BooleanStateCast(false, true))
|
||||
->options([
|
||||
true => trans('admin/server.unlimited'),
|
||||
false => trans('admin/server.limited'),
|
||||
1 => trans('admin/server.unlimited'),
|
||||
0 => trans('admin/server.limited'),
|
||||
])
|
||||
->colors([
|
||||
true => 'primary',
|
||||
false => 'warning',
|
||||
1 => 'primary',
|
||||
0 => 'warning',
|
||||
])
|
||||
->columnSpan(2),
|
||||
|
||||
@@ -287,8 +289,7 @@ class EditServer extends EditRecord
|
||||
->hidden(fn (Get $get) => $get('unlimited_mem'))
|
||||
->label(trans('admin/server.memory_limit'))->inlineLabel()
|
||||
->suffix(config('panel.use_binary_prefix') ? 'MiB' : 'MB')
|
||||
->hintIcon('tabler-question-mark')
|
||||
->hintIconToolTip(trans('admin/server.memory_helper'))
|
||||
->hintIcon('tabler-question-mark', trans('admin/server.memory_helper'))
|
||||
->required()
|
||||
->columnSpan(2)
|
||||
->numeric()
|
||||
@@ -305,13 +306,14 @@ class EditServer extends EditRecord
|
||||
->live()
|
||||
->afterStateUpdated(fn (Set $set) => $set('disk', 0))
|
||||
->formatStateUsing(fn (Get $get) => $get('disk') == 0)
|
||||
->stateCast(new BooleanStateCast(false, true))
|
||||
->options([
|
||||
true => trans('admin/server.unlimited'),
|
||||
false => trans('admin/server.limited'),
|
||||
1 => trans('admin/server.unlimited'),
|
||||
0 => trans('admin/server.limited'),
|
||||
])
|
||||
->colors([
|
||||
true => 'primary',
|
||||
false => 'warning',
|
||||
1 => 'primary',
|
||||
0 => 'warning',
|
||||
])
|
||||
->columnSpan(2),
|
||||
|
||||
@@ -328,6 +330,7 @@ class EditServer extends EditRecord
|
||||
]),
|
||||
|
||||
Fieldset::make(trans('admin/server.advanced_limits'))
|
||||
->columnSpanFull()
|
||||
->columns([
|
||||
'default' => 1,
|
||||
'sm' => 2,
|
||||
@@ -345,17 +348,18 @@ class EditServer extends EditRecord
|
||||
->schema([
|
||||
ToggleButtons::make('cpu_pinning')
|
||||
->label(trans('admin/server.cpu_pin'))->inlineLabel()->inline()
|
||||
->default(false)
|
||||
->default(0)
|
||||
->afterStateUpdated(fn (Set $set) => $set('threads', []))
|
||||
->formatStateUsing(fn (Get $get) => !empty($get('threads')))
|
||||
->live()
|
||||
->stateCast(new BooleanStateCast(false, true))
|
||||
->options([
|
||||
false => trans('admin/server.disabled'),
|
||||
true => trans('admin/server.enabled'),
|
||||
0 => trans('admin/server.disabled'),
|
||||
1 => trans('admin/server.enabled'),
|
||||
])
|
||||
->colors([
|
||||
false => 'success',
|
||||
true => 'warning',
|
||||
0 => 'success',
|
||||
1 => 'warning',
|
||||
])
|
||||
->columnSpan(2),
|
||||
|
||||
@@ -425,21 +429,27 @@ class EditServer extends EditRecord
|
||||
->columnSpanFull()
|
||||
->schema([
|
||||
ToggleButtons::make('oom_killer')
|
||||
->label(trans('admin/server.oom'))->inlineLabel()->inline()
|
||||
->dehydrated()
|
||||
->label(trans('admin/server.oom'))
|
||||
->formatStateUsing(fn ($state) => $state)
|
||||
->inlineLabel()
|
||||
->inline()
|
||||
->columnSpan(2)
|
||||
->stateCast(new BooleanStateCast(false, true))
|
||||
->options([
|
||||
false => trans('admin/server.disabled'),
|
||||
true => trans('admin/server.enabled'),
|
||||
0 => trans('admin/server.disabled'),
|
||||
1 => trans('admin/server.enabled'),
|
||||
])
|
||||
->colors([
|
||||
false => 'success',
|
||||
true => 'danger',
|
||||
0 => 'success',
|
||||
1 => 'danger',
|
||||
]),
|
||||
]),
|
||||
]),
|
||||
|
||||
Fieldset::make(trans('admin/server.feature_limits'))
|
||||
->inlineLabel()
|
||||
->columnSpanFull()
|
||||
->columns([
|
||||
'default' => 1,
|
||||
'sm' => 2,
|
||||
@@ -467,6 +477,7 @@ class EditServer extends EditRecord
|
||||
->numeric(),
|
||||
]),
|
||||
Fieldset::make(trans('admin/server.docker_settings'))
|
||||
->columnSpanFull()
|
||||
->columns([
|
||||
'default' => 1,
|
||||
'sm' => 2,
|
||||
@@ -528,7 +539,8 @@ class EditServer extends EditRecord
|
||||
->columnSpanFull(),
|
||||
]),
|
||||
]),
|
||||
Tab::make(trans('admin/server.egg'))
|
||||
Tab::make('egg')
|
||||
->label(trans('admin/server.egg'))
|
||||
->icon('tabler-egg')
|
||||
->columns([
|
||||
'default' => 1,
|
||||
@@ -555,12 +567,12 @@ class EditServer extends EditRecord
|
||||
Action::make('change_egg')
|
||||
->label(trans('admin/server.change_egg'))
|
||||
->action(function (array $data, Server $server, EggChangerService $service) {
|
||||
$service->handle($server, $data['egg_id'], $data['keepOldVariables']);
|
||||
$service->handle($server, $data['egg_id'], $data['keep_old_variables']);
|
||||
|
||||
// Use redirect instead of fillForm to prevent server variables from duplicating
|
||||
$this->redirect($this->getUrl(['record' => $server, 'tab' => '-egg-tab']), true);
|
||||
$this->redirect($this->getUrl(['record' => $server, 'tab' => 'egg::data::tab']), true);
|
||||
})
|
||||
->form(fn (Server $server) => [
|
||||
->schema(fn (Server $server) => [
|
||||
Select::make('egg_id')
|
||||
->label(trans('admin/server.new_egg'))
|
||||
->prefixIcon('tabler-egg')
|
||||
@@ -568,31 +580,33 @@ class EditServer extends EditRecord
|
||||
->searchable()
|
||||
->preload()
|
||||
->required(),
|
||||
Toggle::make('keepOldVariables')
|
||||
Toggle::make('keep_old_variables')
|
||||
->label(trans('admin/server.keep_old_variables'))
|
||||
->default(true),
|
||||
])
|
||||
),
|
||||
|
||||
ToggleButtons::make('skip_scripts')
|
||||
->label(trans('admin/server.install_script'))->inline()
|
||||
->label(trans('admin/server.install_script'))
|
||||
->inline()
|
||||
->columnSpan([
|
||||
'default' => 6,
|
||||
'sm' => 1,
|
||||
'md' => 1,
|
||||
'lg' => 2,
|
||||
])
|
||||
->stateCast(new BooleanStateCast(false, true))
|
||||
->options([
|
||||
false => trans('admin/server.yes'),
|
||||
true => trans('admin/server.skip'),
|
||||
0 => trans('admin/server.yes'),
|
||||
1 => trans('admin/server.skip'),
|
||||
])
|
||||
->colors([
|
||||
false => 'primary',
|
||||
true => 'danger',
|
||||
0 => 'primary',
|
||||
1 => 'danger',
|
||||
])
|
||||
->icons([
|
||||
false => 'tabler-code',
|
||||
true => 'tabler-code-off',
|
||||
0 => 'tabler-code',
|
||||
1 => 'tabler-code-off',
|
||||
])
|
||||
->required(),
|
||||
Hidden::make('previewing')
|
||||
@@ -605,7 +619,7 @@ class EditServer extends EditRecord
|
||||
->hintAction(PreviewStartupAction::make('preview')),
|
||||
|
||||
Textarea::make('defaultStartup')
|
||||
->hintAction(fn () => request()->isSecure() ? CopyAction::make() : null)
|
||||
->hintCopy()
|
||||
->label(trans('admin/server.default_startup'))
|
||||
->disabled()
|
||||
->autosize()
|
||||
@@ -617,214 +631,40 @@ class EditServer extends EditRecord
|
||||
}),
|
||||
|
||||
Repeater::make('server_variables')
|
||||
->label('')
|
||||
->hiddenLabel()
|
||||
->relationship('serverVariables', function (Builder $query) {
|
||||
/** @var Server $server */
|
||||
$server = $this->getRecord();
|
||||
|
||||
foreach ($server->variables as $variable) {
|
||||
ServerVariable::query()->firstOrCreate([
|
||||
'server_id' => $server->id,
|
||||
'variable_id' => $variable->id,
|
||||
], [
|
||||
'variable_value' => $variable->server_value ?? '',
|
||||
]);
|
||||
}
|
||||
$server->ensureVariablesExist();
|
||||
|
||||
return $query->orderByPowerJoins('variable.sort');
|
||||
})
|
||||
->grid()
|
||||
->mutateRelationshipDataBeforeSaveUsing(function (array &$data): array {
|
||||
foreach ($data as $key => $value) {
|
||||
if (!isset($data['variable_value'])) {
|
||||
$data['variable_value'] = '';
|
||||
}
|
||||
}
|
||||
->mutateRelationshipDataBeforeSaveUsing(function (array $data): array {
|
||||
$data['variable_value'] ??= '';
|
||||
|
||||
return $data;
|
||||
})
|
||||
->reorderable(false)->addable(false)->deletable(false)
|
||||
->schema(function () {
|
||||
|
||||
$text = TextInput::make('variable_value')
|
||||
->hidden($this->shouldHideComponent(...))
|
||||
->dehydratedWhenHidden()
|
||||
->required(fn (ServerVariable $serverVariable) => $serverVariable->variable->getRequiredAttribute())
|
||||
->rules([
|
||||
fn (ServerVariable $serverVariable): Closure => function (string $attribute, $value, Closure $fail) use ($serverVariable) {
|
||||
$validator = Validator::make(['validatorkey' => $value], [
|
||||
'validatorkey' => $serverVariable->variable->rules,
|
||||
]);
|
||||
|
||||
if ($validator->fails()) {
|
||||
$message = str($validator->errors()->first())->replace('validatorkey', $serverVariable->variable->name);
|
||||
|
||||
$fail($message);
|
||||
}
|
||||
},
|
||||
]);
|
||||
|
||||
$select = Select::make('variable_value')
|
||||
->hidden($this->shouldHideComponent(...))
|
||||
->dehydratedWhenHidden()
|
||||
->options($this->getSelectOptionsFromRules(...))
|
||||
->selectablePlaceholder(false);
|
||||
|
||||
$components = [$text, $select];
|
||||
|
||||
foreach ($components as &$component) {
|
||||
$component = $component
|
||||
->live(onBlur: true)
|
||||
->hintIcon('tabler-code')
|
||||
->label(fn (ServerVariable $serverVariable) => $serverVariable->variable->name)
|
||||
->hintIconTooltip(fn (ServerVariable $serverVariable) => implode('|', $serverVariable->variable->rules))
|
||||
->prefix(fn (ServerVariable $serverVariable) => '{{' . $serverVariable->variable->env_variable . '}}')
|
||||
->helperText(fn (ServerVariable $serverVariable) => empty($serverVariable->variable->description) ? '—' : $serverVariable->variable->description);
|
||||
}
|
||||
|
||||
return $components;
|
||||
})
|
||||
->schema([
|
||||
StartupVariable::make('variable_value')
|
||||
->fromRecord(),
|
||||
])
|
||||
->columnSpan(6),
|
||||
]),
|
||||
Tab::make(trans('admin/server.mounts'))
|
||||
Tab::make('mounts')
|
||||
->label(trans('admin/server.mounts'))
|
||||
->icon('tabler-layers-linked')
|
||||
->schema(fn (Get $get) => [
|
||||
ServerResource::getMountCheckboxList($get),
|
||||
]),
|
||||
Tab::make(trans('admin/server.databases'))
|
||||
->hidden(fn () => !auth()->user()->can('viewAny', Database::class))
|
||||
->icon('tabler-database')
|
||||
->columns(4)
|
||||
->schema([
|
||||
Repeater::make('databases')
|
||||
->label('')
|
||||
->grid()
|
||||
->helperText(fn (Server $server) => $server->databases->isNotEmpty() ? '' : trans('admin/server.no_databases'))
|
||||
->columns(2)
|
||||
->schema([
|
||||
TextInput::make('host')
|
||||
->label(trans('admin/databasehost.table.host'))
|
||||
->disabled()
|
||||
->formatStateUsing(fn ($record) => $record->address())
|
||||
->suffixAction(fn (string $state) => request()->isSecure() ? CopyAction::make()->copyable($state) : null)
|
||||
->columnSpan(1),
|
||||
TextInput::make('database')
|
||||
->label(trans('admin/databasehost.table.database'))
|
||||
->disabled()
|
||||
->formatStateUsing(fn ($record) => $record->database)
|
||||
->suffixAction(fn (string $state) => request()->isSecure() ? CopyAction::make()->copyable($state) : null)
|
||||
->hintAction(
|
||||
Action::make('Delete')
|
||||
->label(trans('filament-actions::delete.single.modal.actions.delete.label'))
|
||||
->authorize(fn (Database $database) => auth()->user()->can('delete', $database))
|
||||
->color('danger')
|
||||
->icon('tabler-trash')
|
||||
->requiresConfirmation()
|
||||
->modalIcon('tabler-database-x')
|
||||
->modalHeading(trans('admin/server.delete_db_heading'))
|
||||
->modalSubmitActionLabel(trans('filament-actions::delete.single.label'))
|
||||
->modalDescription(fn (Get $get) => trans('admin/server.delete_db', ['name' => $get('database')]))
|
||||
->action(function (DatabaseManagementService $databaseManagementService, $record) {
|
||||
$databaseManagementService->delete($record);
|
||||
$this->fillForm();
|
||||
})
|
||||
),
|
||||
TextInput::make('username')
|
||||
->label(trans('admin/databasehost.table.username'))
|
||||
->disabled()
|
||||
->formatStateUsing(fn ($record) => $record->username)
|
||||
->suffixAction(fn (string $state) => request()->isSecure() ? CopyAction::make()->copyable($state) : null)
|
||||
->columnSpan(1),
|
||||
TextInput::make('password')
|
||||
->label(trans('admin/databasehost.table.password'))
|
||||
->disabled()
|
||||
->password()
|
||||
->revealable()
|
||||
->columnSpan(1)
|
||||
->hintAction(RotateDatabasePasswordAction::make())
|
||||
->suffixAction(fn (string $state) => request()->isSecure() ? CopyAction::make()->copyable($state) : null)
|
||||
->formatStateUsing(fn (Database $database) => $database->password),
|
||||
TextInput::make('remote')
|
||||
->disabled()
|
||||
->formatStateUsing(fn (Database $record) => $record->remote === '%' ? 'Anywhere ( % )' : $record->remote)
|
||||
->columnSpan(1)
|
||||
->label(trans('admin/databasehost.table.remote')),
|
||||
TextInput::make('max_connections')
|
||||
->label(trans('admin/databasehost.table.max_connections'))
|
||||
->disabled()
|
||||
->formatStateUsing(fn (Database $record) => $record->max_connections === 0 ? 'Unlimited' : $record->max_connections)
|
||||
->columnSpan(1),
|
||||
TextInput::make('jdbc')
|
||||
->disabled()
|
||||
->password()
|
||||
->revealable()
|
||||
->label(trans('admin/databasehost.table.connection_string'))
|
||||
->columnSpan(2)
|
||||
->formatStateUsing(fn (Database $record) => $record->jdbc)
|
||||
->suffixAction(fn (string $state) => request()->isSecure() ? CopyAction::make()->copyable($state) : null),
|
||||
])
|
||||
->relationship('databases')
|
||||
->deletable(false)
|
||||
->addable(false)
|
||||
->columnSpan(4),
|
||||
FormActions::make([
|
||||
Action::make('createDatabase')
|
||||
->authorize(fn () => auth()->user()->can('create', Database::class))
|
||||
->disabled(fn () => DatabaseHost::query()->count() < 1)
|
||||
->label(fn () => DatabaseHost::query()->count() < 1 ? trans('admin/server.no_db_hosts') : trans('admin/server.create_database'))
|
||||
->color(fn () => DatabaseHost::query()->count() < 1 ? 'danger' : 'primary')
|
||||
->modalSubmitActionLabel(trans('admin/server.create_database'))
|
||||
->action(function (array $data, DatabaseManagementService $service, Server $server, RandomWordService $randomWordService) {
|
||||
if (empty($data['database'])) {
|
||||
$data['database'] = $randomWordService->word() . random_int(1, 420);
|
||||
}
|
||||
if (empty($data['remote'])) {
|
||||
$data['remote'] = '%';
|
||||
}
|
||||
|
||||
$data['database'] = $service->generateUniqueDatabaseName($data['database'], $server->id);
|
||||
|
||||
try {
|
||||
$service->setValidateDatabaseLimit(false)->create($server, $data);
|
||||
} catch (Exception $e) {
|
||||
Notification::make()
|
||||
->title(trans('admin/server.failed_to_create'))
|
||||
->body($e->getMessage())
|
||||
->danger()
|
||||
->persistent()->send();
|
||||
}
|
||||
$this->fillForm();
|
||||
})
|
||||
->form([
|
||||
Select::make('database_host_id')
|
||||
->label(trans('admin/databasehost.table.name'))
|
||||
->required()
|
||||
->placeholder('Select Database Host')
|
||||
->options(fn (Server $server) => DatabaseHost::query()
|
||||
->whereHas('nodes', fn ($query) => $query->where('nodes.id', $server->node_id))
|
||||
->pluck('name', 'id')
|
||||
)
|
||||
->default(fn () => (DatabaseHost::query()->first())?->id)
|
||||
->selectablePlaceholder(false),
|
||||
TextInput::make('database')
|
||||
->label(trans('admin/server.name'))
|
||||
->alphaDash()
|
||||
->prefix(fn (Server $server) => 's' . $server->id . '_')
|
||||
->hintIcon('tabler-question-mark')
|
||||
->hintIconTooltip(trans('admin/databasehost.table.name_helper')),
|
||||
TextInput::make('remote')
|
||||
->columnSpan(1)
|
||||
->regex('/^[\w\-\/.%:]+$/')
|
||||
->label(trans('admin/databasehost.table.remote'))
|
||||
->hintIcon('tabler-question-mark')
|
||||
->hintIconTooltip(trans('admin/databasehost.table.remote_helper')),
|
||||
]),
|
||||
])->alignCenter()->columnSpanFull(),
|
||||
]),
|
||||
Tab::make(trans('admin/server.actions'))
|
||||
Tab::make('actions')
|
||||
->label(trans('admin/server.actions'))
|
||||
->icon('tabler-settings')
|
||||
->schema([
|
||||
Fieldset::make(trans('admin/server.actions'))
|
||||
->columnSpanFull()
|
||||
->columns([
|
||||
'default' => 1,
|
||||
'sm' => 2,
|
||||
@@ -835,7 +675,7 @@ class EditServer extends EditRecord
|
||||
Grid::make()
|
||||
->columnSpan(3)
|
||||
->schema([
|
||||
FormActions::make([
|
||||
Actions::make([
|
||||
Action::make('toggleInstall')
|
||||
->label(trans('admin/server.toggle_install'))
|
||||
->disabled(fn (Server $server) => $server->isSuspended())
|
||||
@@ -853,7 +693,6 @@ class EditServer extends EditRecord
|
||||
->success()
|
||||
->send();
|
||||
|
||||
$this->refreshFormData(['status', 'docker']);
|
||||
} catch (Exception) {
|
||||
Notification::make()
|
||||
->title(trans('admin/server.notifications.reinstall_failed'))
|
||||
@@ -870,7 +709,6 @@ class EditServer extends EditRecord
|
||||
->success()
|
||||
->send();
|
||||
|
||||
$this->refreshFormData(['status', 'docker']);
|
||||
} catch (Exception $exception) {
|
||||
Notification::make()
|
||||
->title(trans('admin/server.notifications.install_toggle_failed'))
|
||||
@@ -881,13 +719,14 @@ class EditServer extends EditRecord
|
||||
}
|
||||
}),
|
||||
])->fullWidth(),
|
||||
ToggleButtons::make('')
|
||||
ToggleButtons::make('install_help')
|
||||
->hiddenLabel()
|
||||
->hint(trans('admin/server.toggle_install_help')),
|
||||
]),
|
||||
Grid::make()
|
||||
->columnSpan(3)
|
||||
->schema([
|
||||
FormActions::make([
|
||||
Actions::make([
|
||||
Action::make('toggleSuspend')
|
||||
->label(trans('admin/server.suspend'))
|
||||
->color('warning')
|
||||
@@ -901,7 +740,6 @@ class EditServer extends EditRecord
|
||||
->title(trans('admin/server.notifications.server_suspended'))
|
||||
->send();
|
||||
|
||||
$this->refreshFormData(['status', 'docker']);
|
||||
} catch (Exception) {
|
||||
Notification::make()
|
||||
->warning()
|
||||
@@ -923,7 +761,6 @@ class EditServer extends EditRecord
|
||||
->title(trans('admin/server.notifications.server_unsuspended'))
|
||||
->send();
|
||||
|
||||
$this->refreshFormData(['status', 'docker']);
|
||||
} catch (Exception) {
|
||||
Notification::make()
|
||||
->warning()
|
||||
@@ -933,46 +770,49 @@ class EditServer extends EditRecord
|
||||
}
|
||||
}),
|
||||
])->fullWidth(),
|
||||
ToggleButtons::make('')
|
||||
ToggleButtons::make('server_suspend')
|
||||
->hiddenLabel()
|
||||
->hidden(fn (Server $server) => $server->isSuspended())
|
||||
->hint(trans('admin/server.notifications.server_suspend_help')),
|
||||
ToggleButtons::make('')
|
||||
ToggleButtons::make('server_unsuspend')
|
||||
->hiddenLabel()
|
||||
->hidden(fn (Server $server) => !$server->isSuspended())
|
||||
->hint(trans('admin/server.notifications.server_unsuspend_help')),
|
||||
]),
|
||||
Grid::make()
|
||||
->columnSpan(3)
|
||||
->schema([
|
||||
FormActions::make([
|
||||
Actions::make([
|
||||
Action::make('transfer')
|
||||
->label(trans('admin/server.transfer'))
|
||||
->disabled(fn (Server $server) => Node::count() <= 1 || $server->isInConflictState())
|
||||
->modalheading(trans('admin/server.transfer'))
|
||||
->form($this->transferServer())
|
||||
->modalHeading(trans('admin/server.transfer'))
|
||||
->schema($this->transferServer())
|
||||
->action(function (TransferServerService $transfer, Server $server, $data) {
|
||||
try {
|
||||
$transfer->handle($server, Arr::get($data, 'node_id'), Arr::get($data, 'allocation_id'), Arr::get($data, 'allocation_additional', []));
|
||||
|
||||
Notification::make()
|
||||
->title('Transfer started')
|
||||
->title(trans('admin/server.notifications.transfer_started'))
|
||||
->success()
|
||||
->send();
|
||||
} catch (Exception $exception) {
|
||||
Notification::make()
|
||||
->title('Transfer failed')
|
||||
->title(trans('admin/server.notifications.transfer_failed'))
|
||||
->body($exception->getMessage())
|
||||
->danger()
|
||||
->send();
|
||||
}
|
||||
}),
|
||||
])->fullWidth(),
|
||||
ToggleButtons::make('')
|
||||
ToggleButtons::make('server_transfer')
|
||||
->hiddenLabel()
|
||||
->hint(new HtmlString(trans('admin/server.transfer_help'))),
|
||||
]),
|
||||
Grid::make()
|
||||
->columnSpan(3)
|
||||
->schema([
|
||||
FormActions::make([
|
||||
Actions::make([
|
||||
Action::make('reinstall')
|
||||
->label(trans('admin/server.reinstall'))
|
||||
->color('danger')
|
||||
@@ -988,8 +828,6 @@ class EditServer extends EditRecord
|
||||
->title(trans('admin/server.notifications.reinstall_started'))
|
||||
->success()
|
||||
->send();
|
||||
|
||||
$this->refreshFormData(['status', 'docker']);
|
||||
} catch (Exception) {
|
||||
Notification::make()
|
||||
->title(trans('admin/server.notifications.reinstall_failed'))
|
||||
@@ -999,7 +837,8 @@ class EditServer extends EditRecord
|
||||
}
|
||||
}),
|
||||
])->fullWidth(),
|
||||
ToggleButtons::make('')
|
||||
ToggleButtons::make('server_reinstall')
|
||||
->hiddenLabel()
|
||||
->hint(trans('admin/server.reinstall_help')),
|
||||
]),
|
||||
]),
|
||||
@@ -1008,7 +847,9 @@ class EditServer extends EditRecord
|
||||
]);
|
||||
}
|
||||
|
||||
/** @return Component[] */
|
||||
/** @return Component[]
|
||||
* @throws Exception
|
||||
*/
|
||||
protected function transferServer(): array
|
||||
{
|
||||
return [
|
||||
@@ -1042,7 +883,7 @@ class EditServer extends EditRecord
|
||||
];
|
||||
}
|
||||
|
||||
/** @return array<Actions\Action|Actions\ActionGroup> */
|
||||
/** @return array<Action|ActionGroup> */
|
||||
protected function getDefaultHeaderActions(): array
|
||||
{
|
||||
/** @var Server $server */
|
||||
@@ -1051,7 +892,7 @@ class EditServer extends EditRecord
|
||||
$canForceDelete = cache()->get("servers.$server->uuid.canForceDelete", false);
|
||||
|
||||
return [
|
||||
Actions\Action::make('Delete')
|
||||
Action::make('Delete')
|
||||
->color('danger')
|
||||
->label(trans('filament-actions::delete.single.label'))
|
||||
->modalHeading(trans('filament-actions::delete.single.modal.heading', ['label' => $this->getRecordTitle()]))
|
||||
@@ -1065,7 +906,7 @@ class EditServer extends EditRecord
|
||||
} catch (ConnectionException) {
|
||||
cache()->put("servers.$server->uuid.canForceDelete", true, now()->addMinutes(5));
|
||||
|
||||
Notification::make()
|
||||
return Notification::make()
|
||||
->title(trans('admin/server.notifications.error_server_delete'))
|
||||
->body(trans('admin/server.notifications.error_server_delete_body'))
|
||||
->color('warning')
|
||||
@@ -1075,8 +916,8 @@ class EditServer extends EditRecord
|
||||
}
|
||||
})
|
||||
->hidden(fn () => $canForceDelete)
|
||||
->authorize(fn (Server $server) => auth()->user()->can('delete', $server)),
|
||||
Actions\Action::make('ForceDelete')
|
||||
->authorize(fn (Server $server) => auth()->user()->can('delete server', $server)),
|
||||
Action::make('ForceDelete')
|
||||
->color('danger')
|
||||
->label(trans('filament-actions::force-delete.single.label'))
|
||||
->modalHeading(trans('filament-actions::force-delete.single.modal.heading', ['label' => $this->getRecordTitle()]))
|
||||
@@ -1088,12 +929,12 @@ class EditServer extends EditRecord
|
||||
|
||||
return redirect(ListServers::getUrl(panel: 'admin'));
|
||||
} catch (ConnectionException) {
|
||||
cache()->forget("servers.$server->uuid.canForceDelete");
|
||||
return cache()->forget("servers.$server->uuid.canForceDelete");
|
||||
}
|
||||
})
|
||||
->visible(fn () => $canForceDelete)
|
||||
->authorize(fn (Server $server) => auth()->user()->can('delete', $server)),
|
||||
Actions\Action::make('console')
|
||||
->authorize(fn (Server $server) => auth()->user()->can('delete server', $server)),
|
||||
Action::make('console')
|
||||
->label(trans('admin/server.console'))
|
||||
->icon('tabler-terminal')
|
||||
->url(fn (Server $server) => Console::getUrl(panel: 'server', tenant: $server)),
|
||||
@@ -1146,33 +987,11 @@ class EditServer extends EditRecord
|
||||
return null;
|
||||
}
|
||||
|
||||
private function shouldHideComponent(ServerVariable $serverVariable, Forms\Components\Component $component): bool
|
||||
public function getRelationManagers(): array
|
||||
{
|
||||
$containsRuleIn = array_first($serverVariable->variable->rules, fn ($value) => str($value)->startsWith('in:'), false);
|
||||
|
||||
if ($component instanceof Select) {
|
||||
return !$containsRuleIn;
|
||||
}
|
||||
|
||||
if ($component instanceof TextInput) {
|
||||
return $containsRuleIn;
|
||||
}
|
||||
|
||||
throw new Exception('Component type not supported: ' . $component::class);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array<string, string>
|
||||
*/
|
||||
private function getSelectOptionsFromRules(ServerVariable $serverVariable): array
|
||||
{
|
||||
$inRule = array_first($serverVariable->variable->rules, fn ($value) => str($value)->startsWith('in:'));
|
||||
|
||||
return str($inRule)
|
||||
->after('in:')
|
||||
->explode(',')
|
||||
->each(fn ($value) => str($value)->trim())
|
||||
->mapWithKeys(fn ($value) => [$value => $value])
|
||||
->all();
|
||||
return [
|
||||
AllocationsRelationManager::class,
|
||||
DatabasesRelationManager::class,
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -1,17 +1,17 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Admin\Resources\ServerResource\Pages;
|
||||
namespace App\Filament\Admin\Resources\Servers\Pages;
|
||||
|
||||
use App\Filament\Admin\Resources\Servers\ServerResource;
|
||||
use App\Filament\Server\Pages\Console;
|
||||
use App\Filament\Admin\Resources\ServerResource;
|
||||
use App\Models\Server;
|
||||
use App\Traits\Filament\CanCustomizeHeaderActions;
|
||||
use App\Traits\Filament\CanCustomizeHeaderWidgets;
|
||||
use Filament\Actions;
|
||||
use Filament\Actions\Action;
|
||||
use Filament\Actions\ActionGroup;
|
||||
use Filament\Actions\CreateAction;
|
||||
use Filament\Actions\EditAction;
|
||||
use Filament\Resources\Pages\ListRecords;
|
||||
use Filament\Tables\Actions\Action;
|
||||
use Filament\Tables\Actions\CreateAction;
|
||||
use Filament\Tables\Actions\EditAction;
|
||||
use Filament\Tables\Columns\SelectColumn;
|
||||
use Filament\Tables\Columns\TextColumn;
|
||||
use Filament\Tables\Grouping\Group;
|
||||
@@ -47,27 +47,23 @@ class ListServers extends ListRecords
|
||||
->searchable(),
|
||||
TextColumn::make('name')
|
||||
->label(trans('admin/server.name'))
|
||||
->icon('tabler-brand-docker')
|
||||
->searchable()
|
||||
->sortable(),
|
||||
TextColumn::make('node.name')
|
||||
->label(trans('admin/server.node'))
|
||||
->icon('tabler-server-2')
|
||||
->url(fn (Server $server): string => route('filament.admin.resources.nodes.edit', ['record' => $server->node]))
|
||||
->url(fn (Server $server) => route('filament.admin.resources.nodes.edit', ['record' => $server->node]))
|
||||
->hidden(fn (Table $table) => $table->getGrouping()?->getId() === 'node.name')
|
||||
->sortable()
|
||||
->searchable(),
|
||||
TextColumn::make('egg.name')
|
||||
->icon('tabler-egg')
|
||||
->label(trans('admin/server.egg'))
|
||||
->url(fn (Server $server): string => route('filament.admin.resources.eggs.edit', ['record' => $server->egg]))
|
||||
->url(fn (Server $server) => route('filament.admin.resources.eggs.edit', ['record' => $server->egg]))
|
||||
->hidden(fn (Table $table) => $table->getGrouping()?->getId() === 'egg.name')
|
||||
->sortable()
|
||||
->searchable(),
|
||||
TextColumn::make('user.username')
|
||||
->icon('tabler-user')
|
||||
->label(trans('admin/user.username'))
|
||||
->url(fn (Server $server): string => route('filament.admin.resources.users.edit', ['record' => $server->user]))
|
||||
->url(fn (Server $server) => route('filament.admin.resources.users.edit', ['record' => $server->user]))
|
||||
->hidden(fn (Table $table) => $table->getGrouping()?->getId() === 'user.username')
|
||||
->sortable()
|
||||
->searchable(),
|
||||
@@ -77,25 +73,22 @@ class ListServers extends ListRecords
|
||||
->disabled(fn (Server $server) => $server->allocations->count() <= 1)
|
||||
->options(fn (Server $server) => $server->allocations->mapWithKeys(fn ($allocation) => [$allocation->id => $allocation->address]))
|
||||
->selectablePlaceholder(fn (Server $server) => $server->allocations->count() <= 1)
|
||||
->placeholder('None')
|
||||
->placeholder(trans('admin/server.none'))
|
||||
->sortable(),
|
||||
TextColumn::make('allocation_id_readonly')
|
||||
->label(trans('admin/server.primary_allocation'))
|
||||
->hidden(fn () => auth()->user()->can('update server')) // TODO: update to policy check (fn (Server $server) --> $server is empty)
|
||||
->disabled(fn (Server $server) => $server->allocations->count() <= 1)
|
||||
->state(fn (Server $server) => $server->allocation->address ?? 'None'),
|
||||
->state(fn (Server $server) => $server->allocation->address ?? trans('admin/server.none')),
|
||||
TextColumn::make('image')->hidden(),
|
||||
TextColumn::make('backups_count')
|
||||
->counts('backups')
|
||||
->label(trans('admin/server.backups'))
|
||||
->icon('tabler-file-download')
|
||||
->numeric()
|
||||
->sortable(),
|
||||
])
|
||||
->actions([
|
||||
->recordActions([
|
||||
Action::make('View')
|
||||
->label(trans('admin/server.view'))
|
||||
->icon('tabler-terminal')
|
||||
->url(fn (Server $server) => Console::getUrl(panel: 'server', tenant: $server))
|
||||
->authorize(fn (Server $server) => auth()->user()->canAccessTenant($server)),
|
||||
EditAction::make(),
|
||||
@@ -109,11 +102,11 @@ class ListServers extends ListRecords
|
||||
]);
|
||||
}
|
||||
|
||||
/** @return array<Actions\Action|Actions\ActionGroup> */
|
||||
/** @return array<Action|ActionGroup> */
|
||||
protected function getDefaultHeaderActions(): array
|
||||
{
|
||||
return [
|
||||
Actions\CreateAction::make()
|
||||
CreateAction::make()
|
||||
->hidden(fn () => Server::count() <= 0),
|
||||
];
|
||||
}
|
||||
@@ -1,21 +1,22 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Admin\Resources\ServerResource\RelationManagers;
|
||||
namespace App\Filament\Admin\Resources\Servers\RelationManagers;
|
||||
|
||||
use App\Filament\Admin\Resources\ServerResource\Pages\CreateServer;
|
||||
use App\Filament\Admin\Resources\Servers\Pages\CreateServer;
|
||||
use App\Models\Allocation;
|
||||
use App\Models\Server;
|
||||
use App\Services\Allocations\AssignmentService;
|
||||
use Filament\Actions\Action;
|
||||
use Filament\Actions\AssociateAction;
|
||||
use Filament\Actions\CreateAction;
|
||||
use Filament\Actions\DissociateAction;
|
||||
use Filament\Actions\DissociateBulkAction;
|
||||
use Filament\Forms\Components\Select;
|
||||
use Filament\Forms\Components\TagsInput;
|
||||
use Filament\Forms\Components\TextInput;
|
||||
use Filament\Forms\Get;
|
||||
use Filament\Forms\Set;
|
||||
use Filament\Resources\RelationManagers\RelationManager;
|
||||
use Filament\Tables\Actions\AssociateAction;
|
||||
use Filament\Tables\Actions\CreateAction;
|
||||
use Filament\Tables\Actions\DissociateAction;
|
||||
use Filament\Tables\Actions\DissociateBulkAction;
|
||||
use Filament\Schemas\Components\Utilities\Get;
|
||||
use Filament\Schemas\Components\Utilities\Set;
|
||||
use Filament\Tables\Columns\IconColumn;
|
||||
use Filament\Tables\Columns\TextColumn;
|
||||
use Filament\Tables\Columns\TextInputColumn;
|
||||
@@ -60,7 +61,11 @@ class AllocationsRelationManager extends RelationManager
|
||||
->default(fn (Allocation $allocation) => $allocation->id === $this->getOwnerRecord()->allocation_id)
|
||||
->label(trans('admin/server.primary')),
|
||||
])
|
||||
->actions([
|
||||
->recordActions([
|
||||
Action::make('make-primary')
|
||||
->label(trans('admin/server.make_primary'))
|
||||
->action(fn (Allocation $allocation) => $this->getOwnerRecord()->update(['allocation_id' => $allocation->id]) && $this->deselectAllTableRecords())
|
||||
->hidden(fn (Allocation $allocation) => $allocation->id === $this->getOwnerRecord()->allocation_id),
|
||||
DissociateAction::make()
|
||||
->after(function (Allocation $allocation) {
|
||||
$allocation->update(['notes' => null]);
|
||||
@@ -70,13 +75,22 @@ class AllocationsRelationManager extends RelationManager
|
||||
->headerActions([
|
||||
CreateAction::make()->label(trans('admin/server.create_allocation'))
|
||||
->createAnother(false)
|
||||
->form(fn () => [
|
||||
->schema(fn () => [
|
||||
Select::make('allocation_ip')
|
||||
->options(collect($this->getOwnerRecord()->node->ipAddresses())->mapWithKeys(fn (string $ip) => [$ip => $ip]))
|
||||
->options(fn () => collect($this->getOwnerRecord()->node->ipAddresses())->mapWithKeys(fn (string $ip) => [$ip => $ip]))
|
||||
->label(trans('admin/server.ip_address'))
|
||||
->inlineLabel()
|
||||
->ip()
|
||||
->live()
|
||||
->hintAction(
|
||||
Action::make('refresh')
|
||||
->iconButton()
|
||||
->icon('tabler-refresh')
|
||||
->tooltip(trans('admin/node.refresh'))
|
||||
->action(function () {
|
||||
cache()->forget("nodes.{$this->getOwnerRecord()->node->id}.ips");
|
||||
})
|
||||
)
|
||||
->afterStateUpdated(fn (Set $set) => $set('allocation_ports', []))
|
||||
->required(),
|
||||
TextInput::make('allocation_alias')
|
||||
@@ -0,0 +1,150 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Admin\Resources\Servers\RelationManagers;
|
||||
|
||||
use App\Filament\Components\Actions\RotateDatabasePasswordAction;
|
||||
use App\Filament\Components\Tables\Columns\DateTimeColumn;
|
||||
use App\Models\Database;
|
||||
use App\Models\DatabaseHost;
|
||||
use App\Models\Server;
|
||||
use App\Services\Databases\DatabaseManagementService;
|
||||
use App\Services\Servers\RandomWordService;
|
||||
use Exception;
|
||||
use Filament\Actions\CreateAction;
|
||||
use Filament\Actions\DeleteAction;
|
||||
use Filament\Actions\ViewAction;
|
||||
use Filament\Forms\Components\Select;
|
||||
use Filament\Forms\Components\TextInput;
|
||||
use Filament\Notifications\Notification;
|
||||
use Filament\Resources\RelationManagers\RelationManager;
|
||||
use Filament\Schemas\Schema;
|
||||
use Filament\Support\Exceptions\Halt;
|
||||
use Filament\Tables\Columns\TextColumn;
|
||||
use Filament\Tables\Table;
|
||||
|
||||
/**
|
||||
* @method Server getOwnerRecord()
|
||||
*/
|
||||
class DatabasesRelationManager extends RelationManager
|
||||
{
|
||||
protected static string $relationship = 'databases';
|
||||
|
||||
public function form(Schema $schema): Schema
|
||||
{
|
||||
return $schema
|
||||
->components([
|
||||
TextInput::make('database')
|
||||
->columnSpanFull(),
|
||||
TextInput::make('username')
|
||||
->label(trans('admin/databasehost.table.username')),
|
||||
TextInput::make('password')
|
||||
->label(trans('admin/databasehost.table.password'))
|
||||
->password()
|
||||
->revealable()
|
||||
->hintAction(RotateDatabasePasswordAction::make())
|
||||
->formatStateUsing(fn (Database $database) => $database->password),
|
||||
TextInput::make('remote')
|
||||
->label(trans('admin/databasehost.table.remote'))
|
||||
->formatStateUsing(fn (Database $record) => $record->remote === '%' ? trans('admin/databasehost.anywhere'). ' ( % )' : $record->remote),
|
||||
TextInput::make('max_connections')
|
||||
->label(trans('admin/databasehost.table.max_connections'))
|
||||
->formatStateUsing(fn (Database $record) => $record->max_connections === 0 ? trans('admin/databasehost.unlimited') : $record->max_connections),
|
||||
TextInput::make('jdbc')
|
||||
->label(trans('admin/databasehost.table.connection_string'))
|
||||
->columnSpanFull()
|
||||
->password()
|
||||
->revealable()
|
||||
->formatStateUsing(fn (Database $database) => $database->jdbc),
|
||||
]);
|
||||
}
|
||||
|
||||
public function table(Table $table): Table
|
||||
{
|
||||
return $table
|
||||
->recordTitleAttribute('database')
|
||||
->columns([
|
||||
TextColumn::make('database'),
|
||||
TextColumn::make('username')
|
||||
->label(trans('admin/databasehost.table.username')),
|
||||
TextColumn::make('remote')
|
||||
->label(trans('admin/databasehost.table.remote'))
|
||||
->formatStateUsing(fn (Database $record) => $record->remote === '%' ? trans('admin/databasehost.anywhere'). ' ( % )' : $record->remote),
|
||||
TextColumn::make('server.name')
|
||||
->url(fn (Database $database) => route('filament.admin.resources.servers.edit', ['record' => $database->server_id])),
|
||||
TextColumn::make('max_connections')
|
||||
->label(trans('admin/databasehost.table.max_connections'))
|
||||
->formatStateUsing(fn ($record) => $record->max_connections === 0 ? trans('admin/databasehost.unlimited') : $record->max_connections),
|
||||
DateTimeColumn::make('created_at')
|
||||
->label(trans('admin/databasehost.table.created_at')),
|
||||
])
|
||||
->recordActions([
|
||||
ViewAction::make()
|
||||
->color('primary'),
|
||||
DeleteAction::make()
|
||||
->using(function (Database $database, DatabaseManagementService $service) {
|
||||
try {
|
||||
$service->delete($database);
|
||||
|
||||
Notification::make()
|
||||
->title(trans('server/database.delete_notification', ['database' => $database->database]))
|
||||
->success()
|
||||
->send();
|
||||
} catch (Exception $exception) {
|
||||
Notification::make()
|
||||
->title(trans('server/database.delete_notification_fail', ['database' => $database->database]))
|
||||
->danger()
|
||||
->send();
|
||||
|
||||
report($exception);
|
||||
}
|
||||
}),
|
||||
])
|
||||
->headerActions([
|
||||
CreateAction::make()
|
||||
->disabled(fn () => DatabaseHost::count() < 1)
|
||||
->label(fn () => DatabaseHost::count() < 1 ? trans('admin/server.no_db_hosts') : trans('admin/server.create_database'))
|
||||
->color(fn () => DatabaseHost::count() < 1 ? 'danger' : 'primary')
|
||||
->createAnother(false)
|
||||
->action(function (array $data, DatabaseManagementService $service, RandomWordService $randomWordService) {
|
||||
$data['database'] ??= $randomWordService->word() . random_int(1, 420);
|
||||
$data['remote'] ??= '%';
|
||||
|
||||
$data['database'] = $service->generateUniqueDatabaseName($data['database'], $this->getOwnerRecord()->id);
|
||||
|
||||
try {
|
||||
return $service->setValidateDatabaseLimit(false)->create($this->getOwnerRecord(), $data);
|
||||
} catch (Exception $exception) {
|
||||
Notification::make()
|
||||
->title(trans('admin/server.failed_to_create'))
|
||||
->body($exception->getMessage())
|
||||
->danger()
|
||||
->persistent()->send();
|
||||
|
||||
throw new Halt();
|
||||
}
|
||||
})
|
||||
->schema([
|
||||
Select::make('database_host_id')
|
||||
->label(trans('admin/databasehost.model_label'))
|
||||
->required()
|
||||
->options(fn () => DatabaseHost::query()
|
||||
->whereHas('nodes', fn ($query) => $query->where('nodes.id', $this->getOwnerRecord()->node_id))
|
||||
->pluck('name', 'id')
|
||||
)
|
||||
->selectablePlaceholder(false)
|
||||
->default(fn () => (DatabaseHost::query()->first())?->id),
|
||||
TextInput::make('database')
|
||||
->label(trans('admin/server.name'))
|
||||
->alphaDash()
|
||||
->prefix(fn () => 's' . $this->getOwnerRecord()->id . '_')
|
||||
->hintIcon('tabler-question-mark', trans('admin/databasehost.table.name_helper')),
|
||||
TextInput::make('remote')
|
||||
->columnSpan(1)
|
||||
->regex('/^[\w\-\/.%:]+$/')
|
||||
->label(trans('admin/databasehost.table.remote'))
|
||||
->default('%')
|
||||
->hintIcon('tabler-question-mark', trans('admin/databasehost.table.remote_helper')),
|
||||
]),
|
||||
]);
|
||||
}
|
||||
}
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user