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,73 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<NSpin :show="loading">
|
|
3
|
+
<div style="height: 250px">
|
|
4
|
+
<VChart v-if="groups.length" :option="chartOption" autoresize />
|
|
5
|
+
<NEmpty v-else :description="t('noData')" />
|
|
6
|
+
</div>
|
|
7
|
+
</NSpin>
|
|
8
|
+
</template>
|
|
9
|
+
|
|
10
|
+
<script lang="ts" setup>
|
|
11
|
+
import { useDashboardData } from "~/composables/useDashboardData";
|
|
12
|
+
import { VChart } from "~/composables/useEcharts";
|
|
13
|
+
|
|
14
|
+
const props = defineProps<{
|
|
15
|
+
widget: Widget;
|
|
16
|
+
databaseSlug: string;
|
|
17
|
+
dateRangeOverride?: WidgetDateRange;
|
|
18
|
+
}>();
|
|
19
|
+
|
|
20
|
+
const dateRangeRef = toRef(props, "dateRangeOverride");
|
|
21
|
+
|
|
22
|
+
const { groups, loading, refresh } = useDashboardData(
|
|
23
|
+
props.widget,
|
|
24
|
+
props.databaseSlug,
|
|
25
|
+
dateRangeRef,
|
|
26
|
+
);
|
|
27
|
+
|
|
28
|
+
const Theme = useCookie<"light" | "dark">("theme", { sameSite: true });
|
|
29
|
+
|
|
30
|
+
const chartOption = computed(() => ({
|
|
31
|
+
tooltip: {
|
|
32
|
+
trigger: "axis",
|
|
33
|
+
axisPointer: { type: "shadow" },
|
|
34
|
+
},
|
|
35
|
+
grid: {
|
|
36
|
+
left: "3%",
|
|
37
|
+
right: "4%",
|
|
38
|
+
bottom: "3%",
|
|
39
|
+
containLabel: true,
|
|
40
|
+
},
|
|
41
|
+
xAxis: {
|
|
42
|
+
type: "category",
|
|
43
|
+
data: groups.value.map((g) => g.name),
|
|
44
|
+
axisLabel: {
|
|
45
|
+
color: Theme.value === "dark" ? "#aaa" : "#666",
|
|
46
|
+
rotate: groups.value.length > 6 ? 30 : 0,
|
|
47
|
+
},
|
|
48
|
+
},
|
|
49
|
+
yAxis: {
|
|
50
|
+
type: "value",
|
|
51
|
+
axisLabel: {
|
|
52
|
+
color: Theme.value === "dark" ? "#aaa" : "#666",
|
|
53
|
+
},
|
|
54
|
+
splitLine: {
|
|
55
|
+
lineStyle: {
|
|
56
|
+
color: Theme.value === "dark" ? "#333" : "#eee",
|
|
57
|
+
},
|
|
58
|
+
},
|
|
59
|
+
},
|
|
60
|
+
series: [
|
|
61
|
+
{
|
|
62
|
+
type: "bar",
|
|
63
|
+
itemStyle: {
|
|
64
|
+
color: props.widget.color || "#2080f0",
|
|
65
|
+
borderRadius: [4, 4, 0, 0],
|
|
66
|
+
},
|
|
67
|
+
data: groups.value.map((g) => g.value),
|
|
68
|
+
},
|
|
69
|
+
],
|
|
70
|
+
}));
|
|
71
|
+
|
|
72
|
+
onMounted(refresh);
|
|
73
|
+
</script>
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<NSpin :show="loading">
|
|
3
|
+
<NTooltip :delay="1500">
|
|
4
|
+
<template #trigger>
|
|
5
|
+
<NStatistic :value="displayValue">
|
|
6
|
+
<template #prefix>
|
|
7
|
+
<NIcon size="20" v-if="widget.icon">
|
|
8
|
+
<Icon :name="widget.icon" />
|
|
9
|
+
</NIcon>
|
|
10
|
+
</template>
|
|
11
|
+
<template #suffix>
|
|
12
|
+
<NText v-if="widget.operation && widget.operation !== 'count'" depth="3" style="font-size: 14px">
|
|
13
|
+
({{ t(widget.operation) }})
|
|
14
|
+
</NText>
|
|
15
|
+
</template>
|
|
16
|
+
<template v-if="widget.color" #default>
|
|
17
|
+
<span :style="{ color: widget.color, fontSize: '24px', fontWeight: 500 }">
|
|
18
|
+
{{ displayValue }}
|
|
19
|
+
</span>
|
|
20
|
+
</template>
|
|
21
|
+
</NStatistic>
|
|
22
|
+
</template>
|
|
23
|
+
{{ widget.table }}
|
|
24
|
+
</NTooltip>
|
|
25
|
+
</NSpin>
|
|
26
|
+
</template>
|
|
27
|
+
|
|
28
|
+
<script lang="ts" setup>
|
|
29
|
+
import { useDashboardData } from "~/composables/useDashboardData";
|
|
30
|
+
|
|
31
|
+
const props = defineProps<{
|
|
32
|
+
widget: Widget;
|
|
33
|
+
databaseSlug: string;
|
|
34
|
+
dateRangeOverride?: WidgetDateRange;
|
|
35
|
+
}>();
|
|
36
|
+
|
|
37
|
+
const dateRangeRef = toRef(props, "dateRangeOverride");
|
|
38
|
+
|
|
39
|
+
const { value, loading, refresh } = useDashboardData(
|
|
40
|
+
props.widget,
|
|
41
|
+
props.databaseSlug,
|
|
42
|
+
dateRangeRef,
|
|
43
|
+
);
|
|
44
|
+
|
|
45
|
+
const displayValue = computed(() => {
|
|
46
|
+
if (value.value === null) return 0;
|
|
47
|
+
return value.value;
|
|
48
|
+
});
|
|
49
|
+
|
|
50
|
+
onMounted(refresh);
|
|
51
|
+
</script>
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<NSpin :show="loading">
|
|
3
|
+
<div style="height: 250px">
|
|
4
|
+
<VChart v-if="timeSeries.length" :option="chartOption" autoresize />
|
|
5
|
+
<NEmpty v-else :description="t('noData')" />
|
|
6
|
+
</div>
|
|
7
|
+
</NSpin>
|
|
8
|
+
</template>
|
|
9
|
+
|
|
10
|
+
<script lang="ts" setup>
|
|
11
|
+
import { useDashboardData } from "~/composables/useDashboardData";
|
|
12
|
+
import { VChart } from "~/composables/useEcharts";
|
|
13
|
+
|
|
14
|
+
const props = defineProps<{
|
|
15
|
+
widget: Widget;
|
|
16
|
+
databaseSlug: string;
|
|
17
|
+
dateRangeOverride?: WidgetDateRange;
|
|
18
|
+
}>();
|
|
19
|
+
|
|
20
|
+
const dateRangeRef = toRef(props, "dateRangeOverride");
|
|
21
|
+
|
|
22
|
+
const { timeSeries, loading, refresh } = useDashboardData(
|
|
23
|
+
props.widget,
|
|
24
|
+
props.databaseSlug,
|
|
25
|
+
dateRangeRef,
|
|
26
|
+
);
|
|
27
|
+
|
|
28
|
+
const Theme = useCookie<"light" | "dark">("theme", { sameSite: true });
|
|
29
|
+
|
|
30
|
+
const chartOption = computed(() => ({
|
|
31
|
+
tooltip: {
|
|
32
|
+
trigger: "axis",
|
|
33
|
+
},
|
|
34
|
+
grid: {
|
|
35
|
+
left: "3%",
|
|
36
|
+
right: "4%",
|
|
37
|
+
bottom: "3%",
|
|
38
|
+
containLabel: true,
|
|
39
|
+
},
|
|
40
|
+
xAxis: {
|
|
41
|
+
type: "category",
|
|
42
|
+
boundaryGap: false,
|
|
43
|
+
data: timeSeries.value.map((d) => d.date),
|
|
44
|
+
axisLabel: {
|
|
45
|
+
color: Theme.value === "dark" ? "#aaa" : "#666",
|
|
46
|
+
},
|
|
47
|
+
},
|
|
48
|
+
yAxis: {
|
|
49
|
+
type: "value",
|
|
50
|
+
axisLabel: {
|
|
51
|
+
color: Theme.value === "dark" ? "#aaa" : "#666",
|
|
52
|
+
},
|
|
53
|
+
splitLine: {
|
|
54
|
+
lineStyle: {
|
|
55
|
+
color: Theme.value === "dark" ? "#333" : "#eee",
|
|
56
|
+
},
|
|
57
|
+
},
|
|
58
|
+
},
|
|
59
|
+
series: [
|
|
60
|
+
{
|
|
61
|
+
name: props.widget.title,
|
|
62
|
+
type: "line",
|
|
63
|
+
smooth: true,
|
|
64
|
+
areaStyle: {
|
|
65
|
+
opacity: 0.3,
|
|
66
|
+
},
|
|
67
|
+
itemStyle: {
|
|
68
|
+
color: props.widget.color || "#18a058",
|
|
69
|
+
},
|
|
70
|
+
data: timeSeries.value.map((d) => d.value),
|
|
71
|
+
},
|
|
72
|
+
],
|
|
73
|
+
}));
|
|
74
|
+
|
|
75
|
+
onMounted(refresh);
|
|
76
|
+
</script>
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<NSpin :show="loading">
|
|
3
|
+
<div style="height: 250px">
|
|
4
|
+
<VChart v-if="groups.length" :option="chartOption" autoresize />
|
|
5
|
+
<NEmpty v-else :description="t('noData')" />
|
|
6
|
+
</div>
|
|
7
|
+
</NSpin>
|
|
8
|
+
</template>
|
|
9
|
+
|
|
10
|
+
<script lang="ts" setup>
|
|
11
|
+
import { useDashboardData } from "~/composables/useDashboardData";
|
|
12
|
+
import { VChart } from "~/composables/useEcharts";
|
|
13
|
+
|
|
14
|
+
const props = defineProps<{
|
|
15
|
+
widget: Widget;
|
|
16
|
+
databaseSlug: string;
|
|
17
|
+
dateRangeOverride?: WidgetDateRange;
|
|
18
|
+
}>();
|
|
19
|
+
|
|
20
|
+
const dateRangeRef = toRef(props, "dateRangeOverride");
|
|
21
|
+
|
|
22
|
+
const { groups, loading, refresh } = useDashboardData(
|
|
23
|
+
props.widget,
|
|
24
|
+
props.databaseSlug,
|
|
25
|
+
dateRangeRef,
|
|
26
|
+
);
|
|
27
|
+
|
|
28
|
+
const Theme = useCookie<"light" | "dark">("theme", { sameSite: true });
|
|
29
|
+
|
|
30
|
+
const chartOption = computed(() => ({
|
|
31
|
+
tooltip: {
|
|
32
|
+
trigger: "item",
|
|
33
|
+
formatter: "{b}: {c} ({d}%)",
|
|
34
|
+
},
|
|
35
|
+
legend: {
|
|
36
|
+
orient: "vertical",
|
|
37
|
+
right: 10,
|
|
38
|
+
top: "center",
|
|
39
|
+
textStyle: {
|
|
40
|
+
color: Theme.value === "dark" ? "#aaa" : "#666",
|
|
41
|
+
},
|
|
42
|
+
},
|
|
43
|
+
series: [
|
|
44
|
+
{
|
|
45
|
+
type: "pie",
|
|
46
|
+
radius: ["40%", "70%"],
|
|
47
|
+
avoidLabelOverlap: false,
|
|
48
|
+
itemStyle: {
|
|
49
|
+
borderRadius: 6,
|
|
50
|
+
borderColor: Theme.value === "dark" ? "#1e1e1e" : "#fff",
|
|
51
|
+
borderWidth: 2,
|
|
52
|
+
},
|
|
53
|
+
label: {
|
|
54
|
+
show: false,
|
|
55
|
+
},
|
|
56
|
+
emphasis: {
|
|
57
|
+
label: {
|
|
58
|
+
show: true,
|
|
59
|
+
fontSize: 14,
|
|
60
|
+
fontWeight: "bold",
|
|
61
|
+
},
|
|
62
|
+
},
|
|
63
|
+
data: groups.value.map((g, i) => ({
|
|
64
|
+
value: g.value,
|
|
65
|
+
name: g.name,
|
|
66
|
+
...(props.widget.color && i === 0
|
|
67
|
+
? { itemStyle: { color: props.widget.color } }
|
|
68
|
+
: {}),
|
|
69
|
+
})),
|
|
70
|
+
},
|
|
71
|
+
],
|
|
72
|
+
}));
|
|
73
|
+
|
|
74
|
+
onMounted(refresh);
|
|
75
|
+
</script>
|
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<NSpin :show="loading">
|
|
3
|
+
<NDataTable
|
|
4
|
+
size="small"
|
|
5
|
+
:bordered="false"
|
|
6
|
+
:columns="columns"
|
|
7
|
+
:data="data"
|
|
8
|
+
:loading="loading"
|
|
9
|
+
:scroll-x="tableWidth"
|
|
10
|
+
:max-height="480"
|
|
11
|
+
:row-key="(row: Item) => row.id"
|
|
12
|
+
/>
|
|
13
|
+
</NSpin>
|
|
14
|
+
</template>
|
|
15
|
+
|
|
16
|
+
<script lang="ts" setup>
|
|
17
|
+
import type { DataTableColumns } from "naive-ui";
|
|
18
|
+
import { h } from "vue";
|
|
19
|
+
import { LazyColumn, NFlex, NPerformantEllipsis } from "#components";
|
|
20
|
+
import { getField } from "~/composables/fieldsList";
|
|
21
|
+
import renderLabel from "~/composables/renderLabel";
|
|
22
|
+
import { useDashboardData } from "~/composables/useDashboardData";
|
|
23
|
+
|
|
24
|
+
const props = defineProps<{
|
|
25
|
+
widget: Widget;
|
|
26
|
+
databaseSlug: string;
|
|
27
|
+
dateRangeOverride?: WidgetDateRange;
|
|
28
|
+
}>();
|
|
29
|
+
|
|
30
|
+
const dateRangeRef = toRef(props, "dateRangeOverride");
|
|
31
|
+
|
|
32
|
+
const { data, loading, refresh } = useDashboardData(
|
|
33
|
+
props.widget,
|
|
34
|
+
props.databaseSlug,
|
|
35
|
+
dateRangeRef,
|
|
36
|
+
);
|
|
37
|
+
|
|
38
|
+
const database = useState<Database>("database");
|
|
39
|
+
|
|
40
|
+
const sourceTable = computed(() =>
|
|
41
|
+
database.value?.tables?.find((t) => t.slug === props.widget.table),
|
|
42
|
+
);
|
|
43
|
+
|
|
44
|
+
// Preferred columns: widget.columns (keys) → table.defaultTableColumns (ids)
|
|
45
|
+
// → first 8 schema fields.
|
|
46
|
+
const displayedFields = computed<Field[]>(() => {
|
|
47
|
+
const schema = sourceTable.value?.schema ?? [];
|
|
48
|
+
if (!schema.length) return [];
|
|
49
|
+
|
|
50
|
+
if (props.widget.columns?.length) {
|
|
51
|
+
const byKey = schema.filter((f) => props.widget.columns?.includes(f.key));
|
|
52
|
+
if (byKey.length) return byKey;
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
const defaultIds = sourceTable.value?.defaultTableColumns;
|
|
56
|
+
if (defaultIds?.length) {
|
|
57
|
+
const byId = defaultIds
|
|
58
|
+
.map((id) => schema.find((f) => f.id === id))
|
|
59
|
+
.filter((f): f is Field => !!f);
|
|
60
|
+
if (byId.length) return byId;
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
return schema.slice(0, 8);
|
|
64
|
+
});
|
|
65
|
+
|
|
66
|
+
const columns = computed<DataTableColumns>(() =>
|
|
67
|
+
displayedFields.value.map((field) => ({
|
|
68
|
+
title: () =>
|
|
69
|
+
h(NFlex, { wrap: false, align: "center", justify: "start" }, () => [
|
|
70
|
+
getField(field).icon(),
|
|
71
|
+
h(NPerformantEllipsis, () => t(field.key)),
|
|
72
|
+
]),
|
|
73
|
+
key: field.key,
|
|
74
|
+
minWidth: 150,
|
|
75
|
+
width: 150,
|
|
76
|
+
ellipsis: field.table !== undefined ? false : { tooltip: true },
|
|
77
|
+
render: (row: Item) =>
|
|
78
|
+
h(LazyColumn, {
|
|
79
|
+
field,
|
|
80
|
+
value: row[field.key],
|
|
81
|
+
itemLabel: renderLabel(sourceTable.value, row),
|
|
82
|
+
}),
|
|
83
|
+
})),
|
|
84
|
+
);
|
|
85
|
+
|
|
86
|
+
const tableWidth = computed(() =>
|
|
87
|
+
columns.value.reduce(
|
|
88
|
+
(acc, column) => acc + ((column.width as number) ?? 0),
|
|
89
|
+
100,
|
|
90
|
+
),
|
|
91
|
+
);
|
|
92
|
+
|
|
93
|
+
onMounted(refresh);
|
|
94
|
+
</script>
|
|
@@ -0,0 +1,274 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<NForm ref="formRef" :model="model" label-placement="left" label-width="120">
|
|
3
|
+
<NFormItem :label="t('widgetTitle')" path="title">
|
|
4
|
+
<NInput v-model:value="model.title" :placeholder="t('widgetTitle')" />
|
|
5
|
+
</NFormItem>
|
|
6
|
+
|
|
7
|
+
<NFormItem :label="t('type')" path="type">
|
|
8
|
+
<NSelect
|
|
9
|
+
v-model:value="model.type"
|
|
10
|
+
:options="typeOptions"
|
|
11
|
+
:placeholder="t('selectType')"
|
|
12
|
+
/>
|
|
13
|
+
</NFormItem>
|
|
14
|
+
|
|
15
|
+
<NFormItem :label="t('sourceTable')" path="table">
|
|
16
|
+
<NSelect
|
|
17
|
+
v-model:value="model.table"
|
|
18
|
+
:options="tableOptions"
|
|
19
|
+
:placeholder="t('selectTable')"
|
|
20
|
+
filterable
|
|
21
|
+
/>
|
|
22
|
+
</NFormItem>
|
|
23
|
+
|
|
24
|
+
<NFormItem
|
|
25
|
+
v-if="model.type === 'counter'"
|
|
26
|
+
:label="t('operation')"
|
|
27
|
+
path="operation"
|
|
28
|
+
>
|
|
29
|
+
<NSelect
|
|
30
|
+
v-model:value="model.operation"
|
|
31
|
+
:options="operationOptions"
|
|
32
|
+
:placeholder="t('operation')"
|
|
33
|
+
/>
|
|
34
|
+
</NFormItem>
|
|
35
|
+
|
|
36
|
+
<NFormItem
|
|
37
|
+
v-if="showFieldPicker"
|
|
38
|
+
:label="t('field')"
|
|
39
|
+
path="field"
|
|
40
|
+
>
|
|
41
|
+
<NSelect
|
|
42
|
+
v-model:value="model.field"
|
|
43
|
+
:options="fieldOptions"
|
|
44
|
+
:placeholder="t('selectField')"
|
|
45
|
+
filterable
|
|
46
|
+
clearable
|
|
47
|
+
/>
|
|
48
|
+
</NFormItem>
|
|
49
|
+
|
|
50
|
+
<NFormItem
|
|
51
|
+
v-if="model.type === 'bar' || model.type === 'pie'"
|
|
52
|
+
:label="t('groupBy')"
|
|
53
|
+
path="groupBy"
|
|
54
|
+
>
|
|
55
|
+
<NSelect
|
|
56
|
+
v-model:value="model.groupBy"
|
|
57
|
+
:options="fieldOptions"
|
|
58
|
+
:placeholder="t('groupBy')"
|
|
59
|
+
filterable
|
|
60
|
+
/>
|
|
61
|
+
</NFormItem>
|
|
62
|
+
|
|
63
|
+
<NFormItem
|
|
64
|
+
v-if="model.type === 'line'"
|
|
65
|
+
:label="t('dateField')"
|
|
66
|
+
path="dateField"
|
|
67
|
+
>
|
|
68
|
+
<NSelect
|
|
69
|
+
v-model:value="model.dateField"
|
|
70
|
+
:options="dateFieldOptions"
|
|
71
|
+
:placeholder="t('dateField')"
|
|
72
|
+
clearable
|
|
73
|
+
/>
|
|
74
|
+
</NFormItem>
|
|
75
|
+
|
|
76
|
+
<NFormItem :label="t('dateRange')" path="dateRange">
|
|
77
|
+
<NSelect
|
|
78
|
+
v-model:value="model.dateRange"
|
|
79
|
+
:options="dateRangeOptions"
|
|
80
|
+
:placeholder="t('dateRange')"
|
|
81
|
+
clearable
|
|
82
|
+
/>
|
|
83
|
+
</NFormItem>
|
|
84
|
+
|
|
85
|
+
<NFormItem
|
|
86
|
+
v-if="model.type === 'table'"
|
|
87
|
+
:label="t('columnsToDisplay')"
|
|
88
|
+
path="columns"
|
|
89
|
+
>
|
|
90
|
+
<NSelect
|
|
91
|
+
v-model:value="model.columns"
|
|
92
|
+
:options="fieldOptions"
|
|
93
|
+
:placeholder="t('columnsToDisplay')"
|
|
94
|
+
filterable
|
|
95
|
+
multiple
|
|
96
|
+
clearable
|
|
97
|
+
/>
|
|
98
|
+
</NFormItem>
|
|
99
|
+
|
|
100
|
+
<NFormItem
|
|
101
|
+
v-if="model.type === 'table'"
|
|
102
|
+
:label="t('sortField')"
|
|
103
|
+
path="sortField"
|
|
104
|
+
>
|
|
105
|
+
<NSelect
|
|
106
|
+
v-model:value="model.sortField"
|
|
107
|
+
:options="fieldOptions"
|
|
108
|
+
:placeholder="t('sortField')"
|
|
109
|
+
filterable
|
|
110
|
+
clearable
|
|
111
|
+
/>
|
|
112
|
+
</NFormItem>
|
|
113
|
+
|
|
114
|
+
<NFormItem
|
|
115
|
+
v-if="model.type === 'table' && model.sortField"
|
|
116
|
+
:label="t('sortOrder')"
|
|
117
|
+
path="sortOrder"
|
|
118
|
+
>
|
|
119
|
+
<NSelect
|
|
120
|
+
v-model:value="model.sortOrder"
|
|
121
|
+
:options="sortOrderOptions"
|
|
122
|
+
:placeholder="t('sortOrder')"
|
|
123
|
+
/>
|
|
124
|
+
</NFormItem>
|
|
125
|
+
|
|
126
|
+
<NFormItem
|
|
127
|
+
v-if="model.type === 'table'"
|
|
128
|
+
:label="t('limit')"
|
|
129
|
+
path="limit"
|
|
130
|
+
>
|
|
131
|
+
<NInputNumber
|
|
132
|
+
v-model:value="model.limit"
|
|
133
|
+
:min="1"
|
|
134
|
+
:max="100"
|
|
135
|
+
:placeholder="t('limit')"
|
|
136
|
+
/>
|
|
137
|
+
</NFormItem>
|
|
138
|
+
|
|
139
|
+
<NFormItem v-if="model.table" :label="t('filter')" path="searchArray">
|
|
140
|
+
<LazyTableSearch v-model="model.searchArray" v-model:schema="widgetSchema" />
|
|
141
|
+
</NFormItem>
|
|
142
|
+
|
|
143
|
+
<NFormItem :label="t('size')" path="size">
|
|
144
|
+
<NSelect
|
|
145
|
+
v-model:value="model.size"
|
|
146
|
+
:options="sizeOptions"
|
|
147
|
+
:placeholder="t('size')"
|
|
148
|
+
/>
|
|
149
|
+
</NFormItem>
|
|
150
|
+
|
|
151
|
+
<NFormItem :label="t('color')" path="color">
|
|
152
|
+
<NColorPicker v-model:value="model.color" :modes="['hex']" clearable />
|
|
153
|
+
</NFormItem>
|
|
154
|
+
</NForm>
|
|
155
|
+
</template>
|
|
156
|
+
|
|
157
|
+
<script lang="ts" setup>
|
|
158
|
+
import { LazyTableSearch } from "#components";
|
|
159
|
+
|
|
160
|
+
const props = defineProps<{
|
|
161
|
+
modelValue: Widget;
|
|
162
|
+
}>();
|
|
163
|
+
|
|
164
|
+
const emit = defineEmits<{
|
|
165
|
+
"update:modelValue": [value: Widget];
|
|
166
|
+
}>();
|
|
167
|
+
|
|
168
|
+
const database = useState<Database>("database");
|
|
169
|
+
|
|
170
|
+
const model = computed({
|
|
171
|
+
get: () => props.modelValue,
|
|
172
|
+
set: (v) => emit("update:modelValue", v),
|
|
173
|
+
});
|
|
174
|
+
|
|
175
|
+
// Schema for the search builder, synced from the selected source table.
|
|
176
|
+
// LazyTableSearch writes to its schema model only when empty, so a local
|
|
177
|
+
// ref synced via watcher is safe.
|
|
178
|
+
const widgetSchema = ref<Schema | undefined>(
|
|
179
|
+
database.value?.tables?.find((t) => t.slug === model.value.table)?.schema,
|
|
180
|
+
);
|
|
181
|
+
|
|
182
|
+
watch(
|
|
183
|
+
() => model.value.table,
|
|
184
|
+
(newTable, oldTable) => {
|
|
185
|
+
widgetSchema.value = database.value?.tables?.find(
|
|
186
|
+
(t) => t.slug === newTable,
|
|
187
|
+
)?.schema;
|
|
188
|
+
// Source table changed → previously picked fields are invalid
|
|
189
|
+
if (newTable !== oldTable && oldTable !== undefined) {
|
|
190
|
+
model.value.searchArray = { and: [[null, "=", null]] };
|
|
191
|
+
model.value.columns = undefined;
|
|
192
|
+
model.value.sortField = undefined;
|
|
193
|
+
model.value.sortOrder = undefined;
|
|
194
|
+
}
|
|
195
|
+
if (!model.value.searchArray) {
|
|
196
|
+
model.value.searchArray = { and: [[null, "=", null]] };
|
|
197
|
+
}
|
|
198
|
+
},
|
|
199
|
+
);
|
|
200
|
+
|
|
201
|
+
if (!model.value.searchArray) {
|
|
202
|
+
model.value.searchArray = { and: [[null, "=", null]] };
|
|
203
|
+
}
|
|
204
|
+
|
|
205
|
+
const typeOptions = [
|
|
206
|
+
{ label: t("counter"), value: "counter" },
|
|
207
|
+
{ label: t("lineChart"), value: "line" },
|
|
208
|
+
{ label: t("barChart"), value: "bar" },
|
|
209
|
+
{ label: t("pieChart"), value: "pie" },
|
|
210
|
+
{ label: t("table"), value: "table" },
|
|
211
|
+
];
|
|
212
|
+
|
|
213
|
+
const operationOptions = [
|
|
214
|
+
{ label: t("count"), value: "count" },
|
|
215
|
+
{ label: t("sum"), value: "sum" },
|
|
216
|
+
{ label: t("max"), value: "max" },
|
|
217
|
+
{ label: t("min"), value: "min" },
|
|
218
|
+
];
|
|
219
|
+
|
|
220
|
+
const sortOrderOptions = [
|
|
221
|
+
{ label: t("asc"), value: "asc" },
|
|
222
|
+
{ label: t("desc"), value: "desc" },
|
|
223
|
+
];
|
|
224
|
+
|
|
225
|
+
const sizeOptions = [
|
|
226
|
+
{ label: t("small"), value: "small" },
|
|
227
|
+
{ label: t("medium"), value: "medium" },
|
|
228
|
+
{ label: t("large"), value: "large" },
|
|
229
|
+
];
|
|
230
|
+
|
|
231
|
+
const dateRangeOptions = [
|
|
232
|
+
{ label: t("last7Days"), value: "7d" },
|
|
233
|
+
{ label: t("last30Days"), value: "30d" },
|
|
234
|
+
{ label: t("last90Days"), value: "90d" },
|
|
235
|
+
{ label: t("lastYear"), value: "1y" },
|
|
236
|
+
{ label: t("allTime"), value: "all" },
|
|
237
|
+
];
|
|
238
|
+
|
|
239
|
+
const tableOptions = computed(
|
|
240
|
+
() =>
|
|
241
|
+
database.value?.tables
|
|
242
|
+
?.filter(
|
|
243
|
+
({ slug, allowedMethods }) =>
|
|
244
|
+
allowedMethods?.includes("r") && slug !== "dashboards",
|
|
245
|
+
)
|
|
246
|
+
.map((table) => ({ label: t(table.slug), value: table.slug })) ?? [],
|
|
247
|
+
);
|
|
248
|
+
|
|
249
|
+
const selectedTable = computed(() =>
|
|
250
|
+
database.value?.tables?.find((t) => t.slug === model.value.table),
|
|
251
|
+
);
|
|
252
|
+
|
|
253
|
+
const fieldOptions = computed(
|
|
254
|
+
() =>
|
|
255
|
+
selectedTable.value?.schema?.map((f) => ({
|
|
256
|
+
label: f.label || f.key,
|
|
257
|
+
value: f.key,
|
|
258
|
+
})) ?? [],
|
|
259
|
+
);
|
|
260
|
+
|
|
261
|
+
const dateFieldOptions = computed(() => [
|
|
262
|
+
{ label: "createdAt", value: "createdAt" },
|
|
263
|
+
{ label: "updatedAt", value: "updatedAt" },
|
|
264
|
+
...(selectedTable.value?.schema
|
|
265
|
+
?.filter((f) => f.type === "date" || f.date)
|
|
266
|
+
.map((f) => ({ label: f.label || f.key, value: f.key })) ?? []),
|
|
267
|
+
]);
|
|
268
|
+
|
|
269
|
+
const showFieldPicker = computed(() => {
|
|
270
|
+
if (model.value.type === "counter")
|
|
271
|
+
return model.value.operation && model.value.operation !== "count";
|
|
272
|
+
return false;
|
|
273
|
+
});
|
|
274
|
+
</script>
|