inicontent 1.0.0
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/.github/pull_request.yml +18 -0
- package/CONTRIBUTING.md +67 -0
- package/LICENSE +21 -0
- package/README.md +142 -0
- package/app/app.vue +106 -0
- package/app/assets/main.css +974 -0
- package/app/components/Api/EndpointCard.vue +169 -0
- package/app/components/Api/SchemaDocsTable.vue +208 -0
- package/app/components/Asset/Card.vue +1363 -0
- package/app/components/Asset/Grid.vue +295 -0
- package/app/components/Asset/Icon.vue +38 -0
- package/app/components/Asset/Preview.vue +486 -0
- package/app/components/Asset/Scanner.vue +700 -0
- package/app/components/Asset/Thumb.vue +708 -0
- package/app/components/Auth/Reset.vue +99 -0
- package/app/components/Auth/index.vue +346 -0
- package/app/components/ChatInterface.vue +2326 -0
- package/app/components/ChatPagePreview.vue +34 -0
- package/app/components/Column/Array.vue +29 -0
- package/app/components/Column/Asset.vue +21 -0
- package/app/components/Column/Boolean.vue +12 -0
- package/app/components/Column/Color.vue +9 -0
- package/app/components/Column/Date.vue +57 -0
- package/app/components/Column/Edit.vue +215 -0
- package/app/components/Column/Email.vue +9 -0
- package/app/components/Column/Html.vue +27 -0
- package/app/components/Column/Id.vue +20 -0
- package/app/components/Column/Locale.vue +32 -0
- package/app/components/Column/Object.vue +18 -0
- package/app/components/Column/Password.vue +7 -0
- package/app/components/Column/Role.vue +15 -0
- package/app/components/Column/S.vue +14 -0
- package/app/components/Column/Table/Single.vue +49 -0
- package/app/components/Column/Table/index.vue +42 -0
- package/app/components/Column/Tags.vue +31 -0
- package/app/components/Column/Text.vue +9 -0
- package/app/components/Column/Url.vue +9 -0
- package/app/components/Column/index.vue +41 -0
- package/app/components/Dashboard/Editor.vue +221 -0
- package/app/components/Dashboard/Grid.vue +270 -0
- package/app/components/Dashboard/View.vue +131 -0
- package/app/components/Dashboard/Widget/BarChart.vue +73 -0
- package/app/components/Dashboard/Widget/Counter.vue +51 -0
- package/app/components/Dashboard/Widget/LineChart.vue +76 -0
- package/app/components/Dashboard/Widget/PieChart.vue +75 -0
- package/app/components/Dashboard/Widget/Table.vue +94 -0
- package/app/components/Dashboard/WidgetEditor.vue +274 -0
- package/app/components/Data/Array.vue +102 -0
- package/app/components/Data/Html.vue +9 -0
- package/app/components/Data/Icon.vue +9 -0
- package/app/components/Data/Object.vue +10 -0
- package/app/components/Data/S.vue +16 -0
- package/app/components/Data/Table.vue +53 -0
- package/app/components/Data/Value.vue +34 -0
- package/app/components/Data/index.vue +14 -0
- package/app/components/Field/Array.vue +324 -0
- package/app/components/Field/Asset/Actions.vue +97 -0
- package/app/components/Field/Asset/index.vue +639 -0
- package/app/components/Field/Boolean.vue +26 -0
- package/app/components/Field/Checkbox.vue +48 -0
- package/app/components/Field/Color.vue +27 -0
- package/app/components/Field/Date.vue +30 -0
- package/app/components/Field/Email.vue +51 -0
- package/app/components/Field/EmailTemplate.vue +420 -0
- package/app/components/Field/Html/ColorPicker.vue +127 -0
- package/app/components/Field/Html/Editor.vue +544 -0
- package/app/components/Field/Html/index.vue +25 -0
- package/app/components/Field/Icon.vue +114 -0
- package/app/components/Field/JSON.vue +113 -0
- package/app/components/Field/Mention.vue +36 -0
- package/app/components/Field/Number.vue +27 -0
- package/app/components/Field/Object.vue +92 -0
- package/app/components/Field/Password.vue +55 -0
- package/app/components/Field/Radio.vue +47 -0
- package/app/components/Field/S.vue +44 -0
- package/app/components/Field/Select.vue +49 -0
- package/app/components/Field/Table.vue +348 -0
- package/app/components/Field/Tags.vue +113 -0
- package/app/components/Field/Text.vue +31 -0
- package/app/components/Field/Textarea.vue +33 -0
- package/app/components/Field/Url.vue +40 -0
- package/app/components/Field/Wrapper.vue +128 -0
- package/app/components/Field/index.vue +68 -0
- package/app/components/FloatingChatbot.vue +73 -0
- package/app/components/Form/Card.vue +151 -0
- package/app/components/Form/Drawer.vue +195 -0
- package/app/components/Form/index.vue +621 -0
- package/app/components/Header.vue +328 -0
- package/app/components/Offline/ConflictModal.vue +200 -0
- package/app/components/Offline/SyncStatus.vue +249 -0
- package/app/components/PlatformFeatureLanding.vue +65 -0
- package/app/components/Table/Backups.vue +638 -0
- package/app/components/Table/Flows.vue +814 -0
- package/app/components/Table/Grid.vue +296 -0
- package/app/components/Table/Icon.vue +36 -0
- package/app/components/Table/Logs.vue +181 -0
- package/app/components/Table/Schedules.vue +722 -0
- package/app/components/Table/Search/Button.vue +256 -0
- package/app/components/Table/Search/Items.vue +286 -0
- package/app/components/Table/Search/index.vue +87 -0
- package/app/components/Table/Settings/Schema.vue +801 -0
- package/app/components/Table/Settings/index.vue +631 -0
- package/app/components/Table/TranslateDrawer.vue +526 -0
- package/app/components/Table/Views/Kanban.vue +289 -0
- package/app/components/Table/Views/Table.vue +1273 -0
- package/app/components/Table/index.vue +890 -0
- package/app/composables/Translation/define.ts +41 -0
- package/app/composables/Translation/fetch.ts +107 -0
- package/app/composables/Translation/languages.ts +1 -0
- package/app/composables/Translation/loadCoreTranslations.ts +38 -0
- package/app/composables/Translation/translate.ts +250 -0
- package/app/composables/databaseCookies.ts +79 -0
- package/app/composables/fieldValidator.ts +72 -0
- package/app/composables/fieldsList.ts +301 -0
- package/app/composables/formatDatabase.ts +101 -0
- package/app/composables/index.ts +444 -0
- package/app/composables/openDrawer.ts +118 -0
- package/app/composables/optimizeFile.ts +287 -0
- package/app/composables/renderLabel.ts +88 -0
- package/app/composables/schemaClipboard.ts +95 -0
- package/app/composables/search.ts +353 -0
- package/app/composables/setThemeConfig.ts +48 -0
- package/app/composables/translationValue.ts +169 -0
- package/app/composables/useAssetPreview.ts +84 -0
- package/app/composables/useAssetUploader.ts +56 -0
- package/app/composables/useDashboardData.ts +310 -0
- package/app/composables/useDocumentThumbnail.ts +351 -0
- package/app/composables/useEcharts.ts +33 -0
- package/app/composables/useLocalDatabaseConfig.ts +51 -0
- package/app/composables/useOcr.ts +300 -0
- package/app/composables/useOfflineFetch.ts +194 -0
- package/app/composables/useOfflineItem.ts +107 -0
- package/app/composables/useOfflineQueue.ts +302 -0
- package/app/composables/useOfflineSync.ts +235 -0
- package/app/composables/usePasskeyAuth.ts +156 -0
- package/app/composables/usePdfCompressor.ts +180 -0
- package/app/composables/usePlatformRedirect.ts +72 -0
- package/app/composables/useRealtimeSync.ts +233 -0
- package/app/composables/useReferencedItems.ts +180 -0
- package/app/composables/useScanner.ts +664 -0
- package/app/composables/useSubscription.ts +650 -0
- package/app/composables/useThumbnailCache.ts +136 -0
- package/app/composables/useVideoCompressor.ts +194 -0
- package/app/error.vue +112 -0
- package/app/layouts/api.vue +188 -0
- package/app/layouts/dashboard.vue +91 -0
- package/app/layouts/default.vue +228 -0
- package/app/layouts/table.vue +471 -0
- package/app/locales/ar.ts +996 -0
- package/app/locales/en.ts +655 -0
- package/app/locales/es.ts +996 -0
- package/app/locales/fr.ts +997 -0
- package/app/middleware/dashboard.ts +33 -0
- package/app/middleware/database.ts +83 -0
- package/app/middleware/global.ts +1 -0
- package/app/middleware/sid-ingest.global.ts +29 -0
- package/app/middleware/table.ts +54 -0
- package/app/middleware/user.ts +26 -0
- package/app/pages/[[database]]/admin/api/auth/index.vue +306 -0
- package/app/pages/[[database]]/admin/api/index.vue +18 -0
- package/app/pages/[[database]]/admin/api/tables/[table]/index.vue +497 -0
- package/app/pages/[[database]]/admin/api/tables/index.vue +87 -0
- package/app/pages/[[database]]/admin/billing/index.vue +16 -0
- package/app/pages/[[database]]/admin/dashboards/[id]/edit.vue +66 -0
- package/app/pages/[[database]]/admin/dashboards/[id]/index.vue +117 -0
- package/app/pages/[[database]]/admin/dashboards/index.vue +20 -0
- package/app/pages/[[database]]/admin/index.vue +28 -0
- package/app/pages/[[database]]/admin/settings.vue +526 -0
- package/app/pages/[[database]]/admin/tables/[table]/[id]/edit.vue +143 -0
- package/app/pages/[[database]]/admin/tables/[table]/[id]/index.vue +146 -0
- package/app/pages/[[database]]/admin/tables/[table]/flows.vue +10 -0
- package/app/pages/[[database]]/admin/tables/[table]/index.vue +10 -0
- package/app/pages/[[database]]/admin/tables/[table]/new.vue +12 -0
- package/app/pages/[[database]]/admin/tables/[table]/schedules.vue +10 -0
- package/app/pages/[[database]]/admin/tables/[table]/settings.vue +30 -0
- package/app/pages/[[database]]/admin/tables/assets/[...path].vue +24 -0
- package/app/pages/[[database]]/admin/tables/assets/flows.vue +10 -0
- package/app/pages/[[database]]/admin/tables/backups/index.vue +10 -0
- package/app/pages/[[database]]/admin/tables/blocks/index.vue +16 -0
- package/app/pages/[[database]]/admin/tables/index.vue +20 -0
- package/app/pages/[[database]]/admin/tables/pages/index.vue +16 -0
- package/app/pages/[[database]]/admin/tables/templates/index.vue +16 -0
- package/app/pages/[[database]]/api/index.vue +120 -0
- package/app/pages/[[database]]/auth/index.vue +12 -0
- package/app/pages/[[database]]/auth/reset.vue +10 -0
- package/app/pages/[[database]]/index.vue +10 -0
- package/app/plugins/offline-warmup.client.ts +53 -0
- package/app/plugins/template-globals.ts +9 -0
- package/app/spa-loading-template.html +93 -0
- package/biome.json +53 -0
- package/index.d.ts +380 -0
- package/modules/naiveui.ts +41 -0
- package/nuxt.config.ts +269 -0
- package/package.json +56 -0
- package/pnpm-workspace.yaml +5 -0
- package/public/apple-touch-icon.png +0 -0
- package/public/favicon-16x16.png +0 -0
- package/public/favicon-32x32.png +0 -0
- package/public/favicon.ico +0 -0
- package/public/pwa-192x192.png +0 -0
- package/public/pwa-512x512.png +0 -0
- package/public/pwa-maskable-192x192.png +0 -0
- package/public/pwa-maskable-512x512.png +0 -0
- package/public/vendor/opencv.js +48 -0
- package/tsconfig.json +9 -0
|
@@ -0,0 +1,117 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<NSpin :show="loading">
|
|
3
|
+
<NCard :title="dashboard?.name ?? t('dashboard')" style="background:none" :bordered="false">
|
|
4
|
+
<template #header-extra>
|
|
5
|
+
<NFlex :size="8" align="center">
|
|
6
|
+
<NPopover v-if="dashboard?.widgets?.length" trigger="click" placement="bottom-end">
|
|
7
|
+
<template #trigger>
|
|
8
|
+
<NButton size="small" secondary :type="dateRangeOverride ? 'primary' : 'default'">
|
|
9
|
+
<template #icon>
|
|
10
|
+
<NIcon>
|
|
11
|
+
<Icon name="tabler:calendar" />
|
|
12
|
+
</NIcon>
|
|
13
|
+
</template>
|
|
14
|
+
{{ t('dateRange') }}
|
|
15
|
+
</NButton>
|
|
16
|
+
</template>
|
|
17
|
+
<NSelect
|
|
18
|
+
v-model:value="dateRangeOverride"
|
|
19
|
+
:options="dateRangeOptions"
|
|
20
|
+
:placeholder="t('dateRange')"
|
|
21
|
+
clearable
|
|
22
|
+
style="width: 200px"
|
|
23
|
+
/>
|
|
24
|
+
</NPopover>
|
|
25
|
+
<NButton
|
|
26
|
+
v-if="user?.role === config.public.idOne"
|
|
27
|
+
size="small"
|
|
28
|
+
type="primary"
|
|
29
|
+
secondary
|
|
30
|
+
@click="navigateTo(`${routeBase}/admin/dashboards/${route.params.id}/edit`)"
|
|
31
|
+
>
|
|
32
|
+
<template #icon>
|
|
33
|
+
<NIcon>
|
|
34
|
+
<Icon name="tabler:edit" />
|
|
35
|
+
</NIcon>
|
|
36
|
+
</template>
|
|
37
|
+
{{ t("edit") }}
|
|
38
|
+
</NButton>
|
|
39
|
+
</NFlex>
|
|
40
|
+
</template>
|
|
41
|
+
<LazyDashboardView
|
|
42
|
+
v-if="dashboard"
|
|
43
|
+
:dashboard="dashboard"
|
|
44
|
+
:database-slug="databaseSlug"
|
|
45
|
+
:date-range-override="dateRangeOverride"
|
|
46
|
+
/>
|
|
47
|
+
</NCard>
|
|
48
|
+
</NSpin>
|
|
49
|
+
</template>
|
|
50
|
+
|
|
51
|
+
<script setup lang="ts">
|
|
52
|
+
definePageMeta({
|
|
53
|
+
layout: "table",
|
|
54
|
+
middleware: ["database", "user", "dashboard", "global"],
|
|
55
|
+
});
|
|
56
|
+
|
|
57
|
+
const route = useRoute();
|
|
58
|
+
const config = useRuntimeConfig();
|
|
59
|
+
const user = useState<User>("user");
|
|
60
|
+
const database = useState<Database>("database");
|
|
61
|
+
|
|
62
|
+
const databaseSlug = computed(() =>
|
|
63
|
+
(route.params.database as string) || database.value?.slug || "",
|
|
64
|
+
);
|
|
65
|
+
|
|
66
|
+
const routeBase = computed(() =>
|
|
67
|
+
route.params.database ? `/${route.params.database}` : "",
|
|
68
|
+
);
|
|
69
|
+
|
|
70
|
+
const Language = useScopedCookie<LanguagesType>("language", database.value?.slug);
|
|
71
|
+
const sessionID = useScopedCookie<string>("sid", database.value?.slug);
|
|
72
|
+
|
|
73
|
+
const dashboard = ref<Dashboard | null>(null);
|
|
74
|
+
const currentDashboard = useState<Dashboard | null>("currentDashboard", () => null);
|
|
75
|
+
const loading = ref(true);
|
|
76
|
+
const dateRangeOverride = ref<WidgetDateRange | undefined>(undefined);
|
|
77
|
+
|
|
78
|
+
const dateRangeOptions = [
|
|
79
|
+
{ label: t("last7Days"), value: "7d" },
|
|
80
|
+
{ label: t("last30Days"), value: "30d" },
|
|
81
|
+
{ label: t("last90Days"), value: "90d" },
|
|
82
|
+
{ label: t("lastYear"), value: "1y" },
|
|
83
|
+
{ label: t("allTime"), value: "all" },
|
|
84
|
+
];
|
|
85
|
+
|
|
86
|
+
onMounted(async () => {
|
|
87
|
+
try {
|
|
88
|
+
const slug = databaseSlug.value ? `${databaseSlug.value}/` : "";
|
|
89
|
+
const res = await $fetch<apiResponse<Dashboard>>(
|
|
90
|
+
`${config.public.apiBase}${slug}dashboards/${route.params.id}`,
|
|
91
|
+
{
|
|
92
|
+
params: {
|
|
93
|
+
locale: Language.value,
|
|
94
|
+
[`${databaseSlug.value}_sid`]: sessionID.value,
|
|
95
|
+
},
|
|
96
|
+
credentials: "include",
|
|
97
|
+
},
|
|
98
|
+
);
|
|
99
|
+
dashboard.value = res.result;
|
|
100
|
+
currentDashboard.value = res.result;
|
|
101
|
+
if (dashboard.value) {
|
|
102
|
+
if (typeof dashboard.value.widgets === "string") {
|
|
103
|
+
try {
|
|
104
|
+
dashboard.value.widgets = JSON.parse(dashboard.value.widgets);
|
|
105
|
+
} catch {}
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
} catch {
|
|
109
|
+
window.$message.error(t("error"));
|
|
110
|
+
}
|
|
111
|
+
loading.value = false;
|
|
112
|
+
});
|
|
113
|
+
|
|
114
|
+
useHead({
|
|
115
|
+
title: computed(() => `${dashboard.value?.name ?? t("dashboard")} | ${t("dashboards")}`),
|
|
116
|
+
});
|
|
117
|
+
</script>
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<NCard :title="t('dashboards')" style="background:none" :bordered="false">
|
|
3
|
+
<LazyDashboardGrid v-model="database" />
|
|
4
|
+
</NCard>
|
|
5
|
+
</template>
|
|
6
|
+
|
|
7
|
+
<script setup lang="ts">
|
|
8
|
+
definePageMeta({
|
|
9
|
+
layout: "table",
|
|
10
|
+
middleware: ["database", "user", "dashboard", "global"],
|
|
11
|
+
})
|
|
12
|
+
|
|
13
|
+
const database = useState<Database>("database")
|
|
14
|
+
useHead({
|
|
15
|
+
title: `${t(database.value.slug)} | ${t("dashboards")}`,
|
|
16
|
+
link: [
|
|
17
|
+
{ rel: "icon", href: database.value?.icon?.publicURL ?? "/favicon.ico" },
|
|
18
|
+
],
|
|
19
|
+
})
|
|
20
|
+
</script>
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<NFlex style="width: 100%;" vertical :size="24">
|
|
3
|
+
<NCard :title="t('tables')" style="background:none" :bordered="false">
|
|
4
|
+
<LazyTableGrid v-model="database" />
|
|
5
|
+
</NCard>
|
|
6
|
+
<NCard v-if="user?.role === config.public.idOne" :title="t('dashboards')" style="background:none" :bordered="false">
|
|
7
|
+
<LazyDashboardGrid v-model="database" />
|
|
8
|
+
</NCard>
|
|
9
|
+
</NFlex>
|
|
10
|
+
</template>
|
|
11
|
+
|
|
12
|
+
<script setup lang="ts">
|
|
13
|
+
definePageMeta({
|
|
14
|
+
layout: "dashboard",
|
|
15
|
+
middleware: ["database", "user", "dashboard", "global"],
|
|
16
|
+
})
|
|
17
|
+
|
|
18
|
+
const database = useState<Database>("database")
|
|
19
|
+
const user = useState<User>("user");
|
|
20
|
+
const config = useRuntimeConfig();
|
|
21
|
+
|
|
22
|
+
useHead({
|
|
23
|
+
title: `${t(database.value.slug)} | ${t("dashboard")}`,
|
|
24
|
+
link: [
|
|
25
|
+
{ rel: "icon", href: database.value?.icon?.publicURL ?? "/favicon.ico" },
|
|
26
|
+
],
|
|
27
|
+
})
|
|
28
|
+
</script>
|
|
@@ -0,0 +1,526 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<NGrid x-gap="12" cols="12" layout-shift-disabled>
|
|
3
|
+
<NGridItem :span="!$device.isMobile ? 10 : 12">
|
|
4
|
+
<NCard
|
|
5
|
+
:title="t('settings')" style="background-color: transparent;"
|
|
6
|
+
:header-style="{ paddingRight: 0, paddingLeft: 0 }" content-style="padding: 0" :bordered="false" embedded>
|
|
7
|
+
<template #header-extra>
|
|
8
|
+
<NFlex>
|
|
9
|
+
<NTooltip :delay="1500">
|
|
10
|
+
<template #trigger>
|
|
11
|
+
<NPopconfirm :show-icon="false" @positive-click="deleteDatabase">
|
|
12
|
+
<template #trigger>
|
|
13
|
+
<NButton type="error" tertiary round :loading="Loading.deleteDatabase">
|
|
14
|
+
<template #icon>
|
|
15
|
+
<NIcon>
|
|
16
|
+
<Icon name="tabler:trash" />
|
|
17
|
+
</NIcon>
|
|
18
|
+
</template>
|
|
19
|
+
</NButton>
|
|
20
|
+
</template>
|
|
21
|
+
{{ t("theFollowingActionIsIrreversible") }}
|
|
22
|
+
</NPopconfirm>
|
|
23
|
+
</template>
|
|
24
|
+
{{ t("deleteDatabase") }}
|
|
25
|
+
</NTooltip>
|
|
26
|
+
<NButton @click="() => updateDatabase()" type="primary" secondary round
|
|
27
|
+
:loading="Loading.updateDatabase">
|
|
28
|
+
<template #icon>
|
|
29
|
+
<NIcon>
|
|
30
|
+
<Icon name="tabler:device-floppy" />
|
|
31
|
+
</NIcon>
|
|
32
|
+
</template>
|
|
33
|
+
{{ t("save") }}
|
|
34
|
+
</NButton>
|
|
35
|
+
</NFlex>
|
|
36
|
+
</template>
|
|
37
|
+
<NCard v-show="$device.isMobile || activeSection === 'general'" id="general" :title="t('generalSettings')" hoverable>
|
|
38
|
+
<NForm ref="generalRef" :model="databaseCopy">
|
|
39
|
+
<FieldS v-model="databaseCopy" :schema="databaseSchema" />
|
|
40
|
+
</NForm>
|
|
41
|
+
</NCard>
|
|
42
|
+
<NCard v-show="$device.isMobile || activeSection === 'translation'" id="translation" :title="t('translationSettings')" hoverable>
|
|
43
|
+
<NForm ref="translationRef" :model="databaseCopy">
|
|
44
|
+
<FieldS v-model="databaseCopy" :schema="translationSchema" />
|
|
45
|
+
</NForm>
|
|
46
|
+
</NCard>
|
|
47
|
+
<NCard v-if="canExportDatabase" v-show="$device.isMobile || activeSection === 'database-export'"
|
|
48
|
+
id="database-export" :title="t('databaseExport')" hoverable>
|
|
49
|
+
<template #header-extra>
|
|
50
|
+
<NButton v-if="exportStatus?.state === 'completed'" type="primary" secondary
|
|
51
|
+
:loading="Loading.downloadDatabaseExport" @click="downloadDatabaseExport">
|
|
52
|
+
<template #icon><NIcon><Icon name="tabler:download" /></NIcon></template>
|
|
53
|
+
{{ t("download") }}
|
|
54
|
+
</NButton>
|
|
55
|
+
<NButton v-else type="primary" secondary :disabled="exportIsActive"
|
|
56
|
+
:loading="Loading.databaseExport" @click="startDatabaseExport">
|
|
57
|
+
<template #icon><NIcon><Icon name="tabler:database-export" /></NIcon></template>
|
|
58
|
+
{{ t("startDatabaseExport") }}
|
|
59
|
+
</NButton>
|
|
60
|
+
</template>
|
|
61
|
+
<NFlex vertical>
|
|
62
|
+
<NText depth="3">{{ t("databaseExportDescription") }}</NText>
|
|
63
|
+
<NProgress v-if="exportIsActive" type="line" :percentage="exportStatus?.progress ?? 0"
|
|
64
|
+
indicator-placement="inside" processing />
|
|
65
|
+
<NText v-if="exportStatus" depth="3">
|
|
66
|
+
{{ t(`databaseExportState.${exportStatus.state}`) }}
|
|
67
|
+
<template v-if="exportStatus.totalBytes">
|
|
68
|
+
· {{ formatBytes(exportStatus.processedBytes) }} / {{ formatBytes(exportStatus.totalBytes) }}
|
|
69
|
+
</template>
|
|
70
|
+
</NText>
|
|
71
|
+
<NText v-if="exportStatus?.state === 'completed'" depth="3">
|
|
72
|
+
{{ t("databaseExportExpires", { date: new Date(exportStatus.expiresAt).toLocaleString() }) }}
|
|
73
|
+
</NText>
|
|
74
|
+
<NText v-if="exportStatus?.state === 'failed'" type="error">
|
|
75
|
+
{{ exportStatus.error || t("databaseExportFailed") }}
|
|
76
|
+
</NText>
|
|
77
|
+
</NFlex>
|
|
78
|
+
</NCard>
|
|
79
|
+
<NCard v-show="$device.isMobile || activeSection === 'email'" id="email" :title="t('emailSettings')" hoverable>
|
|
80
|
+
<NFlex align="center" :wrap="false" style="margin-bottom: 12px;">
|
|
81
|
+
<NSwitch v-model:value="useCustomSmtp" />
|
|
82
|
+
<span>{{ t("emailConfig.use_custom_smtp") }}</span>
|
|
83
|
+
</NFlex>
|
|
84
|
+
<NForm ref="emailRef" :model="emailForm">
|
|
85
|
+
<FieldS :key="emailFormKey" v-model="emailForm" :schema="emailSchema" />
|
|
86
|
+
</NForm>
|
|
87
|
+
<n-divider />
|
|
88
|
+
<NFlex align="center" justify="end">
|
|
89
|
+
<NInput v-model:value="testRecipient" :placeholder="t('testEmailRecipient')"
|
|
90
|
+
clearable style="max-width: 360px" />
|
|
91
|
+
<NButton type="primary" secondary :disabled="!isEmail(testRecipient)"
|
|
92
|
+
:loading="Loading.testEmail" @click="sendTestEmail">
|
|
93
|
+
<template #icon>
|
|
94
|
+
<NIcon><Icon name="tabler:send" /></NIcon>
|
|
95
|
+
</template>
|
|
96
|
+
{{ t("sendTestEmail") }}
|
|
97
|
+
</NButton>
|
|
98
|
+
</NFlex>
|
|
99
|
+
</NCard>
|
|
100
|
+
</NCard>
|
|
101
|
+
</NGridItem>
|
|
102
|
+
<NGridItem v-if="!$device.isMobile" span="2" style="padding-top: 58px;">
|
|
103
|
+
<div class="settings-tabs-affix">
|
|
104
|
+
<NTabs v-model:value="activeSection" type="line" :placement="isRTL ? 'left' : 'right'"
|
|
105
|
+
@update:value="changeSection">
|
|
106
|
+
<NTab name="general">{{ t('generalSettings') }}</NTab>
|
|
107
|
+
<NTab name="translation">{{ t('translationSettings') }}</NTab>
|
|
108
|
+
<NTab v-if="canExportDatabase" name="database-export">
|
|
109
|
+
{{ t('databaseExport') }}
|
|
110
|
+
</NTab>
|
|
111
|
+
<NTab name="email">{{ t('emailSettings') }}</NTab>
|
|
112
|
+
</NTabs>
|
|
113
|
+
</div>
|
|
114
|
+
</NGridItem>
|
|
115
|
+
</NGrid>
|
|
116
|
+
</template>
|
|
117
|
+
|
|
118
|
+
<script lang="ts" setup>
|
|
119
|
+
import { isEmail } from "inibase/utils";
|
|
120
|
+
import type { FormInst } from "naive-ui";
|
|
121
|
+
|
|
122
|
+
definePageMeta({
|
|
123
|
+
middleware: ["database", "user", "dashboard", "global"],
|
|
124
|
+
layout: "table",
|
|
125
|
+
});
|
|
126
|
+
|
|
127
|
+
onMounted(() => {
|
|
128
|
+
document.onkeydown = (e) => {
|
|
129
|
+
if (
|
|
130
|
+
!(
|
|
131
|
+
(e.ctrlKey || e.metaKey) &&
|
|
132
|
+
(e.key.toLowerCase() === "s" || e.key === "س")
|
|
133
|
+
)
|
|
134
|
+
)
|
|
135
|
+
return;
|
|
136
|
+
e.preventDefault();
|
|
137
|
+
updateDatabase();
|
|
138
|
+
};
|
|
139
|
+
});
|
|
140
|
+
|
|
141
|
+
const config = useRuntimeConfig();
|
|
142
|
+
const Loading = useState<Record<string, boolean>>("Loading", () => ({}));
|
|
143
|
+
const route = useRoute();
|
|
144
|
+
const router = useRouter();
|
|
145
|
+
const database = useState<Database>("database");
|
|
146
|
+
const user = useState<User>("user");
|
|
147
|
+
const Language = useScopedCookie<LanguagesType>("language", database.value?.slug);
|
|
148
|
+
const isRTL = computed(() => Language.value === "ar");
|
|
149
|
+
const generalRef = ref<FormInst>();
|
|
150
|
+
const translationRef = ref<FormInst>();
|
|
151
|
+
const emailRef = ref<FormInst>();
|
|
152
|
+
type SettingsSection = "general" | "translation" | "database-export" | "email";
|
|
153
|
+
const activeSection = ref<SettingsSection>("general");
|
|
154
|
+
const databaseCopy = ref<Database>(JSON.parse(JSON.stringify(database.value)));
|
|
155
|
+
databaseCopy.value.email ??= {};
|
|
156
|
+
const emailForm = ref<NonNullable<Database["email"]>>({
|
|
157
|
+
...databaseCopy.value.email,
|
|
158
|
+
smtp_port: databaseCopy.value.email.smtp_port ?? 587,
|
|
159
|
+
smtp_secure: databaseCopy.value.email.smtp_secure ?? false,
|
|
160
|
+
smtp_pass: "",
|
|
161
|
+
});
|
|
162
|
+
// UI-only toggle — not persisted, derived from/collapsed into smtp_host presence
|
|
163
|
+
const useCustomSmtp = ref(!!databaseCopy.value.email.smtp_host);
|
|
164
|
+
const emailFormKey = ref(0);
|
|
165
|
+
const testRecipient = ref(
|
|
166
|
+
user.value?.email ?? databaseCopy.value.email.from_email ?? "",
|
|
167
|
+
);
|
|
168
|
+
const exportStatus = ref<DatabaseExportStatus>();
|
|
169
|
+
let exportPollTimer: ReturnType<typeof setTimeout> | undefined;
|
|
170
|
+
const canExportDatabase = computed(
|
|
171
|
+
() => user.value?.role === config.public.idOne,
|
|
172
|
+
);
|
|
173
|
+
const exportIsActive = computed(() =>
|
|
174
|
+
["queued", "running"].includes(exportStatus.value?.state ?? ""),
|
|
175
|
+
);
|
|
176
|
+
|
|
177
|
+
function sectionFromHash(hash: string): SettingsSection | undefined {
|
|
178
|
+
const section = hash.replace(/^#/, "") as SettingsSection;
|
|
179
|
+
if (
|
|
180
|
+
["general", "translation", "database-export", "email"].includes(section) &&
|
|
181
|
+
(section !== "database-export" || canExportDatabase.value)
|
|
182
|
+
)
|
|
183
|
+
return section;
|
|
184
|
+
}
|
|
185
|
+
|
|
186
|
+
watch(
|
|
187
|
+
() => route.hash,
|
|
188
|
+
(hash) => {
|
|
189
|
+
const section = sectionFromHash(hash);
|
|
190
|
+
if (section) activeSection.value = section;
|
|
191
|
+
},
|
|
192
|
+
{ immediate: true },
|
|
193
|
+
);
|
|
194
|
+
|
|
195
|
+
function changeSection(value: string | number) {
|
|
196
|
+
const section = value as SettingsSection;
|
|
197
|
+
if (section === "database-export" && !canExportDatabase.value) return;
|
|
198
|
+
activeSection.value = section;
|
|
199
|
+
if (route.hash !== `#${section}`) router.replace({ hash: `#${section}` });
|
|
200
|
+
}
|
|
201
|
+
|
|
202
|
+
const databaseSchema: Schema = [
|
|
203
|
+
{
|
|
204
|
+
key: "slug",
|
|
205
|
+
type: "string",
|
|
206
|
+
required: true,
|
|
207
|
+
},
|
|
208
|
+
{
|
|
209
|
+
key: "icon",
|
|
210
|
+
type: "table",
|
|
211
|
+
table: "assets",
|
|
212
|
+
accept: ["image"],
|
|
213
|
+
suffix: "?format=avif&fit=94",
|
|
214
|
+
},
|
|
215
|
+
{
|
|
216
|
+
key: "primaryColor",
|
|
217
|
+
type: "string",
|
|
218
|
+
subType: "color",
|
|
219
|
+
},
|
|
220
|
+
{
|
|
221
|
+
key: "primaryDarkColor",
|
|
222
|
+
type: "string",
|
|
223
|
+
subType: "color",
|
|
224
|
+
},
|
|
225
|
+
{
|
|
226
|
+
key: "roles",
|
|
227
|
+
type: "array",
|
|
228
|
+
children: [
|
|
229
|
+
{
|
|
230
|
+
key: "id",
|
|
231
|
+
type: "id",
|
|
232
|
+
inputProps: {
|
|
233
|
+
disabled: true,
|
|
234
|
+
},
|
|
235
|
+
},
|
|
236
|
+
{
|
|
237
|
+
key: "name",
|
|
238
|
+
type: "string",
|
|
239
|
+
},
|
|
240
|
+
],
|
|
241
|
+
onCreate: () => ({ id: `temp-${randomID()}` }),
|
|
242
|
+
inputProps: (index: number) =>
|
|
243
|
+
[0, 1, 2].includes(index) ? { disabled: true } : {},
|
|
244
|
+
required: false,
|
|
245
|
+
},
|
|
246
|
+
];
|
|
247
|
+
|
|
248
|
+
const translationSchema = computed<Schema>(() => [
|
|
249
|
+
{
|
|
250
|
+
key: "primaryLanguage",
|
|
251
|
+
type: "string",
|
|
252
|
+
subType: "locale",
|
|
253
|
+
required: true,
|
|
254
|
+
width: 2,
|
|
255
|
+
},
|
|
256
|
+
{
|
|
257
|
+
key: "secondaryLanguages",
|
|
258
|
+
type: "array",
|
|
259
|
+
children: "string",
|
|
260
|
+
subType: "select",
|
|
261
|
+
options: translationLanguages
|
|
262
|
+
.filter((l) => l !== databaseCopy.value.primaryLanguage)
|
|
263
|
+
.map((l) => ({ label: t(`languages.${l}`), value: l })),
|
|
264
|
+
width: 2,
|
|
265
|
+
},
|
|
266
|
+
]);
|
|
267
|
+
|
|
268
|
+
const emailSchema = computed<Schema>(() => [
|
|
269
|
+
{
|
|
270
|
+
key: "from_email",
|
|
271
|
+
type: "email",
|
|
272
|
+
label: t("emailConfig.from_email"),
|
|
273
|
+
width: 2,
|
|
274
|
+
inputProps: { placeholder: t("emailConfig.from_email") },
|
|
275
|
+
},
|
|
276
|
+
{
|
|
277
|
+
key: "from_name",
|
|
278
|
+
type: "string",
|
|
279
|
+
label: t("emailConfig.from_name"),
|
|
280
|
+
width: 2,
|
|
281
|
+
inputProps: { placeholder: t("emailConfig.from_name") },
|
|
282
|
+
},
|
|
283
|
+
...(useCustomSmtp.value
|
|
284
|
+
? ([
|
|
285
|
+
{
|
|
286
|
+
key: "smtp_host",
|
|
287
|
+
type: "string",
|
|
288
|
+
label: t("emailConfig.smtp_host"),
|
|
289
|
+
width: 2,
|
|
290
|
+
required: true,
|
|
291
|
+
inputProps: { placeholder: t("emailConfig.smtp_host") },
|
|
292
|
+
},
|
|
293
|
+
{
|
|
294
|
+
key: "smtp_port",
|
|
295
|
+
type: "number",
|
|
296
|
+
label: t("emailConfig.smtp_port"),
|
|
297
|
+
width: 2,
|
|
298
|
+
inputProps: { min: 1, max: 65535 },
|
|
299
|
+
},
|
|
300
|
+
{
|
|
301
|
+
key: "smtp_user",
|
|
302
|
+
type: "string",
|
|
303
|
+
label: t("emailConfig.smtp_user"),
|
|
304
|
+
width: 2,
|
|
305
|
+
inputProps: { placeholder: t("emailConfig.smtp_user") },
|
|
306
|
+
},
|
|
307
|
+
{
|
|
308
|
+
key: "smtp_pass",
|
|
309
|
+
type: "password",
|
|
310
|
+
label: t("emailConfig.smtp_pass"),
|
|
311
|
+
width: 2,
|
|
312
|
+
inputProps: { placeholder: t("smtpPasswordUnchanged") },
|
|
313
|
+
},
|
|
314
|
+
{
|
|
315
|
+
key: "smtp_secure",
|
|
316
|
+
type: "boolean",
|
|
317
|
+
label: t("emailConfig.smtp_secure"),
|
|
318
|
+
},
|
|
319
|
+
] as Schema)
|
|
320
|
+
: []),
|
|
321
|
+
]);
|
|
322
|
+
|
|
323
|
+
const sessionID = useScopedCookie<string>("sid", database.value?.slug);
|
|
324
|
+
|
|
325
|
+
function exportRequestOptions() {
|
|
326
|
+
return {
|
|
327
|
+
credentials: "include" as const,
|
|
328
|
+
query: {
|
|
329
|
+
[`${database.value.slug}_sid`]: sessionID.value,
|
|
330
|
+
_t: Date.now(),
|
|
331
|
+
},
|
|
332
|
+
};
|
|
333
|
+
}
|
|
334
|
+
|
|
335
|
+
function formatBytes(bytes: number) {
|
|
336
|
+
if (!bytes) return "0 B";
|
|
337
|
+
const units = ["B", "KB", "MB", "GB", "TB"];
|
|
338
|
+
const index = Math.min(
|
|
339
|
+
Math.floor(Math.log(bytes) / Math.log(1024)),
|
|
340
|
+
units.length - 1,
|
|
341
|
+
);
|
|
342
|
+
return `${(bytes / 1024 ** index).toFixed(index ? 1 : 0)} ${units[index]}`;
|
|
343
|
+
}
|
|
344
|
+
|
|
345
|
+
function scheduleExportPoll() {
|
|
346
|
+
if (exportPollTimer) clearTimeout(exportPollTimer);
|
|
347
|
+
if (!exportIsActive.value) return;
|
|
348
|
+
exportPollTimer = setTimeout(async () => {
|
|
349
|
+
await loadDatabaseExportStatus();
|
|
350
|
+
scheduleExportPoll();
|
|
351
|
+
}, 1500);
|
|
352
|
+
}
|
|
353
|
+
|
|
354
|
+
async function loadDatabaseExportStatus() {
|
|
355
|
+
if (!canExportDatabase.value) return;
|
|
356
|
+
try {
|
|
357
|
+
const response = await $fetch<apiResponse<DatabaseExportStatus | null>>(
|
|
358
|
+
`${config.public.apiBase}inicontent/databases/${database.value.slug}/export`,
|
|
359
|
+
exportRequestOptions(),
|
|
360
|
+
);
|
|
361
|
+
exportStatus.value = response.result ?? undefined;
|
|
362
|
+
} catch {
|
|
363
|
+
exportStatus.value = undefined;
|
|
364
|
+
}
|
|
365
|
+
}
|
|
366
|
+
|
|
367
|
+
async function startDatabaseExport() {
|
|
368
|
+
Loading.value.databaseExport = true;
|
|
369
|
+
try {
|
|
370
|
+
const response = await $fetch<apiResponse<DatabaseExportStatus>>(
|
|
371
|
+
`${config.public.apiBase}inicontent/databases/${database.value.slug}/export`,
|
|
372
|
+
{ ...exportRequestOptions(), method: "POST" },
|
|
373
|
+
);
|
|
374
|
+
if (!response.result) throw new Error(response.message);
|
|
375
|
+
exportStatus.value = response.result;
|
|
376
|
+
scheduleExportPoll();
|
|
377
|
+
} catch (error: unknown) {
|
|
378
|
+
const message = error as { data?: { message?: string }; message?: string };
|
|
379
|
+
window.$message.error(
|
|
380
|
+
message.data?.message || message.message || t("databaseExportFailed"),
|
|
381
|
+
);
|
|
382
|
+
} finally {
|
|
383
|
+
Loading.value.databaseExport = false;
|
|
384
|
+
}
|
|
385
|
+
}
|
|
386
|
+
|
|
387
|
+
async function downloadDatabaseExport() {
|
|
388
|
+
Loading.value.downloadDatabaseExport = true;
|
|
389
|
+
try {
|
|
390
|
+
const response = await $fetch<apiResponse<{ url: string }>>(
|
|
391
|
+
`${config.public.apiBase}inicontent/databases/${database.value.slug}/export/download`,
|
|
392
|
+
exportRequestOptions(),
|
|
393
|
+
);
|
|
394
|
+
if (!response.result?.url) throw new Error(response.message);
|
|
395
|
+
window.location.assign(response.result.url);
|
|
396
|
+
} catch (error: unknown) {
|
|
397
|
+
const message = error as { data?: { message?: string }; message?: string };
|
|
398
|
+
window.$message.error(
|
|
399
|
+
message.data?.message || message.message || t("databaseExportFailed"),
|
|
400
|
+
);
|
|
401
|
+
} finally {
|
|
402
|
+
Loading.value.downloadDatabaseExport = false;
|
|
403
|
+
}
|
|
404
|
+
}
|
|
405
|
+
|
|
406
|
+
onMounted(async () => {
|
|
407
|
+
await loadDatabaseExportStatus();
|
|
408
|
+
scheduleExportPoll();
|
|
409
|
+
});
|
|
410
|
+
onBeforeUnmount(() => {
|
|
411
|
+
if (exportPollTimer) clearTimeout(exportPollTimer);
|
|
412
|
+
});
|
|
413
|
+
|
|
414
|
+
async function updateDatabase(showSuccess = true) {
|
|
415
|
+
try {
|
|
416
|
+
await Promise.all([
|
|
417
|
+
generalRef.value?.validate(),
|
|
418
|
+
translationRef.value?.validate(),
|
|
419
|
+
emailRef.value?.validate(),
|
|
420
|
+
]);
|
|
421
|
+
} catch {
|
|
422
|
+
window.$message.error(t("inputsAreInvalid"));
|
|
423
|
+
return false;
|
|
424
|
+
}
|
|
425
|
+
|
|
426
|
+
const bodyContent = JSON.parse(
|
|
427
|
+
JSON.stringify(databaseCopy.value),
|
|
428
|
+
) as Database;
|
|
429
|
+
bodyContent.email = JSON.parse(JSON.stringify(emailForm.value));
|
|
430
|
+
// Toggling off custom SMTP clears smtp_host so the API falls back to the default Inicontent SMTP
|
|
431
|
+
if (!useCustomSmtp.value && bodyContent.email) {
|
|
432
|
+
bodyContent.email.smtp_host = "";
|
|
433
|
+
bodyContent.email.smtp_user = "";
|
|
434
|
+
bodyContent.email.smtp_pass = "";
|
|
435
|
+
bodyContent.email.smtp_secure = false;
|
|
436
|
+
}
|
|
437
|
+
if (!bodyContent.email?.smtp_pass) delete bodyContent.email?.smtp_pass;
|
|
438
|
+
|
|
439
|
+
Loading.value.updateDatabase = true;
|
|
440
|
+
try {
|
|
441
|
+
const data = await $fetch<apiResponse<Database>>(
|
|
442
|
+
`${config.public.apiBase}inicontent/databases/${database.value.slug}`,
|
|
443
|
+
{
|
|
444
|
+
method: "PUT",
|
|
445
|
+
body: bodyContent,
|
|
446
|
+
credentials: "include",
|
|
447
|
+
query: {
|
|
448
|
+
[`${database.value.slug}_sid`]: sessionID.value,
|
|
449
|
+
},
|
|
450
|
+
},
|
|
451
|
+
);
|
|
452
|
+
if (!data.result) {
|
|
453
|
+
window.$message.error(data.message);
|
|
454
|
+
return false;
|
|
455
|
+
}
|
|
456
|
+
|
|
457
|
+
database.value = { ...database.value, ...data.result };
|
|
458
|
+
emailForm.value.smtp_pass = "";
|
|
459
|
+
emailFormKey.value++;
|
|
460
|
+
if (route.params.database !== database.value.slug)
|
|
461
|
+
await router.replace({ params: { database: database.value.slug } });
|
|
462
|
+
setThemeConfig();
|
|
463
|
+
if (showSuccess) window.$message.success(data.message);
|
|
464
|
+
return true;
|
|
465
|
+
} catch (error: unknown) {
|
|
466
|
+
const message = (error as { data?: { message?: string } })?.data?.message;
|
|
467
|
+
window.$message.error(message ?? t("error"));
|
|
468
|
+
return false;
|
|
469
|
+
} finally {
|
|
470
|
+
Loading.value.updateDatabase = false;
|
|
471
|
+
}
|
|
472
|
+
}
|
|
473
|
+
|
|
474
|
+
async function sendTestEmail() {
|
|
475
|
+
if (!isEmail(testRecipient.value) || !(await updateDatabase(false))) return;
|
|
476
|
+
|
|
477
|
+
Loading.value.testEmail = true;
|
|
478
|
+
try {
|
|
479
|
+
const data = await $fetch<apiResponse<boolean>>(
|
|
480
|
+
`${config.public.apiBase}inicontent/databases/${database.value.slug}/email/test`,
|
|
481
|
+
{
|
|
482
|
+
method: "POST",
|
|
483
|
+
body: { email: testRecipient.value },
|
|
484
|
+
credentials: "include",
|
|
485
|
+
query: { [`${database.value.slug}_sid`]: sessionID.value },
|
|
486
|
+
},
|
|
487
|
+
);
|
|
488
|
+
if (data.result) window.$message.success(data.message);
|
|
489
|
+
else window.$message.error(data.message);
|
|
490
|
+
} catch (error: unknown) {
|
|
491
|
+
const message = (error as { data?: { message?: string } })?.data?.message;
|
|
492
|
+
window.$message.error(message ?? t("emailSendFailed"));
|
|
493
|
+
} finally {
|
|
494
|
+
Loading.value.testEmail = false;
|
|
495
|
+
}
|
|
496
|
+
}
|
|
497
|
+
async function deleteDatabase() {
|
|
498
|
+
Loading.value.deleteDatabase = true;
|
|
499
|
+
const data = await $fetch<apiResponse>(
|
|
500
|
+
`${config.public.apiBase}inicontent/databases/${database.value.slug}`,
|
|
501
|
+
{
|
|
502
|
+
method: "DELETE",
|
|
503
|
+
credentials: "include",
|
|
504
|
+
query: {
|
|
505
|
+
[`${database.value.slug}_sid`]: sessionID.value,
|
|
506
|
+
},
|
|
507
|
+
},
|
|
508
|
+
);
|
|
509
|
+
if (data.result) {
|
|
510
|
+
Loading.value.deleteDatabase = false;
|
|
511
|
+
window.$message.success(data.message);
|
|
512
|
+
setTimeout(async () => {
|
|
513
|
+
clearNuxtState("database");
|
|
514
|
+
await navigateTo("/admin");
|
|
515
|
+
}, 800);
|
|
516
|
+
} else window.$message.error(data.message);
|
|
517
|
+
Loading.value.deleteDatabase = false;
|
|
518
|
+
}
|
|
519
|
+
|
|
520
|
+
useHead({
|
|
521
|
+
title: `${t(database.value.slug)} | ${t("settings")}`,
|
|
522
|
+
link: [
|
|
523
|
+
{ rel: "icon", href: database.value?.icon?.publicURL ?? "/favicon.ico" },
|
|
524
|
+
],
|
|
525
|
+
});
|
|
526
|
+
</script>
|