@ocelescope/core 0.0.0 → 0.0.1
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/dist/index.css +1 -0
- package/dist/index.d.ts +31 -7
- package/dist/index.js +334 -200
- package/package.json +4 -4
package/dist/index.css
CHANGED
|
@@ -1 +1,2 @@
|
|
|
1
1
|
._0yGNhG_wrapper{width:100%;margin-bottom:30px;position:relative}._0yGNhG_dropzone{color:var(--mantine-color-bright);border-width:1px;padding-bottom:50px}._0yGNhG_icon{color:light-dark(var(--mantine-color-gray-4),var(--mantine-color-white))}._0yGNhG_control{width:250px;position:absolute;bottom:-20px;left:calc(50% - 125px)}._0yGNhG_description{text-align:center;font-size:var(--mantine-font-size-sm);color:var(--mantine-color-dimmed);margin-top:var(--mantine-spacing-xs)}
|
|
2
|
+
._4Ar51a_navbar{background-color:var(--mantine-color-white);border-right:1px solid var(--mantine-color-gray-3);flex-direction:column;width:300px;display:flex}[data-mantine-color-scheme=dark] ._4Ar51a_navbar{background-color:var(--mantine-color-dark-6);border-right-color:var(--mantine-color-dark-4)}._4Ar51a_header{padding:var(--mantine-spacing-md);margin-left:calc(var(--mantine-spacing-md) * -1);margin-right:calc(var(--mantine-spacing-md) * -1);color:var(--mantine-color-black);border-bottom:1px solid var(--mantine-color-gray-3);padding-top:0}[data-mantine-color-scheme=dark] ._4Ar51a_header{color:var(--mantine-color-white);border-bottom-color:var(--mantine-color-dark-4)}._4Ar51a_links{margin-left:calc(var(--mantine-spacing-md) * -1);margin-right:calc(var(--mantine-spacing-md) * -1);flex:1}._4Ar51a_footer{margin-left:calc(var(--mantine-spacing-md) * -1);margin-right:calc(var(--mantine-spacing-md) * -1);border-top:1px solid var(--mantine-color-gray-3)}[data-mantine-color-scheme=dark] ._4Ar51a_footer{border-top-color:var(--mantine-color-dark-4)}._4Ar51a_control{width:100%;padding:var(--mantine-spacing-xs) var(--mantine-spacing-md);color:var(--mantine-color-text);font-weight:500;font-size:var(--mantine-font-size-sm);display:block}._4Ar51a_control:hover{background-color:var(--mantine-color-gray-0);color:var(--mantine-color-black)}[data-mantine-color-scheme=dark] ._4Ar51a_control:hover{background-color:var(--mantine-color-dark-7);color:var(--mantine-color-dark-0)}._4Ar51a_link{padding:var(--mantine-spacing-xs) var(--mantine-spacing-md);padding-left:var(--mantine-spacing-md);margin-left:var(--mantine-spacing-xl);font-weight:500;font-size:var(--mantine-font-size-sm);color:var(--mantine-color-gray-7);border-left:1px solid var(--mantine-color-gray-3);text-decoration:none;display:block}[data-mantine-color-scheme=dark] ._4Ar51a_link{color:var(--mantine-color-dark-0);border-left-color:var(--mantine-color-dark-4)}._4Ar51a_link:hover{background-color:var(--mantine-color-gray-0);color:var(--mantine-color-black)}[data-mantine-color-scheme=dark] ._4Ar51a_link:hover{background-color:var(--mantine-color-dark-7);color:var(--mantine-color-dark-0)}._4Ar51a_chevron{transition:transform .2s}._4Ar51a_button{font-size:var(--mantine-font-size-sm);color:var(--mantine-color-gray-7);padding:var(--mantine-spacing-xs) var(--mantine-spacing-sm);border-radius:var(--mantine-radius-sm);font-weight:500;text-decoration:none}[data-mantine-color-scheme=dark] ._4Ar51a_button{color:var(--mantine-color-dark-1)}._4Ar51a_button:hover{background-color:var(--mantine-color-gray-0);color:var(--mantine-color-black)}[data-mantine-color-scheme=dark] ._4Ar51a_button:hover{background-color:var(--mantine-color-dark-6);color:var(--mantine-color-white)}._4Ar51a_button:hover ._4Ar51a_linkIcon{color:var(--mantine-color-black)}[data-mantine-color-scheme=dark] ._4Ar51a_button:hover ._4Ar51a_linkIcon{color:var(--mantine-color-white)}._4Ar51a_button[data-active],._4Ar51a_button[data-active]:hover{background-color:var(--mantine-color-blue-light);color:var(--mantine-color-blue-light-color)}._4Ar51a_button[data-active] ._4Ar51a_linkIcon,._4Ar51a_button[data-active]:hover ._4Ar51a_linkIcon{color:var(--mantine-color-blue-light-color)}._4Ar51a_buttonIcon{color:var(--mantine-color-gray-6);width:25px;height:25px}[data-mantine-color-scheme=dark] ._4Ar51a_buttonIcon{color:var(--mantine-color-dark-2)}
|
package/dist/index.d.ts
CHANGED
|
@@ -3,12 +3,6 @@ import { SVGProps } from "react";
|
|
|
3
3
|
import * as next0 from "next";
|
|
4
4
|
import { GetStaticPaths, GetStaticProps } from "next";
|
|
5
5
|
|
|
6
|
-
//#region src/components/OcelescopeApp.d.ts
|
|
7
|
-
declare const OcelescopeApp: React.FC<any>;
|
|
8
|
-
//#endregion
|
|
9
|
-
//#region src/components/OcelescopeDocument.d.ts
|
|
10
|
-
declare const OcelescopeDocument: React.FC;
|
|
11
|
-
//#endregion
|
|
12
6
|
//#region src/lib/config.d.ts
|
|
13
7
|
type Author = {
|
|
14
8
|
name: string;
|
|
@@ -32,6 +26,8 @@ type OcelescopeConfig = {
|
|
|
32
26
|
homePage?: React.FC;
|
|
33
27
|
modules?: readonly ModuleDefinition[];
|
|
34
28
|
};
|
|
29
|
+
declare const defineModule: (def: ModuleDefinition) => ModuleDefinition;
|
|
30
|
+
declare const defineModuleRoute: (def: ModuleRouteDefinition) => ModuleRouteDefinition;
|
|
35
31
|
//#endregion
|
|
36
32
|
//#region src/components/ModulePage.d.ts
|
|
37
33
|
type ModulePageProps = {
|
|
@@ -48,4 +44,32 @@ declare const createModulesPage: (config: OcelescopeConfig) => {
|
|
|
48
44
|
};
|
|
49
45
|
};
|
|
50
46
|
//#endregion
|
|
51
|
-
|
|
47
|
+
//#region src/components/OcelescopeApp.d.ts
|
|
48
|
+
declare const OcelescopeApp: (config: OcelescopeConfig) => React.FC<any>;
|
|
49
|
+
//#endregion
|
|
50
|
+
//#region src/components/OcelescopeDocument.d.ts
|
|
51
|
+
declare const OcelescopeDocument: React.FC;
|
|
52
|
+
//#endregion
|
|
53
|
+
//#region src/hooks/useCurrentOCEL.d.ts
|
|
54
|
+
declare const useCurrentOcel: () => {
|
|
55
|
+
id: string | null;
|
|
56
|
+
setCurrentOcel: (id: string) => void;
|
|
57
|
+
};
|
|
58
|
+
//#endregion
|
|
59
|
+
//#region src/lib/getModuleRoute.d.ts
|
|
60
|
+
declare const getModuleRoute: ({
|
|
61
|
+
moduleName,
|
|
62
|
+
routeName,
|
|
63
|
+
query
|
|
64
|
+
}: {
|
|
65
|
+
moduleName: string;
|
|
66
|
+
routeName: string;
|
|
67
|
+
query?: Record<string, string>;
|
|
68
|
+
}) => {
|
|
69
|
+
query?: {
|
|
70
|
+
[x: string]: string;
|
|
71
|
+
};
|
|
72
|
+
pathname: string;
|
|
73
|
+
};
|
|
74
|
+
//#endregion
|
|
75
|
+
export { ModuleDefinition, ModuleRouteDefinition, OcelescopeApp, OcelescopeConfig, OcelescopeDocument, createModulesPage, defineModule, defineModuleRoute, getModuleRoute, useCurrentOcel };
|
package/dist/index.js
CHANGED
|
@@ -1,25 +1,48 @@
|
|
|
1
|
-
import { ActionIcon, AppShell, Badge, Burger, Button, ColorSchemeScript, Container, Group, LoadingOverlay, MantineProvider, Menu, MenuItem, Modal, Select, Stack, Text, TextInput, ThemeIcon, Title, mantineHtmlProps, useMantineTheme } from "@mantine/core";
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import { CheckIcon, ContainerIcon, DownloadIcon, EllipsisVerticalIcon, EyeIcon, PencilIcon, TrashIcon, Upload, UploadIcon, X, XIcon } from "lucide-react";
|
|
1
|
+
import { ActionIcon, AppShell, Badge, Box, Burger, Button, ColorSchemeScript, Container, Divider, Group, LoadingOverlay, MantineProvider, Menu, MenuItem, Modal, NavLink, Select, Stack, Text, TextInput, ThemeIcon, Title, mantineHtmlProps, useMantineTheme } from "@mantine/core";
|
|
2
|
+
import { generateColor } from "@marko19907/string-to-color";
|
|
3
|
+
import { useDeleteOcel, useDeleteResource, useGetDefaultOcel, useGetOcels, useGetResourceMeta, useImportDefaultOcel, useRenameOcel, useRenameResource, useResources, useUpload } from "@ocelescope/api-base";
|
|
4
|
+
import { ResourceModal } from "@ocelescope/resources";
|
|
5
|
+
import { CheckIcon, ContainerIcon, DownloadIcon, EllipsisVerticalIcon, EyeIcon, HomeIcon, PackageIcon, PencilIcon, TrashIcon, Upload, UploadIcon, X, XIcon } from "lucide-react";
|
|
6
6
|
import { DataTable } from "mantine-datatable";
|
|
7
|
+
import { useCallback, useEffect, useMemo, useRef, useState } from "react";
|
|
8
|
+
import { env, useSessionStore } from "@ocelescope/api-client";
|
|
9
|
+
import { parse } from "content-disposition-attachment";
|
|
10
|
+
import { saveAs } from "file-saver";
|
|
11
|
+
import { HydrationBoundary, QueryClient, QueryClientProvider, useQueryClient } from "@tanstack/react-query";
|
|
12
|
+
import dayjs from "dayjs";
|
|
13
|
+
import isBetween from "dayjs/plugin/isBetween";
|
|
7
14
|
import { Dropzone } from "@mantine/dropzone";
|
|
8
15
|
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
9
|
-
import {
|
|
10
|
-
import {
|
|
16
|
+
import { ReactQueryDevtools } from "@tanstack/react-query-devtools";
|
|
17
|
+
import { useDisclosure } from "@mantine/hooks";
|
|
11
18
|
import { create } from "zustand";
|
|
12
19
|
import { persist } from "zustand/middleware";
|
|
13
|
-
import
|
|
20
|
+
import Link from "next/link";
|
|
21
|
+
import { useRouter } from "next/router";
|
|
14
22
|
import { Head, Html, Main, NextScript } from "next/document";
|
|
15
|
-
import { ResourceModal } from "@ocelescope/resources";
|
|
16
|
-
import { saveAs } from "file-saver";
|
|
17
|
-
import { parse } from "content-disposition-attachment";
|
|
18
|
-
import dayjs from "dayjs";
|
|
19
|
-
import isBetween from "dayjs/plugin/isBetween";
|
|
20
|
-
import { generateColor } from "@marko19907/string-to-color";
|
|
21
23
|
|
|
22
24
|
import './index.css';
|
|
25
|
+
//#region src/hooks/useDownload.ts
|
|
26
|
+
const useDownloadFile = () => {
|
|
27
|
+
const { sessionId } = useSessionStore();
|
|
28
|
+
const downloadFile = async (path) => {
|
|
29
|
+
try {
|
|
30
|
+
const response = await fetch(`${env.backend_url}${path}`, {
|
|
31
|
+
method: "GET",
|
|
32
|
+
headers: { [env.session_id]: sessionId ?? "" }
|
|
33
|
+
});
|
|
34
|
+
if (!response.ok) throw new Error("Failed to download file");
|
|
35
|
+
const blob = await response.blob();
|
|
36
|
+
const contentDisposition = parse(response.headers.get("Content-Disposition") ?? "");
|
|
37
|
+
saveAs(blob, contentDisposition.attachment ? contentDisposition.filename : "fileName");
|
|
38
|
+
} catch (err) {
|
|
39
|
+
console.error("Download error:", err);
|
|
40
|
+
}
|
|
41
|
+
};
|
|
42
|
+
return downloadFile;
|
|
43
|
+
};
|
|
44
|
+
|
|
45
|
+
//#endregion
|
|
23
46
|
//#region src/hooks/useInvalidate.ts
|
|
24
47
|
const useInvalidate = () => {
|
|
25
48
|
const queryClient = useQueryClient();
|
|
@@ -27,21 +50,27 @@ const useInvalidate = () => {
|
|
|
27
50
|
};
|
|
28
51
|
var useInvalidate_default = useInvalidate;
|
|
29
52
|
|
|
53
|
+
//#endregion
|
|
54
|
+
//#region src/lib/dayjs.ts
|
|
55
|
+
dayjs.extend(isBetween);
|
|
56
|
+
var dayjs_default = dayjs;
|
|
57
|
+
const formatDateTime = (dateString) => dayjs(dateString).format("YYYY-MM-DD HH:mm");
|
|
58
|
+
|
|
30
59
|
//#endregion
|
|
31
60
|
//#region src/components/Dropzone/Dropzone.module.css?css_module
|
|
32
|
-
const classes = {
|
|
33
|
-
"control": "_0yGNhG_control",
|
|
61
|
+
const classes$1 = {
|
|
34
62
|
"icon": "_0yGNhG_icon",
|
|
35
|
-
"description": "_0yGNhG_description",
|
|
36
63
|
"wrapper": "_0yGNhG_wrapper",
|
|
37
|
-
"dropzone": "_0yGNhG_dropzone"
|
|
64
|
+
"dropzone": "_0yGNhG_dropzone",
|
|
65
|
+
"control": "_0yGNhG_control",
|
|
66
|
+
"description": "_0yGNhG_description"
|
|
38
67
|
};
|
|
39
|
-
var Dropzone_module_default = classes;
|
|
40
|
-
const
|
|
41
|
-
const
|
|
42
|
-
const
|
|
43
|
-
const
|
|
44
|
-
const
|
|
68
|
+
var Dropzone_module_default = classes$1;
|
|
69
|
+
const _icon0 = classes$1["icon"];
|
|
70
|
+
const _wrapper0 = classes$1["wrapper"];
|
|
71
|
+
const _dropzone0 = classes$1["dropzone"];
|
|
72
|
+
const _control0$1 = classes$1["control"];
|
|
73
|
+
const _description0 = classes$1["description"];
|
|
45
74
|
|
|
46
75
|
//#endregion
|
|
47
76
|
//#region src/components/Dropzone/Dropzone.tsx
|
|
@@ -190,180 +219,6 @@ const UploadSection = ({ onSuccess }) => {
|
|
|
190
219
|
};
|
|
191
220
|
var UploadSection_default = UploadSection;
|
|
192
221
|
|
|
193
|
-
//#endregion
|
|
194
|
-
//#region src/components/UploadModal/UploadModal.tsx
|
|
195
|
-
const UploadModal = ({ visible, onClose }) => {
|
|
196
|
-
return /* @__PURE__ */ jsx(Modal, {
|
|
197
|
-
title: /* @__PURE__ */ jsx(Text, {
|
|
198
|
-
size: "h3",
|
|
199
|
-
children: "Upload"
|
|
200
|
-
}),
|
|
201
|
-
opened: visible,
|
|
202
|
-
onClose,
|
|
203
|
-
size: "xl",
|
|
204
|
-
children: /* @__PURE__ */ jsx(UploadSection_default, { onSuccess: onClose })
|
|
205
|
-
});
|
|
206
|
-
};
|
|
207
|
-
var UploadModal_default = UploadModal;
|
|
208
|
-
|
|
209
|
-
//#endregion
|
|
210
|
-
//#region src/store/currentOcelStore.ts
|
|
211
|
-
const useCurrentOcelStore = create()(persist((set) => ({
|
|
212
|
-
ocelId: null,
|
|
213
|
-
setOcel: (id) => set({ ocelId: id }),
|
|
214
|
-
clearOcel: () => set({ ocelId: null })
|
|
215
|
-
}), { name: env.current_ocel_id }));
|
|
216
|
-
var currentOcelStore_default = useCurrentOcelStore;
|
|
217
|
-
|
|
218
|
-
//#endregion
|
|
219
|
-
//#region src/hooks/useCurrentOCEL.ts
|
|
220
|
-
const useCurrentOcel = () => {
|
|
221
|
-
const { data: ocels = [] } = useGetOcels();
|
|
222
|
-
const { ocelId, setOcel, clearOcel } = currentOcelStore_default();
|
|
223
|
-
useEffect(() => {
|
|
224
|
-
if (ocelId && !ocels?.some(({ id }) => id === ocelId)) clearOcel();
|
|
225
|
-
if (!ocelId && ocels[0]) setOcel(ocels[0].id);
|
|
226
|
-
}, [
|
|
227
|
-
clearOcel,
|
|
228
|
-
setOcel,
|
|
229
|
-
ocels,
|
|
230
|
-
ocelId
|
|
231
|
-
]);
|
|
232
|
-
return {
|
|
233
|
-
id: ocelId,
|
|
234
|
-
setCurrentOcel: setOcel
|
|
235
|
-
};
|
|
236
|
-
};
|
|
237
|
-
var useCurrentOCEL_default = useCurrentOcel;
|
|
238
|
-
|
|
239
|
-
//#endregion
|
|
240
|
-
//#region src/components/OcelSelect/OcelSelect.tsx
|
|
241
|
-
const OcelSelect = ({ extension, ...props }) => {
|
|
242
|
-
const { data } = useGetOcels(extension ? { extension_name: extension } : {});
|
|
243
|
-
const ocels = useMemo(() => data ?? [], [data]);
|
|
244
|
-
return /* @__PURE__ */ jsx(Select, {
|
|
245
|
-
...props,
|
|
246
|
-
data: ocels.map(({ name, id }) => ({
|
|
247
|
-
value: id,
|
|
248
|
-
label: name
|
|
249
|
-
}))
|
|
250
|
-
});
|
|
251
|
-
};
|
|
252
|
-
const CurrentOcelSelect = () => {
|
|
253
|
-
const { id, setCurrentOcel } = useCurrentOCEL_default();
|
|
254
|
-
return /* @__PURE__ */ jsx(OcelSelect, {
|
|
255
|
-
value: id,
|
|
256
|
-
unselectable: "off",
|
|
257
|
-
onChange: (id$1) => {
|
|
258
|
-
if (id$1) setCurrentOcel(id$1);
|
|
259
|
-
}
|
|
260
|
-
});
|
|
261
|
-
};
|
|
262
|
-
|
|
263
|
-
//#endregion
|
|
264
|
-
//#region src/components/AppShell/AppShell.tsx
|
|
265
|
-
const AppShell$1 = ({ children }) => {
|
|
266
|
-
const [mobileOpened, { toggle: toggleMobile }] = useDisclosure(true);
|
|
267
|
-
const [desktopOpened, { toggle: toggleDesktop }] = useDisclosure(true);
|
|
268
|
-
const [isUploadModalVisible, setIsUploadModalVisible] = useState(false);
|
|
269
|
-
return /* @__PURE__ */ jsxs(AppShell, {
|
|
270
|
-
header: { height: 60 },
|
|
271
|
-
navbar: {
|
|
272
|
-
width: 300,
|
|
273
|
-
breakpoint: "sm",
|
|
274
|
-
collapsed: {
|
|
275
|
-
mobile: !mobileOpened,
|
|
276
|
-
desktop: !desktopOpened
|
|
277
|
-
}
|
|
278
|
-
},
|
|
279
|
-
padding: "md",
|
|
280
|
-
children: [
|
|
281
|
-
/* @__PURE__ */ jsx(AppShell.Header, { children: /* @__PURE__ */ jsxs(Group, {
|
|
282
|
-
h: "100%",
|
|
283
|
-
px: "md",
|
|
284
|
-
justify: "space-between",
|
|
285
|
-
children: [/* @__PURE__ */ jsxs(Group, {
|
|
286
|
-
align: "center",
|
|
287
|
-
children: [/* @__PURE__ */ jsx(Burger, {
|
|
288
|
-
opened: mobileOpened,
|
|
289
|
-
onClick: toggleMobile,
|
|
290
|
-
hiddenFrom: "sm",
|
|
291
|
-
size: "sm"
|
|
292
|
-
}), /* @__PURE__ */ jsx(Burger, {
|
|
293
|
-
opened: desktopOpened,
|
|
294
|
-
onClick: toggleDesktop,
|
|
295
|
-
visibleFrom: "sm",
|
|
296
|
-
size: "sm"
|
|
297
|
-
})]
|
|
298
|
-
}), /* @__PURE__ */ jsxs(Group, { children: [
|
|
299
|
-
/* @__PURE__ */ jsx(CurrentOcelSelect, {}),
|
|
300
|
-
/* @__PURE__ */ jsx(Button, {
|
|
301
|
-
leftSection: /* @__PURE__ */ jsx(UploadIcon, { size: 18 }),
|
|
302
|
-
onClick: () => setIsUploadModalVisible(true),
|
|
303
|
-
children: "Upload"
|
|
304
|
-
}),
|
|
305
|
-
/* @__PURE__ */ jsx(UploadModal_default, {
|
|
306
|
-
visible: isUploadModalVisible,
|
|
307
|
-
onClose: () => setIsUploadModalVisible(false)
|
|
308
|
-
})
|
|
309
|
-
] })]
|
|
310
|
-
}) }),
|
|
311
|
-
/* @__PURE__ */ jsx(AppShell.Navbar, {}),
|
|
312
|
-
/* @__PURE__ */ jsx(AppShell.Main, { children })
|
|
313
|
-
]
|
|
314
|
-
});
|
|
315
|
-
};
|
|
316
|
-
|
|
317
|
-
//#endregion
|
|
318
|
-
//#region src/components/OcelescopeApp.tsx
|
|
319
|
-
const OcelescopeApp = ({ Component, pageProps }) => {
|
|
320
|
-
const [client] = useState(() => new QueryClient());
|
|
321
|
-
return /* @__PURE__ */ jsxs(QueryClientProvider, {
|
|
322
|
-
client,
|
|
323
|
-
children: [/* @__PURE__ */ jsx(HydrationBoundary, {
|
|
324
|
-
state: pageProps.dehydratedState,
|
|
325
|
-
children: /* @__PURE__ */ jsx(MantineProvider, { children: /* @__PURE__ */ jsx(AppShell$1, { children: /* @__PURE__ */ jsx(Component, {}) }) })
|
|
326
|
-
}), /* @__PURE__ */ jsx(ReactQueryDevtools, {})]
|
|
327
|
-
});
|
|
328
|
-
};
|
|
329
|
-
|
|
330
|
-
//#endregion
|
|
331
|
-
//#region src/components/OcelescopeDocument.tsx
|
|
332
|
-
const OcelescopeDocument = () => {
|
|
333
|
-
return /* @__PURE__ */ jsxs(Html, {
|
|
334
|
-
lang: "en",
|
|
335
|
-
...mantineHtmlProps,
|
|
336
|
-
children: [/* @__PURE__ */ jsx(Head, { children: /* @__PURE__ */ jsx(ColorSchemeScript, { defaultColorScheme: "auto" }) }), /* @__PURE__ */ jsxs("body", { children: [/* @__PURE__ */ jsx(Main, {}), /* @__PURE__ */ jsx(NextScript, {})] })]
|
|
337
|
-
});
|
|
338
|
-
};
|
|
339
|
-
|
|
340
|
-
//#endregion
|
|
341
|
-
//#region src/hooks/useDownload.ts
|
|
342
|
-
const useDownloadFile = () => {
|
|
343
|
-
const { sessionId } = useSessionStore();
|
|
344
|
-
const downloadFile = async (path) => {
|
|
345
|
-
try {
|
|
346
|
-
const response = await fetch(`${env.backend_url}${path}`, {
|
|
347
|
-
method: "GET",
|
|
348
|
-
headers: { [env.session_id]: sessionId ?? "" }
|
|
349
|
-
});
|
|
350
|
-
if (!response.ok) throw new Error("Failed to download file");
|
|
351
|
-
const blob = await response.blob();
|
|
352
|
-
const contentDisposition = parse(response.headers.get("Content-Disposition") ?? "");
|
|
353
|
-
saveAs(blob, contentDisposition.attachment ? contentDisposition.filename : "fileName");
|
|
354
|
-
} catch (err) {
|
|
355
|
-
console.error("Download error:", err);
|
|
356
|
-
}
|
|
357
|
-
};
|
|
358
|
-
return downloadFile;
|
|
359
|
-
};
|
|
360
|
-
|
|
361
|
-
//#endregion
|
|
362
|
-
//#region src/lib/dayjs.ts
|
|
363
|
-
dayjs.extend(isBetween);
|
|
364
|
-
var dayjs_default = dayjs;
|
|
365
|
-
const formatDateTime = (dateString) => dayjs(dateString).format("YYYY-MM-DD HH:mm");
|
|
366
|
-
|
|
367
222
|
//#endregion
|
|
368
223
|
//#region src/components/EntityTable/EntityTable.tsx
|
|
369
224
|
const ocelExtenisions = [
|
|
@@ -582,7 +437,7 @@ const createModulesPage = (config) => {
|
|
|
582
437
|
};
|
|
583
438
|
};
|
|
584
439
|
const getStaticProps = async ({ params }) => {
|
|
585
|
-
const slugs = params?.slug ?? [];
|
|
440
|
+
const slugs = params?.["slug"] ?? [];
|
|
586
441
|
const moduleConfig = modules.find(({ name }) => name === slugs[1]);
|
|
587
442
|
const routeName = moduleConfig?.routes.find(({ name }) => name === slugs[2])?.name;
|
|
588
443
|
return moduleConfig && routeName ? { props: { moduleProps: {
|
|
@@ -602,4 +457,283 @@ const createModulesPage = (config) => {
|
|
|
602
457
|
};
|
|
603
458
|
|
|
604
459
|
//#endregion
|
|
605
|
-
|
|
460
|
+
//#region src/store/currentOcelStore.ts
|
|
461
|
+
const useCurrentOcelStore = create()(persist((set) => ({
|
|
462
|
+
ocelId: null,
|
|
463
|
+
setOcel: (id) => set({ ocelId: id }),
|
|
464
|
+
clearOcel: () => set({ ocelId: null })
|
|
465
|
+
}), { name: env.current_ocel_id }));
|
|
466
|
+
var currentOcelStore_default = useCurrentOcelStore;
|
|
467
|
+
|
|
468
|
+
//#endregion
|
|
469
|
+
//#region src/hooks/useCurrentOCEL.ts
|
|
470
|
+
const useCurrentOcel = () => {
|
|
471
|
+
const { data: ocels = [] } = useGetOcels();
|
|
472
|
+
const { ocelId, setOcel, clearOcel } = currentOcelStore_default();
|
|
473
|
+
useEffect(() => {
|
|
474
|
+
if (ocelId && !ocels?.some(({ id }) => id === ocelId)) clearOcel();
|
|
475
|
+
if (!ocelId && ocels[0]) setOcel(ocels[0].id);
|
|
476
|
+
}, [
|
|
477
|
+
clearOcel,
|
|
478
|
+
setOcel,
|
|
479
|
+
ocels,
|
|
480
|
+
ocelId
|
|
481
|
+
]);
|
|
482
|
+
return {
|
|
483
|
+
id: ocelId,
|
|
484
|
+
setCurrentOcel: setOcel
|
|
485
|
+
};
|
|
486
|
+
};
|
|
487
|
+
|
|
488
|
+
//#endregion
|
|
489
|
+
//#region src/components/OcelSelect/OcelSelect.tsx
|
|
490
|
+
const OcelSelect = ({ extension, ...props }) => {
|
|
491
|
+
const { data } = useGetOcels(extension ? { extension_name: extension } : {});
|
|
492
|
+
const ocels = useMemo(() => data ?? [], [data]);
|
|
493
|
+
return /* @__PURE__ */ jsx(Select, {
|
|
494
|
+
...props,
|
|
495
|
+
data: ocels.map(({ name, id }) => ({
|
|
496
|
+
value: id,
|
|
497
|
+
label: name
|
|
498
|
+
}))
|
|
499
|
+
});
|
|
500
|
+
};
|
|
501
|
+
const CurrentOcelSelect = () => {
|
|
502
|
+
const { id, setCurrentOcel } = useCurrentOcel();
|
|
503
|
+
return /* @__PURE__ */ jsx(OcelSelect, {
|
|
504
|
+
value: id,
|
|
505
|
+
unselectable: "off",
|
|
506
|
+
onChange: (id$1) => {
|
|
507
|
+
if (id$1) setCurrentOcel(id$1);
|
|
508
|
+
}
|
|
509
|
+
});
|
|
510
|
+
};
|
|
511
|
+
|
|
512
|
+
//#endregion
|
|
513
|
+
//#region src/components/UploadModal/UploadModal.tsx
|
|
514
|
+
const UploadModal = ({ visible, onClose }) => {
|
|
515
|
+
return /* @__PURE__ */ jsx(Modal, {
|
|
516
|
+
title: /* @__PURE__ */ jsx(Text, {
|
|
517
|
+
size: "h3",
|
|
518
|
+
children: "Upload"
|
|
519
|
+
}),
|
|
520
|
+
opened: visible,
|
|
521
|
+
onClose,
|
|
522
|
+
size: "xl",
|
|
523
|
+
children: /* @__PURE__ */ jsx(UploadSection_default, { onSuccess: onClose })
|
|
524
|
+
});
|
|
525
|
+
};
|
|
526
|
+
var UploadModal_default = UploadModal;
|
|
527
|
+
|
|
528
|
+
//#endregion
|
|
529
|
+
//#region src/components/AppShell/AppShell.module.css?css_module
|
|
530
|
+
const classes = {
|
|
531
|
+
"chevron": "_4Ar51a_chevron",
|
|
532
|
+
"linkIcon": "_4Ar51a_linkIcon",
|
|
533
|
+
"links": "_4Ar51a_links",
|
|
534
|
+
"navbar": "_4Ar51a_navbar",
|
|
535
|
+
"buttonIcon": "_4Ar51a_buttonIcon",
|
|
536
|
+
"link": "_4Ar51a_link",
|
|
537
|
+
"control": "_4Ar51a_control",
|
|
538
|
+
"header": "_4Ar51a_header",
|
|
539
|
+
"footer": "_4Ar51a_footer",
|
|
540
|
+
"button": "_4Ar51a_button"
|
|
541
|
+
};
|
|
542
|
+
var AppShell_module_default = classes;
|
|
543
|
+
const _chevron0 = classes["chevron"];
|
|
544
|
+
const _linkIcon0 = classes["linkIcon"];
|
|
545
|
+
const _links0 = classes["links"];
|
|
546
|
+
const _navbar0 = classes["navbar"];
|
|
547
|
+
const _buttonIcon0 = classes["buttonIcon"];
|
|
548
|
+
const _link0 = classes["link"];
|
|
549
|
+
const _control0 = classes["control"];
|
|
550
|
+
const _header0 = classes["header"];
|
|
551
|
+
const _footer0 = classes["footer"];
|
|
552
|
+
const _button0 = classes["button"];
|
|
553
|
+
|
|
554
|
+
//#endregion
|
|
555
|
+
//#region src/lib/getModuleRoute.ts
|
|
556
|
+
const getModuleRoute = ({ moduleName, routeName, query }) => {
|
|
557
|
+
return {
|
|
558
|
+
pathname: `/modules/${moduleName}/${routeName}`,
|
|
559
|
+
...query && { query: { ...query } }
|
|
560
|
+
};
|
|
561
|
+
};
|
|
562
|
+
|
|
563
|
+
//#endregion
|
|
564
|
+
//#region src/hooks/useModulePath.ts
|
|
565
|
+
const useModulePath = (config) => {
|
|
566
|
+
const { slug } = useRouter().query;
|
|
567
|
+
const [moduleName, routeName] = [slug?.[0], slug?.[1]];
|
|
568
|
+
return useMemo(() => {
|
|
569
|
+
const moduleConfig = config?.modules?.find(({ name }) => name === moduleName);
|
|
570
|
+
const routeConfig = moduleConfig?.routes.find(({ name }) => name === routeName);
|
|
571
|
+
return {
|
|
572
|
+
moduleName: moduleConfig?.name,
|
|
573
|
+
routeName: routeConfig?.name
|
|
574
|
+
};
|
|
575
|
+
}, [moduleName, routeName]);
|
|
576
|
+
};
|
|
577
|
+
var useModulePath_default = useModulePath;
|
|
578
|
+
|
|
579
|
+
//#endregion
|
|
580
|
+
//#region src/components/AppShell/components/Header.tsx
|
|
581
|
+
const NavBar = ({ config }) => {
|
|
582
|
+
const { modules = [] } = config;
|
|
583
|
+
const router = useRouter();
|
|
584
|
+
const modulePath = useModulePath_default(config);
|
|
585
|
+
const { data: ocels } = useGetOcels();
|
|
586
|
+
const isOcelAvailable = ocels?.length !== 0;
|
|
587
|
+
return /* @__PURE__ */ jsx(AppShell.Navbar, {
|
|
588
|
+
className: AppShell_module_default["navbar"] ?? "",
|
|
589
|
+
children: /* @__PURE__ */ jsxs(Stack, {
|
|
590
|
+
justify: "space-between",
|
|
591
|
+
h: "100%",
|
|
592
|
+
gap: 0,
|
|
593
|
+
children: [/* @__PURE__ */ jsxs(Stack, {
|
|
594
|
+
gap: 0,
|
|
595
|
+
flex: 1,
|
|
596
|
+
children: [
|
|
597
|
+
/* @__PURE__ */ jsx(NavLink, {
|
|
598
|
+
component: Link,
|
|
599
|
+
href: "/",
|
|
600
|
+
label: "Home",
|
|
601
|
+
leftSection: /* @__PURE__ */ jsx(HomeIcon, { size: 16 }),
|
|
602
|
+
active: router.asPath === "/"
|
|
603
|
+
}),
|
|
604
|
+
/* @__PURE__ */ jsx(Divider, {}),
|
|
605
|
+
modules.map(({ label, name, icon: Icon = PackageIcon, routes }) => {
|
|
606
|
+
const isModuleDisabled = !Object.values(routes).some(({ requiresOcel }) => !requiresOcel) && !isOcelAvailable;
|
|
607
|
+
return /* @__PURE__ */ jsx(NavLink, {
|
|
608
|
+
leftSection: /* @__PURE__ */ jsx(Icon, {
|
|
609
|
+
width: 18,
|
|
610
|
+
height: 18,
|
|
611
|
+
size: 18
|
|
612
|
+
}),
|
|
613
|
+
label,
|
|
614
|
+
defaultOpened: name === modulePath?.moduleName,
|
|
615
|
+
component: Link,
|
|
616
|
+
href: getModuleRoute({
|
|
617
|
+
moduleName: name,
|
|
618
|
+
routeName: routes[0]?.name ?? ""
|
|
619
|
+
}),
|
|
620
|
+
disabled: isModuleDisabled,
|
|
621
|
+
...isModuleDisabled ? { opened: false } : {},
|
|
622
|
+
active: Object.keys(routes).length === 1 && name === modulePath?.moduleName,
|
|
623
|
+
children: Object.keys(routes).length > 1 && Object.values(routes).map(({ label: routeLabel, name: routeName, requiresOcel }) => /* @__PURE__ */ jsx(NavLink, {
|
|
624
|
+
label: routeLabel,
|
|
625
|
+
href: getModuleRoute({
|
|
626
|
+
moduleName: name,
|
|
627
|
+
routeName
|
|
628
|
+
}),
|
|
629
|
+
disabled: !!requiresOcel && !isOcelAvailable,
|
|
630
|
+
component: Link,
|
|
631
|
+
active: name === modulePath?.moduleName && routeName === modulePath.moduleName
|
|
632
|
+
}, routeName))
|
|
633
|
+
}, name);
|
|
634
|
+
})
|
|
635
|
+
]
|
|
636
|
+
}), /* @__PURE__ */ jsx(Divider, {})]
|
|
637
|
+
})
|
|
638
|
+
});
|
|
639
|
+
};
|
|
640
|
+
var Header_default = NavBar;
|
|
641
|
+
|
|
642
|
+
//#endregion
|
|
643
|
+
//#region src/components/AppShell/AppShell.tsx
|
|
644
|
+
const AppShell$1 = ({ config, children }) => {
|
|
645
|
+
const [mobileOpened, { toggle: toggleMobile }] = useDisclosure(true);
|
|
646
|
+
const [desktopOpened, { toggle: toggleDesktop }] = useDisclosure(true);
|
|
647
|
+
const [isUploadModalVisible, setIsUploadModalVisible] = useState(false);
|
|
648
|
+
return /* @__PURE__ */ jsxs(AppShell, {
|
|
649
|
+
header: { height: 60 },
|
|
650
|
+
navbar: {
|
|
651
|
+
width: 300,
|
|
652
|
+
breakpoint: "sm",
|
|
653
|
+
collapsed: {
|
|
654
|
+
mobile: !mobileOpened,
|
|
655
|
+
desktop: !desktopOpened
|
|
656
|
+
}
|
|
657
|
+
},
|
|
658
|
+
padding: "md",
|
|
659
|
+
children: [
|
|
660
|
+
/* @__PURE__ */ jsx(AppShell.Header, { children: /* @__PURE__ */ jsxs(Group, {
|
|
661
|
+
h: "100%",
|
|
662
|
+
px: "md",
|
|
663
|
+
justify: "space-between",
|
|
664
|
+
children: [/* @__PURE__ */ jsxs(Group, {
|
|
665
|
+
align: "center",
|
|
666
|
+
children: [/* @__PURE__ */ jsx(Burger, {
|
|
667
|
+
opened: mobileOpened,
|
|
668
|
+
onClick: toggleMobile,
|
|
669
|
+
hiddenFrom: "sm",
|
|
670
|
+
size: "sm"
|
|
671
|
+
}), /* @__PURE__ */ jsx(Burger, {
|
|
672
|
+
opened: desktopOpened,
|
|
673
|
+
onClick: toggleDesktop,
|
|
674
|
+
visibleFrom: "sm",
|
|
675
|
+
size: "sm"
|
|
676
|
+
})]
|
|
677
|
+
}), /* @__PURE__ */ jsxs(Group, { children: [
|
|
678
|
+
/* @__PURE__ */ jsx(CurrentOcelSelect, {}),
|
|
679
|
+
/* @__PURE__ */ jsx(Button, {
|
|
680
|
+
leftSection: /* @__PURE__ */ jsx(UploadIcon, { size: 18 }),
|
|
681
|
+
onClick: () => setIsUploadModalVisible(true),
|
|
682
|
+
children: "Upload"
|
|
683
|
+
}),
|
|
684
|
+
/* @__PURE__ */ jsx(UploadModal_default, {
|
|
685
|
+
visible: isUploadModalVisible,
|
|
686
|
+
onClose: () => setIsUploadModalVisible(false)
|
|
687
|
+
})
|
|
688
|
+
] })]
|
|
689
|
+
}) }),
|
|
690
|
+
/* @__PURE__ */ jsx(Header_default, { config }),
|
|
691
|
+
/* @__PURE__ */ jsx(AppShell.Main, {
|
|
692
|
+
style: { overflow: "hidden" },
|
|
693
|
+
h: "calc(100dvh - var(--app-shell-header-offset, 0rem) - var(--app-shell-footer-height, 0px) + var(--app-shell-padding, 0))",
|
|
694
|
+
children: /* @__PURE__ */ jsx(Box, {
|
|
695
|
+
h: "100%",
|
|
696
|
+
style: {
|
|
697
|
+
overflow: "scroll",
|
|
698
|
+
position: "relative"
|
|
699
|
+
},
|
|
700
|
+
children
|
|
701
|
+
})
|
|
702
|
+
})
|
|
703
|
+
]
|
|
704
|
+
});
|
|
705
|
+
};
|
|
706
|
+
|
|
707
|
+
//#endregion
|
|
708
|
+
//#region src/components/OcelescopeApp.tsx
|
|
709
|
+
const OcelescopeApp = (config) => ({ Component, pageProps }) => {
|
|
710
|
+
const [client] = useState(() => new QueryClient());
|
|
711
|
+
return /* @__PURE__ */ jsxs(QueryClientProvider, {
|
|
712
|
+
client,
|
|
713
|
+
children: [/* @__PURE__ */ jsx(HydrationBoundary, {
|
|
714
|
+
state: pageProps.dehydratedState,
|
|
715
|
+
children: /* @__PURE__ */ jsx(MantineProvider, { children: /* @__PURE__ */ jsx(AppShell$1, {
|
|
716
|
+
config,
|
|
717
|
+
children: /* @__PURE__ */ jsx(Component, { ...pageProps })
|
|
718
|
+
}) })
|
|
719
|
+
}), /* @__PURE__ */ jsx(ReactQueryDevtools, {})]
|
|
720
|
+
});
|
|
721
|
+
};
|
|
722
|
+
|
|
723
|
+
//#endregion
|
|
724
|
+
//#region src/components/OcelescopeDocument.tsx
|
|
725
|
+
const OcelescopeDocument = () => {
|
|
726
|
+
return /* @__PURE__ */ jsxs(Html, {
|
|
727
|
+
lang: "en",
|
|
728
|
+
...mantineHtmlProps,
|
|
729
|
+
children: [/* @__PURE__ */ jsx(Head, { children: /* @__PURE__ */ jsx(ColorSchemeScript, { defaultColorScheme: "auto" }) }), /* @__PURE__ */ jsxs("body", { children: [/* @__PURE__ */ jsx(Main, {}), /* @__PURE__ */ jsx(NextScript, {})] })]
|
|
730
|
+
});
|
|
731
|
+
};
|
|
732
|
+
|
|
733
|
+
//#endregion
|
|
734
|
+
//#region src/lib/config.ts
|
|
735
|
+
const defineModule = (def) => def;
|
|
736
|
+
const defineModuleRoute = (def) => def;
|
|
737
|
+
|
|
738
|
+
//#endregion
|
|
739
|
+
export { OcelescopeApp, OcelescopeDocument, createModulesPage, defineModule, defineModuleRoute, getModuleRoute, useCurrentOcel };
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ocelescope/core",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "0.0.
|
|
4
|
+
"version": "0.0.1",
|
|
5
5
|
"description": "Core React component and style library for Ocelescope (Mantine + React Query).",
|
|
6
6
|
"author": "Görkem-Emre Öztürk <goerkem.oeztuerk@rwth-aachen.de>",
|
|
7
7
|
"license": "MIT",
|
|
@@ -31,7 +31,7 @@
|
|
|
31
31
|
"@mantine/core": "^8.3.14",
|
|
32
32
|
"@mantine/dropzone": "^8.3.14",
|
|
33
33
|
"@mantine/hooks": "^8.3.14",
|
|
34
|
-
"@tanstack/react-query": "^5.90.
|
|
34
|
+
"@tanstack/react-query": "^5.90.21",
|
|
35
35
|
"@tanstack/react-query-devtools": "^5.91.3",
|
|
36
36
|
"content-disposition-attachment": "^0.3.1",
|
|
37
37
|
"clsx": "^2.1.1",
|
|
@@ -46,8 +46,8 @@
|
|
|
46
46
|
"@marko19907/string-to-color": "^1.0.2",
|
|
47
47
|
"dayjs": "^1.11.19",
|
|
48
48
|
"@ocelescope/api-base": "0.0.0",
|
|
49
|
-
"@ocelescope/
|
|
50
|
-
"@ocelescope/
|
|
49
|
+
"@ocelescope/resources": "0.0.0",
|
|
50
|
+
"@ocelescope/api-client": "0.0.0"
|
|
51
51
|
},
|
|
52
52
|
"devDependencies": {
|
|
53
53
|
"@tsconfig/strictest": "^2.0.8",
|