Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add file config in db #436

Merged
merged 8 commits into from
Feb 9, 2023
Merged

Conversation

hetao92
Copy link
Contributor

@hetao92 hetao92 commented Jan 29, 2023

What type of PR is this?

  • bug
  • feature
  • enhancement

What problem(s) does this PR solve?

Issue(s) number:

Description:

How do you solve it?

Special notes for your reviewer, ex. impact of this fix, design document, etc:

for _, name := range request.Names {
target := filepath.Join(dir, name)
if _, err := os.Stat(target); err != nil {
logx.Infof("del file error %v", err)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

del?

target := filepath.Join(dir, name)
if _, err := os.Stat(target); err != nil {
logx.Infof("del file error %v", err)
return ecode.WithInternalServer(err)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe 404 suitable?

Comment on lines +119 to +123
if result.Error != nil {
logx.Errorf("get file config record in db error %v", result.Error)
fileConfig.Delimiter = ","
fileConfig.WithHeader = false
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why init with ",", false?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Considering that the user can directly upload the file to the corresponding directory of the server, the configuration record of the file may not exist in the database, so the default value is set and returned to the front end.

line, err := reader.Read()
sample := ""
for count < 5 {
line, _, err := reader.ReadLine()
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

for count:=0; count<5; count++ ?

}
file.Close()
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

func (f *fileService) FileUpload() error {
dir := f.svcCtx.Config.File.UploadDir
auth := f.ctx.Value(auth.CtxKeyUserInfo{}).(*auth.AuthData)
host := auth.Address + ":" + strconv.Itoa(auth.Port)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seems unnecessary?

uploadList: StudioFile[];
}

const DelimiterConfigModal = (props: { onConfirm: (string) => void }) => {
Copy link
Contributor

@huaxiabuluo huaxiabuluo Feb 2, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

missing type, check all code in this commit

Comment on lines 100 to 109
const newData = [...data];
newData.splice(index, 1);
const checkedList = newData.filter((file) => file.withHeader);
setState({
checkAll: checkedList.length === newData.length,
indeterminate: !!checkedList.length && checkedList.length < newData.length,
data: newData,
activeItem: isActive ? null : activeItem,
previewContent: isActive ? [] : previewContent,
});
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

const newData = data.filter((_, i) => i !== index);
const checkedNum = newData.reduce((n, file) => n + (file.withHeader & 1), 0);

setState({
  checkAll: checkedNum === newData.length,
  indeterminate: !!checkedNum && checkedNum < newData.length,
  data: newData,
  activeItem: isActive ? null : activeItem,
  previewContent: isActive ? [] : previewContent,
});

@@ -1,13 +1,15 @@
import { Button, Popover, Table } from 'antd';
import { } from 'antd/lib/button';
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

delete

import styles from './index.module.less';
interface IProps {
file: StudioFile;
children: any;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

type IProps = PropsWithChildren<{ file: StudioFile; }>

interface IProps {
  file: StudioFile;
  children: ReactNode;
}

Comment on lines +79 to +84
fileList.forEach(file => {
file.path = `${file.name}`;
file.withHeader = false;
file.delimiter = ',';
});
setPreviewList(fileList);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

setPreviewList(fileList.map(file => ({
  ...file,
  path: `${file.name}`,
  withHeader: false,
  delimiter: ',',
));

@hetao92 hetao92 merged commit 8e4847a into vesoft-inc:next-version Feb 9, 2023
@hetao92 hetao92 deleted the hetao-upload branch February 9, 2023 06:29
hetao92 added a commit that referenced this pull request Feb 9, 2023
* feat: add upload logic

* feat: add file config in db

* mod: update api

* feat: support update file config

* feat: support cluster import
hetao92 added a commit that referenced this pull request Feb 9, 2023
* feat: update import logic (#435)

* feat: update import logic

* feat: update import page

* feat: add file config in db (#436)

* feat: add upload logic

* feat: add file config in db

* mod: update api

* feat: support update file config

* feat: support cluster import
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants