1009 lines
45 KiB
HTML
1009 lines
45 KiB
HTML
{% extends "base.html" %}
|
|
|
|
{% block title %}Settings - Seismo Fleet Manager{% endblock %}
|
|
|
|
{% block content %}
|
|
<div class="mb-8">
|
|
<h1 class="text-3xl font-bold text-gray-900 dark:text-white">Settings</h1>
|
|
<p class="text-gray-600 dark:text-gray-400 mt-1">Configure application preferences and manage fleet data</p>
|
|
</div>
|
|
|
|
<!-- Tab Navigation -->
|
|
<div class="flex border-b border-gray-200 dark:border-gray-700 mb-6">
|
|
<button class="settings-tab active-settings-tab" data-tab="general" onclick="showTab('general')">
|
|
<svg class="w-4 h-4 inline-block mr-1" fill="none" stroke="currentColor" viewBox="0 0 24 24">
|
|
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M12 6V4m0 2a2 2 0 100 4m0-4a2 2 0 110 4m-6 8a2 2 0 100-4m0 4a2 2 0 110-4m0 4v2m0-6V4m6 6v10m6-2a2 2 0 100-4m0 4a2 2 0 110-4m0 4v2m0-6V4"></path>
|
|
</svg>
|
|
General
|
|
</button>
|
|
<button class="settings-tab" data-tab="data" onclick="showTab('data')">
|
|
<svg class="w-4 h-4 inline-block mr-1" fill="none" stroke="currentColor" viewBox="0 0 24 24">
|
|
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M7 16a4 4 0 01-.88-7.903A5 5 0 1115.9 6L16 6a5 5 0 011 9.9M15 13l-3-3m0 0l-3 3m3-3v12"></path>
|
|
</svg>
|
|
Data Management
|
|
</button>
|
|
<button class="settings-tab" data-tab="advanced" onclick="showTab('advanced')">
|
|
<svg class="w-4 h-4 inline-block mr-1" fill="none" stroke="currentColor" viewBox="0 0 24 24">
|
|
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M10.325 4.317c.426-1.756 2.924-1.756 3.35 0a1.724 1.724 0 002.573 1.066c1.543-.94 3.31.826 2.37 2.37a1.724 1.724 0 001.065 2.572c1.756.426 1.756 2.924 0 3.35a1.724 1.724 0 00-1.066 2.573c.94 1.543-.826 3.31-2.37 2.37a1.724 1.724 0 00-2.572 1.065c-.426 1.756-2.924 1.756-3.35 0a1.724 1.724 0 00-2.573-1.066c-1.543.94-3.31-.826-2.37-2.37a1.724 1.724 0 00-1.065-2.572c-1.756-.426-1.756-2.924 0-3.35a1.724 1.724 0 001.066-2.573c-.94-1.543.826-3.31 2.37-2.37.996.608 2.296.07 2.572-1.065z"></path>
|
|
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M15 12a3 3 0 11-6 0 3 3 0 016 0z"></path>
|
|
</svg>
|
|
Advanced
|
|
</button>
|
|
<button class="settings-tab text-red-600 dark:text-red-400" data-tab="danger" onclick="showTab('danger')">
|
|
<svg class="w-4 h-4 inline-block mr-1" fill="none" stroke="currentColor" viewBox="0 0 24 24">
|
|
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M12 9v2m0 4h.01m-6.938 4h13.856c1.54 0 2.502-1.667 1.732-3L13.732 4c-.77-1.333-2.694-1.333-3.464 0L3.34 16c-.77 1.333.192 3 1.732 3z"></path>
|
|
</svg>
|
|
Danger Zone
|
|
</button>
|
|
</div>
|
|
|
|
<!-- General Tab -->
|
|
<div id="general-tab" class="tab-content">
|
|
<div class="space-y-6">
|
|
<!-- Display Preferences Card -->
|
|
<div class="bg-white dark:bg-slate-800 rounded-xl shadow-lg p-6">
|
|
<h2 class="text-xl font-semibold text-gray-900 dark:text-white mb-4">Display Preferences</h2>
|
|
|
|
<div class="space-y-4">
|
|
<!-- Timezone -->
|
|
<div>
|
|
<label for="timezone-select" class="block text-sm font-medium text-gray-700 dark:text-gray-300 mb-2">
|
|
Timezone
|
|
</label>
|
|
<select id="timezone-select"
|
|
class="w-full max-w-md px-4 py-2 text-gray-900 dark:text-gray-100 bg-gray-50 dark:bg-gray-700 border border-gray-300 dark:border-gray-600 rounded-lg focus:outline-none focus:ring-2 focus:ring-seismo-orange">
|
|
<option value="America/New_York">Eastern Time (ET)</option>
|
|
<option value="America/Chicago">Central Time (CT)</option>
|
|
<option value="America/Denver">Mountain Time (MT)</option>
|
|
<option value="America/Los_Angeles">Pacific Time (PT)</option>
|
|
<option value="America/Anchorage">Alaska Time (AKT)</option>
|
|
<option value="Pacific/Honolulu">Hawaii Time (HT)</option>
|
|
<option value="UTC">UTC</option>
|
|
<option value="Europe/London">London (GMT/BST)</option>
|
|
<option value="Europe/Paris">Paris (CET/CEST)</option>
|
|
<option value="Asia/Tokyo">Tokyo (JST)</option>
|
|
<option value="Australia/Sydney">Sydney (AEST/AEDT)</option>
|
|
</select>
|
|
<p class="text-xs text-gray-500 dark:text-gray-400 mt-1">
|
|
All timestamps will be displayed in this timezone
|
|
</p>
|
|
</div>
|
|
|
|
<!-- Theme -->
|
|
<div>
|
|
<label class="block text-sm font-medium text-gray-700 dark:text-gray-300 mb-2">
|
|
Theme
|
|
</label>
|
|
<div class="flex gap-4">
|
|
<label class="flex items-center gap-2 cursor-pointer">
|
|
<input type="radio" name="theme" value="auto" class="w-4 h-4 text-seismo-orange focus:ring-seismo-orange">
|
|
<span class="text-sm text-gray-700 dark:text-gray-300">Auto (System)</span>
|
|
</label>
|
|
<label class="flex items-center gap-2 cursor-pointer">
|
|
<input type="radio" name="theme" value="light" class="w-4 h-4 text-seismo-orange focus:ring-seismo-orange">
|
|
<span class="text-sm text-gray-700 dark:text-gray-300">Light</span>
|
|
</label>
|
|
<label class="flex items-center gap-2 cursor-pointer">
|
|
<input type="radio" name="theme" value="dark" class="w-4 h-4 text-seismo-orange focus:ring-seismo-orange">
|
|
<span class="text-sm text-gray-700 dark:text-gray-300">Dark</span>
|
|
</label>
|
|
</div>
|
|
<p class="text-xs text-gray-500 dark:text-gray-400 mt-1">
|
|
Choose your preferred color scheme
|
|
</p>
|
|
</div>
|
|
|
|
<!-- Auto-refresh Interval -->
|
|
<div>
|
|
<label for="refresh-interval" class="block text-sm font-medium text-gray-700 dark:text-gray-300 mb-2">
|
|
Auto-Refresh Interval
|
|
</label>
|
|
<select id="refresh-interval"
|
|
class="w-full max-w-md px-4 py-2 text-gray-900 dark:text-gray-100 bg-gray-50 dark:bg-gray-700 border border-gray-300 dark:border-gray-600 rounded-lg focus:outline-none focus:ring-2 focus:ring-seismo-orange">
|
|
<option value="5">5 seconds</option>
|
|
<option value="10" selected>10 seconds</option>
|
|
<option value="30">30 seconds</option>
|
|
<option value="60">1 minute</option>
|
|
<option value="0">Disabled</option>
|
|
</select>
|
|
<p class="text-xs text-gray-500 dark:text-gray-400 mt-1">
|
|
How often the dashboard should refresh automatically
|
|
</p>
|
|
</div>
|
|
</div>
|
|
|
|
<button onclick="saveGeneralSettings()" class="mt-6 px-6 py-3 bg-seismo-orange hover:bg-orange-600 text-white rounded-lg transition-colors">
|
|
Save Changes
|
|
</button>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
<!-- Data Management Tab -->
|
|
<div id="data-tab" class="tab-content hidden">
|
|
<div class="space-y-6">
|
|
<!-- Export Section -->
|
|
<div class="bg-white dark:bg-slate-800 rounded-xl shadow-lg p-6">
|
|
<div class="flex items-start justify-between">
|
|
<div class="flex-1">
|
|
<h2 class="text-xl font-semibold text-gray-900 dark:text-white mb-2">Export Data</h2>
|
|
<p class="text-gray-600 dark:text-gray-400">
|
|
Download all roster data as CSV for backup or editing externally
|
|
</p>
|
|
</div>
|
|
<div>
|
|
<a href="/api/settings/export-csv"
|
|
class="px-6 py-3 bg-seismo-orange hover:bg-orange-600 text-white rounded-lg transition-colors inline-flex items-center gap-2">
|
|
<svg class="w-5 h-5" fill="none" stroke="currentColor" viewBox="0 0 24 24">
|
|
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M4 16v1a3 3 0 003 3h10a3 3 0 003-3v-1m-4-4l-4 4m0 0l-4-4m4 4V4"></path>
|
|
</svg>
|
|
Download CSV
|
|
</a>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
<!-- Import Section (Merge Mode Only) -->
|
|
<div class="bg-white dark:bg-slate-800 rounded-xl shadow-lg p-6">
|
|
<h2 class="text-xl font-semibold text-gray-900 dark:text-white mb-4">Import Data (Merge Mode)</h2>
|
|
|
|
<form id="importMergeForm" class="space-y-4">
|
|
<div>
|
|
<label class="block text-sm font-medium text-gray-700 dark:text-gray-300 mb-2">CSV File</label>
|
|
<input type="file" name="file" accept=".csv" required
|
|
class="block w-full text-sm text-gray-900 dark:text-white border border-gray-300 dark:border-gray-600 rounded-lg cursor-pointer bg-gray-50 dark:bg-slate-700 focus:outline-none">
|
|
<p class="text-xs text-gray-500 dark:text-gray-400 mt-1">
|
|
CSV must include column: unit_id (required). Existing units will be updated, new units will be added.
|
|
</p>
|
|
</div>
|
|
|
|
<div id="importMergeResult" class="hidden"></div>
|
|
|
|
<button type="submit" class="px-6 py-3 bg-seismo-orange hover:bg-orange-600 text-white rounded-lg transition-colors">
|
|
Import CSV
|
|
</button>
|
|
</form>
|
|
</div>
|
|
|
|
<!-- Roster Management Table -->
|
|
<div class="bg-white dark:bg-slate-800 rounded-xl shadow-lg p-6">
|
|
<div class="flex items-center justify-between mb-4">
|
|
<div>
|
|
<h2 class="text-xl font-semibold text-gray-900 dark:text-white">Roster Units</h2>
|
|
<p class="text-gray-600 dark:text-gray-400 text-sm mt-1">
|
|
Manage all units with inline editing and quick actions
|
|
</p>
|
|
</div>
|
|
<button onclick="refreshRosterTable()" class="px-4 py-2 text-seismo-orange hover:bg-orange-50 dark:hover:bg-orange-900/20 rounded-lg transition-colors">
|
|
<svg class="w-5 h-5" fill="none" stroke="currentColor" viewBox="0 0 24 24">
|
|
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M4 4v5h.582m15.356 2A8.001 8.001 0 004.582 9m0 0H9m11 11v-5h-.581m0 0a8.003 8.003 0 01-15.357-2m15.357 2H15"></path>
|
|
</svg>
|
|
</button>
|
|
</div>
|
|
|
|
<!-- Loading State -->
|
|
<div id="rosterTableLoading" class="text-center py-8">
|
|
<div class="inline-block animate-spin rounded-full h-8 w-8 border-b-2 border-seismo-orange"></div>
|
|
<p class="text-gray-600 dark:text-gray-400 mt-2">Loading roster units...</p>
|
|
</div>
|
|
|
|
<!-- Table Container -->
|
|
<div id="rosterTableContainer" class="hidden overflow-x-auto">
|
|
<table class="min-w-full divide-y divide-gray-200 dark:divide-gray-700">
|
|
<thead class="bg-gray-50 dark:bg-gray-700">
|
|
<tr>
|
|
<th class="px-4 py-3 text-left text-xs font-medium text-gray-500 dark:text-gray-300 uppercase">Unit ID</th>
|
|
<th class="px-4 py-3 text-left text-xs font-medium text-gray-500 dark:text-gray-300 uppercase">Type</th>
|
|
<th class="px-4 py-3 text-left text-xs font-medium text-gray-500 dark:text-gray-300 uppercase">Status</th>
|
|
<th class="px-4 py-3 text-left text-xs font-medium text-gray-500 dark:text-gray-300 uppercase">Note</th>
|
|
<th class="px-4 py-3 text-left text-xs font-medium text-gray-500 dark:text-gray-300 uppercase">Location</th>
|
|
<th class="px-4 py-3 text-right text-xs font-medium text-gray-500 dark:text-gray-300 uppercase">Actions</th>
|
|
</tr>
|
|
</thead>
|
|
<tbody id="rosterTableBody" class="bg-white dark:bg-slate-800 divide-y divide-gray-200 dark:divide-gray-700">
|
|
<!-- Rows will be inserted here by JavaScript -->
|
|
</tbody>
|
|
</table>
|
|
</div>
|
|
|
|
<!-- Empty State -->
|
|
<div id="rosterTableEmpty" class="hidden text-center py-8">
|
|
<svg class="mx-auto h-12 w-12 text-gray-400" fill="none" stroke="currentColor" viewBox="0 0 24 24">
|
|
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M20 13V6a2 2 0 00-2-2H6a2 2 0 00-2 2v7m16 0v5a2 2 0 01-2 2H6a2 2 0 01-2-2v-5m16 0h-2.586a1 1 0 00-.707.293l-2.414 2.414a1 1 0 01-.707.293h-3.172a1 1 0 01-.707-.293l-2.414-2.414A1 1 0 006.586 13H4"></path>
|
|
</svg>
|
|
<p class="text-gray-600 dark:text-gray-400 mt-2">No roster units found</p>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
<!-- Advanced Tab -->
|
|
<div id="advanced-tab" class="tab-content hidden">
|
|
<div class="space-y-6">
|
|
<!-- Warning Banner -->
|
|
<div class="bg-yellow-50 dark:bg-yellow-900/20 border-l-4 border-yellow-500 p-4">
|
|
<div class="flex">
|
|
<svg class="w-5 h-5 text-yellow-500 mr-2 flex-shrink-0" fill="none" stroke="currentColor" viewBox="0 0 24 24">
|
|
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M12 9v2m0 4h.01m-6.938 4h13.856c1.54 0 2.502-1.667 1.732-3L13.732 4c-.77-1.333-2.694-1.333-3.464 0L3.34 16c-.77 1.333.192 3 1.732 3z"></path>
|
|
</svg>
|
|
<div>
|
|
<p class="font-semibold text-yellow-800 dark:text-yellow-300">Advanced Settings</p>
|
|
<p class="text-sm text-yellow-700 dark:text-yellow-400 mt-1">These settings can affect system behavior. Change with caution.</p>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
<!-- CSV Import - Replace Mode -->
|
|
<div class="bg-white dark:bg-slate-800 rounded-xl shadow-lg p-6 border-2 border-yellow-200 dark:border-yellow-800">
|
|
<h2 class="text-xl font-semibold text-yellow-800 dark:text-yellow-300 mb-2">CSV Import - Replace Mode</h2>
|
|
<p class="text-sm text-gray-600 dark:text-gray-400 mb-4">
|
|
This will DELETE all existing roster units before importing.
|
|
</p>
|
|
|
|
<form id="importReplaceForm" class="space-y-4">
|
|
<div>
|
|
<label class="block text-sm font-medium text-gray-700 dark:text-gray-300 mb-2">CSV File</label>
|
|
<input type="file" name="file" accept=".csv" required
|
|
class="block w-full text-sm text-gray-900 dark:text-white border border-gray-300 dark:border-gray-600 rounded-lg cursor-pointer bg-gray-50 dark:bg-slate-700 focus:outline-none">
|
|
<p class="text-xs text-gray-500 dark:text-gray-400 mt-1">
|
|
All roster data will be replaced with this CSV file
|
|
</p>
|
|
</div>
|
|
|
|
<div id="importReplaceResult" class="hidden"></div>
|
|
|
|
<button type="submit" class="px-6 py-3 bg-yellow-600 hover:bg-yellow-700 text-white rounded-lg transition-colors">
|
|
Replace All Roster Data
|
|
</button>
|
|
</form>
|
|
</div>
|
|
|
|
<!-- Status Thresholds -->
|
|
<div class="bg-white dark:bg-slate-800 rounded-xl shadow-lg p-6">
|
|
<h2 class="text-xl font-semibold text-gray-900 dark:text-white mb-4">Status Thresholds</h2>
|
|
|
|
<div class="space-y-4">
|
|
<div>
|
|
<label for="ok-threshold" class="block text-sm font-medium text-gray-700 dark:text-gray-300 mb-2">
|
|
OK Threshold (hours)
|
|
</label>
|
|
<input type="number" id="ok-threshold" min="1" max="24"
|
|
class="w-full max-w-md px-4 py-2 text-gray-900 dark:text-gray-100 bg-gray-50 dark:bg-gray-700 border border-gray-300 dark:border-gray-600 rounded-lg focus:outline-none focus:ring-2 focus:ring-seismo-orange">
|
|
<p class="text-xs text-gray-500 dark:text-gray-400 mt-1">
|
|
Units are OK if last seen within this many hours
|
|
</p>
|
|
</div>
|
|
|
|
<div>
|
|
<label for="pending-threshold" class="block text-sm font-medium text-gray-700 dark:text-gray-300 mb-2">
|
|
Pending Threshold (hours)
|
|
</label>
|
|
<input type="number" id="pending-threshold" min="1" max="48"
|
|
class="w-full max-w-md px-4 py-2 text-gray-900 dark:text-gray-100 bg-gray-50 dark:bg-gray-700 border border-gray-300 dark:border-gray-600 rounded-lg focus:outline-none focus:ring-2 focus:ring-seismo-orange">
|
|
<p class="text-xs text-gray-500 dark:text-gray-400 mt-1">
|
|
Units are Pending if last seen within this many hours (units exceeding this are Missing)
|
|
</p>
|
|
</div>
|
|
</div>
|
|
|
|
<button onclick="saveStatusThresholds()" class="mt-6 px-6 py-3 bg-seismo-orange hover:bg-orange-600 text-white rounded-lg transition-colors">
|
|
Save Thresholds
|
|
</button>
|
|
</div>
|
|
|
|
<!-- Calibration Defaults -->
|
|
<div class="bg-white dark:bg-slate-800 rounded-xl shadow-lg p-6">
|
|
<h2 class="text-xl font-semibold text-gray-900 dark:text-white mb-4">Calibration Defaults</h2>
|
|
|
|
<div class="space-y-4">
|
|
<div>
|
|
<label for="cal-interval" class="block text-sm font-medium text-gray-700 dark:text-gray-300 mb-2">
|
|
Calibration Interval (days)
|
|
</label>
|
|
<input type="number" id="cal-interval" min="1"
|
|
class="w-full max-w-md px-4 py-2 text-gray-900 dark:text-gray-100 bg-gray-50 dark:bg-gray-700 border border-gray-300 dark:border-gray-600 rounded-lg focus:outline-none focus:ring-2 focus:ring-seismo-orange">
|
|
<p class="text-xs text-gray-500 dark:text-gray-400 mt-1">
|
|
Default interval between calibrations
|
|
</p>
|
|
</div>
|
|
|
|
<div>
|
|
<label for="cal-warning" class="block text-sm font-medium text-gray-700 dark:text-gray-300 mb-2">
|
|
Warning Threshold (days before due)
|
|
</label>
|
|
<input type="number" id="cal-warning" min="1"
|
|
class="w-full max-w-md px-4 py-2 text-gray-900 dark:text-gray-100 bg-gray-50 dark:bg-gray-700 border border-gray-300 dark:border-gray-600 rounded-lg focus:outline-none focus:ring-2 focus:ring-seismo-orange">
|
|
<p class="text-xs text-gray-500 dark:text-gray-400 mt-1">
|
|
Show warnings when calibration is due within this many days
|
|
</p>
|
|
</div>
|
|
</div>
|
|
|
|
<button onclick="saveCalibrationDefaults()" class="mt-6 px-6 py-3 bg-seismo-orange hover:bg-orange-600 text-white rounded-lg transition-colors">
|
|
Save Defaults
|
|
</button>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
<!-- Danger Zone Tab -->
|
|
<div id="danger-tab" class="tab-content hidden">
|
|
<div class="space-y-6">
|
|
<!-- Warning Banner -->
|
|
<div class="bg-red-50 dark:bg-red-900/20 border-l-4 border-red-500 p-4">
|
|
<div class="flex">
|
|
<svg class="w-5 h-5 text-red-500 mr-2 flex-shrink-0" fill="none" stroke="currentColor" viewBox="0 0 24 24">
|
|
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M12 9v2m0 4h.01m-6.938 4h13.856c1.54 0 2.502-1.667 1.732-3L13.732 4c-.77-1.333-2.694-1.333-3.464 0L3.34 16c-.77 1.333.192 3 1.732 3z"></path>
|
|
</svg>
|
|
<div>
|
|
<p class="font-semibold text-red-800 dark:text-red-300">Danger Zone</p>
|
|
<p class="text-sm text-red-700 dark:text-red-400 mt-1">These operations are PERMANENT and CANNOT be undone. Proceed with extreme caution.</p>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
<!-- Clear All Data -->
|
|
<div class="border-2 border-red-300 dark:border-red-800 rounded-lg p-6 bg-white dark:bg-slate-800">
|
|
<div class="flex justify-between items-start">
|
|
<div>
|
|
<h3 class="font-semibold text-red-600 dark:text-red-400 text-lg">Clear All Data</h3>
|
|
<p class="text-sm text-gray-600 dark:text-gray-400 mt-1">
|
|
Deletes roster units, emitters, and ignored units. Everything will be lost.
|
|
</p>
|
|
</div>
|
|
<button onclick="confirmClearAll()" class="px-4 py-2 bg-red-600 hover:bg-red-700 text-white rounded-lg transition-colors whitespace-nowrap">
|
|
Clear All
|
|
</button>
|
|
</div>
|
|
</div>
|
|
|
|
<!-- Clear Roster Only -->
|
|
<div class="border border-red-200 dark:border-red-800 rounded-lg p-6 bg-white dark:bg-slate-800">
|
|
<div class="flex justify-between items-start">
|
|
<div>
|
|
<h3 class="font-semibold text-gray-900 dark:text-white">Clear Roster Table</h3>
|
|
<p class="text-sm text-gray-600 dark:text-gray-400 mt-1">
|
|
Delete all roster units only (keeps emitters and ignored units)
|
|
</p>
|
|
</div>
|
|
<button onclick="confirmClearRoster()" class="px-4 py-2 bg-red-600 hover:bg-red-700 text-white rounded-lg transition-colors whitespace-nowrap">
|
|
Clear Roster
|
|
</button>
|
|
</div>
|
|
</div>
|
|
|
|
<!-- Clear Emitters Only -->
|
|
<div class="border border-red-200 dark:border-red-800 rounded-lg p-6 bg-white dark:bg-slate-800">
|
|
<div class="flex justify-between items-start">
|
|
<div>
|
|
<h3 class="font-semibold text-gray-900 dark:text-white">Clear Emitters Table</h3>
|
|
<p class="text-sm text-gray-600 dark:text-gray-400 mt-1">
|
|
Delete all auto-discovered emitters (will repopulate automatically)
|
|
</p>
|
|
</div>
|
|
<button onclick="confirmClearEmitters()" class="px-4 py-2 bg-red-600 hover:bg-red-700 text-white rounded-lg transition-colors whitespace-nowrap">
|
|
Clear Emitters
|
|
</button>
|
|
</div>
|
|
</div>
|
|
|
|
<!-- Clear Ignored Units -->
|
|
<div class="border border-red-200 dark:border-red-800 rounded-lg p-6 bg-white dark:bg-slate-800">
|
|
<div class="flex justify-between items-start">
|
|
<div>
|
|
<h3 class="font-semibold text-gray-900 dark:text-white">Clear Ignored Units</h3>
|
|
<p class="text-sm text-gray-600 dark:text-gray-400 mt-1">
|
|
Remove all units from the ignore list
|
|
</p>
|
|
</div>
|
|
<button onclick="confirmClearIgnored()" class="px-4 py-2 bg-red-600 hover:bg-red-700 text-white rounded-lg transition-colors whitespace-nowrap">
|
|
Clear Ignored
|
|
</button>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
<style>
|
|
.settings-tab {
|
|
padding: 0.75rem 1.5rem;
|
|
font-size: 0.875rem;
|
|
font-weight: 500;
|
|
color: #6b7280;
|
|
border-bottom: 2px solid transparent;
|
|
transition: all 0.2s;
|
|
background: none;
|
|
cursor: pointer;
|
|
}
|
|
|
|
.settings-tab:hover {
|
|
color: #374151;
|
|
background-color: rgba(249, 250, 251, 0.5);
|
|
}
|
|
|
|
.dark .settings-tab:hover {
|
|
color: #d1d5db;
|
|
background-color: rgba(55, 65, 81, 0.3);
|
|
}
|
|
|
|
.active-settings-tab {
|
|
color: #f48b1c !important;
|
|
border-bottom-color: #f48b1c !important;
|
|
}
|
|
|
|
.tab-content {
|
|
animation: fadeIn 0.3s ease-in;
|
|
}
|
|
|
|
@keyframes fadeIn {
|
|
from { opacity: 0; transform: translateY(-10px); }
|
|
to { opacity: 1; transform: translateY(0); }
|
|
}
|
|
</style>
|
|
|
|
<script>
|
|
// ========== TAB MANAGEMENT ==========
|
|
|
|
function showTab(tabName) {
|
|
// Hide all tabs
|
|
document.querySelectorAll('.tab-content').forEach(tab => {
|
|
tab.classList.add('hidden');
|
|
});
|
|
|
|
// Remove active class from all buttons
|
|
document.querySelectorAll('.settings-tab').forEach(btn => {
|
|
btn.classList.remove('active-settings-tab');
|
|
});
|
|
|
|
// Show selected tab
|
|
document.getElementById(tabName + '-tab').classList.remove('hidden');
|
|
|
|
// Add active class to clicked button
|
|
const clickedButton = document.querySelector(`[data-tab="${tabName}"]`);
|
|
if (clickedButton) {
|
|
clickedButton.classList.add('active-settings-tab');
|
|
}
|
|
|
|
// Save last active tab to localStorage
|
|
localStorage.setItem('settings-last-tab', tabName);
|
|
|
|
// Load roster table when data tab is shown
|
|
if (tabName === 'data') {
|
|
loadRosterTable();
|
|
}
|
|
}
|
|
|
|
// Restore last active tab on page load
|
|
window.addEventListener('DOMContentLoaded', () => {
|
|
const lastTab = localStorage.getItem('settings-last-tab') || 'general';
|
|
showTab(lastTab);
|
|
loadPreferences();
|
|
});
|
|
|
|
// ========== GENERAL TAB - PREFERENCES ==========
|
|
|
|
let currentPreferences = {};
|
|
|
|
async function loadPreferences() {
|
|
try {
|
|
const response = await fetch('/api/settings/preferences');
|
|
const prefs = await response.json();
|
|
currentPreferences = prefs;
|
|
|
|
// Load timezone
|
|
document.getElementById('timezone-select').value = prefs.timezone || 'America/New_York';
|
|
|
|
// Load theme
|
|
const themeRadios = document.querySelectorAll('input[name="theme"]');
|
|
themeRadios.forEach(radio => {
|
|
radio.checked = radio.value === (prefs.theme || 'auto');
|
|
});
|
|
|
|
// Load auto-refresh interval
|
|
document.getElementById('refresh-interval').value = prefs.auto_refresh_interval || 10;
|
|
|
|
// Load status thresholds
|
|
document.getElementById('ok-threshold').value = prefs.status_ok_threshold_hours || 12;
|
|
document.getElementById('pending-threshold').value = prefs.status_pending_threshold_hours || 24;
|
|
|
|
// Load calibration defaults
|
|
document.getElementById('cal-interval').value = prefs.calibration_interval_days || 365;
|
|
document.getElementById('cal-warning').value = prefs.calibration_warning_days || 30;
|
|
|
|
} catch (error) {
|
|
console.error('Error loading preferences:', error);
|
|
}
|
|
}
|
|
|
|
async function saveGeneralSettings() {
|
|
const timezone = document.getElementById('timezone-select').value;
|
|
const theme = document.querySelector('input[name="theme"]:checked').value;
|
|
const autoRefreshInterval = parseInt(document.getElementById('refresh-interval').value);
|
|
|
|
try {
|
|
const response = await fetch('/api/settings/preferences', {
|
|
method: 'PUT',
|
|
headers: { 'Content-Type': 'application/json' },
|
|
body: JSON.stringify({
|
|
timezone,
|
|
theme,
|
|
auto_refresh_interval: autoRefreshInterval
|
|
})
|
|
});
|
|
|
|
if (response.ok) {
|
|
// Also update localStorage for immediate effect
|
|
localStorage.setItem('timezone', timezone);
|
|
|
|
// Visual feedback
|
|
alert('Settings saved successfully!');
|
|
|
|
// Refresh timestamps on page
|
|
if (typeof updateAllTimestamps === 'function') {
|
|
updateAllTimestamps();
|
|
}
|
|
} else {
|
|
const result = await response.json();
|
|
alert('Error saving settings: ' + (result.detail || 'Unknown error'));
|
|
}
|
|
} catch (error) {
|
|
alert('Error saving settings: ' + error.message);
|
|
}
|
|
}
|
|
|
|
async function saveStatusThresholds() {
|
|
const okThreshold = parseInt(document.getElementById('ok-threshold').value);
|
|
const pendingThreshold = parseInt(document.getElementById('pending-threshold').value);
|
|
|
|
try {
|
|
const response = await fetch('/api/settings/preferences', {
|
|
method: 'PUT',
|
|
headers: { 'Content-Type': 'application/json' },
|
|
body: JSON.stringify({
|
|
status_ok_threshold_hours: okThreshold,
|
|
status_pending_threshold_hours: pendingThreshold
|
|
})
|
|
});
|
|
|
|
if (response.ok) {
|
|
alert('Status thresholds saved successfully!');
|
|
} else {
|
|
const result = await response.json();
|
|
alert('Error saving thresholds: ' + (result.detail || 'Unknown error'));
|
|
}
|
|
} catch (error) {
|
|
alert('Error saving thresholds: ' + error.message);
|
|
}
|
|
}
|
|
|
|
async function saveCalibrationDefaults() {
|
|
const calInterval = parseInt(document.getElementById('cal-interval').value);
|
|
const calWarning = parseInt(document.getElementById('cal-warning').value);
|
|
|
|
try {
|
|
const response = await fetch('/api/settings/preferences', {
|
|
method: 'PUT',
|
|
headers: { 'Content-Type': 'application/json' },
|
|
body: JSON.stringify({
|
|
calibration_interval_days: calInterval,
|
|
calibration_warning_days: calWarning
|
|
})
|
|
});
|
|
|
|
if (response.ok) {
|
|
alert('Calibration defaults saved successfully!');
|
|
} else {
|
|
const result = await response.json();
|
|
alert('Error saving defaults: ' + (result.detail || 'Unknown error'));
|
|
}
|
|
} catch (error) {
|
|
alert('Error saving defaults: ' + error.message);
|
|
}
|
|
}
|
|
|
|
// ========== DATA TAB - IMPORT/EXPORT ==========
|
|
|
|
// Merge Mode Import
|
|
document.getElementById('importMergeForm').addEventListener('submit', async function(e) {
|
|
e.preventDefault();
|
|
|
|
const formData = new FormData(this);
|
|
const resultDiv = document.getElementById('importMergeResult');
|
|
|
|
try {
|
|
const response = await fetch('/api/roster/import-csv', {
|
|
method: 'POST',
|
|
body: formData
|
|
});
|
|
|
|
const result = await response.json();
|
|
|
|
if (response.ok) {
|
|
resultDiv.className = 'mt-4 p-4 rounded-lg bg-green-100 dark:bg-green-900 text-green-800 dark:text-green-200';
|
|
resultDiv.innerHTML = `
|
|
<p class="font-semibold mb-2">Import Successful!</p>
|
|
<ul class="text-sm space-y-1">
|
|
<li>✅ Added: ${result.summary.added}</li>
|
|
<li>🔄 Updated: ${result.summary.updated}</li>
|
|
<li>⏭️ Skipped: ${result.summary.skipped}</li>
|
|
<li>❌ Errors: ${result.summary.errors}</li>
|
|
</ul>
|
|
`;
|
|
resultDiv.classList.remove('hidden');
|
|
|
|
// Refresh roster table
|
|
setTimeout(() => {
|
|
this.reset();
|
|
resultDiv.classList.add('hidden');
|
|
loadRosterTable();
|
|
}, 3000);
|
|
} else {
|
|
resultDiv.className = 'mt-4 p-4 rounded-lg bg-red-100 dark:bg-red-900 text-red-800 dark:text-red-200';
|
|
resultDiv.innerHTML = `<p class="font-semibold">Import Failed</p><p class="text-sm">${result.detail || 'Unknown error'}</p>`;
|
|
resultDiv.classList.remove('hidden');
|
|
}
|
|
} catch (error) {
|
|
resultDiv.className = 'mt-4 p-4 rounded-lg bg-red-100 dark:bg-red-900 text-red-800 dark:text-red-200';
|
|
resultDiv.innerHTML = `<p class="font-semibold">Import Failed</p><p class="text-sm">${error.message}</p>`;
|
|
resultDiv.classList.remove('hidden');
|
|
}
|
|
});
|
|
|
|
// Replace Mode Import
|
|
document.getElementById('importReplaceForm').addEventListener('submit', async function(e) {
|
|
e.preventDefault();
|
|
|
|
const formData = new FormData(this);
|
|
const resultDiv = document.getElementById('importReplaceResult');
|
|
|
|
// Get confirmation
|
|
try {
|
|
const stats = await fetch('/api/settings/stats').then(r => r.json());
|
|
|
|
const confirmMsg = `⚠️ REPLACE MODE WARNING ⚠️
|
|
|
|
This will DELETE all ${stats.roster} roster units first, then import from CSV.
|
|
|
|
THIS CANNOT BE UNDONE!
|
|
|
|
Make sure you have a backup before proceeding.
|
|
|
|
Continue?`;
|
|
|
|
if (!confirm(confirmMsg)) {
|
|
return;
|
|
}
|
|
} catch (error) {
|
|
alert('Error fetching statistics: ' + error.message);
|
|
return;
|
|
}
|
|
|
|
try {
|
|
const response = await fetch('/api/settings/import-csv-replace', {
|
|
method: 'POST',
|
|
body: formData
|
|
});
|
|
|
|
const result = await response.json();
|
|
|
|
if (response.ok) {
|
|
resultDiv.className = 'mt-4 p-4 rounded-lg bg-green-100 dark:bg-green-900 text-green-800 dark:text-green-200';
|
|
resultDiv.innerHTML = `
|
|
<p class="font-semibold mb-2">Replace Import Successful!</p>
|
|
<ul class="text-sm space-y-1">
|
|
<li>🗑️ Deleted: ${result.deleted}</li>
|
|
<li>✅ Added: ${result.added}</li>
|
|
</ul>
|
|
`;
|
|
resultDiv.classList.remove('hidden');
|
|
|
|
// Refresh roster table
|
|
setTimeout(() => {
|
|
this.reset();
|
|
resultDiv.classList.add('hidden');
|
|
loadRosterTable();
|
|
}, 3000);
|
|
} else {
|
|
resultDiv.className = 'mt-4 p-4 rounded-lg bg-red-100 dark:bg-red-900 text-red-800 dark:text-red-200';
|
|
resultDiv.innerHTML = `<p class="font-semibold">Import Failed</p><p class="text-sm">${result.detail || 'Unknown error'}</p>`;
|
|
resultDiv.classList.remove('hidden');
|
|
}
|
|
} catch (error) {
|
|
resultDiv.className = 'mt-4 p-4 rounded-lg bg-red-100 dark:bg-red-900 text-red-800 dark:text-red-200';
|
|
resultDiv.innerHTML = `<p class="font-semibold">Import Failed</p><p class="text-sm">${error.message}</p>`;
|
|
resultDiv.classList.remove('hidden');
|
|
}
|
|
});
|
|
|
|
// ========== ROSTER MANAGEMENT TABLE ==========
|
|
|
|
async function loadRosterTable() {
|
|
const loading = document.getElementById('rosterTableLoading');
|
|
const container = document.getElementById('rosterTableContainer');
|
|
const empty = document.getElementById('rosterTableEmpty');
|
|
const tbody = document.getElementById('rosterTableBody');
|
|
|
|
try {
|
|
loading.classList.remove('hidden');
|
|
container.classList.add('hidden');
|
|
empty.classList.add('hidden');
|
|
|
|
const response = await fetch('/api/settings/roster-units');
|
|
const units = await response.json();
|
|
|
|
if (units.length === 0) {
|
|
loading.classList.add('hidden');
|
|
empty.classList.remove('hidden');
|
|
return;
|
|
}
|
|
|
|
tbody.innerHTML = units.map(unit => createRosterRow(unit)).join('');
|
|
|
|
loading.classList.add('hidden');
|
|
container.classList.remove('hidden');
|
|
} catch (error) {
|
|
loading.classList.add('hidden');
|
|
alert('Error loading roster: ' + error.message);
|
|
}
|
|
}
|
|
|
|
function createRosterRow(unit) {
|
|
const statusBadges = [];
|
|
if (unit.deployed) {
|
|
statusBadges.push('<span class="inline-flex items-center px-2 py-1 rounded text-xs font-medium bg-green-100 text-green-800 dark:bg-green-900 dark:text-green-300">Deployed</span>');
|
|
} else {
|
|
statusBadges.push('<span class="inline-flex items-center px-2 py-1 rounded text-xs font-medium bg-gray-100 text-gray-800 dark:bg-gray-700 dark:text-gray-300">Benched</span>');
|
|
}
|
|
if (unit.retired) {
|
|
statusBadges.push('<span class="inline-flex items-center px-2 py-1 rounded text-xs font-medium bg-purple-100 text-purple-800 dark:bg-purple-900 dark:text-purple-300">Retired</span>');
|
|
}
|
|
|
|
return `
|
|
<tr class="hover:bg-gray-50 dark:hover:bg-gray-700 transition-colors" data-unit-id="${unit.id}">
|
|
<td class="px-4 py-3 whitespace-nowrap">
|
|
<a href="/unit/${unit.id}" class="text-sm font-medium text-seismo-orange hover:text-orange-600 dark:hover:text-orange-400">
|
|
${unit.id}
|
|
</a>
|
|
</td>
|
|
<td class="px-4 py-3 whitespace-nowrap">
|
|
<div class="text-sm text-gray-900 dark:text-white">${unit.device_type}</div>
|
|
<div class="text-xs text-gray-500 dark:text-gray-400">${unit.unit_type}</div>
|
|
</td>
|
|
<td class="px-4 py-3">
|
|
<div class="flex flex-wrap gap-1">
|
|
${statusBadges.join('')}
|
|
</div>
|
|
</td>
|
|
<td class="px-4 py-3">
|
|
<div class="text-sm text-gray-600 dark:text-gray-400 max-w-xs truncate" title="${unit.note}">
|
|
${unit.note || '<span class="text-gray-400 italic">No note</span>'}
|
|
</div>
|
|
</td>
|
|
<td class="px-4 py-3">
|
|
<div class="text-sm text-gray-600 dark:text-gray-400 max-w-xs truncate" title="${unit.location}">
|
|
${unit.location || '<span class="text-gray-400 italic">—</span>'}
|
|
</div>
|
|
</td>
|
|
<td class="px-4 py-3 whitespace-nowrap text-right text-sm">
|
|
<div class="flex justify-end gap-1">
|
|
<button onclick="toggleDeployed('${unit.id}', ${unit.deployed})"
|
|
class="p-2 hover:bg-gray-100 dark:hover:bg-gray-600 rounded transition-colors"
|
|
title="${unit.deployed ? 'Bench Unit' : 'Deploy Unit'}">
|
|
<svg class="w-4 h-4 ${unit.deployed ? 'text-green-600 dark:text-green-400' : 'text-gray-400'}" fill="none" stroke="currentColor" viewBox="0 0 24 24">
|
|
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M9 12l2 2 4-4m6 2a9 9 0 11-18 0 9 9 0 0118 0z"></path>
|
|
</svg>
|
|
</button>
|
|
<button onclick="toggleRetired('${unit.id}', ${unit.retired})"
|
|
class="p-2 hover:bg-gray-100 dark:hover:bg-gray-600 rounded transition-colors"
|
|
title="${unit.retired ? 'Unretire Unit' : 'Retire Unit'}">
|
|
<svg class="w-4 h-4 ${unit.retired ? 'text-purple-600 dark:text-purple-400' : 'text-gray-400'}" fill="none" stroke="currentColor" viewBox="0 0 24 24">
|
|
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M20 7l-8-4-8 4m16 0l-8 4m8-4v10l-8 4m0-10L4 7m8 4v10M4 7v10l8 4"></path>
|
|
</svg>
|
|
</button>
|
|
<button onclick="editUnit('${unit.id}')"
|
|
class="p-2 hover:bg-gray-100 dark:hover:bg-gray-600 rounded transition-colors text-blue-600 dark:text-blue-400"
|
|
title="Edit Unit">
|
|
<svg class="w-4 h-4" fill="none" stroke="currentColor" viewBox="0 0 24 24">
|
|
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M11 5H6a2 2 0 00-2 2v11a2 2 0 002 2h11a2 2 0 002-2v-5m-1.414-9.414a2 2 0 112.828 2.828L11.828 15H9v-2.828l8.586-8.586z"></path>
|
|
</svg>
|
|
</button>
|
|
<button onclick="confirmDeleteUnit('${unit.id}')"
|
|
class="p-2 hover:bg-gray-100 dark:hover:bg-gray-600 rounded transition-colors text-red-600 dark:text-red-400"
|
|
title="Delete Unit">
|
|
<svg class="w-4 h-4" fill="none" stroke="currentColor" viewBox="0 0 24 24">
|
|
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M19 7l-.867 12.142A2 2 0 0116.138 21H7.862a2 2 0 01-1.995-1.858L5 7m5 4v6m4-6v6m1-10V4a1 1 0 00-1-1h-4a1 1 0 00-1 1v3M4 7h16"></path>
|
|
</svg>
|
|
</button>
|
|
</div>
|
|
</td>
|
|
</tr>
|
|
`;
|
|
}
|
|
|
|
async function toggleDeployed(unitId, currentState) {
|
|
try {
|
|
const response = await fetch(`/api/roster/set-deployed/${unitId}`, {
|
|
method: 'POST',
|
|
headers: { 'Content-Type': 'application/x-www-form-urlencoded' },
|
|
body: `deployed=${!currentState}`
|
|
});
|
|
|
|
if (response.ok) {
|
|
await loadRosterTable();
|
|
} else {
|
|
const result = await response.json();
|
|
alert('Error: ' + (result.detail || 'Unknown error'));
|
|
}
|
|
} catch (error) {
|
|
alert('Error: ' + error.message);
|
|
}
|
|
}
|
|
|
|
async function toggleRetired(unitId, currentState) {
|
|
try {
|
|
const response = await fetch(`/api/roster/set-retired/${unitId}`, {
|
|
method: 'POST',
|
|
headers: { 'Content-Type': 'application/x-www-form-urlencoded' },
|
|
body: `retired=${!currentState}`
|
|
});
|
|
|
|
if (response.ok) {
|
|
await loadRosterTable();
|
|
} else {
|
|
const result = await response.json();
|
|
alert('Error: ' + (result.detail || 'Unknown error'));
|
|
}
|
|
} catch (error) {
|
|
alert('Error: ' + error.message);
|
|
}
|
|
}
|
|
|
|
function editUnit(unitId) {
|
|
window.location.href = `/unit/${unitId}`;
|
|
}
|
|
|
|
async function confirmDeleteUnit(unitId) {
|
|
if (!confirm(`Delete unit ${unitId}?\n\nThis will permanently remove the unit from the roster.\n\nContinue?`)) {
|
|
return;
|
|
}
|
|
|
|
try {
|
|
const response = await fetch(`/api/roster/${unitId}`, {
|
|
method: 'DELETE'
|
|
});
|
|
|
|
if (response.ok) {
|
|
await loadRosterTable();
|
|
alert(`✅ Unit ${unitId} deleted successfully`);
|
|
} else {
|
|
const result = await response.json();
|
|
alert('❌ Error: ' + (result.detail || 'Unknown error'));
|
|
}
|
|
} catch (error) {
|
|
alert('❌ Error: ' + error.message);
|
|
}
|
|
}
|
|
|
|
function refreshRosterTable() {
|
|
loadRosterTable();
|
|
}
|
|
|
|
// ========== DANGER ZONE ==========
|
|
|
|
async function confirmClearAll() {
|
|
try {
|
|
const stats = await fetch('/api/settings/stats').then(r => r.json());
|
|
|
|
const message = `⚠️ CLEAR ALL DATA WARNING ⚠️
|
|
|
|
You are about to DELETE ALL data:
|
|
|
|
• Roster units: ${stats.roster}
|
|
• Emitters: ${stats.emitters}
|
|
• Ignored units: ${stats.ignored}
|
|
• TOTAL: ${stats.total} records
|
|
|
|
THIS ACTION CANNOT BE UNDONE!
|
|
|
|
Export a backup first if needed.
|
|
|
|
Are you absolutely sure?`;
|
|
|
|
if (!confirm(message)) {
|
|
return;
|
|
}
|
|
|
|
const response = await fetch('/api/settings/clear-all', {
|
|
method: 'POST'
|
|
});
|
|
|
|
if (response.ok) {
|
|
const result = await response.json();
|
|
alert(`✅ Success! Deleted ${result.deleted.total} records\n\n• Roster: ${result.deleted.roster}\n• Emitters: ${result.deleted.emitters}\n• Ignored: ${result.deleted.ignored}`);
|
|
location.reload();
|
|
} else {
|
|
const result = await response.json();
|
|
alert('❌ Error: ' + (result.detail || 'Unknown error'));
|
|
}
|
|
} catch (error) {
|
|
alert('❌ Error: ' + error.message);
|
|
}
|
|
}
|
|
|
|
async function confirmClearRoster() {
|
|
try {
|
|
const stats = await fetch('/api/settings/stats').then(r => r.json());
|
|
|
|
if (!confirm(`Delete all ${stats.roster} roster units?\n\nThis cannot be undone!`)) {
|
|
return;
|
|
}
|
|
|
|
const response = await fetch('/api/settings/clear-roster', {
|
|
method: 'POST'
|
|
});
|
|
|
|
if (response.ok) {
|
|
const result = await response.json();
|
|
alert(`✅ Success! Deleted ${result.deleted} roster units`);
|
|
location.reload();
|
|
} else {
|
|
const result = await response.json();
|
|
alert('❌ Error: ' + (result.detail || 'Unknown error'));
|
|
}
|
|
} catch (error) {
|
|
alert('❌ Error: ' + error.message);
|
|
}
|
|
}
|
|
|
|
async function confirmClearEmitters() {
|
|
try {
|
|
const stats = await fetch('/api/settings/stats').then(r => r.json());
|
|
|
|
if (!confirm(`Delete all ${stats.emitters} emitters?\n\nEmitters will repopulate automatically from heartbeats.`)) {
|
|
return;
|
|
}
|
|
|
|
const response = await fetch('/api/settings/clear-emitters', {
|
|
method: 'POST'
|
|
});
|
|
|
|
if (response.ok) {
|
|
const result = await response.json();
|
|
alert(`✅ Success! Deleted ${result.deleted} emitters`);
|
|
location.reload();
|
|
} else {
|
|
const result = await response.json();
|
|
alert('❌ Error: ' + (result.detail || 'Unknown error'));
|
|
}
|
|
} catch (error) {
|
|
alert('❌ Error: ' + error.message);
|
|
}
|
|
}
|
|
|
|
async function confirmClearIgnored() {
|
|
try {
|
|
const stats = await fetch('/api/settings/stats').then(r => r.json());
|
|
|
|
if (!confirm(`Remove all ${stats.ignored} units from ignore list?\n\nThey will appear as unknown emitters again.`)) {
|
|
return;
|
|
}
|
|
|
|
const response = await fetch('/api/settings/clear-ignored', {
|
|
method: 'POST'
|
|
});
|
|
|
|
if (response.ok) {
|
|
const result = await response.json();
|
|
alert(`✅ Success! Removed ${result.deleted} units from ignore list`);
|
|
location.reload();
|
|
} else {
|
|
const result = await response.json();
|
|
alert('❌ Error: ' + (result.detail || 'Unknown error'));
|
|
}
|
|
} catch (error) {
|
|
alert('❌ Error: ' + error.message);
|
|
}
|
|
}
|
|
</script>
|
|
{% endblock %}
|