Web: Files: added upload setting menu, added translations, code refactoring

This commit is contained in:
Nikita Gopienko 2020-04-28 17:43:12 +03:00
parent 30bc96584c
commit 6310ea509b
4 changed files with 70 additions and 26 deletions

View File

@ -55,7 +55,7 @@ class PureArticleMainButtonContent extends React.Component {
.finally(() => {
onLoading(false);
});
}
};
sendChunk = (files, location, requestsDataArray, isLatestFile, indexOfFile) => {
const sendRequestFunc = (index) => {
@ -87,20 +87,29 @@ class PureArticleMainButtonContent extends React.Component {
})
.catch((err) => toastr.error(err))
.finally(() => {
if (newState.hasOwnProperty('files') || newState.hasOwnProperty('percent') || newState.hasOwnProperty('uploadedFiles')) {
if (
newState.hasOwnProperty("files") ||
newState.hasOwnProperty("percent") ||
newState.hasOwnProperty("uploadedFiles")
) {
let progressVisible = true;
let uploadedFiles = newState.uploadedFiles;
let percent = newState.percent;
if(newState.uploadedFiles === files.length) {
percent=100;
newState.percent = 0;
newState.uploadedFiles = 0;
progressVisible = false
if (newState.uploadedFiles === files.length) {
percent = 100;
newState.percent = 0;
newState.uploadedFiles = 0;
progressVisible = false;
}
this.setState(newState, () => {
this.props.setProgressValue(percent);
this.props.setProgressLabel(this.props.t("UploadingLabel", {file: uploadedFiles, totalFiles: files.length}));
if(!progressVisible) {
this.props.setProgressLabel(
this.props.t("UploadingLabel", {
file: uploadedFiles,
totalFiles: files.length,
})
);
if (!progressVisible) {
this.props.setProgressVisible(false);
}
});
@ -163,8 +172,8 @@ class PureArticleMainButtonContent extends React.Component {
const newFiles = [];
if(files) {
let total = 0;
for(let item of files) {
if(item.size !== 0) {
for (let item of files) {
if (item.size !== 0) {
newFiles.push(item);
total += item.size;
} else {
@ -172,13 +181,16 @@ class PureArticleMainButtonContent extends React.Component {
}
}
if(newFiles.length > 0) {
if (newFiles.length > 0) {
this.setState({ files: newFiles, totalSize: total }, () => {
setProgressVisible(true);
setProgressLabel(this.props.t("UploadingLabel", {file: 0, totalFiles: newFiles.length}));
setProgressLabel(
this.props.t("UploadingLabel", {
file: 0,
totalFiles: newFiles.length,
})
);
this.startSessionFunc(0);
//setProgressValue
//setProgressContent
});
}
}

View File

@ -2,7 +2,7 @@ import React from "react";
import { connect } from "react-redux";
import PropTypes from "prop-types";
import { withRouter } from "react-router";
import { RequestLoader } from "asc-web-components";
import { RequestLoader, Checkbox } from "asc-web-components";
import { PageLayout, utils } from "asc-web-common";
import { withTranslation, I18nextProvider } from 'react-i18next';
import i18n from "./i18n";
@ -33,8 +33,10 @@ class PureHome extends React.Component {
showProgressBar: false,
progressBarValue: 0,
progressBarDropDownContent: null,
progressBarLabel: ""//{`Uploading files: ${progressBarValue} of ${progressBarMaxValue}`}
progressBarLabel: "",
overwriteSetting: false,
uploadOriginalFormatSetting: false,
hideWindowSetting: false
};
}
@ -103,9 +105,12 @@ class PureHome extends React.Component {
else { setTimeout(() => this.setState({ showProgressBar: visible, progressBarValue: 0 }), 10000)};
};
setProgressValue = value => this.setState({ progressBarValue: value });
setProgressContent = content => this.setState({ progressBarDropDownContent: content });
setProgressLabel = label => this.setState({ progressBarLabel: label });
onChangeOverwrite = () => this.setState({overwriteSetting: !this.state.overwriteSetting})
onChangeOriginalFormat = () => this.setState({uploadOriginalFormatSetting: !this.state.uploadOriginalFormatSetting})
onChangeWindowVisible = () => this.setState({hideWindowSetting: !this.state.hideWindowSetting})
render() {
const {
isHeaderVisible,
@ -115,10 +120,33 @@ class PureHome extends React.Component {
isLoading,
showProgressBar,
progressBarValue,
progressBarDropDownContent,
progressBarLabel
progressBarLabel,
overwriteSetting,
uploadOriginalFormatSetting,
hideWindowSetting
} = this.state;
const { t } = this.props;
const progressBarContent = (
<div>
<Checkbox
onChange={this.onChangeOverwrite}
isChecked={overwriteSetting}
label={t("OverwriteSetting")}
/>
<Checkbox
onChange={this.onChangeOriginalFormat}
isChecked={uploadOriginalFormatSetting}
label={t("UploadOriginalFormatSetting")}
/>
<Checkbox
onChange={this.onChangeWindowVisible}
isChecked={hideWindowSetting}
label={t("HideWindowSetting")}
/>
</div>
);
return (
<>
<RequestLoader
@ -133,12 +161,10 @@ class PureHome extends React.Component {
<PageLayout
withBodyScroll
withBodyAutoFocus
showProgressBar={showProgressBar}
progressBarValue={progressBarValue}
progressBarDropDownContent={progressBarDropDownContent}
progressBarDropDownContent={progressBarContent}
progressBarLabel={progressBarLabel}
articleHeaderContent={<ArticleHeaderContent />}
articleMainButtonContent={
<ArticleMainButtonContent

View File

@ -68,5 +68,8 @@
"EmptyFolderHeader": "No files in this folder",
"EmptyFilterSubheadingText": "No files to be displayed for this filter here",
"EmptyFilterDescriptionText": "No files or folders matching your filter can be displayed in this section. Please select other filter options or clear filter to view all the files in this section. You can also look for the file you need in other sections.",
"Filter": "Filter"
"Filter": "Filter",
"OverwriteSetting": "Overwrite existing file with the same name",
"UploadOriginalFormatSetting": "Upload the documents in original format as well",
"HideWindowSetting": "Show this window minimized"
}

View File

@ -68,5 +68,8 @@
"EmptyFolderHeader": "В этой папке нет файлов",
"EmptyFilterSubheadingText": "Здесь нет файлов, соответствующих этому фильтру",
"EmptyFilterDescriptionText": "В этом разделе нет файлов или папок, соответствующих фильтру. Пожалуйста, выберите другие параметры или очистите фильтр, чтобы показать все файлы в этом разделе. Вы можете также поискать нужный файл в других разделах.",
"Filter": "Фильтр"
"Filter": "Фильтр",
"OverwriteSetting": "Перезаписывать существующий файл с таким же именем",
"UploadOriginalFormatSetting": "Сохранять также копию файла в исходном формате",
"HideWindowSetting": "Показывать это окно минимизированным"
}