@postgres.ai/shared 3.5.1-pr-1027.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.gitlab-ci.yml +60 -0
- package/components/AlertSnackbar/index.tsx +23 -0
- package/components/AlertSnackbar/useAlertSnackbar.tsx +65 -0
- package/components/Button/index.tsx +79 -0
- package/components/Button2/index.tsx +43 -0
- package/components/Button2/styles.module.scss +82 -0
- package/components/DestroyCloneModal/index.tsx +56 -0
- package/components/DestroyCloneRestrictionModal/index.tsx +50 -0
- package/components/ErrorStub/index.tsx +83 -0
- package/components/FormattedText/index.tsx +44 -0
- package/components/FormattedText/styles.module.scss +34 -0
- package/components/GatewayLink/index.tsx +33 -0
- package/components/HorizontalScrollContainer/index.tsx +131 -0
- package/components/HorizontalScrollContainer/types.ts +12 -0
- package/components/HorizontalScrollContainer/utils.ts +16 -0
- package/components/ImportantText/index.tsx +29 -0
- package/components/Link2/index.tsx +31 -0
- package/components/Link2/styles.module.scss +12 -0
- package/components/MenuButton/index.tsx +80 -0
- package/components/MenuButton/styles.module.scss +42 -0
- package/components/Modal/index.tsx +93 -0
- package/components/PageSpinner/index.tsx +18 -0
- package/components/PageSpinner/styles.module.scss +13 -0
- package/components/ResetCloneModal/index.tsx +154 -0
- package/components/SectionTitle/index.tsx +74 -0
- package/components/Select/index.tsx +42 -0
- package/components/SimpleModalControls/index.tsx +56 -0
- package/components/Spinner/icon.tsx +29 -0
- package/components/Spinner/index.tsx +16 -0
- package/components/Spinner/styles.module.scss +33 -0
- package/components/Status/index.tsx +61 -0
- package/components/Status/styles.module.scss +45 -0
- package/components/StubContainer/index.tsx +41 -0
- package/components/StubSpinner/index.tsx +49 -0
- package/components/StubSpinnerFlex/index.tsx +20 -0
- package/components/StubSpinnerFlex/styles.module.scss +20 -0
- package/components/SyntaxHighlight/index.tsx +107 -0
- package/components/Table/RowMenu/index.tsx +111 -0
- package/components/Table/index.tsx +140 -0
- package/components/Text/index.tsx +28 -0
- package/components/TextField/index.tsx +117 -0
- package/components/Tooltip/index.tsx +52 -0
- package/config/index.ts +32 -0
- package/config/links.ts +6 -0
- package/craco.config.js +80 -0
- package/helpers/getEntropy.ts +232 -0
- package/helpers/localStorage.ts +15 -0
- package/helpers/request.ts +47 -0
- package/hooks/useWindowDimensions.ts +16 -0
- package/icons/ArrowDropDown/index.tsx +29 -0
- package/icons/Circle/index.tsx +27 -0
- package/icons/External/index.tsx +14 -0
- package/icons/Info/index.tsx +12 -0
- package/icons/Renewable/index.tsx +65 -0
- package/icons/Shield/index.tsx +33 -0
- package/icons/Warning/index.tsx +29 -0
- package/meta.json +1 -0
- package/package.json +55 -0
- package/pages/Clone/Status/index.tsx +73 -0
- package/pages/Clone/context.ts +22 -0
- package/pages/Clone/index.tsx +634 -0
- package/pages/Clone/stores/Main.ts +206 -0
- package/pages/Clone/useCreatedStores.ts +11 -0
- package/pages/Configuration/Header/index.tsx +84 -0
- package/pages/Configuration/InputWithTooltip/index.tsx +240 -0
- package/pages/Configuration/ResponseMessage/index.tsx +71 -0
- package/pages/Configuration/configOptions.ts +60 -0
- package/pages/Configuration/index.tsx +1184 -0
- package/pages/Configuration/styles.module.scss +122 -0
- package/pages/Configuration/tooltipText.tsx +157 -0
- package/pages/Configuration/useForm.ts +108 -0
- package/pages/Configuration/utils/index.ts +153 -0
- package/pages/CreateClone/index.tsx +311 -0
- package/pages/CreateClone/stores/Main.ts +107 -0
- package/pages/CreateClone/styles.module.scss +71 -0
- package/pages/CreateClone/useCreatedStores.ts +11 -0
- package/pages/CreateClone/useForm.ts +36 -0
- package/pages/Instance/Clones/Header/Item/index.tsx +15 -0
- package/pages/Instance/Clones/Header/Item/styles.module.scss +17 -0
- package/pages/Instance/Clones/Header/index.tsx +74 -0
- package/pages/Instance/Clones/Header/styles.module.scss +11 -0
- package/pages/Instance/Clones/index.tsx +135 -0
- package/pages/Instance/ClonesModal/index.tsx +71 -0
- package/pages/Instance/ClonesModal/utils.ts +21 -0
- package/pages/Instance/InactiveInstance/index.tsx +165 -0
- package/pages/Instance/InactiveInstance/utils.ts +9 -0
- package/pages/Instance/Info/Connection/ConnectModal/Content/index.tsx +176 -0
- package/pages/Instance/Info/Connection/ConnectModal/Content/utils.ts +24 -0
- package/pages/Instance/Info/Connection/ConnectModal/index.tsx +36 -0
- package/pages/Instance/Info/Connection/index.tsx +81 -0
- package/pages/Instance/Info/Details/index.tsx +20 -0
- package/pages/Instance/Info/Disks/Disk/ActionsMenu/index.tsx +100 -0
- package/pages/Instance/Info/Disks/Disk/Marker/index.tsx +26 -0
- package/pages/Instance/Info/Disks/Disk/ProgressBar/PointerIcon.tsx +20 -0
- package/pages/Instance/Info/Disks/Disk/ProgressBar/index.tsx +73 -0
- package/pages/Instance/Info/Disks/Disk/Status/index.tsx +75 -0
- package/pages/Instance/Info/Disks/Disk/index.tsx +168 -0
- package/pages/Instance/Info/Disks/index.tsx +65 -0
- package/pages/Instance/Info/Icons/index.tsx +39 -0
- package/pages/Instance/Info/Retrieval/RefreshFailedAlert/index.tsx +32 -0
- package/pages/Instance/Info/Retrieval/RefreshFailedAlert/styles.module.scss +33 -0
- package/pages/Instance/Info/Retrieval/RetrievalModal/index.tsx +49 -0
- package/pages/Instance/Info/Retrieval/RetrievalModal/styles.module.scss +6 -0
- package/pages/Instance/Info/Retrieval/RetrievalTable/index.tsx +53 -0
- package/pages/Instance/Info/Retrieval/RetrievalTable/styles.module.scss +29 -0
- package/pages/Instance/Info/Retrieval/index.tsx +95 -0
- package/pages/Instance/Info/Retrieval/utils.ts +10 -0
- package/pages/Instance/Info/Snapshots/Calendar/Day/index.tsx +125 -0
- package/pages/Instance/Info/Snapshots/Calendar/index.tsx +133 -0
- package/pages/Instance/Info/Snapshots/Calendar/utils.ts +74 -0
- package/pages/Instance/Info/Snapshots/TimeLine/Day/index.tsx +79 -0
- package/pages/Instance/Info/Snapshots/TimeLine/index.tsx +57 -0
- package/pages/Instance/Info/Snapshots/index.tsx +97 -0
- package/pages/Instance/Info/Snapshots/utils.ts +18 -0
- package/pages/Instance/Info/Status/InstanceResponseModal/index.tsx +32 -0
- package/pages/Instance/Info/Status/InstanceResponseModal/styles.module.scss +3 -0
- package/pages/Instance/Info/Status/index.tsx +85 -0
- package/pages/Instance/Info/Status/styles.module.scss +12 -0
- package/pages/Instance/Info/Status/utils.ts +24 -0
- package/pages/Instance/Info/components/Property/index.tsx +32 -0
- package/pages/Instance/Info/components/Property/styles.module.scss +21 -0
- package/pages/Instance/Info/components/Section/index.tsx +50 -0
- package/pages/Instance/Info/components/ValueStatus/index.tsx +51 -0
- package/pages/Instance/Info/index.tsx +129 -0
- package/pages/Instance/SnapshotsModal/index.tsx +169 -0
- package/pages/Instance/SnapshotsModal/utils.ts +17 -0
- package/pages/Instance/Tabs/index.tsx +98 -0
- package/pages/Instance/components/ClonesList/ConnectionModal/index.tsx +196 -0
- package/pages/Instance/components/ClonesList/MenuCell/index.tsx +98 -0
- package/pages/Instance/components/ClonesList/MenuCell/utils.ts +21 -0
- package/pages/Instance/components/ClonesList/index.tsx +189 -0
- package/pages/Instance/components/ClonesList/styles.module.scss +32 -0
- package/pages/Instance/components/ErrorStub/index.tsx +77 -0
- package/pages/Instance/components/ModalReloadButton/index.tsx +43 -0
- package/pages/Instance/components/Tags/Tag/index.tsx +60 -0
- package/pages/Instance/components/Tags/index.tsx +42 -0
- package/pages/Instance/context.ts +39 -0
- package/pages/Instance/index.tsx +235 -0
- package/pages/Instance/stores/ClonesModal.ts +35 -0
- package/pages/Instance/stores/Main.ts +335 -0
- package/pages/Instance/stores/SnapshotsModal.ts +35 -0
- package/pages/Instance/styles.scss +40 -0
- package/pages/Instance/useCreatedStores.ts +14 -0
- package/pages/Logs/Icons/PlusIcon.tsx +8 -0
- package/pages/Logs/constants/index.ts +7 -0
- package/pages/Logs/hooks/useWsScroll.tsx +44 -0
- package/pages/Logs/index.tsx +267 -0
- package/pages/Logs/utils/index.ts +20 -0
- package/pages/Logs/wsLogs.ts +110 -0
- package/pages/Logs/wsSnackbar.ts +27 -0
- package/postgres.ai-shared-3.5.0.tgz +0 -0
- package/react-app-env.d.ts +71 -0
- package/scripts/copy-assets.js +30 -0
- package/scripts/pack.js +70 -0
- package/stores/Snapshots.ts +54 -0
- package/styles/colors.ts +67 -0
- package/styles/global.scss +29 -0
- package/styles/icons.tsx +1917 -0
- package/styles/mixins.scss +30 -0
- package/styles/styles.ts +87 -0
- package/styles/theme.ts +53 -0
- package/styles/vars.scss +43 -0
- package/styles/vars.ts +40 -0
- package/tsconfig.build.json +37 -0
- package/tsconfig.json +30 -0
- package/types/api/endpoints/createClone.ts +10 -0
- package/types/api/endpoints/destroyClone.ts +7 -0
- package/types/api/endpoints/getClone.ts +6 -0
- package/types/api/endpoints/getConfig.ts +6 -0
- package/types/api/endpoints/getEngine.ts +13 -0
- package/types/api/endpoints/getFullConfig.ts +4 -0
- package/types/api/endpoints/getInstance.ts +6 -0
- package/types/api/endpoints/getInstanceRetrieval.ts +6 -0
- package/types/api/endpoints/getSeImages.ts +22 -0
- package/types/api/endpoints/getSnapshots.ts +6 -0
- package/types/api/endpoints/getWSToken.ts +6 -0
- package/types/api/endpoints/initWS.ts +1 -0
- package/types/api/endpoints/refreshInstance.ts +4 -0
- package/types/api/endpoints/resetClone.ts +8 -0
- package/types/api/endpoints/testDbSource.ts +48 -0
- package/types/api/endpoints/updateClone.ts +10 -0
- package/types/api/endpoints/updateConfig.ts +6 -0
- package/types/api/entities/clone.ts +42 -0
- package/types/api/entities/config.ts +114 -0
- package/types/api/entities/dbSource.ts +13 -0
- package/types/api/entities/instance.ts +67 -0
- package/types/api/entities/instanceRetrieval.ts +46 -0
- package/types/api/entities/instanceState.ts +102 -0
- package/types/api/entities/pool.ts +27 -0
- package/types/api/entities/snapshot.ts +18 -0
- package/types/api/entities/wsToken.ts +7 -0
- package/types/byte-size/index.d.ts +22 -0
- package/utils/api.ts +30 -0
- package/utils/clone.ts +31 -0
- package/utils/connection.ts +38 -0
- package/utils/date.ts +87 -0
- package/utils/instance.ts +10 -0
- package/utils/numbers.ts +11 -0
- package/utils/react.ts +10 -0
- package/utils/snapshot.ts +4 -0
- package/utils/strings.ts +11 -0
- package/utils/units.ts +23 -0
|
@@ -0,0 +1,122 @@
|
|
|
1
|
+
.textField {
|
|
2
|
+
width: 400px;
|
|
3
|
+
max-width: 100%;
|
|
4
|
+
|
|
5
|
+
input,
|
|
6
|
+
label {
|
|
7
|
+
font-family: 'Fira Code', monospace;
|
|
8
|
+
color: #000;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
label {
|
|
12
|
+
font-size: 10px;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
:disabled {
|
|
16
|
+
cursor: not-allowed;
|
|
17
|
+
color: rgba(0, 0, 0, 0.38);
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
@media (max-width: 600px) {
|
|
21
|
+
width: 100%;
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
.chipContainer {
|
|
26
|
+
width: 350px;
|
|
27
|
+
max-width: 100%;
|
|
28
|
+
margin-bottom: 0;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
.databasesContainer {
|
|
32
|
+
width: 350px;
|
|
33
|
+
max-width: 100%;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
.chip {
|
|
37
|
+
margin-right: 8px;
|
|
38
|
+
margin-top: 8px;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
.underline {
|
|
42
|
+
text-decoration: underline;
|
|
43
|
+
cursor: pointer;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
.root {
|
|
47
|
+
font-size: 12px;
|
|
48
|
+
max-width: 450px;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
.spinner {
|
|
52
|
+
margin-left: 8px;
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
.spinnerContainer {
|
|
56
|
+
position: absolute;
|
|
57
|
+
top: 50%;
|
|
58
|
+
left: 50%;
|
|
59
|
+
transform: translate(-50%, -50%);
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
.infoIcon {
|
|
63
|
+
margin-left: 6px;
|
|
64
|
+
height: 12px;
|
|
65
|
+
width: 12px;
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
.externalIcon {
|
|
69
|
+
margin-left: 2px;
|
|
70
|
+
height: 12px;
|
|
71
|
+
width: 12px;
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
.externalLink {
|
|
75
|
+
display: inline-flex;
|
|
76
|
+
align-items: center;
|
|
77
|
+
width: max-content;
|
|
78
|
+
|
|
79
|
+
&:link,
|
|
80
|
+
&:hover {
|
|
81
|
+
color: #0000ee;
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
&:visited {
|
|
85
|
+
color: #551a8b;
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
.largeIcon {
|
|
90
|
+
height: 15px;
|
|
91
|
+
width: 15px;
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
.subsection {
|
|
95
|
+
margin-bottom: 0.25rem;
|
|
96
|
+
font-size: 13px;
|
|
97
|
+
font-weight: 500;
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
.modalTitle {
|
|
101
|
+
font-size: 16px;
|
|
102
|
+
font-weight: bold !important;
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
.sectionTitle {
|
|
106
|
+
display: flex;
|
|
107
|
+
align-items: center;
|
|
108
|
+
gap: 3px;
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
.firaCodeFont {
|
|
112
|
+
font-family: 'Fira Code', monospace !important;
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
.snackbar {
|
|
116
|
+
div {
|
|
117
|
+
background-color: #ff6212;
|
|
118
|
+
color: #fff;
|
|
119
|
+
border-radius: 4px;
|
|
120
|
+
cursor: pointer;
|
|
121
|
+
}
|
|
122
|
+
}
|
|
@@ -0,0 +1,157 @@
|
|
|
1
|
+
import styles from './styles.module.scss'
|
|
2
|
+
|
|
3
|
+
export const tooltipText = {
|
|
4
|
+
dockerTag: () => (
|
|
5
|
+
<div>
|
|
6
|
+
Docker image version - latest ones listed first. If unsure, pick the top
|
|
7
|
+
one
|
|
8
|
+
</div>
|
|
9
|
+
),
|
|
10
|
+
dockerImage: () => (
|
|
11
|
+
<div>
|
|
12
|
+
Major PostgreSQL version (e.g., "9.6", "15"). For logical provisioning
|
|
13
|
+
mode, the version used by DBLab doesn't need to match the version used on
|
|
14
|
+
the source (although, it's recommended). <br />
|
|
15
|
+
If you need a version that is not listed here, contact support.
|
|
16
|
+
</div>
|
|
17
|
+
),
|
|
18
|
+
dockerImageType: () => (
|
|
19
|
+
<div>
|
|
20
|
+
Docker image used to run all database containers – clones, snapshot
|
|
21
|
+
preparation containers, sync containers. Although such images are based on
|
|
22
|
+
traditional Docker images for Postgres, DBLab expects slightly different
|
|
23
|
+
behavior: e.g., Postgres is not the first process used to start container,
|
|
24
|
+
so Postgres restarts are possible, they do not trigger container state
|
|
25
|
+
change. For details, see{' '}
|
|
26
|
+
<a
|
|
27
|
+
target={'_blank'}
|
|
28
|
+
href={'https://postgres.ai/docs/database-lab/supported-databases'}
|
|
29
|
+
className={styles.externalLink}
|
|
30
|
+
>
|
|
31
|
+
the docs
|
|
32
|
+
</a>
|
|
33
|
+
.
|
|
34
|
+
</div>
|
|
35
|
+
),
|
|
36
|
+
sharedBuffers: () => (
|
|
37
|
+
<div>
|
|
38
|
+
Defines default buffer pool size of each Postgres instance managed by DBLab.
|
|
39
|
+
Note, that this amount of RAM is immediately allocated at Postgres startup
|
|
40
|
+
time. For example, if the machine running DBLab has 32 GiB of RAM, and the
|
|
41
|
+
value used here is '1GB', then the theoretical limit of the number of
|
|
42
|
+
clones is 32. Practically, this limit is even lower because some memory is
|
|
43
|
+
consumed by various other processes. If you need more clones, reduce the
|
|
44
|
+
value of{' '}
|
|
45
|
+
<span className={styles.firaCodeFont}>configs.shared_buffers</span>.
|
|
46
|
+
</div>
|
|
47
|
+
),
|
|
48
|
+
sharedPreloadLibraries: () => (
|
|
49
|
+
<div>
|
|
50
|
+
Specifies one or more shared libraries (comma-separated list) to be
|
|
51
|
+
preloaded at Postgres server start (
|
|
52
|
+
<a
|
|
53
|
+
target={'_blank'}
|
|
54
|
+
href={'https://postgresqlco.nf/doc/en/param/shared_preload_libraries/'}
|
|
55
|
+
className={styles.externalLink}
|
|
56
|
+
>
|
|
57
|
+
details
|
|
58
|
+
</a>
|
|
59
|
+
). If some libraries/extensions are missing, Postgres fails to start, so
|
|
60
|
+
make sure that <span className={styles.firaCodeFont}>dockerImage</span>{' '}
|
|
61
|
+
used above contains all the needed extensions.
|
|
62
|
+
</div>
|
|
63
|
+
),
|
|
64
|
+
host: () => (
|
|
65
|
+
<div>
|
|
66
|
+
Hostname/IP of database that will be used as source for data retrieval
|
|
67
|
+
(full data refresh).
|
|
68
|
+
</div>
|
|
69
|
+
),
|
|
70
|
+
port: () => (
|
|
71
|
+
<div>
|
|
72
|
+
Port of database that will be used as source for data retrieval (full data
|
|
73
|
+
refresh).
|
|
74
|
+
</div>
|
|
75
|
+
),
|
|
76
|
+
username: () => (
|
|
77
|
+
<div>
|
|
78
|
+
Username used to connect to database that will be used as source for data
|
|
79
|
+
retrieval (full data refresh).
|
|
80
|
+
</div>
|
|
81
|
+
),
|
|
82
|
+
password: () => (
|
|
83
|
+
<div>
|
|
84
|
+
Password used to connect to database that will be used as source for data
|
|
85
|
+
retrieval (full data refresh).
|
|
86
|
+
</div>
|
|
87
|
+
),
|
|
88
|
+
dbname: () => (
|
|
89
|
+
<div>
|
|
90
|
+
Database name used to connect to the source to run diagnostics queries.
|
|
91
|
+
This database is not necesserarily to be copied (another field,{' '}
|
|
92
|
+
<span className={styles.firaCodeFont}>databases</span>, defines which
|
|
93
|
+
database to copy).
|
|
94
|
+
</div>
|
|
95
|
+
),
|
|
96
|
+
databases: () => (
|
|
97
|
+
<div>
|
|
98
|
+
Specifies list of databases Postgres server to copy at data retrieval
|
|
99
|
+
(full data refresh). To specify multiple database names, provide each
|
|
100
|
+
value in a separte line or use space as a divider. To copy all available
|
|
101
|
+
databases, leave this value empty.
|
|
102
|
+
</div>
|
|
103
|
+
),
|
|
104
|
+
dumpParallelJobs: () => (
|
|
105
|
+
<div>
|
|
106
|
+
Number of parallel workers used to dump the source databases to disk. If
|
|
107
|
+
the source is production server under load, it is not recommended to use
|
|
108
|
+
more than 50% of its number of vCPUs. The higher number, the faster
|
|
109
|
+
dumping is, but the higher risks of performance issues on the source
|
|
110
|
+
(e.g., due to CPU or disk IO saturation).
|
|
111
|
+
</div>
|
|
112
|
+
),
|
|
113
|
+
pgDumpCustomOptions: () => (
|
|
114
|
+
<div>
|
|
115
|
+
pg_dump options to be used to create a database dump, for example:
|
|
116
|
+
'--exclude-schema=repack --exclude-schema="camelStyleSchemaName"'. Note
|
|
117
|
+
that due to security reasons, the current implementation supports only
|
|
118
|
+
letters, numbers, hyphen, underscore, equal sign, and double quotes.
|
|
119
|
+
</div>
|
|
120
|
+
),
|
|
121
|
+
restoreParallelJobs: () => (
|
|
122
|
+
<div>
|
|
123
|
+
Number of parallel workers used to restore databases from dump to Postgres
|
|
124
|
+
managed by DBLab. For initial data retrieval (very first data refresh), it
|
|
125
|
+
is recommended to use the number of vCPUs available on machine running
|
|
126
|
+
DBLab. With this approach, we have faster restore time, but we need to keep
|
|
127
|
+
in mind that we can also have higher usage of CPU and disk IO on this
|
|
128
|
+
machine (up to temporary saturation of resources). For subsequent
|
|
129
|
+
refreshes, if DBLab is constantly used, it is recommended to reduce this
|
|
130
|
+
value by 50% to keep some room for normal use of DBLab (such as work with
|
|
131
|
+
clones).
|
|
132
|
+
</div>
|
|
133
|
+
),
|
|
134
|
+
pgRestoreCustomOptions: () => (
|
|
135
|
+
<div>
|
|
136
|
+
pg_restore options to be used to restore from a database dump, for
|
|
137
|
+
example: '--exclude-schema=repack
|
|
138
|
+
--exclude-schema="camelStyleSchemaName"'. Note that due to security
|
|
139
|
+
reasons, the current implementation supports only letters, numbers,
|
|
140
|
+
hyphen, underscore, equal sign, and double quotes.
|
|
141
|
+
</div>
|
|
142
|
+
),
|
|
143
|
+
timetable: () => (
|
|
144
|
+
<div>
|
|
145
|
+
Schedule for full data refreshes, in{' '}
|
|
146
|
+
<a
|
|
147
|
+
target={'_blank'}
|
|
148
|
+
href={'https://en.wikipedia.org/wiki/Cron#Overview'}
|
|
149
|
+
className={styles.externalLink}
|
|
150
|
+
>
|
|
151
|
+
crontab format
|
|
152
|
+
</a>
|
|
153
|
+
.
|
|
154
|
+
</div>
|
|
155
|
+
),
|
|
156
|
+
tuningParams: () => <div>Test</div>,
|
|
157
|
+
}
|
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
/*--------------------------------------------------------------------------
|
|
2
|
+
* Copyright (c) 2019-2021, Postgres.ai, Nikolay Samokhvalov nik@postgres.ai
|
|
3
|
+
* All Rights Reserved. Proprietary and confidential.
|
|
4
|
+
* Unauthorized copying of this file, via any medium is strictly prohibited
|
|
5
|
+
*--------------------------------------------------------------------------
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
import { useFormik } from 'formik'
|
|
9
|
+
import * as Yup from 'yup'
|
|
10
|
+
|
|
11
|
+
export type FormValues = {
|
|
12
|
+
debug: boolean
|
|
13
|
+
dockerImage: string
|
|
14
|
+
dockerTag: string
|
|
15
|
+
dockerPath: string
|
|
16
|
+
dockerImageType: string
|
|
17
|
+
sharedBuffers: string
|
|
18
|
+
sharedPreloadLibraries: string
|
|
19
|
+
tuningParams: string
|
|
20
|
+
timetable: string
|
|
21
|
+
dbname: string
|
|
22
|
+
host: string
|
|
23
|
+
port: string
|
|
24
|
+
username: string
|
|
25
|
+
password: string
|
|
26
|
+
databases: string
|
|
27
|
+
dumpParallelJobs: string
|
|
28
|
+
dumpIgnoreErrors: boolean
|
|
29
|
+
restoreParallelJobs: string
|
|
30
|
+
restoreIgnoreErrors: boolean
|
|
31
|
+
pgDumpCustomOptions: string
|
|
32
|
+
pgRestoreCustomOptions: string
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
const Schema = Yup.object().shape({
|
|
36
|
+
dockerImage: Yup.string().required('Docker image is required'),
|
|
37
|
+
dbname: Yup.string().required('Dbname is required'),
|
|
38
|
+
host: Yup.string().required('Host is required'),
|
|
39
|
+
port: Yup.string().required('Port is required'),
|
|
40
|
+
username: Yup.string().required('Username is required'),
|
|
41
|
+
})
|
|
42
|
+
|
|
43
|
+
export const useForm = (onSubmit: (values: FormValues) => void) => {
|
|
44
|
+
const formik = useFormik<FormValues>({
|
|
45
|
+
initialValues: {
|
|
46
|
+
debug: false,
|
|
47
|
+
dockerImage: '',
|
|
48
|
+
dockerTag: '',
|
|
49
|
+
dockerPath: '',
|
|
50
|
+
dockerImageType: '',
|
|
51
|
+
sharedBuffers: '',
|
|
52
|
+
sharedPreloadLibraries: '',
|
|
53
|
+
tuningParams: '',
|
|
54
|
+
timetable: '',
|
|
55
|
+
dbname: '',
|
|
56
|
+
host: '',
|
|
57
|
+
port: '',
|
|
58
|
+
username: '',
|
|
59
|
+
password: '',
|
|
60
|
+
databases: '',
|
|
61
|
+
dumpParallelJobs: '',
|
|
62
|
+
restoreParallelJobs: '',
|
|
63
|
+
pgDumpCustomOptions: '',
|
|
64
|
+
pgRestoreCustomOptions: '',
|
|
65
|
+
dumpIgnoreErrors: false,
|
|
66
|
+
restoreIgnoreErrors: false,
|
|
67
|
+
},
|
|
68
|
+
validationSchema: Schema,
|
|
69
|
+
onSubmit,
|
|
70
|
+
validateOnBlur: false,
|
|
71
|
+
validateOnChange: false,
|
|
72
|
+
})
|
|
73
|
+
|
|
74
|
+
const formatDatabaseArray = (database: string) => {
|
|
75
|
+
let databases = []
|
|
76
|
+
const splitDatabaseArray = database.split(/[,(\s)(\n)(\r)(\t)(\r\n)]/)
|
|
77
|
+
|
|
78
|
+
for (let i = 0; i < splitDatabaseArray.length; i++) {
|
|
79
|
+
if (splitDatabaseArray[i] !== '') {
|
|
80
|
+
databases.push(splitDatabaseArray[i])
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
return databases
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
const connectionData = {
|
|
88
|
+
host: formik.values.host,
|
|
89
|
+
port: formik.values.port,
|
|
90
|
+
username: formik.values.username,
|
|
91
|
+
password: formik.values.password,
|
|
92
|
+
dbname: formik.values.dbname,
|
|
93
|
+
...(formik.values.databases && {
|
|
94
|
+
db_list: formatDatabaseArray(formik.values.databases),
|
|
95
|
+
}),
|
|
96
|
+
...(formik.values.dockerImageType === 'custom' && {
|
|
97
|
+
dockerImage: formik.values.dockerImage,
|
|
98
|
+
}),
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
const isConnectionDataValid =
|
|
102
|
+
formik.values.host &&
|
|
103
|
+
formik.values.port &&
|
|
104
|
+
formik.values.username &&
|
|
105
|
+
formik.values.dbname
|
|
106
|
+
|
|
107
|
+
return [{ formik, connectionData, isConnectionDataValid }]
|
|
108
|
+
}
|
|
@@ -0,0 +1,153 @@
|
|
|
1
|
+
import { DatabaseType } from '@postgres.ai/shared/types/api/entities/config'
|
|
2
|
+
|
|
3
|
+
import { dockerImageOptions } from '../configOptions'
|
|
4
|
+
import { FormValues } from '../useForm'
|
|
5
|
+
|
|
6
|
+
const seContainerRegistry = 'se-images'
|
|
7
|
+
const genericImagePrefix = 'postgresai/extended-postgres'
|
|
8
|
+
// since some tags are rc, we need to specify the exact tags to use
|
|
9
|
+
const dockerImagesConfig = {
|
|
10
|
+
'9.6': ['0.5.2', '0.5.1', '0.4.6'],
|
|
11
|
+
'10': ['0.5.2', '0.5.1', '0.4.6'],
|
|
12
|
+
'11': ['0.5.2', '0.5.1', '0.4.6'],
|
|
13
|
+
'12': ['0.5.2', '0.5.1', '0.4.6'],
|
|
14
|
+
'13': ['0.5.2', '0.5.1', '0.4.6'],
|
|
15
|
+
'14': ['0.5.2', '0.5.1', '0.4.6'],
|
|
16
|
+
'15': ['0.5.2', '0.5.1', '0.4.6'],
|
|
17
|
+
'16': ['0.5.2', '0.5.1', '0.4.6'],
|
|
18
|
+
'17': ['0.5.2', '0.5.1'],
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
export type FormValuesKey = keyof FormValues
|
|
22
|
+
|
|
23
|
+
interface DockerImage {
|
|
24
|
+
package_group: string
|
|
25
|
+
pg_major_version: string
|
|
26
|
+
tag: string
|
|
27
|
+
location: string
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
type DockerImagesConfig = Record<string, string[]>
|
|
31
|
+
|
|
32
|
+
export const uniqueChipValue = (values: string) => {
|
|
33
|
+
const splitChipArray = values.split(/[,(\s)(\n)(\r)(\t)(\r\n)]/)
|
|
34
|
+
let databaseArray = []
|
|
35
|
+
|
|
36
|
+
for (let i in splitChipArray) {
|
|
37
|
+
if (
|
|
38
|
+
splitChipArray[i] !== '' &&
|
|
39
|
+
databaseArray.indexOf(splitChipArray[i]) === -1
|
|
40
|
+
) {
|
|
41
|
+
databaseArray.push(splitChipArray[i])
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
return databaseArray.join(' ')
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
export const postUniqueDatabases = (values: string) => {
|
|
49
|
+
const splitDatabaseArray = values.split(/[,(\s)(\n)(\r)(\t)(\r\n)]/)
|
|
50
|
+
|
|
51
|
+
const databases = splitDatabaseArray.reduce((acc: DatabaseType, curr) => {
|
|
52
|
+
acc[curr] = {}
|
|
53
|
+
return acc
|
|
54
|
+
}, {})
|
|
55
|
+
|
|
56
|
+
const nonEmptyDatabase = Object.fromEntries(
|
|
57
|
+
Object.entries(databases).filter(([name]) => name != ''),
|
|
58
|
+
)
|
|
59
|
+
|
|
60
|
+
return values.length !== 0 ? nonEmptyDatabase : null
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
const createDockerImages = (
|
|
64
|
+
dockerImagesConfig: DockerImagesConfig,
|
|
65
|
+
): DockerImage[] => {
|
|
66
|
+
const dockerImages: DockerImage[] = []
|
|
67
|
+
|
|
68
|
+
for (const pg_major_version in dockerImagesConfig) {
|
|
69
|
+
if (dockerImagesConfig.hasOwnProperty(pg_major_version)) {
|
|
70
|
+
const customTags = dockerImagesConfig[pg_major_version]
|
|
71
|
+
|
|
72
|
+
customTags.forEach((tag) => {
|
|
73
|
+
const image: DockerImage = {
|
|
74
|
+
package_group: 'postgresai',
|
|
75
|
+
pg_major_version,
|
|
76
|
+
tag: `${pg_major_version}-${tag}`,
|
|
77
|
+
location: `${genericImagePrefix}:${pg_major_version}-${tag}`,
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
dockerImages.push(image)
|
|
81
|
+
})
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
return dockerImages
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
export const genericDockerImages = createDockerImages(dockerImagesConfig)
|
|
89
|
+
|
|
90
|
+
export const isSeDockerImage = (dockerImage: string | undefined) => {
|
|
91
|
+
const dockerImageType =
|
|
92
|
+
dockerImage?.includes(seContainerRegistry) &&
|
|
93
|
+
dockerImage.split(`${seContainerRegistry}/`)[1]?.split(':')[0]
|
|
94
|
+
|
|
95
|
+
return dockerImageOptions.some((element) => element.type === dockerImageType)
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
export const getImageType = (imageUrl: string) => {
|
|
99
|
+
const postgresCustomImageType =
|
|
100
|
+
imageUrl.includes(seContainerRegistry) &&
|
|
101
|
+
imageUrl.split(`${seContainerRegistry}/`)[1]?.split(':')[0]
|
|
102
|
+
|
|
103
|
+
if (imageUrl.includes(genericImagePrefix)) {
|
|
104
|
+
return 'Generic Postgres'
|
|
105
|
+
} else if (postgresCustomImageType && isSeDockerImage(imageUrl)) {
|
|
106
|
+
return postgresCustomImageType
|
|
107
|
+
} else {
|
|
108
|
+
return 'custom'
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
export const getImageMajorVersion = (pgImage: string | undefined) => {
|
|
113
|
+
const pgImageVersion = pgImage?.split(':')[1]
|
|
114
|
+
const pgServerVersion = pgImageVersion?.split('-')[0]
|
|
115
|
+
return pgServerVersion?.includes('.')
|
|
116
|
+
? pgServerVersion?.split('.')[0]
|
|
117
|
+
: pgServerVersion
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
export const formatDatabases = (databases: DatabaseType | null) => {
|
|
121
|
+
let formattedDatabases = ''
|
|
122
|
+
|
|
123
|
+
if (databases !== null) {
|
|
124
|
+
Object.keys(databases).forEach(function (key) {
|
|
125
|
+
formattedDatabases += key + ' '
|
|
126
|
+
})
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
return formattedDatabases
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
export const formatDumpCustomOptions = (options: string[] | null) => {
|
|
133
|
+
let formattedOptions = ''
|
|
134
|
+
|
|
135
|
+
if (options !== null) {
|
|
136
|
+
options.forEach(function (key) {
|
|
137
|
+
formattedOptions += key + ' '
|
|
138
|
+
})
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
return formattedOptions
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
export const postUniqueCustomOptions = (options: string) => {
|
|
145
|
+
const splitOptionsArray = options.split(/[,(\s)(\n)(\r)(\t)(\r\n)]/)
|
|
146
|
+
const uniqueOptions = splitOptionsArray.filter(
|
|
147
|
+
(item, index) => splitOptionsArray.indexOf(item) === index && item !== '',
|
|
148
|
+
)
|
|
149
|
+
return uniqueOptions
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
export const customOrGenericImage = (dockerImage: string | undefined) =>
|
|
153
|
+
dockerImage === 'Generic Postgres' || dockerImage === 'custom'
|