fix: 【数据源】新建数据源至空必要参数,部分必要参数未弹出提示

This commit is contained in:
taojinlong 2021-09-29 16:55:55 +08:00
parent 2dcae3d146
commit 814aee0e15
3 changed files with 17 additions and 18 deletions

View File

@ -8,8 +8,8 @@ import lombok.Setter;
@Setter
public class EsConfigDTO {
private String url;
private String username;
private String password;
private String esUsername;
private String esPassword;
private String version;
private String uri;
private String dataSourceType = "es";

View File

@ -50,8 +50,8 @@ public class EsProvider extends DatasourceProvider {
try {
EsConfigDTO esConfigDTO = new Gson().fromJson(dsr.getDatasource().getConfiguration(), EsConfigDTO.class);
HttpClientConfig httpClientConfig = new HttpClientConfig();
if(StringUtils.isNotEmpty(esConfigDTO.getUsername())){
String auth = esConfigDTO.getUsername() + ":" + esConfigDTO.getPassword();
if(StringUtils.isNotEmpty(esConfigDTO.getEsUsername())){
String auth = esConfigDTO.getEsUsername() + ":" + esConfigDTO.getEsPassword();
byte[] encodedAuth = Base64.encodeBase64(auth.getBytes(StandardCharsets.UTF_8));
httpClientConfig.addHeader(HttpHeaders.AUTHORIZATION, "Basic " + new String(encodedAuth));
}
@ -252,8 +252,8 @@ public class EsProvider extends DatasourceProvider {
EsConfigDTO esConfigDTO = new Gson().fromJson(datasourceRequest.getDatasource().getConfiguration(), EsConfigDTO.class);
uri = esConfigDTO.getUri()+uri;
HttpClientConfig httpClientConfig = new HttpClientConfig();
if(StringUtils.isNotEmpty(esConfigDTO.getUsername()) && StringUtils.isNotEmpty(esConfigDTO.getPassword())){
String auth = esConfigDTO.getUsername() + ":" + esConfigDTO.getPassword();
if(StringUtils.isNotEmpty(esConfigDTO.getEsUsername()) && StringUtils.isNotEmpty(esConfigDTO.getEsPassword())){
String auth = esConfigDTO.getEsUsername() + ":" + esConfigDTO.getEsPassword();
byte[] encodedAuth = Base64.encodeBase64(auth.getBytes(StandardCharsets.UTF_8));
httpClientConfig.addHeader(HttpHeaders.AUTHORIZATION, "Basic " + new String(encodedAuth));
}
@ -269,8 +269,8 @@ public class EsProvider extends DatasourceProvider {
private String exexGetQuery(DatasourceRequest datasourceRequest){
EsConfigDTO esConfigDTO = new Gson().fromJson(datasourceRequest.getDatasource().getConfiguration(), EsConfigDTO.class);
HttpClientConfig httpClientConfig = new HttpClientConfig();
if(StringUtils.isNotEmpty(esConfigDTO.getUsername()) && StringUtils.isNotEmpty(esConfigDTO.getPassword())){
String auth = esConfigDTO.getUsername() + ":" + esConfigDTO.getPassword();
if(StringUtils.isNotEmpty(esConfigDTO.getEsUsername()) && StringUtils.isNotEmpty(esConfigDTO.getEsPassword())){
String auth = esConfigDTO.getEsUsername() + ":" + esConfigDTO.getEsPassword();
byte[] encodedAuth = Base64.encodeBase64(auth.getBytes(StandardCharsets.UTF_8));
httpClientConfig.addHeader(HttpHeaders.AUTHORIZATION, "Basic " + new String(encodedAuth));
}

View File

@ -39,12 +39,19 @@
<el-radio v-model="form.configuration.connectionType" label="serviceName">{{ $t('datasource.oracle_service_name') }}</el-radio>
</el-form-item>
<el-form-item :label="$t('datasource.user_name')" >
<el-form-item v-if="form.configuration.dataSourceType=='jdbc'" :label="$t('datasource.user_name')" prop="configuration.username">
<el-input v-model="form.configuration.username" autocomplete="off" />
</el-form-item>
<el-form-item :label="$t('datasource.password')" >
<el-form-item v-if="form.configuration.dataSourceType=='jdbc'" :label="$t('datasource.password')" prop="configuration.password">
<el-input v-model="form.configuration.password" autocomplete="off" show-password />
</el-form-item>
<el-form-item v-if="form.configuration.dataSourceType=='es'" :label="$t('datasource.user_name')" >
<el-input v-model="form.configuration.esUsername" autocomplete="off" />
</el-form-item>
<el-form-item v-if="form.configuration.dataSourceType=='es'" :label="$t('datasource.password')" >
<el-input v-model="form.configuration.esPassword" autocomplete="off" show-password />
</el-form-item>
<el-form-item v-if="form.configuration.dataSourceType=='jdbc'" :label="$t('datasource.port')" prop="configuration.port">
<el-input v-model="form.configuration.port" autocomplete="off" />
</el-form-item>
@ -208,14 +215,6 @@ export default {
this.$refs.dsForm.resetFields()
},
save() {
if(this.form.type !== 'es' && !this.form.configuration.username){
this.$message.error(this.$t('datasource.please_input_user_name'))
return
}
if(this.form.type !== 'es' && !this.form.configuration.username){
this.$message.error(this.$t('datasource.please_input_password'))
return
}
if (!this.form.configuration.schema && (this.form.type === 'oracle' || this.form.type === 'sqlServer')) {
this.$message.error(this.$t('datasource.please_choose_schema'))
return