Skip to content

Commit 588c121

Browse files
committed
feat: add recconect all nodes in general settings
1 parent 18616c7 commit 588c121

File tree

8 files changed

+424
-146
lines changed

8 files changed

+424
-146
lines changed

dashboard/public/statics/locales/en.json

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,13 @@
8989
"1h": "1 hour",
9090
"2h": "2 hours"
9191
}
92-
}
92+
},
93+
"reconnectinfo": "Refresh all nodes connections to resolve connectivity issues",
94+
"reconnectAll": "Reconnect All Nodes",
95+
"reconnectingAll": "Reconnecting...",
96+
"reconnectAllSuccess": "All nodes have been reconnected successfully",
97+
"reconnectAllFailed": "Failed to reconnect all nodes",
98+
"reconnectAllPrompt": "Are you sure you want to reconnect all nodes? This will temporarily disconnect all active connections and may take a few moments to complete."
9399
},
94100
"groups": "Groups",
95101
"documentation": "Documentation",
@@ -1508,5 +1514,13 @@
15081514
"message": "Your support helps us improve PasarGuard and build better features for everyone!",
15091515
"donate": "Donate Now",
15101516
"starOnGitHub": "Star on GitHub"
1517+
},
1518+
"goal": {
1519+
"currentGoal": "Current Goal",
1520+
"of": "of",
1521+
"remaining": "Remaining",
1522+
"contribute": "Contribute",
1523+
"completed": "Completed",
1524+
"pending": "In Progress"
15111525
}
1512-
}
1526+
}

dashboard/public/statics/locales/fa.json

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1134,7 +1134,13 @@
11341134
"1h": "۱ ساعت",
11351135
"2h": "۲ ساعت"
11361136
}
1137-
}
1137+
},
1138+
"reconnectinfo": "به‌روزرسانی همه اتصالات گره‌ها برای رفع مشکلات اتصال",
1139+
"reconnectAll": "اتصال مجدد همه گره‌ها",
1140+
"reconnectingAll": "در حال اتصال مجدد...",
1141+
"reconnectAllSuccess": "همه گره‌ها با موفقیت مجدداً متصل شدند",
1142+
"reconnectAllFailed": "اتصال مجدد همه گره‌ها با خطا مواجه شد",
1143+
"reconnectAllPrompt": "آیا مطمئن هستید که می‌خواهید همه گره‌ها را مجدداً متصل کنید؟ این عمل موقتاً تمام اتصالات فعال را قطع می‌کند و ممکن است چند لحظه طول بکشد."
11381144
},
11391145
"success": "موفق",
11401146
"error": "خطا",
@@ -1488,5 +1494,13 @@
14881494
"message": "حمایت شما به ما کمک می‌کند تا پاسارگارد را بهبود بخشیم و ویژگی‌های بهتری برای همه بسازیم!",
14891495
"donate": "حمایت مالی",
14901496
"starOnGitHub": "ستاره در GitHub"
1497+
},
1498+
"goal": {
1499+
"currentGoal": "هدف فعلی",
1500+
"of": "از",
1501+
"remaining": "باقیمانده",
1502+
"contribute": "مشارکت کنید",
1503+
"completed": "تکمیل شده",
1504+
"pending": "در حال انجام"
14911505
}
14921506
}

dashboard/public/statics/locales/ru.json

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,13 @@
102102
"1h": "1 час",
103103
"2h": "2 часа"
104104
}
105-
}
105+
},
106+
"reconnectinfo": "Обновить все соединения узлов для устранения проблем с подключением",
107+
"reconnectAll": "Переподключить все узлы",
108+
"reconnectingAll": "Переподключение...",
109+
"reconnectAllSuccess": "Все узлы успешно переподключены",
110+
"reconnectAllFailed": "Не удалось переподключить все узлы",
111+
"reconnectAllPrompt": "Вы уверены, что хотите переподключить все узлы? Это временно отключит все активные соединения и может занять несколько минут."
106112
},
107113
"groups": "Группы",
108114
"documentation": "Документация",
@@ -1497,5 +1503,13 @@
14971503
"message": "Ваша поддержка помогает нам улучшать PasarGuard и создавать лучшие функции для всех!",
14981504
"donate": "Поддержать проект",
14991505
"starOnGitHub": "Поставить звезду на GitHub"
1506+
},
1507+
"goal": {
1508+
"currentGoal": "Текущая цель",
1509+
"of": "из",
1510+
"remaining": "Осталось",
1511+
"contribute": "Поддержать",
1512+
"completed": "Завершено",
1513+
"pending": "В процессе"
15001514
}
15011515
}

