diff --git a/analyticshub/appinfo/Application.php b/analyticshub/appinfo/Application.php index a5cc183..c16749b 100644 --- a/analyticshub/appinfo/Application.php +++ b/analyticshub/appinfo/Application.php @@ -18,7 +18,7 @@ class Application extends App { public function __construct(array $urlParams = []) { parent::__construct(self::APP_ID, $urlParams); - // Load scripts and styles + // Load scripts and styles for admin page Util::addStyle(self::APP_ID, 'admin'); Util::addScript(self::APP_ID, 'admin'); } diff --git a/analyticshub/appinfo/info.xml b/analyticshub/appinfo/info.xml index a207ad9..e6b209f 100644 --- a/analyticshub/appinfo/info.xml +++ b/analyticshub/appinfo/info.xml @@ -24,15 +24,4 @@ - - OCA\AnalyticsHub\Controller\Admin - - - analyticshub.admin.index - - - Repair steps not needed - Or remove and reinstall - Check Nextcloud logs for errors - diff --git a/analyticshub/css/admin.css b/analyticshub/css/admin.css new file mode 100644 index 0000000..c64b9e6 --- /dev/null +++ b/analyticshub/css/admin.css @@ -0,0 +1,60 @@ +#analytics-hub-settings { + max-width: 800px; + margin: 0 auto; + padding: 20px; +} + +.analytics-hub-settings__section { + margin-bottom: 30px; +} + +.analytics-hub-settings__field { + margin-bottom: 20px; +} + +.analytics-hub-settings__field label { + display: block; + font-weight: 600; + margin-bottom: 8px; +} + +.analytics-hub-settings__field input { + width: 100%; + padding: 10px; + border: 1px solid #ccc; + border-radius: 4px; + font-size: 14px; + box-sizing: border-box; +} + +.analytics-hub-settings__hint { + font-size: 13px; + color: #666; + margin-top: 8px; + line-height: 1.4; +} + +.analytics-hub-settings__actions { + display: flex; + gap: 10px; + margin-top: 20px; +} + +.analytics-hub-settings__actions button { + padding: 12px 24px; + border: none; + border-radius: 6px; + font-size: 14px; + font-weight: 600; + cursor: pointer; +} + +.analytics-hub-settings__actions .primary { + background-color: #0078d4; + color: white; +} + +.analytics-hub-settings__actions .secondary { + background-color: #6c757d; + color: white; +} diff --git a/analyticshub/js/admin.js b/analyticshub/js/admin.js new file mode 100644 index 0000000..66ec288 --- /dev/null +++ b/analyticshub/js/admin.js @@ -0,0 +1,66 @@ +(function() { + 'use strict'; + + const saveButton = document.getElementById('analytics-hub-save'); + const testButton = document.getElementById('analytics-hub-test'); + + if (saveButton) { + saveButton.addEventListener('click', function() { + // Collect form data + const data = { + google_client_id: document.getElementById('google_client_id').value, + google_client_secret: document.getElementById('google_client_secret').value, + google_refresh_token: document.getElementById('google_refresh_token').value, + anthropic_api_key: document.getElementById('anthropic_api_key').value + }; + + // Send save request + fetch(OC.generateUrl('/apps/analyticshub/admin/save'), { + method: 'POST', + headers: { + 'Content-Type': 'application/json', + 'requesttoken': OC.requestToken + }, + body: JSON.stringify(data) + }) + .then(response => response.json()) + .then(data => { + if (data.success) { + OC.Notification.showTemporary(t('analyticshub', 'Configuration saved successfully')); + } else { + OC.Notification.showTemporary(t('analyticshub', 'Error: ' + data.error)); + } + }) + .catch(error => { + OC.Notification.showTemporary(t('analyticshub', 'Error saving configuration')); + }); + }); + } + + if (testButton) { + testButton.addEventListener('click', function() { + // Test connections + fetch(OC.generateUrl('/apps/analyticshub/admin/status'), { + method: 'GET', + headers: { + 'requesttoken': OC.requestToken + } + }) + .then(response => response.json()) + .then(data => { + if (data.success) { + const status = data.data; + const message = [ + 'App Status: ' + status.status, + 'Google Analytics: ' + status.google_analytics, + 'LLM Service: ' + status.llm_service + ].join('\n'); + alert(message); + } + }) + .catch(error => { + OC.Notification.showTemporary(t('analyticshub', 'Error getting status')); + }); + }); + } +})(); diff --git a/analyticshub/templates/admin.php b/analyticshub/templates/admin.php index 5d73f12..b923803 100644 --- a/analyticshub/templates/admin.php +++ b/analyticshub/templates/admin.php @@ -1,18 +1,16 @@ -
-

Mini-CMO Analytics Hub

-

AI-powered Google Analytics 4 reporting with automated daily reports.

+
+

t('Mini-CMO Analytics Hub')); ?>

+

t('AI-powered Google Analytics 4 reporting with automated daily reports.')); ?>

-

Google Analytics Configuration

+

t('Google Analytics Configuration')); ?>

- +
- +
- +

- After OAuth consent, paste only the refresh token here. - The access token is refreshed automatically each run. + t('After OAuth consent, paste only the refresh token here. The access token is refreshed automatically each run.')); ?>

-

Anthropic Claude API

+

t('Anthropic Claude API')); ?>

- +

- Enter your Anthropic API key for AI-powered report generation. - Model: claude-sonnet-4-5-20250929 (cost-effective) - Cost: ~$0.015 per report (3K tokens) + t('Enter your Anthropic API key for AI-powered report generation. Model: claude-sonnet-4-5-20250929 (cost-effective)')); ?> +

+

+ t('Cost: ~$0.015 per report (3K tokens)')); ?>

- -