parent
130b815f61
commit
f59d1f57f3
@ -0,0 +1,11 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<!-- The icon received from: https://github.com/gilbarbara/logos -->
|
||||||
|
<!-- License: CC0-1.0 License -->
|
||||||
|
<svg width="1em" height="1em" viewBox="0 0 256 206" version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" preserveAspectRatio="xMidYMid">
|
||||||
|
<g>
|
||||||
|
<path d="M170.2517,56.8186 L192.5047,34.5656 L193.9877,25.1956 C153.4367,-11.6774 88.9757,-7.4964 52.4207,33.9196 C42.2667,45.4226 34.7337,59.7636 30.7167,74.5726 L38.6867,73.4496 L83.1917,66.1106 L86.6277,62.5966 C106.4247,40.8546 139.8977,37.9296 162.7557,56.4286 L170.2517,56.8186 Z" fill="#EA4335"></path>
|
||||||
|
<path d="M224.2048,73.9182 C219.0898,55.0822 208.5888,38.1492 193.9878,25.1962 L162.7558,56.4282 C175.9438,67.2042 183.4568,83.4382 183.1348,100.4652 L183.1348,106.0092 C198.4858,106.0092 210.9318,118.4542 210.9318,133.8052 C210.9318,149.1572 198.4858,161.2902 183.1348,161.2902 L127.4638,161.2902 L121.9978,167.2242 L121.9978,200.5642 L127.4638,205.7952 L183.1348,205.7952 C223.0648,206.1062 255.6868,174.3012 255.9978,134.3712 C256.1858,110.1682 244.2528,87.4782 224.2048,73.9182" fill="#4285F4"></path>
|
||||||
|
<path d="M71.8704,205.7957 L127.4634,205.7957 L127.4634,161.2897 L71.8704,161.2897 C67.9094,161.2887 64.0734,160.4377 60.4714,158.7917 L52.5844,161.2117 L30.1754,183.4647 L28.2234,191.0387 C40.7904,200.5277 56.1234,205.8637 71.8704,205.7957" fill="#34A853"></path>
|
||||||
|
<path d="M71.8704,61.4255 C31.9394,61.6635 -0.2366,94.2275 0.0014,134.1575 C0.1344,156.4555 10.5484,177.4455 28.2234,191.0385 L60.4714,158.7915 C46.4804,152.4705 40.2634,136.0055 46.5844,122.0155 C52.9044,108.0255 69.3704,101.8085 83.3594,108.1285 C89.5244,110.9135 94.4614,115.8515 97.2464,122.0155 L129.4944,89.7685 C115.7734,71.8315 94.4534,61.3445 71.8704,61.4255" fill="#FBBC05"></path>
|
||||||
|
</g>
|
||||||
|
</svg>
|
||||||
|
After Width: | Height: | Size: 1.8 KiB |
@ -0,0 +1,31 @@
|
|||||||
|
// Copyright (C) 2021 Intel Corporation
|
||||||
|
//
|
||||||
|
// SPDX-License-Identifier: MIT
|
||||||
|
import React from 'react';
|
||||||
|
import Location from './location';
|
||||||
|
import consts from '../../consts';
|
||||||
|
|
||||||
|
interface Props {
|
||||||
|
selectedRegion: any;
|
||||||
|
onSelectRegion: any;
|
||||||
|
internalCommonProps: any;
|
||||||
|
}
|
||||||
|
|
||||||
|
export default function GCSLocation(props: Props): JSX.Element {
|
||||||
|
const {
|
||||||
|
selectedRegion,
|
||||||
|
onSelectRegion,
|
||||||
|
internalCommonProps,
|
||||||
|
} = props;
|
||||||
|
return (
|
||||||
|
<Location
|
||||||
|
selectedRegion={selectedRegion}
|
||||||
|
onSelectRegion={onSelectRegion}
|
||||||
|
internalCommonProps={internalCommonProps}
|
||||||
|
values={consts.DEFAULT_GOOGLE_CLOUD_STORAGE_LOCATIONS}
|
||||||
|
name='location'
|
||||||
|
label='Location'
|
||||||
|
href='https://cloud.google.com/storage/docs/locations#available-locations'
|
||||||
|
/>
|
||||||
|
);
|
||||||
|
}
|
||||||
@ -0,0 +1,123 @@
|
|||||||
|
// Copyright (C) 2021 Intel Corporation
|
||||||
|
//
|
||||||
|
// SPDX-License-Identifier: MIT
|
||||||
|
|
||||||
|
import React, { useState } from 'react';
|
||||||
|
import Divider from 'antd/lib/divider';
|
||||||
|
import Select from 'antd/lib/select';
|
||||||
|
import { PlusCircleOutlined, QuestionCircleOutlined } from '@ant-design/icons';
|
||||||
|
import Input from 'antd/lib/input';
|
||||||
|
import Button from 'antd/lib/button';
|
||||||
|
import Form from 'antd/lib/form';
|
||||||
|
import notification from 'antd/lib/notification';
|
||||||
|
import Tooltip from 'antd/lib/tooltip';
|
||||||
|
|
||||||
|
const { Option } = Select;
|
||||||
|
interface Props {
|
||||||
|
selectedRegion: undefined | string;
|
||||||
|
onSelectRegion: any;
|
||||||
|
internalCommonProps: any;
|
||||||
|
|
||||||
|
label: 'Location' | 'Region';
|
||||||
|
name: 'location' | 'region';
|
||||||
|
values: string[][];
|
||||||
|
href: string;
|
||||||
|
}
|
||||||
|
|
||||||
|
interface Locations {
|
||||||
|
[index: string]: string;
|
||||||
|
}
|
||||||
|
|
||||||
|
export default function Location(props: Props): JSX.Element {
|
||||||
|
const {
|
||||||
|
selectedRegion, onSelectRegion, internalCommonProps, name, values, href, label,
|
||||||
|
} = props;
|
||||||
|
const [locations, setLocations] = useState<Locations>(() => Object.fromEntries(values));
|
||||||
|
const [newRegionKey, setNewRegionKey] = useState<string>('');
|
||||||
|
const [newRegionName, setNewRegionName] = useState<string>('');
|
||||||
|
|
||||||
|
const handleAddingRegion = (): void => {
|
||||||
|
if (!newRegionKey || !newRegionName) {
|
||||||
|
notification.warning({
|
||||||
|
message: 'Incorrect region',
|
||||||
|
className: 'cvat-incorrect-add-region-notification',
|
||||||
|
});
|
||||||
|
} else if (locations[newRegionKey]) {
|
||||||
|
notification.warning({
|
||||||
|
message: 'This region already exists',
|
||||||
|
className: 'cvat-incorrect-add-region-notification',
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
setLocations({
|
||||||
|
...locations,
|
||||||
|
[newRegionKey]: newRegionName,
|
||||||
|
});
|
||||||
|
setNewRegionKey('');
|
||||||
|
setNewRegionName('');
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
return (
|
||||||
|
<Form.Item
|
||||||
|
label={(
|
||||||
|
<>
|
||||||
|
{label}
|
||||||
|
<Tooltip title='More information'>
|
||||||
|
<Button
|
||||||
|
className='cvat-cloud-storage-help-button'
|
||||||
|
type='link'
|
||||||
|
target='_blank'
|
||||||
|
href={href}
|
||||||
|
>
|
||||||
|
<QuestionCircleOutlined />
|
||||||
|
</Button>
|
||||||
|
</Tooltip>
|
||||||
|
</>
|
||||||
|
)}
|
||||||
|
name={name}
|
||||||
|
{...internalCommonProps}
|
||||||
|
>
|
||||||
|
<Select
|
||||||
|
placeholder={name}
|
||||||
|
defaultValue={selectedRegion ? locations[selectedRegion] : undefined}
|
||||||
|
dropdownRender={(menu) => (
|
||||||
|
<div>
|
||||||
|
{menu}
|
||||||
|
<Divider className='cvat-divider' />
|
||||||
|
<div className='cvat-cloud-storage-region-creator'>
|
||||||
|
<Input
|
||||||
|
value={newRegionKey}
|
||||||
|
onChange={(event: any) => setNewRegionKey(event.target.value)}
|
||||||
|
maxLength={14}
|
||||||
|
placeholder='key'
|
||||||
|
/>
|
||||||
|
<Input
|
||||||
|
value={newRegionName}
|
||||||
|
onChange={(event: any) => setNewRegionName(event.target.value)}
|
||||||
|
placeholder='name'
|
||||||
|
/>
|
||||||
|
<Button
|
||||||
|
type='link'
|
||||||
|
onClick={handleAddingRegion}
|
||||||
|
>
|
||||||
|
Add region
|
||||||
|
<PlusCircleOutlined />
|
||||||
|
</Button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
)}
|
||||||
|
onSelect={(_, instance) => onSelectRegion(instance.key)}
|
||||||
|
>
|
||||||
|
{
|
||||||
|
Array.from(Object.entries(locations)).map(
|
||||||
|
([key, value]): JSX.Element => (
|
||||||
|
<Option key={key} value={value}>
|
||||||
|
{value}
|
||||||
|
</Option>
|
||||||
|
),
|
||||||
|
)
|
||||||
|
}
|
||||||
|
</Select>
|
||||||
|
</Form.Item>
|
||||||
|
);
|
||||||
|
}
|
||||||
@ -1,119 +1,31 @@
|
|||||||
// Copyright (C) 2021 Intel Corporation
|
// Copyright (C) 2021 Intel Corporation
|
||||||
//
|
//
|
||||||
// SPDX-License-Identifier: MIT
|
// SPDX-License-Identifier: MIT
|
||||||
|
import React from 'react';
|
||||||
import React, { useState } from 'react';
|
import Location from './location';
|
||||||
import Divider from 'antd/lib/divider';
|
|
||||||
import Select from 'antd/lib/select';
|
|
||||||
import { PlusCircleOutlined, QuestionCircleOutlined } from '@ant-design/icons';
|
|
||||||
import Input from 'antd/lib/input';
|
|
||||||
import Button from 'antd/lib/button';
|
|
||||||
import Form from 'antd/lib/form';
|
|
||||||
import notification from 'antd/lib/notification';
|
|
||||||
import Tooltip from 'antd/lib/tooltip';
|
|
||||||
import consts from '../../consts';
|
import consts from '../../consts';
|
||||||
|
|
||||||
const { Option } = Select;
|
|
||||||
interface Props {
|
interface Props {
|
||||||
selectedRegion: undefined | string;
|
selectedRegion: any;
|
||||||
onSelectRegion: any;
|
onSelectRegion: any;
|
||||||
internalCommonProps: any;
|
internalCommonProps: any;
|
||||||
}
|
}
|
||||||
|
|
||||||
function prepareDefaultRegions(): Map<string, string> {
|
|
||||||
const temp = new Map<string, string>();
|
|
||||||
for (const [key, value] of consts.DEFAULT_AWS_S3_REGIONS) {
|
|
||||||
temp.set(key, value);
|
|
||||||
}
|
|
||||||
return temp;
|
|
||||||
}
|
|
||||||
|
|
||||||
export default function S3Region(props: Props): JSX.Element {
|
export default function S3Region(props: Props): JSX.Element {
|
||||||
const { selectedRegion, onSelectRegion, internalCommonProps } = props;
|
const {
|
||||||
const [regions, setRegions] = useState<Map<string, string>>(() => prepareDefaultRegions());
|
selectedRegion,
|
||||||
const [newRegionKey, setNewRegionKey] = useState<string>('');
|
onSelectRegion,
|
||||||
const [newRegionName, setNewRegionName] = useState<string>('');
|
internalCommonProps,
|
||||||
|
} = props;
|
||||||
const handleAddingRegion = (): void => {
|
|
||||||
if (!newRegionKey || !newRegionName) {
|
|
||||||
notification.warning({
|
|
||||||
message: 'Incorrect region',
|
|
||||||
className: 'cvat-incorrect-add-region-notification',
|
|
||||||
});
|
|
||||||
} else if (regions.has(newRegionKey)) {
|
|
||||||
notification.warning({
|
|
||||||
message: 'This region already exists',
|
|
||||||
className: 'cvat-incorrect-add-region-notification',
|
|
||||||
});
|
|
||||||
} else {
|
|
||||||
const regionsCopy = regions;
|
|
||||||
setRegions(regionsCopy.set(newRegionKey, newRegionName));
|
|
||||||
setNewRegionKey('');
|
|
||||||
setNewRegionName('');
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Form.Item
|
<Location
|
||||||
label={(
|
selectedRegion={selectedRegion}
|
||||||
<>
|
onSelectRegion={onSelectRegion}
|
||||||
Region
|
internalCommonProps={internalCommonProps}
|
||||||
<Tooltip title='More information'>
|
values={consts.DEFAULT_AWS_S3_REGIONS}
|
||||||
<Button
|
|
||||||
className='cvat-cloud-storage-help-button'
|
|
||||||
type='link'
|
|
||||||
target='_blank'
|
|
||||||
href='https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/using-regions-availability-zones.html#concepts-available-regions'
|
|
||||||
>
|
|
||||||
<QuestionCircleOutlined />
|
|
||||||
</Button>
|
|
||||||
</Tooltip>
|
|
||||||
</>
|
|
||||||
)}
|
|
||||||
name='region'
|
name='region'
|
||||||
{...internalCommonProps}
|
label='Region'
|
||||||
>
|
href='https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/using-regions-availability-zones.html#concepts-available-regions'
|
||||||
<Select
|
/>
|
||||||
placeholder='Select region'
|
|
||||||
defaultValue={selectedRegion ? regions.get(selectedRegion) : undefined}
|
|
||||||
dropdownRender={(menu) => (
|
|
||||||
<div>
|
|
||||||
{menu}
|
|
||||||
<Divider className='cvat-divider' />
|
|
||||||
<div className='cvat-cloud-storage-region-creator'>
|
|
||||||
<Input
|
|
||||||
value={newRegionKey}
|
|
||||||
onChange={(event: any) => setNewRegionKey(event.target.value)}
|
|
||||||
maxLength={14}
|
|
||||||
placeholder='key'
|
|
||||||
/>
|
|
||||||
<Input
|
|
||||||
value={newRegionName}
|
|
||||||
onChange={(event: any) => setNewRegionName(event.target.value)}
|
|
||||||
placeholder='name'
|
|
||||||
/>
|
|
||||||
<Button
|
|
||||||
type='link'
|
|
||||||
onClick={handleAddingRegion}
|
|
||||||
>
|
|
||||||
Add region
|
|
||||||
<PlusCircleOutlined />
|
|
||||||
</Button>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
)}
|
|
||||||
onSelect={(_, instance) => onSelectRegion(instance.key)}
|
|
||||||
>
|
|
||||||
{
|
|
||||||
Array.from(regions.entries()).map(
|
|
||||||
([key, value]): JSX.Element => (
|
|
||||||
<Option key={key} value={value}>
|
|
||||||
{value}
|
|
||||||
</Option>
|
|
||||||
),
|
|
||||||
)
|
|
||||||
}
|
|
||||||
</Select>
|
|
||||||
</Form.Item>
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -0,0 +1,23 @@
|
|||||||
|
# Generated by Django 3.1.13 on 2021-11-23 08:24
|
||||||
|
|
||||||
|
from django.db import migrations, models
|
||||||
|
|
||||||
|
|
||||||
|
class Migration(migrations.Migration):
|
||||||
|
|
||||||
|
dependencies = [
|
||||||
|
('engine', '0044_auto_20211115_0858'),
|
||||||
|
]
|
||||||
|
|
||||||
|
operations = [
|
||||||
|
migrations.AlterField(
|
||||||
|
model_name='cloudstorage',
|
||||||
|
name='resource',
|
||||||
|
field=models.CharField(max_length=222),
|
||||||
|
),
|
||||||
|
migrations.AlterField(
|
||||||
|
model_name='cloudstorage',
|
||||||
|
name='specific_attributes',
|
||||||
|
field=models.CharField(blank=True, max_length=128),
|
||||||
|
),
|
||||||
|
]
|
||||||
Loading…
Reference in New Issue