Browse Source

Merge branch 'release/11.0' of ssh://code.fineres.com:7999/~aries.lsy/decision-webui-dcm into release/11.0

release/11.0
Aries.lsy 2 years ago
parent
commit
9f44140a75
  1. 36
      src/modules/components/test_status/test_status.ts
  2. 12
      src/modules/crud/api.ts
  3. 9
      src/modules/crud/crud.typings.d.ts
  4. 23
      src/modules/crud/decision.api.ts
  5. 23
      src/modules/crud/design.api.ts
  6. 58
      src/modules/pages/maintain/forms/form.server.ts
  7. 1
      types/globals.d.ts

36
src/modules/components/test_status/test_status.ts

@ -29,7 +29,9 @@ export class TestStatus extends BI.Widget {
failDriverMessage: Label; failDriverMessage: Label;
driverLink: FloatLeftLayout; driverLink: FloatLeftLayout;
detail: VerticalLayout; detail: VerticalLayout;
failMaskers:any; failMaskers: any;
extraContainer: VerticalLayout;
watch = { watch = {
status: (status: string) => { status: (status: string) => {
@ -38,8 +40,9 @@ export class TestStatus extends BI.Widget {
} }
render() { render() {
const LAYOUT_WIDTH = 400;
const { loadingCls, loadingText, successCls, successText, failCls, failText, retryText } = this.options; const { loadingCls, loadingText, successCls, successText, failCls, failText, retryText } = this.options;
var self=this;
return { return {
type: BI.CenterAdaptLayout.xtype, type: BI.CenterAdaptLayout.xtype,
cls: 'bi-z-index-mask', cls: 'bi-z-index-mask',
@ -71,10 +74,10 @@ export class TestStatus extends BI.Widget {
tipCls: failCls, tipCls: failCls,
tipText: failText, tipText: failText,
retryText, retryText,
ref:(_ref:any)=>{ ref: (_ref: TipFail) => {
self.failMaskers=_ref; this.failMaskers = _ref;
if(this.failMessage.getText()===''){ if (BI.isEmptyString(this.failMessage.getText())) {
this.failMaskers.populateFail(BI.i18nText("Dec-Conn-ect-Failed"),false); this.failMaskers.populateFail(BI.i18nText('Dec-Conn-ect-Failed'), false);
} }
}, },
listeners: [ listeners: [
@ -123,10 +126,17 @@ export class TestStatus extends BI.Widget {
scrolly: true, scrolly: true,
height: 75, height: 75,
items: [ items: [
{
type: BI.VerticalLayout.xtype,
width: LAYOUT_WIDTH,
ref: (_ref: VerticalLayout) => {
this.extraContainer = _ref;
}
},
{ {
type: BI.Label.xtype, type: BI.Label.xtype,
whiteSpace: 'normal', whiteSpace: 'normal',
width: 400, width: LAYOUT_WIDTH,
textAlign: 'left', textAlign: 'left',
text: '', text: '',
ref: (_ref: Label) => { ref: (_ref: Label) => {
@ -175,7 +185,7 @@ export class TestStatus extends BI.Widget {
this.store.setStatus(TEST_STATUS.SUCCESS); this.store.setStatus(TEST_STATUS.SUCCESS);
} }
setFail(message: string='', driver = '', link = '') { setFail(message: string = '', driver = '', link = '') {
this.store.setStatus(TEST_STATUS.FAIL); this.store.setStatus(TEST_STATUS.FAIL);
this.failMessage.setText(message); this.failMessage.setText(message);
this.failDriverMessage.setVisible(!!driver); this.failDriverMessage.setVisible(!!driver);
@ -189,4 +199,14 @@ export class TestStatus extends BI.Widget {
setLoading() { setLoading() {
this.store.setStatus(TEST_STATUS.LOADING); this.store.setStatus(TEST_STATUS.LOADING);
} }
/**
*
*/
setExtraContainer(container: Obj) {
BI.createWidget({
...container,
element: this.extraContainer,
});
}
} }

12
src/modules/crud/api.ts

@ -5,6 +5,7 @@ import {
ConnectionPoolType, ConnectionPoolType,
SocketResult, SocketResult,
ResultType, ResultType,
checkDriverStatusParams,
} from './crud.typings'; } from './crud.typings';
export interface Api { export interface Api {
@ -46,6 +47,17 @@ export interface Api {
*/ */
testConnection(data: Connection): Promise<TestRequest>; testConnection(data: Connection): Promise<TestRequest>;
/**
*
*/
getDriverLoadPath(data: Connection): Promise<ResultType<string>>;
/**
*
* @param data
*/
checkDriverStatus(data: checkDriverStatusParams): Promise<ResultType<boolean>>;
/** /**
* *
* @param name * @param name

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

@ -306,8 +306,13 @@ export interface SocketResult {
errorMsg?: string; errorMsg?: string;
} }
export interface ResultType { export interface ResultType<T = any> {
data?: any; data?: T;
errorCode?: string; errorCode?: string;
errorMsg?: string; errorMsg?: string;
} }
export type checkDriverStatusParams = {
path: string;
driver: ConnectionJDBC['driver'];
}

23
src/modules/crud/decision.api.ts

@ -1,5 +1,5 @@
import { Api } from './api'; import { Api } from './api';
import { Connection, TestRequest, ConnectionPoolType, SocketResult, ConnectionLicInfo } from './crud.typings'; import { Connection, TestRequest, ConnectionPoolType, SocketResult, ConnectionLicInfo, ResultType, checkDriverStatusParams } from './crud.typings';
import { requestGet, requestDelete, requestPost, requestPut } from './crud.service'; import { requestGet, requestDelete, requestPost, requestPut } from './crud.service';
import { editStatusEvent, errorCode } from '@constants/env'; import { editStatusEvent, errorCode } from '@constants/env';
@ -48,6 +48,27 @@ export class DecisionApi implements Api {
return requestPost('test', form); return requestPost('test', form);
} }
/**
*
* @returns
*/
getDriverLoadPath(data: Connection): Promise<ResultType<string>> {
const form = {
...data,
connectionData: JSON.stringify(data.connectionData),
};
return requestPost('driver/path', form);
}
/**
*
* @param data
*/
checkDriverStatus(data: checkDriverStatusParams): Promise<ResultType<boolean>> {
return requestGet(Dec.Utils.getEncodeURL('test/driver/conflict', '', data));
}
getConnectionPool(name: string): Promise<{ data?: ConnectionPoolType }> { getConnectionPool(name: string): Promise<{ data?: ConnectionPoolType }> {
return requestGet(`pool/info?connectionName=${encodeURIComponent(name)}`, {}); return requestGet(`pool/info?connectionName=${encodeURIComponent(name)}`, {});
} }

23
src/modules/crud/design.api.ts

@ -1,5 +1,5 @@
import { Api } from './api'; import { Api } from './api';
import { Connection, TestRequest, ConnectionPoolType, SocketResult, ConnectionLicInfo } from './crud.typings'; import { Connection, TestRequest, ConnectionPoolType, SocketResult, ConnectionLicInfo, ResultType, ConnectionJDBC, checkDriverStatusParams } from './crud.typings';
import { requestGet } from './crud.service'; import { requestGet } from './crud.service';
// TODO: 此页面的接口等待设计器提供相应的方法 // TODO: 此页面的接口等待设计器提供相应的方法
@ -39,6 +39,27 @@ export class DesignApi implements Api {
}); });
} }
/**
*
* @param name
* @returns
*/
getDriverLoadPath(data: Connection): Promise<ResultType<string>> {
return new Promise(resolve => {
resolve({ data: '' });
});
}
/**
*
* @param data
*/
checkDriverStatus(data: checkDriverStatusParams): Promise<ResultType<boolean>> {
return new Promise(resolve => {
resolve({ data: false });
});
}
getConnectionPool(name: string): Promise<{ data: ConnectionPoolType }> { getConnectionPool(name: string): Promise<{ data: ConnectionPoolType }> {
return new Promise(resolve => { return new Promise(resolve => {
resolve({ resolve({

58
src/modules/pages/maintain/forms/form.server.ts

@ -5,6 +5,7 @@ import { TestStatus } from '../../../components/test_status/test_status';
import { getJdbcDatabaseType } from '../../../app.service'; import { getJdbcDatabaseType } from '../../../app.service';
import { ApiFactory } from '../../../crud/apiFactory'; import { ApiFactory } from '../../../crud/apiFactory';
const api = new ApiFactory().create(); const api = new ApiFactory().create();
export function testConnection(value: Connection): Promise<string[]> { export function testConnection(value: Connection): Promise<string[]> {
return new Promise(resolve => { return new Promise(resolve => {
let testStatus = null; let testStatus = null;
@ -15,16 +16,18 @@ export function testConnection(value: Connection): Promise<string[]> {
return false; return false;
} }
const id = BI.UUID(); const id = BI.UUID();
const testConnection = () => { const testConnection = () => {
const formValue = value; const formValue = value;
api.testConnection(formValue).then(re => { api.testConnection(formValue).then(re => {
if (re && re.errorCode) { if (re && re.errorCode) {
if(re.errorCode === DecCst.ErrorCode.NO_IP_AUTHORIZED){ if (re.errorCode === DecCst.ErrorCode.NO_IP_AUTHORIZED) {
testStatus.setFail(); testStatus.setFail();
return; return;
} }
// 判断是否是缺少驱动,如果缺少驱动则显示下载驱动的连接 // 判断是否是缺少驱动,如果缺少驱动则显示下载驱动的连接
if (api.isDriverError(re.errorCode)) { if (api.isDriverError(re.errorCode)) {
if (formValue.connectionType === connectionType.JDBC) { if (formValue.connectionType === connectionType.JDBC) {
const driver = (formValue.connectionData as ConnectionJDBC).driver; const driver = (formValue.connectionData as ConnectionJDBC).driver;
@ -44,7 +47,11 @@ export function testConnection(value: Connection): Promise<string[]> {
} else if (re.errorCode === errorCode.DUPLICATE_NAMES) { } else if (re.errorCode === errorCode.DUPLICATE_NAMES) {
testStatus.setFail(BI.i18nText(re.errorMsg)); testStatus.setFail(BI.i18nText(re.errorMsg));
} else { } else {
// 不缺少驱动,但连接失败,打印出当前驱动加载路径,并显示检测驱动按钮
testStatus.setFail(re.errorMsg); testStatus.setFail(re.errorMsg);
api.getDriverLoadPath(formValue).then(res => {
testStatus.setExtraContainer(createDriverTestContainer(res.data));
})
} }
} else if (re.data) { } else if (re.data) {
testStatus.setSuccess(); testStatus.setSuccess();
@ -59,7 +66,54 @@ export function testConnection(value: Connection): Promise<string[]> {
BI.Maskers.remove(id); BI.Maskers.remove(id);
} }
}); });
/**
*
*/
function createDriverTestContainer(path: string) {
return {
type: BI.VerticalLayout.xtype,
vgap: 5,
items: [
{
type: BI.Label.xtype,
text: BI.i18nText('Dec-Connection_Driver_Current_Load_Path', path),
textAlign: 'left',
whiteSpace: 'normal',
},
{
type: BI.TextButton.xtype,
cls: 'bi-high-light',
text: BI.i18nText('Dec-Connection_Driver_Check'),
textAlign: 'left',
handler: () => {
api.checkDriverStatus({
driver: (formValue.connectionData as ConnectionJDBC).driver,
path,
}).then(res => {
const isDriverConflict = res.data;
testStatus.setExtraContainer({
type: BI.VerticalLayout.xtype,
items: [
{
type: BI.Label.xtype,
textAlign: 'left',
text: isDriverConflict
? BI.i18nText('Dec-Connection_Driver_Has_Confilt_Tip')
: BI.i18nText('Dec-Connection_Driver_No_Confilt_Tip'),
cls: isDriverConflict ? 'bi-error' : '',
}
]
})
});
}
}
]
}
}
}; };
BI.Maskers.create(id, null, { BI.Maskers.create(id, null, {
render: { render: {
type: TestStatus.xtype, type: TestStatus.xtype,

1
types/globals.d.ts vendored

@ -16,6 +16,7 @@ declare const Dec: {
personal: { personal: {
username: string; username: string;
}; };
Utils: Obj;
reqByEncrypt: (method: AxiosType.X_Method, url: string, data?: any, config?: AxiosType.X_AxiosRequestConfig) => {}, reqByEncrypt: (method: AxiosType.X_Method, url: string, data?: any, config?: AxiosType.X_AxiosRequestConfig) => {},
socketEmit: (type: string, name: string, callback: (re: any) => void) => void; socketEmit: (type: string, name: string, callback: (re: any) => void) => void;
// req // req

Loading…
Cancel
Save