468 lines
18 KiB
HTML
468 lines
18 KiB
HTML
<!DOCTYPE html>
|
|
<html lang="en">
|
|
|
|
<head>
|
|
<meta charset="UTF-8">
|
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
<title>C-Relay Admin</title>
|
|
<link rel="stylesheet" href="/api/index.css">
|
|
</head>
|
|
|
|
<body>
|
|
<!-- Side Navigation Menu -->
|
|
<nav class="side-nav" id="side-nav">
|
|
<ul class="nav-menu">
|
|
<li><button class="nav-item" data-page="statistics">Statistics</button></li>
|
|
<li><button class="nav-item" data-page="subscriptions">Subscriptions</button></li>
|
|
<li><button class="nav-item" data-page="configuration">Configuration</button></li>
|
|
<li><button class="nav-item" data-page="authorization">Authorization</button></li>
|
|
<li><button class="nav-item" data-page="relay-events">Relay Events</button></li>
|
|
<li><button class="nav-item" data-page="dm">DM</button></li>
|
|
<li><button class="nav-item" data-page="database">Database Query</button></li>
|
|
</ul>
|
|
<div class="nav-footer">
|
|
<button class="nav-footer-btn" id="nav-dark-mode-btn">DARK MODE</button>
|
|
<button class="nav-footer-btn" id="nav-logout-btn">LOGOUT</button>
|
|
</div>
|
|
</nav>
|
|
|
|
<!-- Side Navigation Overlay -->
|
|
<div class="side-nav-overlay" id="side-nav-overlay"></div>
|
|
|
|
<!-- Header with title and profile display -->
|
|
<div class="section">
|
|
|
|
<div class="header-content">
|
|
<div class="header-title clickable" id="header-title">
|
|
<span class="relay-letter" data-letter="R">R</span>
|
|
<span class="relay-letter" data-letter="E">E</span>
|
|
<span class="relay-letter" data-letter="L">L</span>
|
|
<span class="relay-letter" data-letter="A">A</span>
|
|
<span class="relay-letter" data-letter="Y">Y</span>
|
|
</div>
|
|
<div class="relay-info">
|
|
<div id="relay-name" class="relay-name">C-Relay</div>
|
|
<div id="relay-description" class="relay-description">Loading...</div>
|
|
<div id="relay-pubkey-container" class="relay-pubkey-container">
|
|
<div id="relay-pubkey" class="relay-pubkey">Loading...</div>
|
|
</div>
|
|
</div>
|
|
<div class="profile-area" id="profile-area" style="display: none;">
|
|
<div class="admin-label">admin</div>
|
|
<div class="profile-container">
|
|
<img id="header-user-image" class="header-user-image" alt="Profile" style="display: none;">
|
|
<span id="header-user-name" class="header-user-name">Loading...</span>
|
|
</div>
|
|
<!-- Logout dropdown -->
|
|
<!-- Dropdown menu removed - buttons moved to sidebar -->
|
|
</div>
|
|
</div>
|
|
|
|
</div>
|
|
|
|
<!-- Login Modal Overlay -->
|
|
<div id="login-modal" class="login-modal-overlay" style="display: none;">
|
|
<div class="login-modal-content">
|
|
<div id="login-modal-container"></div>
|
|
</div>
|
|
</div>
|
|
|
|
<!-- DATABASE STATISTICS Section -->
|
|
<!-- Subscribe to kind 24567 events to receive real-time monitoring data -->
|
|
<div class="section flex-section" id="databaseStatisticsSection" style="display: none;">
|
|
<div class="section-header">
|
|
DATABASE STATISTICS
|
|
</div>
|
|
|
|
<!-- Event Rate Graph Container -->
|
|
<div id="event-rate-chart"></div>
|
|
|
|
<!-- Database Overview Table -->
|
|
<div class="input-group">
|
|
<div class="config-table-container">
|
|
<table class="config-table" id="stats-overview-table">
|
|
<thead>
|
|
<tr>
|
|
<th>Metric</th>
|
|
<th>Value</th>
|
|
</tr>
|
|
</thead>
|
|
<tbody id="stats-overview-table-body">
|
|
<tr>
|
|
<td>Database Size</td>
|
|
<td id="db-size">-</td>
|
|
</tr>
|
|
<tr>
|
|
<td>Total Events</td>
|
|
<td id="total-events">-</td>
|
|
</tr>
|
|
<tr>
|
|
<td>Process ID</td>
|
|
<td id="process-id">-</td>
|
|
</tr>
|
|
<tr>
|
|
<td>Active Subscriptions</td>
|
|
<td id="active-subscriptions">-</td>
|
|
</tr>
|
|
<tr>
|
|
<td>Memory Usage</td>
|
|
<td id="memory-usage">-</td>
|
|
</tr>
|
|
<tr>
|
|
<td>CPU Core</td>
|
|
<td id="cpu-core">-</td>
|
|
</tr>
|
|
<tr>
|
|
<td>CPU Usage</td>
|
|
<td id="cpu-usage">-</td>
|
|
</tr>
|
|
<tr>
|
|
<td>Oldest Event</td>
|
|
<td id="oldest-event">-</td>
|
|
</tr>
|
|
<tr>
|
|
<td>Newest Event</td>
|
|
<td id="newest-event">-</td>
|
|
</tr>
|
|
</tbody>
|
|
</table>
|
|
</div>
|
|
</div>
|
|
|
|
<!-- Event Kind Distribution Table -->
|
|
<div class="input-group">
|
|
<label>Event Kind Distribution:</label>
|
|
<div class="config-table-container">
|
|
<table class="config-table" id="stats-kinds-table">
|
|
<thead>
|
|
<tr>
|
|
<th>Event Kind</th>
|
|
<th>Count</th>
|
|
<th>Percentage</th>
|
|
</tr>
|
|
</thead>
|
|
<tbody id="stats-kinds-table-body">
|
|
<tr>
|
|
<td colspan="3" style="text-align: center; font-style: italic;">No data loaded</td>
|
|
</tr>
|
|
</tbody>
|
|
</table>
|
|
</div>
|
|
</div>
|
|
|
|
<!-- Time-based Statistics Table -->
|
|
<div class="input-group">
|
|
<label>Time-based Statistics:</label>
|
|
<div class="config-table-container">
|
|
<table class="config-table" id="stats-time-table">
|
|
<thead>
|
|
<tr>
|
|
<th>Period</th>
|
|
<th>Events</th>
|
|
</tr>
|
|
</thead>
|
|
<tbody id="stats-time-table-body">
|
|
<tr>
|
|
<td>Last 24 Hours</td>
|
|
<td id="events-24h">-</td>
|
|
</tr>
|
|
<tr>
|
|
<td>Last 7 Days</td>
|
|
<td id="events-7d">-</td>
|
|
</tr>
|
|
<tr>
|
|
<td>Last 30 Days</td>
|
|
<td id="events-30d">-</td>
|
|
</tr>
|
|
</tbody>
|
|
</table>
|
|
</div>
|
|
</div>
|
|
|
|
<!-- Top Pubkeys Table -->
|
|
<div class="input-group">
|
|
<label>Top Pubkeys by Event Count:</label>
|
|
<div class="config-table-container">
|
|
<table class="config-table" id="stats-pubkeys-table">
|
|
<thead>
|
|
<tr>
|
|
<th>Rank</th>
|
|
<th>Pubkey</th>
|
|
<th>Event Count</th>
|
|
<th>Percentage</th>
|
|
</tr>
|
|
</thead>
|
|
<tbody id="stats-pubkeys-table-body">
|
|
<tr>
|
|
<td colspan="4" style="text-align: center; font-style: italic;">No data loaded</td>
|
|
</tr>
|
|
</tbody>
|
|
</table>
|
|
</div>
|
|
</div>
|
|
|
|
</div>
|
|
|
|
<!-- SUBSCRIPTION DETAILS Section (Admin Only) -->
|
|
<div class="section flex-section" id="subscriptionDetailsSection" style="display: none;">
|
|
<div class="section-header">
|
|
ACTIVE SUBSCRIPTION DETAILS
|
|
</div>
|
|
|
|
<div class="input-group">
|
|
<div class="config-table-container">
|
|
<table class="config-table" id="subscription-details-table">
|
|
<tbody id="subscription-details-table-body">
|
|
<tr>
|
|
<td colspan="4" style="text-align: center; font-style: italic;">No subscriptions active</td>
|
|
</tr>
|
|
</tbody>
|
|
</table>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
<!-- Testing Section -->
|
|
<div id="div_config" class="section flex-section" style="display: none;">
|
|
<div class="section-header">
|
|
RELAY CONFIGURATION
|
|
</div>
|
|
<div id="config-display" class="hidden">
|
|
<div class="config-table-container">
|
|
<table class="config-table" id="config-table">
|
|
<thead>
|
|
<tr>
|
|
<th>Parameter</th>
|
|
<th>Value</th>
|
|
<th>Actions</th>
|
|
</tr>
|
|
</thead>
|
|
<tbody id="config-table-body">
|
|
</tbody>
|
|
</table>
|
|
</div>
|
|
|
|
<div class="inline-buttons">
|
|
<button type="button" id="fetch-config-btn">REFRESH</button>
|
|
</div>
|
|
|
|
|
|
</div>
|
|
</div>
|
|
|
|
<!-- Auth Rules Management - Moved after configuration -->
|
|
<div class="section flex-section" id="authRulesSection" style="display: none;">
|
|
<div class="section-header">
|
|
AUTH RULES MANAGEMENT
|
|
</div>
|
|
|
|
<!-- Auth Rules Table -->
|
|
<div id="authRulesTableContainer" style="display: none;">
|
|
<table class="config-table" id="authRulesTable">
|
|
<thead>
|
|
<tr>
|
|
<th>Rule Type</th>
|
|
<th>Pattern Type</th>
|
|
<th>Pattern Value</th>
|
|
<th>Status</th>
|
|
<th>Actions</th>
|
|
</tr>
|
|
</thead>
|
|
<tbody id="authRulesTableBody">
|
|
</tbody>
|
|
</table>
|
|
</div>
|
|
|
|
<!-- Simplified Auth Rule Input Section -->
|
|
<div id="authRuleInputSections" style="display: block;">
|
|
|
|
<!-- Combined Pubkey Auth Rule Section -->
|
|
|
|
|
|
<div class="input-group">
|
|
<label for="authRulePubkey">Pubkey (nsec or hex):</label>
|
|
<input type="text" id="authRulePubkey" placeholder="nsec1... or 64-character hex pubkey">
|
|
|
|
</div>
|
|
<div id="whitelistWarning" class="warning-box" style="display: none;">
|
|
<strong>⚠️ WARNING:</strong> Adding whitelist rules changes relay behavior to whitelist-only
|
|
mode.
|
|
Only whitelisted users will be able to interact with the relay.
|
|
</div>
|
|
<div class="inline-buttons">
|
|
<button type="button" id="addWhitelistBtn" onclick="addWhitelistRule()">ADD TO
|
|
WHITELIST</button>
|
|
<button type="button" id="addBlacklistBtn" onclick="addBlacklistRule()">ADD TO
|
|
BLACKLIST</button>
|
|
<button type="button" id="refreshAuthRulesBtn">REFRESH</button>
|
|
</div>
|
|
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<!-- NIP-17 DIRECT MESSAGES Section -->
|
|
<div class="section" id="nip17DMSection" style="display: none;">
|
|
<div class="section-header">
|
|
<h2>NIP-17 DIRECT MESSAGES</h2>
|
|
</div>
|
|
|
|
<!-- Outbox -->
|
|
<div>
|
|
<label for="dm-outbox">Send Message to Relay:</label>
|
|
<textarea id="dm-outbox" rows="4" placeholder="Enter your message to send to the relay..."></textarea>
|
|
</div>
|
|
|
|
<!-- Send Button -->
|
|
<div class="input-group">
|
|
<button type="button" id="send-dm-btn">SEND MESSAGE</button>
|
|
</div>
|
|
|
|
<!-- Inbox -->
|
|
<div class="input-group">
|
|
<label>Received Messages from Relay:</label>
|
|
<div id="dm-inbox" class="log-panel" style="height: 200px;">
|
|
<div class="log-entry">No messages received yet.</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
<!-- RELAY EVENTS Section -->
|
|
<div class="section" id="relayEventsSection" style="display: none;">
|
|
<div class="section-header">
|
|
RELAY EVENTS MANAGEMENT
|
|
</div>
|
|
|
|
<!-- Kind 0: User Metadata -->
|
|
<div class="input-group">
|
|
<h3>Kind 0: User Metadata</h3>
|
|
<div class="form-group">
|
|
<label for="kind0-name">Name:</label>
|
|
<input type="text" id="kind0-name" placeholder="Relay Name">
|
|
</div>
|
|
<div class="form-group">
|
|
<label for="kind0-about">About:</label>
|
|
<textarea id="kind0-about" rows="3" placeholder="Relay Description"></textarea>
|
|
</div>
|
|
<div class="form-group">
|
|
<label for="kind0-picture">Picture URL:</label>
|
|
<input type="url" id="kind0-picture" placeholder="https://example.com/logo.png">
|
|
</div>
|
|
<div class="form-group">
|
|
<label for="kind0-banner">Banner URL:</label>
|
|
<input type="url" id="kind0-banner" placeholder="https://example.com/banner.png">
|
|
</div>
|
|
<div class="form-group">
|
|
<label for="kind0-nip05">NIP-05:</label>
|
|
<input type="text" id="kind0-nip05" placeholder="relay@example.com">
|
|
</div>
|
|
<div class="form-group">
|
|
<label for="kind0-website">Website:</label>
|
|
<input type="url" id="kind0-website" placeholder="https://example.com">
|
|
</div>
|
|
<div class="inline-buttons">
|
|
<button type="button" id="submit-kind0-btn">UPDATE METADATA</button>
|
|
</div>
|
|
<div id="kind0-status" class="status-message"></div>
|
|
</div>
|
|
|
|
<!-- Kind 10050: DM Relay List -->
|
|
<div class="input-group">
|
|
<h3>Kind 10050: DM Relay List</h3>
|
|
<div class="form-group">
|
|
<label for="kind10050-relays">Relay URLs (one per line):</label>
|
|
<textarea id="kind10050-relays" rows="4" placeholder="wss://relay1.com wss://relay2.com"></textarea>
|
|
</div>
|
|
<div class="inline-buttons">
|
|
<button type="button" id="submit-kind10050-btn">UPDATE DM RELAYS</button>
|
|
</div>
|
|
<div id="kind10050-status" class="status-message"></div>
|
|
</div>
|
|
|
|
<!-- Kind 10002: Relay List -->
|
|
<div class="input-group">
|
|
<h3>Kind 10002: Relay List</h3>
|
|
<div id="kind10002-relay-entries">
|
|
<!-- Dynamic relay entries will be added here -->
|
|
</div>
|
|
<div class="inline-buttons">
|
|
<button type="button" id="add-relay-entry-btn">ADD RELAY</button>
|
|
<button type="button" id="submit-kind10002-btn">UPDATE RELAYS</button>
|
|
</div>
|
|
<div id="kind10002-status" class="status-message"></div>
|
|
</div>
|
|
</div>
|
|
|
|
<!-- SQL QUERY Section -->
|
|
<div class="section" id="sqlQuerySection" style="display: none;">
|
|
<div class="section-header">
|
|
<h2>SQL QUERY CONSOLE</h2>
|
|
</div>
|
|
|
|
<!-- Query Selector -->
|
|
<div class="input-group">
|
|
<label for="query-dropdown">Quick Queries & History:</label>
|
|
<select id="query-dropdown" onchange="loadSelectedQuery()">
|
|
<option value="">-- Select a query --</option>
|
|
<optgroup label="Common Queries">
|
|
<option value="recent_events">Recent Events</option>
|
|
<option value="event_stats">Event Statistics</option>
|
|
<option value="subscriptions">Active Subscriptions</option>
|
|
<option value="top_pubkeys">Top Pubkeys</option>
|
|
<option value="event_kinds">Event Kinds Distribution</option>
|
|
<option value="time_stats">Time-based Statistics</option>
|
|
</optgroup>
|
|
<optgroup label="Query History" id="history-group">
|
|
<!-- Dynamically populated from localStorage -->
|
|
</optgroup>
|
|
</select>
|
|
</div>
|
|
|
|
<!-- Query Editor -->
|
|
<div class="input-group">
|
|
<label for="sql-input">SQL Query:</label>
|
|
<textarea id="sql-input" rows="5" placeholder="SELECT * FROM events LIMIT 10"></textarea>
|
|
</div>
|
|
|
|
<!-- Query Actions -->
|
|
<div class="input-group">
|
|
<div class="inline-buttons">
|
|
<button type="button" id="execute-sql-btn">EXECUTE QUERY</button>
|
|
<button type="button" id="clear-sql-btn">CLEAR</button>
|
|
<button type="button" id="clear-history-btn">CLEAR HISTORY</button>
|
|
</div>
|
|
</div>
|
|
|
|
<!-- Query Results -->
|
|
<div class="input-group">
|
|
<label>Query Results:</label>
|
|
<div id="query-info" class="info-box"></div>
|
|
<div id="query-table" class="config-table-container"></div>
|
|
</div>
|
|
</div>
|
|
|
|
<!-- Load the official nostr-tools bundle first -->
|
|
<!-- <script src="https://laantungir.net/nostr-login-lite/nostr.bundle.js"></script> -->
|
|
<script src="/api/nostr.bundle.js"></script>
|
|
|
|
<!-- Load NOSTR_LOGIN_LITE main library -->
|
|
<!-- <script src="https://laantungir.net/nostr-login-lite/nostr-lite.js"></script> -->
|
|
<script src="/api/nostr-lite.js"></script>
|
|
<!-- Load text_graph library -->
|
|
<script src="/api/text_graph.js"></script>
|
|
|
|
|
|
|
|
|
|
|
|
<script src="/api/index.js"></script>
|
|
</body>
|
|
|
|
</html> |