diff --git a/src/app/styles/antd.less b/src/app/styles/antd.less
index 93fbbc14..f3745e77 100644
--- a/src/app/styles/antd.less
+++ b/src/app/styles/antd.less
@@ -59,3 +59,7 @@
display: flex;
justify-content: space-between;
}
+
+p:last-of-type {
+ margin-bottom: 0;
+}
diff --git a/src/app/styles/variables.less b/src/app/styles/variables.less
index a0d0cba0..f0ad101e 100644
--- a/src/app/styles/variables.less
+++ b/src/app/styles/variables.less
@@ -22,4 +22,5 @@
@picker-bg: #f1f3f5;
@tooltip-bg: #000000;
+@tooltip-max-width: 300px;
@line-height-base: 1.5;
diff --git a/src/entities/file/@x/transfer.ts b/src/entities/file/@x/transfer.ts
index 73ae16d9..804add0f 100644
--- a/src/entities/file/@x/transfer.ts
+++ b/src/entities/file/@x/transfer.ts
@@ -1,3 +1,4 @@
/** Cross-import entities using public API in FSD https://feature-sliced.design/ru/docs/reference/public-api#public-api-for-cross-imports */
export type { FileFormat, Json } from '../types';
+export { FileSizeUnitValue, FileSizeUnit } from '../types';
export { FileFormatParams, FileNameTemplate } from '../ui';
diff --git a/src/entities/file/constants.ts b/src/entities/file/constants.ts
index 02e2271b..4e2cb0a2 100644
--- a/src/entities/file/constants.ts
+++ b/src/entities/file/constants.ts
@@ -2,7 +2,7 @@ import { FileSizeUnit } from './types';
export const FILE_SIZE_UNIT_DISPLAY = {
[FileSizeUnit.B]: 'b',
- [FileSizeUnit.KB]: 'kb',
- [FileSizeUnit.MB]: 'mb',
- [FileSizeUnit.GB]: 'gb',
+ [FileSizeUnit.KiB]: 'kib',
+ [FileSizeUnit.MiB]: 'mib',
+ [FileSizeUnit.GiB]: 'gib',
} as const;
diff --git a/src/entities/file/types.ts b/src/entities/file/types.ts
index 1d7acba5..cd1283d5 100644
--- a/src/entities/file/types.ts
+++ b/src/entities/file/types.ts
@@ -1,15 +1,15 @@
export enum FileSizeUnit {
B = 'B',
- KB = 'KB',
- MB = 'MB',
- GB = 'GB',
+ KiB = 'KiB',
+ MiB = 'MiB',
+ GiB = 'GiB',
}
export enum FileSizeUnitValue {
B = 1,
- KB = 1000,
- MB = 1000 * 1000,
- GB = 1000 * 1000 * 1000,
+ KiB = 1024,
+ MiB = 1024 * 1024,
+ GiB = 1024 * 1024 * 1024,
}
export enum FileCompression {
diff --git a/src/entities/file/utils/parseFileSize/index.ts b/src/entities/file/utils/parseFileSize/index.ts
index 56d39e45..f2924311 100644
--- a/src/entities/file/utils/parseFileSize/index.ts
+++ b/src/entities/file/utils/parseFileSize/index.ts
@@ -4,14 +4,14 @@ import { ParseFileSizeReturn } from './types';
/** Util for parsing file size in bytes to appropriate unit and value */
export const parseFileSize = (bytes: number): ParseFileSizeReturn => {
- if (bytes >= FileSizeUnitValue.GB) {
- return { value: bytes / FileSizeUnitValue.GB, unit: FileSizeUnit.GB };
+ if (bytes >= FileSizeUnitValue.GiB) {
+ return { value: bytes / FileSizeUnitValue.GiB, unit: FileSizeUnit.GiB };
}
- if (bytes >= FileSizeUnitValue.MB) {
- return { value: bytes / FileSizeUnitValue.MB, unit: FileSizeUnit.MB };
+ if (bytes >= FileSizeUnitValue.MiB) {
+ return { value: bytes / FileSizeUnitValue.MiB, unit: FileSizeUnit.MiB };
}
- if (bytes >= FileSizeUnitValue.KB) {
- return { value: bytes / FileSizeUnitValue.KB, unit: FileSizeUnit.KB };
+ if (bytes >= FileSizeUnitValue.KiB) {
+ return { value: bytes / FileSizeUnitValue.KiB, unit: FileSizeUnit.KiB };
}
return { value: bytes, unit: FileSizeUnit.B };
};
diff --git a/src/entities/transfer/api/types.ts b/src/entities/transfer/api/types.ts
index 0d2a526e..bec0d1b9 100644
--- a/src/entities/transfer/api/types.ts
+++ b/src/entities/transfer/api/types.ts
@@ -15,6 +15,7 @@ export interface Transfer {
strategy_params: TransferStrategyParams;
is_scheduled: boolean;
schedule: string;
+ resources: TransferResources;
transformations: Transformations;
}
@@ -35,6 +36,12 @@ export interface TransferStrategyParams {
increment_by?: TransferConnectionFileIncrementBy | string;
}
+export interface TransferResources {
+ max_parallel_tasks: number;
+ cpu_cores_per_task: number;
+ ram_bytes_per_task: number | string;
+}
+
export interface TransferSourceConnectionFileType {
type:
| ConnectionType.FTP
diff --git a/src/entities/transfer/index.ts b/src/entities/transfer/index.ts
index 1a554c55..a2835f50 100644
--- a/src/entities/transfer/index.ts
+++ b/src/entities/transfer/index.ts
@@ -1,2 +1,3 @@
export * from './api';
export * from './ui';
+export * from './utils';
diff --git a/src/entities/transfer/utils/index.ts b/src/entities/transfer/utils/index.ts
new file mode 100644
index 00000000..b200194b
--- /dev/null
+++ b/src/entities/transfer/utils/index.ts
@@ -0,0 +1,2 @@
+export * from './prepareTransferResourcesForm';
+export * from './prepareTransferResourcesRequest';
diff --git a/src/entities/transfer/utils/prepareTransferResourcesForm/index.ts b/src/entities/transfer/utils/prepareTransferResourcesForm/index.ts
new file mode 100644
index 00000000..56bc9c46
--- /dev/null
+++ b/src/entities/transfer/utils/prepareTransferResourcesForm/index.ts
@@ -0,0 +1,10 @@
+import { FileSizeUnitValue } from '@entities/file/@x/transfer';
+import { TransferResources } from '@entities/transfer';
+
+/** Util for mapping of transfer resources data from backend to appropriate form value */
+export const prepareTransferResourcesForm = (data: TransferResources): TransferResources => {
+ return {
+ ...data,
+ ram_bytes_per_task: +data.ram_bytes_per_task / FileSizeUnitValue.GiB,
+ };
+};
diff --git a/src/entities/transfer/utils/prepareTransferResourcesRequest/index.ts b/src/entities/transfer/utils/prepareTransferResourcesRequest/index.ts
new file mode 100644
index 00000000..96991652
--- /dev/null
+++ b/src/entities/transfer/utils/prepareTransferResourcesRequest/index.ts
@@ -0,0 +1,10 @@
+import { FileSizeUnit } from '@entities/file/@x/transfer';
+import { TransferResources } from '@entities/transfer';
+
+/** Util for mapping of transfer resources data from form value to appropriate value for backend */
+export const prepareTransferResourcesRequest = (data: TransferResources): TransferResources => {
+ return {
+ ...data,
+ ram_bytes_per_task: `${data.ram_bytes_per_task}${FileSizeUnit.GiB}`,
+ };
+};
diff --git a/src/features/transfer/MutateTransferForm/MutateTransferForm.tsx b/src/features/transfer/MutateTransferForm/MutateTransferForm.tsx
index e40ee8b0..f17b4d31 100644
--- a/src/features/transfer/MutateTransferForm/MutateTransferForm.tsx
+++ b/src/features/transfer/MutateTransferForm/MutateTransferForm.tsx
@@ -5,7 +5,7 @@ import { Form, Input } from 'antd';
import { useTranslation } from 'react-i18next';
import { MutateTransferFormProps } from './types';
-import { StrategyParams, TransferConnections, TransferSchedule } from './components';
+import { StrategyParams, TransferConnections, TransferResources, TransferSchedule } from './components';
export const MutateTransferForm = ({ group, onCancel }: MutateTransferFormProps) => {
const { t } = useTranslation();
@@ -39,6 +39,8 @@ export const MutateTransferForm = ({ group, onCancel }: MutateTransferFormProps)
+ {t('minValue')} = {minValue} +
++ {t('maxValue')} = {maxValue} +
+ > + ); +}; diff --git a/src/features/transfer/MutateTransferForm/components/TransferResources/components/TooltipText/types.ts b/src/features/transfer/MutateTransferForm/components/TransferResources/components/TooltipText/types.ts new file mode 100644 index 00000000..9033279c --- /dev/null +++ b/src/features/transfer/MutateTransferForm/components/TransferResources/components/TooltipText/types.ts @@ -0,0 +1,4 @@ +export interface TooltipTextProps { + minValue: string | number; + maxValue: string | number; +} diff --git a/src/features/transfer/MutateTransferForm/components/TransferResources/components/index.ts b/src/features/transfer/MutateTransferForm/components/TransferResources/components/index.ts new file mode 100644 index 00000000..93a7a09c --- /dev/null +++ b/src/features/transfer/MutateTransferForm/components/TransferResources/components/index.ts @@ -0,0 +1 @@ +export * from './TooltipText'; diff --git a/src/features/transfer/MutateTransferForm/components/TransferResources/constants.ts b/src/features/transfer/MutateTransferForm/components/TransferResources/constants.ts new file mode 100644 index 00000000..15249fe0 --- /dev/null +++ b/src/features/transfer/MutateTransferForm/components/TransferResources/constants.ts @@ -0,0 +1,8 @@ +export const MIN_PARALLEL_TASKS = 1; +export const MAX_PARALLEL_TASKS = 100; + +export const MIN_CPU_CORES_PER_TASKS = 1; +export const MAX_CPU_CORES_PER_TASKS = 32; + +export const MIN_RAM_PER_TASK = 0.5; +export const MAX_RAM_PER_TASK = 64; diff --git a/src/features/transfer/MutateTransferForm/components/TransferResources/index.tsx b/src/features/transfer/MutateTransferForm/components/TransferResources/index.tsx new file mode 100644 index 00000000..4481b6fd --- /dev/null +++ b/src/features/transfer/MutateTransferForm/components/TransferResources/index.tsx @@ -0,0 +1,68 @@ +import { Fieldset } from '@shared/ui'; +import { Form, InputNumber } from 'antd'; +import React from 'react'; +import { useTranslation } from 'react-i18next'; +import { validateFormFieldByPattern } from '@shared/utils'; +import { INTEGER_ERROR_DISPLAY, INTEGER_REGEXP } from '@shared/constants'; + +import { + MAX_PARALLEL_TASKS, + MAX_CPU_CORES_PER_TASKS, + MIN_PARALLEL_TASKS, + MIN_CPU_CORES_PER_TASKS, + MIN_RAM_PER_TASK, + MAX_RAM_PER_TASK, +} from './constants'; +import { TooltipText } from './components'; + +export const TransferResources = () => { + const { t } = useTranslation('error'); + + return ( + + ); +}; diff --git a/src/features/transfer/MutateTransferForm/components/index.ts b/src/features/transfer/MutateTransferForm/components/index.ts index 12227410..f78d3fca 100644 --- a/src/features/transfer/MutateTransferForm/components/index.ts +++ b/src/features/transfer/MutateTransferForm/components/index.ts @@ -4,3 +4,4 @@ export * from './TransferSchedule'; export * from './TransferConnections'; export * from './StrategyParams'; export * from './TransferConnectionsCanvas'; +export * from './TransferResources'; diff --git a/src/features/transfer/TransferDetailInfo/components/TransferResources/index.tsx b/src/features/transfer/TransferDetailInfo/components/TransferResources/index.tsx new file mode 100644 index 00000000..d080ca20 --- /dev/null +++ b/src/features/transfer/TransferDetailInfo/components/TransferResources/index.tsx @@ -0,0 +1,24 @@ +import React from 'react'; +import { Descriptions } from 'antd'; +import { useTranslation } from 'react-i18next'; +import { FileSizeUnitValue } from '@entities/file'; + +import { TransferResourcesProps } from './types'; + +export const TransferResources = ({ data, ...props }: TransferResourcesProps) => { + const { t } = useTranslation('transfer'); + + return ( +