Added Phase‑1 continuation work across deep links, offline moderation queue, and admin push.

resources/js/admin/mobile/lib.
  - Admin push is end‑to‑end: new backend model/migration/service/job + API endpoints, admin runtime config, push‑aware
    service worker, and a settings toggle via useAdminPushSubscription. Notifications now auto‑refresh on push.
  - New PHP/JS tests: admin push API feature test and queue/haptics unit tests
  Added admin-specific PWA icon assets and wired them into the admin manifest, service worker, and admin shell, plus a
  new “Device & permissions” card in mobile Settings with a persistent storage action and translations.
  Details: public/manifest.json, public/admin-sw.js, resources/views/admin.blade.php, new icons in public/; new hook
  resources/js/admin/mobile/hooks/useDevicePermissions.ts, helpers/tests in resources/js/admin/mobile/lib/
  devicePermissions.ts + resources/js/admin/mobile/lib/devicePermissions.test.ts, and Settings UI updates in resources/
  js/admin/mobile/SettingsPage.tsx with copy in resources/js/admin/i18n/locales/en/management.json and resources/js/
admin/i18n/locales/de/management.json.
This commit is contained in:
Codex Agent
2025-12-28 15:00:47 +01:00
parent 4ce409e918
commit b780d82d62
42 changed files with 2258 additions and 121 deletions

View File

@@ -0,0 +1,41 @@
<?php
namespace Database\Factories;
use App\Models\Tenant;
use App\Models\TenantAdminPushSubscription;
use App\Models\User;
use Illuminate\Database\Eloquent\Factories\Factory;
use Illuminate\Support\Str;
/**
* @extends \Illuminate\Database\Eloquent\Factories\Factory<\App\Models\TenantAdminPushSubscription>
*/
class TenantAdminPushSubscriptionFactory extends Factory
{
protected $model = TenantAdminPushSubscription::class;
/**
* Define the model's default state.
*
* @return array<string, mixed>
*/
public function definition(): array
{
$endpoint = $this->faker->url();
return [
'tenant_id' => Tenant::factory(),
'user_id' => User::factory(),
'device_id' => (string) Str::uuid(),
'endpoint' => $endpoint,
'endpoint_hash' => hash('sha256', $endpoint),
'public_key' => base64_encode(random_bytes(32)),
'auth_token' => base64_encode(random_bytes(16)),
'content_encoding' => 'aes128gcm',
'status' => 'active',
'language' => 'de',
'user_agent' => 'Mozilla/5.0',
];
}
}

View File

@@ -0,0 +1,48 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
/**
* Run the migrations.
*/
public function up(): void
{
Schema::create('tenant_admin_push_subscriptions', function (Blueprint $table) {
$table->id();
$table->foreignId('tenant_id')->constrained()->cascadeOnDelete();
$table->foreignId('user_id')->nullable()->constrained()->nullOnDelete();
$table->string('device_id', 120)->nullable();
$table->string('endpoint', 500)->unique();
$table->string('endpoint_hash', 128)->index();
$table->string('public_key', 255);
$table->string('auth_token', 255);
$table->string('content_encoding', 32)->default('aes128gcm');
$table->string('status', 32)->default('active');
$table->timestamp('expires_at')->nullable();
$table->timestamp('last_seen_at')->nullable();
$table->timestamp('last_notified_at')->nullable();
$table->timestamp('last_failed_at')->nullable();
$table->unsignedSmallInteger('failure_count')->default(0);
$table->string('language', 12)->nullable();
$table->string('user_agent', 255)->nullable();
$table->json('meta')->nullable();
$table->timestamps();
$table->index(['tenant_id', 'status']);
$table->index(['tenant_id', 'user_id']);
$table->index(['tenant_id', 'device_id']);
});
}
/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::dropIfExists('tenant_admin_push_subscriptions');
}
};

View File

@@ -0,0 +1,19 @@
<?php
namespace Database\Seeders;
use App\Models\TenantAdminPushSubscription;
use Illuminate\Database\Seeder;
class TenantAdminPushSubscriptionSeeder extends Seeder
{
/**
* Run the database seeds.
*/
public function run(): void
{
TenantAdminPushSubscription::factory()
->count(3)
->create();
}
}