dashboard/public/statics/locales/zh.json

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,13 @@
8484
"1h": "1小时",
8585
"2h": "2小时"
8686
}
87-
}
87+
},
88+
"reconnectinfo": "刷新所有节点连接以解决连接问题",
89+
"reconnectAll": "重新连接所有节点",
90+
"reconnectingAll": "重新连接中...",
91+
"reconnectAllSuccess": "所有节点已成功重新连接",
92+
"reconnectAllFailed": "重新连接所有节点失败",
93+
"reconnectAllPrompt": "您确定要重新连接所有节点吗?这将暂时断开所有活动连接,可能需要几分钟时间。"
8894
},
8995
"groups": "群组",
9096
"documentation": "文档",
@@ -1537,5 +1543,13 @@
15371543
"message": "您的支持帮助我们改进 PasarGuard 并为所有人构建更好的功能!",
15381544
"donate": "立即捐赠",
15391545
"starOnGitHub": "在 GitHub 上加星"
1546+
},
1547+
"goal": {
1548+
"currentGoal": "当前目标",
1549+
"of": "",
1550+
"remaining": "剩余",
1551+
"contribute": "贡献",
1552+
"completed": "已完成",
1553+
"pending": "进行中"
15401554
}
15411555
}
Lines changed: 103 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,103 @@
1+
import { Progress } from '@/components/ui/progress'
2+
import { Card, CardContent } from '@/components/ui/card'
3+
import { useCurrentGoal } from '@/hooks/use-goal'
4+
import { Target, TrendingUp } from 'lucide-react'
5+
import { useTranslation } from 'react-i18next'
6+
import { Skeleton } from '@/components/ui/skeleton'
7+
import { cn } from '@/lib/utils'
8+
9+
export function GoalProgress() {
10+
const { data: goal, isLoading, isError } = useCurrentGoal()
11+
const { t } = useTranslation()
12+
13+
if (isLoading) {
14+
return (
15+
<div className="space-y-2 px-4 py-3">
16+
<Skeleton className="h-4 w-24" />
17+
<Skeleton className="h-2 w-full" />
18+
<Skeleton className="h-3 w-32" />
19+
</div>
20+
)
21+
}
22+
23+
if (isError || !goal) {
24+
return null
25+
}
26+
27+
const progress = Math.min((goal.paid_amount / goal.price) * 100, 100)
28+
const remaining = Math.max(goal.price - goal.paid_amount, 0)
29+
30+
return (
31+
<Card className="mx-2 mb-2 border-primary/20 bg-gradient-to-br from-primary/5 to-primary/10 dark:from-primary/10 dark:to-primary/20">
32+
<CardContent className="p-3">
33+
<div className="space-y-2.5">
34+
{/* Header */}
35+
<div className="flex items-start justify-between gap-2">
36+
<div className="flex items-center gap-2">
37+
<div className="flex h-8 w-8 items-center justify-center rounded-full bg-primary/20">
38+
<Target className="h-4 w-4 text-primary" />
39+
</div>
40+
<div className="flex flex-col">
41+
<span className="text-xs font-medium text-muted-foreground">{t('goal.currentGoal')}</span>
42+
<span className="line-clamp-1 text-sm font-semibold leading-tight">{goal.name}</span>
43+
</div>
44+
</div>
45+
<div
46+
className={cn(
47+
'flex items-center gap-1 rounded-full px-2 py-0.5 text-xs font-medium',
48+
goal.status === 'completed' ? 'bg-green-500/20 text-green-700 dark:text-green-400' : 'bg-amber-500/20 text-amber-700 dark:text-amber-400'
49+
)}
50+
>
51+
<TrendingUp className="h-3 w-3" />
52+
{progress.toFixed(0)}%
53+
</div>
54+
</div>
55+
56+
{/* Progress Bar */}
57+
<div className="space-y-1">
58+
<Progress value={progress} className="h-2" />
59+
<div className="flex items-center justify-between text-xs">
60+
<span className="font-medium text-primary">
61+
${goal.paid_amount.toLocaleString()}
62+
</span>
63+
<span className="text-muted-foreground">
64+
{t('goal.of')} ${goal.price.toLocaleString()}
65+
</span>
66+
</div>
67+
</div>
68+
69+
{/* Details */}
70+
{goal.detail && (
71+
<p className="line-clamp-2 text-xs leading-relaxed text-muted-foreground">
72+
{goal.detail}
73+
</p>
74+
)}
75+
76+
{/* Remaining */}
77+
{remaining > 0 && (
78+
<div className="flex items-center justify-between rounded-md bg-background/50 px-2 py-1.5">
79+
<span className="text-xs font-medium text-muted-foreground">
80+
{t('goal.remaining')}
81+
</span>
82+
<span className="text-xs font-semibold text-foreground">
83+
${remaining.toLocaleString()}
84+
</span>
85+
</div>
86+
)}
87+
88+
{/* CTA Button */}
89+
<a
90+
href="https://donate.pasarguard.org"
91+
target="_blank"
92+
rel="noopener noreferrer"
93+
className="flex w-full items-center justify-center gap-2 rounded-md bg-primary px-3 py-2 text-xs font-semibold text-primary-foreground transition-all hover:bg-primary/90 hover:shadow-md"
94+
>
95+
<Target className="h-3.5 w-3.5" />
96+
{t('goal.contribute')}
97+
</a>
98+
</div>
99+
</CardContent>
100+
</Card>
101+
)
102+
}
103+

0 commit comments

Comments
 (0)