Skip to content

Commit

Permalink
[Featue] support resource file copy path (#3188)
Browse files Browse the repository at this point in the history
Co-authored-by: Zzm0809 <[email protected]>
  • Loading branch information
Zzm0809 and Zzm0809 authored Feb 27, 2024
1 parent 4ffb933 commit 81689c1
Show file tree
Hide file tree
Showing 9 changed files with 95 additions and 76 deletions.
2 changes: 1 addition & 1 deletion dinky-admin/src/main/resources/db/db-h2-ddl.sql
Original file line number Diff line number Diff line change
Expand Up @@ -469,7 +469,7 @@ CREATE TABLE `dinky_resources` (
`type` tinyint(4) DEFAULT null COMMENT 'resource type,0:FILE,1:UDF',
`size` bigint(20) DEFAULT null COMMENT 'resource size',
`pid` int(11) DEFAULT null,
`full_name` varchar(128) DEFAULT null,
`full_name` text DEFAULT null,
`is_directory` tinyint(4) DEFAULT null,
`create_time` datetime NOT null DEFAULT CURRENT_TIMESTAMP COMMENT 'create time',
`update_time` datetime NOT null DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT 'update time',
Expand Down
2 changes: 2 additions & 0 deletions dinky-web/src/locales/en-US/pages.ts
Original file line number Diff line number Diff line change
Expand Up @@ -975,6 +975,8 @@ export default {
'Support for a single or bulk upload. Strictly prohibited from uploading company data or\n other banned files.',
'rc.resource.filelist': 'File list',
'rc.resource.sync': 'Sync remote files',
'rc.resource.copy': 'Copy as: {fillValue}',

'rc.template.codeType': 'Code Type',
'rc.template.codeTypePlaceholder': 'Please select code type! ',
'rc.template.create': 'Create UDF Template',
Expand Down
1 change: 1 addition & 0 deletions dinky-web/src/locales/zh-CN/pages.ts
Original file line number Diff line number Diff line change
Expand Up @@ -934,6 +934,7 @@ export default {
'rc.resource.upload.tip2': '支持单个或批量上传。严禁上传公司数据或其他禁止上传的文件。',
'rc.resource.filelist': '文件列表',
'rc.resource.sync': '同步目录结构',
'rc.resource.copy': '复制为: {fillValue}',

'rc.template.codeType': '代码类型',
'rc.template.codeTypePlaceholder': '请选择代码类型!',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,22 @@ import { TagAlignCenter } from '@/components/StyledComponents';
import { ResourceInfo } from '@/types/RegCenter/data';
import { parseByteStr, renderIcon } from '@/utils/function';
import { l } from '@/utils/intl';
import { Typography } from 'antd';

const buildTitleLabel = (showCopy = false, item: ResourceInfo) => {
const fillValue = `ADD FILE 'rs:${item.fullName}';`;

const buildTitleLabel = (item: ResourceInfo) => {
return (
<>
{item.fileName}
{!item.isDirectory && showCopy ? (
<Typography.Text
copyable={{ text: fillValue, tooltips: l('rc.resource.copy', '', { fillValue }) }}
>
{item.fileName}
</Typography.Text>
) : (
item.fileName
)}
{!item.isDirectory && (
<span style={{ color: 'gray' }}>
{' '}
Expand Down Expand Up @@ -79,9 +90,10 @@ function filterEmpty(
}

export const buildResourceTreeData = (
data: ResourceInfo[],
data: ResourceInfo[] = [],
isFilterEmptyChildren = false,
filterSuffixList: string[] = []
filterSuffixList: string[] = [],
showCopy: boolean = false
): any =>
data
.filter((item: ResourceInfo) => filterEmpty(isFilterEmptyChildren, item, filterSuffixList))
Expand All @@ -90,13 +102,15 @@ export const buildResourceTreeData = (
isLeaf: !item.isDirectory,
name: item.fileName,
parentId: item.pid,
label: item.fullName + '/' + item.fileName,
label: item.fileName,
icon: <TagAlignCenter>{renderIcon(item.fileName, '.', item.isDirectory)}</TagAlignCenter>,
path: item.fullName,
title: buildTitleLabel(item),
title: buildTitleLabel(showCopy, item),
fullInfo: item,
key: item.id,
id: item.id,
children: item.children && buildResourceTreeData(item.children, isFilterEmptyChildren)
children:
item.children &&
buildResourceTreeData(item.children, isFilterEmptyChildren, filterSuffixList, showCopy)
};
});
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ const FileTree: React.FC<FileTreeProps> = (props) => {
selectedKeys={selectedKeys}
onSelect={(_, info) => onNodeClick(info)}
onRightClick={(info) => onRightClick(info)}
treeData={buildResourceTreeData(treeData)}
treeData={buildResourceTreeData(treeData, false, [], true)}
/>
) : (
<Empty image={Empty.PRESENTED_IMAGE_SIMPLE} />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -248,15 +248,15 @@ const ResourceOverView: React.FC = () => {
<ProCard ghost size={'small'} bodyStyle={{ height: parent.innerHeight - 80 }}>
<SplitPane
split={'vertical'}
defaultSizes={[150, 500]}
minSize={150}
defaultSizes={[200, 500]}
minSize={200}
className={'split-pane'}
>
<Pane
className={'split-pane'}
forwardRef={refObject}
minSize={100}
size={100}
minSize={200}
size={200}
split={'horizontal'}
>
<ProCard
Expand Down
24 changes: 12 additions & 12 deletions script/sql/dinky-mysql.sql
Original file line number Diff line number Diff line change
Expand Up @@ -1651,7 +1651,7 @@ CREATE TABLE `dinky_git_project` (
`operator` int(11) DEFAULT NULL COMMENT 'operator',
PRIMARY KEY (`id`) USING BTREE,
KEY `tenant_id` (`tenant_id`) USING BTREE
) ENGINE=InnoDB AUTO_INCREMENT=3 DEFAULT CHARSET=utf8mb4;
) ENGINE=InnoDB AUTO_INCREMENT=3 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci COMMENT='git project' ROW_FORMAT=DYNAMIC;

-- ----------------------------
-- Records of dinky_git_project
Expand All @@ -1678,29 +1678,29 @@ CREATE TABLE `dinky_metrics` (
`create_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT 'create time',
`update_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT 'update time',
PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8mb4 COMMENT='metrics layout';
) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci COMMENT='metrics layout';

-- ----------------------------
-- Table structure for dinky_resources
-- ----------------------------
DROP TABLE IF EXISTS dinky_resources;
CREATE TABLE `dinky_resources` (
`id` int(11) NOT NULL AUTO_INCREMENT COMMENT 'key',
`file_name` varchar(64) COLLATE utf8_bin DEFAULT NULL COMMENT 'file name',
`description` varchar(255) COLLATE utf8_bin DEFAULT NULL,
`file_name` varchar(64) COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT 'file name',
`description` varchar(255) COLLATE utf8mb4_general_ci DEFAULT NULL,
`user_id` int(11) DEFAULT NULL COMMENT 'user id',
`type` tinyint(4) DEFAULT NULL COMMENT 'resource type,0:FILE,1:UDF',
`size` bigint(20) DEFAULT NULL COMMENT 'resource size',
`pid` int(11) DEFAULT NULL,
`full_name` varchar(128) COLLATE utf8_bin DEFAULT NULL,
`full_name` text COLLATE utf8mb4_general_ci DEFAULT NULL,
`is_directory` tinyint(4) DEFAULT NULL,
`create_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT 'create time',
`update_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT 'update time',
`creator` int(11) DEFAULT NULL COMMENT 'creator',
`updater` int(11) DEFAULT NULL COMMENT 'updater',
PRIMARY KEY (`id`),
UNIQUE KEY `dinky_resources_un` (`full_name`,`type`)
) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8 COLLATE=utf8_bin;
) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;
-- ----------------------------
-- Records of dinky_resources
-- ----------------------------
Expand Down Expand Up @@ -1770,7 +1770,7 @@ create table `dinky_sys_menu` (
`update_time` datetime not null default current_timestamp on update current_timestamp comment 'modify time',
`note` varchar(255) COLLATE utf8mb4_general_ci DEFAULT NULL,
primary key (`id`) using btree
) engine=innodb auto_increment=1 default charset=utf8mb4 collate=utf8mb4_general_ci;
) engine=innodb auto_increment=1 default charset=utf8mb4 collate=utf8mb4_general_ci comment='system menu' row_format=dynamic;

-- ----------------------------
-- Records of dinky_sys_menu
Expand Down Expand Up @@ -1942,7 +1942,7 @@ CREATE TABLE `dinky_sys_role_menu` (
`update_time` datetime not null default current_timestamp on update current_timestamp comment 'modify time',
PRIMARY KEY (`id`) USING BTREE,
UNIQUE KEY `un_role_menu_inx` (`role_id`,`menu_id`) USING BTREE
) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;
) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci ROW_FORMAT=DYNAMIC COMMENT='role menu';

-- ----------------------------
-- Table structure dinky_sys_alert
Expand All @@ -1958,7 +1958,7 @@ CREATE TABLE `dinky_alert_template` (
`creator` int(11) DEFAULT NULL COMMENT 'create user id',
`updater` int(11) DEFAULT NULL COMMENT 'update user id',
PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;
) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci ROW_FORMAT=DYNAMIC COMMENT='alert template';



Expand All @@ -1978,7 +1978,7 @@ CREATE TABLE `dinky_alert_rules` (
`updater` int(11) DEFAULT NULL COMMENT 'update user id',
PRIMARY KEY (`id`),
UNIQUE KEY `name` (`name`)
) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;
) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci ROW_FORMAT=DYNAMIC COMMENT='alert rule';



Expand Down Expand Up @@ -2020,7 +2020,7 @@ CREATE TABLE `dinky_udf_manage` (
`updater` int(11) DEFAULT NULL COMMENT 'update user id',
PRIMARY KEY (`id`) USING BTREE,
KEY `name,resources_id` (`name`,`resources_id`) USING BTREE
) ENGINE=InnoDB AUTO_INCREMENT=3 DEFAULT CHARSET=utf8mb4 ROW_FORMAT=DYNAMIC COMMENT='udf';
) ENGINE=InnoDB AUTO_INCREMENT=3 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci ROW_FORMAT=DYNAMIC COMMENT='udf';

-- ----------------------------
-- Table structure dinky_sys_token
Expand All @@ -2043,6 +2043,6 @@ CREATE TABLE `dinky_sys_token` (
PRIMARY KEY (`id`),
UNIQUE KEY `token_value` (`token_value`) USING BTREE,
KEY `source` (`source`) USING HASH
) ENGINE=InnoDB AUTO_INCREMENT=22 DEFAULT CHARSET=utf8mb4 COMMENT='token management';
) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8mb4 ROW_FORMAT=DYNAMIC collate = utf8mb4_general_ci COMMENT='token management';

SET FOREIGN_KEY_CHECKS = 1;
2 changes: 1 addition & 1 deletion script/sql/dinky-pg.sql
Original file line number Diff line number Diff line change
Expand Up @@ -3418,7 +3418,7 @@ CREATE TABLE "public"."dinky_resources"
"type" int2,
"size" int8,
"pid" int4,
"full_name" varchar(128) COLLATE "pg_catalog"."default",
"full_name" text COLLATE "pg_catalog"."default",
"is_directory" int2,
"create_time" timestamp(6) NOT null,
"update_time" timestamp(6) NOT null,
Expand Down
Loading

0 comments on commit 81689c1

Please sign in to comment.