-
Notifications
You must be signed in to change notification settings - Fork 64
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
Conversation
for _, name := range request.Names { | ||
target := filepath.Join(dir, name) | ||
if _, err := os.Stat(target); err != nil { | ||
logx.Infof("del file error %v", err) |
There was a problem hiding this comment.
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) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe 404 suitable?
if result.Error != nil { | ||
logx.Errorf("get file config record in db error %v", result.Error) | ||
fileConfig.Delimiter = "," | ||
fileConfig.WithHeader = false | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why init with ","
, false
?
There was a problem hiding this comment.
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() |
There was a problem hiding this comment.
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() |
There was a problem hiding this comment.
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) |
There was a problem hiding this comment.
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 }) => { |
There was a problem hiding this comment.
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
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, | ||
}); |
There was a problem hiding this comment.
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'; |
There was a problem hiding this comment.
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; |
There was a problem hiding this comment.
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;
}
fileList.forEach(file => { | ||
file.path = `${file.name}`; | ||
file.withHeader = false; | ||
file.delimiter = ','; | ||
}); | ||
setPreviewList(fileList); |
There was a problem hiding this comment.
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: ',',
));
* feat: add upload logic * feat: add file config in db * mod: update api * feat: support update file config * feat: support cluster import
What type of PR is this?
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: