|
|
@ -2,7 +2,8 @@ |
|
|
|
import { Form, Modal, message } from 'ant-design-vue' |
|
|
|
import { Form, Modal, message } from 'ant-design-vue' |
|
|
|
import type { SelectHandler } from 'ant-design-vue/es/vc-select/Select' |
|
|
|
import type { SelectHandler } from 'ant-design-vue/es/vc-select/Select' |
|
|
|
import { |
|
|
|
import { |
|
|
|
certTypes, |
|
|
|
CertTypes, |
|
|
|
|
|
|
|
SSLUsage, |
|
|
|
clientTypes, |
|
|
|
clientTypes, |
|
|
|
computed, |
|
|
|
computed, |
|
|
|
extractSdkResponseErrorMsg, |
|
|
|
extractSdkResponseErrorMsg, |
|
|
@ -16,7 +17,6 @@ import { |
|
|
|
projectTitleValidator, |
|
|
|
projectTitleValidator, |
|
|
|
readFile, |
|
|
|
readFile, |
|
|
|
ref, |
|
|
|
ref, |
|
|
|
sslUsage, |
|
|
|
|
|
|
|
useApi, |
|
|
|
useApi, |
|
|
|
useI18n, |
|
|
|
useI18n, |
|
|
|
useNuxtApp, |
|
|
|
useNuxtApp, |
|
|
@ -24,6 +24,7 @@ import { |
|
|
|
watch, |
|
|
|
watch, |
|
|
|
} from '#imports' |
|
|
|
} from '#imports' |
|
|
|
import { ClientType } from '~/lib' |
|
|
|
import { ClientType } from '~/lib' |
|
|
|
|
|
|
|
import { DefaultConnection, SQLiteConnection } from '~/utils' |
|
|
|
import type { ProjectCreateForm } from '~/utils' |
|
|
|
import type { ProjectCreateForm } from '~/utils' |
|
|
|
|
|
|
|
|
|
|
|
const useForm = Form.useForm |
|
|
|
const useForm = Form.useForm |
|
|
@ -47,7 +48,7 @@ let formState = $ref<ProjectCreateForm>({ |
|
|
|
inflectionColumn: 'camelize', |
|
|
|
inflectionColumn: 'camelize', |
|
|
|
inflectionTable: 'camelize', |
|
|
|
inflectionTable: 'camelize', |
|
|
|
}, |
|
|
|
}, |
|
|
|
sslUse: sslUsage.No, |
|
|
|
sslUse: SSLUsage.No, |
|
|
|
extraParameters: [], |
|
|
|
extraParameters: [], |
|
|
|
}) |
|
|
|
}) |
|
|
|
|
|
|
|
|
|
|
@ -58,7 +59,7 @@ const customFormState = ref<ProjectCreateForm>({ |
|
|
|
inflectionColumn: 'camelize', |
|
|
|
inflectionColumn: 'camelize', |
|
|
|
inflectionTable: 'camelize', |
|
|
|
inflectionTable: 'camelize', |
|
|
|
}, |
|
|
|
}, |
|
|
|
sslUse: sslUsage.No, |
|
|
|
sslUse: SSLUsage.No, |
|
|
|
extraParameters: [], |
|
|
|
extraParameters: [], |
|
|
|
}) |
|
|
|
}) |
|
|
|
|
|
|
|
|
|
|
@ -103,33 +104,39 @@ const onClientChange = () => { |
|
|
|
populateName(formState.title) |
|
|
|
populateName(formState.title) |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
const onSSLModeChange = ((mode: sslUsage) => { |
|
|
|
const onSSLModeChange = ((mode: SSLUsage) => { |
|
|
|
switch (mode) { |
|
|
|
if (formState.dataSource.client !== ClientType.SQLITE) { |
|
|
|
case sslUsage.No: |
|
|
|
const connection = formState.dataSource.connection as DefaultConnection |
|
|
|
delete formState.dataSource.connection.ssl |
|
|
|
switch (mode) { |
|
|
|
break |
|
|
|
case SSLUsage.No: |
|
|
|
case sslUsage.Allowed: |
|
|
|
delete connection.ssl |
|
|
|
formState.dataSource.connection.ssl = 'true' |
|
|
|
break |
|
|
|
break |
|
|
|
case SSLUsage.Allowed: |
|
|
|
default: |
|
|
|
connection.ssl = 'true' |
|
|
|
formState.dataSource.connection.ssl = { |
|
|
|
break |
|
|
|
ca: '', |
|
|
|
default: |
|
|
|
cert: '', |
|
|
|
connection.ssl = { |
|
|
|
key: '', |
|
|
|
ca: '', |
|
|
|
} |
|
|
|
cert: '', |
|
|
|
break |
|
|
|
key: '', |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
break |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
}) as SelectHandler |
|
|
|
}) as SelectHandler |
|
|
|
|
|
|
|
|
|
|
|
const updateSSLUse = () => { |
|
|
|
const updateSSLUse = () => { |
|
|
|
if (formState.dataSource.connection.ssl) { |
|
|
|
if (formState.dataSource.client !== ClientType.SQLITE) { |
|
|
|
if (typeof formState.dataSource.connection.ssl === 'string') { |
|
|
|
const connection = formState.dataSource.connection as DefaultConnection |
|
|
|
formState.sslUse = sslUsage.Allowed |
|
|
|
if (connection.ssl) { |
|
|
|
|
|
|
|
if (typeof connection.ssl === 'string') { |
|
|
|
|
|
|
|
formState.sslUse = SSLUsage.Allowed |
|
|
|
|
|
|
|
} else { |
|
|
|
|
|
|
|
formState.sslUse = SSLUsage.Preferred |
|
|
|
|
|
|
|
} |
|
|
|
} else { |
|
|
|
} else { |
|
|
|
formState.sslUse = sslUsage.Preferred |
|
|
|
formState.sslUse = SSLUsage.No |
|
|
|
} |
|
|
|
} |
|
|
|
} else { |
|
|
|
|
|
|
|
formState.sslUse = sslUsage.No |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
@ -150,7 +157,7 @@ const caFileInput = ref<HTMLInputElement>() |
|
|
|
const keyFileInput = ref<HTMLInputElement>() |
|
|
|
const keyFileInput = ref<HTMLInputElement>() |
|
|
|
const certFileInput = ref<HTMLInputElement>() |
|
|
|
const certFileInput = ref<HTMLInputElement>() |
|
|
|
|
|
|
|
|
|
|
|
const onFileSelect = (key: certTypes, el?: HTMLInputElement) => { |
|
|
|
const onFileSelect = (key: CertTypes, el?: HTMLInputElement) => { |
|
|
|
if (!el) return |
|
|
|
if (!el) return |
|
|
|
|
|
|
|
|
|
|
|
readFile(el, (content) => { |
|
|
|
readFile(el, (content) => { |
|
|
@ -160,7 +167,7 @@ const onFileSelect = (key: certTypes, el?: HTMLInputElement) => { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
const sslFilesRequired = computed( |
|
|
|
const sslFilesRequired = computed( |
|
|
|
() => !!formState.sslUse && formState.sslUse !== sslUsage.No && formState.sslUse !== sslUsage.Allowed, |
|
|
|
() => !!formState.sslUse && formState.sslUse !== SSLUsage.No && formState.sslUse !== SSLUsage.Allowed, |
|
|
|
) |
|
|
|
) |
|
|
|
|
|
|
|
|
|
|
|
function getConnectionConfig() { |
|
|
|
function getConnectionConfig() { |
|
|
@ -173,7 +180,7 @@ function getConnectionConfig() { |
|
|
|
|
|
|
|
|
|
|
|
if ('ssl' in connection && connection.ssl) { |
|
|
|
if ('ssl' in connection && connection.ssl) { |
|
|
|
if ( |
|
|
|
if ( |
|
|
|
formState.sslUse === sslUsage.No || |
|
|
|
formState.sslUse === SSLUsage.No || |
|
|
|
(typeof connection.ssl === 'object' && Object.values(connection.ssl).every((v) => !v)) |
|
|
|
(typeof connection.ssl === 'object' && Object.values(connection.ssl).every((v) => !v)) |
|
|
|
) { |
|
|
|
) { |
|
|
|
delete connection.ssl |
|
|
|
delete connection.ssl |
|
|
@ -365,28 +372,34 @@ onMounted(() => { |
|
|
|
:label="$t('labels.sqliteFile')" |
|
|
|
:label="$t('labels.sqliteFile')" |
|
|
|
v-bind="validateInfos['dataSource.connection.connection.filename']" |
|
|
|
v-bind="validateInfos['dataSource.connection.connection.filename']" |
|
|
|
> |
|
|
|
> |
|
|
|
<a-input v-model:value="formState.dataSource.connection.connection.filename" /> |
|
|
|
<a-input v-model:value="(formState.dataSource.connection as SQLiteConnection).connection.filename" /> |
|
|
|
</a-form-item> |
|
|
|
</a-form-item> |
|
|
|
|
|
|
|
|
|
|
|
<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']"> |
|
|
|
<a-input v-model:value="formState.dataSource.connection.host" class="nc-extdb-host-address" /> |
|
|
|
<a-input v-model:value="(formState.dataSource.connection as DefaultConnection).host" class="nc-extdb-host-address" /> |
|
|
|
</a-form-item> |
|
|
|
</a-form-item> |
|
|
|
|
|
|
|
|
|
|
|
<!-- Port Number --> |
|
|
|
<!-- Port Number --> |
|
|
|
<a-form-item :label="$t('labels.port')" v-bind="validateInfos['dataSource.connection.port']"> |
|
|
|
<a-form-item :label="$t('labels.port')" v-bind="validateInfos['dataSource.connection.port']"> |
|
|
|
<a-input-number v-model:value="formState.dataSource.connection.port" class="!w-full nc-extdb-host-port" /> |
|
|
|
<a-input-number |
|
|
|
|
|
|
|
v-model:value="(formState.dataSource.connection as DefaultConnection).port" |
|
|
|
|
|
|
|
class="!w-full nc-extdb-host-port" |
|
|
|
|
|
|
|
/> |
|
|
|
</a-form-item> |
|
|
|
</a-form-item> |
|
|
|
|
|
|
|
|
|
|
|
<!-- Username --> |
|
|
|
<!-- Username --> |
|
|
|
<a-form-item :label="$t('labels.username')" v-bind="validateInfos['dataSource.connection.user']"> |
|
|
|
<a-form-item :label="$t('labels.username')" v-bind="validateInfos['dataSource.connection.user']"> |
|
|
|
<a-input v-model:value="formState.dataSource.connection.user" class="nc-extdb-host-user" /> |
|
|
|
<a-input v-model:value="(formState.dataSource.connection as DefaultConnection).user" class="nc-extdb-host-user" /> |
|
|
|
</a-form-item> |
|
|
|
</a-form-item> |
|
|
|
|
|
|
|
|
|
|
|
<!-- Password --> |
|
|
|
<!-- Password --> |
|
|
|
<a-form-item :label="$t('labels.password')"> |
|
|
|
<a-form-item :label="$t('labels.password')"> |
|
|
|
<a-input-password v-model:value="formState.dataSource.connection.password" class="nc-extdb-host-password" /> |
|
|
|
<a-input-password |
|
|
|
|
|
|
|
v-model:value="(formState.dataSource.connection as DefaultConnection).password" |
|
|
|
|
|
|
|
class="nc-extdb-host-password" |
|
|
|
|
|
|
|
/> |
|
|
|
</a-form-item> |
|
|
|
</a-form-item> |
|
|
|
|
|
|
|
|
|
|
|
<!-- Database --> |
|
|
|
<!-- Database --> |
|
|
@ -421,7 +434,7 @@ onMounted(() => { |
|
|
|
<!-- todo: add in i18n --> |
|
|
|
<!-- todo: add in i18n --> |
|
|
|
<a-form-item label="SSL mode"> |
|
|
|
<a-form-item label="SSL mode"> |
|
|
|
<a-select v-model:value="formState.sslUse" @select="onSSLModeChange"> |
|
|
|
<a-select v-model:value="formState.sslUse" @select="onSSLModeChange"> |
|
|
|
<a-select-option v-for="opt in Object.values(sslUsage)" :key="opt" :value="opt">{{ opt }}</a-select-option> |
|
|
|
<a-select-option v-for="opt in Object.values(SSLUsage)" :key="opt" :value="opt">{{ opt }}</a-select-option> |
|
|
|
</a-select> |
|
|
|
</a-select> |
|
|
|
</a-form-item> |
|
|
|
</a-form-item> |
|
|
|
|
|
|
|
|
|
|
@ -461,11 +474,11 @@ onMounted(() => { |
|
|
|
</div> |
|
|
|
</div> |
|
|
|
</a-form-item> |
|
|
|
</a-form-item> |
|
|
|
|
|
|
|
|
|
|
|
<input ref="caFileInput" type="file" class="!hidden" @change="onFileSelect(certTypes.ca, caFileInput)" /> |
|
|
|
<input ref="caFileInput" type="file" class="!hidden" @change="onFileSelect(CertTypes.ca, caFileInput)" /> |
|
|
|
|
|
|
|
|
|
|
|
<input ref="certFileInput" type="file" class="!hidden" @change="onFileSelect(certTypes.cert, certFileInput)" /> |
|
|
|
<input ref="certFileInput" type="file" class="!hidden" @change="onFileSelect(CertTypes.cert, certFileInput)" /> |
|
|
|
|
|
|
|
|
|
|
|
<input ref="keyFileInput" type="file" class="!hidden" @change="onFileSelect(certTypes.key, keyFileInput)" /> |
|
|
|
<input ref="keyFileInput" type="file" class="!hidden" @change="onFileSelect(CertTypes.key, keyFileInput)" /> |
|
|
|
|
|
|
|
|
|
|
|
<a-divider /> |
|
|
|
<a-divider /> |
|
|
|
|
|
|
|
|
|
|
|