Skip to content

Commit

Permalink
fix: issue (#382)
Browse files Browse the repository at this point in the history
  • Loading branch information
NicolaCage authored Dec 7, 2022
1 parent e56d856 commit ffefb5b
Show file tree
Hide file tree
Showing 7 changed files with 12 additions and 15 deletions.
2 changes: 1 addition & 1 deletion app/config/locale/en-US.json
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,7 @@
"fileUploadRequired": "1. Please make sure all CSV data files are uploaded before import the YAML file. If not, please go to ",
"fileUploadRequired2": " first.",
"exampleDownload": "2. An example for the configuration file: ",
"uploadTemplateTip": "3. Configure the Yaml file: please keep only the file name (retain the file extension) for all file paths (path, failDataPath, logPath) in the template, e.g. logPath: config.csv",
"uploadTemplateTip": "3. Configure the Yaml file: please keep only the file name (retain the file extension) for all file paths (path, logPath) in the template, e.g. logPath: config.csv",
"reUpload": "Re-upload",
"fileNotExist": "{name} file does not exist!",
"importYaml": "Import the YAML file",
Expand Down
2 changes: 1 addition & 1 deletion app/config/locale/zh-CN.json
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,7 @@
"fileUploadRequired": "1. 请确保在导入 YAML 文件之前上传所有 CSV 数据文件。 如果没有,请先前往",
"fileUploadRequired2": "数据文件",
"exampleDownload": "2. 配置文件示例:",
"uploadTemplateTip": "3. 配置Yaml文件:模板中所有文件路径(path、failDataPath、logPath)请只保留文件名(保留文件扩展名),例如: 日志路径:config.csv",
"uploadTemplateTip": "3. 配置Yaml文件:模板中所有文件路径(path、logPath)请只保留文件名(保留文件扩展名),例如: 日志路径:config.csv",
"reUpload": "重新上传",
"fileNotExist": "文件 {name} 不存在",
"importYaml": "导入 YAML 文件",
Expand Down
2 changes: 1 addition & 1 deletion app/pages/Import/TaskCreate/PasswordInputModal/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ const PasswordInputModal = (props: IProps) => {
onChange={e => setPassword(e.target.value)}
/>
<div className={styles.btns}>
<Button onClick={() => handleConfirm()}>
<Button onClick={() => handleCancel()}>
{intl.get('common.cancel')}
</Button>
<Button
Expand Down
9 changes: 2 additions & 7 deletions app/utils/import.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { message } from 'antd';
import _ from 'lodash';

import { getI18n } from '@vesoft-inc/i18n';
import { handleEscape } from './function';

export function configToJson(payload) {
Expand Down Expand Up @@ -84,10 +84,8 @@ export function edgeDataToJSON(
edgePorps.push(_prop);
}
});
const fileName = edge.file.name.replace('.csv', '');
const edgeConfig = {
path: edge.file.name,
failDataPath: `${fileName}Fail.csv`,
batchSize: Number(batchSize) || 60,
type: 'csv',
csv: {
Expand Down Expand Up @@ -136,10 +134,8 @@ export function vertexDataToJSON(
};
return _tag;
});
const fileName = vertex.file.name.replace('.csv', '');
const vertexConfig: any = {
path: vertex.file.name,
failDataPath: `${fileName}Fail.csv`,
batchSize: Number(batchSize) || 60,
type: 'csv',
csv: {
Expand All @@ -164,6 +160,7 @@ export function vertexDataToJSON(

export function indexJudge(index: number | null, name: string) {
if (index === null) {
const { intl } = getI18n();
message.error(`${name} ${intl.get('import.indexNotEmpty')}`);
throw new Error();
}
Expand Down Expand Up @@ -191,7 +188,6 @@ export const exampleJson = {
'files': [
{
'path': 'item.csv',
'failDataPath': 'itemFail.csv',
'batchSize': 60,
'limit': null,
'inOrder': null,
Expand Down Expand Up @@ -248,7 +244,6 @@ export const exampleJson = {
},
{
'path': 'orderr.csv',
'failDataPath': 'orderrFail.csv',
'batchSize': 60,
'limit': null,
'inOrder': null,
Expand Down
8 changes: 5 additions & 3 deletions server/api/studio/internal/service/importer/importer.go
Original file line number Diff line number Diff line change
Expand Up @@ -60,11 +60,13 @@ func CreateConfigFile(uploadDir, taskdir string, config importconfig.YAMLConfig)
failDataPaths := make([]string, 0)
for _, file := range config.Files {
paths = append(paths, filepath.Join(uploadDir, *file.Path))
failDataPaths = append(failDataPaths, filepath.Join(taskdir, "err", *file.FailDataPath))
failDataPaths = append(failDataPaths, filepath.Join(taskdir, "err"))
_, fileName := filepath.Split(*file.Path)
_, fileDataName := filepath.Split(*file.FailDataPath)
*file.Path = fileName
*file.FailDataPath = fileDataName
if file.FailDataPath == nil {
file.FailDataPath = new(string)
}
*file.FailDataPath = fileName
}

outYaml, err := yaml.Marshal(config)
Expand Down
2 changes: 1 addition & 1 deletion server/api/studio/internal/types/types.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion server/api/studio/restapi/import.api
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ type (

ImportTaskFile {
Path *string `json:"path" validate:"required"`
FailDataPath *string `json:"failDataPath" validate:"required"`
FailDataPath *string `json:"failDataPath,optional"`
BatchSize *int `json:"batchSize,optional"`
Limit *int `json:"limit, optional"`
InOrder *bool `json:"inOrder, optional"`
Expand Down

0 comments on commit ffefb5b

Please sign in to comment.