From d4f96cc28b0818e0e8b2bc21014293ccbcc1cdb0 Mon Sep 17 00:00:00 2001 From: WLTBAgent Date: Fri, 13 Feb 2026 20:13:46 +0000 Subject: [PATCH] Fix: Use simple HTML output to test routing - Changed AdminController to use simple echo/exit instead of TemplateResponse - Eliminates TemplateResponse complexity - Direct HTML output for debugging - Simplified routes.php to single admin route - Removed test route (no longer needed) - Simple GET only route - Simplified Application.php - Removed resource loading - Minimal bootstrap If this shows 'Controller is working' page, routing is confirmed working. If it still redirects to dashboard, it's a Nextcloud routing issue. This is a minimal test version to confirm routing works before building full UI. --- analyticshub/appinfo/Application.php | 5 +-- analyticshub/appinfo/routes.php | 12 +---- .../lib/Controller/AdminController.php | 44 +++++++------------ 3 files changed, 19 insertions(+), 42 deletions(-) diff --git a/analyticshub/appinfo/Application.php b/analyticshub/appinfo/Application.php index c16749b..0c6cb6f 100644 --- a/analyticshub/appinfo/Application.php +++ b/analyticshub/appinfo/Application.php @@ -5,7 +5,6 @@ declare(strict_types=1); namespace OCA\AnalyticsHub\AppInfo; use OCP\AppFramework\App; -use OCP\Util; /** * Application class for Mini-CMO Analytics Hub @@ -18,8 +17,6 @@ class Application extends App { public function __construct(array $urlParams = []) { parent::__construct(self::APP_ID, $urlParams); - // Load scripts and styles for admin page - Util::addStyle(self::APP_ID, 'admin'); - Util::addScript(self::APP_ID, 'admin'); + // No resources to load for simple test } } diff --git a/analyticshub/appinfo/routes.php b/analyticshub/appinfo/routes.php index 18c224f..0c164c5 100644 --- a/analyticshub/appinfo/routes.php +++ b/analyticshub/appinfo/routes.php @@ -4,23 +4,13 @@ declare(strict_types=1); namespace OCA\AnalyticsHub; -use OCP\AppFramework\Http\TemplateResponse; -use OCP\AppFramework\Http\JSONResponse; - /** * Routes for Mini-CMO Analytics Hub */ return [ 'routes' => [ - // Test route - [ - 'name' => 'admin#test', - 'url' => '/test', - 'verb' => 'GET', - 'requirements' => [], - ], - // Admin routes + // Admin route - simple GET only [ 'name' => 'admin#index', 'url' => '/admin', diff --git a/analyticshub/lib/Controller/AdminController.php b/analyticshub/lib/Controller/AdminController.php index f848646..aea58b5 100644 --- a/analyticshub/lib/Controller/AdminController.php +++ b/analyticshub/lib/Controller/AdminController.php @@ -4,9 +4,6 @@ declare(strict_types=1); namespace OCA\AnalyticsHub\Controller; -use OCP\AppFramework\Controller; -use OCP\AppFramework\Http\TemplateResponse; -use OCP\AppFramework\Http\JSONResponse; use OCP\IRequest; /** @@ -15,40 +12,33 @@ use OCP\IRequest; * @NoAdminRequired * @NoCSRFRequired */ -class AdminController extends Controller { +class AdminController { private $appName; - public function __construct($appName, IRequest $request) { - parent::__construct($appName, $request); + public function __construct(string $appName, IRequest $request) { $this->appName = $appName; + $this->request = $request; } /** - * Index page - render admin UI + * Index page - simple render without TemplateResponse * * @NoAdminRequired * @NoCSRFRequired */ - public function index(): TemplateResponse { - return new TemplateResponse($this->appName, 'admin', [ - 'app_name' => $this->appName, - 'version' => '1.0.0', - 'status' => 'testing - admin accessible', - ]); - } - - /** - * Test route - simple JSON response - * - * @NoAdminRequired - * @NoCSRFRequired - */ - public function test(): JSONResponse { - return new JSONResponse([ - 'success' => true, - 'message' => 'Analytics Hub controller is working!', - 'app_name' => $this->appName, - ]); + public function index(): void { + echo ''; + echo ''; + echo 'Mini-CMO Analytics Hub'; + echo ''; + echo '

Mini-CMO Analytics Hub

'; + echo '

Controller is working! App name: ' . htmlspecialchars($this->appName) . '

'; + echo '

Status: Admin accessible!

'; + echo '
'; + echo '

Test successful - routing is working.

'; + echo ''; + echo ''; + exit; } }