Skip to content

Commit d61532e

Browse files
ZabilsyaZabilsya
andauthored
[DOP-22294] add transfer resources (#81)
Co-authored-by: Zabilsya <[email protected]>
1 parent c0a8a52 commit d61532e

File tree

29 files changed

+232
-31
lines changed

29 files changed

+232
-31
lines changed

src/app/styles/antd.less

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,3 +59,7 @@
5959
display: flex;
6060
justify-content: space-between;
6161
}
62+
63+
p:last-of-type {
64+
margin-bottom: 0;
65+
}

src/app/styles/variables.less

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,4 +22,5 @@
2222
@picker-bg: #f1f3f5;
2323
@tooltip-bg: #000000;
2424

25+
@tooltip-max-width: 300px;
2526
@line-height-base: 1.5;

src/entities/file/@x/transfer.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
/** Cross-import entities using public API in FSD https://feature-sliced.design/ru/docs/reference/public-api#public-api-for-cross-imports */
22
export type { FileFormat, Json } from '../types';
3+
export { FileSizeUnitValue, FileSizeUnit } from '../types';
34
export { FileFormatParams, FileNameTemplate } from '../ui';

src/entities/file/constants.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import { FileSizeUnit } from './types';
22

33
export const FILE_SIZE_UNIT_DISPLAY = {
44
[FileSizeUnit.B]: 'b',
5-
[FileSizeUnit.KB]: 'kb',
6-
[FileSizeUnit.MB]: 'mb',
7-
[FileSizeUnit.GB]: 'gb',
5+
[FileSizeUnit.KiB]: 'kib',
6+
[FileSizeUnit.MiB]: 'mib',
7+
[FileSizeUnit.GiB]: 'gib',
88
} as const;

src/entities/file/types.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
11
export enum FileSizeUnit {
22
B = 'B',
3-
KB = 'KB',
4-
MB = 'MB',
5-
GB = 'GB',
3+
KiB = 'KiB',
4+
MiB = 'MiB',
5+
GiB = 'GiB',
66
}
77

88
export enum FileSizeUnitValue {
99
B = 1,
10-
KB = 1000,
11-
MB = 1000 * 1000,
12-
GB = 1000 * 1000 * 1000,
10+
KiB = 1024,
11+
MiB = 1024 * 1024,
12+
GiB = 1024 * 1024 * 1024,
1313
}
1414

1515
export enum FileCompression {

src/entities/file/utils/parseFileSize/index.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,14 @@ import { ParseFileSizeReturn } from './types';
44

55
/** Util for parsing file size in bytes to appropriate unit and value */
66
export const parseFileSize = (bytes: number): ParseFileSizeReturn => {
7-
if (bytes >= FileSizeUnitValue.GB) {
8-
return { value: bytes / FileSizeUnitValue.GB, unit: FileSizeUnit.GB };
7+
if (bytes >= FileSizeUnitValue.GiB) {
8+
return { value: bytes / FileSizeUnitValue.GiB, unit: FileSizeUnit.GiB };
99
}
10-
if (bytes >= FileSizeUnitValue.MB) {
11-
return { value: bytes / FileSizeUnitValue.MB, unit: FileSizeUnit.MB };
10+
if (bytes >= FileSizeUnitValue.MiB) {
11+
return { value: bytes / FileSizeUnitValue.MiB, unit: FileSizeUnit.MiB };
1212
}
13-
if (bytes >= FileSizeUnitValue.KB) {
14-
return { value: bytes / FileSizeUnitValue.KB, unit: FileSizeUnit.KB };
13+
if (bytes >= FileSizeUnitValue.KiB) {
14+
return { value: bytes / FileSizeUnitValue.KiB, unit: FileSizeUnit.KiB };
1515
}
1616
return { value: bytes, unit: FileSizeUnit.B };
1717
};

src/entities/transfer/api/types.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ export interface Transfer {
1515
strategy_params: TransferStrategyParams;
1616
is_scheduled: boolean;
1717
schedule: string;
18+
resources: TransferResources;
1819
transformations: Transformations;
1920
}
2021

@@ -35,6 +36,12 @@ export interface TransferStrategyParams {
3536
increment_by?: TransferConnectionFileIncrementBy | string;
3637
}
3738

39+
export interface TransferResources {
40+
max_parallel_tasks: number;
41+
cpu_cores_per_task: number;
42+
ram_bytes_per_task: number | string;
43+
}
44+
3845
export interface TransferSourceConnectionFileType {
3946
type:
4047
| ConnectionType.FTP

src/entities/transfer/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
11
export * from './api';
22
export * from './ui';
3+
export * from './utils';
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
export * from './prepareTransferResourcesForm';
2+
export * from './prepareTransferResourcesRequest';
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
import { FileSizeUnitValue } from '@entities/file/@x/transfer';
2+
import { TransferResources } from '@entities/transfer';
3+
4+
/** Util for mapping of transfer resources data from backend to appropriate form value */
5+
export const prepareTransferResourcesForm = (data: TransferResources): TransferResources => {
6+
return {
7+
...data,
8+
ram_bytes_per_task: +data.ram_bytes_per_task / FileSizeUnitValue.GiB,
9+
};
10+
};

0 commit comments

Comments
 (0)