update data purging, re-enable channel selection
This commit is contained in:
+17
-7
@@ -118,6 +118,11 @@
|
||||
<select id="message-from">
|
||||
<option value="474572292">!1c496604</option>
|
||||
</select>
|
||||
<select id="message-channel">
|
||||
<option value="0">LongFast (public)</option>
|
||||
<option value="1">Aether (private)</option>
|
||||
<option value="2">Other (2)</option>
|
||||
</select>
|
||||
<button type="submit" class="btn btn-primary">Send</button>
|
||||
</div>
|
||||
</form>
|
||||
@@ -159,13 +164,18 @@
|
||||
<p>Purge old data from the database to free up space.</p>
|
||||
<form id="purge-form" class="settings-form">
|
||||
<div class="form-group">
|
||||
<label for="purge-days">Keep data from the last:</label>
|
||||
<select id="purge-days">
|
||||
<option value="7">7 days</option>
|
||||
<option value="14">14 days</option>
|
||||
<option value="30" selected>30 days</option>
|
||||
<option value="60">60 days</option>
|
||||
<option value="90">90 days</option>
|
||||
<label for="purge-hours">Keep data from the last:</label>
|
||||
<select id="purge-hours">
|
||||
<option value="1">1 hour</option>
|
||||
<option value="6">6 hours</option>
|
||||
<option value="12">12 hours</option>
|
||||
<option value="24">1 day</option>
|
||||
<option value="72">3 days</option>
|
||||
<option value="168">7 days</option>
|
||||
<option value="336">14 days</option>
|
||||
<option value="720" selected>30 days</option>
|
||||
<option value="1440">60 days</option>
|
||||
<option value="2160">90 days</option>
|
||||
</select>
|
||||
</div>
|
||||
<button type="submit" class="btn btn-danger">Purge Old Data</button>
|
||||
|
||||
+18
-8
@@ -173,17 +173,17 @@ const api = {
|
||||
return this.request(`/api/messages?limit=${limit}`);
|
||||
},
|
||||
|
||||
async sendMessage(from, text) {
|
||||
async sendMessage(from, text, channel) {
|
||||
return this.request('/api/messages/send', {
|
||||
method: 'POST',
|
||||
body: JSON.stringify({ text, from })
|
||||
body: JSON.stringify({ from, text, channel })
|
||||
});
|
||||
},
|
||||
|
||||
async purgeData(days) {
|
||||
async purgeData(hours) {
|
||||
return this.request('/api/purge', {
|
||||
method: 'POST',
|
||||
body: JSON.stringify({ days })
|
||||
body: JSON.stringify({ hours })
|
||||
});
|
||||
},
|
||||
|
||||
@@ -547,9 +547,10 @@ document.getElementById('send-message-form')?.addEventListener('submit', async (
|
||||
|
||||
const text = document.getElementById('message-text').value;
|
||||
const from = parseInt(document.getElementById('message-from').value);
|
||||
const channel = parseInt(document.getElementById('message-channel').value);
|
||||
|
||||
try {
|
||||
await api.sendMessage(text, from);
|
||||
await api.sendMessage(from, text, channel);
|
||||
document.getElementById('message-text').value = '';
|
||||
|
||||
// Reload messages after a short delay
|
||||
@@ -1045,14 +1046,23 @@ document.getElementById('refresh-map-btn')?.addEventListener('click', loadMap);
|
||||
document.getElementById('purge-form')?.addEventListener('submit', async (e) => {
|
||||
e.preventDefault();
|
||||
|
||||
const days = parseInt(document.getElementById('purge-days').value);
|
||||
const hours = parseInt(document.getElementById('purge-hours').value);
|
||||
|
||||
if (!confirm(`Are you sure you want to delete data older than ${days} days? This cannot be undone.`)) {
|
||||
// Format time period for display
|
||||
let timePeriod;
|
||||
if (hours < 24) {
|
||||
timePeriod = `${hours} hour${hours !== 1 ? 's' : ''}`;
|
||||
} else {
|
||||
const days = hours / 24;
|
||||
timePeriod = `${days} day${days !== 1 ? 's' : ''}`;
|
||||
}
|
||||
|
||||
if (!confirm(`Are you sure you want to delete data older than ${timePeriod}? This cannot be undone.`)) {
|
||||
return;
|
||||
}
|
||||
|
||||
try {
|
||||
const result = await api.purgeData(days);
|
||||
const result = await api.purgeData(hours);
|
||||
alert(`Successfully purged:\n${result.deleted.messages} messages\n${result.deleted.positions} positions\n${result.deleted.telemetry} telemetry records`);
|
||||
|
||||
// Reload stats
|
||||
|
||||
Reference in New Issue
Block a user