Skip to content

Commit

Permalink
CCS-102689 Add total size in files upload
Browse files Browse the repository at this point in the history
  • Loading branch information
Ivan Kudinov committed Dec 3, 2024
1 parent 11717e4 commit 62a150d
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 14 deletions.
16 changes: 11 additions & 5 deletions frontend/app/modules/max-file-size/MaxFileSizePage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,25 +9,31 @@ import { observer } from 'mobx-react'

const MaxFileSizePage: FC = () => {
const { maxFileSizeStore: store } = useStore()
const [maxSize, setMaxSize] = useState(10_000_000)
const [maxSize, setMaxSize] = useState('10000000')
const [totalSize, setTotalSize] = useState('30000000')
const [mime, setMime] = useState('')

const handleMaxSizeChange = (event: React.ChangeEvent<HTMLInputElement>) =>
setMaxSize(parseInt(event.target.value, 10))
const handleMaxSizeChange = (event: React.ChangeEvent<HTMLInputElement>) => setMaxSize(event.target.value)

const handleTotalSizeChange = (event: React.ChangeEvent<HTMLInputElement>) => setTotalSize(event.target.value)

const handleMimeChange = (event: React.ChangeEvent<HTMLInputElement>) => setMime(event.target.value)

const handleSubmit = () => {
store.uploadFile(mime, maxSize)
const maxSizeParsed = maxSize ? parseInt(maxSize, 10) : undefined
const totalSizeParsed = totalSize ? parseInt(totalSize, 10) : undefined
store.uploadFile(mime, maxSizeParsed, totalSizeParsed)
}

return (
<FeaturePage>
<FeatureHeader name="Ограничение размера файла" />
Mime тип
<Input onChange={handleMimeChange} value={mime} id="mime-type" />
Размер в байтах
Размер одного файла в байтах
<Input onChange={handleMaxSizeChange} value={maxSize} id="max-size" type="numeric" />
Размер всех файлов в байтах
<Input onChange={handleTotalSizeChange} value={totalSize} id="max-size" type="numeric" />
<Button onClick={handleSubmit} id="submit" title="Прикрепить" />
<br />
<br />
Expand Down
4 changes: 2 additions & 2 deletions frontend/app/modules/max-file-size/max-file-size.store.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,9 @@ export class MaxFileSizeStore {
this.response = null
}

async uploadFile(mimeType: string, maxSize: number): Promise<void> {
async uploadFile(mimeType: string, maxSize?: number, totalSize?: number): Promise<void> {
try {
const response = await SDK.uploadFiles({ mimeType, maxSize })
const response = await SDK.uploadFiles({ mimeType, maxSize, totalSize })

if (response.payload.status === STATUS.ERROR) {
this.rootStore.toastStore.showToast(`Ошибка при отправке файла SmartApp ${response.payload.errorCode}`)
Expand Down
4 changes: 2 additions & 2 deletions frontend/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "next-feature-smartapp",
"version": "2.5.4",
"version": "2.6.0",
"description": "SmartApp with all features",
"main": "index.js",
"scripts": {
Expand All @@ -13,7 +13,7 @@
"license": "ISC",
"dependencies": {
"@amcharts/amcharts5": "5.9.12",
"@expressms/smartapp-sdk": "1.10.0-alpha.4",
"@expressms/smartapp-sdk": "1.11.0-alpha.0",
"html5-qrcode": "2.3.8",
"jsoneditor": "10.1.0",
"material-icons": "1.13.12",
Expand Down
2 changes: 1 addition & 1 deletion frontend/smartapp-manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,5 @@
"manifestVersion": "1.0.0",
"smartAppVersion": "",
"bundlePath": "",
"changeLog": "Тестирование disableRenameParams()"
"changeLog": "Ограничение на размер всех файлов"
}
8 changes: 4 additions & 4 deletions frontend/yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -1160,10 +1160,10 @@
lodash-es "^4.17.21"
uuid "^8.3.2"

"@expressms/smartapp-sdk@1.10.0-alpha.3":
version "1.10.0-alpha.3"
resolved "https://registry.yarnpkg.com/@expressms/smartapp-sdk/-/smartapp-sdk-1.10.0-alpha.3.tgz#69ed818c32ed31056894969be5b1cdc9d929270a"
integrity sha512-52eUXr5rLg6Q5o9HFZL/Qf32Zho8zCWkIeuZ9ZvsTgPlgFziSebXfrBgOLkusHrjR4G5xhrPPo/bjGJDig09Ew==
"@expressms/smartapp-sdk@1.11.0-alpha.0":
version "1.11.0-alpha.0"
resolved "https://registry.yarnpkg.com/@expressms/smartapp-sdk/-/smartapp-sdk-1.11.0-alpha.0.tgz#3eb59eca09aaa9f2d4f73b0bce7cfa9ff07e4ec7"
integrity sha512-dhdL5ysnRzUw8+d6/nBG7RFryfIvHD8dHA2FTAlYyi4bGr5Eh2mVCu7s75uHyIrTNGmViDig4QWzCz4DXJUCbg==
dependencies:
"@expressms/smartapp-bridge" "1.4.0-alpha.1"

Expand Down

0 comments on commit 62a150d

Please sign in to comment.