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
This commit is contained in:
66
analyticshub/js/admin.js
Normal file
66
analyticshub/js/admin.js
Normal file
@@ -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'));
|
||||
});
|
||||
});
|
||||
}
|
||||
})();
|
||||
Reference in New Issue
Block a user