mirror of https://github.com/nocodb/nocodb
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
644 lines
20 KiB
644 lines
20 KiB
2 years ago
|
<script lang="ts" setup>
|
||
2 years ago
|
import type { ProjectType } from 'nocodb-sdk'
|
||
2 years ago
|
import type { SelectHandler } from 'ant-design-vue/es/vc-select/Select'
|
||
2 years ago
|
import type { DefaultConnection, ProjectCreateForm } from '#imports'
|
||
2 years ago
|
import {
|
||
2 years ago
|
CertTypes,
|
||
2 years ago
|
ClientType,
|
||
2 years ago
|
Form,
|
||
|
Modal,
|
||
2 years ago
|
SSLUsage,
|
||
2 years ago
|
clientTypes as _clientTypes,
|
||
2 years ago
|
computed,
|
||
|
extractSdkResponseErrorMsg,
|
||
|
fieldRequiredValidator,
|
||
|
generateUniqueName,
|
||
|
getDefaultConnectionConfig,
|
||
|
getTestDatabaseName,
|
||
2 years ago
|
iconMap,
|
||
2 years ago
|
message,
|
||
2 years ago
|
navigateTo,
|
||
|
nextTick,
|
||
|
onMounted,
|
||
|
projectTitleValidator,
|
||
|
readFile,
|
||
|
ref,
|
||
|
useApi,
|
||
|
useI18n,
|
||
|
useNuxtApp,
|
||
|
useSidebar,
|
||
|
watch,
|
||
|
} from '#imports'
|
||
|
|
||
|
const useForm = Form.useForm
|
||
|
|
||
|
const testSuccess = ref(false)
|
||
|
|
||
2 years ago
|
const form = ref<typeof Form>()
|
||
|
|
||
2 years ago
|
const { api, isLoading } = useApi({ useGlobalInstance: true })
|
||
2 years ago
|
|
||
|
const { $e } = useNuxtApp()
|
||
|
|
||
2 years ago
|
useSidebar('nc-left-sidebar', { hasSidebar: false })
|
||
2 years ago
|
|
||
|
const { t } = useI18n()
|
||
|
|
||
1 year ago
|
const formState = ref<ProjectCreateForm>({
|
||
2 years ago
|
title: '',
|
||
|
dataSource: { ...getDefaultConnectionConfig(ClientType.MYSQL) },
|
||
|
inflection: {
|
||
2 years ago
|
inflectionColumn: 'none',
|
||
|
inflectionTable: 'none',
|
||
2 years ago
|
},
|
||
2 years ago
|
sslUse: SSLUsage.No,
|
||
2 years ago
|
extraParameters: [],
|
||
2 years ago
|
})
|
||
|
|
||
2 years ago
|
const customFormState = ref<ProjectCreateForm>({
|
||
|
title: '',
|
||
|
dataSource: { ...getDefaultConnectionConfig(ClientType.MYSQL) },
|
||
|
inflection: {
|
||
2 years ago
|
inflectionColumn: 'none',
|
||
|
inflectionTable: 'none',
|
||
2 years ago
|
},
|
||
2 years ago
|
sslUse: SSLUsage.No,
|
||
2 years ago
|
extraParameters: [],
|
||
2 years ago
|
})
|
||
|
|
||
2 years ago
|
const clientTypes = computed(() => {
|
||
|
return _clientTypes.filter((type) => {
|
||
1 year ago
|
// return appInfo.value?.ee || type.value !== ClientType.SNOWFLAKE
|
||
|
return type.value !== ClientType.SNOWFLAKE
|
||
2 years ago
|
})
|
||
|
})
|
||
|
|
||
2 years ago
|
const validators = computed(() => {
|
||
2 years ago
|
let clientValidations: Record<string, any[]> = {
|
||
|
'dataSource.connection.host': [fieldRequiredValidator()],
|
||
|
'dataSource.connection.port': [fieldRequiredValidator()],
|
||
|
'dataSource.connection.user': [fieldRequiredValidator()],
|
||
|
'dataSource.connection.password': [fieldRequiredValidator()],
|
||
|
'dataSource.connection.database': [fieldRequiredValidator()],
|
||
|
}
|
||
|
|
||
1 year ago
|
switch (formState.value.dataSource.client) {
|
||
2 years ago
|
case ClientType.SQLITE:
|
||
|
clientValidations = {
|
||
|
'dataSource.connection.connection.filename': [fieldRequiredValidator()],
|
||
|
}
|
||
|
break
|
||
|
case ClientType.SNOWFLAKE:
|
||
|
clientValidations = {
|
||
|
'dataSource.connection.account': [fieldRequiredValidator()],
|
||
|
'dataSource.connection.username': [fieldRequiredValidator()],
|
||
|
'dataSource.connection.password': [fieldRequiredValidator()],
|
||
|
'dataSource.connection.warehouse': [fieldRequiredValidator()],
|
||
|
'dataSource.connection.database': [fieldRequiredValidator()],
|
||
|
'dataSource.connection.schema': [fieldRequiredValidator()],
|
||
|
}
|
||
|
break
|
||
|
case ClientType.PG:
|
||
|
case ClientType.MSSQL:
|
||
|
clientValidations['dataSource.searchPath.0'] = [fieldRequiredValidator()]
|
||
|
break
|
||
|
}
|
||
|
|
||
2 years ago
|
return {
|
||
|
'title': [
|
||
|
{
|
||
|
required: true,
|
||
|
message: 'Project name is required',
|
||
|
},
|
||
|
projectTitleValidator,
|
||
|
],
|
||
2 years ago
|
'extraParameters': [extraParameterValidator],
|
||
2 years ago
|
'dataSource.client': [fieldRequiredValidator()],
|
||
2 years ago
|
...clientValidations,
|
||
2 years ago
|
}
|
||
|
})
|
||
|
|
||
1 year ago
|
const { validate, validateInfos } = useForm(formState.value, validators)
|
||
2 years ago
|
|
||
2 years ago
|
const populateName = (v: string) => {
|
||
1 year ago
|
formState.value.dataSource.connection.database = `${v.trim()}_noco`
|
||
2 years ago
|
}
|
||
|
|
||
2 years ago
|
const onClientChange = () => {
|
||
1 year ago
|
formState.value.dataSource = { ...getDefaultConnectionConfig(formState.value.dataSource.client) }
|
||
|
populateName(formState.value.title)
|
||
2 years ago
|
}
|
||
|
|
||
2 years ago
|
const onSSLModeChange = ((mode: SSLUsage) => {
|
||
1 year ago
|
if (formState.value.dataSource.client !== ClientType.SQLITE) {
|
||
|
const connection = formState.value.dataSource.connection as DefaultConnection
|
||
2 years ago
|
switch (mode) {
|
||
|
case SSLUsage.No:
|
||
|
delete connection.ssl
|
||
|
break
|
||
|
case SSLUsage.Allowed:
|
||
2 years ago
|
connection.ssl = 'no-verify'
|
||
|
break
|
||
|
case SSLUsage.Preferred:
|
||
2 years ago
|
connection.ssl = 'true'
|
||
|
break
|
||
|
default:
|
||
|
connection.ssl = {
|
||
|
ca: '',
|
||
|
cert: '',
|
||
|
key: '',
|
||
|
}
|
||
|
break
|
||
|
}
|
||
2 years ago
|
}
|
||
2 years ago
|
}) as SelectHandler
|
||
2 years ago
|
|
||
2 years ago
|
const updateSSLUse = () => {
|
||
1 year ago
|
if (formState.value.dataSource.client !== ClientType.SQLITE) {
|
||
|
const connection = formState.value.dataSource.connection as DefaultConnection
|
||
2 years ago
|
if (connection.ssl) {
|
||
|
if (typeof connection.ssl === 'string') {
|
||
1 year ago
|
formState.value.sslUse = SSLUsage.Allowed
|
||
2 years ago
|
} else {
|
||
1 year ago
|
formState.value.sslUse = SSLUsage.Preferred
|
||
2 years ago
|
}
|
||
2 years ago
|
} else {
|
||
1 year ago
|
formState.value.sslUse = SSLUsage.No
|
||
2 years ago
|
}
|
||
|
}
|
||
|
}
|
||
|
|
||
2 years ago
|
const addNewParam = () => {
|
||
1 year ago
|
formState.value.extraParameters.push({ key: '', value: '' })
|
||
2 years ago
|
}
|
||
2 years ago
|
|
||
2 years ago
|
const removeParam = (index: number) => {
|
||
1 year ago
|
formState.value.extraParameters.splice(index, 1)
|
||
2 years ago
|
}
|
||
2 years ago
|
|
||
2 years ago
|
const inflectionTypes = ['camelize', 'none']
|
||
2 years ago
|
const importURL = ref('')
|
||
2 years ago
|
const configEditDlg = ref(false)
|
||
2 years ago
|
const importURLDlg = ref(false)
|
||
2 years ago
|
|
||
|
const caFileInput = ref<HTMLInputElement>()
|
||
|
const keyFileInput = ref<HTMLInputElement>()
|
||
|
const certFileInput = ref<HTMLInputElement>()
|
||
|
|
||
2 years ago
|
const onFileSelect = (key: CertTypes, el?: HTMLInputElement) => {
|
||
2 years ago
|
if (!el) return
|
||
|
|
||
2 years ago
|
readFile(el, (content) => {
|
||
1 year ago
|
if ('ssl' in formState.value.dataSource.connection && typeof formState.value.dataSource.connection.ssl === 'object')
|
||
|
formState.value.dataSource.connection.ssl[key] = content ?? ''
|
||
2 years ago
|
})
|
||
|
}
|
||
|
|
||
2 years ago
|
const sslFilesRequired = computed(
|
||
1 year ago
|
() => !!formState.value.sslUse && formState.value.sslUse !== SSLUsage.No && formState.value.sslUse !== SSLUsage.Allowed,
|
||
2 years ago
|
)
|
||
2 years ago
|
|
||
|
function getConnectionConfig() {
|
||
1 year ago
|
const extraParameters = Object.fromEntries(new Map(formState.value.extraParameters.map((object) => [object.key, object.value])))
|
||
2 years ago
|
|
||
2 years ago
|
const connection = {
|
||
1 year ago
|
...formState.value.dataSource.connection,
|
||
2 years ago
|
...extraParameters,
|
||
2 years ago
|
}
|
||
|
|
||
2 years ago
|
if ('ssl' in connection && connection.ssl) {
|
||
2 years ago
|
if (
|
||
1 year ago
|
formState.value.sslUse === SSLUsage.No ||
|
||
2 years ago
|
(typeof connection.ssl === 'object' && Object.values(connection.ssl).every((v) => v === null || v === undefined))
|
||
2 years ago
|
) {
|
||
2 years ago
|
delete connection.ssl
|
||
|
}
|
||
2 years ago
|
}
|
||
|
return connection
|
||
|
}
|
||
|
|
||
|
const focusInvalidInput = () => {
|
||
2 years ago
|
form.value?.$el.querySelector('.ant-form-item-explain-error')?.parentNode?.parentNode?.querySelector('input')?.focus()
|
||
2 years ago
|
}
|
||
|
|
||
|
const createProject = async () => {
|
||
|
try {
|
||
|
await validate()
|
||
|
} catch (e) {
|
||
|
focusInvalidInput()
|
||
|
return
|
||
|
}
|
||
|
|
||
|
try {
|
||
|
const connection = getConnectionConfig()
|
||
|
|
||
1 year ago
|
const config = { ...formState.value.dataSource, connection }
|
||
2 years ago
|
|
||
2 years ago
|
const result = (await api.project.create({
|
||
1 year ago
|
title: formState.value.title,
|
||
2 years ago
|
bases: [
|
||
|
{
|
||
1 year ago
|
type: formState.value.dataSource.client,
|
||
2 years ago
|
config,
|
||
1 year ago
|
inflection_column: formState.value.inflection.inflectionColumn,
|
||
|
inflection_table: formState.value.inflection.inflectionTable,
|
||
2 years ago
|
},
|
||
|
],
|
||
|
external: true,
|
||
2 years ago
|
})) as Partial<ProjectType>
|
||
2 years ago
|
|
||
|
$e('a:project:create:extdb')
|
||
|
|
||
|
await navigateTo(`/nc/${result.id}`)
|
||
|
} catch (e: any) {
|
||
|
message.error(await extractSdkResponseErrorMsg(e))
|
||
|
}
|
||
|
}
|
||
|
|
||
|
const testConnection = async () => {
|
||
|
try {
|
||
|
await validate()
|
||
|
} catch (e) {
|
||
|
focusInvalidInput()
|
||
|
return
|
||
|
}
|
||
|
|
||
|
$e('a:project:create:extdb:test-connection', [])
|
||
|
|
||
|
try {
|
||
1 year ago
|
if (formState.value.dataSource.client === ClientType.SQLITE) {
|
||
2 years ago
|
testSuccess.value = true
|
||
|
} else {
|
||
|
const connection = getConnectionConfig()
|
||
|
|
||
1 year ago
|
connection.database = getTestDatabaseName(formState.value.dataSource)!
|
||
2 years ago
|
|
||
|
const testConnectionConfig = {
|
||
1 year ago
|
...formState.value.dataSource,
|
||
2 years ago
|
connection,
|
||
|
}
|
||
|
|
||
|
const result = await api.utils.testConnection(testConnectionConfig)
|
||
|
|
||
|
if (result.code === 0) {
|
||
|
testSuccess.value = true
|
||
|
|
||
|
Modal.confirm({
|
||
|
title: t('msg.info.dbConnected'),
|
||
|
icon: null,
|
||
|
type: 'success',
|
||
|
|
||
|
okText: t('activity.OkSaveProject'),
|
||
|
okType: 'primary',
|
||
2 years ago
|
cancelText: t('general.cancel'),
|
||
2 years ago
|
onOk: createProject,
|
||
|
})
|
||
|
} else {
|
||
|
testSuccess.value = false
|
||
|
|
||
|
message.error(`${t('msg.error.dbConnectionFailed')} ${result.message}`)
|
||
|
}
|
||
|
}
|
||
|
} catch (e: any) {
|
||
|
testSuccess.value = false
|
||
|
|
||
|
message.error(await extractSdkResponseErrorMsg(e))
|
||
|
}
|
||
|
}
|
||
|
|
||
2 years ago
|
const handleImportURL = async () => {
|
||
|
if (!importURL.value || importURL.value === '') return
|
||
|
|
||
|
const connectionConfig = await api.utils.urlToConfig({ url: importURL.value })
|
||
|
|
||
|
if (connectionConfig) {
|
||
1 year ago
|
formState.value.dataSource.client = connectionConfig.client
|
||
|
formState.value.dataSource.connection = { ...connectionConfig.connection }
|
||
2 years ago
|
} else {
|
||
2 years ago
|
message.error(t('msg.error.invalidURL'))
|
||
2 years ago
|
}
|
||
|
importURLDlg.value = false
|
||
2 years ago
|
updateSSLUse()
|
||
2 years ago
|
}
|
||
|
|
||
2 years ago
|
const handleEditJSON = () => {
|
||
1 year ago
|
customFormState.value = { ...formState.value }
|
||
2 years ago
|
configEditDlg.value = true
|
||
|
}
|
||
|
|
||
|
const handleOk = () => {
|
||
1 year ago
|
formState.value = { ...customFormState.value }
|
||
2 years ago
|
configEditDlg.value = false
|
||
2 years ago
|
updateSSLUse()
|
||
2 years ago
|
}
|
||
|
|
||
2 years ago
|
// reset test status on config change
|
||
|
watch(
|
||
1 year ago
|
() => formState.value.dataSource,
|
||
2 years ago
|
() => (testSuccess.value = false),
|
||
|
{ deep: true },
|
||
|
)
|
||
|
|
||
2 years ago
|
// populate database name based on title
|
||
|
watch(
|
||
1 year ago
|
() => formState.value.title,
|
||
2 years ago
|
(v) => populateName(v),
|
||
|
)
|
||
|
|
||
2 years ago
|
// select and focus title field on load
|
||
2 years ago
|
onMounted(async () => {
|
||
1 year ago
|
formState.value.title = await generateUniqueName()
|
||
2 years ago
|
|
||
|
await nextTick(() => {
|
||
2 years ago
|
// todo: replace setTimeout and follow better approach
|
||
|
setTimeout(() => {
|
||
|
const input = form.value?.$el?.querySelector('input[type=text]')
|
||
1 year ago
|
input.setSelectionRange(0, formState.value.title.length)
|
||
2 years ago
|
input.focus()
|
||
|
}, 500)
|
||
|
})
|
||
|
})
|
||
|
</script>
|
||
|
|
||
|
<template>
|
||
|
<div
|
||
2 years ago
|
class="create-external relative flex flex-col justify-center gap-2 w-full p-8 md:(bg-white rounded-lg border-1 border-gray-200 shadow)"
|
||
2 years ago
|
>
|
||
2 years ago
|
<LazyGeneralNocoIcon class="color-transition hover:(ring ring-accent)" :animate="isLoading" />
|
||
2 years ago
|
|
||
2 years ago
|
<div
|
||
2 years ago
|
class="color-transition transform group absolute top-5 left-5 text-4xl rounded-full cursor-pointer"
|
||
2 years ago
|
@click="navigateTo('/')"
|
||
|
>
|
||
2 years ago
|
<component :is="iconMap.chevronLeft" class="text-black group-hover:(text-accent scale-110)" />
|
||
2 years ago
|
</div>
|
||
|
|
||
|
<h1 class="prose-2xl font-bold self-center my-4">{{ $t('activity.createProject') }}</h1>
|
||
2 years ago
|
|
||
|
<a-form
|
||
|
ref="form"
|
||
|
:model="formState"
|
||
|
name="external-project-create-form"
|
||
|
layout="horizontal"
|
||
|
no-style
|
||
2 years ago
|
:label-col="{ span: 8 }"
|
||
2 years ago
|
>
|
||
|
<a-form-item :label="$t('placeholder.projName')" v-bind="validateInfos.title">
|
||
2 years ago
|
<a-input v-model:value="formState.title" class="nc-extdb-proj-name" />
|
||
2 years ago
|
</a-form-item>
|
||
|
|
||
|
<a-form-item :label="$t('labels.dbType')" v-bind="validateInfos['dataSource.client']">
|
||
2 years ago
|
<a-select
|
||
|
v-model:value="formState.dataSource.client"
|
||
|
class="nc-extdb-db-type"
|
||
|
dropdown-class-name="nc-dropdown-ext-db-type"
|
||
|
@change="onClientChange"
|
||
|
>
|
||
2 years ago
|
<a-select-option v-for="client in clientTypes" :key="client.value" :value="client.value">
|
||
|
{{ client.text }}
|
||
2 years ago
|
</a-select-option>
|
||
|
</a-select>
|
||
|
</a-form-item>
|
||
|
|
||
|
<!-- SQLite File -->
|
||
|
<a-form-item
|
||
|
v-if="formState.dataSource.client === ClientType.SQLITE"
|
||
|
:label="$t('labels.sqliteFile')"
|
||
|
v-bind="validateInfos['dataSource.connection.connection.filename']"
|
||
|
>
|
||
2 years ago
|
<a-input v-model:value="formState.dataSource.connection.connection.filename" />
|
||
2 years ago
|
</a-form-item>
|
||
|
|
||
|
<template v-else>
|
||
|
<!-- Host Address -->
|
||
|
<a-form-item :label="$t('labels.hostAddress')" v-bind="validateInfos['dataSource.connection.host']">
|
||
2 years ago
|
<a-input v-model:value="formState.dataSource.connection.host" class="nc-extdb-host-address" />
|
||
2 years ago
|
</a-form-item>
|
||
|
|
||
|
<!-- Port Number -->
|
||
|
<a-form-item :label="$t('labels.port')" v-bind="validateInfos['dataSource.connection.port']">
|
||
2 years ago
|
<a-input-number v-model:value="formState.dataSource.connection.port" class="!w-full nc-extdb-host-port" />
|
||
2 years ago
|
</a-form-item>
|
||
|
|
||
|
<!-- Username -->
|
||
|
<a-form-item :label="$t('labels.username')" v-bind="validateInfos['dataSource.connection.user']">
|
||
2 years ago
|
<a-input v-model:value="formState.dataSource.connection.user" class="nc-extdb-host-user" />
|
||
2 years ago
|
</a-form-item>
|
||
|
|
||
|
<!-- Password -->
|
||
|
<a-form-item :label="$t('labels.password')">
|
||
2 years ago
|
<a-input-password v-model:value="formState.dataSource.connection.password" class="nc-extdb-host-password" />
|
||
2 years ago
|
</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
|
||
|
v-if="[ClientType.MSSQL, ClientType.PG].includes(formState.dataSource.client) && formState.dataSource.searchPath"
|
||
|
:label="$t('labels.schemaName')"
|
||
|
v-bind="validateInfos['dataSource.searchPath.0']"
|
||
|
>
|
||
2 years ago
|
<a-input v-model:value="formState.dataSource.searchPath[0]" />
|
||
2 years ago
|
</a-form-item>
|
||
|
|
||
|
<a-collapse ghost expand-icon-position="right" class="!mt-6">
|
||
2 years ago
|
<a-collapse-panel key="1">
|
||
|
<template #header>
|
||
|
<div class="flex items-center gap-2">
|
||
2 years ago
|
<!-- Use Connection URL -->
|
||
2 years ago
|
<a-button type="default" class="nc-extdb-btn-import-url" @click.stop="importURLDlg = true">
|
||
2 years ago
|
{{ $t('activity.useConnectionUrl') }}
|
||
2 years ago
|
</a-button>
|
||
|
<span>{{ $t('title.advancedParameters') }}</span>
|
||
|
</div>
|
||
|
</template>
|
||
2 years ago
|
<a-form-item label="SSL mode">
|
||
2 years ago
|
<a-select v-model:value="formState.sslUse" dropdown-class-name="nc-dropdown-ssl-mode" @select="onSSLModeChange">
|
||
|
<a-select-option v-for="opt in Object.values(SSLUsage)" :key="opt" :value="opt">{{ opt }} </a-select-option>
|
||
2 years ago
|
</a-select>
|
||
|
</a-form-item>
|
||
|
|
||
|
<a-form-item label="SSL keys">
|
||
|
<div class="flex gap-2">
|
||
|
<a-tooltip placement="top">
|
||
|
<!-- Select .cert file -->
|
||
|
<template #title>
|
||
|
<span>{{ $t('tooltip.clientCert') }}</span>
|
||
|
</template>
|
||
|
|
||
2 years ago
|
<a-button :disabled="!sslFilesRequired" class="shadow" @click="certFileInput?.click()">
|
||
2 years ago
|
{{ $t('labels.clientCert') }}
|
||
|
</a-button>
|
||
|
</a-tooltip>
|
||
|
|
||
|
<a-tooltip placement="top">
|
||
|
<!-- Select .key file -->
|
||
|
<template #title>
|
||
|
<span>{{ $t('tooltip.clientKey') }}</span>
|
||
|
</template>
|
||
2 years ago
|
<a-button :disabled="!sslFilesRequired" class="shadow" @click="keyFileInput?.click()">
|
||
2 years ago
|
{{ $t('labels.clientKey') }}
|
||
|
</a-button>
|
||
|
</a-tooltip>
|
||
|
|
||
|
<a-tooltip placement="top">
|
||
|
<!-- Select CA file -->
|
||
|
<template #title>
|
||
|
<span>{{ $t('tooltip.clientCA') }}</span>
|
||
|
</template>
|
||
|
|
||
2 years ago
|
<a-button :disabled="!sslFilesRequired" class="shadow" @click="caFileInput?.click()">
|
||
2 years ago
|
{{ $t('labels.serverCA') }}
|
||
|
</a-button>
|
||
|
</a-tooltip>
|
||
|
</div>
|
||
|
</a-form-item>
|
||
|
|
||
2 years ago
|
<input ref="caFileInput" type="file" class="!hidden" @change="onFileSelect(CertTypes.ca, caFileInput)" />
|
||
2 years ago
|
|
||
2 years ago
|
<input ref="certFileInput" type="file" class="!hidden" @change="onFileSelect(CertTypes.cert, certFileInput)" />
|
||
2 years ago
|
|
||
2 years ago
|
<input ref="keyFileInput" type="file" class="!hidden" @change="onFileSelect(CertTypes.key, keyFileInput)" />
|
||
2 years ago
|
|
||
2 years ago
|
<a-divider />
|
||
|
|
||
2 years ago
|
<!-- Extra connection parameters -->
|
||
2 years ago
|
<a-form-item class="mb-2" :label="$t('labels.extraConnectionParameters')" v-bind="validateInfos.extraParameters">
|
||
2 years ago
|
<a-card>
|
||
|
<div v-for="(item, index) of formState.extraParameters" :key="index">
|
||
|
<div class="flex py-1 items-center gap-1">
|
||
|
<a-input v-model:value="item.key" />
|
||
2 years ago
|
|
||
2 years ago
|
<span>:</span>
|
||
2 years ago
|
|
||
2 years ago
|
<a-input v-model:value="item.value" />
|
||
2 years ago
|
|
||
2 years ago
|
<component
|
||
|
:is="iconMap.close"
|
||
|
:style="{ 'font-size': '1.5em', 'color': 'red' }"
|
||
|
@click="removeParam(index)"
|
||
|
/>
|
||
2 years ago
|
</div>
|
||
|
</div>
|
||
|
<a-button type="dashed" class="w-full caption mt-2" @click="addNewParam">
|
||
2 years ago
|
<div class="flex items-center justify-center">
|
||
2 years ago
|
<component :is="iconMap.plus" />
|
||
2 years ago
|
</div>
|
||
2 years ago
|
</a-button>
|
||
|
</a-card>
|
||
|
</a-form-item>
|
||
|
|
||
|
<a-divider />
|
||
|
|
||
2 years ago
|
<a-form-item :label="$t('labels.inflection.tableName')">
|
||
2 years ago
|
<a-select
|
||
|
v-model:value="formState.inflection.inflectionTable"
|
||
|
dropdown-class-name="nc-dropdown-inflection-table-name"
|
||
|
>
|
||
2 years ago
|
<a-select-option v-for="type in inflectionTypes" :key="type" :value="type">{{ type }}</a-select-option>
|
||
|
</a-select>
|
||
|
</a-form-item>
|
||
|
|
||
|
<a-form-item :label="$t('labels.inflection.columnName')">
|
||
2 years ago
|
<a-select
|
||
|
v-model:value="formState.inflection.inflectionColumn"
|
||
|
dropdown-class-name="nc-dropdown-inflection-column-name"
|
||
|
>
|
||
2 years ago
|
<a-select-option v-for="type in inflectionTypes" :key="type" :value="type">{{ type }}</a-select-option>
|
||
|
</a-select>
|
||
|
</a-form-item>
|
||
|
|
||
2 years ago
|
<div class="flex justify-end">
|
||
|
<a-button class="!shadow-md" @click="handleEditJSON()">
|
||
|
<!-- Edit connection JSON -->
|
||
|
{{ $t('activity.editConnJson') }}
|
||
|
</a-button>
|
||
|
</div>
|
||
2 years ago
|
</a-collapse-panel>
|
||
|
</a-collapse>
|
||
|
</template>
|
||
|
|
||
|
<a-form-item class="flex justify-center !mt-5">
|
||
|
<div class="flex justify-center gap-2">
|
||
|
<a-button type="primary" ghost class="nc-extdb-btn-test-connection" @click="testConnection">
|
||
|
{{ $t('activity.testDbConn') }}
|
||
|
</a-button>
|
||
|
|
||
|
<a-button type="primary" :disabled="!testSuccess" class="nc-extdb-btn-submit !shadow" @click="createProject">
|
||
2 years ago
|
{{ $t('general.submit') }}
|
||
2 years ago
|
</a-button>
|
||
|
</div>
|
||
|
</a-form-item>
|
||
|
</a-form>
|
||
|
|
||
2 years ago
|
<a-modal
|
||
|
v-model:visible="configEditDlg"
|
||
2 years ago
|
:class="{ active: configEditDlg }"
|
||
2 years ago
|
:title="$t('activity.editConnJson')"
|
||
|
width="600px"
|
||
|
wrap-class-name="nc-modal-edit-connection-json"
|
||
|
@ok="handleOk"
|
||
|
>
|
||
2 years ago
|
<LazyMonacoEditor v-if="configEditDlg" v-model="customFormState" class="h-[400px] w-full" />
|
||
2 years ago
|
</a-modal>
|
||
2 years ago
|
|
||
2 years ago
|
<!-- Use Connection URL -->
|
||
2 years ago
|
<a-modal
|
||
|
v-model:visible="importURLDlg"
|
||
2 years ago
|
:class="{ active: importURLDlg }"
|
||
2 years ago
|
:title="$t('activity.useConnectionUrl')"
|
||
|
width="600px"
|
||
|
:ok-text="$t('general.ok')"
|
||
|
:cancel-text="$t('general.cancel')"
|
||
2 years ago
|
wrap-class-name="nc-modal-connection-url"
|
||
2 years ago
|
@ok="handleImportURL"
|
||
|
>
|
||
2 years ago
|
<a-input v-model:value="importURL" />
|
||
|
</a-modal>
|
||
2 years ago
|
</div>
|
||
|
</template>
|
||
|
|
||
|
<style lang="scss" scoped>
|
||
|
:deep(.ant-collapse-header) {
|
||
|
@apply !pr-10 !-mt-4 text-right justify-end;
|
||
|
}
|
||
|
|
||
|
:deep(.ant-collapse-content-box) {
|
||
|
@apply !px-0;
|
||
|
}
|
||
|
|
||
|
:deep(.ant-form-item-explain-error) {
|
||
|
@apply !text-xs;
|
||
|
}
|
||
|
|
||
|
:deep(.ant-form-item) {
|
||
|
@apply mb-2;
|
||
|
}
|
||
|
|
||
|
:deep(.ant-form-item-with-help .ant-form-item-explain) {
|
||
|
@apply !min-h-0;
|
||
|
}
|
||
|
|
||
|
.create-external {
|
||
|
:deep(.ant-input-affix-wrapper),
|
||
|
:deep(.ant-input),
|
||
|
:deep(.ant-select) {
|
||
2 years ago
|
@apply !appearance-none border-1 border-solid rounded;
|
||
2 years ago
|
}
|
||
|
|
||
2 years ago
|
:deep(.ant-input-password) {
|
||
2 years ago
|
input {
|
||
2 years ago
|
@apply !border-none my-0;
|
||
2 years ago
|
}
|
||
|
}
|
||
|
}
|
||
|
</style>
|