Browse Source

feat: snowflake front-end

Signed-off-by: mertmit <mertmit99@gmail.com>
pull/4645/head
mertmit 2 years ago
parent
commit
b800f838a7
  1. 1
      packages/nc-gui/lib/enums.ts
  2. 39
      packages/nc-gui/pages/index/index/create-external.vue
  3. 29
      packages/nc-gui/utils/projectCreateUtils.ts

1
packages/nc-gui/lib/enums.ts

@ -20,6 +20,7 @@ export enum ClientType {
PG = 'pg', PG = 'pg',
SQLITE = 'sqlite3', SQLITE = 'sqlite3',
VITESS = 'vitess', VITESS = 'vitess',
SNOWFLAKE = 'snowflake',
} }
export enum Language { export enum Language {

39
packages/nc-gui/pages/index/index/create-external.vue

@ -79,6 +79,8 @@ const validators = computed(() => {
? { ? {
'dataSource.connection.connection.filename': [fieldRequiredValidator()], 'dataSource.connection.connection.filename': [fieldRequiredValidator()],
} }
: formState.dataSource.client === ClientType.SNOWFLAKE
? {}
: { : {
'dataSource.connection.host': [fieldRequiredValidator()], 'dataSource.connection.host': [fieldRequiredValidator()],
'dataSource.connection.port': [fieldRequiredValidator()], 'dataSource.connection.port': [fieldRequiredValidator()],
@ -385,6 +387,43 @@ onMounted(async () => {
<a-input v-model:value="formState.dataSource.connection.connection.filename" /> <a-input v-model:value="formState.dataSource.connection.connection.filename" />
</a-form-item> </a-form-item>
<template v-else-if="formState.dataSource.client === ClientType.SNOWFLAKE">
<!-- Account -->
<a-form-item label="Account">
<a-input v-model:value="formState.dataSource.connection.account" class="nc-extdb-account" />
</a-form-item>
<!-- Username -->
<a-form-item :label="$t('labels.username')" v-bind="validateInfos['dataSource.connection.user']">
<a-input v-model:value="formState.dataSource.connection.username" class="nc-extdb-host-user" />
</a-form-item>
<!-- Password -->
<a-form-item :label="$t('labels.password')">
<a-input-password v-model:value="formState.dataSource.connection.password" class="nc-extdb-host-password" />
</a-form-item>
<!-- Warehouse -->
<a-form-item label="Warehouse">
<a-input v-model:value="formState.dataSource.connection.warehouse" />
</a-form-item>
<!-- Database -->
<a-form-item :label="$t('labels.database')" v-bind="validateInfos['dataSource.connection.database']">
<!-- Database : create if not exists -->
<a-input
v-model:value="formState.dataSource.connection.database"
:placeholder="$t('labels.dbCreateIfNotExists')"
class="nc-extdb-host-database"
/>
</a-form-item>
<!-- Schema name -->
<a-form-item :label="$t('labels.schemaName')">
<a-input v-model:value="formState.dataSource.connection.schema" />
</a-form-item>
</template>
<template v-else> <template v-else>
<!-- Host Address --> <!-- Host Address -->
<a-form-item :label="$t('labels.hostAddress')" v-bind="validateInfos['dataSource.connection.host']"> <a-form-item :label="$t('labels.hostAddress')" v-bind="validateInfos['dataSource.connection.host']">

29
packages/nc-gui/utils/projectCreateUtils.ts

@ -4,7 +4,7 @@ interface ProjectCreateForm {
title: string title: string
dataSource: { dataSource: {
client: ClientType client: ClientType
connection: DefaultConnection | SQLiteConnection connection: DefaultConnection | SQLiteConnection | SnowflakeConnection
searchPath?: string[] searchPath?: string[]
} }
inflection: { inflection: {
@ -33,6 +33,15 @@ interface SQLiteConnection {
useNullAsDefault?: boolean useNullAsDefault?: boolean
} }
export interface SnowflakeConnection {
account: string
username: string
password: string
warehouse: string
database?: string
schema?: string
}
const defaultHost = 'localhost' const defaultHost = 'localhost'
const testDataBaseNames = { const testDataBaseNames = {
@ -66,12 +75,16 @@ export const clientTypes = [
text: 'SQLite', text: 'SQLite',
value: ClientType.SQLITE, value: ClientType.SQLITE,
}, },
{
text: 'SnowFlake',
value: ClientType.SNOWFLAKE,
},
] ]
const homeDir = '' const homeDir = ''
type ConnectionClientType = type ConnectionClientType =
| Exclude<ClientType, ClientType.SQLITE> | Exclude<ClientType, ClientType.SQLITE | ClientType.SNOWFLAKE>
| 'tidb' | 'tidb'
| 'yugabyte' | 'yugabyte'
| 'citusdb' | 'citusdb'
@ -79,7 +92,9 @@ type ConnectionClientType =
| 'oracledb' | 'oracledb'
| 'greenplum' | 'greenplum'
const sampleConnectionData: { [key in ConnectionClientType]: DefaultConnection } & { [ClientType.SQLITE]: SQLiteConnection } = { const sampleConnectionData: { [key in ConnectionClientType]: DefaultConnection } & { [ClientType.SQLITE]: SQLiteConnection } & {
[ClientType.SNOWFLAKE]: SnowflakeConnection
} = {
[ClientType.PG]: { [ClientType.PG]: {
host: defaultHost, host: defaultHost,
port: '5432', port: '5432',
@ -116,6 +131,14 @@ const sampleConnectionData: { [key in ConnectionClientType]: DefaultConnection }
}, },
useNullAsDefault: true, useNullAsDefault: true,
}, },
[ClientType.SNOWFLAKE]: {
account: 'account',
username: 'username',
password: 'password',
warehouse: 'warehouse',
database: 'database',
schema: 'schema',
},
tidb: { tidb: {
host: defaultHost, host: defaultHost,
port: '4000', port: '4000',

Loading…
Cancel
Save