mirror of
https://github.com/pelican-dev/panel.git
synced 2025-09-08 23:08:37 +02:00
Merge remote-tracking branch 'upstream/main' into filament-v4
This commit is contained in:
commit
8a8e3c5369
@ -23,7 +23,6 @@ use Illuminate\Support\Str;
|
|||||||
* \App\Models\ActivityLog.
|
* \App\Models\ActivityLog.
|
||||||
*
|
*
|
||||||
* @property int $id
|
* @property int $id
|
||||||
* @property string|null $batch
|
|
||||||
* @property string $event
|
* @property string $event
|
||||||
* @property string $ip
|
* @property string $ip
|
||||||
* @property string|null $description
|
* @property string|null $description
|
||||||
@ -45,7 +44,6 @@ use Illuminate\Support\Str;
|
|||||||
* @method static Builder|ActivityLog whereActorId($value)
|
* @method static Builder|ActivityLog whereActorId($value)
|
||||||
* @method static Builder|ActivityLog whereActorType($value)
|
* @method static Builder|ActivityLog whereActorType($value)
|
||||||
* @method static Builder|ActivityLog whereApiKeyId($value)
|
* @method static Builder|ActivityLog whereApiKeyId($value)
|
||||||
* @method static Builder|ActivityLog whereBatch($value)
|
|
||||||
* @method static Builder|ActivityLog whereDescription($value)
|
* @method static Builder|ActivityLog whereDescription($value)
|
||||||
* @method static Builder|ActivityLog whereEvent($value)
|
* @method static Builder|ActivityLog whereEvent($value)
|
||||||
* @method static Builder|ActivityLog whereId($value)
|
* @method static Builder|ActivityLog whereId($value)
|
||||||
@ -78,7 +76,6 @@ class ActivityLog extends Model implements HasIcon, HasLabel
|
|||||||
/** @var array<array-key, string[]> */
|
/** @var array<array-key, string[]> */
|
||||||
public static array $validationRules = [
|
public static array $validationRules = [
|
||||||
'event' => ['required', 'string'],
|
'event' => ['required', 'string'],
|
||||||
'batch' => ['nullable', 'uuid'],
|
|
||||||
'ip' => ['required', 'string'],
|
'ip' => ['required', 'string'],
|
||||||
'description' => ['nullable', 'string'],
|
'description' => ['nullable', 'string'],
|
||||||
'properties' => ['array'],
|
'properties' => ['array'],
|
||||||
|
@ -219,7 +219,7 @@ class ApiKey extends PersonalAccessToken
|
|||||||
{
|
{
|
||||||
Assert::oneOf($type, [self::TYPE_ACCOUNT, self::TYPE_APPLICATION]);
|
Assert::oneOf($type, [self::TYPE_ACCOUNT, self::TYPE_APPLICATION]);
|
||||||
|
|
||||||
return $type === self::TYPE_ACCOUNT ? 'plcn_' : 'peli_';
|
return $type === self::TYPE_ACCOUNT ? 'pacc_' : 'papp_';
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -3,7 +3,6 @@
|
|||||||
namespace App\Providers;
|
namespace App\Providers;
|
||||||
|
|
||||||
use Illuminate\Support\ServiceProvider;
|
use Illuminate\Support\ServiceProvider;
|
||||||
use App\Services\Activity\ActivityLogBatchService;
|
|
||||||
use App\Services\Activity\ActivityLogTargetableService;
|
use App\Services\Activity\ActivityLogTargetableService;
|
||||||
|
|
||||||
class ActivityLogServiceProvider extends ServiceProvider
|
class ActivityLogServiceProvider extends ServiceProvider
|
||||||
@ -14,7 +13,6 @@ class ActivityLogServiceProvider extends ServiceProvider
|
|||||||
*/
|
*/
|
||||||
public function register(): void
|
public function register(): void
|
||||||
{
|
{
|
||||||
$this->app->scoped(ActivityLogBatchService::class);
|
|
||||||
$this->app->scoped(ActivityLogTargetableService::class);
|
$this->app->scoped(ActivityLogTargetableService::class);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,61 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
namespace App\Services\Activity;
|
|
||||||
|
|
||||||
use Closure;
|
|
||||||
use Ramsey\Uuid\Uuid;
|
|
||||||
|
|
||||||
class ActivityLogBatchService
|
|
||||||
{
|
|
||||||
protected int $transaction = 0;
|
|
||||||
|
|
||||||
protected ?string $uuid = null;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Returns the UUID of the batch, or null if there is not a batch currently
|
|
||||||
* being executed.
|
|
||||||
*/
|
|
||||||
public function uuid(): ?string
|
|
||||||
{
|
|
||||||
return $this->uuid;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Starts a new batch transaction. If there is already a transaction present
|
|
||||||
* this will be nested.
|
|
||||||
*/
|
|
||||||
public function start(): void
|
|
||||||
{
|
|
||||||
if ($this->transaction === 0) {
|
|
||||||
$this->uuid = Uuid::uuid4()->toString();
|
|
||||||
}
|
|
||||||
|
|
||||||
$this->transaction++;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Ends a batch transaction, if this is the last transaction in the stack
|
|
||||||
* the UUID will be cleared out.
|
|
||||||
*/
|
|
||||||
public function end(): void
|
|
||||||
{
|
|
||||||
$this->transaction = max(0, $this->transaction - 1);
|
|
||||||
|
|
||||||
if ($this->transaction === 0) {
|
|
||||||
$this->uuid = null;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Executes the logic provided within the callback in the scope of an activity
|
|
||||||
* log batch transaction.
|
|
||||||
*/
|
|
||||||
public function transaction(Closure $callback): mixed
|
|
||||||
{
|
|
||||||
$this->start();
|
|
||||||
$result = $callback($this->uuid());
|
|
||||||
$this->end();
|
|
||||||
|
|
||||||
return $result;
|
|
||||||
}
|
|
||||||
}
|
|
@ -25,7 +25,6 @@ class ActivityLogService
|
|||||||
|
|
||||||
public function __construct(
|
public function __construct(
|
||||||
protected AuthFactory $manager,
|
protected AuthFactory $manager,
|
||||||
protected ActivityLogBatchService $batch,
|
|
||||||
protected ActivityLogTargetableService $targetable,
|
protected ActivityLogTargetableService $targetable,
|
||||||
protected ConnectionInterface $connection
|
protected ConnectionInterface $connection
|
||||||
) {}
|
) {}
|
||||||
@ -202,7 +201,6 @@ class ActivityLogService
|
|||||||
|
|
||||||
$this->activity = new ActivityLog([
|
$this->activity = new ActivityLog([
|
||||||
'ip' => Request::ip(),
|
'ip' => Request::ip(),
|
||||||
'batch_uuid' => $this->batch->uuid(),
|
|
||||||
'properties' => Collection::make([]),
|
'properties' => Collection::make([]),
|
||||||
'api_key_id' => $this->targetable->apiKeyId(),
|
'api_key_id' => $this->targetable->apiKeyId(),
|
||||||
]);
|
]);
|
||||||
|
@ -50,7 +50,7 @@ class NodeAutoDeployService
|
|||||||
|
|
||||||
return sprintf(
|
return sprintf(
|
||||||
'%s wings configure --panel-url %s --token %s --node %d%s',
|
'%s wings configure --panel-url %s --token %s --node %d%s',
|
||||||
$docker ? 'docker compose exec -it' : 'sudo',
|
$docker ? 'docker compose exec -it $(docker ps --filter "name=wings" --format "{{.Names}}")' : 'sudo',
|
||||||
config('app.url'),
|
config('app.url'),
|
||||||
$token,
|
$token,
|
||||||
$node->id,
|
$node->id,
|
||||||
|
@ -26,7 +26,6 @@ class ActivityLogTransformer extends BaseClientTransformer
|
|||||||
// the front-end for each entry to improve rendering performance since there
|
// the front-end for each entry to improve rendering performance since there
|
||||||
// is nothing else sufficiently unique to key off at this point.
|
// is nothing else sufficiently unique to key off at this point.
|
||||||
'id' => sha1((string) $model->id),
|
'id' => sha1((string) $model->id),
|
||||||
'batch' => $model->batch,
|
|
||||||
'event' => $model->event,
|
'event' => $model->event,
|
||||||
'is_api' => !is_null($model->api_key_id),
|
'is_api' => !is_null($model->api_key_id),
|
||||||
'ip' => $this->canViewIP($model->actor) ? $model->ip : null,
|
'ip' => $this->canViewIP($model->actor) ? $model->ip : null,
|
||||||
|
@ -0,0 +1,28 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
use Illuminate\Database\Migrations\Migration;
|
||||||
|
use Illuminate\Database\Schema\Blueprint;
|
||||||
|
use Illuminate\Support\Facades\Schema;
|
||||||
|
|
||||||
|
return new class extends Migration
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Run the migrations.
|
||||||
|
*/
|
||||||
|
public function up(): void
|
||||||
|
{
|
||||||
|
Schema::table('activity_logs', function (Blueprint $table) {
|
||||||
|
$table->dropColumn('batch');
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Reverse the migrations.
|
||||||
|
*/
|
||||||
|
public function down(): void
|
||||||
|
{
|
||||||
|
Schema::table('activity_logs', function (Blueprint $table) {
|
||||||
|
$table->string('batch', 36)->nullable();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
};
|
Loading…
x
Reference in New Issue
Block a user