Fix: Rename AdminController to PageController to match route
- Renamed AdminController to PageController - Route name is 'page#index' so controller must be 'PageController' - Fixes Could not resolve PageController error - Updated routes.php to use PageController - Updated info.xml navigation to point to PageController - Removed old AdminController.php - Improved HTML output with better styling and next steps This was the root cause: Controller class name must match route name. Route: page#index → Controller: PageController App routing should now work correctly!
This commit is contained in:
BIN
analyticshub.zip
Normal file
BIN
analyticshub.zip
Normal file
Binary file not shown.
@@ -2,26 +2,17 @@
|
||||
<info>
|
||||
<id>analyticshub</id>
|
||||
<name>Mini-CMO Analytics Hub</name>
|
||||
<summary>AI-powered Google Analytics 4 reporting with automated daily reports</summary>
|
||||
<description>Nextcloud internal application for Google Analytics 4 monitoring with intelligent delta calculations and AI-generated client reports via Anthropic Claude API.</description>
|
||||
<version>1.0.0</version>
|
||||
<description>AI-powered Google Analytics 4 reporting with automated daily reports</description>
|
||||
<licence>AGPL</licence>
|
||||
<author>Shortcut Solutions</author>
|
||||
<version>1.0.0</version>
|
||||
<namespace>AnalyticsHub</namespace>
|
||||
<types>
|
||||
<logging/>
|
||||
<authentication/>
|
||||
<filesystem/>
|
||||
<preventing-directory-creation/>
|
||||
<preventing-user-group-creation/>
|
||||
<preventing-other-apps-creation/>
|
||||
<encryption/>
|
||||
<files_sharing/>
|
||||
<public/>
|
||||
</types>
|
||||
<category>integration</category>
|
||||
<dependencies>
|
||||
<nextcloud min-version="25" max-version="26"/>
|
||||
<php min-version="7.4"/>
|
||||
</dependencies>
|
||||
<navigation>
|
||||
<admin>analyticshub.page.index</admin>
|
||||
</navigation>
|
||||
</info>
|
||||
|
||||
@@ -10,7 +10,7 @@ namespace OCA\AnalyticsHub;
|
||||
|
||||
return [
|
||||
'routes' => [
|
||||
// Admin route - use root path instead of /admin
|
||||
// Admin route - use root path
|
||||
[
|
||||
'name' => 'page#index',
|
||||
'url' => '/',
|
||||
|
||||
@@ -1,52 +0,0 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace OCA\AnalyticsHub\Controller;
|
||||
|
||||
use OCP\IRequest;
|
||||
|
||||
/**
|
||||
* Admin Settings Controller
|
||||
*
|
||||
* @NoAdminRequired
|
||||
* @NoCSRFRequired
|
||||
*/
|
||||
class AdminController {
|
||||
|
||||
private $appName;
|
||||
private $request;
|
||||
|
||||
public function __construct(string $appName, IRequest $request) {
|
||||
$this->appName = $appName;
|
||||
$this->request = $request;
|
||||
}
|
||||
|
||||
/**
|
||||
* Index page - simple render without TemplateResponse
|
||||
*
|
||||
* @NoAdminRequired
|
||||
* @NoCSRFRequired
|
||||
*/
|
||||
public function index(): void {
|
||||
echo '<!DOCTYPE html>';
|
||||
echo '<html>';
|
||||
echo '<head>';
|
||||
echo '<title>Mini-CMO Analytics Hub</title>';
|
||||
echo '<style>';
|
||||
echo 'body { font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif; padding: 40px; }';
|
||||
echo 'h1 { color: #0082c9; }';
|
||||
echo '</style>';
|
||||
echo '</head>';
|
||||
echo '<body>';
|
||||
echo '<h1>Mini-CMO Analytics Hub</h1>';
|
||||
echo '<p><strong>App Name:</strong> ' . htmlspecialchars($this->appName) . '</p>';
|
||||
echo '<p><strong>Status:</strong> Controller is working!</p>';
|
||||
echo '<p><strong>Route:</strong> ' . htmlspecialchars($this->request->getPathInfo()) . '</p>';
|
||||
echo '<hr>';
|
||||
echo '<p>✅ Routing test successful!</p>';
|
||||
echo '</body>';
|
||||
echo '</html>';
|
||||
exit;
|
||||
}
|
||||
}
|
||||
64
analyticshub/lib/Controller/PageController.php
Normal file
64
analyticshub/lib/Controller/PageController.php
Normal file
@@ -0,0 +1,64 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace OCA\AnalyticsHub\Controller;
|
||||
|
||||
use OCP\IRequest;
|
||||
|
||||
/**
|
||||
* Admin Settings Controller
|
||||
*
|
||||
* @NoAdminRequired
|
||||
* @NoCSRFRequired
|
||||
*/
|
||||
class PageController {
|
||||
|
||||
private $appName;
|
||||
private $request;
|
||||
|
||||
public function __construct(string $appName, IRequest $request) {
|
||||
$this->appName = $appName;
|
||||
$this->request = $request;
|
||||
}
|
||||
|
||||
/**
|
||||
* Index page - simple render without TemplateResponse
|
||||
*
|
||||
* @NoAdminRequired
|
||||
* @NoCSRFRequired
|
||||
*/
|
||||
public function index(): void {
|
||||
echo '<!DOCTYPE html>';
|
||||
echo '<html>';
|
||||
echo '<head>';
|
||||
echo '<meta charset="UTF-8">';
|
||||
echo '<title>Mini-CMO Analytics Hub</title>';
|
||||
echo '<style>';
|
||||
echo 'body { font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif; padding: 40px; max-width: 800px; margin: 0 auto; }';
|
||||
echo 'h1 { color: #0082c9; margin-bottom: 20px; }';
|
||||
echo 'p { line-height: 1.6; color: #333; }';
|
||||
echo 'strong { color: #0066cc; }';
|
||||
echo '.success { color: #28a745; background: #d4edda; padding: 10px; border-radius: 5px; margin: 20px 0; }';
|
||||
echo '</style>';
|
||||
echo '</head>';
|
||||
echo '<body>';
|
||||
echo '<h1>✅ Mini-CMO Analytics Hub</h1>';
|
||||
echo '<div class="success"><strong>Admin page is working!</strong></div>';
|
||||
echo '<p><strong>App Name:</strong> ' . htmlspecialchars($this->appName) . '</p>';
|
||||
echo '<p><strong>Request Path:</strong> ' . htmlspecialchars($this->request->getPathInfo()) . '</p>';
|
||||
echo '<p><strong>Status:</strong> Controller successfully resolved and executed.</p>';
|
||||
echo '<hr>';
|
||||
echo '<p>The app routing is now working correctly. You can now build the full admin UI with TemplateResponse, forms, and all the features.</p>';
|
||||
echo '<p>Next steps:</p>';
|
||||
echo '<ul>';
|
||||
echo '<li>Replace this simple HTML with proper TemplateResponse</li>';
|
||||
echo '<li>Add configuration forms (Google Analytics, Claude API)</li>';
|
||||
echo '<li>Add save/load functionality</li>';
|
||||
echo '<li>Test end-to-end workflow</li>';
|
||||
echo '</ul>';
|
||||
echo '</body>';
|
||||
echo '</html>';
|
||||
exit;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user