@gadmin2n/schematics 0.0.65 → 0.0.67
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/lib/application/files/gadmin2-game-angle-demo/config/prisma/system.prisma +7 -0
- package/dist/lib/application/files/gadmin2-game-angle-demo/server/package.json +3 -3
- package/dist/lib/application/files/gadmin2-game-angle-demo/web/package.json +4 -4
- package/dist/lib/application/files/gadmin2-game-angle-demo/web/src/authProvider.ts +2 -2
- package/dist/lib/application/files/gadmin2-game-angle-demo/web/src/components/SqlModal.tsx +419 -0
- package/dist/lib/application/files/gadmin2-game-angle-demo/web/src/components/contexts/business/index.tsx +1 -1
- package/dist/lib/application/files/gadmin2-game-angle-demo/web/src/components/custom-avatar.tsx +1 -1
- package/dist/lib/application/files/gadmin2-game-angle-demo/web/src/config/http.ts +28 -0
- package/dist/lib/application/files/gadmin2-game-angle-demo/web/src/config/routeRegistry.tsx +1 -1
- package/dist/lib/application/files/gadmin2-game-angle-demo/web/src/helpers/http.ts +87 -0
- package/dist/lib/application/files/gadmin2-game-angle-demo/web/src/helpers/index.tsx +6 -1
- package/dist/lib/application/files/gadmin2-game-angle-demo/web/src/helpers/login.ts +22 -77
- package/dist/lib/application/files/gadmin2-game-angle-demo/web/src/{utilities → helpers}/utils.tsx +1 -1
- package/dist/lib/application/files/gadmin2-game-angle-demo/web/src/routes/audit/components/action-cell.tsx +1 -1
- package/dist/lib/application/files/gadmin2-game-angle-demo/web/src/routes/page/Components/AssignRolesModal.tsx +3 -3
- package/dist/lib/application/files/gadmin2-game-angle-demo/web/src/routes/page/Components/PageDetailDrawer.tsx +1 -1
- package/dist/lib/application/files/gadmin2-game-angle-demo/web/src/routes/page/Components/PageFormModal.tsx +1 -1
- package/dist/lib/application/files/gadmin2-game-angle-demo/web/src/routes/page/hooks/usePageManagement.ts +1 -1
- package/dist/lib/application/files/gadmin2-game-angle-demo/web/src/routes/page/index.ts +0 -7
- package/dist/lib/application/files/gadmin2-game-angle-demo/web/src/routes/page/list.tsx +110 -8
- package/dist/lib/application/files/gadmin2-game-angle-demo/web/src/routes/page/types.ts +1 -0
- package/dist/lib/application/files/gadmin2-game-angle-demo/web/src/routes/{permission-readme → permissionReadme}/index.tsx +4 -3
- package/dist/lib/application/files/gadmin2-game-angle-demo/web/src/routes/resource/Components/ResourceDetailDrawer.tsx +1 -1
- package/dist/lib/application/files/gadmin2-game-angle-demo/web/src/routes/resource/index.ts +0 -7
- package/dist/lib/application/files/gadmin2-game-angle-demo/web/src/routes/resource/list.tsx +32 -4
- package/dist/lib/application/files/gadmin2-game-angle-demo/web/src/routes/role/Components/RoleDetailDrawer.tsx +1 -1
- package/dist/lib/application/files/gadmin2-game-angle-demo/web/src/routes/role/Components/modal.tsx +1 -1
- package/dist/lib/application/files/gadmin2-game-angle-demo/web/src/routes/role/hooks/useRolePage.ts +1 -1
- package/dist/lib/application/files/gadmin2-game-angle-demo/web/src/routes/role/index.ts +1 -8
- package/dist/lib/application/files/gadmin2-game-angle-demo/web/src/routes/role/list.tsx +52 -3
- package/dist/lib/application/files/gadmin2-game-angle-demo/web/src/routes/user/components/form-modal.tsx +2 -2
- package/dist/lib/application/files/gadmin2-game-angle-demo/web/src/routes/user/components/show-drawer.tsx +2 -2
- package/dist/lib/application/files/gadmin2-game-angle-demo/web/src/routes/user/index.ts +1 -8
- package/dist/lib/application/files/gadmin2-game-angle-demo/web/src/routes/user/list.tsx +41 -11
- package/dist/lib/application/files/gadmin2-game-angle-demo/web/tsconfig.json +2 -1
- package/dist/lib/application/files/gadmin2-game-angle-demo/web/yarn.lock +8321 -0
- package/package.json +1 -1
- package/dist/lib/application/files/gadmin2-game-angle-demo/web/src/helpers/utils.ts +0 -76
- package/dist/lib/application/files/gadmin2-game-angle-demo/web/src/routes/page/create.tsx +0 -113
- package/dist/lib/application/files/gadmin2-game-angle-demo/web/src/routes/page/edit.tsx +0 -122
- package/dist/lib/application/files/gadmin2-game-angle-demo/web/src/routes/page/index.tsx +0 -6
- package/dist/lib/application/files/gadmin2-game-angle-demo/web/src/routes/page/show.tsx +0 -61
- package/dist/lib/application/files/gadmin2-game-angle-demo/web/src/routes/pageResource/create.tsx +0 -113
- package/dist/lib/application/files/gadmin2-game-angle-demo/web/src/routes/pageResource/edit.tsx +0 -122
- package/dist/lib/application/files/gadmin2-game-angle-demo/web/src/routes/pageResource/index.tsx +0 -6
- package/dist/lib/application/files/gadmin2-game-angle-demo/web/src/routes/pageResource/list.tsx +0 -243
- package/dist/lib/application/files/gadmin2-game-angle-demo/web/src/routes/pageResource/show.tsx +0 -61
- package/dist/lib/application/files/gadmin2-game-angle-demo/web/src/routes/resource/create.tsx +0 -113
- package/dist/lib/application/files/gadmin2-game-angle-demo/web/src/routes/resource/edit.tsx +0 -122
- package/dist/lib/application/files/gadmin2-game-angle-demo/web/src/routes/resource/index.tsx +0 -6
- package/dist/lib/application/files/gadmin2-game-angle-demo/web/src/routes/resource/show.tsx +0 -61
- package/dist/lib/application/files/gadmin2-game-angle-demo/web/src/routes/role/create.tsx +0 -113
- package/dist/lib/application/files/gadmin2-game-angle-demo/web/src/routes/role/edit.tsx +0 -122
- package/dist/lib/application/files/gadmin2-game-angle-demo/web/src/routes/role/index.tsx +0 -6
- package/dist/lib/application/files/gadmin2-game-angle-demo/web/src/routes/role/show.tsx +0 -61
- package/dist/lib/application/files/gadmin2-game-angle-demo/web/src/routes/rolePages/create.tsx +0 -113
- package/dist/lib/application/files/gadmin2-game-angle-demo/web/src/routes/rolePages/edit.tsx +0 -122
- package/dist/lib/application/files/gadmin2-game-angle-demo/web/src/routes/rolePages/index.tsx +0 -6
- package/dist/lib/application/files/gadmin2-game-angle-demo/web/src/routes/rolePages/list.tsx +0 -243
- package/dist/lib/application/files/gadmin2-game-angle-demo/web/src/routes/rolePages/show.tsx +0 -61
- package/dist/lib/application/files/gadmin2-game-angle-demo/web/src/routes/roleResource/create.tsx +0 -113
- package/dist/lib/application/files/gadmin2-game-angle-demo/web/src/routes/roleResource/edit.tsx +0 -122
- package/dist/lib/application/files/gadmin2-game-angle-demo/web/src/routes/roleResource/index.tsx +0 -6
- package/dist/lib/application/files/gadmin2-game-angle-demo/web/src/routes/roleResource/list.tsx +0 -243
- package/dist/lib/application/files/gadmin2-game-angle-demo/web/src/routes/roleResource/show.tsx +0 -61
- package/dist/lib/application/files/gadmin2-game-angle-demo/web/src/routes/user/create.tsx +0 -113
- package/dist/lib/application/files/gadmin2-game-angle-demo/web/src/routes/user/edit.tsx +0 -122
- package/dist/lib/application/files/gadmin2-game-angle-demo/web/src/routes/user/index.tsx +0 -6
- package/dist/lib/application/files/gadmin2-game-angle-demo/web/src/routes/user/show.tsx +0 -61
- package/dist/lib/application/files/gadmin2-game-angle-demo/web/src/utilities/index.ts +0 -2
- /package/dist/lib/application/files/gadmin2-game-angle-demo/web/src/{utilities → helpers}/get-name-initials.ts +0 -0
- /package/dist/lib/application/files/gadmin2-game-angle-demo/web/src/{utilities → helpers}/get-random-color.ts +0 -0
|
@@ -1,17 +1,20 @@
|
|
|
1
1
|
import React, { useCallback, useMemo, useState } from "react";
|
|
2
2
|
import { useTable } from "@refinedev/antd";
|
|
3
|
-
import { useGetLocale } from "@refinedev/core";
|
|
4
|
-
import { Table, Button, Space, Tooltip } from "antd";
|
|
3
|
+
import { useGetLocale, useGetIdentity } from "@refinedev/core";
|
|
4
|
+
import { Table, Button, Space, Tooltip, message } from "antd";
|
|
5
5
|
|
|
6
6
|
import { EditModal } from "./Components/EditModal";
|
|
7
7
|
import { CreateModal } from "./Components/CreateModal";
|
|
8
8
|
import type { RolePageTreeNode } from "./types";
|
|
9
9
|
import { useRolePage } from "./hooks/useRolePage";
|
|
10
|
-
import { EditOutlined, EyeOutlined } from "@ant-design/icons";
|
|
10
|
+
import { EditOutlined, EyeOutlined, CodeOutlined } from "@ant-design/icons";
|
|
11
11
|
import { RoleDetailDrawer } from "./Components/RoleDetailDrawer";
|
|
12
|
+
import { SqlModal, generateRoleSql } from "../../components/SqlModal";
|
|
13
|
+
import { customRequest } from "@/helpers/http";
|
|
12
14
|
|
|
13
15
|
type RolePageInfo = {
|
|
14
16
|
id: number;
|
|
17
|
+
code: string;
|
|
15
18
|
name: string;
|
|
16
19
|
menuPath: string;
|
|
17
20
|
};
|
|
@@ -74,6 +77,7 @@ const extractActionsFromRelation = (relation: any, pageRecord: any): string[] =>
|
|
|
74
77
|
export const RoleManagementListPage: React.FC = () => {
|
|
75
78
|
const getLocale = useGetLocale();
|
|
76
79
|
const currentLocale = getLocale();
|
|
80
|
+
const { data: identity } = useGetIdentity<any>();
|
|
77
81
|
|
|
78
82
|
const { tableProps } = useTable({
|
|
79
83
|
resource: "role",
|
|
@@ -241,6 +245,7 @@ export const RoleManagementListPage: React.FC = () => {
|
|
|
241
245
|
if (!summary.pageInfos.some(p => p.id === pageId)) {
|
|
242
246
|
summary.pageInfos.push({
|
|
243
247
|
id: pageId,
|
|
248
|
+
code: pageRecord?.code ?? "",
|
|
244
249
|
name: localizedName,
|
|
245
250
|
menuPath: buildMenuPath(pageId),
|
|
246
251
|
});
|
|
@@ -296,6 +301,36 @@ export const RoleManagementListPage: React.FC = () => {
|
|
|
296
301
|
id: null,
|
|
297
302
|
});
|
|
298
303
|
|
|
304
|
+
const [sqlModal, setSqlModal] = useState<{
|
|
305
|
+
open: boolean;
|
|
306
|
+
title: string;
|
|
307
|
+
sql: string;
|
|
308
|
+
}>({ open: false, title: "", sql: "" });
|
|
309
|
+
|
|
310
|
+
const handleShowSql = useCallback(async (record: any) => {
|
|
311
|
+
const summary = rolePermissionSummary[record.id];
|
|
312
|
+
const rolePages = summary?.pageInfos?.map(p => ({ pageId: p.id, pageCode: p.code, pageName: p.name })) ?? [];
|
|
313
|
+
|
|
314
|
+
let roleResources: Array<{ resourceCode: string; resourceName: string; actions: string[] }> = [];
|
|
315
|
+
try {
|
|
316
|
+
const resp: any = await customRequest("roleResource/findMany", "post", {
|
|
317
|
+
where: { roleId: record.id },
|
|
318
|
+
include: { resource: true },
|
|
319
|
+
});
|
|
320
|
+
const items: any[] = Array.isArray(resp?.data) ? resp.data : [];
|
|
321
|
+
roleResources = items.map(item => ({
|
|
322
|
+
resourceCode: item.resource?.code ?? String(item.resourceId),
|
|
323
|
+
resourceName: item.resource?.name ?? String(item.resourceId),
|
|
324
|
+
actions: Array.isArray(item.actions) ? item.actions : [],
|
|
325
|
+
}));
|
|
326
|
+
} catch {
|
|
327
|
+
message.warning("Could not fetch role resource details; SQL will omit permissions.");
|
|
328
|
+
}
|
|
329
|
+
|
|
330
|
+
const sql = generateRoleSql(record, rolePages, roleResources, { authorId: identity?.userid, authorName: identity?.username });
|
|
331
|
+
setSqlModal({ open: true, title: `SQL — Role: ${record.name}`, sql });
|
|
332
|
+
}, [rolePermissionSummary]);
|
|
333
|
+
|
|
299
334
|
const refreshRoleRelatedData = useCallback(() => {
|
|
300
335
|
refetchRolePages(rolePagesQuery ?? {});
|
|
301
336
|
refetchPages(pageQuery ?? {});
|
|
@@ -349,6 +384,14 @@ export const RoleManagementListPage: React.FC = () => {
|
|
|
349
384
|
onClick={() => setShowModal({ type: "edit", id: record.id })}
|
|
350
385
|
/>
|
|
351
386
|
</Tooltip>
|
|
387
|
+
<Tooltip title="Generate SQL">
|
|
388
|
+
<Button
|
|
389
|
+
type="default"
|
|
390
|
+
size="small"
|
|
391
|
+
icon={<CodeOutlined />}
|
|
392
|
+
onClick={() => handleShowSql(record)}
|
|
393
|
+
/>
|
|
394
|
+
</Tooltip>
|
|
352
395
|
</Space>
|
|
353
396
|
)}
|
|
354
397
|
/>
|
|
@@ -377,6 +420,12 @@ export const RoleManagementListPage: React.FC = () => {
|
|
|
377
420
|
pageTreeData={pageTreeData}
|
|
378
421
|
/>
|
|
379
422
|
)}
|
|
423
|
+
<SqlModal
|
|
424
|
+
open={sqlModal.open}
|
|
425
|
+
onClose={() => setSqlModal({ open: false, title: "", sql: "" })}
|
|
426
|
+
title={sqlModal.title}
|
|
427
|
+
sql={sqlModal.sql}
|
|
428
|
+
/>
|
|
380
429
|
</div>
|
|
381
430
|
);
|
|
382
431
|
};
|
|
@@ -6,8 +6,8 @@ import { type HttpError, type RedirectAction } from "@refinedev/core";
|
|
|
6
6
|
import { Button, Form, Input, Modal, Select, Space, Switch } from "antd";
|
|
7
7
|
import { ReloadOutlined } from "@ant-design/icons";
|
|
8
8
|
|
|
9
|
-
import { useRoles } from "hooks/useRoles";
|
|
10
|
-
import { User } from "types";
|
|
9
|
+
import { useRoles } from "@/hooks/useRoles";
|
|
10
|
+
import { User } from "@/types";
|
|
11
11
|
|
|
12
12
|
import { UserSelect } from "../queries";
|
|
13
13
|
|
|
@@ -7,8 +7,8 @@ import { CloseOutlined } from "@ant-design/icons";
|
|
|
7
7
|
import { Button, Drawer, Space, Tag, Typography } from "antd";
|
|
8
8
|
import dayjs from "dayjs";
|
|
9
9
|
|
|
10
|
-
import styles from "styles/show-drawer.module.css";
|
|
11
|
-
import { User } from "types";
|
|
10
|
+
import styles from "@/styles/show-drawer.module.css";
|
|
11
|
+
import { User } from "@/types";
|
|
12
12
|
|
|
13
13
|
import { UserSelect } from "../queries";
|
|
14
14
|
|
|
@@ -1,8 +1 @@
|
|
|
1
|
-
export * from "./list";
|
|
2
|
-
|
|
3
|
-
// Stub exports for generated/resources.tsx compatibility
|
|
4
|
-
const EmptyComponent = () => null;
|
|
5
|
-
export const UserCreate = EmptyComponent;
|
|
6
|
-
export const UserEdit = EmptyComponent;
|
|
7
|
-
export const UserList = EmptyComponent;
|
|
8
|
-
export const UserShow = EmptyComponent;
|
|
1
|
+
export * from "./list";
|
|
@@ -8,10 +8,10 @@ import {
|
|
|
8
8
|
ShowButton,
|
|
9
9
|
useTable,
|
|
10
10
|
} from "@refinedev/antd";
|
|
11
|
-
import { getDefaultFilter, type HttpError } from "@refinedev/core";
|
|
11
|
+
import { getDefaultFilter, type HttpError, useGetIdentity } from "@refinedev/core";
|
|
12
12
|
|
|
13
|
-
import { PlusOutlined } from "@ant-design/icons";
|
|
14
|
-
import { Button, Form, Input, Select, Space, Table, Tag } from "antd";
|
|
13
|
+
import { PlusOutlined, CodeOutlined } from "@ant-design/icons";
|
|
14
|
+
import { Button, Form, Input, Select, Space, Table, Tag, Tooltip } from "antd";
|
|
15
15
|
import debounce from "lodash/debounce";
|
|
16
16
|
|
|
17
17
|
import {
|
|
@@ -19,17 +19,19 @@ import {
|
|
|
19
19
|
PaginationTotal,
|
|
20
20
|
RoleStatusTag,
|
|
21
21
|
Text,
|
|
22
|
-
} from "components";
|
|
23
|
-
import { useRoles } from "hooks/useRoles";
|
|
24
|
-
import { User } from "types";
|
|
22
|
+
} from "@/components";
|
|
23
|
+
import { useRoles } from "@/hooks/useRoles";
|
|
24
|
+
import { User } from "@/types";
|
|
25
25
|
|
|
26
26
|
import { CreateModal } from "./components/create-modal";
|
|
27
27
|
import { EditModal } from "./components/edit-modal";
|
|
28
28
|
import { ShowDrawer } from "./components/show-drawer";
|
|
29
|
-
import { LIST_CONTENT_PROPS } from "constants/layout";
|
|
29
|
+
import { LIST_CONTENT_PROPS } from "@/constants/layout";
|
|
30
|
+
import { SqlModal, generateUserSql } from "../../components/SqlModal";
|
|
30
31
|
|
|
31
32
|
export const UserListPage: React.FC<PropsWithChildren> = ({ children }) => {
|
|
32
33
|
const [form] = Form.useForm();
|
|
34
|
+
const { data: identity } = useGetIdentity<any>();
|
|
33
35
|
|
|
34
36
|
// Fetch roles from backend using custom hook
|
|
35
37
|
const { roleOptions, loading: rolesLoading } = useRoles();
|
|
@@ -116,6 +118,18 @@ export const UserListPage: React.FC<PropsWithChildren> = ({ children }) => {
|
|
|
116
118
|
id: null,
|
|
117
119
|
});
|
|
118
120
|
|
|
121
|
+
const [sqlModal, setSqlModal] = useState<{
|
|
122
|
+
open: boolean;
|
|
123
|
+
title: string;
|
|
124
|
+
sql: string;
|
|
125
|
+
}>({ open: false, title: "", sql: "" });
|
|
126
|
+
|
|
127
|
+
const handleShowSql = (record: any) => {
|
|
128
|
+
const operator = { authorId: identity?.userid, authorName: identity?.username };
|
|
129
|
+
const sql = generateUserSql(record, operator);
|
|
130
|
+
setSqlModal({ open: true, title: `SQL — User: ${record.userid}`, sql });
|
|
131
|
+
};
|
|
132
|
+
|
|
119
133
|
// 处理modal关闭
|
|
120
134
|
const handleModalClose = () => {
|
|
121
135
|
setShowModal({ type: null, id: null });
|
|
@@ -169,7 +183,7 @@ export const UserListPage: React.FC<PropsWithChildren> = ({ children }) => {
|
|
|
169
183
|
title="User Name"
|
|
170
184
|
filterDropdown={(props) => (
|
|
171
185
|
<FilterDropdown
|
|
172
|
-
{...
|
|
186
|
+
{...props}
|
|
173
187
|
clearFilters={() => {
|
|
174
188
|
props.setSelectedKeys([]);
|
|
175
189
|
props.confirm?.();
|
|
@@ -195,7 +209,7 @@ export const UserListPage: React.FC<PropsWithChildren> = ({ children }) => {
|
|
|
195
209
|
)}
|
|
196
210
|
filterDropdown={(props) => (
|
|
197
211
|
<FilterDropdown
|
|
198
|
-
{...
|
|
212
|
+
{...props}
|
|
199
213
|
clearFilters={() => {
|
|
200
214
|
props.setSelectedKeys([]);
|
|
201
215
|
props.confirm?.();
|
|
@@ -223,7 +237,7 @@ export const UserListPage: React.FC<PropsWithChildren> = ({ children }) => {
|
|
|
223
237
|
defaultFilteredValue={getDefaultFilter("isApiKey", filters, "eq")}
|
|
224
238
|
filterDropdown={(props) => (
|
|
225
239
|
<FilterDropdown
|
|
226
|
-
{...
|
|
240
|
+
{...props}
|
|
227
241
|
mapValue={(selectedKeys) => {
|
|
228
242
|
if (selectedKeys?.[0] === "Yes") return true;
|
|
229
243
|
if (selectedKeys?.[0] === "No") return false;
|
|
@@ -257,7 +271,7 @@ export const UserListPage: React.FC<PropsWithChildren> = ({ children }) => {
|
|
|
257
271
|
defaultFilteredValue={getDefaultFilter("isActive", filters, "eq")}
|
|
258
272
|
filterDropdown={(props) => (
|
|
259
273
|
<FilterDropdown
|
|
260
|
-
{...
|
|
274
|
+
{...props}
|
|
261
275
|
mapValue={(selectedKeys) => {
|
|
262
276
|
if (selectedKeys?.[0] === "Active") return true;
|
|
263
277
|
if (selectedKeys?.[0] === "Inactive") return false;
|
|
@@ -308,6 +322,14 @@ export const UserListPage: React.FC<PropsWithChildren> = ({ children }) => {
|
|
|
308
322
|
setShowModal({ type: "edit", id: record.id })
|
|
309
323
|
}
|
|
310
324
|
/>
|
|
325
|
+
<Tooltip title="Generate SQL">
|
|
326
|
+
<Button
|
|
327
|
+
size="small"
|
|
328
|
+
icon={<CodeOutlined />}
|
|
329
|
+
style={{ backgroundColor: "transparent" }}
|
|
330
|
+
onClick={() => handleShowSql(record)}
|
|
331
|
+
/>
|
|
332
|
+
</Tooltip>
|
|
311
333
|
<DeleteButton
|
|
312
334
|
hideText
|
|
313
335
|
size="small"
|
|
@@ -336,6 +358,14 @@ export const UserListPage: React.FC<PropsWithChildren> = ({ children }) => {
|
|
|
336
358
|
<CreateModal onClose={handleModalClose} />
|
|
337
359
|
)}
|
|
338
360
|
|
|
361
|
+
{/* SQL Modal */}
|
|
362
|
+
<SqlModal
|
|
363
|
+
open={sqlModal.open}
|
|
364
|
+
onClose={() => setSqlModal({ open: false, title: "", sql: "" })}
|
|
365
|
+
title={sqlModal.title}
|
|
366
|
+
sql={sqlModal.sql}
|
|
367
|
+
/>
|
|
368
|
+
|
|
339
369
|
{children}
|
|
340
370
|
</div>
|
|
341
371
|
);
|