Fix: Add proper Application.php and fix DI
- Created appinfo/Application.php (Nextcloud app bootstrap) - Extends OCP\AppFramework\App - Registers proper app ID: analyticshub - Loads CSS and JS files - Removed obsolete lib/App.php file - Updated all AppInfo::APP_NAME references to Application::APP_NAME - AdminController, ApiV1Controller - GoogleAnalyticsService, LLMService - Fixed dependency injection in AdminController - Injected IConfig service properly - Added missing use statements This is the core fix for the app not appearing in Nextcloud. Nextcloud requires appinfo/Application.php to initialize the app.
This commit is contained in:
@@ -10,10 +10,12 @@ use OCP\AppFramework\Http;
|
||||
use OCP\AppFramework\Http\DataResponse;
|
||||
use OCP\AppFramework\Http\JSONResponse;
|
||||
use OCP\AppFramework\Http\TemplateResponse;
|
||||
use OCA\AnalyticsHub\AppInfo\Application;
|
||||
|
||||
use OCA\AnalyticsHub\Service\GoogleAnalyticsService;
|
||||
use OCA\AnalyticsHub\Service\LLMService;
|
||||
use OCA\AnalyticsHub\Service\DataProcessor;
|
||||
use OCP\IConfig;
|
||||
|
||||
/**
|
||||
* Admin Settings Controller
|
||||
@@ -21,15 +23,18 @@ use OCA\AnalyticsHub\Service\DataProcessor;
|
||||
*/
|
||||
class AdminController {
|
||||
|
||||
private IConfig $config;
|
||||
private GoogleAnalyticsService $gaService;
|
||||
private LLMService $llmService;
|
||||
private DataProcessor $dataProcessor;
|
||||
|
||||
public function __construct(
|
||||
IConfig $config,
|
||||
GoogleAnalyticsService $gaService,
|
||||
LLMService $llmService,
|
||||
DataProcessor $dataProcessor
|
||||
) {
|
||||
$this->config = $config;
|
||||
$this->gaService = $gaService;
|
||||
$this->llmService = $llmService;
|
||||
$this->dataProcessor = $dataProcessor;
|
||||
@@ -41,7 +46,7 @@ class AdminController {
|
||||
*/
|
||||
public function index(): TemplateResponse {
|
||||
return new TemplateResponse('analyticshub', 'admin', [
|
||||
'app_name' => AppInfo::APP_NAME,
|
||||
'app_name' => Application::APP_NAME,
|
||||
'version' => AppInfo::getVersion(),
|
||||
'status' => $this->gaService->isConfigured() ? 'configured' : 'not_configured',
|
||||
]);
|
||||
@@ -145,7 +150,7 @@ class AdminController {
|
||||
*/
|
||||
public function getStatus(IRequest $request): DataResponse {
|
||||
$status = [
|
||||
'app_name' => AppInfo::APP_NAME,
|
||||
'app_name' => Application::APP_NAME,
|
||||
'version' => AppInfo::getVersion(),
|
||||
'status' => 'operational',
|
||||
'google_analytics' => $this->gaService->isConfigured() ? 'configured' : 'not_configured',
|
||||
@@ -164,10 +169,10 @@ class AdminController {
|
||||
* Helper methods
|
||||
*/
|
||||
private function saveConfigValue(string $key, string $value): void {
|
||||
$this->getConfig()->setAppValue($key, $value, AppInfo::APP_NAME);
|
||||
$this->config->setAppValue(Application::APP_NAME, $key, $value);
|
||||
}
|
||||
|
||||
private function getConfigValue(string $key): ?string {
|
||||
return $this->getConfig()->getAppValue($key, AppInfo::APP_NAME);
|
||||
return $this->config->getAppValue(Application::APP_NAME, $key);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user