feat(admin): plan statistics + node restart/close-ae actions
Build backend images / build content-svc (push) Failing after 1m22s
Build backend images / build file-svc (push) Failing after 3m8s
Build backend images / build gateway (push) Failing after 53s
Build backend images / build identity-svc (push) Failing after 57s
Build backend images / build notification-svc (push) Failing after 1m25s
Build backend images / build render-svc (push) Failing after 2m5s
Build backend images / build studio-svc (push) Failing after 3m59s
Build backend images / build content-svc (push) Failing after 1m22s
Build backend images / build file-svc (push) Failing after 3m8s
Build backend images / build gateway (push) Failing after 53s
Build backend images / build identity-svc (push) Failing after 57s
Build backend images / build notification-svc (push) Failing after 1m25s
Build backend images / build render-svc (push) Failing after 2m5s
Build backend images / build studio-svc (push) Failing after 3m59s
Final legacy-admin items: - identity GET /v1/admin/plan-statistics (active/total users + revenue per plan from user_plans); surfaced as a breakdown table in /admin/stats - NodesTable: wire Restart + Close-AE actions (backend already supported them) via new proxy routes; was only drain/release before Full DivineGateWeb legacy-admin parity achieved. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
@@ -107,6 +107,20 @@ export function NodesTable({ nodes }: { nodes: V2Node[] }) {
|
||||
>
|
||||
{t("actionDrain")}
|
||||
</button>
|
||||
<button
|
||||
onClick={() => action(node.id, "restart")}
|
||||
disabled={loading[node.id]}
|
||||
className="rounded px-2.5 py-1 text-xs text-blue-300 border border-blue-500/30 hover:bg-blue-500/10 disabled:opacity-40 disabled:cursor-not-allowed transition-colors"
|
||||
>
|
||||
{t("actionRestart")}
|
||||
</button>
|
||||
<button
|
||||
onClick={() => action(node.id, "close-ae")}
|
||||
disabled={loading[node.id]}
|
||||
className="rounded px-2.5 py-1 text-xs text-orange-300 border border-orange-500/30 hover:bg-orange-500/10 disabled:opacity-40 disabled:cursor-not-allowed transition-colors"
|
||||
>
|
||||
{t("actionCloseAe")}
|
||||
</button>
|
||||
<button
|
||||
onClick={() => action(node.id, "release")}
|
||||
disabled={loading[node.id]}
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
import { useEffect, useState } from "react";
|
||||
|
||||
interface Crm { total_signups: number; buyers: number; conversion_rate: number; revenue_minor: number; paying_users_all_time: number }
|
||||
interface PlanStat { plan_name: string; total: number; active: number; revenue_minor: number }
|
||||
|
||||
const card = "rounded-xl border border-[#1e2235] bg-[#0f1120] p-5";
|
||||
function toman(minor: number) { return (minor / 10).toLocaleString("fa-IR"); }
|
||||
@@ -19,14 +20,16 @@ async function total(path: string): Promise<number> {
|
||||
export function StatsAdmin() {
|
||||
const [crm, setCrm] = useState<Crm | null>(null);
|
||||
const [counts, setCounts] = useState<Record<string, number>>({});
|
||||
const [plans, setPlans] = useState<PlanStat[]>([]);
|
||||
const [loading, setLoading] = useState(true);
|
||||
|
||||
useEffect(() => {
|
||||
(async () => {
|
||||
const since = new Date(Date.now() - 365 * 864e5).toISOString().slice(0, 10);
|
||||
const to = new Date().toISOString().slice(0, 10);
|
||||
const [c, users, templates, categories, campaigns, blogs] = await Promise.all([
|
||||
const [c, ps, users, templates, categories, campaigns, blogs] = await Promise.all([
|
||||
fetch(`/api/admin/resource/admin/crm/analytics?start=${since}&end=${to}`, { cache: "no-store" }).then((x) => x.ok ? x.json() : null).catch(() => null),
|
||||
fetch(`/api/admin/resource/admin/plan-statistics`, { cache: "no-store" }).then((x) => x.ok ? x.json() : []).catch(() => []),
|
||||
total("users?pageSize=1"),
|
||||
total("templates?pageSize=1"),
|
||||
total("categories"),
|
||||
@@ -34,6 +37,7 @@ export function StatsAdmin() {
|
||||
total("blogs?pageSize=1"),
|
||||
]);
|
||||
setCrm(c);
|
||||
setPlans(Array.isArray(ps) ? ps : (ps?.data ?? []));
|
||||
setCounts({ users, templates, categories, campaigns, blogs });
|
||||
setLoading(false);
|
||||
})();
|
||||
@@ -73,6 +77,27 @@ export function StatsAdmin() {
|
||||
<div><div className="text-xl font-bold text-indigo-300">{(crm?.conversion_rate ?? 0).toLocaleString("fa-IR")}٪</div><div className="text-xs text-gray-500">تبدیل</div></div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div className={`${card} !p-0 overflow-hidden`}>
|
||||
<div className="p-5 pb-2 text-sm font-semibold text-white">آمار پلنها</div>
|
||||
<table className="w-full text-sm">
|
||||
<thead><tr className="border-b border-[#1e2235] text-right text-xs text-gray-500">
|
||||
<th className="px-5 py-2">پلن</th><th className="px-5 py-2">فعال</th><th className="px-5 py-2">کل</th><th className="px-5 py-2">درآمد</th>
|
||||
</tr></thead>
|
||||
<tbody>
|
||||
{plans.length === 0 ? (
|
||||
<tr><td colSpan={4} className="px-5 py-6 text-center text-gray-500">دادهای نیست.</td></tr>
|
||||
) : plans.map((p) => (
|
||||
<tr key={p.plan_name} className="border-b border-[#161a2e]">
|
||||
<td className="px-5 py-2 text-gray-200">{p.plan_name}</td>
|
||||
<td className="px-5 py-2 text-emerald-300">{(p.active ?? 0).toLocaleString("fa-IR")}</td>
|
||||
<td className="px-5 py-2 text-gray-400">{(p.total ?? 0).toLocaleString("fa-IR")}</td>
|
||||
<td className="px-5 py-2 text-gray-300">{toman(p.revenue_minor ?? 0)} ت</td>
|
||||
</tr>
|
||||
))}
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
</>
|
||||
)}
|
||||
</div>
|
||||
|
||||
Reference in New Issue
Block a user