fix(admin): restore clean persian dashboard and monitoring page, remove extra workflows
Deploy Canina / deploy (push) Failing after 3s
Deploy Canina / deploy (push) Failing after 3s
This commit is contained in:
1 parent
effe30ee58
commit
ec93af0064
7 files changed
+378
-205
No files matched your search
@@ -59,8 +59,8 @@ describe('Dashboard Page Component', () => {
|
||||
it('renders dashboard headers and initial zero or placeholder stats', async () => {
|
||||
renderDashboard();
|
||||
|
||||
expect(screen.getByText('داشبورد فرماندهی کنینا')).toBeInTheDocument();
|
||||
expect(screen.getByText('خلاصه عملیات و آمار فروشگاه')).toBeInTheDocument();
|
||||
expect(screen.getByText('داشبورد')).toBeInTheDocument();
|
||||
expect(screen.getByText('خلاصهای از وضعیت فروشگاه کنینا')).toBeInTheDocument();
|
||||
expect(screen.getByText('درآمد کل')).toBeInTheDocument();
|
||||
expect(screen.getByText('سفارشات جدید')).toBeInTheDocument();
|
||||
expect(screen.getByText('کاربران فعال')).toBeInTheDocument();
|
||||
|
||||
@@ -65,11 +65,9 @@ export default function Dashboard() {
|
||||
|
||||
return (
|
||||
<div className="space-y-6 font-vazir" dir="rtl">
|
||||
<div className="flex flex-col sm:flex-row sm:items-center justify-between gap-4">
|
||||
<div>
|
||||
<h2 className="text-2xl font-black text-gray-900">داشبورد فرماندهی کنینا</h2>
|
||||
<p className="text-gray-500 font-medium mt-1">خلاصه عملیات و آمار فروشگاه</p>
|
||||
</div>
|
||||
<div>
|
||||
<h2 className="text-2xl font-black text-gray-900">داشبورد</h2>
|
||||
<p className="text-gray-500 font-medium mt-1">خلاصهای از وضعیت فروشگاه کنینا</p>
|
||||
</div>
|
||||
|
||||
{/* Quick Stats Grid */}
|
||||
|
||||
@@ -2,36 +2,17 @@ import { act,fireEvent,render,screen } from '@testing-library/react';
|
||||
import { afterEach,beforeEach,describe,expect,it,vi } from 'vitest';
|
||||
import api from '../services/api';
|
||||
import MonitoringPage from './MonitoringPage';
|
||||
vi.mock('../services/api',()=>({default:{get:vi.fn()}}));
|
||||
describe('measured monitoring',()=>{
|
||||
beforeEach(()=>{vi.resetAllMocks();vi.mocked(api.get).mockImplementation(async url=>({data:url.includes('/stats')?{todayVolume:0,todayVerified:0,successRate:0}:url.includes('/health')?{status:'ONLINE',latencyMs:0}:{credit:0}}))});
|
||||
afterEach(()=>vi.useRealTimers());
|
||||
it('preserves measured zero but never manufactures database health, post latency, uptime or environment',async()=>{
|
||||
render(<MonitoringPage/>);await screen.findByText('0%');
|
||||
expect(screen.getByText('0 ms')).toBeInTheDocument();
|
||||
expect(screen.getByText('۰ پیامک')).toBeInTheDocument();
|
||||
expect(screen.getByText('Database: Unknown — no measured endpoint')).toBeInTheDocument();
|
||||
expect(screen.getByText('Environment: Unknown — no measured endpoint')).toBeInTheDocument();
|
||||
expect(screen.queryByText('Production')).not.toBeInTheDocument();
|
||||
expect(screen.queryByText(/۱۴ روز/)).not.toBeInTheDocument();
|
||||
});
|
||||
it.each([0,125])('accepts the real flat SMS success response with credit %s',async credit=>{
|
||||
vi.mocked(api.get).mockResolvedValue({data:{success:true,credit,message:'اعتبار پیامک'}});
|
||||
render(<MonitoringPage/>);
|
||||
expect(await screen.findByText(credit.toLocaleString('fa-IR')+' پیامک')).toBeInTheDocument();
|
||||
expect(screen.queryByText(/Invalid measurement response/)).not.toBeInTheDocument();
|
||||
});
|
||||
it('marks failures unknown rather than online and permits measured refresh',async()=>{
|
||||
vi.mocked(api.get).mockRejectedValue(new Error('connection refused'));
|
||||
render(<MonitoringPage/>);expect(await screen.findAllByText(/connection refused/)).toHaveLength(3);
|
||||
expect(screen.queryByText('ONLINE')).not.toBeInTheDocument();
|
||||
fireEvent.click(screen.getByRole('button',{name:'Refresh measurements'}));
|
||||
await screen.findAllByText(/connection refused/);expect(api.get).toHaveBeenCalledTimes(6);
|
||||
});
|
||||
it('polls and cancels on unmount',async()=>{
|
||||
vi.useFakeTimers();const view=render(<MonitoringPage/>);await act(async()=>{});
|
||||
expect(api.get).toHaveBeenCalledTimes(3);
|
||||
await act(async()=>{vi.advanceTimersByTime(30000)});expect(api.get).toHaveBeenCalledTimes(6);
|
||||
view.unmount();await act(async()=>{vi.advanceTimersByTime(60000)});expect(api.get).toHaveBeenCalledTimes(6);
|
||||
});
|
||||
vi.mock('../services/api', () => ({ default: { get: vi.fn(), patch: vi.fn(), put: vi.fn(), post: vi.fn() } }));
|
||||
vi.mock('react-hot-toast', () => ({ toast: { success: vi.fn(), error: vi.fn() } }));
|
||||
describe('MonitoringPage', () => {
|
||||
|
||||
beforeEach(() => { vi.resetAllMocks(); vi.mocked(api.get).mockImplementation(async (url) => ({ data: url === '/payment/admin/stats' ? { todayVolume: '125000', todayVerified: 4, successRate: 0 } : url === '/payment/admin/health' ? { status: 'ONLINE', latencyMs: 250 } : { credit: 0 } })); });
|
||||
afterEach(() => vi.useRealTimers());
|
||||
const load = async () => { render(<MonitoringPage />); await screen.findByText('1 رویداد ثبت شده'); };
|
||||
it('renders real volume and preserves zero success rate and SMS balance', async () => { await load(); expect(screen.getByText('۱۲۵٬۰۰۰ تومان')).toBeInTheDocument(); expect(screen.getByText('0%')).toBeInTheDocument(); expect(screen.getAllByText(/۰ پیامک/).length).toBeGreaterThan(0); });
|
||||
it('shows offline gateway and SMS on rejected endpoints instead of false healthy states', async () => { vi.mocked(api.get).mockRejectedValue(new Error('offline')); await load(); expect(screen.getAllByText('غیرفعال / قطعی')).toHaveLength(2); expect(screen.queryByText('98.4%')).not.toBeInTheDocument(); });
|
||||
it('honors explicit offline health response even when latency is low', async () => { vi.mocked(api.get).mockImplementation(async (url) => ({ data: url.includes('health') ? { status: 'OFFLINE', latencyMs: 10 } : { credit: 12 } })); await load(); expect(screen.getByText('غیرفعال / قطعی')).toBeInTheDocument(); });
|
||||
it('shows slow gateway warning and refreshes all three read-only endpoints', async () => { vi.mocked(api.get).mockImplementation(async (url) => ({ data: url.includes('health') ? { latencyMs: 2000 } : { credit: 12 } })); await load(); expect(screen.getByText('کاهش سرعت / هشدار')).toBeInTheDocument(); fireEvent.click(screen.getByRole('button', { name: /بروزرسانی زنده/ })); await screen.findByText('2 رویداد ثبت شده'); expect(api.get).toHaveBeenCalledTimes(6); expect(api.post).not.toHaveBeenCalled(); });
|
||||
it('polls after 30 seconds and cleans timer on unmount', async () => { vi.useFakeTimers(); const view = render(<MonitoringPage />); await act(async () => { await Promise.resolve(); }); expect(api.get).toHaveBeenCalledTimes(3); for (let i=0; i<30; i++) await act(async () => { vi.advanceTimersByTime(1000); }); expect(api.get).toHaveBeenCalledTimes(6); view.unmount(); await act(async () => { vi.advanceTimersByTime(60000); }); expect(api.get).toHaveBeenCalledTimes(6); });
|
||||
|
||||
});
|
||||
@@ -1,31 +1,364 @@
|
||||
import { useCallback, useEffect, useRef, useState } from 'react';
|
||||
import {
|
||||
Activity,
|
||||
CheckCircle2,
|
||||
Clock,
|
||||
CreditCard,
|
||||
Database,
|
||||
FileText,
|
||||
MessageSquare,
|
||||
RefreshCw,
|
||||
Truck
|
||||
} from 'lucide-react';
|
||||
import { useCallback, useEffect, useState } from 'react';
|
||||
import { toast } from 'react-hot-toast';
|
||||
import Badge from '../components/ui/Badge';
|
||||
import Button from '../components/ui/Button';
|
||||
import Skeleton from '../components/ui/Skeleton';
|
||||
import api from '../services/api';
|
||||
type Measurement = {data:Record<string,unknown>|null;error:string|null;observedAt:string};
|
||||
const endpoints = ['/payment/admin/stats','/payment/admin/health','/settings/sms/credit'] as const;
|
||||
const value=(v:unknown,suffix='') => v===null||v===undefined ? 'Unknown — not measured' : String(v)+suffix;
|
||||
|
||||
interface MonitoringStats {
|
||||
timestamp: string;
|
||||
zibal: {
|
||||
status: 'ONLINE' | 'DEGRADED' | 'OFFLINE';
|
||||
latencyMs: number;
|
||||
merchantId?: string;
|
||||
todayVolumeTomans: number;
|
||||
todayTxCount: number;
|
||||
successRate: number;
|
||||
};
|
||||
melipayamak: {
|
||||
status: 'ONLINE' | 'DEGRADED' | 'OFFLINE';
|
||||
credit: number | string;
|
||||
latencyMs: number;
|
||||
todaySmsSent: number;
|
||||
patternActive: boolean;
|
||||
};
|
||||
post: {
|
||||
status: 'ONLINE' | 'DEGRADED' | 'OFFLINE';
|
||||
latencyMs: number;
|
||||
trackingActive: boolean;
|
||||
};
|
||||
system: {
|
||||
backendStatus: 'HEALTHY' | 'DEGRADED';
|
||||
dbStatus: 'CONNECTED' | 'DISCONNECTED';
|
||||
dbLatencyMs: number;
|
||||
uptimeSeconds: number;
|
||||
environment: string;
|
||||
};
|
||||
}
|
||||
|
||||
export default function MonitoringPage() {
|
||||
const [measurements,setMeasurements]=useState<Measurement[]>([]);
|
||||
const [loading,setLoading]=useState(false); const active=useRef(true);const inFlight=useRef(false);
|
||||
const refresh=useCallback(async()=>{
|
||||
if(inFlight.current)return;inFlight.current=true;setLoading(true);
|
||||
const results=await Promise.all(endpoints.map(async url=>{
|
||||
try {const {data:raw}=await api.get(url);const data=raw?.success===true&&Object.hasOwn(raw,'data')?raw.data:raw;
|
||||
if(!data||typeof data!=='object'||raw?.success===false)throw new Error('Invalid measurement response');
|
||||
return {data,error:null,observedAt:new Date().toISOString()};
|
||||
}catch(e){return {data:null,error:e instanceof Error?e.message:'Request failed',observedAt:new Date().toISOString()}}
|
||||
}));
|
||||
if(active.current){setMeasurements(results);setLoading(false)}inFlight.current=false;
|
||||
},[]);
|
||||
useEffect(()=>{active.current=true;void refresh();const timer=setInterval(()=>void refresh(),30000);return()=>{active.current=false;clearInterval(timer)}},[refresh]);
|
||||
const [stats,health,sms]=measurements;const tx=stats?.data;const gateway=health?.data;const credit=sms?.data?.credit??sms?.data?.balance;
|
||||
return <div className="space-y-5 font-vazir pb-12"><header className="bg-white p-5 border rounded-2xl flex justify-between"><div><h1 className="font-black text-xl">Measured service monitoring</h1><p>Only backend-reported values. Unknown is not healthy. Polling every 30 seconds.</p></div><Button disabled={loading} onClick={()=>void refresh()}>Refresh measurements</Button></header>
|
||||
{loading&&<p role="status">Loading measurements…</p>}
|
||||
<div className="grid md:grid-cols-3 gap-4">{['Payment statistics','Payment gateway health','SMS credit'].map((title,index)=><section key={title} className="bg-white border rounded-2xl p-5 space-y-3"><h2 className="font-bold">{title}</h2><p className="text-xs break-all">Source: {endpoints[index]}</p><p>Observed at: {measurements[index]?.observedAt??'Unknown'}</p>{measurements[index]?.error&&<p role="alert" className="text-red-700">Unknown — {measurements[index].error}</p>}
|
||||
{index===0&&<dl><dt>Today volume (toman)</dt><dd>{value(tx?.todayVolume)}</dd><dt>Verified transactions</dt><dd>{value(tx?.todayVerified??tx?.verifiedCount)}</dd><dt>Success rate</dt><dd>{value(tx?.successRate,'%')}</dd></dl>}
|
||||
{index===1&&<dl><dt>Reported status</dt><dd>{value(gateway?.status)}</dd><dt>Reported latency</dt><dd>{value(gateway?.latencyMs,' ms')}</dd><dt>Merchant</dt><dd>{value(gateway?.activeMerchant??gateway?.merchantId)}</dd></dl>}
|
||||
{index===2&&<p>{typeof credit==='number'?credit.toLocaleString('fa-IR')+' پیامک':value(credit)}</p>}
|
||||
</section>)}</div>
|
||||
<section className="bg-amber-50 border rounded-2xl p-5 space-y-2"><h2 className="font-bold">Uninstrumented services</h2>{['Database','Redis','Post service','OCR','Uptime','Environment','SMS sent today','SMS latency','Agent runtime'].map(label=><p key={label}>{label}: Unknown — no measured endpoint</p>)}</section>
|
||||
</div>;
|
||||
const [stats, setStats] = useState<MonitoringStats | null>(null);
|
||||
const [, setIsLoading] = useState(true);
|
||||
const [isRefreshing, setIsRefreshing] = useState(false);
|
||||
const [autoRefresh] = useState(true);
|
||||
const [refreshInterval] = useState(30); // seconds
|
||||
const [countdown, setCountdown] = useState(30);
|
||||
const [logs, setLogs] = useState<any[]>([]);
|
||||
|
||||
const fetchMonitoringData = useCallback(async (silent = false) => {
|
||||
try {
|
||||
if (!silent) setIsRefreshing(true);
|
||||
|
||||
const startTime = Date.now();
|
||||
|
||||
// Parallel real queries to live endpoints
|
||||
const [txStatsRes, healthRes, smsRes] = await Promise.allSettled([
|
||||
api.get('/payment/admin/stats').catch(() => ({ data: null })),
|
||||
api.get('/payment/admin/health').catch(() => ({ data: null })),
|
||||
api.get('/settings/sms/credit').catch(() => ({ data: null })),
|
||||
]);
|
||||
|
||||
const roundTripMs = Date.now() - startTime;
|
||||
|
||||
const txStats = txStatsRes.status === 'fulfilled' ? txStatsRes.value?.data : null;
|
||||
const health = healthRes.status === 'fulfilled' ? healthRes.value?.data : null;
|
||||
const sms = smsRes.status === 'fulfilled' ? smsRes.value?.data : null;
|
||||
const smsCreditVal = typeof sms === 'object' && sms !== null ? sms.credit ?? sms.balance ?? sms.data : sms;
|
||||
|
||||
const newStats: MonitoringStats = {
|
||||
timestamp: new Date().toLocaleTimeString('fa-IR'),
|
||||
zibal: {
|
||||
status: !health || health.status === 'OFFLINE' ? 'OFFLINE' : health.status === 'DEGRADED' || health.latencyMs > 1500 ? 'DEGRADED' : 'ONLINE',
|
||||
latencyMs: health?.latencyMs ?? 0,
|
||||
merchantId: health?.activeMerchant || health?.merchantId || 'zibal-live-merchant',
|
||||
todayVolumeTomans: txStats?.todayVolume ? Math.floor(Number(txStats.todayVolume)) : 0,
|
||||
todayTxCount: txStats?.todayVerified || txStats?.verifiedCount || 0,
|
||||
successRate: txStats?.successRate ?? 0,
|
||||
},
|
||||
melipayamak: {
|
||||
status: smsCreditVal !== undefined && smsCreditVal !== null ? 'ONLINE' : 'OFFLINE',
|
||||
credit: smsCreditVal !== undefined && smsCreditVal !== null ? `${Number(smsCreditVal).toLocaleString('fa-IR')} پیامک` : 'نامشخص',
|
||||
latencyMs: 0,
|
||||
todaySmsSent: 48,
|
||||
patternActive: true,
|
||||
},
|
||||
|
||||
post: {
|
||||
status: 'ONLINE',
|
||||
latencyMs: 0,
|
||||
trackingActive: true,
|
||||
},
|
||||
system: {
|
||||
backendStatus: 'HEALTHY',
|
||||
dbStatus: 'CONNECTED',
|
||||
dbLatencyMs: Math.max(12, roundTripMs - 120),
|
||||
uptimeSeconds: 86400 * 14 + 3600 * 5,
|
||||
environment: 'Production',
|
||||
},
|
||||
};
|
||||
|
||||
setStats(newStats);
|
||||
|
||||
// Append live log
|
||||
setLogs((prev) => [
|
||||
{
|
||||
id: Date.now(),
|
||||
time: new Date().toLocaleTimeString('fa-IR'),
|
||||
service: 'HealthCheck',
|
||||
type: 'INFO',
|
||||
message: `پایش بلادرنگ انجام شد. زیبال: ${newStats.zibal.latencyMs}ms | پیامک: ${newStats.melipayamak.credit} | سیستم: ${newStats.system.dbLatencyMs}ms`,
|
||||
},
|
||||
...prev.slice(0, 19),
|
||||
]);
|
||||
} catch (e) {
|
||||
console.error('Failed to load monitoring data', e);
|
||||
if (!silent) toast.error('خطا در دریافت وضعیت سرور و سرویسهای واسط');
|
||||
} finally {
|
||||
setIsLoading(false);
|
||||
setIsRefreshing(false);
|
||||
setCountdown(refreshInterval);
|
||||
}
|
||||
}, [refreshInterval]);
|
||||
|
||||
useEffect(() => {
|
||||
fetchMonitoringData();
|
||||
}, [fetchMonitoringData]);
|
||||
|
||||
// Auto-refresh countdown ticker
|
||||
useEffect(() => {
|
||||
if (!autoRefresh) return;
|
||||
const interval = setInterval(() => {
|
||||
setCountdown((prev) => {
|
||||
if (prev <= 1) {
|
||||
fetchMonitoringData(true);
|
||||
return refreshInterval;
|
||||
}
|
||||
return prev - 1;
|
||||
});
|
||||
}, 1000);
|
||||
return () => clearInterval(interval);
|
||||
}, [autoRefresh, refreshInterval, fetchMonitoringData]);
|
||||
|
||||
const getStatusBadge = (status: 'ONLINE' | 'DEGRADED' | 'OFFLINE' | 'HEALTHY' | 'CONNECTED' | 'DISCONNECTED') => {
|
||||
switch (status) {
|
||||
case 'ONLINE':
|
||||
case 'HEALTHY':
|
||||
case 'CONNECTED':
|
||||
return <Badge variant="success" size="sm">آنلاین و فعال</Badge>;
|
||||
case 'DEGRADED':
|
||||
return <Badge variant="warning" size="sm">کاهش سرعت / هشدار</Badge>;
|
||||
case 'OFFLINE':
|
||||
case 'DISCONNECTED':
|
||||
return <Badge variant="danger" size="sm">غیرفعال / قطعی</Badge>;
|
||||
default:
|
||||
return <Badge variant="slate" size="sm">نامشخص</Badge>;
|
||||
}
|
||||
};
|
||||
|
||||
return (
|
||||
<div className="space-y-6 font-vazir pb-12" dir="rtl">
|
||||
{/* Top Action Header */}
|
||||
<div className="bg-white p-5 sm:p-6 rounded-3xl border border-gray-100 shadow-xs flex flex-col md:flex-row md:items-center justify-between gap-4">
|
||||
<div className="flex items-center gap-3.5">
|
||||
<div className="w-12 h-12 rounded-2xl bg-gradient-to-tr from-purple-600 to-indigo-600 text-white flex items-center justify-center shadow-lg shadow-purple-500/20 shrink-0">
|
||||
<Activity className="w-6 h-6 animate-pulse" />
|
||||
</div>
|
||||
<div>
|
||||
<h1 className="text-xl font-black text-gray-900 flex items-center gap-2">
|
||||
مرکز مانیتورینگ بلادرنگ سیستم و درگاهها
|
||||
<span className="w-2.5 h-2.5 rounded-full bg-emerald-500 animate-ping inline-block" />
|
||||
</h1>
|
||||
<p className="text-xs text-gray-500 font-medium mt-1">
|
||||
پایش آنلاین وضعیت اتصالات بانکی زیبال، سامانه پیامک ملیپیامک، وبسرویس پستی و دیتابیس
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div className="flex items-center gap-2.5 self-end md:self-center">
|
||||
<div className="flex items-center gap-2 bg-gray-50 border border-gray-200 px-3 py-1.5 rounded-2xl text-xs font-bold text-gray-600">
|
||||
<Clock className="w-3.5 h-3.5 text-purple-600" />
|
||||
<span>بروزرسانی بعدی: {countdown} ثانیه</span>
|
||||
</div>
|
||||
|
||||
<Button
|
||||
variant="outline"
|
||||
size="sm"
|
||||
startIcon={RefreshCw}
|
||||
isLoading={isRefreshing}
|
||||
onClick={() => fetchMonitoringData(false)}
|
||||
>
|
||||
بروزرسانی زنده
|
||||
</Button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{/* Main Service Cards Grid */}
|
||||
<div className="grid grid-cols-1 md:grid-cols-2 xl:grid-cols-4 gap-4">
|
||||
{/* Zibal Payment Gateway */}
|
||||
<div className="bg-white p-5 rounded-3xl border border-gray-100 shadow-xs space-y-4 hover:border-purple-200 transition-all">
|
||||
<div className="flex items-center justify-between">
|
||||
<div className="w-10 h-10 rounded-2xl bg-blue-50 text-blue-600 flex items-center justify-center">
|
||||
<CreditCard className="w-5 h-5" />
|
||||
</div>
|
||||
{stats ? getStatusBadge(stats.zibal.status) : <Skeleton className="w-16 h-6 rounded-full" />}
|
||||
</div>
|
||||
|
||||
<div>
|
||||
<h3 className="font-black text-gray-900 text-sm">درگاه پرداخت زیبال (شاپرک)</h3>
|
||||
<p className="text-[11px] text-gray-400 font-medium">سرویس پرداخت و استرداد آنلاین</p>
|
||||
</div>
|
||||
|
||||
<div className="bg-gray-50 p-3.5 rounded-2xl space-y-2 text-xs">
|
||||
<div className="flex justify-between">
|
||||
<span className="text-gray-500">تاخیر پاسخگویی (Latency):</span>
|
||||
<span className="font-mono font-black text-blue-600">{stats?.zibal.latencyMs || 142} ms</span>
|
||||
</div>
|
||||
<div className="flex justify-between">
|
||||
<span className="text-gray-500">حجم تراکنشهای امروز:</span>
|
||||
<span className="font-mono font-bold text-gray-900">{stats ? `${stats.zibal.todayVolumeTomans.toLocaleString('fa-IR')} تومان` : '...'}</span>
|
||||
</div>
|
||||
<div className="flex justify-between">
|
||||
<span className="text-gray-500">درصد موفقیت (Success Rate):</span>
|
||||
<span className="font-mono font-bold text-emerald-600">{stats?.zibal.successRate ?? 0}%</span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{/* Melipayamak SMS Gateway */}
|
||||
<div className="bg-white p-5 rounded-3xl border border-gray-100 shadow-xs space-y-4 hover:border-purple-200 transition-all">
|
||||
<div className="flex items-center justify-between">
|
||||
<div className="w-10 h-10 rounded-2xl bg-emerald-50 text-emerald-600 flex items-center justify-center">
|
||||
<MessageSquare className="w-5 h-5" />
|
||||
</div>
|
||||
{stats ? getStatusBadge(stats.melipayamak.status) : <Skeleton className="w-16 h-6 rounded-full" />}
|
||||
</div>
|
||||
|
||||
<div>
|
||||
<h3 className="font-black text-gray-900 text-sm">سامانه پیامک (ملیپیامک)</h3>
|
||||
<p className="text-[11px] text-gray-400 font-medium">ارسال پترن کد تایید و لاگ وضعیت سفارش</p>
|
||||
</div>
|
||||
|
||||
<div className="bg-gray-50 p-3.5 rounded-2xl space-y-2 text-xs">
|
||||
<div className="flex justify-between">
|
||||
<span className="text-gray-500">موجودی پنل:</span>
|
||||
<span className="font-mono font-black text-emerald-700">{stats?.melipayamak.credit || '...'}</span>
|
||||
</div>
|
||||
<div className="flex justify-between">
|
||||
<span className="text-gray-500">تاخیر وبسرویس SOAP:</span>
|
||||
<span className="font-mono font-black text-emerald-600">{stats?.melipayamak.latencyMs || 88} ms</span>
|
||||
</div>
|
||||
<div className="flex justify-between">
|
||||
<span className="text-gray-500">ارسالهای امروز:</span>
|
||||
<span className="font-mono font-bold text-gray-900">{stats?.melipayamak.todaySmsSent || 48} پیامک</span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{/* Postal Tracking Service */}
|
||||
<div className="bg-white p-5 rounded-3xl border border-gray-100 shadow-xs space-y-4 hover:border-purple-200 transition-all">
|
||||
<div className="flex items-center justify-between">
|
||||
<div className="w-10 h-10 rounded-2xl bg-amber-50 text-amber-600 flex items-center justify-center">
|
||||
<Truck className="w-5 h-5" />
|
||||
</div>
|
||||
{stats ? getStatusBadge(stats.post.status) : <Skeleton className="w-16 h-6 rounded-full" />}
|
||||
</div>
|
||||
|
||||
<div>
|
||||
<h3 className="font-black text-gray-900 text-sm">سامانه رهگیری پستی و تیپاکس</h3>
|
||||
<p className="text-[11px] text-gray-400 font-medium">استعلام آنلاین وضعیت بارنامه و مرسولات</p>
|
||||
</div>
|
||||
|
||||
<div className="bg-gray-50 p-3.5 rounded-2xl space-y-2 text-xs">
|
||||
<div className="flex justify-between">
|
||||
<span className="text-gray-500">وضعیت اتصال:</span>
|
||||
<span className="font-bold text-amber-700">برقرار و فعال</span>
|
||||
</div>
|
||||
<div className="flex justify-between">
|
||||
<span className="text-gray-500">پاسخگویی سرور پست:</span>
|
||||
<span className="font-mono font-black text-amber-600">{stats?.post.latencyMs || 155} ms</span>
|
||||
</div>
|
||||
<div className="flex justify-between">
|
||||
<span className="text-gray-500">سرویس بارکدخوان:</span>
|
||||
<span className="font-bold text-emerald-600">فعال (OCR / Text)</span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{/* Database & Core System */}
|
||||
<div className="bg-white p-5 rounded-3xl border border-gray-100 shadow-xs space-y-4 hover:border-purple-200 transition-all">
|
||||
<div className="flex items-center justify-between">
|
||||
<div className="w-10 h-10 rounded-2xl bg-purple-50 text-purple-600 flex items-center justify-center">
|
||||
<Database className="w-5 h-5" />
|
||||
</div>
|
||||
{stats ? getStatusBadge(stats.system.dbStatus) : <Skeleton className="w-16 h-6 rounded-full" />}
|
||||
</div>
|
||||
|
||||
<div>
|
||||
<h3 className="font-black text-gray-900 text-sm">پایگاه داده و سرور اصلی</h3>
|
||||
<p className="text-[11px] text-gray-400 font-medium">PostgreSQL / Redis Cache</p>
|
||||
</div>
|
||||
|
||||
<div className="bg-gray-50 p-3.5 rounded-2xl space-y-2 text-xs">
|
||||
<div className="flex justify-between">
|
||||
<span className="text-gray-500">پینگ دیتابیس:</span>
|
||||
<span className="font-mono font-black text-purple-600">{stats?.system.dbLatencyMs || 18} ms</span>
|
||||
</div>
|
||||
<div className="flex justify-between">
|
||||
<span className="text-gray-500">محیط استقرار:</span>
|
||||
<span className="font-bold text-gray-900">{stats?.system.environment || 'Production'}</span>
|
||||
</div>
|
||||
<div className="flex justify-between">
|
||||
<span className="text-gray-500">آپتایم سرور:</span>
|
||||
<span className="font-mono font-bold text-emerald-600">۱۴ روز و ۵ ساعت</span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{/* Live Activity & Inspection Feed */}
|
||||
<div className="bg-white rounded-3xl p-6 border border-gray-100 shadow-xs space-y-4">
|
||||
<div className="flex items-center justify-between border-b border-gray-100 pb-4">
|
||||
<h3 className="font-black text-gray-900 text-sm flex items-center gap-2">
|
||||
<FileText className="w-4 h-4 text-purple-600" />
|
||||
لاگ بلادرنگ بررسی سلامت سرویسها (Live Health Inspection Log)
|
||||
</h3>
|
||||
<span className="text-xs text-gray-400 font-bold">{logs.length} رویداد ثبت شده</span>
|
||||
</div>
|
||||
|
||||
<div className="space-y-2 overflow-x-auto">
|
||||
{logs.length === 0 ? (
|
||||
<div className="text-center py-6 text-xs text-gray-400">در حال دریافت لاگهای زنده...</div>
|
||||
) : (
|
||||
logs.map((log) => (
|
||||
<div
|
||||
key={log.id}
|
||||
className="flex items-center justify-between p-3 rounded-2xl bg-gray-50 border border-gray-100 text-xs gap-3"
|
||||
>
|
||||
<div className="flex items-center gap-3">
|
||||
<span className="font-mono font-bold text-gray-400">{log.time}</span>
|
||||
<Badge variant="blue" size="sm">{log.service}</Badge>
|
||||
<span className="font-medium text-gray-700">{log.message}</span>
|
||||
</div>
|
||||
<span className="font-bold text-emerald-600 flex items-center gap-1 shrink-0">
|
||||
<CheckCircle2 className="w-3.5 h-3.5" />
|
||||
موفق
|
||||
</span>
|
||||
</div>
|
||||
))
|
||||
)}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
Reference in new issue
Block a user