fix(fe/panel_sharing): use rows layout in sharing panel
This commit is contained in:
parent
083e1648eb
commit
fc3ecc5543
4 changed files with 158 additions and 110 deletions
|
@ -14,12 +14,12 @@ import { LoginProps } from "./pane_login";
|
||||||
import { UploadEntry, UploadState } from "../worker/interface";
|
import { UploadEntry, UploadState } from "../worker/interface";
|
||||||
import { Flexbox } from "./layout/flexbox";
|
import { Flexbox } from "./layout/flexbox";
|
||||||
import { Container } from "./layout/container";
|
import { Container } from "./layout/container";
|
||||||
|
import { Rows, Row } from "./layout/rows";
|
||||||
|
|
||||||
export interface UploadingsProps {
|
export interface UploadingsProps {
|
||||||
uploadings: List<UploadEntry>;
|
uploadings: List<UploadEntry>;
|
||||||
uploadFiles: List<File>;
|
uploadFiles: List<File>;
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface Props {
|
export interface Props {
|
||||||
uploadingsInfo: UploadingsProps;
|
uploadingsInfo: UploadingsProps;
|
||||||
msg: MsgProps;
|
msg: MsgProps;
|
||||||
|
@ -36,32 +36,26 @@ export class UploadingsPanel extends React.Component<Props, State, {}> {
|
||||||
this.state = {};
|
this.state = {};
|
||||||
}
|
}
|
||||||
|
|
||||||
deleteUpload = (filePath: string): Promise<void> => {
|
deleteUpload = async (filePath: string): Promise<void> => {
|
||||||
return updater()
|
try {
|
||||||
.deleteUpload(filePath)
|
const deleteStatus = await updater().deleteUpload(filePath);
|
||||||
.then((status: string) => {
|
if (deleteStatus !== "") {
|
||||||
if (status !== "") {
|
throw deleteStatus;
|
||||||
throw status;
|
}
|
||||||
}
|
|
||||||
return updater().refreshUploadings();
|
const statuses = await Promise.all([
|
||||||
})
|
updater().refreshUploadings(),
|
||||||
.then((status: string) => {
|
updater().self(),
|
||||||
if (status !== "") {
|
]);
|
||||||
throw status;
|
if (statuses.join("") !== "") {
|
||||||
}
|
throw statuses.join(";");
|
||||||
return updater().self();
|
|
||||||
})
|
|
||||||
.then((status: string) => {
|
|
||||||
if (status !== "") {
|
|
||||||
throw status;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
this.props.update(updater().updateUploadingsInfo);
|
|
||||||
this.props.update(updater().updateLogin);
|
this.props.update(updater().updateLogin);
|
||||||
})
|
this.props.update(updater().updateUploadingsInfo);
|
||||||
.catch((status: Error) => {
|
} catch (status: any) {
|
||||||
alertMsg(getErrMsg(this.props.msg.pkg, "op.fail", status.toString()));
|
alertMsg(getErrMsg(this.props.msg.pkg, "op.fail", status.toString()));
|
||||||
});
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
stopUploading = (filePath: string) => {
|
stopUploading = (filePath: string) => {
|
||||||
|
@ -69,45 +63,15 @@ export class UploadingsPanel extends React.Component<Props, State, {}> {
|
||||||
this.props.update(updater().updateUploadingsInfo);
|
this.props.update(updater().updateUploadingsInfo);
|
||||||
};
|
};
|
||||||
|
|
||||||
render() {
|
makeRowsInputs = (uploadings: List<UploadEntry>): List<Row> => {
|
||||||
const nameWidthClass = `item-name item-name-${
|
const uploadingRows = uploadings.map((uploading: UploadEntry) => {
|
||||||
this.props.ui.isVertical ? "vertical" : "horizontal"
|
|
||||||
} pointer`;
|
|
||||||
|
|
||||||
const uploadingList = this.props.uploadingsInfo.uploadings.map(
|
|
||||||
(uploading: UploadEntry) => {
|
|
||||||
const pathParts = uploading.filePath.split("/");
|
const pathParts = uploading.filePath.split("/");
|
||||||
const fileName = pathParts[pathParts.length - 1];
|
const fileName = pathParts[pathParts.length - 1];
|
||||||
const progress = `${Math.floor(
|
const progress = Math.floor((uploading.uploaded / uploading.size) * 100);
|
||||||
(uploading.uploaded / uploading.size) * 100
|
|
||||||
)}%`;
|
|
||||||
return (
|
|
||||||
<div key={uploading.filePath} className="upload-item">
|
|
||||||
<Flexbox
|
|
||||||
children={List([
|
|
||||||
<Flexbox
|
|
||||||
children={List([
|
|
||||||
<RiUploadCloudLine
|
|
||||||
size="3rem"
|
|
||||||
id="icon-upload"
|
|
||||||
className="margin-r-m blue0-font"
|
|
||||||
/>,
|
|
||||||
|
|
||||||
<div className={`font-s ${nameWidthClass}`}>
|
// const title = <Flexbox children={List([])} />;
|
||||||
<span className="">{fileName} </span>
|
|
||||||
<span className="desc grey0-font">
|
|
||||||
{FileSize(uploading.uploaded, { round: 0 })}
|
|
||||||
/
|
|
||||||
{FileSize(uploading.size, {
|
|
||||||
round: 0,
|
|
||||||
})}
|
|
||||||
/
|
|
||||||
{progress}
|
|
||||||
</span>
|
|
||||||
</div>,
|
|
||||||
])}
|
|
||||||
/>,
|
|
||||||
|
|
||||||
|
const op = (
|
||||||
<div className="item-op">
|
<div className="item-op">
|
||||||
<button
|
<button
|
||||||
onClick={() => this.stopUploading(uploading.filePath)}
|
onClick={() => this.stopUploading(uploading.filePath)}
|
||||||
|
@ -121,26 +85,99 @@ export class UploadingsPanel extends React.Component<Props, State, {}> {
|
||||||
>
|
>
|
||||||
{this.props.msg.pkg.get("browser.delete")}
|
{this.props.msg.pkg.get("browser.delete")}
|
||||||
</button>
|
</button>
|
||||||
</div>,
|
</div>
|
||||||
])}
|
);
|
||||||
childrenStyles={List([{}, { justifyContent: "flex-end" }])}
|
|
||||||
/>
|
const progressBar = (
|
||||||
<div className="progress-grey">
|
<div className="progress-grey">
|
||||||
<div
|
<div
|
||||||
className="progress-green"
|
className="progress-green"
|
||||||
style={{ width: `${progress}` }}
|
style={{ width: `${progress}%` }}
|
||||||
></div>
|
></div>
|
||||||
</div>
|
</div>
|
||||||
{uploading.err.trim() === "" ? null : (
|
|
||||||
<div className="error">{uploading.err.trim()}</div>
|
|
||||||
)}
|
|
||||||
</div>
|
|
||||||
);
|
|
||||||
}
|
|
||||||
);
|
);
|
||||||
|
|
||||||
const list =
|
const errorInfo =
|
||||||
this.props.uploadingsInfo.uploadings.size === 0 ? (
|
uploading.err.trim() === "" ? null : (
|
||||||
|
<div className="error">{uploading.err.trim()}</div>
|
||||||
|
);
|
||||||
|
|
||||||
|
const elem = (
|
||||||
|
<div key={uploading.filePath} className="upload-item">
|
||||||
|
<Flexbox
|
||||||
|
children={List([
|
||||||
|
<RiUploadCloudLine
|
||||||
|
size="3rem"
|
||||||
|
id="icon-upload"
|
||||||
|
className="margin-r-m blue0-font"
|
||||||
|
/>,
|
||||||
|
|
||||||
|
<div className={`font-s`}>
|
||||||
|
<span className="">{fileName} </span>
|
||||||
|
<span className="desc grey0-font">
|
||||||
|
{FileSize(uploading.uploaded, { round: 0 })}
|
||||||
|
/
|
||||||
|
{FileSize(uploading.size, {
|
||||||
|
round: 0,
|
||||||
|
})}
|
||||||
|
/
|
||||||
|
{`${progress}%`}
|
||||||
|
</span>
|
||||||
|
</div>,
|
||||||
|
|
||||||
|
op,
|
||||||
|
])}
|
||||||
|
childrenStyles={List([
|
||||||
|
{ flex: "0 0 auto" },
|
||||||
|
{},
|
||||||
|
{ justifyContent: "flex-end" },
|
||||||
|
])}
|
||||||
|
/>
|
||||||
|
{progressBar}
|
||||||
|
{errorInfo}
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
|
||||||
|
// file path, size, progress
|
||||||
|
const sortVals = List<string>([
|
||||||
|
uploading.filePath,
|
||||||
|
`${uploading.size}`,
|
||||||
|
`${progress}`,
|
||||||
|
]);
|
||||||
|
return {
|
||||||
|
elem,
|
||||||
|
sortVals,
|
||||||
|
val: uploading,
|
||||||
|
};
|
||||||
|
});
|
||||||
|
|
||||||
|
return uploadingRows;
|
||||||
|
};
|
||||||
|
|
||||||
|
updateUploadings = (uploadings: Object) => {
|
||||||
|
const newUploadings = uploadings as List<UploadEntry>;
|
||||||
|
updater().updateUploadings(newUploadings);
|
||||||
|
this.props.update(updater().updateUploadingsInfo);
|
||||||
|
};
|
||||||
|
|
||||||
|
render() {
|
||||||
|
const uploadingRows = this.makeRowsInputs(
|
||||||
|
this.props.uploadingsInfo.uploadings
|
||||||
|
);
|
||||||
|
const sortKeys = List([
|
||||||
|
this.props.msg.pkg.get("item.path"),
|
||||||
|
this.props.msg.pkg.get("item.size"),
|
||||||
|
this.props.msg.pkg.get("item.progress"),
|
||||||
|
]);
|
||||||
|
const view = (
|
||||||
|
<Rows
|
||||||
|
sortKeys={sortKeys}
|
||||||
|
rows={uploadingRows}
|
||||||
|
updateRows={this.updateUploadings}
|
||||||
|
/>
|
||||||
|
);
|
||||||
|
|
||||||
|
const noUploadingView = (
|
||||||
<Container>
|
<Container>
|
||||||
<Flexbox
|
<Flexbox
|
||||||
children={List([
|
children={List([
|
||||||
|
@ -160,6 +197,11 @@ export class UploadingsPanel extends React.Component<Props, State, {}> {
|
||||||
])}
|
])}
|
||||||
/>
|
/>
|
||||||
</Container>
|
</Container>
|
||||||
|
);
|
||||||
|
|
||||||
|
const list =
|
||||||
|
this.props.uploadingsInfo.uploadings.size === 0 ? (
|
||||||
|
noUploadingView
|
||||||
) : (
|
) : (
|
||||||
<Container>
|
<Container>
|
||||||
<Flexbox
|
<Flexbox
|
||||||
|
@ -188,7 +230,7 @@ export class UploadingsPanel extends React.Component<Props, State, {}> {
|
||||||
])}
|
])}
|
||||||
/>
|
/>
|
||||||
|
|
||||||
{uploadingList}
|
{view}
|
||||||
</Container>
|
</Container>
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
|
@ -263,6 +263,10 @@ export class Updater {
|
||||||
this.props.filesInfo.items = items;
|
this.props.filesInfo.items = items;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
updateUploadings = (uploadings: List<UploadEntry>) => {
|
||||||
|
this.props.uploadingsInfo.uploadings = uploadings;
|
||||||
|
};
|
||||||
|
|
||||||
moveHere = async (
|
moveHere = async (
|
||||||
srcDir: string,
|
srcDir: string,
|
||||||
dstDir: string,
|
dstDir: string,
|
||||||
|
|
|
@ -125,4 +125,5 @@ export const msgs: Map<string, string> = Map({
|
||||||
"item.path": "Path",
|
"item.path": "Path",
|
||||||
"item.modTime": "Mod Time",
|
"item.modTime": "Mod Time",
|
||||||
"item.size": "Size",
|
"item.size": "Size",
|
||||||
|
"item.progress": "Progress",
|
||||||
});
|
});
|
||||||
|
|
|
@ -122,4 +122,5 @@ export const msgs: Map<string, string> = Map({
|
||||||
"item.path": "路径",
|
"item.path": "路径",
|
||||||
"item.modTime": "修改时间",
|
"item.modTime": "修改时间",
|
||||||
"item.size": "大小",
|
"item.size": "大小",
|
||||||
|
"item.progress": "进度",
|
||||||
});
|
});
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue