Browse Source

feat: DEC-9068 测试连接的时候返回并绑定模式

qufenxi
alan 5 years ago
parent
commit
bcfd2132e2
  1. 2
      src/modules/crud/crud.typings.d.ts
  2. 28
      src/modules/pages/maintain/forms/components/form.jdbc.ts
  3. 3
      src/modules/pages/maintain/forms/form.ts

2
src/modules/crud/crud.typings.d.ts vendored

@ -193,7 +193,7 @@ export interface ConnectionPlugin {
} }
export interface TestRequest { export interface TestRequest {
data?: []; data?: string[];
errorCode?: string; errorCode?: string;
errorMsg?: string; errorMsg?: string;
} }

28
src/modules/pages/maintain/forms/components/form.jdbc.ts

@ -17,6 +17,8 @@ export class FormJdbc extends BI.Widget {
oldPassword = ''; oldPassword = '';
allDatabaseTypes = getAllDatabaseTypes(); allDatabaseTypes = getAllDatabaseTypes();
private schemas = [] as string[];
testStatus: any; testStatus: any;
advancedSet: any; advancedSet: any;
formUser: any; formUser: any;
@ -298,14 +300,33 @@ export class FormJdbc extends BI.Widget {
invisible: !databaseType.hasSchema, invisible: !databaseType.hasSchema,
name: BI.i18nText('Dec-Dcm_Connection_Form_Pattern'), name: BI.i18nText('Dec-Dcm_Connection_Form_Pattern'),
forms: [{ forms: [{
type: TextEditor, type: SingleSelectInsertCombo,
width: 300, width: 300,
allowBlank: true,
value: schema, value: schema,
watermark: BI.i18nText('Dec-Dcm_Connection_Form_Pattern'), watermark: BI.i18nText('Dec-Dcm_Connection_Form_Pattern'),
ref: (_ref: any) => { ref: (_ref: any) => {
this.form.schema = _ref; this.form.schema = _ref;
}, },
itemsCreator: (options: {
keywords?: string[],
selectedValues: string[],
times: number,
type: number,
}, callback: Function) => {
let schemas = this.schemas;
if (options.selectedValues && options.selectedValues.length > 0) {
schemas = schemas.filter(item => item !== options.selectedValues[0]);
}
callback({
items: schemas.map(item => {
return {
text: item,
value: item,
};
}),
hasNext: false,
});
},
}], }],
}, },
{ {
@ -598,6 +619,9 @@ export class FormJdbc extends BI.Widget {
this.form.url.setValue(url.replace('hostname', host).replace(':port', port ? `:${port}` : '')); this.form.url.setValue(url.replace('hostname', host).replace(':port', port ? `:${port}` : ''));
} }
public setSchemas(schemas: string[]) {
this.schemas = schemas;
}
public getSubmitValue():Connection { public getSubmitValue():Connection {
const connectionData = this.options.formData.connectionData as ConnectionJDBC; const connectionData = this.options.formData.connectionData as ConnectionJDBC;

3
src/modules/pages/maintain/forms/form.ts

@ -46,6 +46,9 @@ export class MaintainForm extends BI.Widget {
this.testStatus.setFail(re.errorMsg); this.testStatus.setFail(re.errorMsg);
} else if (re.data) { } else if (re.data) {
this.testStatus.setSuccess(); this.testStatus.setSuccess();
if (re.data.length > 0) {
this.form.setSchemas && this.form.setSchemas(re.data);
}
setTimeout(() => { setTimeout(() => {
BI.Maskers.remove(id); BI.Maskers.remove(id);
}, 1000 * 2); }, 1000 * 2);

Loading…
Cancel
Save