-
Notifications
You must be signed in to change notification settings - Fork 97
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
390b98f
commit c8bce78
Showing
11 changed files
with
285 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
import { ClickhouseConfig, SSHConfig } from '@/grpc_generated/peers'; | ||
import { Dispatch, SetStateAction } from 'react'; | ||
import { PeerSetting } from './common'; | ||
|
||
export const clickhouseSetting: PeerSetting[] = [ | ||
{ | ||
label: 'Host', | ||
stateHandler: (value, setter) => | ||
setter((curr) => ({ ...curr, host: value })), | ||
tips: 'Specifies the IP host name or address on which postgres is to listen for TCP/IP connections from client applications. Ensure that this host has us whitelisted so we can connect to it.', | ||
}, | ||
{ | ||
label: 'Port', | ||
stateHandler: (value, setter) => | ||
setter((curr) => ({ ...curr, port: parseInt(value, 10) })), | ||
type: 'number', // type for textfield | ||
default: 5432, | ||
tips: 'Specifies the TCP/IP port or local Unix domain socket file extension on which postgres is listening for connections from client applications.', | ||
}, | ||
{ | ||
label: 'User', | ||
stateHandler: (value, setter) => | ||
setter((curr) => ({ ...curr, user: value })), | ||
tips: 'Specify the user that we should use to connect to this host.', | ||
helpfulLink: 'https://www.postgresql.org/docs/8.0/user-manag.html', | ||
}, | ||
{ | ||
label: 'Password', | ||
stateHandler: (value, setter) => | ||
setter((curr) => ({ ...curr, password: value })), | ||
type: 'password', | ||
tips: 'Password associated with the user you provided.', | ||
helpfulLink: 'https://www.postgresql.org/docs/current/auth-password.html', | ||
}, | ||
{ | ||
label: 'Database', | ||
stateHandler: (value, setter) => | ||
setter((curr) => ({ ...curr, database: value })), | ||
tips: 'Specify which database to associate with this peer.', | ||
helpfulLink: | ||
'https://www.postgresql.org/docs/current/sql-createdatabase.html', | ||
}, | ||
{ | ||
label: 'S3 Integration', | ||
stateHandler: (value, setter) => | ||
setter((curr) => ({ ...curr, s3Integration: value })), | ||
optional: true, | ||
tips: `This is needed only if you plan to run a mirror and you wish to stage AVRO files on S3.`, | ||
helpfulLink: | ||
'https://docs.snowflake.com/en/user-guide/data-load-s3-config-storage-integration', | ||
}, | ||
|
||
]; | ||
|
||
export const blankClickhouseSetting: ClickhouseConfig = { | ||
host: '', | ||
port: 5432, | ||
user: '', | ||
password: '', | ||
database: '', | ||
s3Integration:'' | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,156 @@ | ||
'use client'; | ||
import { PeerSetter } from '@/app/dto/PeersDTO'; | ||
import { PeerSetting } from '@/app/peers/create/[peerType]/helpers/common'; | ||
import { | ||
blankSSHConfig, | ||
sshSetting, | ||
} from '@/app/peers/create/[peerType]/helpers/pg'; | ||
import { SSHConfig } from '@/grpc_generated/peers'; | ||
import { Label } from '@/lib/Label'; | ||
import { RowWithTextField } from '@/lib/Layout'; | ||
import { Switch } from '@/lib/Switch'; | ||
import { TextField } from '@/lib/TextField'; | ||
import { Tooltip } from '@/lib/Tooltip'; | ||
import { useEffect, useState } from 'react'; | ||
import { InfoPopover } from '../InfoPopover'; | ||
interface ConfigProps { | ||
settings: PeerSetting[]; | ||
setter: PeerSetter; | ||
} | ||
|
||
export default function PostgresForm({ settings, setter }: ConfigProps) { | ||
const [showSSH, setShowSSH] = useState<boolean>(false); | ||
const [sshConfig, setSSHConfig] = useState<SSHConfig>(blankSSHConfig); | ||
|
||
const handleChange = ( | ||
e: React.ChangeEvent<HTMLInputElement>, | ||
setting: PeerSetting | ||
) => { | ||
setting.stateHandler(e.target.value, setter); | ||
}; | ||
|
||
useEffect(() => { | ||
setter((prev) => { | ||
return { | ||
...prev, | ||
sshConfig: showSSH ? sshConfig : undefined, | ||
}; | ||
}); | ||
}, [sshConfig, setter, showSSH]); | ||
|
||
return ( | ||
<> | ||
{settings.map((setting, id) => { | ||
return ( | ||
<RowWithTextField | ||
key={id} | ||
label={ | ||
<Label> | ||
{setting.label}{' '} | ||
{!setting.optional && ( | ||
<Tooltip | ||
style={{ width: '100%' }} | ||
content={'This is a required field.'} | ||
> | ||
<Label colorName='lowContrast' colorSet='destructive'> | ||
* | ||
</Label> | ||
</Tooltip> | ||
)} | ||
</Label> | ||
} | ||
action={ | ||
<div | ||
style={{ | ||
display: 'flex', | ||
flexDirection: 'row', | ||
alignItems: 'center', | ||
}} | ||
> | ||
<TextField | ||
variant='simple' | ||
type={setting.type} | ||
defaultValue={setting.default} | ||
onChange={(e: React.ChangeEvent<HTMLInputElement>) => | ||
handleChange(e, setting) | ||
} | ||
/> | ||
{setting.tips && ( | ||
<InfoPopover tips={setting.tips} link={setting.helpfulLink} /> | ||
)} | ||
</div> | ||
} | ||
/> | ||
); | ||
})} | ||
|
||
<Label | ||
as='label' | ||
style={{ marginTop: '1rem' }} | ||
variant='subheadline' | ||
colorName='lowContrast' | ||
> | ||
SSH Configuration | ||
</Label> | ||
<Label> | ||
You may provide SSH configuration to connect to your PostgreSQL database | ||
through SSH tunnel. | ||
</Label> | ||
<div style={{ width: '50%', display: 'flex', alignItems: 'center' }}> | ||
<Label variant='subheadline'>Configure SSH Tunnel</Label> | ||
<Switch onCheckedChange={(state) => setShowSSH(state)} /> | ||
</div> | ||
{showSSH && | ||
sshSetting.map((sshParam, index) => ( | ||
<RowWithTextField | ||
key={index} | ||
label={ | ||
<Label> | ||
{sshParam.label}{' '} | ||
{!sshParam.optional && ( | ||
<Tooltip | ||
style={{ width: '100%' }} | ||
content={'This is a required field.'} | ||
> | ||
<Label colorName='lowContrast' colorSet='destructive'> | ||
* | ||
</Label> | ||
</Tooltip> | ||
)} | ||
</Label> | ||
} | ||
action={ | ||
<div | ||
style={{ | ||
display: 'flex', | ||
flexDirection: 'row', | ||
alignItems: 'center', | ||
}} | ||
> | ||
<TextField | ||
variant='simple' | ||
onChange={(e: React.ChangeEvent<HTMLInputElement>) => | ||
sshParam.stateHandler(e.target.value, setSSHConfig) | ||
} | ||
type={sshParam.type} | ||
defaultValue={ | ||
(sshConfig as SSHConfig)[ | ||
sshParam.label === 'BASE64 Private Key' | ||
? 'privateKey' | ||
: (sshParam.label.toLowerCase() as | ||
| 'host' | ||
| 'port' | ||
| 'user' | ||
| 'password' | ||
| 'privateKey') | ||
] || '' | ||
} | ||
/> | ||
{sshParam.tips && <InfoPopover tips={sshParam.tips} />} | ||
</div> | ||
} | ||
/> | ||
))} | ||
</> | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.