Browse Source

Add isUploadFileModalVisible

HEAD
Yang Luo 3 years ago
parent
commit
f5ade8baab
3 changed files with 80 additions and 9 deletions
  1. +75
    -8
      web/src/FileTree.js
  2. +2
    -0
      web/src/locales/en/data.json
  3. +3
    -1
      web/src/locales/zh/data.json

+ 75
- 8
web/src/FileTree.js View File

@@ -1,6 +1,6 @@
import React from "react";
import {Button, Col, DatePicker, Descriptions, Empty, Input, Popconfirm, Row, Select, Spin, Tooltip, Tree, Upload} from 'antd';
import {CloudUploadOutlined, createFromIconfontCN, DeleteOutlined, DownloadOutlined, FileDoneOutlined, FolderAddOutlined} from "@ant-design/icons";
import {Button, Col, DatePicker, Descriptions, Empty, Input, Modal, Popconfirm, Radio, Row, Select, Spin, Tooltip, Tree, Upload} from 'antd';
import {CloudUploadOutlined, createFromIconfontCN, DeleteOutlined, DownloadOutlined, FileDoneOutlined, FolderAddOutlined, InfoCircleTwoTone} from "@ant-design/icons";
import moment from "moment";
import * as Setting from "./Setting";
import * as FileBackend from "./backend/FileBackend";
@@ -40,6 +40,10 @@ class FileTree extends React.Component {
permissions: null,
permissionMap: null,
searchValue: "",
isUploadFileModalVisible: false,
uploadFileType: null,
file: null,
info: null,
};

this.filePane = React.createRef();
@@ -76,6 +80,62 @@ class FileTree extends React.Component {
this.props.onUpdateStore(store);
}

checkUploadFile(info) {
for (let i = 0; i < info.fileList.length; i++) {
const filename = info.fileList[i].name;
if (this.getCacheApp(filename) === "" && filename.endsWith(".txt")) {
return true;
}
}
return false;
}

renderUploadFileModal() {
return (
<Modal title={
<div>
<InfoCircleTwoTone twoToneColor="rgb(45,120,213)" />
{" " + i18next.t("store:Please choose the type of your data")}
</div>
}
visible={this.state.isUploadFileModalVisible}
onCancel={() => {
this.setState({
isUploadFileModalVisible: false,
});
}}
width={"360px"}
footer={null} >
<Radio.Group buttonStyle="solid" onChange={e => {
this.setState({
uploadFileType: e.target.value,
isUploadFileModalVisible: false,
});

const uploadFileType = e.target.value;
console.log(this.state.file);
console.log(this.state.info);

let newInfo = Setting.deepCopy(this.state.info);
if (uploadFileType !== "Other") {
for (let i = 0; i < newInfo.fileList.length; i++) {
const filename = newInfo.fileList[i].name;
if (this.getCacheApp(filename) === "" && filename.endsWith(".txt")) {
newInfo.fileList[i].name = `${uploadFileType}_${newInfo.fileList[i].name}`;
}
}
}
this.uploadFile(this.state.file, newInfo);
}} value={this.state.uploadFileType}>
<Radio.Button value={"ECG"}>ECG</Radio.Button>
<Radio.Button value={"Impedance"}>Impedance</Radio.Button>
{/*<Radio.Button value={"EEG"}>EEG</Radio.Button>*/}
<Radio.Button value={"Other"}>{i18next.t("store:Other")}</Radio.Button>
</Radio.Group>
</Modal>
)
}

uploadFile(file, info) {
const storeId = `${this.props.store.owner}/${this.props.store.name}`;

@@ -444,7 +504,15 @@ class FileTree extends React.Component {
<Tooltip title={i18next.t("store:Upload file")}>
<span onClick={(e) => e.stopPropagation()}>
<Upload multiple={true} accept="*" showUploadList={false} beforeUpload={file => {return false;}} onChange={(info) => {
this.uploadFile(file, info);
if (this.checkUploadFile(info)) {
this.setState({
isUploadFileModalVisible: true,
file: file,
info: info,
});
} else {
this.uploadFile(file, info);
}
}}
>
<Button style={{marginRight: "5px"}} icon={<CloudUploadOutlined />} size="small" />
@@ -525,10 +593,6 @@ class FileTree extends React.Component {
);
}

isDataFile(filename) {
return filename.startsWith("Impedance_");
}

isExtForDocViewer(ext) {
return ["bmp", "jpg", "jpeg", "png", "tiff", "doc", "docx", "ppt", "pptx", "xls", "xlsx", "pdf"].includes(ext);
}
@@ -577,7 +641,7 @@ class FileTree extends React.Component {
const app = this.getCacheApp(filename);
if (app !== "") {
return (
<iframe key={path} src={`${Conf.AppUrl}${app}`} width={"100%"} height={"100%"} />
<iframe key={path} title={app} src={`${Conf.AppUrl}${app}`} width={"100%"} height={"100%"} />
// <DataChart filename={filename} url={url} height={this.getEditorHeightCss()} />
)
} else if (this.isExtForDocViewer(ext)) {
@@ -773,6 +837,9 @@ class FileTree extends React.Component {
</div>
</Col>
</Row>
{
this.renderUploadFileModal()
}
</div>
)
}


+ 2
- 0
web/src/locales/en/data.json View File

@@ -53,8 +53,10 @@
"Math": "Math",
"Move": "Move",
"New folder": "New folder",
"Other": "Other",
"Path": "Path",
"Physics": "Physics",
"Please choose the type of your data": "Please choose the type of your data",
"Please input your search term": "Please input your search term",
"Rename": "Rename",
"Science": "Science",


+ 3
- 1
web/src/locales/zh/data.json View File

@@ -53,8 +53,10 @@
"Math": "数学",
"Move": "移动",
"New folder": "新建文件夹",
"Other": "其他",
"Path": "路径",
"Physics": "物理",
"Please choose the type of your data": "请选择所上传文件的数据类型",
"Please input your search term": "请输入您的搜索关键字",
"Rename": "重命名",
"Science": "科学",
@@ -95,4 +97,4 @@
"Vectorset": "向量集",
"Words": "词汇表"
}
}
}

Loading…
Cancel
Save