|
|
@ -1,22 +1,22 @@ |
|
|
|
<script lang="ts" setup> |
|
|
|
<script lang="ts" setup> |
|
|
|
import { onMounted } from '@vue/runtime-core' |
|
|
|
import { onMounted } from '@vue/runtime-core' |
|
|
|
|
|
|
|
import { Form, Modal } from 'ant-design-vue' |
|
|
|
import { useI18n } from 'vue-i18n' |
|
|
|
import { useI18n } from 'vue-i18n' |
|
|
|
import { useToast } from 'vue-toastification' |
|
|
|
import { useToast } from 'vue-toastification' |
|
|
|
import { Form, Modal } from 'ant-design-vue' |
|
|
|
|
|
|
|
import { ref } from '#imports' |
|
|
|
import { ref } from '#imports' |
|
|
|
import { navigateTo, useNuxtApp } from '#app' |
|
|
|
import { navigateTo, useNuxtApp } from '#app' |
|
|
|
import type { ProjectCreateForm } from '~/lib/types' |
|
|
|
import type { ProjectCreateForm } from '~/lib/types' |
|
|
|
|
|
|
|
import { ClientType } from '~/lib/types' |
|
|
|
import { extractSdkResponseErrorMsg } from '~/utils/errorUtils' |
|
|
|
import { extractSdkResponseErrorMsg } from '~/utils/errorUtils' |
|
|
|
|
|
|
|
import { readFile } from '~/utils/fileUtils' |
|
|
|
import { |
|
|
|
import { |
|
|
|
clientTypes, |
|
|
|
clientTypes, |
|
|
|
fieldRequiredValidator, |
|
|
|
|
|
|
|
generateUniqueName, |
|
|
|
generateUniqueName, |
|
|
|
getDefaultConnectionConfig, |
|
|
|
getDefaultConnectionConfig, |
|
|
|
getTestDatabaseName, |
|
|
|
getTestDatabaseName, |
|
|
|
projectTitleValidator, |
|
|
|
|
|
|
|
sslUsage, |
|
|
|
sslUsage, |
|
|
|
} from '~/utils/projectCreateUtils' |
|
|
|
} from '~/utils/projectCreateUtils' |
|
|
|
import { readFile } from '~/utils/fileUtils' |
|
|
|
import { fieldRequiredValidator, projectTitleValidator } from '~/utils/validation' |
|
|
|
|
|
|
|
|
|
|
|
const useForm = Form.useForm |
|
|
|
const useForm = Form.useForm |
|
|
|
const loading = ref(false) |
|
|
|
const loading = ref(false) |
|
|
@ -28,10 +28,10 @@ const { t } = useI18n() |
|
|
|
|
|
|
|
|
|
|
|
const formState = $ref<ProjectCreateForm>({ |
|
|
|
const formState = $ref<ProjectCreateForm>({ |
|
|
|
title: '', |
|
|
|
title: '', |
|
|
|
dataSource: { ...getDefaultConnectionConfig('mysql2') }, |
|
|
|
dataSource: { ...getDefaultConnectionConfig(ClientType.MYSQL) }, |
|
|
|
inflection: { |
|
|
|
inflection: { |
|
|
|
inflection_column: 'camelize', |
|
|
|
inflectionColumn: 'camelize', |
|
|
|
inflection_table: 'camelize', |
|
|
|
inflectionTable: 'camelize', |
|
|
|
}, |
|
|
|
}, |
|
|
|
sslUse: 'No', |
|
|
|
sslUse: 'No', |
|
|
|
}) |
|
|
|
}) |
|
|
@ -46,7 +46,7 @@ const validators = computed(() => { |
|
|
|
projectTitleValidator, |
|
|
|
projectTitleValidator, |
|
|
|
], |
|
|
|
], |
|
|
|
'dataSource.client': [fieldRequiredValidator], |
|
|
|
'dataSource.client': [fieldRequiredValidator], |
|
|
|
...(formState.dataSource.client === 'sqlite3' |
|
|
|
...(formState.dataSource.client === ClientType.SQLITE |
|
|
|
? { |
|
|
|
? { |
|
|
|
'dataSource.connection.connection.filename': [fieldRequiredValidator], |
|
|
|
'dataSource.connection.connection.filename': [fieldRequiredValidator], |
|
|
|
} |
|
|
|
} |
|
|
@ -56,7 +56,7 @@ const validators = computed(() => { |
|
|
|
'dataSource.connection.user': [fieldRequiredValidator], |
|
|
|
'dataSource.connection.user': [fieldRequiredValidator], |
|
|
|
'dataSource.connection.password': [fieldRequiredValidator], |
|
|
|
'dataSource.connection.password': [fieldRequiredValidator], |
|
|
|
'dataSource.connection.database': [fieldRequiredValidator], |
|
|
|
'dataSource.connection.database': [fieldRequiredValidator], |
|
|
|
...(['pg', 'mssql'].includes(formState.dataSource.client) |
|
|
|
...([ClientType.PG, ClientType.MSSQL].includes(formState.dataSource.client) |
|
|
|
? { |
|
|
|
? { |
|
|
|
'dataSource.connection.searchPath.0': [fieldRequiredValidator], |
|
|
|
'dataSource.connection.searchPath.0': [fieldRequiredValidator], |
|
|
|
} |
|
|
|
} |
|
|
@ -131,8 +131,8 @@ const createProject = async () => { |
|
|
|
{ |
|
|
|
{ |
|
|
|
type: formState.dataSource.client, |
|
|
|
type: formState.dataSource.client, |
|
|
|
config, |
|
|
|
config, |
|
|
|
inflection_column: formState.inflection.inflection_column, |
|
|
|
inflection_column: formState.inflection.inflectionColumn, |
|
|
|
inflection_table: formState.inflection.inflection_table, |
|
|
|
inflection_table: formState.inflection.inflectionTable, |
|
|
|
}, |
|
|
|
}, |
|
|
|
], |
|
|
|
], |
|
|
|
external: true, |
|
|
|
external: true, |
|
|
@ -155,7 +155,7 @@ const testConnection = async () => { |
|
|
|
} |
|
|
|
} |
|
|
|
$e('a:project:create:extdb:test-connection', []) |
|
|
|
$e('a:project:create:extdb:test-connection', []) |
|
|
|
try { |
|
|
|
try { |
|
|
|
if (formState.dataSource.client === 'sqlite3') { |
|
|
|
if (formState.dataSource.client === ClientType.SQLITE) { |
|
|
|
testSuccess.value = true |
|
|
|
testSuccess.value = true |
|
|
|
} else { |
|
|
|
} else { |
|
|
|
const connection: any = getConnectionConfig() |
|
|
|
const connection: any = getConnectionConfig() |
|
|
@ -242,7 +242,7 @@ onMounted(() => { |
|
|
|
|
|
|
|
|
|
|
|
<!-- SQLite File --> |
|
|
|
<!-- SQLite File --> |
|
|
|
<a-form-item |
|
|
|
<a-form-item |
|
|
|
v-if="formState.dataSource.client === 'sqlite3'" |
|
|
|
v-if="formState.dataSource.client === ClientType.SQLITE" |
|
|
|
:label="$t('labels.sqliteFile')" |
|
|
|
:label="$t('labels.sqliteFile')" |
|
|
|
v-bind="validateInfos['dataSource.connection.connection.filename']" |
|
|
|
v-bind="validateInfos['dataSource.connection.connection.filename']" |
|
|
|
> |
|
|
|
> |
|
|
@ -286,7 +286,7 @@ onMounted(() => { |
|
|
|
</a-form-item> |
|
|
|
</a-form-item> |
|
|
|
<!-- Schema name --> |
|
|
|
<!-- Schema name --> |
|
|
|
<a-form-item |
|
|
|
<a-form-item |
|
|
|
v-if="['mssql', 'pg'].includes(formState.dataSource.client)" |
|
|
|
v-if="[ClientType.MSSQL, ClientType.PG].includes(formState.dataSource.client)" |
|
|
|
:label="$t('labels.schemaName')" |
|
|
|
:label="$t('labels.schemaName')" |
|
|
|
v-bind="validateInfos['dataSource.connection.searchPath.0']" |
|
|
|
v-bind="validateInfos['dataSource.connection.searchPath.0']" |
|
|
|
> |
|
|
|
> |
|
|
@ -339,12 +339,12 @@ onMounted(() => { |
|
|
|
<input ref="keyFileInput" type="file" class="!hidden" @change="onFileSelect('key', keyFileInput)" /> |
|
|
|
<input ref="keyFileInput" type="file" class="!hidden" @change="onFileSelect('key', keyFileInput)" /> |
|
|
|
|
|
|
|
|
|
|
|
<a-form-item :label="$t('labels.inflection.tableName')"> |
|
|
|
<a-form-item :label="$t('labels.inflection.tableName')"> |
|
|
|
<a-select v-model:value="formState.inflection.inflection_table" size="small" @change="onClientChange"> |
|
|
|
<a-select v-model:value="formState.inflection.inflectionTable" size="small" @change="onClientChange"> |
|
|
|
<a-select-option v-for="type in inflectionTypes" :key="type" :value="type">{{ type }}</a-select-option> |
|
|
|
<a-select-option v-for="type in inflectionTypes" :key="type" :value="type">{{ type }}</a-select-option> |
|
|
|
</a-select> |
|
|
|
</a-select> |
|
|
|
</a-form-item> |
|
|
|
</a-form-item> |
|
|
|
<a-form-item :label="$t('labels.inflection.columnName')"> |
|
|
|
<a-form-item :label="$t('labels.inflection.columnName')"> |
|
|
|
<a-select v-model:value="formState.inflection.inflection_column" size="small" @change="onClientChange"> |
|
|
|
<a-select v-model:value="formState.inflection.inflectionColumn" size="small" @change="onClientChange"> |
|
|
|
<a-select-option v-for="type in inflectionTypes" :key="type" :value="type">{{ type }}</a-select-option> |
|
|
|
<a-select-option v-for="type in inflectionTypes" :key="type" :value="type">{{ type }}</a-select-option> |
|
|
|
</a-select> |
|
|
|
</a-select> |
|
|
|
</a-form-item> |
|
|
|
</a-form-item> |
|
|
@ -370,7 +370,7 @@ onMounted(() => { |
|
|
|
|
|
|
|
|
|
|
|
<v-dialog v-model="configEditDlg"> |
|
|
|
<v-dialog v-model="configEditDlg"> |
|
|
|
<a-card> |
|
|
|
<a-card> |
|
|
|
<Monaco v-if="configEditDlg" v-model="formState" class="h-[400px] w-[600px]"></Monaco> |
|
|
|
<MonacoEditor v-if="configEditDlg" v-model="formState" class="h-[400px] w-[600px]" /> |
|
|
|
</a-card> |
|
|
|
</a-card> |
|
|
|
</v-dialog> |
|
|
|
</v-dialog> |
|
|
|
</a-card> |
|
|
|
</a-card> |
|
|
|