Files
nextcloud-analytics/analyticshub/js/admin.js
WLTBAgent 730e576ead Fix: Simplify integration and fix admin template
- Removed settings/navigation from appinfo/info.xml
  - These sections can cause routing conflicts
  - App now relies purely on routes.php
- Simplified Application.php
  - Removed manual service/controller registration
  - Let Nextcloud DI framework handle it automatically
- Fixed admin template to use Nextcloud standards
  - Removed non-standard style() call
  - Added proper l10n support with p($l->t(...))
  - Clean template structure
- Created css/admin.css
  - Nextcloud-compatible styling
  - Matches design language
- Created js/admin.js
  - Handles Save Configuration button
  - Handles Test Connection button
  - Uses OC, OC.Notification APIs

This should fix admin page not appearing issue.
Users can access via: Settings → Administration → Additional Settings
2026-02-13 19:06:07 +00:00

67 lines
2.5 KiB
JavaScript

(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'));
});
});
}
})();