Fix: Add routes and admin navigation
- Created appinfo/routes.php to register all routes - Admin routes: index, save, load, getStatus - API v1 routes: reports, getReport, generate, getStatus - Report routes: index, generate - Added index() method to AdminController - Renders admin template via TemplateResponse - Updated info.xml and appinfo/info.xml - Fixed navigation entry to point to route: analyticshub.admin.index - Added settings and navigation sections - App now appears in Settings → Administration after enable/disable Fixes issue where app didn't show up in Nextcloud toolbar after being enabled.
This commit is contained in:
@@ -24,6 +24,12 @@
|
|||||||
<nextcloud min-version="25" max-version="26"/>
|
<nextcloud min-version="25" max-version="26"/>
|
||||||
<php min-version="7.4"/>
|
<php min-version="7.4"/>
|
||||||
</dependencies>
|
</dependencies>
|
||||||
|
<settings>
|
||||||
|
<admin>OCA\AnalyticsHub\Controller\Admin</admin>
|
||||||
|
</settings>
|
||||||
|
<navigation>
|
||||||
|
<admin>analyticshub.admin.index</admin>
|
||||||
|
</navigation>
|
||||||
<repair-steps>
|
<repair-steps>
|
||||||
<step>Repair steps not needed</step>
|
<step>Repair steps not needed</step>
|
||||||
<repair-step>Or remove and reinstall</repair-step>
|
<repair-step>Or remove and reinstall</repair-step>
|
||||||
|
|||||||
67
analyticshub/appinfo/routes.php
Normal file
67
analyticshub/appinfo/routes.php
Normal file
@@ -0,0 +1,67 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
declare(strict_types=1);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Routes for Mini-CMO Analytics Hub
|
||||||
|
*/
|
||||||
|
|
||||||
|
return [
|
||||||
|
'routes' => [
|
||||||
|
// Admin routes
|
||||||
|
[
|
||||||
|
'name' => 'admin#index',
|
||||||
|
'url' => '/admin',
|
||||||
|
'verb' => 'GET'
|
||||||
|
],
|
||||||
|
[
|
||||||
|
'name' => 'admin#save',
|
||||||
|
'url' => '/admin/save',
|
||||||
|
'verb' => 'POST'
|
||||||
|
],
|
||||||
|
[
|
||||||
|
'name' => 'admin#load',
|
||||||
|
'url' => '/admin/load',
|
||||||
|
'verb' => 'GET'
|
||||||
|
],
|
||||||
|
[
|
||||||
|
'name' => 'admin#getStatus',
|
||||||
|
'url' => '/admin/status',
|
||||||
|
'verb' => 'GET'
|
||||||
|
],
|
||||||
|
|
||||||
|
// API v1 routes
|
||||||
|
[
|
||||||
|
'name' => 'api_v1#reports',
|
||||||
|
'url' => '/api/reports',
|
||||||
|
'verb' => 'GET'
|
||||||
|
],
|
||||||
|
[
|
||||||
|
'name' => 'api_v1#getReport',
|
||||||
|
'url' => '/api/report/{id}',
|
||||||
|
'verb' => 'GET'
|
||||||
|
],
|
||||||
|
[
|
||||||
|
'name' => 'api_v1#generate',
|
||||||
|
'url' => '/api/generate',
|
||||||
|
'verb' => 'POST'
|
||||||
|
],
|
||||||
|
[
|
||||||
|
'name' => 'api_v1#getStatus',
|
||||||
|
'url' => '/api/status',
|
||||||
|
'verb' => 'GET'
|
||||||
|
],
|
||||||
|
|
||||||
|
// Report routes
|
||||||
|
[
|
||||||
|
'name' => 'report#index',
|
||||||
|
'url' => '/report',
|
||||||
|
'verb' => 'GET'
|
||||||
|
],
|
||||||
|
[
|
||||||
|
'name' => 'report#generate',
|
||||||
|
'url' => '/report/generate',
|
||||||
|
'verb' => 'POST'
|
||||||
|
],
|
||||||
|
],
|
||||||
|
];
|
||||||
@@ -12,9 +12,9 @@
|
|||||||
<nextcloud min-version="25" max-version="26"/>
|
<nextcloud min-version="25" max-version="26"/>
|
||||||
</dependencies>
|
</dependencies>
|
||||||
<settings>
|
<settings>
|
||||||
<admin>OCA\AnalyticsHub\Settings\Admin</admin>
|
<admin>OCA\AnalyticsHub\Controller\Admin</admin>
|
||||||
</settings>
|
</settings>
|
||||||
<navigation>
|
<navigation>
|
||||||
<admin>OCA\AnalyticsHub\Settings\Admin</admin>
|
<admin>analyticshub.admin.index</admin>
|
||||||
</navigation>
|
</navigation>
|
||||||
</info>
|
</info>
|
||||||
|
|||||||
@@ -9,6 +9,7 @@ use OCP\IResponse;
|
|||||||
use OCP\AppFramework\Http;
|
use OCP\AppFramework\Http;
|
||||||
use OCP\AppFramework\Http\DataResponse;
|
use OCP\AppFramework\Http\DataResponse;
|
||||||
use OCP\AppFramework\Http\JSONResponse;
|
use OCP\AppFramework\Http\JSONResponse;
|
||||||
|
use OCP\AppFramework\Http\TemplateResponse;
|
||||||
|
|
||||||
use OCA\AnalyticsHub\Service\GoogleAnalyticsService;
|
use OCA\AnalyticsHub\Service\GoogleAnalyticsService;
|
||||||
use OCA\AnalyticsHub\Service\LLMService;
|
use OCA\AnalyticsHub\Service\LLMService;
|
||||||
@@ -34,9 +35,21 @@ class AdminController {
|
|||||||
$this->dataProcessor = $dataProcessor;
|
$this->dataProcessor = $dataProcessor;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Index page - render admin UI
|
||||||
|
* GET /admin
|
||||||
|
*/
|
||||||
|
public function index(): TemplateResponse {
|
||||||
|
return new TemplateResponse('analyticshub', 'admin', [
|
||||||
|
'app_name' => AppInfo::APP_NAME,
|
||||||
|
'version' => AppInfo::getVersion(),
|
||||||
|
'status' => $this->gaService->isConfigured() ? 'configured' : 'not_configured',
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Save configuration
|
* Save configuration
|
||||||
* POST /settings/save
|
* POST /admin/save
|
||||||
*/
|
*/
|
||||||
public function save(IRequest $request): JSONResponse {
|
public function save(IRequest $request): JSONResponse {
|
||||||
$params = $request->getParams();
|
$params = $request->getParams();
|
||||||
|
|||||||
Reference in New Issue
Block a user