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',
SQLITE = 'sqlite3',
VITESS = 'vitess',
SNOWFLAKE = 'snowflake',
}
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()],
}
: formState.dataSource.client === ClientType.SNOWFLAKE
? {}
: {
'dataSource.connection.host': [fieldRequiredValidator()],
'dataSource.connection.port': [fieldRequiredValidator()],
@ -385,6 +387,43 @@ onMounted(async () => {
<a-input v-model:value="formState.dataSource.connection.connection.filename" />
</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>
<!-- Host Address -->
<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
dataSource: {
client: ClientType
connection: DefaultConnection | SQLiteConnection
connection: DefaultConnection | SQLiteConnection | SnowflakeConnection
searchPath?: string[]
}
inflection: {
@ -33,6 +33,15 @@ interface SQLiteConnection {
useNullAsDefault?: boolean
}
export interface SnowflakeConnection {
account: string
username: string
password: string
warehouse: string
database?: string
schema?: string
}
const defaultHost = 'localhost'
const testDataBaseNames = {
@ -66,12 +75,16 @@ export const clientTypes = [
text: 'SQLite',
value: ClientType.SQLITE,
},
{
text: 'SnowFlake',
value: ClientType.SNOWFLAKE,
},
]
const homeDir = ''
type ConnectionClientType =
| Exclude<ClientType, ClientType.SQLITE>
| Exclude<ClientType, ClientType.SQLITE | ClientType.SNOWFLAKE>
| 'tidb'
| 'yugabyte'
| 'citusdb'
@ -79,7 +92,9 @@ type ConnectionClientType =
| 'oracledb'
| 'greenplum'
const sampleConnectionData: { [key in ConnectionClientType]: DefaultConnection } & { [ClientType.SQLITE]: SQLiteConnection } = {
const sampleConnectionData: { [key in ConnectionClientType]: DefaultConnection } & { [ClientType.SQLITE]: SQLiteConnection } & {
[ClientType.SNOWFLAKE]: SnowflakeConnection
} = {
[ClientType.PG]: {
host: defaultHost,
port: '5432',
@ -116,6 +131,14 @@ const sampleConnectionData: { [key in ConnectionClientType]: DefaultConnection }
},
useNullAsDefault: true,
},
[ClientType.SNOWFLAKE]: {
account: 'account',
username: 'username',
password: 'password',
warehouse: 'warehouse',
database: 'database',
schema: 'schema',
},
tidb: {
host: defaultHost,
port: '4000',

Loading…
Cancel
Save