- Removed service dependencies from PageController constructor - Fixed AdminController config API signatures - Cleaned up Application.php resource loading - Updated template with proper resource includes - Simplified routes.php - Reduced analyticshub.zip from 50KB to 27KB - Status: Fixed and ready for redeployment
84 lines
2.9 KiB
PHP
84 lines
2.9 KiB
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
namespace OCA\AnalyticsHub\Controller;
|
|
|
|
use OCP\IRequest;
|
|
use OCP\IConfig;
|
|
use OCP\AppFramework\Http\TemplateResponse;
|
|
|
|
/**
|
|
* Admin Settings Controller
|
|
*
|
|
* @AdminRequired
|
|
* @NoCSRFRequired
|
|
*/
|
|
class PageController extends \OCP\AppFramework\Controller {
|
|
|
|
protected $appName;
|
|
protected $config;
|
|
|
|
public function __construct(
|
|
string $appName,
|
|
IRequest $request,
|
|
IConfig $config
|
|
) {
|
|
parent::__construct($appName, $request);
|
|
$this->appName = $appName;
|
|
$this->config = $config;
|
|
}
|
|
|
|
/**
|
|
* Index page - render admin UI
|
|
*
|
|
* @AdminRequired
|
|
* @NoCSRFRequired
|
|
*/
|
|
public function index(): TemplateResponse {
|
|
// Get configuration values directly from config service
|
|
$clientId = $this->config->getAppValue('analyticshub', 'google_client_id', '');
|
|
$clientSecret = $this->config->getAppValue('analyticshub', 'google_client_secret', '');
|
|
$refreshToken = $this->config->getAppValue('analyticshub', 'google_refresh_token', '');
|
|
$apiKey = $this->config->getAppValue('analyticshub', 'anthropic_api_key', '');
|
|
$llmEndpoint = $this->config->getAppValue('analyticshub', 'llm_api_endpoint', '');
|
|
$llmModel = $this->config->getAppValue('analyticshub', 'llm_model', '');
|
|
|
|
// Check if configured
|
|
$isConfigured = !empty($clientId) && !empty($clientSecret) && !empty($refreshToken) && !empty($apiKey);
|
|
$isGAConfigured = !empty($clientId) && !empty($clientSecret) && !empty($refreshToken);
|
|
$isLLMConfigured = !empty($apiKey);
|
|
|
|
// Mask secrets for display
|
|
$maskedClientSecret = '';
|
|
if (!empty($clientSecret)) {
|
|
$maskedClientSecret = '••••••••••••••••';
|
|
}
|
|
|
|
$maskedRefreshToken = '';
|
|
if (!empty($refreshToken)) {
|
|
$maskedRefreshToken = substr($refreshToken, 0, 8) . '...' . substr($refreshToken, -4);
|
|
}
|
|
|
|
$maskedApiKey = '';
|
|
if (!empty($apiKey)) {
|
|
$maskedApiKey = substr($apiKey, 0, 8) . '...' . substr($apiKey, -4);
|
|
}
|
|
|
|
return new TemplateResponse('analyticshub', 'admin', [
|
|
'app_name' => 'Mini-CMO Analytics Hub',
|
|
'version' => '1.0.0',
|
|
'status' => $isConfigured ? 'Ready' : 'Configuration Required',
|
|
'is_configured' => $isConfigured,
|
|
'is_ga_configured' => $isGAConfigured,
|
|
'is_llm_configured' => $isLLMConfigured,
|
|
'google_client_id' => $clientId,
|
|
'google_client_secret_masked' => $maskedClientSecret,
|
|
'google_refresh_token_masked' => $maskedRefreshToken,
|
|
'llm_api_endpoint' => $llmEndpoint,
|
|
'llm_model' => $llmModel,
|
|
'anthropic_api_key_masked' => $maskedApiKey,
|
|
], 'blank'); // Use 'blank' rendering mode for admin pages
|
|
}
|
|
}
|