diff --git a/app/Addons/AdvancedAdmin/AddonServiceProvider.php b/app/Addons/AdvancedAdmin/AddonServiceProvider.php index 1158c28..c82fe8f 100644 --- a/app/Addons/AdvancedAdmin/AddonServiceProvider.php +++ b/app/Addons/AdvancedAdmin/AddonServiceProvider.php @@ -26,7 +26,7 @@ class AddonServiceProvider extends ServiceProvider { // Merge addon config (won't overwrite user's published config) $this->mergeConfigFrom( - __DIR__ . '/../../config/advanced-admin.php', + __DIR__ . '/../../../config/advanced-admin.php', 'advanced-admin' ); @@ -43,8 +43,8 @@ class AddonServiceProvider extends ServiceProvider public function boot(): void { // ── Routes ──────────────────────────────────────────────────────────── - $clientRoutes = __DIR__ . '/../../routes/addon-client.php'; - $appRoutes = __DIR__ . '/../../routes/addon-application.php'; + $clientRoutes = __DIR__ . '/../../../routes/addon-client.php'; + $appRoutes = __DIR__ . '/../../../routes/addon-application.php'; if (file_exists($clientRoutes)) { $this->loadRoutesFrom($clientRoutes); @@ -54,7 +54,7 @@ class AddonServiceProvider extends ServiceProvider } // ── Migrations ──────────────────────────────────────────────────────── - $migrationsPath = __DIR__ . '/../../database/migrations/addon'; + $migrationsPath = __DIR__ . '/../../../database/migrations/addon'; if (is_dir($migrationsPath)) { $this->loadMigrationsFrom($migrationsPath); } @@ -129,11 +129,11 @@ class AddonServiceProvider extends ServiceProvider // ── Publishable Assets ──────────────────────────────────────────────── $this->publishes([ - __DIR__ . '/../../config/advanced-admin.php' => config_path('advanced-admin.php'), + __DIR__ . '/../../../config/advanced-admin.php' => config_path('advanced-admin.php'), ], 'advanced-admin-config'); $this->publishes([ - __DIR__ . '/../../config/addon-commands' => base_path('config/addon-commands'), + __DIR__ . '/../../../config/addon-commands' => base_path('config/addon-commands'), ], 'advanced-admin-commands'); } } diff --git a/app/Addons/AdvancedAdmin/Http/Controllers/Admin/CommandDefinitionController.php b/app/Addons/AdvancedAdmin/Http/Controllers/Admin/CommandDefinitionController.php new file mode 100644 index 0000000..335ae56 --- /dev/null +++ b/app/Addons/AdvancedAdmin/Http/Controllers/Admin/CommandDefinitionController.php @@ -0,0 +1,88 @@ +get() + : collect([]); + + return response()->json(['data' => $defs]); + } + + /** POST api/application/addons/console/definitions */ + public function store(Request $request): JsonResponse + { + $validated = $request->validate([ + 'command' => 'required|string|max:100', + 'description' => 'required|string|max:255', + 'syntax' => 'nullable|string|max:255', + 'dangerous' => 'boolean', + 'plugin' => 'nullable|string|max:80', + ]); + + if (!class_exists(CommandDefinition::class)) { + return response()->json(['error' => 'CommandDefinition model not available'], 501); + } + + $def = CommandDefinition::create($validated); + return response()->json(['data' => $def], 201); + } + + /** GET api/application/addons/console/definitions/{id} */ + public function show(int $id): JsonResponse + { + if (!class_exists(CommandDefinition::class)) { + return response()->json(['error' => 'Not available'], 501); + } + return response()->json(['data' => CommandDefinition::findOrFail($id)]); + } + + /** PUT api/application/addons/console/definitions/{id} */ + public function update(Request $request, int $id): JsonResponse + { + if (!class_exists(CommandDefinition::class)) { + return response()->json(['error' => 'Not available'], 501); + } + $def = CommandDefinition::findOrFail($id); + $def->update($request->only(['command', 'description', 'syntax', 'dangerous', 'plugin'])); + return response()->json(['data' => $def]); + } + + /** DELETE api/application/addons/console/definitions/{id} */ + public function destroy(int $id): JsonResponse + { + if (!class_exists(CommandDefinition::class)) { + return response()->json(['error' => 'Not available'], 501); + } + CommandDefinition::findOrFail($id)->delete(); + return response()->json(null, 204); + } + + /** GET api/application/addons/console/settings */ + public function settings(): JsonResponse + { + return response()->json([ + 'data' => [ + 'enabled' => config('advanced-admin.console.enabled', true), + 'rate_limit' => config('advanced-admin.console.rate_limit', 60), + 'player_ttl' => config('advanced-admin.console.player_ttl_minutes', 30), + ], + ]); + } + + /** PUT api/application/addons/console/settings */ + public function updateSettings(Request $request): JsonResponse + { + return $this->settings(); + } +} diff --git a/app/Addons/AdvancedAdmin/Http/Controllers/Admin/NodeNetworkController.php b/app/Addons/AdvancedAdmin/Http/Controllers/Admin/NodeNetworkController.php new file mode 100644 index 0000000..c22caf4 --- /dev/null +++ b/app/Addons/AdvancedAdmin/Http/Controllers/Admin/NodeNetworkController.php @@ -0,0 +1,46 @@ +map(function (Node $node) { + $latest = NetworkMetric::where('node_id', $node->id) + ->orderByDesc('recorded_at') + ->first(); + + return [ + 'id' => $node->id, + 'name' => $node->name, + 'fqdn' => $node->fqdn, + 'rx_bytes' => $latest?->rx_bytes ?? 0, + 'tx_bytes' => $latest?->tx_bytes ?? 0, + 'recorded_at'=> $latest?->recorded_at, + ]; + }); + + return response()->json(['data' => $nodes]); + } + + /** GET api/application/addons/network/nodes/{node} */ + public function show(Node $node): JsonResponse + { + $metrics = NetworkMetric::where('node_id', $node->id) + ->orderByDesc('recorded_at') + ->limit(60) + ->get(['recorded_at', 'rx_bytes', 'tx_bytes', 'server_id']); + + return response()->json([ + 'node' => ['id' => $node->id, 'name' => $node->name, 'fqdn' => $node->fqdn], + 'metrics' => $metrics, + ]); + } +} diff --git a/app/Addons/AdvancedAdmin/Http/Controllers/Admin/RevisionSettingsController.php b/app/Addons/AdvancedAdmin/Http/Controllers/Admin/RevisionSettingsController.php new file mode 100644 index 0000000..3fa8657 --- /dev/null +++ b/app/Addons/AdvancedAdmin/Http/Controllers/Admin/RevisionSettingsController.php @@ -0,0 +1,30 @@ +json([ + 'data' => [ + 'enabled' => config('advanced-admin.revisions.enabled', true), + 'max_file_size' => config('advanced-admin.revisions.max_file_size', 10485760), + 'max_per_file' => config('advanced-admin.revisions.max_per_file', 50), + 'retention_days' => config('advanced-admin.revisions.retention_days', 90), + ], + ]); + } + + /** PUT api/application/addons/revisions/settings */ + public function update(Request $request): JsonResponse + { + // Settings are managed via .env / config — return current for now + return $this->show(); + } +}