Files
nextcloud-analytics/analyticshub/templates/admin.php

135 lines
5.7 KiB
PHP

<?php
declare(strict_types=1);
style('display:none');
?>
<div id="analytics-hub-settings" class="section analytics-hub-settings">
<h2><?php p($l->t('Mini-CMO Analytics Hub')); ?></h2>
<p><?php p($l->t('AI-powered Google Analytics 4 reporting with automated daily reports.')); ?></p>
<?php if ($_['is_configured']): ?>
<div class="analytics-hub-settings__success">
<h3>✅ <?php p($l->t('Configuration Status')); ?></h3>
<p><?php p($l->t('App is configured and ready to use.')); ?></p>
</div>
<?php else: ?>
<div class="analytics-hub-settings__warning">
<h3>⚠️ <?php p($l->t('Configuration Status')); ?></h3>
<p><?php p($l->t('App is not yet configured. Please enter your credentials below.')); ?></p>
</div>
<?php endif; ?>
<form id="analytics-hub-form" class="analytics-hub-settings__form">
<?php print_unescaped($l->t('CSRF Token: %s', [$_['request']->getParam('requesttoken')])); ?>
<input type="hidden" name="requesttoken" value="<?php p($_['request']->getParam('requesttoken')); ?>" />
<!-- Google Analytics Configuration -->
<div class="analytics-hub-settings__section">
<h3><?php p($l->t('Google Analytics Configuration')); ?></h3>
<div class="analytics-hub-settings__field">
<label for="google_client_id">
<?php p($l->t('Google Client ID')); ?>
<span class="analytics-hub-settings__required">*</span>
</label>
<input
type="text"
id="google_client_id"
name="google_client_id"
value="<?php p($_['google_client_id']); ?>"
placeholder="123456789.apps.googleusercontent.com"
autocomplete="off"
required
/>
</div>
<div class="analytics-hub-settings__field">
<label for="google_client_secret">
<?php p($l->t('Google Client Secret')); ?>
<span class="analytics-hub-settings__required">*</span>
</label>
<input
type="password"
id="google_client_secret"
name="google_client_secret"
placeholder="GOCSPX-..."
autocomplete="off"
required
/>
</div>
<div class="analytics-hub-settings__field">
<label for="google_refresh_token">
<?php p($l->t('Refresh Token')); ?>
<span class="analytics-hub-settings__optional"><?php p($l->t('(Optional - will be retrieved via OAuth setup)')); ?></span>
</label>
<input
type="password"
id="google_refresh_token"
name="google_refresh_token"
placeholder="1//..."
autocomplete="off"
/>
<p class="analytics-hub-settings__hint">
<?php p($l->t('After OAuth consent, paste only the refresh token here. The access token is refreshed automatically each run.')); ?>
</p>
</div>
</div>
<!-- Anthropic Claude API Configuration -->
<div class="analytics-hub-settings__section">
<h3><?php p($l->t('Anthropic Claude API')); ?></h3>
<div class="analytics-hub-settings__field">
<label for="anthropic_api_key">
<?php p($l->t('API Key')); ?>
<span class="analytics-hub-settings__required">*</span>
</label>
<input
type="password"
id="anthropic_api_key"
name="anthropic_api_key"
value="<?php p($_['anthropic_api_key_masked']); ?>"
placeholder="sk-ant-..."
autocomplete="off"
required
/>
<p class="analytics-hub-settings__hint">
<?php p($l->t('Enter your Anthropic API key for AI-powered report generation.')); ?>
</p>
<p class="analytics-hub-settings__hint">
<?php p($l->t('Model: claude-sonnet-4-5-20250929 (cost-effective)')); ?>
</p>
<p class="analytics-hub-settings__hint">
<?php p($l->t('Cost: ~$0.015 per report (3K tokens)')); ?>
</p>
</div>
</div>
<!-- Actions -->
<div class="analytics-hub-settings__actions">
<button id="analytics-hub-save" class="primary">
<?php p($l->t('Save Configuration')); ?>
</button>
<button id="analytics-hub-cancel" class="secondary">
<?php p($l->t('Cancel')); ?>
</button>
</div>
</form>
<!-- Status Information -->
<div class="analytics-hub-settings__status">
<h3><?php p($l->t('App Information')); ?></h3>
<p><strong><?php p($l->t('App Name')); ?>:</strong> <?php p($_['app_name']); ?></p>
<p><strong><?php p($l->t('Version')); ?>:</strong> <?php p($_['version']); ?></p>
<p><strong><?php p($l->t('Google Analytics')); ?>:</strong>
<?php echo $_['is_ga_configured'] ? '✅ Configured' : '❌ Not configured'; ?>
</p>
<p><strong><?php p($l->t('LLM Service')); ?>:</strong>
<?php echo $_['is_llm_configured'] ? '✅ Configured' : '❌ Not configured'; ?></p>
<p><strong><?php p($l->t('Overall Status')); ?>:</strong>
<?php echo $_['is_configured'] ? '✅ Ready' : '⚠️ Configuration Required'; ?>
</p>
</div>
</div>