|
|
@ -1,5 +1,6 @@ |
|
|
|
<script lang="ts" setup> |
|
|
|
<script lang="ts" setup> |
|
|
|
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 { |
|
|
|
import { |
|
|
|
clientTypes, |
|
|
|
clientTypes, |
|
|
|
computed, |
|
|
|
computed, |
|
|
@ -28,6 +29,8 @@ const useForm = Form.useForm |
|
|
|
|
|
|
|
|
|
|
|
const testSuccess = ref(false) |
|
|
|
const testSuccess = ref(false) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const form = ref<typeof Form>() |
|
|
|
|
|
|
|
|
|
|
|
const { api, isLoading } = useApi() |
|
|
|
const { api, isLoading } = useApi() |
|
|
|
|
|
|
|
|
|
|
|
const { $e } = useNuxtApp() |
|
|
|
const { $e } = useNuxtApp() |
|
|
@ -91,7 +94,7 @@ const validators = computed(() => { |
|
|
|
const { validate, validateInfos } = useForm(formState, validators) |
|
|
|
const { validate, validateInfos } = useForm(formState, validators) |
|
|
|
|
|
|
|
|
|
|
|
const populateName = (v: string) => { |
|
|
|
const populateName = (v: string) => { |
|
|
|
formState.dataSource.connection.database = `${v?.trim()}_noco` |
|
|
|
formState.dataSource.connection.database = `${v.trim()}_noco` |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
const onClientChange = () => { |
|
|
|
const onClientChange = () => { |
|
|
@ -99,23 +102,25 @@ const onClientChange = () => { |
|
|
|
populateName(formState.title) |
|
|
|
populateName(formState.title) |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
const onSSLModeChange = (v: any) => { |
|
|
|
const onSSLModeChange = ((mode: 'No' | 'Allow' | string) => { |
|
|
|
switch (v) { |
|
|
|
if ('ssl' in formState.dataSource.connection) { |
|
|
|
case 'No': |
|
|
|
switch (mode) { |
|
|
|
delete formState.dataSource.connection.ssl |
|
|
|
case 'No': |
|
|
|
break |
|
|
|
delete formState.dataSource.connection.ssl |
|
|
|
case 'Allowed': |
|
|
|
break |
|
|
|
formState.dataSource.connection.ssl = 'true' |
|
|
|
case 'Allowed': |
|
|
|
break |
|
|
|
formState.dataSource.connection.ssl = 'true' |
|
|
|
default: |
|
|
|
break |
|
|
|
formState.dataSource.connection.ssl = { |
|
|
|
default: |
|
|
|
ca: '', |
|
|
|
formState.dataSource.connection.ssl = { |
|
|
|
cert: '', |
|
|
|
ca: '', |
|
|
|
key: '', |
|
|
|
cert: '', |
|
|
|
} |
|
|
|
key: '', |
|
|
|
break |
|
|
|
} |
|
|
|
|
|
|
|
break |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
}) as unknown as SelectHandler |
|
|
|
|
|
|
|
|
|
|
|
const addNewParam = () => { |
|
|
|
const addNewParam = () => { |
|
|
|
formState.extraParameters.push({ key: '', value: '' }) |
|
|
|
formState.extraParameters.push({ key: '', value: '' }) |
|
|
@ -132,25 +137,19 @@ const caFileInput = ref<HTMLInputElement>() |
|
|
|
const keyFileInput = ref<HTMLInputElement>() |
|
|
|
const keyFileInput = ref<HTMLInputElement>() |
|
|
|
const certFileInput = ref<HTMLInputElement>() |
|
|
|
const certFileInput = ref<HTMLInputElement>() |
|
|
|
|
|
|
|
|
|
|
|
const onFileSelect = (key: 'ca' | 'cert' | 'key', el: HTMLInputElement) => { |
|
|
|
const onFileSelect = (key: 'ca' | 'cert' | 'key', el?: HTMLInputElement) => { |
|
|
|
|
|
|
|
if (!el) return |
|
|
|
|
|
|
|
|
|
|
|
readFile(el, (content) => { |
|
|
|
readFile(el, (content) => { |
|
|
|
if ('ssl' in formState.dataSource.connection && formState.dataSource.connection.ssl) |
|
|
|
if ('ssl' in formState.dataSource.connection && typeof formState.dataSource.connection.ssl === 'object') |
|
|
|
formState.dataSource.connection.ssl[key] = content ?? '' |
|
|
|
formState.dataSource.connection.ssl[key] = content ?? '' |
|
|
|
}) |
|
|
|
}) |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
const sslFilesRequired = computed<boolean>(() => { |
|
|
|
const sslFilesRequired = computed(() => !!formState.sslUse && formState.sslUse !== 'No' && formState.sslUse !== 'Allowed') |
|
|
|
return formState?.sslUse && formState.sslUse !== 'No' && formState.sslUse !== 'Allowed' |
|
|
|
|
|
|
|
}) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
function getConnectionConfig() { |
|
|
|
function getConnectionConfig() { |
|
|
|
const extraParameters = Object.fromEntries( |
|
|
|
const extraParameters = Object.fromEntries(new Map(formState.extraParameters.map((object) => [object.key, object.value]))) |
|
|
|
new Map( |
|
|
|
|
|
|
|
formState.extraParameters.map((object) => { |
|
|
|
|
|
|
|
return [object.key, object.value] |
|
|
|
|
|
|
|
}), |
|
|
|
|
|
|
|
), |
|
|
|
|
|
|
|
) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const connection = { |
|
|
|
const connection = { |
|
|
|
...formState.dataSource.connection, |
|
|
|
...formState.dataSource.connection, |
|
|
@ -165,9 +164,8 @@ function getConnectionConfig() { |
|
|
|
return connection |
|
|
|
return connection |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
const form = ref<any>() |
|
|
|
|
|
|
|
const focusInvalidInput = () => { |
|
|
|
const focusInvalidInput = () => { |
|
|
|
form?.value?.$el.querySelector('.ant-form-item-explain-error')?.parentNode?.parentNode?.querySelector('input')?.focus() |
|
|
|
form.value?.$el.querySelector('.ant-form-item-explain-error')?.parentNode?.parentNode?.querySelector('input')?.focus() |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
const createProject = async () => { |
|
|
|
const createProject = async () => { |
|
|
@ -393,7 +391,7 @@ onMounted(() => { |
|
|
|
<span>{{ $t('tooltip.clientCert') }}</span> |
|
|
|
<span>{{ $t('tooltip.clientCert') }}</span> |
|
|
|
</template> |
|
|
|
</template> |
|
|
|
|
|
|
|
|
|
|
|
<a-button :disabled="!sslFilesRequired" class="shadow" @click="certFileInput.click()"> |
|
|
|
<a-button :disabled="!sslFilesRequired" class="shadow" @click="certFileInput?.click()"> |
|
|
|
{{ $t('labels.clientCert') }} |
|
|
|
{{ $t('labels.clientCert') }} |
|
|
|
</a-button> |
|
|
|
</a-button> |
|
|
|
</a-tooltip> |
|
|
|
</a-tooltip> |
|
|
@ -403,7 +401,7 @@ onMounted(() => { |
|
|
|
<template #title> |
|
|
|
<template #title> |
|
|
|
<span>{{ $t('tooltip.clientKey') }}</span> |
|
|
|
<span>{{ $t('tooltip.clientKey') }}</span> |
|
|
|
</template> |
|
|
|
</template> |
|
|
|
<a-button :disabled="!sslFilesRequired" class="shadow" @click="keyFileInput.click()"> |
|
|
|
<a-button :disabled="!sslFilesRequired" class="shadow" @click="keyFileInput?.click()"> |
|
|
|
{{ $t('labels.clientKey') }} |
|
|
|
{{ $t('labels.clientKey') }} |
|
|
|
</a-button> |
|
|
|
</a-button> |
|
|
|
</a-tooltip> |
|
|
|
</a-tooltip> |
|
|
@ -414,7 +412,7 @@ onMounted(() => { |
|
|
|
<span>{{ $t('tooltip.clientCA') }}</span> |
|
|
|
<span>{{ $t('tooltip.clientCA') }}</span> |
|
|
|
</template> |
|
|
|
</template> |
|
|
|
|
|
|
|
|
|
|
|
<a-button :disabled="!sslFilesRequired" class="shadow" @click="caFileInput.click()"> |
|
|
|
<a-button :disabled="!sslFilesRequired" class="shadow" @click="caFileInput?.click()"> |
|
|
|
{{ $t('labels.serverCA') }} |
|
|
|
{{ $t('labels.serverCA') }} |
|
|
|
</a-button> |
|
|
|
</a-button> |
|
|
|
</a-tooltip> |
|
|
|
</a-tooltip> |
|
|
@ -434,8 +432,11 @@ onMounted(() => { |
|
|
|
<div v-for="(item, index) of formState.extraParameters" :key="index"> |
|
|
|
<div v-for="(item, index) of formState.extraParameters" :key="index"> |
|
|
|
<div class="flex py-1 items-center gap-1"> |
|
|
|
<div class="flex py-1 items-center gap-1"> |
|
|
|
<a-input v-model:value="item.key" /> |
|
|
|
<a-input v-model:value="item.key" /> |
|
|
|
|
|
|
|
|
|
|
|
<span>:</span> |
|
|
|
<span>:</span> |
|
|
|
|
|
|
|
|
|
|
|
<a-input v-model:value="item.value" /> |
|
|
|
<a-input v-model:value="item.value" /> |
|
|
|
|
|
|
|
|
|
|
|
<MdiClose :style="{ 'font-size': '1.5em', 'color': 'red' }" @click="removeParam(index)" /> |
|
|
|
<MdiClose :style="{ 'font-size': '1.5em', 'color': 'red' }" @click="removeParam(index)" /> |
|
|
|
</div> |
|
|
|
</div> |
|
|
|
</div> |
|
|
|
</div> |
|
|
|