qarpeo 0.1.18 → 0.1.21
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +96 -96
- package/dist/chunks/auth-schema.mjs +3 -1
- package/dist/chunks/wrangler.mjs +22 -3
- package/dist/cli/index.mjs +448 -221
- package/dist/fate/index.d.ts +29 -22
- package/dist/fate/index.mjs +1 -3
- package/dist/module.d.ts +1 -1
- package/dist/module.mjs +103 -82
- package/dist/runtime/ai.d.ts +2 -2
- package/dist/runtime/app/components/BlobImage.vue +119 -107
- package/dist/runtime/app/components/CMSBlocks.vue +104 -93
- package/dist/runtime/app/components/CMSContent.vue +24 -23
- package/dist/runtime/app/components/CMSImage.vue +49 -49
- package/dist/runtime/app/components/CMSLocaleSwitcher.vue +110 -110
- package/dist/runtime/app/components/CMSPreviewBanner.vue +83 -79
- package/dist/runtime/app/components/CMSVersionBanner.vue +53 -49
- package/dist/runtime/app/components/CMSVersionSwitcher.vue +140 -140
- package/dist/runtime/app/components/ContentRenderer.vue +83 -80
- package/dist/runtime/app/components/FileUpload.vue +200 -196
- package/dist/runtime/app/components/ImpersonationBanner.vue +61 -57
- package/dist/runtime/app/components/QarpeoWelcome.vue +84 -84
- package/dist/runtime/app/components/SignedIn.vue +13 -13
- package/dist/runtime/app/components/SignedOut.vue +13 -13
- package/dist/runtime/app/components/shiki.css +34 -34
- package/dist/runtime/app/composables/ai.d.ts +22 -22
- package/dist/runtime/app/composables/ai.mjs +3 -7
- package/dist/runtime/app/composables/analytics.mjs +1 -1
- package/dist/runtime/app/composables/api-tokens.mjs +1 -1
- package/dist/runtime/app/composables/auth.d.ts +6 -7
- package/dist/runtime/app/composables/auth.mjs +6 -3
- package/dist/runtime/app/composables/chat.mjs +3 -7
- package/dist/runtime/app/composables/cms-preview.d.ts +3 -3
- package/dist/runtime/app/composables/cms-preview.mjs +1 -1
- package/dist/runtime/app/composables/cms.d.ts +3 -5
- package/dist/runtime/app/composables/cms.mjs +2 -2
- package/dist/runtime/app/composables/docs-version.d.ts +8 -7
- package/dist/runtime/app/composables/docs-version.mjs +3 -3
- package/dist/runtime/app/composables/impersonation.mjs +1 -1
- package/dist/runtime/app/composables/notifications.d.ts +5 -5
- package/dist/runtime/app/composables/notifications.mjs +4 -5
- package/dist/runtime/app/composables/organization.mjs +1 -1
- package/dist/runtime/app/composables/passkey.mjs +1 -1
- package/dist/runtime/app/composables/passwordless.mjs +1 -1
- package/dist/runtime/app/composables/payments.d.ts +2 -1
- package/dist/runtime/app/composables/payments.mjs +1 -1
- package/dist/runtime/app/composables/realtime.d.ts +13 -13
- package/dist/runtime/app/composables/realtime.mjs +2 -2
- package/dist/runtime/app/composables/resumable-upload.d.ts +11 -11
- package/dist/runtime/app/composables/resumable-upload.mjs +1 -1
- package/dist/runtime/app/composables/site.mjs +1 -1
- package/dist/runtime/app/composables/storage.d.ts +151 -11
- package/dist/runtime/app/composables/storage.mjs +291 -33
- package/dist/runtime/app/composables/turnstile.mjs +1 -1
- package/dist/runtime/app/composables/two-factor.mjs +1 -1
- package/dist/runtime/app/pages/devtools/agents.vue +716 -716
- package/dist/runtime/app/pages/devtools/analytics.vue +616 -616
- package/dist/runtime/app/pages/devtools/auth.vue +381 -350
- package/dist/runtime/app/pages/devtools/blob.vue +743 -744
- package/dist/runtime/app/pages/devtools/db.vue +545 -545
- package/dist/runtime/app/pages/devtools/domains.vue +771 -771
- package/dist/runtime/app/pages/devtools/kv.vue +827 -828
- package/dist/runtime/app/pages/devtools/logs.vue +649 -653
- package/dist/runtime/app/pages/devtools/mail.vue +388 -388
- package/dist/runtime/app/pages/devtools/overview.vue +391 -389
- package/dist/runtime/app/pages/devtools/realtime.vue +89 -27
- package/dist/runtime/app/pages/devtools/security.vue +20 -5
- package/dist/runtime/app/pages/devtools/settings.vue +559 -559
- package/dist/runtime/app/pages/devtools/tasks.vue +26 -10
- package/dist/runtime/app/pages/devtools.vue +176 -176
- package/dist/runtime/app/plugins/seo.mjs +1 -1
- package/dist/runtime/app/plugins/shortcuts.client.d.ts +1 -4
- package/dist/runtime/app/public/sw-notifications.mjs +47 -52
- package/dist/runtime/blob.mjs +11 -4
- package/dist/runtime/browser.d.ts +1 -1
- package/dist/runtime/browser.mjs +12 -2
- package/dist/runtime/cache.d.ts +2 -1
- package/dist/runtime/kv.mjs +4 -1
- package/dist/runtime/providers/qarpeo.d.ts +3 -3
- package/dist/runtime/server/durable-objects/agent.mjs +1 -1
- package/dist/runtime/server/durable-objects/room.d.ts +2 -2
- package/dist/runtime/server/durable-objects/room.mjs +5 -5
- package/dist/runtime/server/middleware/devtools.mjs +6 -2
- package/dist/runtime/server/plugins/cms.d.ts +4 -2
- package/dist/runtime/server/plugins/dev-proxy.mjs +1 -1
- package/dist/runtime/server/routes/__qarpeo/agents/chat.post.d.ts +2 -2
- package/dist/runtime/server/routes/__qarpeo/agents/chat.post.mjs +4 -1
- package/dist/runtime/server/routes/__qarpeo/analytics/events.get.d.ts +1 -4
- package/dist/runtime/server/routes/__qarpeo/analytics/summary.get.d.ts +2 -2
- package/dist/runtime/server/routes/__qarpeo/analytics/summary.get.mjs +5 -1
- package/dist/runtime/server/routes/__qarpeo/db/tables.get.d.ts +2 -2
- package/dist/runtime/server/routes/__qarpeo/db/tables.get.mjs +1 -1
- package/dist/runtime/server/routes/__qarpeo/logs.get.d.ts +4 -1
- package/dist/runtime/server/routes/__qarpeo/mail/track/click/[id].get.mjs +1 -1
- package/dist/runtime/server/routes/__qarpeo/mail/track/open/[id].get.mjs +2 -2
- package/dist/runtime/server/routes/__qarpeo/overview.get.d.ts +2 -2
- package/dist/runtime/server/routes/__qarpeo/realtime/broadcast.post.d.ts +2 -2
- package/dist/runtime/server/routes/__qarpeo/realtime/broadcast.post.mjs +1 -1
- package/dist/runtime/server/routes/__qarpeo/realtime/clear.post.d.ts +1 -4
- package/dist/runtime/server/routes/__qarpeo/realtime/clear.post.mjs +1 -1
- package/dist/runtime/server/routes/__qarpeo/realtime/disconnect.post.d.ts +1 -4
- package/dist/runtime/server/routes/__qarpeo/realtime/disconnect.post.mjs +1 -1
- package/dist/runtime/server/routes/__qarpeo/realtime/room.get.d.ts +2 -2
- package/dist/runtime/server/routes/__qarpeo/realtime/rooms.get.d.ts +2 -2
- package/dist/runtime/server/routes/__qarpeo/security/analytics.get.d.ts +2 -2
- package/dist/runtime/server/routes/__qarpeo/security/ban.post.d.ts +1 -4
- package/dist/runtime/server/routes/__qarpeo/security/clear.post.d.ts +1 -4
- package/dist/runtime/server/routes/__qarpeo/security/unban.post.d.ts +1 -4
- package/dist/runtime/server/routes/__qarpeo/settings.get.mjs +1 -1
- package/dist/runtime/server/routes/__qarpeo/tasks/run.post.mjs +3 -1
- package/dist/runtime/server/routes/agents/[agent]/chat.post.mjs +8 -2
- package/dist/runtime/server/routes/agents/[agent]/clear.post.mjs +8 -2
- package/dist/runtime/server/routes/agents/[agent]/history.get.mjs +8 -2
- package/dist/runtime/server/routes/ai/embed.post.d.ts +1 -4
- package/dist/runtime/server/routes/ai/search.post.d.ts +2 -2
- package/dist/runtime/server/routes/auth/account.delete.mjs +1 -1
- package/dist/runtime/server/routes/auth/handler.mjs +6 -1
- package/dist/runtime/server/routes/auth/magic-link/verify.get.mjs +1 -1
- package/dist/runtime/server/routes/auth/organization/members/[id].delete.mjs +7 -1
- package/dist/runtime/server/routes/auth/otp/verify.post.mjs +1 -1
- package/dist/runtime/server/routes/auth/sso/login.get.mjs +7 -1
- package/dist/runtime/server/routes/auth/sso/oidc/callback.get.mjs +8 -2
- package/dist/runtime/server/routes/auth/sso/saml/acs.post.mjs +7 -2
- package/dist/runtime/server/routes/auth/webauthn/login/options.post.mjs +1 -1
- package/dist/runtime/server/routes/auth/webauthn/login/verify.post.mjs +7 -2
- package/dist/runtime/server/routes/auth/webauthn/register/options.post.mjs +6 -1
- package/dist/runtime/server/routes/auth/webauthn/register/verify.post.mjs +6 -1
- package/dist/runtime/server/routes/browser/crawl.post.d.ts +1 -2
- package/dist/runtime/server/routes/browser/invoice.post.d.ts +1 -2
- package/dist/runtime/server/routes/browser/og-image.post.d.ts +2 -2
- package/dist/runtime/server/routes/browser/pdf.post.d.ts +1 -2
- package/dist/runtime/server/routes/browser/pdf.post.mjs +6 -1
- package/dist/runtime/server/routes/browser/screenshot.post.d.ts +2 -2
- package/dist/runtime/server/routes/browser/screenshot.post.mjs +5 -1
- package/dist/runtime/server/routes/cms/components/index.get.d.ts +2 -2
- package/dist/runtime/server/routes/cms/preview/disable.get.d.ts +4 -3
- package/dist/runtime/server/routes/cms/preview/enable.get.d.ts +8 -8
- package/dist/runtime/server/routes/cms/search.get.mjs +1 -1
- package/dist/runtime/server/routes/cms/webhooks/[provider].post.d.ts +7 -7
- package/dist/runtime/server/routes/cms/webhooks/[provider].post.mjs +9 -2
- package/dist/runtime/server/routes/docs/search.get.d.ts +9 -9
- package/dist/runtime/server/routes/fate.mjs +5 -8
- package/dist/runtime/server/routes/mail/bounce.post.d.ts +2 -2
- package/dist/runtime/server/routes/mail/unsubscribe.d.ts +2 -2
- package/dist/runtime/server/routes/mail/webhooks.post.d.ts +2 -2
- package/dist/runtime/server/routes/mail/webhooks.post.mjs +7 -1
- package/dist/runtime/server/routes/payments/usage.get.d.ts +8 -8
- package/dist/runtime/server/routes/payments/usage.post.d.ts +2 -2
- package/dist/runtime/server/routes/realtime/history.delete.d.ts +4 -3
- package/dist/runtime/server/routes/realtime/history.get.d.ts +7 -6
- package/dist/runtime/server/routes/realtime/ws.get.mjs +6 -1
- package/dist/runtime/server/routes/robots.txt.get.mjs +1 -1
- package/dist/runtime/server/routes/sitemap.xml.get.mjs +2 -1
- package/dist/runtime/server/routes/storage/multipart/abort.post.d.ts +2 -2
- package/dist/runtime/server/routes/storage/multipart/complete.post.d.ts +2 -2
- package/dist/runtime/server/routes/storage/multipart/complete.post.mjs +2 -2
- package/dist/runtime/server/routes/storage/multipart/create.post.d.ts +2 -2
- package/dist/runtime/server/routes/storage/multipart/create.post.mjs +7 -3
- package/dist/runtime/server/routes/storage/multipart/part.put.d.ts +2 -2
- package/dist/runtime/server/routes/storage/multipart/part.put.mjs +1 -1
- package/dist/runtime/server/routes/tenants/[tenant]/domains/[domain]/index.delete.mjs +2 -4
- package/dist/runtime/server/routes/tenants/[tenant]/domains/[domain]/verify.post.mjs +2 -4
- package/dist/runtime/server/routes/tenants/[tenant]/domains/index.get.mjs +1 -1
- package/dist/runtime/server/routes/tenants/[tenant]/domains/index.post.mjs +2 -4
- package/dist/runtime/server/tasks/cms/publish.mjs +1 -1
- package/dist/runtime/server/utils/ai.d.ts +9 -9
- package/dist/runtime/server/utils/ai.mjs +3 -3
- package/dist/runtime/server/utils/auth.d.ts +12 -16
- package/dist/runtime/server/utils/auth.mjs +15 -9
- package/dist/runtime/server/utils/bots.mjs +21 -7
- package/dist/runtime/server/utils/browser-utils.d.ts +44 -41
- package/dist/runtime/server/utils/browser-utils.mjs +14 -4
- package/dist/runtime/server/utils/cache.d.ts +5 -5
- package/dist/runtime/server/utils/cms/common.d.ts +26 -0
- package/dist/runtime/server/utils/cms/common.mjs +68 -0
- package/dist/runtime/server/utils/cms/git.d.ts +24 -0
- package/dist/runtime/server/utils/cms/git.mjs +240 -0
- package/dist/runtime/server/utils/cms/markdown.d.ts +22 -0
- package/dist/runtime/server/utils/cms/markdown.mjs +92 -0
- package/dist/runtime/server/utils/cms/path.d.ts +51 -0
- package/dist/runtime/server/utils/cms/path.mjs +127 -0
- package/dist/runtime/server/utils/cms/search.d.ts +22 -0
- package/dist/runtime/server/utils/cms/search.mjs +221 -0
- package/dist/runtime/server/utils/cms-events.d.ts +1 -1
- package/dist/runtime/server/utils/cms-events.mjs +2 -2
- package/dist/runtime/server/utils/cms-filter.mjs +2 -2
- package/dist/runtime/server/utils/cms.d.ts +17 -149
- package/dist/runtime/server/utils/cms.mjs +52 -761
- package/dist/runtime/server/utils/config.d.ts +5 -4
- package/dist/runtime/server/utils/domains.mjs +7 -4
- package/dist/runtime/server/utils/email-templates.d.ts +10 -7
- package/dist/runtime/server/utils/email-templates.mjs +20 -5
- package/dist/runtime/server/utils/feed.d.ts +2 -2
- package/dist/runtime/server/utils/feed.mjs +3 -1
- package/dist/runtime/server/utils/mail-suppression.d.ts +8 -24
- package/dist/runtime/server/utils/mail-suppression.mjs +2 -2
- package/dist/runtime/server/utils/mail.d.ts +7 -8
- package/dist/runtime/server/utils/mail.mjs +17 -12
- package/dist/runtime/server/utils/multipart-store.d.ts +2 -2
- package/dist/runtime/server/utils/notifications.d.ts +9 -23
- package/dist/runtime/server/utils/organization.mjs +4 -12
- package/dist/runtime/server/utils/passwordless.mjs +1 -1
- package/dist/runtime/server/utils/payments.d.ts +2 -6
- package/dist/runtime/server/utils/payments.mjs +1 -1
- package/dist/runtime/server/utils/queue.d.ts +21 -31
- package/dist/runtime/server/utils/rag.d.ts +4 -4
- package/dist/runtime/server/utils/rag.mjs +8 -8
- package/dist/runtime/server/utils/realtime-store.d.ts +2 -2
- package/dist/runtime/server/utils/realtime.d.ts +26 -28
- package/dist/runtime/server/utils/scheduled-task.d.ts +1 -3
- package/dist/runtime/server/utils/security-store.d.ts +2 -2
- package/dist/runtime/server/utils/session.d.ts +9 -11
- package/dist/runtime/server/utils/sso.d.ts +9 -15
- package/dist/runtime/server/utils/sso.mjs +4 -8
- package/dist/runtime/server/utils/storage.d.ts +19 -2
- package/dist/runtime/server/utils/storage.mjs +36 -7
- package/dist/runtime/server/utils/tenant.mjs +3 -1
- package/dist/runtime/server/utils/turnstile.d.ts +3 -5
- package/dist/runtime/server/utils/vapid.d.ts +5 -8
- package/dist/runtime/server/utils/vapid.mjs +26 -13
- package/dist/runtime/service.d.ts +13 -13
- package/dist/runtime/service.mjs +4 -2
- package/dist/runtime/test-utils.d.ts +20 -30
- package/dist/runtime/test-utils.mjs +5 -4
- package/dist/runtime/types/auth-globals.d.ts +14 -14
- package/dist/runtime/types/imports.d.ts +82 -82
- package/dist/runtime/types/index.d.ts +2 -2
- package/dist/runtime/types/r2.d.ts +5 -0
- package/dist/runtime/types/service.d.ts +11 -18
- package/dist/types.d.ts +100 -107
- package/dist/utils/auth-schema.d.ts +2 -2
- package/dist/utils/cms-sources.d.ts +3 -3
- package/dist/utils/local-db.d.ts +3 -3
- package/dist/utils/notifications-schema.d.ts +1 -3
- package/dist/utils/pkg.d.ts +7 -0
- package/dist/utils/queue.d.ts +3 -3
- package/dist/utils/tasks.d.ts +3 -2
- package/package.json +11 -8
|
@@ -1,771 +1,771 @@
|
|
|
1
|
-
<script setup lang="ts">
|
|
2
|
-
import {
|
|
3
|
-
import
|
|
4
|
-
import { computed, onMounted, ref } from "vue"
|
|
5
|
-
|
|
6
|
-
const route = useRoute()
|
|
7
|
-
|
|
8
|
-
interface TenantRecord {
|
|
9
|
-
id: string
|
|
10
|
-
slug: string
|
|
11
|
-
name: string
|
|
12
|
-
plan: string
|
|
13
|
-
customDomain?: string
|
|
14
|
-
logoUrl?: string
|
|
15
|
-
metadata?: Record<string, any>
|
|
16
|
-
createdAt?: number
|
|
17
|
-
updatedAt?: number
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
interface CustomDomainRecord {
|
|
21
|
-
id: string
|
|
22
|
-
tenantId: string
|
|
23
|
-
domain: string
|
|
24
|
-
status: "pending_validation" | "active" | "error" | "deleted"
|
|
25
|
-
sslStatus: "initializing" | "pending_validation" | "active" | "expired" | "error"
|
|
26
|
-
cnameTarget?: string
|
|
27
|
-
cloudflareHostnameId?: string
|
|
28
|
-
createdAt?: number
|
|
29
|
-
updatedAt?: number
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
interface DomainsApiResponse {
|
|
33
|
-
tenants: TenantRecord[]
|
|
34
|
-
domains: CustomDomainRecord[]
|
|
35
|
-
config: {
|
|
36
|
-
rootDomains: string[]
|
|
37
|
-
cnameTarget: string
|
|
38
|
-
provider: string
|
|
39
|
-
customDomainsEnabled: boolean
|
|
40
|
-
}
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
const {
|
|
44
|
-
data: apiData,
|
|
45
|
-
status: apiStatus,
|
|
46
|
-
pending: apiPending,
|
|
47
|
-
execute: executeLoad,
|
|
48
|
-
} = useFetch<DomainsApiResponse>("/_qarpeo/api/tenants/list", {
|
|
49
|
-
immediate: false,
|
|
50
|
-
lazy: true,
|
|
51
|
-
default: () => ({
|
|
52
|
-
tenants: [],
|
|
53
|
-
domains: [],
|
|
54
|
-
config: {
|
|
55
|
-
rootDomains: ["qarpeo.dev"],
|
|
56
|
-
cnameTarget: "cname.qarpeo.com",
|
|
57
|
-
provider: "cloudflare",
|
|
58
|
-
customDomainsEnabled: true,
|
|
59
|
-
},
|
|
60
|
-
}),
|
|
61
|
-
})
|
|
62
|
-
|
|
63
|
-
const loading = computed(
|
|
64
|
-
() => apiPending.value || apiStatus.value === "idle" || apiStatus.value === "pending",
|
|
65
|
-
)
|
|
66
|
-
|
|
67
|
-
const tenants = computed(() => apiData.value?.tenants || [])
|
|
68
|
-
const domains = computed(() => apiData.value?.domains || [])
|
|
69
|
-
const multitenantConfig = computed(() => apiData.value?.config)
|
|
70
|
-
|
|
71
|
-
const tenantSearch = ref("")
|
|
72
|
-
const domainSearch = ref("")
|
|
73
|
-
const selectedTenantId = computed(
|
|
74
|
-
() => (route.query.tenant as string) || tenants.value[0]?.id || null,
|
|
75
|
-
)
|
|
76
|
-
|
|
77
|
-
// Filtered Tenants
|
|
78
|
-
const filteredTenants = computed(() => {
|
|
79
|
-
if (!tenantSearch.value.trim()) return tenants.value
|
|
80
|
-
const q = tenantSearch.value.toLowerCase()
|
|
81
|
-
return tenants.value.filter(
|
|
82
|
-
(t) => t.name.toLowerCase().includes(q) || t.slug.toLowerCase().includes(q),
|
|
83
|
-
)
|
|
84
|
-
})
|
|
85
|
-
|
|
86
|
-
// Current Selected Tenant
|
|
87
|
-
const currentTenant = computed(
|
|
88
|
-
() => tenants.value.find((t) => t.id === selectedTenantId.value) || tenants.value[0] || null,
|
|
89
|
-
)
|
|
90
|
-
|
|
91
|
-
// Domains for Selected Tenant
|
|
92
|
-
const tenantDomains = computed(() => {
|
|
93
|
-
if (!currentTenant.value) return []
|
|
94
|
-
let list = domains.value.filter((d) => d.tenantId === currentTenant.value.id)
|
|
95
|
-
if (domainSearch.value.trim()) {
|
|
96
|
-
const q = domainSearch.value.toLowerCase()
|
|
97
|
-
list = list.filter((d) => d.domain.toLowerCase().includes(q))
|
|
98
|
-
}
|
|
99
|
-
return list
|
|
100
|
-
})
|
|
101
|
-
|
|
102
|
-
// Nav items for left panel
|
|
103
|
-
const tenantNavItems = computed<NavigationMenuItem[]>(() =>
|
|
104
|
-
filteredTenants.value.map((t) => {
|
|
105
|
-
const count = domains.value.filter((d) => d.tenantId === t.id).length
|
|
106
|
-
return {
|
|
107
|
-
label: t.name,
|
|
108
|
-
icon: "i-lucide-building-2",
|
|
109
|
-
value: t.id,
|
|
110
|
-
badge: {
|
|
111
|
-
label: `${count} ${count === 1 ? "domain" : "domains"}`,
|
|
112
|
-
size: "sm" as const,
|
|
113
|
-
color: "neutral" as const,
|
|
114
|
-
variant: "subtle" as const,
|
|
115
|
-
},
|
|
116
|
-
class: "text-xs",
|
|
117
|
-
to: { query: { ...route.query, tenant: t.id } },
|
|
118
|
-
active: selectedTenantId.value === t.id,
|
|
119
|
-
}
|
|
120
|
-
}),
|
|
121
|
-
)
|
|
122
|
-
|
|
123
|
-
// Counts
|
|
124
|
-
const activeDomainsCount = computed(
|
|
125
|
-
() => tenantDomains.value.filter((d) => d.sslStatus === "active").length,
|
|
126
|
-
)
|
|
127
|
-
const pendingDomainsCount = computed(
|
|
128
|
-
() => tenantDomains.value.filter((d) => d.sslStatus !== "active").length,
|
|
129
|
-
)
|
|
130
|
-
|
|
131
|
-
function getSslBadgeColor(status?: string): "success" | "warning" | "error" | "neutral" {
|
|
132
|
-
if (status === "active") return "success"
|
|
133
|
-
if (status === "pending_validation" || status === "initializing") return "warning"
|
|
134
|
-
if (status === "error" || status === "expired") return "error"
|
|
135
|
-
return "neutral"
|
|
136
|
-
}
|
|
137
|
-
|
|
138
|
-
// ─── Actions: Modals & API Calls ──────────────────────────────────────────────
|
|
139
|
-
const showNewTenantModal = ref(false)
|
|
140
|
-
const newTenantForm = ref({ name: "", slug: "", plan: "pro" })
|
|
141
|
-
const creatingTenant = ref(false)
|
|
142
|
-
const tenantError = ref<string | null>(null)
|
|
143
|
-
|
|
144
|
-
function openNewTenantModal() {
|
|
145
|
-
newTenantForm.value = { name: "", slug: "", plan: "pro" }
|
|
146
|
-
tenantError.value = null
|
|
147
|
-
showNewTenantModal.value = true
|
|
148
|
-
}
|
|
149
|
-
|
|
150
|
-
async function createTenant() {
|
|
151
|
-
if (!newTenantForm.value.name.trim() || !newTenantForm.value.slug.trim()) {
|
|
152
|
-
tenantError.value = "Name and slug are required."
|
|
153
|
-
return
|
|
154
|
-
}
|
|
155
|
-
|
|
156
|
-
creatingTenant.value = true
|
|
157
|
-
tenantError.value = null
|
|
158
|
-
try {
|
|
159
|
-
const res = await $fetch<any>("/_qarpeo/api/tenants/create", {
|
|
160
|
-
method: "POST",
|
|
161
|
-
body: newTenantForm.value,
|
|
162
|
-
})
|
|
163
|
-
if (res?.tenant) {
|
|
164
|
-
showNewTenantModal.value = false
|
|
165
|
-
await executeLoad()
|
|
166
|
-
await navigateTo({ query: { ...route.query, tenant: res.tenant.id } })
|
|
167
|
-
}
|
|
168
|
-
} catch (err: any) {
|
|
169
|
-
tenantError.value = err?.data?.message || err?.message || "Failed to create tenant"
|
|
170
|
-
} finally {
|
|
171
|
-
creatingTenant.value = false
|
|
172
|
-
}
|
|
173
|
-
}
|
|
174
|
-
|
|
175
|
-
const showAddDomainModal = ref(false)
|
|
176
|
-
const newDomainInput = ref("")
|
|
177
|
-
const addingDomain = ref(false)
|
|
178
|
-
const domainError = ref<string | null>(null)
|
|
179
|
-
|
|
180
|
-
function openAddDomainModal() {
|
|
181
|
-
newDomainInput.value = ""
|
|
182
|
-
domainError.value = null
|
|
183
|
-
showAddDomainModal.value = true
|
|
184
|
-
}
|
|
185
|
-
|
|
186
|
-
async function addDomain() {
|
|
187
|
-
if (!currentTenant.value) return
|
|
188
|
-
const domain = newDomainInput.value.trim().toLowerCase()
|
|
189
|
-
if (!domain) {
|
|
190
|
-
domainError.value = "Domain name is required."
|
|
191
|
-
return
|
|
192
|
-
}
|
|
193
|
-
|
|
194
|
-
addingDomain.value = true
|
|
195
|
-
domainError.value = null
|
|
196
|
-
try {
|
|
197
|
-
await $fetch<any>("/_qarpeo/api/tenants/domain-add", {
|
|
198
|
-
method: "POST",
|
|
199
|
-
body: {
|
|
200
|
-
tenantId: currentTenant.value.id,
|
|
201
|
-
domain,
|
|
202
|
-
},
|
|
203
|
-
})
|
|
204
|
-
showAddDomainModal.value = false
|
|
205
|
-
await executeLoad()
|
|
206
|
-
} catch (err: any) {
|
|
207
|
-
domainError.value = err?.data?.message || err?.message || "Failed to register domain"
|
|
208
|
-
} finally {
|
|
209
|
-
addingDomain.value = false
|
|
210
|
-
}
|
|
211
|
-
}
|
|
212
|
-
|
|
213
|
-
const verifyingDomain = ref<string | null>(null)
|
|
214
|
-
async function verifyDomain(domain: string) {
|
|
215
|
-
verifyingDomain.value = domain
|
|
216
|
-
try {
|
|
217
|
-
await $fetch<any>("/_qarpeo/api/tenants/domain-verify", {
|
|
218
|
-
method: "POST",
|
|
219
|
-
body: { domain },
|
|
220
|
-
})
|
|
221
|
-
await executeLoad()
|
|
222
|
-
} catch (err: any) {
|
|
223
|
-
if (typeof window !== "undefined") {
|
|
224
|
-
window.alert(`Verification check failed: ${err?.data?.message || err?.message}`)
|
|
225
|
-
}
|
|
226
|
-
} finally {
|
|
227
|
-
verifyingDomain.value = null
|
|
228
|
-
}
|
|
229
|
-
}
|
|
230
|
-
|
|
231
|
-
const deletingDomain = ref<string | null>(null)
|
|
232
|
-
async function deleteDomain(domain: string) {
|
|
233
|
-
if (
|
|
234
|
-
typeof window !== "undefined" &&
|
|
235
|
-
!window.confirm(`Are you sure you want to delete custom domain "${domain}"?`)
|
|
236
|
-
) {
|
|
237
|
-
return
|
|
238
|
-
}
|
|
239
|
-
|
|
240
|
-
deletingDomain.value = domain
|
|
241
|
-
try {
|
|
242
|
-
await $fetch<any>("/_qarpeo/api/tenants/domain-delete", {
|
|
243
|
-
method: "POST",
|
|
244
|
-
body: { domain },
|
|
245
|
-
})
|
|
246
|
-
await executeLoad()
|
|
247
|
-
} catch (err: any) {
|
|
248
|
-
if (typeof window !== "undefined") {
|
|
249
|
-
window.alert(`Failed to delete domain: ${err?.data?.message || err?.message}`)
|
|
250
|
-
}
|
|
251
|
-
} finally {
|
|
252
|
-
deletingDomain.value = null
|
|
253
|
-
}
|
|
254
|
-
}
|
|
255
|
-
|
|
256
|
-
function copyToClipboard(text: string) {
|
|
257
|
-
if (typeof navigator !== "undefined") {
|
|
258
|
-
navigator.clipboard?.writeText(text)
|
|
259
|
-
}
|
|
260
|
-
}
|
|
261
|
-
|
|
262
|
-
onMounted(() => {
|
|
263
|
-
executeLoad()
|
|
264
|
-
})
|
|
265
|
-
</script>
|
|
266
|
-
|
|
267
|
-
<template>
|
|
268
|
-
<!-- ── Panel 1: Tenants List ─────────────────────────────────────────── -->
|
|
269
|
-
<UDashboardPanel id="domains-tenants" :default-size="25" :min-size="20" :max-size="40" resizable>
|
|
270
|
-
<template #header>
|
|
271
|
-
<UDashboardNavbar>
|
|
272
|
-
<template #title>
|
|
273
|
-
<div class="flex items-center gap-2">
|
|
274
|
-
<UIcon name="i-lucide-building-2" class="w-4 h-4 text-primary" />
|
|
275
|
-
<span class="font-bold text-sm text-highlighted">Tenants</span>
|
|
276
|
-
<UBadge size="xs" color="neutral" variant="subtle">
|
|
277
|
-
{{ filteredTenants.length }}
|
|
278
|
-
</UBadge>
|
|
279
|
-
</div>
|
|
280
|
-
</template>
|
|
281
|
-
<template #right>
|
|
282
|
-
<div class="flex items-center gap-1">
|
|
283
|
-
<UButton
|
|
284
|
-
icon="i-lucide-plus"
|
|
285
|
-
size="xs"
|
|
286
|
-
color="primary"
|
|
287
|
-
variant="subtle"
|
|
288
|
-
title="Create new organization"
|
|
289
|
-
@click="openNewTenantModal"
|
|
290
|
-
/>
|
|
291
|
-
<UButton
|
|
292
|
-
icon="i-lucide-refresh-cw"
|
|
293
|
-
size="xs"
|
|
294
|
-
color="neutral"
|
|
295
|
-
variant="ghost"
|
|
296
|
-
title="Refresh tenants"
|
|
297
|
-
:loading="loading"
|
|
298
|
-
@click="() => executeLoad()"
|
|
299
|
-
/>
|
|
300
|
-
</div>
|
|
301
|
-
</template>
|
|
302
|
-
</UDashboardNavbar>
|
|
303
|
-
<UDashboardToolbar>
|
|
304
|
-
<UInput
|
|
305
|
-
v-model="tenantSearch"
|
|
306
|
-
icon="i-lucide-search"
|
|
307
|
-
placeholder="Search organizations…"
|
|
308
|
-
class="w-full"
|
|
309
|
-
/>
|
|
310
|
-
</UDashboardToolbar>
|
|
311
|
-
</template>
|
|
312
|
-
|
|
313
|
-
<template #body>
|
|
314
|
-
<!-- Loading Skeleton -->
|
|
315
|
-
<div v-if="loading" class="p-3 space-y-2">
|
|
316
|
-
<div
|
|
317
|
-
v-for="i in 5"
|
|
318
|
-
:key="i"
|
|
319
|
-
class="h-9 rounded bg-muted/60 animate-pulse flex items-center justify-between px-3"
|
|
320
|
-
>
|
|
321
|
-
<div class="flex items-center gap-2">
|
|
322
|
-
<div class="h-4 w-4 rounded bg-muted/40"></div>
|
|
323
|
-
<div class="h-3 w-28 rounded bg-muted/40"></div>
|
|
324
|
-
</div>
|
|
325
|
-
<div class="h-4 w-12 rounded bg-muted/40"></div>
|
|
326
|
-
</div>
|
|
327
|
-
</div>
|
|
328
|
-
|
|
329
|
-
<template v-else>
|
|
330
|
-
<UNavigationMenu
|
|
331
|
-
v-model="selectedTenantId"
|
|
332
|
-
:items="tenantNavItems"
|
|
333
|
-
orientation="vertical"
|
|
334
|
-
variant="pill"
|
|
335
|
-
/>
|
|
336
|
-
<div v-if="!filteredTenants.length" class="text-xs text-muted p-6 text-center">
|
|
337
|
-
No tenant organizations found
|
|
338
|
-
</div>
|
|
339
|
-
</template>
|
|
340
|
-
</template>
|
|
341
|
-
</UDashboardPanel>
|
|
342
|
-
|
|
343
|
-
<!-- ── Panel 2: Domains & SSL Management ─────────────────────────────── -->
|
|
344
|
-
<UDashboardPanel id="domains-content" class="hidden lg:flex flex-1">
|
|
345
|
-
<template #header>
|
|
346
|
-
<UDashboardNavbar>
|
|
347
|
-
<template #title>
|
|
348
|
-
<div v-if="currentTenant" class="flex items-center gap-2.5">
|
|
349
|
-
<UIcon name="i-lucide-globe" class="w-4 h-4 text-primary" />
|
|
350
|
-
<span class="font-bold text-sm text-highlighted">{{ currentTenant.name }}</span>
|
|
351
|
-
<UBadge size="xs" color="neutral" variant="subtle" class="font-mono">
|
|
352
|
-
{{ currentTenant.slug }}
|
|
353
|
-
</UBadge>
|
|
354
|
-
<UBadge size="xs" color="primary" variant="subtle" class="uppercase text-[9px]">
|
|
355
|
-
{{ currentTenant.plan }}
|
|
356
|
-
</UBadge>
|
|
357
|
-
</div>
|
|
358
|
-
<span v-else class="text-sm font-semibold text-muted">Select an organization</span>
|
|
359
|
-
</template>
|
|
360
|
-
|
|
361
|
-
<template #right>
|
|
362
|
-
<div v-if="currentTenant" class="flex items-center gap-2">
|
|
363
|
-
<UButton
|
|
364
|
-
label="Manage Zone on qarpeo.com"
|
|
365
|
-
icon="i-lucide-external-link"
|
|
366
|
-
trailing
|
|
367
|
-
size="xs"
|
|
368
|
-
color="neutral"
|
|
369
|
-
variant="ghost"
|
|
370
|
-
to="https://qarpeo.com/dashboard/domains"
|
|
371
|
-
target="_blank"
|
|
372
|
-
class="hidden sm:inline-flex"
|
|
373
|
-
/>
|
|
374
|
-
<UButton
|
|
375
|
-
label="Add Custom Domain"
|
|
376
|
-
icon="i-lucide-plus"
|
|
377
|
-
size="xs"
|
|
378
|
-
color="primary"
|
|
379
|
-
@click="openAddDomainModal"
|
|
380
|
-
/>
|
|
381
|
-
</div>
|
|
382
|
-
</template>
|
|
383
|
-
</UDashboardNavbar>
|
|
384
|
-
</template>
|
|
385
|
-
|
|
386
|
-
<template #body>
|
|
387
|
-
<!-- Loading Skeleton for Main Panel -->
|
|
388
|
-
<div v-if="loading" class="p-6 space-y-6">
|
|
389
|
-
<div class="grid grid-cols-1 sm:grid-cols-4 gap-4">
|
|
390
|
-
<UCard v-for="i in 4" :key="`skel-${i}`">
|
|
391
|
-
<div class="h-3 w-20 rounded bg-muted animate-pulse mb-2"></div>
|
|
392
|
-
<div class="h-6 w-16 rounded bg-muted animate-pulse"></div>
|
|
393
|
-
</UCard>
|
|
394
|
-
</div>
|
|
395
|
-
<div class="h-48 rounded bg-muted/40 animate-pulse"></div>
|
|
396
|
-
</div>
|
|
397
|
-
|
|
398
|
-
<div v-else-if="currentTenant" class="flex flex-col h-full p-6 space-y-6 overflow-y-auto">
|
|
399
|
-
<!-- Top Metrics Cards -->
|
|
400
|
-
<div class="grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-4 gap-4">
|
|
401
|
-
<UCard>
|
|
402
|
-
<div class="flex items-center justify-between text-xs text-muted mb-1">
|
|
403
|
-
<span>Total Domains</span>
|
|
404
|
-
<UIcon name="i-lucide-globe" class="w-4 h-4 text-primary" />
|
|
405
|
-
</div>
|
|
406
|
-
<div class="text-2xl font-extrabold text-highlighted">
|
|
407
|
-
{{ tenantDomains.length }}
|
|
408
|
-
</div>
|
|
409
|
-
<div class="text-[11px] text-muted mt-1">Configured hostnames</div>
|
|
410
|
-
</UCard>
|
|
411
|
-
|
|
412
|
-
<UCard>
|
|
413
|
-
<div class="flex items-center justify-between text-xs text-muted mb-1">
|
|
414
|
-
<span>Active SSL</span>
|
|
415
|
-
<UIcon name="i-lucide-shield-check" class="w-4 h-4 text-success" />
|
|
416
|
-
</div>
|
|
417
|
-
<div class="text-2xl font-extrabold text-success">
|
|
418
|
-
{{ activeDomainsCount }}
|
|
419
|
-
</div>
|
|
420
|
-
<div class="text-[11px] text-muted mt-1">Let's Encrypt / Google Trust</div>
|
|
421
|
-
</UCard>
|
|
422
|
-
|
|
423
|
-
<UCard>
|
|
424
|
-
<div class="flex items-center justify-between text-xs text-muted mb-1">
|
|
425
|
-
<span>Pending DNS / SSL</span>
|
|
426
|
-
<UIcon name="i-lucide-clock" class="w-4 h-4 text-warning" />
|
|
427
|
-
</div>
|
|
428
|
-
<div class="text-2xl font-extrabold text-warning">
|
|
429
|
-
{{ pendingDomainsCount }}
|
|
430
|
-
</div>
|
|
431
|
-
<div class="text-[11px] text-muted mt-1">Awaiting DNS propagation</div>
|
|
432
|
-
</UCard>
|
|
433
|
-
|
|
434
|
-
<UCard>
|
|
435
|
-
<div class="flex items-center justify-between text-xs text-muted mb-1">
|
|
436
|
-
<span>Primary Subdomain</span>
|
|
437
|
-
<UIcon name="i-lucide-link" class="w-4 h-4 text-primary" />
|
|
438
|
-
</div>
|
|
439
|
-
<div class="text-xs font-mono font-bold text-primary truncate mt-1">
|
|
440
|
-
{{ currentTenant.slug }}.{{ multitenantConfig?.rootDomains?.[0] || "qarpeo.dev" }}
|
|
441
|
-
</div>
|
|
442
|
-
<div class="text-[11px] text-muted mt-2">Zero-config edge routing</div>
|
|
443
|
-
</UCard>
|
|
444
|
-
</div>
|
|
445
|
-
|
|
446
|
-
<!-- Custom Domains List Card -->
|
|
447
|
-
<UCard :ui="{ body: 'p-0 overflow-hidden' }">
|
|
448
|
-
<template #header>
|
|
449
|
-
<div class="flex items-center justify-between flex-wrap gap-2">
|
|
450
|
-
<div>
|
|
451
|
-
<h3 class="font-bold text-sm text-highlighted flex items-center gap-2">
|
|
452
|
-
<UIcon name="i-lucide-shield" class="w-4 h-4 text-primary" />
|
|
453
|
-
Custom Hostnames (Cloudflare for SaaS)
|
|
454
|
-
</h3>
|
|
455
|
-
<p class="text-xs text-muted mt-0.5">
|
|
456
|
-
Point your customer's DNS CNAME record to
|
|
457
|
-
<code class="font-mono text-primary font-bold">{{
|
|
458
|
-
multitenantConfig?.cnameTarget || "cname.qarpeo.com"
|
|
459
|
-
}}</code>
|
|
460
|
-
</p>
|
|
461
|
-
</div>
|
|
462
|
-
|
|
463
|
-
<div class="flex items-center gap-2">
|
|
464
|
-
<UInput
|
|
465
|
-
v-model="domainSearch"
|
|
466
|
-
icon="i-lucide-search"
|
|
467
|
-
placeholder="Filter domains…"
|
|
468
|
-
size="xs"
|
|
469
|
-
class="w-48"
|
|
470
|
-
/>
|
|
471
|
-
</div>
|
|
472
|
-
</div>
|
|
473
|
-
</template>
|
|
474
|
-
|
|
475
|
-
<div class="overflow-x-auto">
|
|
476
|
-
<table class="w-full text-left text-xs">
|
|
477
|
-
<thead>
|
|
478
|
-
<tr class="border-b border-default bg-muted/40 text-muted font-mono">
|
|
479
|
-
<th class="py-2.5 px-4 font-semibold">Hostname</th>
|
|
480
|
-
<th class="py-2.5 px-4 font-semibold">SSL Status</th>
|
|
481
|
-
<th class="py-2.5 px-4 font-semibold">CNAME Target</th>
|
|
482
|
-
<th class="py-2.5 px-4 font-semibold text-right">Actions</th>
|
|
483
|
-
</tr>
|
|
484
|
-
</thead>
|
|
485
|
-
<tbody class="divide-y divide-default font-mono">
|
|
486
|
-
<tr
|
|
487
|
-
v-for="d in tenantDomains"
|
|
488
|
-
:key="d.id"
|
|
489
|
-
class="hover:bg-elevated/50 transition-colors group"
|
|
490
|
-
>
|
|
491
|
-
<td class="py-3 px-4 font-bold text-highlighted">
|
|
492
|
-
<div class="flex items-center gap-2">
|
|
493
|
-
<span>{{ d.domain }}</span>
|
|
494
|
-
<a
|
|
495
|
-
:href="`https://${d.domain}`"
|
|
496
|
-
target="_blank"
|
|
497
|
-
rel="noopener"
|
|
498
|
-
class="text-muted hover:text-primary transition-colors"
|
|
499
|
-
title="Open domain"
|
|
500
|
-
>
|
|
501
|
-
<UIcon name="i-lucide-external-link" class="w-3.5 h-3.5" />
|
|
502
|
-
</a>
|
|
503
|
-
</div>
|
|
504
|
-
</td>
|
|
505
|
-
<td class="py-3 px-4">
|
|
506
|
-
<UBadge
|
|
507
|
-
size="xs"
|
|
508
|
-
:color="getSslBadgeColor(d.sslStatus)"
|
|
509
|
-
variant="subtle"
|
|
510
|
-
class="uppercase text-[9px] font-semibold"
|
|
511
|
-
>
|
|
512
|
-
<UIcon
|
|
513
|
-
:name="
|
|
514
|
-
d.sslStatus === 'active'
|
|
515
|
-
? 'i-lucide-check-circle'
|
|
516
|
-
: 'i-lucide-alert-circle'
|
|
517
|
-
"
|
|
518
|
-
class="w-3 h-3 mr-1"
|
|
519
|
-
/>
|
|
520
|
-
{{ d.sslStatus }}
|
|
521
|
-
</UBadge>
|
|
522
|
-
</td>
|
|
523
|
-
<td class="py-3 px-4 text-muted flex items-center gap-2">
|
|
524
|
-
<span class="font-mono text-xs text-default">{{
|
|
525
|
-
d.cnameTarget || multitenantConfig?.cnameTarget || "cname.qarpeo.com"
|
|
526
|
-
}}</span>
|
|
527
|
-
<UButton
|
|
528
|
-
icon="i-lucide-copy"
|
|
529
|
-
color="neutral"
|
|
530
|
-
variant="ghost"
|
|
531
|
-
size="xs"
|
|
532
|
-
title="Copy CNAME target"
|
|
533
|
-
@click="
|
|
534
|
-
copyToClipboard(
|
|
535
|
-
d.cnameTarget || multitenantConfig?.cnameTarget || 'cname.qarpeo.com',
|
|
536
|
-
)
|
|
537
|
-
"
|
|
538
|
-
/>
|
|
539
|
-
</td>
|
|
540
|
-
<td class="py-3 px-4 text-right">
|
|
541
|
-
<div class="flex items-center justify-end gap-1.5">
|
|
542
|
-
<UButton
|
|
543
|
-
label="Verify"
|
|
544
|
-
icon="i-lucide-refresh-cw"
|
|
545
|
-
size="xs"
|
|
546
|
-
color="neutral"
|
|
547
|
-
variant="subtle"
|
|
548
|
-
title="Check DNS propagation & SSL certificate"
|
|
549
|
-
:loading="verifyingDomain === d.domain"
|
|
550
|
-
@click="verifyDomain(d.domain)"
|
|
551
|
-
/>
|
|
552
|
-
<UButton
|
|
553
|
-
icon="i-lucide-trash"
|
|
554
|
-
size="xs"
|
|
555
|
-
color="neutral"
|
|
556
|
-
variant="ghost"
|
|
557
|
-
class="hover:text-error"
|
|
558
|
-
title="Remove domain"
|
|
559
|
-
:loading="deletingDomain === d.domain"
|
|
560
|
-
@click="deleteDomain(d.domain)"
|
|
561
|
-
/>
|
|
562
|
-
</div>
|
|
563
|
-
</td>
|
|
564
|
-
</tr>
|
|
565
|
-
|
|
566
|
-
<tr v-if="!tenantDomains.length">
|
|
567
|
-
<td colspan="4" class="text-center py-12 text-muted text-xs font-sans">
|
|
568
|
-
<UIcon name="i-lucide-globe" class="w-8 h-8 opacity-40 mx-auto mb-2" />
|
|
569
|
-
No custom domains registered for {{ currentTenant.name }}.
|
|
570
|
-
<div class="mt-2">
|
|
571
|
-
<UButton
|
|
572
|
-
label="Add Custom Domain"
|
|
573
|
-
icon="i-lucide-plus"
|
|
574
|
-
size="xs"
|
|
575
|
-
color="primary"
|
|
576
|
-
variant="subtle"
|
|
577
|
-
@click="openAddDomainModal"
|
|
578
|
-
/>
|
|
579
|
-
</div>
|
|
580
|
-
</td>
|
|
581
|
-
</tr>
|
|
582
|
-
</tbody>
|
|
583
|
-
</table>
|
|
584
|
-
</div>
|
|
585
|
-
</UCard>
|
|
586
|
-
|
|
587
|
-
<!-- DNS Configuration Setup Guide Card -->
|
|
588
|
-
<UCard>
|
|
589
|
-
<template #header>
|
|
590
|
-
<div class="flex items-center gap-2">
|
|
591
|
-
<UIcon name="i-lucide-info" class="w-4 h-4 text-primary" />
|
|
592
|
-
<span class="font-bold text-sm text-highlighted">DNS Configuration Guide</span>
|
|
593
|
-
</div>
|
|
594
|
-
</template>
|
|
595
|
-
|
|
596
|
-
<div class="text-xs text-muted space-y-3">
|
|
597
|
-
<p>
|
|
598
|
-
To route custom domains to your multi-tenant application, your customers must
|
|
599
|
-
configure a DNS record with their domain registrar:
|
|
600
|
-
</p>
|
|
601
|
-
|
|
602
|
-
<div
|
|
603
|
-
class="bg-muted/40 p-3 rounded-lg border border-default font-mono text-xs space-y-2"
|
|
604
|
-
>
|
|
605
|
-
<div
|
|
606
|
-
class="grid grid-cols-3 gap-2 font-bold text-highlighted pb-1 border-b border-default"
|
|
607
|
-
>
|
|
608
|
-
<div>Type</div>
|
|
609
|
-
<div>Name / Host</div>
|
|
610
|
-
<div>Target / Value</div>
|
|
611
|
-
</div>
|
|
612
|
-
<div class="grid grid-cols-3 gap-2 text-default">
|
|
613
|
-
<div class="text-primary font-bold">CNAME</div>
|
|
614
|
-
<div>app (or @ for apex)</div>
|
|
615
|
-
<div class="flex items-center gap-1.5 font-bold">
|
|
616
|
-
{{ multitenantConfig?.cnameTarget || "cname.qarpeo.com" }}
|
|
617
|
-
<UButton
|
|
618
|
-
icon="i-lucide-copy"
|
|
619
|
-
color="neutral"
|
|
620
|
-
variant="ghost"
|
|
621
|
-
size="xs"
|
|
622
|
-
title="Copy Target"
|
|
623
|
-
@click="copyToClipboard(multitenantConfig?.cnameTarget || 'cname.qarpeo.com')"
|
|
624
|
-
/>
|
|
625
|
-
</div>
|
|
626
|
-
</div>
|
|
627
|
-
</div>
|
|
628
|
-
|
|
629
|
-
<p class="text-[11px] text-muted">
|
|
630
|
-
Once configured, Cloudflare for SaaS will automatically issue and renew a free TLS/SSL
|
|
631
|
-
certificate (via Let's Encrypt or Google Trust Services), providing automatic HTTPS at
|
|
632
|
-
the edge.
|
|
633
|
-
</p>
|
|
634
|
-
</div>
|
|
635
|
-
</UCard>
|
|
636
|
-
</div>
|
|
637
|
-
|
|
638
|
-
<div
|
|
639
|
-
v-else
|
|
640
|
-
class="flex-1 flex flex-col items-center justify-center text-muted text-xs p-12 text-center"
|
|
641
|
-
>
|
|
642
|
-
<UIcon name="i-lucide-building-2" class="w-8 h-8 mb-2 opacity-50 text-muted" />
|
|
643
|
-
Select an organization from the list to manage its custom domains.
|
|
644
|
-
</div>
|
|
645
|
-
</template>
|
|
646
|
-
</UDashboardPanel>
|
|
647
|
-
|
|
648
|
-
<!-- ── Modal: Create Tenant ──────────────────────────────────────────── -->
|
|
649
|
-
<UModal
|
|
650
|
-
v-model:open="showNewTenantModal"
|
|
651
|
-
title="Create Organization"
|
|
652
|
-
description="Add a new tenant organization to the multi-tenant system."
|
|
653
|
-
>
|
|
654
|
-
<template #body>
|
|
655
|
-
<div class="space-y-3">
|
|
656
|
-
<div
|
|
657
|
-
v-if="tenantError"
|
|
658
|
-
class="p-2.5 bg-error/10 border border-error/20 rounded text-error text-xs font-mono"
|
|
659
|
-
>
|
|
660
|
-
{{ tenantError }}
|
|
661
|
-
</div>
|
|
662
|
-
|
|
663
|
-
<UFormField label="Organization Name" name="name" required>
|
|
664
|
-
<UInput
|
|
665
|
-
v-model="newTenantForm.name"
|
|
666
|
-
placeholder="e.g. Acme Corporation"
|
|
667
|
-
class="w-full"
|
|
668
|
-
@update:model-value="
|
|
669
|
-
(val) => {
|
|
670
|
-
if (!newTenantForm.slug) {
|
|
671
|
-
newTenantForm.slug = val.toLowerCase().replace(/[^a-z0-9]/g, '-')
|
|
672
|
-
}
|
|
673
|
-
}
|
|
674
|
-
"
|
|
675
|
-
/>
|
|
676
|
-
</UFormField>
|
|
677
|
-
|
|
678
|
-
<UFormField
|
|
679
|
-
label="Subdomain Slug"
|
|
680
|
-
name="slug"
|
|
681
|
-
required
|
|
682
|
-
help="Used for edge subdomain routing (e.g. acme.qarpeo.dev)"
|
|
683
|
-
>
|
|
684
|
-
<UInput
|
|
685
|
-
v-model="newTenantForm.slug"
|
|
686
|
-
placeholder="e.g. acme"
|
|
687
|
-
class="w-full font-mono text-xs"
|
|
688
|
-
/>
|
|
689
|
-
</UFormField>
|
|
690
|
-
|
|
691
|
-
<UFormField label="Subscription Plan" name="plan">
|
|
692
|
-
<USelect
|
|
693
|
-
v-model="newTenantForm.plan"
|
|
694
|
-
:items="[
|
|
695
|
-
{ label: 'Pro Plan', value: 'pro' },
|
|
696
|
-
{ label: 'Enterprise Plan', value: 'enterprise' },
|
|
697
|
-
{ label: 'Free Tier', value: 'free' },
|
|
698
|
-
]"
|
|
699
|
-
class="w-full"
|
|
700
|
-
/>
|
|
701
|
-
</UFormField>
|
|
702
|
-
</div>
|
|
703
|
-
</template>
|
|
704
|
-
|
|
705
|
-
<template #footer>
|
|
706
|
-
<div class="flex justify-end gap-2 w-full">
|
|
707
|
-
<UButton size="xs" color="neutral" variant="ghost" @click="showNewTenantModal = false">
|
|
708
|
-
Cancel
|
|
709
|
-
</UButton>
|
|
710
|
-
<UButton
|
|
711
|
-
size="xs"
|
|
712
|
-
color="primary"
|
|
713
|
-
icon="i-lucide-plus"
|
|
714
|
-
:loading="creatingTenant"
|
|
715
|
-
@click="createTenant"
|
|
716
|
-
>
|
|
717
|
-
Create Organization
|
|
718
|
-
</UButton>
|
|
719
|
-
</div>
|
|
720
|
-
</template>
|
|
721
|
-
</UModal>
|
|
722
|
-
|
|
723
|
-
<!-- ── Modal: Add Custom Domain ──────────────────────────────────────── -->
|
|
724
|
-
<UModal
|
|
725
|
-
v-model:open="showAddDomainModal"
|
|
726
|
-
:title="`Add Custom Domain for ${currentTenant?.name}`"
|
|
727
|
-
description="Connect a fully qualified custom domain name."
|
|
728
|
-
>
|
|
729
|
-
<template #body>
|
|
730
|
-
<div class="space-y-3">
|
|
731
|
-
<div
|
|
732
|
-
v-if="domainError"
|
|
733
|
-
class="p-2.5 bg-error/10 border border-error/20 rounded text-error text-xs font-mono"
|
|
734
|
-
>
|
|
735
|
-
{{ domainError }}
|
|
736
|
-
</div>
|
|
737
|
-
|
|
738
|
-
<UFormField
|
|
739
|
-
label="Domain Name (FQDN)"
|
|
740
|
-
name="domain"
|
|
741
|
-
required
|
|
742
|
-
help="Enter your customer's domain, e.g. portal.acme.com or app.custom.org"
|
|
743
|
-
>
|
|
744
|
-
<UInput
|
|
745
|
-
v-model="newDomainInput"
|
|
746
|
-
placeholder="e.g. portal.acme.com"
|
|
747
|
-
class="w-full font-mono text-xs"
|
|
748
|
-
@keydown.enter.prevent="addDomain"
|
|
749
|
-
/>
|
|
750
|
-
</UFormField>
|
|
751
|
-
</div>
|
|
752
|
-
</template>
|
|
753
|
-
|
|
754
|
-
<template #footer>
|
|
755
|
-
<div class="flex justify-end gap-2 w-full">
|
|
756
|
-
<UButton size="xs" color="neutral" variant="ghost" @click="showAddDomainModal = false">
|
|
757
|
-
Cancel
|
|
758
|
-
</UButton>
|
|
759
|
-
<UButton
|
|
760
|
-
size="xs"
|
|
761
|
-
color="primary"
|
|
762
|
-
icon="i-lucide-plus"
|
|
763
|
-
:loading="addingDomain"
|
|
764
|
-
@click="addDomain"
|
|
765
|
-
>
|
|
766
|
-
Add Domain
|
|
767
|
-
</UButton>
|
|
768
|
-
</div>
|
|
769
|
-
</template>
|
|
770
|
-
</UModal>
|
|
771
|
-
</template>
|
|
1
|
+
<script setup lang="ts">
|
|
2
|
+
import type { NavigationMenuItem } from "@nuxt/ui"
|
|
3
|
+
import { useRoute, useFetch, navigateTo } from "nuxt/app"
|
|
4
|
+
import { computed, onMounted, ref } from "vue"
|
|
5
|
+
|
|
6
|
+
const route = useRoute()
|
|
7
|
+
|
|
8
|
+
interface TenantRecord {
|
|
9
|
+
id: string
|
|
10
|
+
slug: string
|
|
11
|
+
name: string
|
|
12
|
+
plan: string
|
|
13
|
+
customDomain?: string
|
|
14
|
+
logoUrl?: string
|
|
15
|
+
metadata?: Record<string, any>
|
|
16
|
+
createdAt?: number
|
|
17
|
+
updatedAt?: number
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
interface CustomDomainRecord {
|
|
21
|
+
id: string
|
|
22
|
+
tenantId: string
|
|
23
|
+
domain: string
|
|
24
|
+
status: "pending_validation" | "active" | "error" | "deleted"
|
|
25
|
+
sslStatus: "initializing" | "pending_validation" | "active" | "expired" | "error"
|
|
26
|
+
cnameTarget?: string
|
|
27
|
+
cloudflareHostnameId?: string
|
|
28
|
+
createdAt?: number
|
|
29
|
+
updatedAt?: number
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
interface DomainsApiResponse {
|
|
33
|
+
tenants: TenantRecord[]
|
|
34
|
+
domains: CustomDomainRecord[]
|
|
35
|
+
config: {
|
|
36
|
+
rootDomains: string[]
|
|
37
|
+
cnameTarget: string
|
|
38
|
+
provider: string
|
|
39
|
+
customDomainsEnabled: boolean
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
const {
|
|
44
|
+
data: apiData,
|
|
45
|
+
status: apiStatus,
|
|
46
|
+
pending: apiPending,
|
|
47
|
+
execute: executeLoad,
|
|
48
|
+
} = useFetch<DomainsApiResponse>("/_qarpeo/api/tenants/list", {
|
|
49
|
+
immediate: false,
|
|
50
|
+
lazy: true,
|
|
51
|
+
default: () => ({
|
|
52
|
+
tenants: [],
|
|
53
|
+
domains: [],
|
|
54
|
+
config: {
|
|
55
|
+
rootDomains: ["qarpeo.dev"],
|
|
56
|
+
cnameTarget: "cname.qarpeo.com",
|
|
57
|
+
provider: "cloudflare",
|
|
58
|
+
customDomainsEnabled: true,
|
|
59
|
+
},
|
|
60
|
+
}),
|
|
61
|
+
})
|
|
62
|
+
|
|
63
|
+
const loading = computed(
|
|
64
|
+
() => apiPending.value || apiStatus.value === "idle" || apiStatus.value === "pending",
|
|
65
|
+
)
|
|
66
|
+
|
|
67
|
+
const tenants = computed(() => apiData.value?.tenants || [])
|
|
68
|
+
const domains = computed(() => apiData.value?.domains || [])
|
|
69
|
+
const multitenantConfig = computed(() => apiData.value?.config)
|
|
70
|
+
|
|
71
|
+
const tenantSearch = ref("")
|
|
72
|
+
const domainSearch = ref("")
|
|
73
|
+
const selectedTenantId = computed(
|
|
74
|
+
() => (route.query.tenant as string) || tenants.value[0]?.id || null,
|
|
75
|
+
)
|
|
76
|
+
|
|
77
|
+
// Filtered Tenants
|
|
78
|
+
const filteredTenants = computed(() => {
|
|
79
|
+
if (!tenantSearch.value.trim()) return tenants.value
|
|
80
|
+
const q = tenantSearch.value.toLowerCase()
|
|
81
|
+
return tenants.value.filter(
|
|
82
|
+
(t) => t.name.toLowerCase().includes(q) || t.slug.toLowerCase().includes(q),
|
|
83
|
+
)
|
|
84
|
+
})
|
|
85
|
+
|
|
86
|
+
// Current Selected Tenant
|
|
87
|
+
const currentTenant = computed(
|
|
88
|
+
() => tenants.value.find((t) => t.id === selectedTenantId.value) || tenants.value[0] || null,
|
|
89
|
+
)
|
|
90
|
+
|
|
91
|
+
// Domains for Selected Tenant
|
|
92
|
+
const tenantDomains = computed(() => {
|
|
93
|
+
if (!currentTenant.value) return []
|
|
94
|
+
let list = domains.value.filter((d) => d.tenantId === currentTenant.value.id)
|
|
95
|
+
if (domainSearch.value.trim()) {
|
|
96
|
+
const q = domainSearch.value.toLowerCase()
|
|
97
|
+
list = list.filter((d) => d.domain.toLowerCase().includes(q))
|
|
98
|
+
}
|
|
99
|
+
return list
|
|
100
|
+
})
|
|
101
|
+
|
|
102
|
+
// Nav items for left panel
|
|
103
|
+
const tenantNavItems = computed<NavigationMenuItem[]>(() =>
|
|
104
|
+
filteredTenants.value.map((t) => {
|
|
105
|
+
const count = domains.value.filter((d) => d.tenantId === t.id).length
|
|
106
|
+
return {
|
|
107
|
+
label: t.name,
|
|
108
|
+
icon: "i-lucide-building-2",
|
|
109
|
+
value: t.id,
|
|
110
|
+
badge: {
|
|
111
|
+
label: `${count} ${count === 1 ? "domain" : "domains"}`,
|
|
112
|
+
size: "sm" as const,
|
|
113
|
+
color: "neutral" as const,
|
|
114
|
+
variant: "subtle" as const,
|
|
115
|
+
},
|
|
116
|
+
class: "text-xs",
|
|
117
|
+
to: { query: { ...route.query, tenant: t.id } },
|
|
118
|
+
active: selectedTenantId.value === t.id,
|
|
119
|
+
}
|
|
120
|
+
}),
|
|
121
|
+
)
|
|
122
|
+
|
|
123
|
+
// Counts
|
|
124
|
+
const activeDomainsCount = computed(
|
|
125
|
+
() => tenantDomains.value.filter((d) => d.sslStatus === "active").length,
|
|
126
|
+
)
|
|
127
|
+
const pendingDomainsCount = computed(
|
|
128
|
+
() => tenantDomains.value.filter((d) => d.sslStatus !== "active").length,
|
|
129
|
+
)
|
|
130
|
+
|
|
131
|
+
function getSslBadgeColor(status?: string): "success" | "warning" | "error" | "neutral" {
|
|
132
|
+
if (status === "active") return "success"
|
|
133
|
+
if (status === "pending_validation" || status === "initializing") return "warning"
|
|
134
|
+
if (status === "error" || status === "expired") return "error"
|
|
135
|
+
return "neutral"
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
// ─── Actions: Modals & API Calls ──────────────────────────────────────────────
|
|
139
|
+
const showNewTenantModal = ref(false)
|
|
140
|
+
const newTenantForm = ref({ name: "", slug: "", plan: "pro" })
|
|
141
|
+
const creatingTenant = ref(false)
|
|
142
|
+
const tenantError = ref<string | null>(null)
|
|
143
|
+
|
|
144
|
+
function openNewTenantModal() {
|
|
145
|
+
newTenantForm.value = { name: "", slug: "", plan: "pro" }
|
|
146
|
+
tenantError.value = null
|
|
147
|
+
showNewTenantModal.value = true
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
async function createTenant() {
|
|
151
|
+
if (!newTenantForm.value.name.trim() || !newTenantForm.value.slug.trim()) {
|
|
152
|
+
tenantError.value = "Name and slug are required."
|
|
153
|
+
return
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
creatingTenant.value = true
|
|
157
|
+
tenantError.value = null
|
|
158
|
+
try {
|
|
159
|
+
const res = await $fetch<any>("/_qarpeo/api/tenants/create", {
|
|
160
|
+
method: "POST",
|
|
161
|
+
body: newTenantForm.value,
|
|
162
|
+
})
|
|
163
|
+
if (res?.tenant) {
|
|
164
|
+
showNewTenantModal.value = false
|
|
165
|
+
await executeLoad()
|
|
166
|
+
await navigateTo({ query: { ...route.query, tenant: res.tenant.id } })
|
|
167
|
+
}
|
|
168
|
+
} catch (err: any) {
|
|
169
|
+
tenantError.value = err?.data?.message || err?.message || "Failed to create tenant"
|
|
170
|
+
} finally {
|
|
171
|
+
creatingTenant.value = false
|
|
172
|
+
}
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
const showAddDomainModal = ref(false)
|
|
176
|
+
const newDomainInput = ref("")
|
|
177
|
+
const addingDomain = ref(false)
|
|
178
|
+
const domainError = ref<string | null>(null)
|
|
179
|
+
|
|
180
|
+
function openAddDomainModal() {
|
|
181
|
+
newDomainInput.value = ""
|
|
182
|
+
domainError.value = null
|
|
183
|
+
showAddDomainModal.value = true
|
|
184
|
+
}
|
|
185
|
+
|
|
186
|
+
async function addDomain() {
|
|
187
|
+
if (!currentTenant.value) return
|
|
188
|
+
const domain = newDomainInput.value.trim().toLowerCase()
|
|
189
|
+
if (!domain) {
|
|
190
|
+
domainError.value = "Domain name is required."
|
|
191
|
+
return
|
|
192
|
+
}
|
|
193
|
+
|
|
194
|
+
addingDomain.value = true
|
|
195
|
+
domainError.value = null
|
|
196
|
+
try {
|
|
197
|
+
await $fetch<any>("/_qarpeo/api/tenants/domain-add", {
|
|
198
|
+
method: "POST",
|
|
199
|
+
body: {
|
|
200
|
+
tenantId: currentTenant.value.id,
|
|
201
|
+
domain,
|
|
202
|
+
},
|
|
203
|
+
})
|
|
204
|
+
showAddDomainModal.value = false
|
|
205
|
+
await executeLoad()
|
|
206
|
+
} catch (err: any) {
|
|
207
|
+
domainError.value = err?.data?.message || err?.message || "Failed to register domain"
|
|
208
|
+
} finally {
|
|
209
|
+
addingDomain.value = false
|
|
210
|
+
}
|
|
211
|
+
}
|
|
212
|
+
|
|
213
|
+
const verifyingDomain = ref<string | null>(null)
|
|
214
|
+
async function verifyDomain(domain: string) {
|
|
215
|
+
verifyingDomain.value = domain
|
|
216
|
+
try {
|
|
217
|
+
await $fetch<any>("/_qarpeo/api/tenants/domain-verify", {
|
|
218
|
+
method: "POST",
|
|
219
|
+
body: { domain },
|
|
220
|
+
})
|
|
221
|
+
await executeLoad()
|
|
222
|
+
} catch (err: any) {
|
|
223
|
+
if (typeof window !== "undefined") {
|
|
224
|
+
window.alert(`Verification check failed: ${err?.data?.message || err?.message}`)
|
|
225
|
+
}
|
|
226
|
+
} finally {
|
|
227
|
+
verifyingDomain.value = null
|
|
228
|
+
}
|
|
229
|
+
}
|
|
230
|
+
|
|
231
|
+
const deletingDomain = ref<string | null>(null)
|
|
232
|
+
async function deleteDomain(domain: string) {
|
|
233
|
+
if (
|
|
234
|
+
typeof window !== "undefined" &&
|
|
235
|
+
!window.confirm(`Are you sure you want to delete custom domain "${domain}"?`)
|
|
236
|
+
) {
|
|
237
|
+
return
|
|
238
|
+
}
|
|
239
|
+
|
|
240
|
+
deletingDomain.value = domain
|
|
241
|
+
try {
|
|
242
|
+
await $fetch<any>("/_qarpeo/api/tenants/domain-delete", {
|
|
243
|
+
method: "POST",
|
|
244
|
+
body: { domain },
|
|
245
|
+
})
|
|
246
|
+
await executeLoad()
|
|
247
|
+
} catch (err: any) {
|
|
248
|
+
if (typeof window !== "undefined") {
|
|
249
|
+
window.alert(`Failed to delete domain: ${err?.data?.message || err?.message}`)
|
|
250
|
+
}
|
|
251
|
+
} finally {
|
|
252
|
+
deletingDomain.value = null
|
|
253
|
+
}
|
|
254
|
+
}
|
|
255
|
+
|
|
256
|
+
function copyToClipboard(text: string) {
|
|
257
|
+
if (typeof navigator !== "undefined") {
|
|
258
|
+
navigator.clipboard?.writeText(text)
|
|
259
|
+
}
|
|
260
|
+
}
|
|
261
|
+
|
|
262
|
+
onMounted(() => {
|
|
263
|
+
executeLoad()
|
|
264
|
+
})
|
|
265
|
+
</script>
|
|
266
|
+
|
|
267
|
+
<template>
|
|
268
|
+
<!-- ── Panel 1: Tenants List ─────────────────────────────────────────── -->
|
|
269
|
+
<UDashboardPanel id="domains-tenants" :default-size="25" :min-size="20" :max-size="40" resizable>
|
|
270
|
+
<template #header>
|
|
271
|
+
<UDashboardNavbar>
|
|
272
|
+
<template #title>
|
|
273
|
+
<div class="flex items-center gap-2">
|
|
274
|
+
<UIcon name="i-lucide-building-2" class="w-4 h-4 text-primary" />
|
|
275
|
+
<span class="font-bold text-sm text-highlighted">Tenants</span>
|
|
276
|
+
<UBadge size="xs" color="neutral" variant="subtle">
|
|
277
|
+
{{ filteredTenants.length }}
|
|
278
|
+
</UBadge>
|
|
279
|
+
</div>
|
|
280
|
+
</template>
|
|
281
|
+
<template #right>
|
|
282
|
+
<div class="flex items-center gap-1">
|
|
283
|
+
<UButton
|
|
284
|
+
icon="i-lucide-plus"
|
|
285
|
+
size="xs"
|
|
286
|
+
color="primary"
|
|
287
|
+
variant="subtle"
|
|
288
|
+
title="Create new organization"
|
|
289
|
+
@click="openNewTenantModal"
|
|
290
|
+
/>
|
|
291
|
+
<UButton
|
|
292
|
+
icon="i-lucide-refresh-cw"
|
|
293
|
+
size="xs"
|
|
294
|
+
color="neutral"
|
|
295
|
+
variant="ghost"
|
|
296
|
+
title="Refresh tenants"
|
|
297
|
+
:loading="loading"
|
|
298
|
+
@click="() => executeLoad()"
|
|
299
|
+
/>
|
|
300
|
+
</div>
|
|
301
|
+
</template>
|
|
302
|
+
</UDashboardNavbar>
|
|
303
|
+
<UDashboardToolbar>
|
|
304
|
+
<UInput
|
|
305
|
+
v-model="tenantSearch"
|
|
306
|
+
icon="i-lucide-search"
|
|
307
|
+
placeholder="Search organizations…"
|
|
308
|
+
class="w-full"
|
|
309
|
+
/>
|
|
310
|
+
</UDashboardToolbar>
|
|
311
|
+
</template>
|
|
312
|
+
|
|
313
|
+
<template #body>
|
|
314
|
+
<!-- Loading Skeleton -->
|
|
315
|
+
<div v-if="loading" class="p-3 space-y-2">
|
|
316
|
+
<div
|
|
317
|
+
v-for="i in 5"
|
|
318
|
+
:key="i"
|
|
319
|
+
class="h-9 rounded bg-muted/60 animate-pulse flex items-center justify-between px-3"
|
|
320
|
+
>
|
|
321
|
+
<div class="flex items-center gap-2">
|
|
322
|
+
<div class="h-4 w-4 rounded bg-muted/40"></div>
|
|
323
|
+
<div class="h-3 w-28 rounded bg-muted/40"></div>
|
|
324
|
+
</div>
|
|
325
|
+
<div class="h-4 w-12 rounded bg-muted/40"></div>
|
|
326
|
+
</div>
|
|
327
|
+
</div>
|
|
328
|
+
|
|
329
|
+
<template v-else>
|
|
330
|
+
<UNavigationMenu
|
|
331
|
+
v-model="selectedTenantId"
|
|
332
|
+
:items="tenantNavItems"
|
|
333
|
+
orientation="vertical"
|
|
334
|
+
variant="pill"
|
|
335
|
+
/>
|
|
336
|
+
<div v-if="!filteredTenants.length" class="text-xs text-muted p-6 text-center">
|
|
337
|
+
No tenant organizations found
|
|
338
|
+
</div>
|
|
339
|
+
</template>
|
|
340
|
+
</template>
|
|
341
|
+
</UDashboardPanel>
|
|
342
|
+
|
|
343
|
+
<!-- ── Panel 2: Domains & SSL Management ─────────────────────────────── -->
|
|
344
|
+
<UDashboardPanel id="domains-content" class="hidden lg:flex flex-1">
|
|
345
|
+
<template #header>
|
|
346
|
+
<UDashboardNavbar>
|
|
347
|
+
<template #title>
|
|
348
|
+
<div v-if="currentTenant" class="flex items-center gap-2.5">
|
|
349
|
+
<UIcon name="i-lucide-globe" class="w-4 h-4 text-primary" />
|
|
350
|
+
<span class="font-bold text-sm text-highlighted">{{ currentTenant.name }}</span>
|
|
351
|
+
<UBadge size="xs" color="neutral" variant="subtle" class="font-mono">
|
|
352
|
+
{{ currentTenant.slug }}
|
|
353
|
+
</UBadge>
|
|
354
|
+
<UBadge size="xs" color="primary" variant="subtle" class="uppercase text-[9px]">
|
|
355
|
+
{{ currentTenant.plan }}
|
|
356
|
+
</UBadge>
|
|
357
|
+
</div>
|
|
358
|
+
<span v-else class="text-sm font-semibold text-muted">Select an organization</span>
|
|
359
|
+
</template>
|
|
360
|
+
|
|
361
|
+
<template #right>
|
|
362
|
+
<div v-if="currentTenant" class="flex items-center gap-2">
|
|
363
|
+
<UButton
|
|
364
|
+
label="Manage Zone on qarpeo.com"
|
|
365
|
+
icon="i-lucide-external-link"
|
|
366
|
+
trailing
|
|
367
|
+
size="xs"
|
|
368
|
+
color="neutral"
|
|
369
|
+
variant="ghost"
|
|
370
|
+
to="https://qarpeo.com/dashboard/domains"
|
|
371
|
+
target="_blank"
|
|
372
|
+
class="hidden sm:inline-flex"
|
|
373
|
+
/>
|
|
374
|
+
<UButton
|
|
375
|
+
label="Add Custom Domain"
|
|
376
|
+
icon="i-lucide-plus"
|
|
377
|
+
size="xs"
|
|
378
|
+
color="primary"
|
|
379
|
+
@click="openAddDomainModal"
|
|
380
|
+
/>
|
|
381
|
+
</div>
|
|
382
|
+
</template>
|
|
383
|
+
</UDashboardNavbar>
|
|
384
|
+
</template>
|
|
385
|
+
|
|
386
|
+
<template #body>
|
|
387
|
+
<!-- Loading Skeleton for Main Panel -->
|
|
388
|
+
<div v-if="loading" class="p-6 space-y-6">
|
|
389
|
+
<div class="grid grid-cols-1 sm:grid-cols-4 gap-4">
|
|
390
|
+
<UCard v-for="i in 4" :key="`skel-${i}`">
|
|
391
|
+
<div class="h-3 w-20 rounded bg-muted animate-pulse mb-2"></div>
|
|
392
|
+
<div class="h-6 w-16 rounded bg-muted animate-pulse"></div>
|
|
393
|
+
</UCard>
|
|
394
|
+
</div>
|
|
395
|
+
<div class="h-48 rounded bg-muted/40 animate-pulse"></div>
|
|
396
|
+
</div>
|
|
397
|
+
|
|
398
|
+
<div v-else-if="currentTenant" class="flex flex-col h-full p-6 space-y-6 overflow-y-auto">
|
|
399
|
+
<!-- Top Metrics Cards -->
|
|
400
|
+
<div class="grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-4 gap-4">
|
|
401
|
+
<UCard>
|
|
402
|
+
<div class="flex items-center justify-between text-xs text-muted mb-1">
|
|
403
|
+
<span>Total Domains</span>
|
|
404
|
+
<UIcon name="i-lucide-globe" class="w-4 h-4 text-primary" />
|
|
405
|
+
</div>
|
|
406
|
+
<div class="text-2xl font-extrabold text-highlighted">
|
|
407
|
+
{{ tenantDomains.length }}
|
|
408
|
+
</div>
|
|
409
|
+
<div class="text-[11px] text-muted mt-1">Configured hostnames</div>
|
|
410
|
+
</UCard>
|
|
411
|
+
|
|
412
|
+
<UCard>
|
|
413
|
+
<div class="flex items-center justify-between text-xs text-muted mb-1">
|
|
414
|
+
<span>Active SSL</span>
|
|
415
|
+
<UIcon name="i-lucide-shield-check" class="w-4 h-4 text-success" />
|
|
416
|
+
</div>
|
|
417
|
+
<div class="text-2xl font-extrabold text-success">
|
|
418
|
+
{{ activeDomainsCount }}
|
|
419
|
+
</div>
|
|
420
|
+
<div class="text-[11px] text-muted mt-1">Let's Encrypt / Google Trust</div>
|
|
421
|
+
</UCard>
|
|
422
|
+
|
|
423
|
+
<UCard>
|
|
424
|
+
<div class="flex items-center justify-between text-xs text-muted mb-1">
|
|
425
|
+
<span>Pending DNS / SSL</span>
|
|
426
|
+
<UIcon name="i-lucide-clock" class="w-4 h-4 text-warning" />
|
|
427
|
+
</div>
|
|
428
|
+
<div class="text-2xl font-extrabold text-warning">
|
|
429
|
+
{{ pendingDomainsCount }}
|
|
430
|
+
</div>
|
|
431
|
+
<div class="text-[11px] text-muted mt-1">Awaiting DNS propagation</div>
|
|
432
|
+
</UCard>
|
|
433
|
+
|
|
434
|
+
<UCard>
|
|
435
|
+
<div class="flex items-center justify-between text-xs text-muted mb-1">
|
|
436
|
+
<span>Primary Subdomain</span>
|
|
437
|
+
<UIcon name="i-lucide-link" class="w-4 h-4 text-primary" />
|
|
438
|
+
</div>
|
|
439
|
+
<div class="text-xs font-mono font-bold text-primary truncate mt-1">
|
|
440
|
+
{{ currentTenant.slug }}.{{ multitenantConfig?.rootDomains?.[0] || "qarpeo.dev" }}
|
|
441
|
+
</div>
|
|
442
|
+
<div class="text-[11px] text-muted mt-2">Zero-config edge routing</div>
|
|
443
|
+
</UCard>
|
|
444
|
+
</div>
|
|
445
|
+
|
|
446
|
+
<!-- Custom Domains List Card -->
|
|
447
|
+
<UCard :ui="{ body: 'p-0 overflow-hidden' }">
|
|
448
|
+
<template #header>
|
|
449
|
+
<div class="flex items-center justify-between flex-wrap gap-2">
|
|
450
|
+
<div>
|
|
451
|
+
<h3 class="font-bold text-sm text-highlighted flex items-center gap-2">
|
|
452
|
+
<UIcon name="i-lucide-shield" class="w-4 h-4 text-primary" />
|
|
453
|
+
Custom Hostnames (Cloudflare for SaaS)
|
|
454
|
+
</h3>
|
|
455
|
+
<p class="text-xs text-muted mt-0.5">
|
|
456
|
+
Point your customer's DNS CNAME record to
|
|
457
|
+
<code class="font-mono text-primary font-bold">{{
|
|
458
|
+
multitenantConfig?.cnameTarget || "cname.qarpeo.com"
|
|
459
|
+
}}</code>
|
|
460
|
+
</p>
|
|
461
|
+
</div>
|
|
462
|
+
|
|
463
|
+
<div class="flex items-center gap-2">
|
|
464
|
+
<UInput
|
|
465
|
+
v-model="domainSearch"
|
|
466
|
+
icon="i-lucide-search"
|
|
467
|
+
placeholder="Filter domains…"
|
|
468
|
+
size="xs"
|
|
469
|
+
class="w-48"
|
|
470
|
+
/>
|
|
471
|
+
</div>
|
|
472
|
+
</div>
|
|
473
|
+
</template>
|
|
474
|
+
|
|
475
|
+
<div class="overflow-x-auto">
|
|
476
|
+
<table class="w-full text-left text-xs">
|
|
477
|
+
<thead>
|
|
478
|
+
<tr class="border-b border-default bg-muted/40 text-muted font-mono">
|
|
479
|
+
<th class="py-2.5 px-4 font-semibold">Hostname</th>
|
|
480
|
+
<th class="py-2.5 px-4 font-semibold">SSL Status</th>
|
|
481
|
+
<th class="py-2.5 px-4 font-semibold">CNAME Target</th>
|
|
482
|
+
<th class="py-2.5 px-4 font-semibold text-right">Actions</th>
|
|
483
|
+
</tr>
|
|
484
|
+
</thead>
|
|
485
|
+
<tbody class="divide-y divide-default font-mono">
|
|
486
|
+
<tr
|
|
487
|
+
v-for="d in tenantDomains"
|
|
488
|
+
:key="d.id"
|
|
489
|
+
class="hover:bg-elevated/50 transition-colors group"
|
|
490
|
+
>
|
|
491
|
+
<td class="py-3 px-4 font-bold text-highlighted">
|
|
492
|
+
<div class="flex items-center gap-2">
|
|
493
|
+
<span>{{ d.domain }}</span>
|
|
494
|
+
<a
|
|
495
|
+
:href="`https://${d.domain}`"
|
|
496
|
+
target="_blank"
|
|
497
|
+
rel="noopener"
|
|
498
|
+
class="text-muted hover:text-primary transition-colors"
|
|
499
|
+
title="Open domain"
|
|
500
|
+
>
|
|
501
|
+
<UIcon name="i-lucide-external-link" class="w-3.5 h-3.5" />
|
|
502
|
+
</a>
|
|
503
|
+
</div>
|
|
504
|
+
</td>
|
|
505
|
+
<td class="py-3 px-4">
|
|
506
|
+
<UBadge
|
|
507
|
+
size="xs"
|
|
508
|
+
:color="getSslBadgeColor(d.sslStatus)"
|
|
509
|
+
variant="subtle"
|
|
510
|
+
class="uppercase text-[9px] font-semibold"
|
|
511
|
+
>
|
|
512
|
+
<UIcon
|
|
513
|
+
:name="
|
|
514
|
+
d.sslStatus === 'active'
|
|
515
|
+
? 'i-lucide-check-circle'
|
|
516
|
+
: 'i-lucide-alert-circle'
|
|
517
|
+
"
|
|
518
|
+
class="w-3 h-3 mr-1"
|
|
519
|
+
/>
|
|
520
|
+
{{ d.sslStatus }}
|
|
521
|
+
</UBadge>
|
|
522
|
+
</td>
|
|
523
|
+
<td class="py-3 px-4 text-muted flex items-center gap-2">
|
|
524
|
+
<span class="font-mono text-xs text-default">{{
|
|
525
|
+
d.cnameTarget || multitenantConfig?.cnameTarget || "cname.qarpeo.com"
|
|
526
|
+
}}</span>
|
|
527
|
+
<UButton
|
|
528
|
+
icon="i-lucide-copy"
|
|
529
|
+
color="neutral"
|
|
530
|
+
variant="ghost"
|
|
531
|
+
size="xs"
|
|
532
|
+
title="Copy CNAME target"
|
|
533
|
+
@click="
|
|
534
|
+
copyToClipboard(
|
|
535
|
+
d.cnameTarget || multitenantConfig?.cnameTarget || 'cname.qarpeo.com',
|
|
536
|
+
)
|
|
537
|
+
"
|
|
538
|
+
/>
|
|
539
|
+
</td>
|
|
540
|
+
<td class="py-3 px-4 text-right">
|
|
541
|
+
<div class="flex items-center justify-end gap-1.5">
|
|
542
|
+
<UButton
|
|
543
|
+
label="Verify"
|
|
544
|
+
icon="i-lucide-refresh-cw"
|
|
545
|
+
size="xs"
|
|
546
|
+
color="neutral"
|
|
547
|
+
variant="subtle"
|
|
548
|
+
title="Check DNS propagation & SSL certificate"
|
|
549
|
+
:loading="verifyingDomain === d.domain"
|
|
550
|
+
@click="verifyDomain(d.domain)"
|
|
551
|
+
/>
|
|
552
|
+
<UButton
|
|
553
|
+
icon="i-lucide-trash"
|
|
554
|
+
size="xs"
|
|
555
|
+
color="neutral"
|
|
556
|
+
variant="ghost"
|
|
557
|
+
class="hover:text-error"
|
|
558
|
+
title="Remove domain"
|
|
559
|
+
:loading="deletingDomain === d.domain"
|
|
560
|
+
@click="deleteDomain(d.domain)"
|
|
561
|
+
/>
|
|
562
|
+
</div>
|
|
563
|
+
</td>
|
|
564
|
+
</tr>
|
|
565
|
+
|
|
566
|
+
<tr v-if="!tenantDomains.length">
|
|
567
|
+
<td colspan="4" class="text-center py-12 text-muted text-xs font-sans">
|
|
568
|
+
<UIcon name="i-lucide-globe" class="w-8 h-8 opacity-40 mx-auto mb-2" />
|
|
569
|
+
No custom domains registered for {{ currentTenant.name }}.
|
|
570
|
+
<div class="mt-2">
|
|
571
|
+
<UButton
|
|
572
|
+
label="Add Custom Domain"
|
|
573
|
+
icon="i-lucide-plus"
|
|
574
|
+
size="xs"
|
|
575
|
+
color="primary"
|
|
576
|
+
variant="subtle"
|
|
577
|
+
@click="openAddDomainModal"
|
|
578
|
+
/>
|
|
579
|
+
</div>
|
|
580
|
+
</td>
|
|
581
|
+
</tr>
|
|
582
|
+
</tbody>
|
|
583
|
+
</table>
|
|
584
|
+
</div>
|
|
585
|
+
</UCard>
|
|
586
|
+
|
|
587
|
+
<!-- DNS Configuration Setup Guide Card -->
|
|
588
|
+
<UCard>
|
|
589
|
+
<template #header>
|
|
590
|
+
<div class="flex items-center gap-2">
|
|
591
|
+
<UIcon name="i-lucide-info" class="w-4 h-4 text-primary" />
|
|
592
|
+
<span class="font-bold text-sm text-highlighted">DNS Configuration Guide</span>
|
|
593
|
+
</div>
|
|
594
|
+
</template>
|
|
595
|
+
|
|
596
|
+
<div class="text-xs text-muted space-y-3">
|
|
597
|
+
<p>
|
|
598
|
+
To route custom domains to your multi-tenant application, your customers must
|
|
599
|
+
configure a DNS record with their domain registrar:
|
|
600
|
+
</p>
|
|
601
|
+
|
|
602
|
+
<div
|
|
603
|
+
class="bg-muted/40 p-3 rounded-lg border border-default font-mono text-xs space-y-2"
|
|
604
|
+
>
|
|
605
|
+
<div
|
|
606
|
+
class="grid grid-cols-3 gap-2 font-bold text-highlighted pb-1 border-b border-default"
|
|
607
|
+
>
|
|
608
|
+
<div>Type</div>
|
|
609
|
+
<div>Name / Host</div>
|
|
610
|
+
<div>Target / Value</div>
|
|
611
|
+
</div>
|
|
612
|
+
<div class="grid grid-cols-3 gap-2 text-default">
|
|
613
|
+
<div class="text-primary font-bold">CNAME</div>
|
|
614
|
+
<div>app (or @ for apex)</div>
|
|
615
|
+
<div class="flex items-center gap-1.5 font-bold">
|
|
616
|
+
{{ multitenantConfig?.cnameTarget || "cname.qarpeo.com" }}
|
|
617
|
+
<UButton
|
|
618
|
+
icon="i-lucide-copy"
|
|
619
|
+
color="neutral"
|
|
620
|
+
variant="ghost"
|
|
621
|
+
size="xs"
|
|
622
|
+
title="Copy Target"
|
|
623
|
+
@click="copyToClipboard(multitenantConfig?.cnameTarget || 'cname.qarpeo.com')"
|
|
624
|
+
/>
|
|
625
|
+
</div>
|
|
626
|
+
</div>
|
|
627
|
+
</div>
|
|
628
|
+
|
|
629
|
+
<p class="text-[11px] text-muted">
|
|
630
|
+
Once configured, Cloudflare for SaaS will automatically issue and renew a free TLS/SSL
|
|
631
|
+
certificate (via Let's Encrypt or Google Trust Services), providing automatic HTTPS at
|
|
632
|
+
the edge.
|
|
633
|
+
</p>
|
|
634
|
+
</div>
|
|
635
|
+
</UCard>
|
|
636
|
+
</div>
|
|
637
|
+
|
|
638
|
+
<div
|
|
639
|
+
v-else
|
|
640
|
+
class="flex-1 flex flex-col items-center justify-center text-muted text-xs p-12 text-center"
|
|
641
|
+
>
|
|
642
|
+
<UIcon name="i-lucide-building-2" class="w-8 h-8 mb-2 opacity-50 text-muted" />
|
|
643
|
+
Select an organization from the list to manage its custom domains.
|
|
644
|
+
</div>
|
|
645
|
+
</template>
|
|
646
|
+
</UDashboardPanel>
|
|
647
|
+
|
|
648
|
+
<!-- ── Modal: Create Tenant ──────────────────────────────────────────── -->
|
|
649
|
+
<UModal
|
|
650
|
+
v-model:open="showNewTenantModal"
|
|
651
|
+
title="Create Organization"
|
|
652
|
+
description="Add a new tenant organization to the multi-tenant system."
|
|
653
|
+
>
|
|
654
|
+
<template #body>
|
|
655
|
+
<div class="space-y-3">
|
|
656
|
+
<div
|
|
657
|
+
v-if="tenantError"
|
|
658
|
+
class="p-2.5 bg-error/10 border border-error/20 rounded text-error text-xs font-mono"
|
|
659
|
+
>
|
|
660
|
+
{{ tenantError }}
|
|
661
|
+
</div>
|
|
662
|
+
|
|
663
|
+
<UFormField label="Organization Name" name="name" required>
|
|
664
|
+
<UInput
|
|
665
|
+
v-model="newTenantForm.name"
|
|
666
|
+
placeholder="e.g. Acme Corporation"
|
|
667
|
+
class="w-full"
|
|
668
|
+
@update:model-value="
|
|
669
|
+
(val) => {
|
|
670
|
+
if (!newTenantForm.slug) {
|
|
671
|
+
newTenantForm.slug = val.toLowerCase().replace(/[^a-z0-9]/g, '-')
|
|
672
|
+
}
|
|
673
|
+
}
|
|
674
|
+
"
|
|
675
|
+
/>
|
|
676
|
+
</UFormField>
|
|
677
|
+
|
|
678
|
+
<UFormField
|
|
679
|
+
label="Subdomain Slug"
|
|
680
|
+
name="slug"
|
|
681
|
+
required
|
|
682
|
+
help="Used for edge subdomain routing (e.g. acme.qarpeo.dev)"
|
|
683
|
+
>
|
|
684
|
+
<UInput
|
|
685
|
+
v-model="newTenantForm.slug"
|
|
686
|
+
placeholder="e.g. acme"
|
|
687
|
+
class="w-full font-mono text-xs"
|
|
688
|
+
/>
|
|
689
|
+
</UFormField>
|
|
690
|
+
|
|
691
|
+
<UFormField label="Subscription Plan" name="plan">
|
|
692
|
+
<USelect
|
|
693
|
+
v-model="newTenantForm.plan"
|
|
694
|
+
:items="[
|
|
695
|
+
{ label: 'Pro Plan', value: 'pro' },
|
|
696
|
+
{ label: 'Enterprise Plan', value: 'enterprise' },
|
|
697
|
+
{ label: 'Free Tier', value: 'free' },
|
|
698
|
+
]"
|
|
699
|
+
class="w-full"
|
|
700
|
+
/>
|
|
701
|
+
</UFormField>
|
|
702
|
+
</div>
|
|
703
|
+
</template>
|
|
704
|
+
|
|
705
|
+
<template #footer>
|
|
706
|
+
<div class="flex justify-end gap-2 w-full">
|
|
707
|
+
<UButton size="xs" color="neutral" variant="ghost" @click="showNewTenantModal = false">
|
|
708
|
+
Cancel
|
|
709
|
+
</UButton>
|
|
710
|
+
<UButton
|
|
711
|
+
size="xs"
|
|
712
|
+
color="primary"
|
|
713
|
+
icon="i-lucide-plus"
|
|
714
|
+
:loading="creatingTenant"
|
|
715
|
+
@click="createTenant"
|
|
716
|
+
>
|
|
717
|
+
Create Organization
|
|
718
|
+
</UButton>
|
|
719
|
+
</div>
|
|
720
|
+
</template>
|
|
721
|
+
</UModal>
|
|
722
|
+
|
|
723
|
+
<!-- ── Modal: Add Custom Domain ──────────────────────────────────────── -->
|
|
724
|
+
<UModal
|
|
725
|
+
v-model:open="showAddDomainModal"
|
|
726
|
+
:title="`Add Custom Domain for ${currentTenant?.name}`"
|
|
727
|
+
description="Connect a fully qualified custom domain name."
|
|
728
|
+
>
|
|
729
|
+
<template #body>
|
|
730
|
+
<div class="space-y-3">
|
|
731
|
+
<div
|
|
732
|
+
v-if="domainError"
|
|
733
|
+
class="p-2.5 bg-error/10 border border-error/20 rounded text-error text-xs font-mono"
|
|
734
|
+
>
|
|
735
|
+
{{ domainError }}
|
|
736
|
+
</div>
|
|
737
|
+
|
|
738
|
+
<UFormField
|
|
739
|
+
label="Domain Name (FQDN)"
|
|
740
|
+
name="domain"
|
|
741
|
+
required
|
|
742
|
+
help="Enter your customer's domain, e.g. portal.acme.com or app.custom.org"
|
|
743
|
+
>
|
|
744
|
+
<UInput
|
|
745
|
+
v-model="newDomainInput"
|
|
746
|
+
placeholder="e.g. portal.acme.com"
|
|
747
|
+
class="w-full font-mono text-xs"
|
|
748
|
+
@keydown.enter.prevent="addDomain"
|
|
749
|
+
/>
|
|
750
|
+
</UFormField>
|
|
751
|
+
</div>
|
|
752
|
+
</template>
|
|
753
|
+
|
|
754
|
+
<template #footer>
|
|
755
|
+
<div class="flex justify-end gap-2 w-full">
|
|
756
|
+
<UButton size="xs" color="neutral" variant="ghost" @click="showAddDomainModal = false">
|
|
757
|
+
Cancel
|
|
758
|
+
</UButton>
|
|
759
|
+
<UButton
|
|
760
|
+
size="xs"
|
|
761
|
+
color="primary"
|
|
762
|
+
icon="i-lucide-plus"
|
|
763
|
+
:loading="addingDomain"
|
|
764
|
+
@click="addDomain"
|
|
765
|
+
>
|
|
766
|
+
Add Domain
|
|
767
|
+
</UButton>
|
|
768
|
+
</div>
|
|
769
|
+
</template>
|
|
770
|
+
</UModal>
|
|
771
|
+
</template>
|