feat(modpackchecker): Phase 5 complete - Dashboard badge and cron job
Phase 5 Components (completing Pyrrhus's work): NEW FILES: - views/dashboard/UpdateBadge.tsx: Dashboard badge component - Shows 🟢 (up to date) or 🟠 (update available) next to server names - Global cache prevents multiple API calls on page load - Reads from local database, never calls external APIs directly - Fire (#FF6B35) and Frost (#4ECDC4) brand colors - console/CheckModpackUpdates.php: Laravel cron command - Run with: php artisan modpackchecker:check - Loops through servers with MODPACK_PLATFORM variable - Checks CurseForge, Modrinth, FTB, Technic APIs - Rate limited (2s sleep between checks) - Stores results in modpackchecker_servers table UPDATED FILES: - Controllers/ModpackAPIController.php: - Added getStatus() method for dashboard badge endpoint - Returns all user's servers' update status in single query - Added DB facade import - routes/client.php: - Added GET /extensions/modpackchecker/status route - build.sh: - Complete rewrite for Phase 5 - Handles both console widget AND dashboard badge - Auto-detects extension directory (dev vs extensions) - Copies CheckModpackUpdates.php to app/Console/Commands/ - Injects UpdateBadge into ServerRow.tsx - Clear status output and next-steps guide Architecture (Gemini-approved): CRON (hourly) → Database cache → Single API endpoint → React badge Dashboard badge is 'dumb' - only reads from cache, never external APIs Completing work started by Chronicler #62 (Pyrrhus). UpdateBadge.tsx was lost in Blueprint corruption - reconstructed from handoff notes and architecture documentation. Signed-off-by: Claude (Chronicler #63) <claude@firefrostgaming.com>
This commit is contained in:
@@ -9,6 +9,7 @@ use Pterodactyl\BlueprintFramework\Libraries\ExtensionLibrary\Admin\BlueprintAdm
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use Illuminate\Support\Facades\Http;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
|
||||
class ModpackAPIController extends Controller
|
||||
{
|
||||
@@ -245,4 +246,34 @@ class ModpackAPIController extends Controller
|
||||
'version' => $data['version'] ?? 'Unknown',
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* Get cached update status for all servers (dashboard badge view)
|
||||
* Called once on page load, returns status for all user's servers
|
||||
*/
|
||||
public function getStatus(Request $request): JsonResponse
|
||||
{
|
||||
$user = $request->user();
|
||||
|
||||
// Get all servers the user has access to
|
||||
$serverIds = $user->accessibleServers()->pluck('id')->toArray();
|
||||
|
||||
// Query our cache table for these servers
|
||||
$statuses = DB::table('modpackchecker_servers')
|
||||
->whereIn('server_id', $serverIds)
|
||||
->get()
|
||||
->keyBy('server_uuid');
|
||||
|
||||
$result = [];
|
||||
foreach ($statuses as $uuid => $status) {
|
||||
$result[$uuid] = [
|
||||
'update_available' => (bool) $status->update_available,
|
||||
'modpack_name' => $status->modpack_name,
|
||||
'current_version' => $status->current_version,
|
||||
'latest_version' => $status->latest_version,
|
||||
];
|
||||
}
|
||||
|
||||
return response()->json($result);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user