|
|
@ -7,7 +7,7 @@ import { |
|
|
|
Form, |
|
|
|
Form, |
|
|
|
Modal, |
|
|
|
Modal, |
|
|
|
SSLUsage, |
|
|
|
SSLUsage, |
|
|
|
clientTypes, |
|
|
|
clientTypes as _clientTypes, |
|
|
|
computed, |
|
|
|
computed, |
|
|
|
extractSdkResponseErrorMsg, |
|
|
|
extractSdkResponseErrorMsg, |
|
|
|
fieldRequiredValidator, |
|
|
|
fieldRequiredValidator, |
|
|
@ -28,6 +28,8 @@ import { |
|
|
|
watch, |
|
|
|
watch, |
|
|
|
} from '#imports' |
|
|
|
} from '#imports' |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const { appInfo } = useGlobal() |
|
|
|
|
|
|
|
|
|
|
|
const useForm = Form.useForm |
|
|
|
const useForm = Form.useForm |
|
|
|
|
|
|
|
|
|
|
|
const testSuccess = ref(false) |
|
|
|
const testSuccess = ref(false) |
|
|
@ -64,23 +66,29 @@ const customFormState = ref<ProjectCreateForm>({ |
|
|
|
extraParameters: [], |
|
|
|
extraParameters: [], |
|
|
|
}) |
|
|
|
}) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const clientTypes = computed(() => { |
|
|
|
|
|
|
|
return _clientTypes.filter((type) => { |
|
|
|
|
|
|
|
return appInfo.value?.ee || type.value !== ClientType.SNOWFLAKE |
|
|
|
|
|
|
|
}) |
|
|
|
|
|
|
|
}) |
|
|
|
|
|
|
|
|
|
|
|
const validators = computed(() => { |
|
|
|
const validators = computed(() => { |
|
|
|
return { |
|
|
|
let clientValidations: Record<string, any[]> = { |
|
|
|
'title': [ |
|
|
|
'dataSource.connection.host': [fieldRequiredValidator()], |
|
|
|
{ |
|
|
|
'dataSource.connection.port': [fieldRequiredValidator()], |
|
|
|
required: true, |
|
|
|
'dataSource.connection.user': [fieldRequiredValidator()], |
|
|
|
message: 'Project name is required', |
|
|
|
'dataSource.connection.password': [fieldRequiredValidator()], |
|
|
|
}, |
|
|
|
'dataSource.connection.database': [fieldRequiredValidator()], |
|
|
|
projectTitleValidator, |
|
|
|
} |
|
|
|
], |
|
|
|
|
|
|
|
'extraParameters': [extraParameterValidator], |
|
|
|
switch (formState.dataSource.client) { |
|
|
|
'dataSource.client': [fieldRequiredValidator()], |
|
|
|
case ClientType.SQLITE: |
|
|
|
...(formState.dataSource.client === ClientType.SQLITE |
|
|
|
clientValidations = { |
|
|
|
? { |
|
|
|
|
|
|
|
'dataSource.connection.connection.filename': [fieldRequiredValidator()], |
|
|
|
'dataSource.connection.connection.filename': [fieldRequiredValidator()], |
|
|
|
} |
|
|
|
} |
|
|
|
: formState.dataSource.client === ClientType.SNOWFLAKE |
|
|
|
break |
|
|
|
? { |
|
|
|
case ClientType.SNOWFLAKE: |
|
|
|
|
|
|
|
clientValidations = { |
|
|
|
'dataSource.connection.account': [fieldRequiredValidator()], |
|
|
|
'dataSource.connection.account': [fieldRequiredValidator()], |
|
|
|
'dataSource.connection.username': [fieldRequiredValidator()], |
|
|
|
'dataSource.connection.username': [fieldRequiredValidator()], |
|
|
|
'dataSource.connection.password': [fieldRequiredValidator()], |
|
|
|
'dataSource.connection.password': [fieldRequiredValidator()], |
|
|
@ -88,18 +96,24 @@ const validators = computed(() => { |
|
|
|
'dataSource.connection.database': [fieldRequiredValidator()], |
|
|
|
'dataSource.connection.database': [fieldRequiredValidator()], |
|
|
|
'dataSource.connection.schema': [fieldRequiredValidator()], |
|
|
|
'dataSource.connection.schema': [fieldRequiredValidator()], |
|
|
|
} |
|
|
|
} |
|
|
|
: { |
|
|
|
break |
|
|
|
'dataSource.connection.host': [fieldRequiredValidator()], |
|
|
|
case ClientType.PG: |
|
|
|
'dataSource.connection.port': [fieldRequiredValidator()], |
|
|
|
case ClientType.MSSQL: |
|
|
|
'dataSource.connection.user': [fieldRequiredValidator()], |
|
|
|
clientValidations['dataSource.searchPath.0'] = [fieldRequiredValidator()] |
|
|
|
'dataSource.connection.password': [fieldRequiredValidator()], |
|
|
|
break |
|
|
|
'dataSource.connection.database': [fieldRequiredValidator()], |
|
|
|
|
|
|
|
...([ClientType.PG, ClientType.MSSQL].includes(formState.dataSource.client) |
|
|
|
|
|
|
|
? { |
|
|
|
|
|
|
|
'dataSource.searchPath.0': [fieldRequiredValidator()], |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
: {}), |
|
|
|
|
|
|
|
}), |
|
|
|
return { |
|
|
|
|
|
|
|
'title': [ |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
required: true, |
|
|
|
|
|
|
|
message: 'Project name is required', |
|
|
|
|
|
|
|
}, |
|
|
|
|
|
|
|
projectTitleValidator, |
|
|
|
|
|
|
|
], |
|
|
|
|
|
|
|
'extraParameters': [extraParameterValidator], |
|
|
|
|
|
|
|
'dataSource.client': [fieldRequiredValidator()], |
|
|
|
|
|
|
|
...clientValidations, |
|
|
|
} |
|
|
|
} |
|
|
|
}) |
|
|
|
}) |
|
|
|
|
|
|
|
|
|
|
@ -483,8 +497,10 @@ onMounted(async () => { |
|
|
|
</div> |
|
|
|
</div> |
|
|
|
</template> |
|
|
|
</template> |
|
|
|
<a-form-item label="SSL mode"> |
|
|
|
<a-form-item label="SSL mode"> |
|
|
|
<a-select v-model:value="formState.sslUse" dropdown-class-name="nc-dropdown-ssl-mode" @select="onSSLModeChange"> |
|
|
|
<a-select v-model:value="formState.sslUse" dropdown-class-name="nc-dropdown-ssl-mode" |
|
|
|
<a-select-option v-for="opt in Object.values(SSLUsage)" :key="opt" :value="opt">{{ opt }}</a-select-option> |
|
|
|
@select="onSSLModeChange"> |
|
|
|
|
|
|
|
<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> |
|
|
|
|
|
|
|
|
|
|
@ -526,14 +542,16 @@ onMounted(async () => { |
|
|
|
|
|
|
|
|
|
|
|
<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 /> |
|
|
|
|
|
|
|
|
|
|
|
<!-- Extra connection parameters --> |
|
|
|
<!-- Extra connection parameters --> |
|
|
|
<a-form-item class="mb-2" :label="$t('labels.extraConnectionParameters')" v-bind="validateInfos.extraParameters"> |
|
|
|
<a-form-item class="mb-2" :label="$t('labels.extraConnectionParameters')" |
|
|
|
|
|
|
|
v-bind="validateInfos.extraParameters"> |
|
|
|
<a-card> |
|
|
|
<a-card> |
|
|
|
<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"> |
|
|
@ -547,7 +565,9 @@ onMounted(async () => { |
|
|
|
</div> |
|
|
|
</div> |
|
|
|
</div> |
|
|
|
</div> |
|
|
|
<a-button type="dashed" class="w-full caption mt-2" @click="addNewParam"> |
|
|
|
<a-button type="dashed" class="w-full caption mt-2" @click="addNewParam"> |
|
|
|
<div class="flex items-center justify-center"><MdiPlus /></div> |
|
|
|
<div class="flex items-center justify-center"> |
|
|
|
|
|
|
|
<MdiPlus /> |
|
|
|
|
|
|
|
</div> |
|
|
|
</a-button> |
|
|
|
</a-button> |
|
|
|
</a-card> |
|
|
|
</a-card> |
|
|
|
</a-form-item> |
|
|
|
</a-form-item> |
|
|
|