Add edit modal and diverse polling settings UI
- Add Edit button for each poll source - Modal dialog for editing all source settings - Add max_posts, fetch_comments, priority fields to add form - Display source settings in source list - JavaScript modal management for editing 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
@@ -251,6 +251,35 @@
|
||||
</select>
|
||||
</div>
|
||||
|
||||
<div class="form-group">
|
||||
<label class="form-label" for="max_posts">Max Posts Per Poll</label>
|
||||
<select class="form-select" name="max_posts" id="max_posts">
|
||||
<option value="25">25 posts</option>
|
||||
<option value="50">50 posts</option>
|
||||
<option value="100" selected>100 posts</option>
|
||||
<option value="200">200 posts</option>
|
||||
<option value="500">500 posts</option>
|
||||
</select>
|
||||
</div>
|
||||
|
||||
<div class="form-group">
|
||||
<label class="form-label" for="fetch_comments">Fetch Comments</label>
|
||||
<select class="form-select" name="fetch_comments" id="fetch_comments">
|
||||
<option value="true" selected>Yes - Fetch comments</option>
|
||||
<option value="false">No - Posts only</option>
|
||||
</select>
|
||||
</div>
|
||||
|
||||
<div class="form-group">
|
||||
<label class="form-label" for="priority">Priority</label>
|
||||
<select class="form-select" name="priority" id="priority">
|
||||
<option value="low">Low</option>
|
||||
<option value="medium" selected>Medium</option>
|
||||
<option value="high">High</option>
|
||||
</select>
|
||||
<p class="help-text">Higher priority sources poll more reliably during load</p>
|
||||
</div>
|
||||
|
||||
<button type="submit" class="btn btn-primary">Add Source</button>
|
||||
</form>
|
||||
</div>
|
||||
@@ -315,6 +344,8 @@
|
||||
{% endif %}
|
||||
|
||||
<div class="source-actions">
|
||||
<button onclick="openEditModal('{{ source.id }}', '{{ source.display_name }}', {{ source.poll_interval_minutes }}, {{ source.max_posts or 100 }}, {{ 'true' if source.fetch_comments else 'false' }}, '{{ source.priority or 'medium' }}')" class="btn btn-secondary">⚙️ Edit</button>
|
||||
|
||||
<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 %}
|
||||
@@ -387,6 +418,85 @@
|
||||
sourceSelect.setAttribute('required', 'required');
|
||||
}
|
||||
});
|
||||
|
||||
function openEditModal(sourceId, displayName, interval, maxPosts, fetchComments, priority) {
|
||||
const modal = document.getElementById('edit-modal');
|
||||
if (!modal) {
|
||||
// Create modal HTML
|
||||
const modalHTML = `
|
||||
<div id="edit-modal" style="display: none; position: fixed; top: 0; left: 0; width: 100%; height: 100%; background: rgba(0,0,0,0.5); z-index: 1000;">
|
||||
<div style="position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%); background: white; padding: 24px; border-radius: 8px; max-width: 500px; width: 90%;">
|
||||
<h3>Edit Poll Source</h3>
|
||||
<form id="edit-form" action="" method="POST">
|
||||
<div class="form-group">
|
||||
<label>Display Name</label>
|
||||
<input type="text" name="display_name" id="edit_display_name" class="form-input" required>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label>Poll Interval</label>
|
||||
<select name="poll_interval" id="edit_interval" class="form-select">
|
||||
<option value="15">15 minutes</option>
|
||||
<option value="30">30 minutes</option>
|
||||
<option value="60">1 hour</option>
|
||||
<option value="120">2 hours</option>
|
||||
<option value="240">4 hours</option>
|
||||
<option value="360">6 hours</option>
|
||||
<option value="720">12 hours</option>
|
||||
<option value="1440">24 hours</option>
|
||||
</select>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label>Max Posts</label>
|
||||
<select name="max_posts" id="edit_max_posts" class="form-select">
|
||||
<option value="25">25 posts</option>
|
||||
<option value="50">50 posts</option>
|
||||
<option value="100">100 posts</option>
|
||||
<option value="200">200 posts</option>
|
||||
<option value="500">500 posts</option>
|
||||
</select>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label>Fetch Comments</label>
|
||||
<select name="fetch_comments" id="edit_fetch_comments" class="form-select">
|
||||
<option value="true">Yes</option>
|
||||
<option value="false">No</option>
|
||||
</select>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label>Priority</label>
|
||||
<select name="priority" id="edit_priority" class="form-select">
|
||||
<option value="low">Low</option>
|
||||
<option value="medium">Medium</option>
|
||||
<option value="high">High</option>
|
||||
</select>
|
||||
</div>
|
||||
<div style="display: flex; gap: 8px; margin-top: 16px;">
|
||||
<button type="submit" class="btn btn-primary">Save Changes</button>
|
||||
<button type="button" onclick="closeEditModal()" class="btn btn-secondary">Cancel</button>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
`;
|
||||
document.body.insertAdjacentHTML('beforeend', modalHTML);
|
||||
}
|
||||
|
||||
// Fill form with current values
|
||||
const modal2 = document.getElementById('edit-modal');
|
||||
const form = document.getElementById('edit-form');
|
||||
form.action = `/admin/polling/${sourceId}/update`;
|
||||
document.getElementById('edit_display_name').value = displayName;
|
||||
document.getElementById('edit_interval').value = interval;
|
||||
document.getElementById('edit_max_posts').value = maxPosts;
|
||||
document.getElementById('edit_fetch_comments').value = fetchComments;
|
||||
document.getElementById('edit_priority').value = priority;
|
||||
|
||||
modal2.style.display = 'block';
|
||||
}
|
||||
|
||||
function closeEditModal() {
|
||||
document.getElementById('edit-modal').style.display = 'none';
|
||||
}
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
|
||||
Reference in New Issue
Block a user