feature/domain-health-dashboard #2
@@ -49,6 +49,18 @@ type Props = {
|
||||
>;
|
||||
};
|
||||
|
||||
function getDomainStatusBadge(status: string | null) {
|
||||
const normalized = (status ?? "unknown").toLowerCase();
|
||||
|
||||
if (normalized === "active") return "bg-emerald-100 text-emerald-700";
|
||||
|
||||
if (normalized === "suspended") return "bg-rose-100 text-rose-700";
|
||||
|
||||
if (normalized === "inactive") return "bg-amber-100 text-amber-700";
|
||||
|
||||
return "bg-slate-100 text-slate-600";
|
||||
}
|
||||
|
||||
export function DashboardControls({
|
||||
instances,
|
||||
subscriptions,
|
||||
@@ -351,14 +363,28 @@ export function DashboardControls({
|
||||
<span className="font-medium">{instance.status}</span>
|
||||
</p>
|
||||
<p className="text-xs text-slate-500">
|
||||
Last sync: {formatDateTime(instance.last_sync_at)}
|
||||
{instance.last_sync_status
|
||||
? ` (${instance.last_sync_status})`
|
||||
: ""}
|
||||
Subscriptions: {instance.last_sync_subscriptions ?? 0}
|
||||
</p>
|
||||
<p className="text-xs text-slate-500">
|
||||
Last counts: {instance.last_sync_subscriptions ?? 0}{" "}
|
||||
subscriptions, {instance.last_sync_domains ?? 0} domains
|
||||
Domains: {instance.last_sync_domains ?? 0}
|
||||
</p>
|
||||
<p className="text-xs text-slate-500">
|
||||
Last sync status:{" "}
|
||||
<span
|
||||
className={`inline-flex rounded px-2 py-0.5 text-[11px] font-medium ${
|
||||
instance.last_sync_status === "success"
|
||||
? "bg-emerald-100 text-emerald-700"
|
||||
: instance.last_sync_status === "failed" ||
|
||||
instance.last_sync_status === "error"
|
||||
? "bg-rose-100 text-rose-700"
|
||||
: "bg-slate-100 text-slate-600"
|
||||
}`}
|
||||
>
|
||||
{instance.last_sync_status ?? "unknown"}
|
||||
</span>
|
||||
</p>
|
||||
<p className="text-xs text-slate-500">
|
||||
Last sync time: {formatDateTime(instance.last_sync_at)}
|
||||
</p>
|
||||
<p className="text-xs text-slate-500">
|
||||
Last connected:{" "}
|
||||
@@ -521,11 +547,15 @@ export function DashboardControls({
|
||||
) : (
|
||||
filteredDomains.map((domain) => (
|
||||
<tr key={domain.id} className="border-b border-slate-100">
|
||||
<td className="px-2 py-2 font-medium text-slate-900">
|
||||
<td className="font-medium text-slate-900">
|
||||
{domain.domain_name}
|
||||
</td>
|
||||
<td className="px-2 py-2">
|
||||
<span
|
||||
className={`inline-flex rounded px-2 py-0.5 text-xs font-medium ${getDomainStatusBadge(domain.status)}`}
|
||||
>
|
||||
{domain.status ?? "unknown"}
|
||||
</span>
|
||||
</td>
|
||||
<td className="px-2 py-2">
|
||||
{domain.hosting_type ?? "unknown"}
|
||||
|
||||
@@ -117,6 +117,9 @@ export async function syncPleskInstance(
|
||||
.map((item: any) => {
|
||||
const domainId = item?.id ?? item?.guid ?? item?.name;
|
||||
const domainName = item?.name ?? item?.domain_name ?? item?.domain;
|
||||
const status =
|
||||
item?.status ??
|
||||
(item?.hosting_type === "virtual" ? "active" : "inactive");
|
||||
const externalSubscriptionId =
|
||||
item?.subscription?.id ?? item?.subscription_id ?? item?.webspace_id;
|
||||
const rawCreated = item?.created_at ?? item?.created;
|
||||
@@ -141,12 +144,8 @@ export async function syncPleskInstance(
|
||||
: null,
|
||||
plesk_domain_id: String(domainId),
|
||||
domain_name: String(domainName),
|
||||
status: item?.status ? String(item.status) : null,
|
||||
hosting_type: item?.hosting_type
|
||||
? String(item.hosting_type)
|
||||
: item?.hosting?.type
|
||||
? String(item.hosting.type)
|
||||
: null,
|
||||
status: status ? String(status) : "unknown",
|
||||
hosting_type: item?.hosting_type ? String(item.hosting_type) : null,
|
||||
source_created_at: sourceCreatedAt,
|
||||
aliases_count: aliasesCount,
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user