|
|
@ -44,6 +44,8 @@ const useForm = Form.useForm |
|
|
|
|
|
|
|
|
|
|
|
const testSuccess = ref(false) |
|
|
|
const testSuccess = ref(false) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const testingConnection = ref(false) |
|
|
|
|
|
|
|
|
|
|
|
const form = ref<typeof Form>() |
|
|
|
const form = ref<typeof Form>() |
|
|
|
|
|
|
|
|
|
|
|
const { api } = useApi() |
|
|
|
const { api } = useApi() |
|
|
@ -52,6 +54,8 @@ const { $e } = useNuxtApp() |
|
|
|
|
|
|
|
|
|
|
|
const { t } = useI18n() |
|
|
|
const { t } = useI18n() |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const creatingBase = ref(false) |
|
|
|
|
|
|
|
|
|
|
|
const formState = ref<ProjectCreateForm>({ |
|
|
|
const formState = ref<ProjectCreateForm>({ |
|
|
|
title: '', |
|
|
|
title: '', |
|
|
|
dataSource: { ...getDefaultConnectionConfig(ClientType.MYSQL) }, |
|
|
|
dataSource: { ...getDefaultConnectionConfig(ClientType.MYSQL) }, |
|
|
@ -225,26 +229,27 @@ function getConnectionConfig() { |
|
|
|
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 isConnSuccess = ref(false) |
|
|
|
|
|
|
|
|
|
|
|
const { $jobs } = useNuxtApp() |
|
|
|
|
|
|
|
|
|
|
|
const createBase = async () => { |
|
|
|
const createBase = async () => { |
|
|
|
try { |
|
|
|
try { |
|
|
|
await validate() |
|
|
|
await validate() |
|
|
|
isConnSuccess.value = false |
|
|
|
|
|
|
|
} catch (e) { |
|
|
|
} catch (e) { |
|
|
|
focusInvalidInput() |
|
|
|
focusInvalidInput() |
|
|
|
isConnSuccess.value = false |
|
|
|
|
|
|
|
return |
|
|
|
return |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
try { |
|
|
|
try { |
|
|
|
if (!projectId.value) return |
|
|
|
if (!projectId.value) return |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
creatingBase.value = true |
|
|
|
|
|
|
|
|
|
|
|
const connection = getConnectionConfig() |
|
|
|
const connection = getConnectionConfig() |
|
|
|
|
|
|
|
|
|
|
|
const config = { ...formState.value.dataSource, connection } |
|
|
|
const config = { ...formState.value.dataSource, connection } |
|
|
|
|
|
|
|
|
|
|
|
await api.base.create(projectId.value, { |
|
|
|
const jobData = await api.base.create(projectId.value, { |
|
|
|
alias: formState.value.title, |
|
|
|
alias: formState.value.title, |
|
|
|
type: formState.value.dataSource.client, |
|
|
|
type: formState.value.dataSource.client, |
|
|
|
config, |
|
|
|
config, |
|
|
@ -252,12 +257,23 @@ const createBase = async () => { |
|
|
|
inflection_table: formState.value.inflection.inflectionTable, |
|
|
|
inflection_table: formState.value.inflection.inflectionTable, |
|
|
|
}) |
|
|
|
}) |
|
|
|
|
|
|
|
|
|
|
|
$e('a:base:create:extdb') |
|
|
|
$jobs.subscribe({ id: jobData.id }, undefined, async (status: string) => { |
|
|
|
|
|
|
|
if (status === JobStatus.COMPLETED) { |
|
|
|
|
|
|
|
$e('a:base:create:extdb') |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (projectId.value) { |
|
|
|
|
|
|
|
await loadProject(projectId.value, true) |
|
|
|
|
|
|
|
await loadProjectTables(projectId.value, true) |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
emit('baseCreated') |
|
|
|
|
|
|
|
emit('close') |
|
|
|
|
|
|
|
} else if (status === JobStatus.FAILED) { |
|
|
|
|
|
|
|
message.error('Failed to create base') |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
await loadProject(projectId.value, true) |
|
|
|
creatingBase.value = false |
|
|
|
await loadProjectTables(projectId.value, true) |
|
|
|
}) |
|
|
|
emit('baseCreated') |
|
|
|
|
|
|
|
emit('close') |
|
|
|
|
|
|
|
} catch (e: any) { |
|
|
|
} catch (e: any) { |
|
|
|
message.error(await extractSdkResponseErrorMsg(e)) |
|
|
|
message.error(await extractSdkResponseErrorMsg(e)) |
|
|
|
} |
|
|
|
} |
|
|
@ -274,6 +290,8 @@ const testConnection = async () => { |
|
|
|
$e('a:base:create:extdb:test-connection', []) |
|
|
|
$e('a:base:create:extdb:test-connection', []) |
|
|
|
|
|
|
|
|
|
|
|
try { |
|
|
|
try { |
|
|
|
|
|
|
|
testingConnection.value = true |
|
|
|
|
|
|
|
|
|
|
|
if (formState.value.dataSource.client === ClientType.SQLITE) { |
|
|
|
if (formState.value.dataSource.client === ClientType.SQLITE) { |
|
|
|
testSuccess.value = true |
|
|
|
testSuccess.value = true |
|
|
|
} else { |
|
|
|
} else { |
|
|
@ -290,7 +308,6 @@ const testConnection = async () => { |
|
|
|
|
|
|
|
|
|
|
|
if (result.code === 0) { |
|
|
|
if (result.code === 0) { |
|
|
|
testSuccess.value = true |
|
|
|
testSuccess.value = true |
|
|
|
isConnSuccess.value = true |
|
|
|
|
|
|
|
} else { |
|
|
|
} else { |
|
|
|
testSuccess.value = false |
|
|
|
testSuccess.value = false |
|
|
|
|
|
|
|
|
|
|
@ -302,6 +319,8 @@ const testConnection = async () => { |
|
|
|
|
|
|
|
|
|
|
|
message.error(await extractSdkResponseErrorMsg(e)) |
|
|
|
message.error(await extractSdkResponseErrorMsg(e)) |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
testingConnection.value = false |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
const handleImportURL = async () => { |
|
|
|
const handleImportURL = async () => { |
|
|
@ -367,15 +386,6 @@ watch( |
|
|
|
</script> |
|
|
|
</script> |
|
|
|
|
|
|
|
|
|
|
|
<template> |
|
|
|
<template> |
|
|
|
<GeneralModal v-model:visible="isConnSuccess" class="!w-[25rem]"> |
|
|
|
|
|
|
|
<div class="flex flex-col h-full p-8"> |
|
|
|
|
|
|
|
<div class="text-lg font-semibold self-start mb-4">{{ t('msg.info.dbConnected') }}</div> |
|
|
|
|
|
|
|
<div class="flex gap-x-2 mt-5 ml-7 pt-2.5 justify-end"> |
|
|
|
|
|
|
|
<NcButton key="back" type="secondary" @click="isConnSuccess = false">{{ $t('general.cancel') }}</NcButton> |
|
|
|
|
|
|
|
<NcButton key="submit" type="primary" @click="createBase"> {{ $t('activity.addBase') }}</NcButton> |
|
|
|
|
|
|
|
</div> |
|
|
|
|
|
|
|
</div> |
|
|
|
|
|
|
|
</GeneralModal> |
|
|
|
|
|
|
|
<div class="create-base bg-white relative flex flex-col justify-center gap-2 w-full"> |
|
|
|
<div class="create-base bg-white relative flex flex-col justify-center gap-2 w-full"> |
|
|
|
<h1 class="prose-2xl font-bold self-start mb-4 flex items-center gap-2"> |
|
|
|
<h1 class="prose-2xl font-bold self-start mb-4 flex items-center gap-2"> |
|
|
|
{{ $t('title.newBase') }} |
|
|
|
{{ $t('title.newBase') }} |
|
|
@ -470,7 +480,7 @@ watch( |
|
|
|
</a-form-item> |
|
|
|
</a-form-item> |
|
|
|
<div class="flex items-right justify-end gap-2"> |
|
|
|
<div class="flex items-right justify-end gap-2"> |
|
|
|
<!-- Use Connection URL --> |
|
|
|
<!-- Use Connection URL --> |
|
|
|
<NcButton size="small" class="nc-extdb-btn-import-url !rounded-md" @click.stop="importURLDlg = true"> |
|
|
|
<NcButton type="ghost" size="small" class="nc-extdb-btn-import-url !rounded-md" @click.stop="importURLDlg = true"> |
|
|
|
{{ $t('activity.useConnectionUrl') }} |
|
|
|
{{ $t('activity.useConnectionUrl') }} |
|
|
|
</NcButton> |
|
|
|
</NcButton> |
|
|
|
</div> |
|
|
|
</div> |
|
|
@ -563,7 +573,7 @@ watch( |
|
|
|
v-model:value="formState.inflection.inflectionTable" |
|
|
|
v-model:value="formState.inflection.inflectionTable" |
|
|
|
dropdown-class-name="nc-dropdown-inflection-table-name" |
|
|
|
dropdown-class-name="nc-dropdown-inflection-table-name" |
|
|
|
> |
|
|
|
> |
|
|
|
<a-select-option v-for="type in inflectionTypes" :key="type" :value="type">{{ type }} </a-select-option> |
|
|
|
<a-select-option v-for="tp in inflectionTypes" :key="tp" :value="tp">{{ tp }} </a-select-option> |
|
|
|
</a-select> |
|
|
|
</a-select> |
|
|
|
</a-form-item> |
|
|
|
</a-form-item> |
|
|
|
|
|
|
|
|
|
|
@ -572,7 +582,7 @@ watch( |
|
|
|
v-model:value="formState.inflection.inflectionColumn" |
|
|
|
v-model:value="formState.inflection.inflectionColumn" |
|
|
|
dropdown-class-name="nc-dropdown-inflection-column-name" |
|
|
|
dropdown-class-name="nc-dropdown-inflection-column-name" |
|
|
|
> |
|
|
|
> |
|
|
|
<a-select-option v-for="type in inflectionTypes" :key="type" :value="type">{{ type }} </a-select-option> |
|
|
|
<a-select-option v-for="tp in inflectionTypes" :key="tp" :value="tp">{{ tp }} </a-select-option> |
|
|
|
</a-select> |
|
|
|
</a-select> |
|
|
|
</a-form-item> |
|
|
|
</a-form-item> |
|
|
|
|
|
|
|
|
|
|
@ -589,7 +599,14 @@ watch( |
|
|
|
|
|
|
|
|
|
|
|
<a-form-item class="flex justify-end !mt-5"> |
|
|
|
<a-form-item class="flex justify-end !mt-5"> |
|
|
|
<div class="flex justify-end gap-2"> |
|
|
|
<div class="flex justify-end gap-2"> |
|
|
|
<NcButton type="primary" size="small" class="nc-extdb-btn-test-connection !rounded-md" @click="testConnection"> |
|
|
|
<NcButton |
|
|
|
|
|
|
|
type="primary" |
|
|
|
|
|
|
|
size="small" |
|
|
|
|
|
|
|
class="nc-extdb-btn-test-connection !rounded-md" |
|
|
|
|
|
|
|
:loading="testingConnection" |
|
|
|
|
|
|
|
@click="testConnection" |
|
|
|
|
|
|
|
> |
|
|
|
|
|
|
|
<GeneralIcon v-if="testSuccess" icon="circleCheck" class="mr-2" /> |
|
|
|
{{ $t('activity.testDbConn') }} |
|
|
|
{{ $t('activity.testDbConn') }} |
|
|
|
</NcButton> |
|
|
|
</NcButton> |
|
|
|
|
|
|
|
|
|
|
@ -597,6 +614,7 @@ watch( |
|
|
|
size="small" |
|
|
|
size="small" |
|
|
|
type="primary" |
|
|
|
type="primary" |
|
|
|
:disabled="!testSuccess" |
|
|
|
:disabled="!testSuccess" |
|
|
|
|
|
|
|
:loading="creatingBase" |
|
|
|
class="nc-extdb-btn-submit !rounded-md" |
|
|
|
class="nc-extdb-btn-submit !rounded-md" |
|
|
|
@click="createBase" |
|
|
|
@click="createBase" |
|
|
|
> |
|
|
|
> |
|
|
@ -628,17 +646,6 @@ watch( |
|
|
|
> |
|
|
|
> |
|
|
|
<a-input v-model:value="importURL" /> |
|
|
|
<a-input v-model:value="importURL" /> |
|
|
|
</a-modal> |
|
|
|
</a-modal> |
|
|
|
|
|
|
|
|
|
|
|
<!-- connection succesfull modal --> |
|
|
|
|
|
|
|
<GeneralModal v-model:visible="isConnSuccess" class="!w-[25rem]"> |
|
|
|
|
|
|
|
<div class="flex flex-col h-full p-8"> |
|
|
|
|
|
|
|
<div class="text-lg font-semibold self-start mb-4">{{ t('msg.info.dbConnected') }}</div> |
|
|
|
|
|
|
|
<div class="flex gap-x-2 mt-5 ml-7 pt-2.5 justify-end"> |
|
|
|
|
|
|
|
<NcButton key="back" type="secondary" @click="isConnSuccess = false">{{ $t('general.cancel') }}</NcButton> |
|
|
|
|
|
|
|
<NcButton key="submit" type="primary" @click="createBase">{{ $t('activity.addBase') }}</NcButton> |
|
|
|
|
|
|
|
</div> |
|
|
|
|
|
|
|
</div> |
|
|
|
|
|
|
|
</GeneralModal> |
|
|
|
|
|
|
|
</div> |
|
|
|
</div> |
|
|
|
</template> |
|
|
|
</template> |
|
|
|
|
|
|
|
|
|
|
|