mirror of
https://github.com/agessaman/meshcore-bot.git
synced 2026-08-27 21:10:13 +00:00
remove purging template stub
This commit is contained in:
@@ -153,10 +153,6 @@ class BotDataViewer:
|
||||
"""Cache management page"""
|
||||
return render_template('cache.html')
|
||||
|
||||
@self.app.route('/purging')
|
||||
def purging():
|
||||
"""Purging log page"""
|
||||
return render_template('purging.html')
|
||||
|
||||
@self.app.route('/stats')
|
||||
def stats():
|
||||
@@ -232,15 +228,6 @@ class BotDataViewer:
|
||||
self.logger.error(f"Error optimizing database: {e}")
|
||||
return jsonify({'success': False, 'error': str(e)}), 500
|
||||
|
||||
@self.app.route('/api/purging')
|
||||
def api_purging():
|
||||
"""Get purging log data"""
|
||||
try:
|
||||
purging = self._get_purging_data()
|
||||
return jsonify(purging)
|
||||
except Exception as e:
|
||||
self.logger.error(f"Error getting purging: {e}")
|
||||
return jsonify({'error': str(e)}), 500
|
||||
|
||||
@self.app.route('/api/stream_data', methods=['POST'])
|
||||
def api_stream_data():
|
||||
@@ -875,7 +862,6 @@ class BotDataViewer:
|
||||
'message_stats': 'Message statistics and analytics',
|
||||
'command_stats': 'Command execution statistics',
|
||||
'path_stats': 'Network path statistics',
|
||||
'purging_log': 'Repeater purging activity log',
|
||||
'geocoding_cache': 'Geocoding service cache',
|
||||
'generic_cache': 'General purpose cache storage'
|
||||
}
|
||||
@@ -1052,34 +1038,6 @@ class BotDataViewer:
|
||||
self.logger.error(f"Error getting cache data: {e}")
|
||||
return {'error': str(e)}
|
||||
|
||||
def _get_purging_data(self):
|
||||
"""Get purging log data"""
|
||||
try:
|
||||
conn = self._get_db_connection()
|
||||
cursor = conn.cursor()
|
||||
|
||||
# Get recent purging activity
|
||||
cursor.execute("""
|
||||
SELECT timestamp, action, details, user_id
|
||||
FROM adverts
|
||||
WHERE timestamp > datetime('now', '-7 days')
|
||||
ORDER BY timestamp DESC
|
||||
LIMIT 100
|
||||
""")
|
||||
|
||||
purging = []
|
||||
for row in cursor.fetchall():
|
||||
purging.append({
|
||||
'timestamp': row['timestamp'],
|
||||
'action': row.get('action', 'unknown'),
|
||||
'details': row.get('details', ''),
|
||||
'user_id': row['user_id']
|
||||
})
|
||||
|
||||
return {'purging': purging}
|
||||
except Exception as e:
|
||||
self.logger.error(f"Error getting purging data: {e}")
|
||||
return {'error': str(e)}
|
||||
|
||||
def _get_bot_uptime(self):
|
||||
"""Get bot uptime in seconds from database"""
|
||||
|
||||
@@ -146,11 +146,6 @@
|
||||
<i class="fas fa-database"></i> Cache
|
||||
</a>
|
||||
</li>
|
||||
<li class="nav-item">
|
||||
<a class="nav-link" href="/purging">
|
||||
<i class="fas fa-trash"></i> Purging
|
||||
</a>
|
||||
</li>
|
||||
</ul>
|
||||
|
||||
<!-- Connection Status -->
|
||||
|
||||
@@ -1,345 +0,0 @@
|
||||
{% extends "base.html" %}
|
||||
|
||||
{% block title %}Purging Log - MeshCore Bot Data Viewer{% endblock %}
|
||||
|
||||
{% block content %}
|
||||
<div class="row">
|
||||
<div class="col-12">
|
||||
<h1 class="mb-4">
|
||||
<i class="fas fa-trash"></i> Purging Log
|
||||
</h1>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Purging Statistics -->
|
||||
<div class="row mb-4">
|
||||
<div class="col-md-3">
|
||||
<div class="card">
|
||||
<div class="card-header">
|
||||
<i class="fas fa-calendar"></i> Last 7 Days
|
||||
</div>
|
||||
<div class="card-body">
|
||||
<h3 id="recent-purging">0</h3>
|
||||
<small class="text-muted">Purging events</small>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="col-md-3">
|
||||
<div class="card">
|
||||
<div class="card-header">
|
||||
<i class="fas fa-clock"></i> Recent Activity
|
||||
</div>
|
||||
<div class="card-body">
|
||||
<h3 id="recent-activity">0</h3>
|
||||
<small class="text-muted">Last 24 hours</small>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="col-md-3">
|
||||
<div class="card">
|
||||
<div class="card-header">
|
||||
<i class="fas fa-users"></i> Affected Users
|
||||
</div>
|
||||
<div class="card-body">
|
||||
<h3 id="affected-users">0</h3>
|
||||
<small class="text-muted">Unique users</small>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="col-md-3">
|
||||
<div class="card">
|
||||
<div class="card-header">
|
||||
<i class="fas fa-chart-line"></i> Purging Trend
|
||||
</div>
|
||||
<div class="card-body">
|
||||
<div id="purging-trend">
|
||||
<div class="loading">Loading...</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Purging Controls -->
|
||||
<div class="row mb-4">
|
||||
<div class="col-12">
|
||||
<div class="card">
|
||||
<div class="card-header">
|
||||
<i class="fas fa-cog"></i> Purging Operations
|
||||
</div>
|
||||
<div class="card-body">
|
||||
<div class="btn-group" role="group">
|
||||
<button class="btn btn-primary" id="refresh-purging">
|
||||
<i class="fas fa-sync"></i> Refresh
|
||||
</button>
|
||||
<button class="btn btn-info" id="export-purging">
|
||||
<i class="fas fa-download"></i> Export
|
||||
</button>
|
||||
<button class="btn btn-warning" id="manual-purge">
|
||||
<i class="fas fa-broom"></i> Manual Purge
|
||||
</button>
|
||||
<button class="btn btn-danger" id="clear-purging">
|
||||
<i class="fas fa-trash"></i> Clear Log
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Purging Log Table -->
|
||||
<div class="row">
|
||||
<div class="col-12">
|
||||
<div class="card">
|
||||
<div class="card-header">
|
||||
<i class="fas fa-list"></i> Purging Log
|
||||
<div class="float-end">
|
||||
<small class="text-muted">Showing <span id="showing-count">0</span> entries</small>
|
||||
</div>
|
||||
</div>
|
||||
<div class="card-body">
|
||||
<div class="table-responsive">
|
||||
<table class="table table-striped table-hover">
|
||||
<thead class="table-dark">
|
||||
<tr>
|
||||
<th>Timestamp</th>
|
||||
<th>Action</th>
|
||||
<th>User ID</th>
|
||||
<th>Details</th>
|
||||
<th>Status</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody id="purging-table-body">
|
||||
<tr>
|
||||
<td colspan="5" class="text-center">
|
||||
<div class="loading">Loading purging log...</div>
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
{% endblock %}
|
||||
|
||||
{% block extra_js %}
|
||||
<script>
|
||||
class ModernPurgingManager {
|
||||
constructor() {
|
||||
this.purgingData = [];
|
||||
this.initializePurging();
|
||||
}
|
||||
|
||||
async initializePurging() {
|
||||
await this.loadPurgingData();
|
||||
this.setupEventHandlers();
|
||||
this.renderPurgingData();
|
||||
this.updateStatistics();
|
||||
}
|
||||
|
||||
async loadPurgingData() {
|
||||
try {
|
||||
const response = await fetch('/api/purging');
|
||||
const data = await response.json();
|
||||
|
||||
if (data.error) {
|
||||
this.showError('Failed to load purging data: ' + data.error);
|
||||
return;
|
||||
}
|
||||
|
||||
this.purgingData = data.purging || [];
|
||||
|
||||
} catch (error) {
|
||||
console.error('Error loading purging data:', error);
|
||||
this.showError('Failed to load purging data: ' + error.message);
|
||||
}
|
||||
}
|
||||
|
||||
setupEventHandlers() {
|
||||
document.getElementById('refresh-purging').addEventListener('click', () => {
|
||||
this.loadPurgingData().then(() => {
|
||||
this.renderPurgingData();
|
||||
this.updateStatistics();
|
||||
});
|
||||
});
|
||||
|
||||
document.getElementById('export-purging').addEventListener('click', () => {
|
||||
this.exportPurging();
|
||||
});
|
||||
|
||||
document.getElementById('manual-purge').addEventListener('click', () => {
|
||||
this.manualPurge();
|
||||
});
|
||||
|
||||
document.getElementById('clear-purging').addEventListener('click', () => {
|
||||
this.clearPurging();
|
||||
});
|
||||
}
|
||||
|
||||
renderPurgingData() {
|
||||
const tbody = document.getElementById('purging-table-body');
|
||||
|
||||
if (this.purgingData.length === 0) {
|
||||
tbody.innerHTML = `
|
||||
<tr>
|
||||
<td colspan="5" class="text-center text-muted">
|
||||
No purging data available
|
||||
</td>
|
||||
</tr>
|
||||
`;
|
||||
return;
|
||||
}
|
||||
|
||||
tbody.innerHTML = this.purgingData.map(entry => `
|
||||
<tr>
|
||||
<td>${this.formatTimestamp(entry.timestamp)}</td>
|
||||
<td><span class="badge bg-${this.getActionBadgeColor(entry.action)}">${entry.action || 'Unknown'}</span></td>
|
||||
<td><code>${entry.user_id || 'N/A'}</code></td>
|
||||
<td>${entry.details || 'No details'}</td>
|
||||
<td>${this.getStatusBadge(entry.timestamp)}</td>
|
||||
</tr>
|
||||
`).join('');
|
||||
|
||||
document.getElementById('showing-count').textContent = this.purgingData.length;
|
||||
}
|
||||
|
||||
updateStatistics() {
|
||||
const now = new Date();
|
||||
const sevenDaysAgo = new Date(now.getTime() - 7 * 24 * 60 * 60 * 1000);
|
||||
const oneDayAgo = new Date(now.getTime() - 24 * 60 * 60 * 1000);
|
||||
|
||||
const recentPurging = this.purgingData.filter(entry => {
|
||||
const entryDate = new Date(entry.timestamp);
|
||||
return entryDate >= sevenDaysAgo;
|
||||
}).length;
|
||||
|
||||
const recentActivity = this.purgingData.filter(entry => {
|
||||
const entryDate = new Date(entry.timestamp);
|
||||
return entryDate >= oneDayAgo;
|
||||
}).length;
|
||||
|
||||
const affectedUsers = new Set(
|
||||
this.purgingData.map(entry => entry.user_id).filter(userId => userId)
|
||||
).size;
|
||||
|
||||
document.getElementById('recent-purging').textContent = recentPurging;
|
||||
document.getElementById('recent-activity').textContent = recentActivity;
|
||||
document.getElementById('affected-users').textContent = affectedUsers;
|
||||
|
||||
// Update purging trend
|
||||
const trendElement = document.getElementById('purging-trend');
|
||||
const trendPercent = recentPurging > 0 ? Math.round((recentActivity / recentPurging) * 100) : 0;
|
||||
trendElement.innerHTML = `
|
||||
<h5>${trendPercent}%</h5>
|
||||
<small class="text-muted">Recent activity</small>
|
||||
`;
|
||||
}
|
||||
|
||||
formatTimestamp(timestamp) {
|
||||
if (!timestamp) return 'Unknown';
|
||||
|
||||
const date = new Date(timestamp);
|
||||
return date.toLocaleString();
|
||||
}
|
||||
|
||||
getActionBadgeColor(action) {
|
||||
switch (action?.toLowerCase()) {
|
||||
case 'delete':
|
||||
case 'remove':
|
||||
return 'danger';
|
||||
case 'clean':
|
||||
case 'purge':
|
||||
return 'warning';
|
||||
case 'archive':
|
||||
return 'info';
|
||||
default:
|
||||
return 'secondary';
|
||||
}
|
||||
}
|
||||
|
||||
getStatusBadge(timestamp) {
|
||||
if (!timestamp) return '<span class="badge bg-secondary">Unknown</span>';
|
||||
|
||||
const date = new Date(timestamp);
|
||||
const now = new Date();
|
||||
const diffMs = now - date;
|
||||
const diffHours = Math.floor(diffMs / (1000 * 60 * 60));
|
||||
const diffDays = Math.floor(diffHours / 24);
|
||||
|
||||
if (diffDays > 7) {
|
||||
return '<span class="badge bg-secondary">Old</span>';
|
||||
} else if (diffDays > 0) {
|
||||
return '<span class="badge bg-warning">Recent</span>';
|
||||
} else {
|
||||
return '<span class="badge bg-success">Today</span>';
|
||||
}
|
||||
}
|
||||
|
||||
exportPurging() {
|
||||
const csvContent = this.generatePurgingCSV();
|
||||
const blob = new Blob([csvContent], { type: 'text/csv' });
|
||||
const url = window.URL.createObjectURL(blob);
|
||||
const a = document.createElement('a');
|
||||
a.href = url;
|
||||
a.download = `purging_log_${new Date().toISOString().split('T')[0]}.csv`;
|
||||
a.click();
|
||||
window.URL.revokeObjectURL(url);
|
||||
}
|
||||
|
||||
generatePurgingCSV() {
|
||||
const headers = ['Timestamp', 'Action', 'User ID', 'Details'];
|
||||
const rows = this.purgingData.map(entry => [
|
||||
entry.timestamp || '',
|
||||
entry.action || '',
|
||||
entry.user_id || '',
|
||||
entry.details || ''
|
||||
]);
|
||||
|
||||
return [headers, ...rows].map(row =>
|
||||
row.map(field => `"${field}"`).join(',')
|
||||
).join('\n');
|
||||
}
|
||||
|
||||
manualPurge() {
|
||||
if (confirm('Are you sure you want to perform a manual purge? This action cannot be undone.')) {
|
||||
// Implementation would depend on backend API
|
||||
alert('Manual purge functionality would be implemented here');
|
||||
}
|
||||
}
|
||||
|
||||
clearPurging() {
|
||||
if (confirm('Are you sure you want to clear the purging log? This action cannot be undone.')) {
|
||||
// Implementation would depend on backend API
|
||||
alert('Clear purging log functionality would be implemented here');
|
||||
}
|
||||
}
|
||||
|
||||
showError(message) {
|
||||
const errorDiv = document.createElement('div');
|
||||
errorDiv.className = 'error';
|
||||
errorDiv.textContent = message;
|
||||
|
||||
const content = document.querySelector('.container-fluid');
|
||||
if (content) {
|
||||
content.insertBefore(errorDiv, content.firstChild);
|
||||
|
||||
setTimeout(() => {
|
||||
if (errorDiv.parentNode) {
|
||||
errorDiv.parentNode.removeChild(errorDiv);
|
||||
}
|
||||
}, 5000);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Initialize purging manager when page loads
|
||||
document.addEventListener('DOMContentLoaded', () => {
|
||||
window.purgingManager = new ModernPurgingManager();
|
||||
});
|
||||
</script>
|
||||
{% endblock %}
|
||||
Reference in New Issue
Block a user