- Docker deployment ready
- Content aggregation and filtering
- User authentication
- Polling service for updates
🤖 Generated with Claude Code
367 lines
13 KiB
HTML
367 lines
13 KiB
HTML
<!DOCTYPE html>
|
|
<html lang="en">
|
|
<head>
|
|
<meta charset="UTF-8">
|
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
<title>Polling Management - Admin - BalanceBoard</title>
|
|
<link rel="stylesheet" href="{{ url_for('serve_theme', filename='modern-card-ui/styles.css') }}">
|
|
<style>
|
|
.admin-container {
|
|
max-width: 1400px;
|
|
margin: 0 auto;
|
|
padding: 24px;
|
|
}
|
|
|
|
.admin-header {
|
|
background: linear-gradient(135deg, var(--primary-dark) 0%, #2a5068 100%);
|
|
color: white;
|
|
padding: 32px;
|
|
border-radius: 12px;
|
|
margin-bottom: 24px;
|
|
}
|
|
|
|
.status-badge {
|
|
display: inline-block;
|
|
padding: 4px 12px;
|
|
border-radius: 12px;
|
|
font-size: 0.85rem;
|
|
font-weight: 500;
|
|
}
|
|
|
|
.status-enabled {
|
|
background: #d4edda;
|
|
color: #155724;
|
|
}
|
|
|
|
.status-disabled {
|
|
background: #f8d7da;
|
|
color: #721c24;
|
|
}
|
|
|
|
.status-success {
|
|
background: #d4edda;
|
|
color: #155724;
|
|
}
|
|
|
|
.status-error {
|
|
background: #f8d7da;
|
|
color: #721c24;
|
|
}
|
|
|
|
.source-card {
|
|
background: var(--surface-color);
|
|
border: 1px solid var(--divider-color);
|
|
border-radius: 12px;
|
|
padding: 20px;
|
|
margin-bottom: 16px;
|
|
}
|
|
|
|
.source-header {
|
|
display: flex;
|
|
justify-content: space-between;
|
|
align-items: center;
|
|
margin-bottom: 16px;
|
|
}
|
|
|
|
.source-title {
|
|
font-size: 1.2rem;
|
|
font-weight: 600;
|
|
color: var(--text-primary);
|
|
}
|
|
|
|
.source-meta {
|
|
display: grid;
|
|
grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
|
|
gap: 16px;
|
|
margin-bottom: 16px;
|
|
}
|
|
|
|
.meta-item {
|
|
display: flex;
|
|
flex-direction: column;
|
|
}
|
|
|
|
.meta-label {
|
|
font-size: 0.85rem;
|
|
color: var(--text-secondary);
|
|
margin-bottom: 4px;
|
|
}
|
|
|
|
.meta-value {
|
|
font-weight: 500;
|
|
color: var(--text-primary);
|
|
}
|
|
|
|
.source-actions {
|
|
display: flex;
|
|
gap: 8px;
|
|
flex-wrap: wrap;
|
|
}
|
|
|
|
.btn {
|
|
padding: 8px 16px;
|
|
border: none;
|
|
border-radius: 6px;
|
|
cursor: pointer;
|
|
font-weight: 500;
|
|
transition: all 0.2s;
|
|
}
|
|
|
|
.btn-primary {
|
|
background: var(--primary-color);
|
|
color: white;
|
|
}
|
|
|
|
.btn-primary:hover {
|
|
background: var(--primary-dark);
|
|
}
|
|
|
|
.btn-secondary {
|
|
background: var(--divider-color);
|
|
color: var(--text-primary);
|
|
}
|
|
|
|
.btn-secondary:hover {
|
|
background: #d0d0d0;
|
|
}
|
|
|
|
.btn-danger {
|
|
background: #dc3545;
|
|
color: white;
|
|
}
|
|
|
|
.btn-danger:hover {
|
|
background: #c82333;
|
|
}
|
|
|
|
.add-source-form {
|
|
background: var(--surface-color);
|
|
border: 2px dashed var(--divider-color);
|
|
border-radius: 12px;
|
|
padding: 24px;
|
|
margin-bottom: 24px;
|
|
}
|
|
|
|
.form-group {
|
|
margin-bottom: 16px;
|
|
}
|
|
|
|
.form-label {
|
|
display: block;
|
|
margin-bottom: 8px;
|
|
font-weight: 500;
|
|
color: var(--text-primary);
|
|
}
|
|
|
|
.form-input, .form-select {
|
|
width: 100%;
|
|
padding: 10px;
|
|
border: 1px solid var(--divider-color);
|
|
border-radius: 6px;
|
|
font-size: 1rem;
|
|
}
|
|
|
|
.scheduler-status {
|
|
background: var(--surface-color);
|
|
border: 1px solid var(--divider-color);
|
|
border-radius: 12px;
|
|
padding: 16px;
|
|
margin-bottom: 24px;
|
|
}
|
|
|
|
.no-sources {
|
|
text-align: center;
|
|
padding: 48px;
|
|
color: var(--text-secondary);
|
|
}
|
|
</style>
|
|
</head>
|
|
<body>
|
|
<div class="admin-container">
|
|
<div class="admin-header">
|
|
<h1>📡 Polling Management</h1>
|
|
<p>Configure automatic data collection from content sources</p>
|
|
</div>
|
|
|
|
{% with messages = get_flashed_messages(with_categories=true) %}
|
|
{% if messages %}
|
|
{% for category, message in messages %}
|
|
<div class="alert alert-{{ category }}">{{ message }}</div>
|
|
{% endfor %}
|
|
{% endif %}
|
|
{% endwith %}
|
|
|
|
<!-- Scheduler Status -->
|
|
<div class="scheduler-status">
|
|
<h3>Scheduler Status</h3>
|
|
<p><strong>Status:</strong>
|
|
{% if scheduler_status.running %}
|
|
<span class="status-badge status-enabled">Running</span>
|
|
{% else %}
|
|
<span class="status-badge status-disabled">Stopped</span>
|
|
{% endif %}
|
|
</p>
|
|
<p><strong>Active Jobs:</strong> {{ scheduler_status.jobs|length }}</p>
|
|
</div>
|
|
|
|
<!-- Add New Source Form -->
|
|
<div class="add-source-form">
|
|
<h3>Add New Source</h3>
|
|
<form action="{{ url_for('admin_polling_add') }}" method="POST">
|
|
<div class="form-group">
|
|
<label class="form-label" for="platform">Platform</label>
|
|
<select class="form-select" name="platform" id="platform" required onchange="updateSourceOptions()">
|
|
<option value="">Select platform...</option>
|
|
{% for platform_id, platform_data in platform_config.platforms.items() %}
|
|
<option value="{{ platform_id }}">{{ platform_data.name }}</option>
|
|
{% endfor %}
|
|
</select>
|
|
</div>
|
|
|
|
<div class="form-group">
|
|
<label class="form-label" for="source_id">Source</label>
|
|
<select class="form-select" name="source_id" id="source_id" required onchange="updateDisplayName()">
|
|
<option value="">Select source...</option>
|
|
</select>
|
|
</div>
|
|
|
|
<div class="form-group">
|
|
<label class="form-label" for="display_name">Display Name</label>
|
|
<input type="text" class="form-input" name="display_name" id="display_name" required>
|
|
</div>
|
|
|
|
<div class="form-group">
|
|
<label class="form-label" for="poll_interval">Poll Interval (minutes)</label>
|
|
<input type="number" class="form-input" name="poll_interval" id="poll_interval" value="60" min="5" required>
|
|
</div>
|
|
|
|
<button type="submit" class="btn btn-primary">Add Source</button>
|
|
</form>
|
|
</div>
|
|
|
|
<!-- Existing Sources -->
|
|
<h3>Configured Sources ({{ sources|length }})</h3>
|
|
|
|
{% if sources %}
|
|
{% for source in sources %}
|
|
<div class="source-card">
|
|
<div class="source-header">
|
|
<div>
|
|
<div class="source-title">{{ source.display_name }}</div>
|
|
<small>{{ source.platform }}:{{ source.source_id }}</small>
|
|
</div>
|
|
<div>
|
|
{% if source.enabled %}
|
|
<span class="status-badge status-enabled">Enabled</span>
|
|
{% else %}
|
|
<span class="status-badge status-disabled">Disabled</span>
|
|
{% endif %}
|
|
</div>
|
|
</div>
|
|
|
|
<div class="source-meta">
|
|
<div class="meta-item">
|
|
<span class="meta-label">Poll Interval</span>
|
|
<span class="meta-value">{{ source.poll_interval_minutes }} minutes</span>
|
|
</div>
|
|
<div class="meta-item">
|
|
<span class="meta-label">Last Poll</span>
|
|
<span class="meta-value">
|
|
{% if source.last_poll_time %}
|
|
{{ source.last_poll_time.strftime('%Y-%m-%d %H:%M:%S') }}
|
|
{% else %}
|
|
Never
|
|
{% endif %}
|
|
</span>
|
|
</div>
|
|
<div class="meta-item">
|
|
<span class="meta-label">Status</span>
|
|
<span class="meta-value">
|
|
{% if source.last_poll_status == 'success' %}
|
|
<span class="status-badge status-success">Success</span>
|
|
{% elif source.last_poll_status == 'error' %}
|
|
<span class="status-badge status-error">Error</span>
|
|
{% else %}
|
|
<span class="status-badge">{{ source.last_poll_status or 'N/A' }}</span>
|
|
{% endif %}
|
|
</span>
|
|
</div>
|
|
<div class="meta-item">
|
|
<span class="meta-label">Posts Collected</span>
|
|
<span class="meta-value">{{ source.posts_collected }}</span>
|
|
</div>
|
|
</div>
|
|
|
|
{% if source.last_poll_error %}
|
|
<div style="background: #fff3cd; padding: 12px; border-radius: 6px; margin-bottom: 16px;">
|
|
<strong>Last Error:</strong> {{ source.last_poll_error }}
|
|
</div>
|
|
{% endif %}
|
|
|
|
<div class="source-actions">
|
|
<form action="{{ url_for('admin_polling_toggle', source_id=source.id) }}" method="POST" style="display: inline;">
|
|
<button type="submit" class="btn btn-secondary">
|
|
{% if source.enabled %}Disable{% else %}Enable{% endif %}
|
|
</button>
|
|
</form>
|
|
|
|
<form action="{{ url_for('admin_polling_poll_now', source_id=source.id) }}" method="POST" style="display: inline;">
|
|
<button type="submit" class="btn btn-primary">Poll Now</button>
|
|
</form>
|
|
|
|
<a href="{{ url_for('admin_polling_logs', source_id=source.id) }}" class="btn btn-secondary">View Logs</a>
|
|
|
|
<form action="{{ url_for('admin_polling_delete', source_id=source.id) }}" method="POST" style="display: inline;" onsubmit="return confirm('Are you sure you want to delete this source?');">
|
|
<button type="submit" class="btn btn-danger">Delete</button>
|
|
</form>
|
|
</div>
|
|
</div>
|
|
{% endfor %}
|
|
{% else %}
|
|
<div class="no-sources">
|
|
<p>No polling sources configured yet.</p>
|
|
<p>Add your first source above to start collecting content!</p>
|
|
</div>
|
|
{% endif %}
|
|
|
|
<div style="margin-top: 24px;">
|
|
<a href="{{ url_for('admin_panel') }}" class="btn btn-secondary">← Back to Admin Panel</a>
|
|
</div>
|
|
</div>
|
|
|
|
<script>
|
|
const platformConfig = {{ platform_config|tojson }};
|
|
|
|
function updateSourceOptions() {
|
|
const platformSelect = document.getElementById('platform');
|
|
const sourceSelect = document.getElementById('source_id');
|
|
const selectedPlatform = platformSelect.value;
|
|
|
|
// Clear existing options
|
|
sourceSelect.innerHTML = '<option value="">Select source...</option>';
|
|
|
|
if (selectedPlatform && platformConfig.platforms[selectedPlatform]) {
|
|
const communities = platformConfig.platforms[selectedPlatform].communities || [];
|
|
communities.forEach(community => {
|
|
const option = document.createElement('option');
|
|
option.value = community.id;
|
|
option.textContent = community.display_name || community.name;
|
|
option.dataset.displayName = community.display_name || community.name;
|
|
sourceSelect.appendChild(option);
|
|
});
|
|
}
|
|
}
|
|
|
|
function updateDisplayName() {
|
|
const sourceSelect = document.getElementById('source_id');
|
|
const displayNameInput = document.getElementById('display_name');
|
|
const selectedOption = sourceSelect.options[sourceSelect.selectedIndex];
|
|
|
|
if (selectedOption && selectedOption.dataset.displayName) {
|
|
displayNameInput.value = selectedOption.dataset.displayName;
|
|
}
|
|
}
|
|
</script>
|
|
</body>
|
|
</html>
|