Tg with Notifications, bags fixxed
This commit is contained in:
154
test_telegram_status.html
Normal file
154
test_telegram_status.html
Normal file
@@ -0,0 +1,154 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="ru">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<title>Тест Telegram Status API</title>
|
||||
<style>
|
||||
body {
|
||||
font-family: Arial, sans-serif;
|
||||
max-width: 800px;
|
||||
margin: 0 auto;
|
||||
padding: 20px;
|
||||
}
|
||||
.user-item {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 10px;
|
||||
padding: 10px;
|
||||
border: 1px solid #ddd;
|
||||
margin: 5px 0;
|
||||
border-radius: 8px;
|
||||
}
|
||||
.avatar {
|
||||
width: 40px;
|
||||
height: 40px;
|
||||
border-radius: 20px;
|
||||
background: #e5e7eb;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
font-weight: bold;
|
||||
position: relative;
|
||||
}
|
||||
.online-indicator {
|
||||
position: absolute;
|
||||
bottom: 0;
|
||||
right: 0;
|
||||
width: 12px;
|
||||
height: 12px;
|
||||
border-radius: 6px;
|
||||
background: #10b981;
|
||||
border: 2px solid #fff;
|
||||
}
|
||||
.status {
|
||||
font-size: 14px;
|
||||
color: #6b7280;
|
||||
}
|
||||
.status.online {
|
||||
color: #10b981;
|
||||
font-weight: 600;
|
||||
}
|
||||
.error {
|
||||
color: #dc2626;
|
||||
padding: 10px;
|
||||
background: #fef2f2;
|
||||
border-radius: 8px;
|
||||
}
|
||||
button {
|
||||
padding: 10px 20px;
|
||||
background: #0084ff;
|
||||
color: white;
|
||||
border: none;
|
||||
border-radius: 8px;
|
||||
cursor: pointer;
|
||||
margin: 10px 0;
|
||||
}
|
||||
button:hover {
|
||||
background: #0066cc;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<h1>Тест Telegram Status API</h1>
|
||||
|
||||
<div>
|
||||
<label for="token">JWT Token:</label><br>
|
||||
<input type="text" id="token" placeholder="Введите JWT токен" style="width: 100%; padding: 10px; margin: 10px 0;">
|
||||
<br>
|
||||
<button onclick="testAPI()">Тестировать API</button>
|
||||
<button onclick="clearResults()">Очистить результаты</button>
|
||||
</div>
|
||||
|
||||
<div id="results"></div>
|
||||
|
||||
<script>
|
||||
async function testAPI() {
|
||||
const token = document.getElementById('token').value;
|
||||
const resultsDiv = document.getElementById('results');
|
||||
|
||||
if (!token) {
|
||||
resultsDiv.innerHTML = '<div class="error">Введите JWT токен</div>';
|
||||
return;
|
||||
}
|
||||
|
||||
try {
|
||||
resultsDiv.innerHTML = '<div>Загрузка...</div>';
|
||||
|
||||
const response = await fetch('/api/users/status', {
|
||||
headers: {
|
||||
'Authorization': `Bearer ${token}`,
|
||||
'Content-Type': 'application/json'
|
||||
}
|
||||
});
|
||||
|
||||
if (!response.ok) {
|
||||
const errorText = await response.text();
|
||||
throw new Error(`HTTP ${response.status}: ${errorText}`);
|
||||
}
|
||||
|
||||
const users = await response.json();
|
||||
|
||||
let html = '<h2>Результат:</h2>';
|
||||
html += `<p>Найдено пользователей: ${users.length}</p>`;
|
||||
|
||||
users.forEach(user => {
|
||||
const isOnline = user.isOnline;
|
||||
const lastSeen = user.lastSeen;
|
||||
|
||||
let statusText = isOnline ? 'Онлайн' : 'Офлайн';
|
||||
if (!isOnline && lastSeen) {
|
||||
statusText = `Был(а) ${new Date(lastSeen).toLocaleString('ru-RU')}`;
|
||||
}
|
||||
|
||||
html += `
|
||||
<div class="user-item">
|
||||
<div class="avatar">
|
||||
${user.firstName?.[0] || ''}${user.lastName?.[0] || ''}
|
||||
${isOnline ? '<div class="online-indicator"></div>' : ''}
|
||||
</div>
|
||||
<div>
|
||||
<div><strong>${user.firstName} ${user.lastName}</strong></div>
|
||||
<div class="status ${isOnline ? 'online' : ''}">${statusText}</div>
|
||||
<div style="font-size: 12px; color: #999;">
|
||||
ID: ${user.id} | Online: ${isOnline} | LastSeen: ${lastSeen || 'N/A'}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
`;
|
||||
});
|
||||
|
||||
resultsDiv.innerHTML = html;
|
||||
|
||||
} catch (error) {
|
||||
resultsDiv.innerHTML = `<div class="error">Ошибка: ${error.message}</div>`;
|
||||
console.error('API Error:', error);
|
||||
}
|
||||
}
|
||||
|
||||
function clearResults() {
|
||||
document.getElementById('results').innerHTML = '';
|
||||
}
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
Reference in New Issue
Block a user