Browse Source

feat: KERNEL-1208 测试连接异常时显示下载对应驱动的链接

qufenxi
alan 5 years ago
parent
commit
96c23b5759
  1. 3
      i18n/zh_cn.properties
  2. 3
      private/i18n.ts
  3. 4
      src/modules/components/test_status/test_status.model.ts
  4. 61
      src/modules/components/test_status/test_status.ts
  5. 140
      src/modules/constants/constant.ts
  6. 5
      src/modules/crud/api.ts
  7. 8
      src/modules/crud/decision.api.ts
  8. 5
      src/modules/crud/design.api.ts
  9. 9
      src/modules/pages/connection/list/list_item/list_item.model.ts
  10. 21
      src/modules/pages/connection/list/list_item/list_item.ts
  11. 2
      src/modules/pages/maintain/forms/components/form.jdbc.ts
  12. 3
      src/modules/pages/maintain/forms/form.model.ts
  13. 16
      src/modules/pages/maintain/forms/form.ts

3
i18n/zh_cn.properties

@ -102,6 +102,9 @@ Dec-Dcm_Connection_JDBC_Warning= 请确认已经将krb5.Conf文件添加到/weba
Dec-Dcm_Connection_Form_UserName_Password= 用户名密码 Dec-Dcm_Connection_Form_UserName_Password= 用户名密码
Dec-Dcm_Change_Name= 重命名 Dec-Dcm_Change_Name= 重命名
Dec-Dcm_Socket_Unable_Connect= Socket未连接,可能存在多人同时编辑造成冲突,相关端口可能未开放 Dec-Dcm_Socket_Unable_Connect= Socket未连接,可能存在多人同时编辑造成冲突,相关端口可能未开放
Dec-Dcm_Connection_HW_DWS=华为云DWS
Dec-Dcm_Connection_Lack_Driver=未找到“{R1}”驱动。
Dec-Dcm_Connection_Download_Driver=下载对应驱动
BI-Multi_Date_Quarter_End= 季度末 BI-Multi_Date_Quarter_End= 季度末
BI-Multi_Date_Month_Begin= 月初 BI-Multi_Date_Month_Begin= 月初

3
private/i18n.ts

@ -101,6 +101,9 @@ export default {
'Dec-Dcm_Connection_Form_UserName_Password': '用户名密码', 'Dec-Dcm_Connection_Form_UserName_Password': '用户名密码',
'Dec-Dcm_Change_Name': '重命名', 'Dec-Dcm_Change_Name': '重命名',
'Dec-Dcm_Socket_Unable_Connect': 'Socket未连接,可能存在多人同时编辑造成冲突,相关端口可能未开放', 'Dec-Dcm_Socket_Unable_Connect': 'Socket未连接,可能存在多人同时编辑造成冲突,相关端口可能未开放',
'Dec-Dcm_Connection_HW_DWS': '华为云DWS',
'Dec-Dcm_Connection_Lack_Driver': '未找到“{R1}”驱动。',
'Dec-Dcm_Connection_Download_Driver': '下载对应驱动',
'BI-Multi_Date_Quarter_End': '季度末', 'BI-Multi_Date_Quarter_End': '季度末',
'BI-Multi_Date_Month_Begin': '月初', 'BI-Multi_Date_Month_Begin': '月初',
'BI-Multi_Date_YMD': '年月日', 'BI-Multi_Date_YMD': '年月日',

4
src/modules/components/test_status/test_status.model.ts

@ -6,6 +6,7 @@ export class TestStatusModel extends Model {
state() { state() {
return { return {
status: TEST_STATUS.LOADING, status: TEST_STATUS.LOADING,
link: '',
}; };
} }
@ -13,5 +14,8 @@ export class TestStatusModel extends Model {
setStatus: (status: string) => { setStatus: (status: string) => {
this.model.status = status; this.model.status = status;
}, },
setLink: (link: string) => {
this.model.link = link;
},
} }
} }

61
src/modules/components/test_status/test_status.ts

@ -1,6 +1,6 @@
import { shortcut, store } from '@core/core'; import { shortcut, store } from '@core/core';
import { TestStatusModelXtype, TestStatusModel } from './test_status.model'; import { TestStatusModelXtype, TestStatusModel } from './test_status.model';
import { CenterAdapt, Tab, Horizotal, Vertical } from 'ui'; import { CenterAdapt, Tab, Vertical, Label, TextButton, Left } from 'ui';
import { TEST_STATUS } from '@constants/constant'; import { TEST_STATUS } from '@constants/constant';
import { TipIconXtype } from './tip_icon/tip_icon'; import { TipIconXtype } from './tip_icon/tip_icon';
import { TipFailXtype, EVENT_CLOSE, EVENT_RELOAD, EVENT_DETAIL } from './tip_icon/tip_fail'; import { TipFailXtype, EVENT_CLOSE, EVENT_RELOAD, EVENT_DETAIL } from './tip_icon/tip_fail';
@ -27,6 +27,8 @@ export class TestStatus extends BI.Widget {
tab: any; tab: any;
failMessage: any; failMessage: any;
failDriverMessage: any;
driverLink: any;
detail: any; detail: any;
watch = { watch = {
@ -105,25 +107,48 @@ export class TestStatus extends BI.Widget {
type: Vertical, type: Vertical,
cls: 'bi-card', cls: 'bi-card',
invisible: true, invisible: true,
bgap: 10,
items: [ items: [
{ {
type: Horizotal, type: Vertical,
height: 73,
cls: 'bi-header-background', cls: 'bi-header-background',
tgap: 5, vgap: 5,
bgap: 10,
hgap: 10, hgap: 10,
scrolly: true, scrolly: true,
items: [{ items: [
type: 'bi.label', {
whiteSpace: 'normal', type: Label,
width: 400, whiteSpace: 'normal',
textAlign: 'left', width: 400,
text: '', textAlign: 'left',
ref: (_ref: any) => { text: '',
this.failMessage = _ref; ref: (_ref: any) => {
this.failMessage = _ref;
},
}, },
}], {
type: Label,
textAlign: 'left',
invisible: true,
ref: (_ref: any) => {
this.failDriverMessage = _ref;
},
},
{
type: Left,
invisible: true,
items: [
{
type: TextButton,
cls: 'bi-high-light bi-high-light-border-bottom',
text: BI.i18nText('Dec-Dcm_Connection_Download_Driver'),
},
],
ref: (_ref: any) => {
this.driverLink = _ref;
},
},
],
}, },
], ],
ref: (_ref: any) => { ref: (_ref: any) => {
@ -140,9 +165,15 @@ export class TestStatus extends BI.Widget {
this.store.setStatus(TEST_STATUS.SUCCESS); this.store.setStatus(TEST_STATUS.SUCCESS);
} }
setFail(message: string) { 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.isVisible(!!driver);
this.driverLink.isVisible(!!driver);
if (driver) {
this.failDriverMessage.setText(BI.i18nText('Dec-Dcm_Connection_Lack_Driver', driver));
this.store.setLink(link);
}
} }
setLoading() { setLoading() {

140
src/modules/constants/constant.ts

@ -28,6 +28,144 @@ export const DATA_BASE_TYPES_OTHER =
hasSchema: true, hasSchema: true,
kerberos: false, kerberos: false,
}; };
export const DATA_BASE_DRIVER_LINK = DecCst ? [
{
databaseType: 'ads',
link: DecCst.Hyperlink.Database.ADS,
},
{
databaseType: 'amazon-redshift',
link: DecCst.Hyperlink.Database.REDSHIFT,
},
{
databaseType: 'apache-impala',
link: DecCst.Hyperlink.Database.IMPALA,
},
{
databaseType: 'apache-kylin',
link: DecCst.Hyperlink.Database.PHOENIX,
},
{
databaseType: 'apache-phoenix',
link: DecCst.Hyperlink.Database.PHOENIX,
},
{
databaseType: 'derby',
link: DecCst.Hyperlink.Database.DERBY,
},
{
databaseType: 'gbase-8a',
link: DecCst.Hyperlink.Database.GBASE8A,
},
{
databaseType: 'gbase-8s',
link: DecCst.Hyperlink.Database.GBASE8S,
},
{
databaseType: 'gbase-8t',
link: DecCst.Hyperlink.Database.GBASE8T,
},
{
databaseType: 'h2',
link: DecCst.Hyperlink.Database.H2,
},
{
databaseType: 'hw-dws',
link: DecCst.Hyperlink.Database.DWS,
},
{
databaseType: 'hw-elk',
link: DecCst.Hyperlink.Database.ELK,
},
{
databaseType: 'hw-fusioninsight-hd',
link: DecCst.Hyperlink.Database.FUSIONINSIGHT,
},
{
databaseType: 'hw-libr-a',
link: DecCst.Hyperlink.Database.LIBRA,
},
{
databaseType: 'hadoop-hive',
link: DecCst.Hyperlink.Database.HIVE,
},
{
databaseType: 'hbase',
link: DecCst.Hyperlink.Database.HBASE,
},
{
databaseType: 'hp-vertica',
link: DecCst.Hyperlink.Database.VERTICA,
},
{
databaseType: 'hsql',
link: DecCst.Hyperlink.Database.HSQL,
},
{
databaseType: 'ibm-db2',
link: DecCst.Hyperlink.Database.DB2,
},
{
databaseType: 'informix',
link: DecCst.Hyperlink.Database.INFORMIX,
},
{
databaseType: 'kingbase',
link: DecCst.Hyperlink.Database.KINGBASE,
},
{
databaseType: 'sql-server',
link: DecCst.Hyperlink.Database.SQLSERVER,
},
{
databaseType: 'mysql',
link: DecCst.Hyperlink.Database.MYSQL,
},
{
databaseType: 'oracle',
link: DecCst.Hyperlink.Database.ORACLE,
},
{
databaseType: 'pivotal-greenplum-database',
link: DecCst.Hyperlink.Database.GP,
},
{
databaseType: 'postgresql',
link: DecCst.Hyperlink.Database.POSTGRE,
},
{
databaseType: 'presto',
link: DecCst.Hyperlink.Database.PRESTO,
},
{
databaseType: 'sap-hana',
link: DecCst.Hyperlink.Database.HANA,
},
{
databaseType: 'sap-sybase',
link: DecCst.Hyperlink.Database.SYBASE,
},
{
databaseType: 'spark',
link: DecCst.Hyperlink.Database.SPARK,
},
{
databaseType: 'sqlite',
link: DecCst.Hyperlink.Database.SQLITE,
},
{
databaseType: 'teradata',
link: DecCst.Hyperlink.Database.TERADATA,
},
{
databaseType: 'transwarp-inceptor',
link: DecCst.Hyperlink.Database.INCEPTOR,
},
{
databaseType: 'other',
link: DecCst.Hyperlink.Database.OTHER,
},
] : [];
export const DATA_BASE_TYPES = [ export const DATA_BASE_TYPES = [
{ {
text: 'ADS', text: 'ADS',
@ -141,7 +279,7 @@ export const DATA_BASE_TYPES = [
kerberos: false, kerberos: false,
}, },
{ {
text: '华为云DWS', text: BI.i18nText('Dec-Dcm_Connection_HW_DWS'),
databaseType: 'hw-dws', databaseType: 'hw-dws',
driver: 'org.postgresql.Driver', driver: 'org.postgresql.Driver',
url: 'jdbc:postgresql://hostname:port/database', url: 'jdbc:postgresql://hostname:port/database',

5
src/modules/crud/api.ts

@ -56,4 +56,9 @@ export interface Api {
* socket连接状态 * socket连接状态
*/ */
getSocketStatus(): boolean; getSocketStatus(): boolean;
/**
*
*/
isDriverError(errorCode: string): boolean;
} }

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

@ -64,6 +64,14 @@ export class DecisionApi implements Api {
return false; return false;
} }
isDriverError(errorCode: string) {
if (Dec) {
return DecCst.ErrorCode.LACK_DRIVER === errorCode;
}
return false;
}
private sendEditStatusEvent(name: string, type: string): Promise<SocketResult> { private sendEditStatusEvent(name: string, type: string): Promise<SocketResult> {
return new Promise(resolve => { return new Promise(resolve => {
if (Dec && Dec.socket.connected) { if (Dec && Dec.socket.connected) {

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

@ -61,4 +61,9 @@ export class DesignApi implements Api {
// 设计器无socket校验 // 设计器无socket校验
return true; return true;
} }
isDriverError(errorCode: string) {
// 设计器暂不校验
return false;
}
} }

9
src/modules/pages/connection/list/list_item/list_item.model.ts

@ -78,11 +78,18 @@ export class ListItemModel extends Model<{
}; };
}); });
return api.updateConnection(connection); return api.updateConnection(connection).then(re => {
this.setIsEdit(false, oldName);
return re;
});
}, },
setIsCopy(isCopy: boolean) { setIsCopy(isCopy: boolean) {
this.model.isCopy = isCopy; this.model.isCopy = isCopy;
}, },
isDriverError(errorCode: string) {
return api.isDriverError(errorCode);
},
} }
removeConnection(name: string) { removeConnection(name: string) {
api.deleteConnection(name).then(re => api.getConnectionlist()) api.deleteConnection(name).then(re => api.getConnectionlist())

21
src/modules/pages/connection/list/list_item/list_item.ts

@ -2,9 +2,11 @@ import { shortcut, store } from '@core/core';
import { Label, LeftRightVerticalAdapt, IconLabel, IconButton, DownListCombo, SignEditor } from 'ui'; import { Label, LeftRightVerticalAdapt, IconLabel, IconButton, DownListCombo, SignEditor } from 'ui';
import './list_item.less'; import './list_item.less';
import { ListItemModel, ListItemModelXtype } from './list_item.model'; import { ListItemModel, ListItemModelXtype } from './list_item.model';
import { PAGE_INDEX } from '@constants/constant'; import { PAGE_INDEX, DATA_BASE_DRIVER_LINK } from '@constants/constant';
import { TestStatusXtype, TestStatus, EVENT_CLOSE, EVENT_RELOAD } from 'src/modules/components/test_status/test_status'; import { TestStatusXtype, TestStatus, EVENT_CLOSE, EVENT_RELOAD } from 'src/modules/components/test_status/test_status';
import { hasRegistered } from '../list.service'; import { hasRegistered } from '../list.service';
import { connectionType } from '@constants/env';
import { ConnectionJDBC } from 'src/modules/crud/crud.typings';
export const ListItemXtype = 'dec.dcm.connection.list_item'; export const ListItemXtype = 'dec.dcm.connection.list_item';
@shortcut(ListItemXtype) @shortcut(ListItemXtype)
@store(ListItemModelXtype) @store(ListItemModelXtype)
@ -68,7 +70,6 @@ export class ListItem extends BI.BasicButton {
action: () => { action: () => {
const newName = this.nameEditor.getValue(); const newName = this.nameEditor.getValue();
this.store.changeName(name, newName).then(() => { this.store.changeName(name, newName).then(() => {
this.store.setIsEdit(false, name);
this.nameLabel.setText(newName); this.nameLabel.setText(newName);
}); });
}, },
@ -156,12 +157,24 @@ export class ListItem extends BI.BasicButton {
} }
private testConnectionAction() { private testConnectionAction() {
const { name } = this.options; const { name, databaseType } = this.options;
const id = BI.UUID(); const id = BI.UUID();
const testConnection = () => { const testConnection = () => {
this.store.testConnection(name).then(re => { this.store.testConnection(name).then(re => {
if (re && re.errorCode) { if (re && re.errorCode) {
this.testStatus.setFail(re.errorMsg); // 判断是否是缺少驱动,如果缺少驱动则显示下载驱动的连接
if (this.store.isDriverError(re.errorCode)) {
const thisConnection = this.model.connections.find(item => item.connectionName === name);
if (thisConnection.connectionType === connectionType.JDBC) {
const driver = (thisConnection.connectionData as ConnectionJDBC).driver;
const databaseLink = BI.get(DATA_BASE_DRIVER_LINK.find(item => item.databaseType === databaseType), 'link');
this.testStatus.setFail(re.errorMsg, driver, BI.Services.getService('dec.service.migration').getHelpLink(databaseLink));
} else {
this.testStatus.setFail(re.errorMsg);
}
} else {
this.testStatus.setFail(re.errorMsg);
}
} else if (re.data) { } else if (re.data) {
this.testStatus.setSuccess(); this.testStatus.setSuccess();
setTimeout(() => { setTimeout(() => {

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

@ -285,7 +285,7 @@ export class FormJdbc extends BI.Widget {
cls: 'bi-tips', cls: 'bi-tips',
textAlign: 'left', textAlign: 'left',
invisible: true, invisible: true,
text: BI.i18nText('Dec-Dcm_Connection_JNDI_Warning'), text: BI.i18nText('Dec-Dcm_Connection_JDBC_Warning'),
ref: (_ref: any) => { ref: (_ref: any) => {
this.labelTips = _ref; this.labelTips = _ref;
}, },

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

@ -36,5 +36,8 @@ export class MaintainFormModel extends Model<{
setIsCopy(isCopy: boolean) { setIsCopy(isCopy: boolean) {
this.model.isCopy = isCopy; this.model.isCopy = isCopy;
}, },
isDriverError(errorCode: string) {
return api.isDriverError(errorCode);
},
} }
} }

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

@ -6,7 +6,7 @@ import { FormPluginXtype } from './components/form.plugin';
import { connectionType } from '@constants/env'; import { connectionType } from '@constants/env';
import { ConnectionJDBC, Connection } from 'src/modules/crud/crud.typings'; import { ConnectionJDBC, Connection } from 'src/modules/crud/crud.typings';
import { TestStatusXtype, EVENT_RELOAD, EVENT_CLOSE } from 'src/modules/components/test_status/test_status'; import { TestStatusXtype, EVENT_RELOAD, EVENT_CLOSE } from 'src/modules/components/test_status/test_status';
import { DEFAULT_JNDI_DATA, DEFAULT_JDBC_POOL } from '@constants/constant'; import { DEFAULT_JNDI_DATA, DEFAULT_JDBC_POOL, DATA_BASE_DRIVER_LINK } from '@constants/constant';
import { getJdbcDatabaseType } from 'src/modules/app.service'; import { getJdbcDatabaseType } from 'src/modules/app.service';
export const MaintainFormXtype = 'dec.dcm.maintain.form'; export const MaintainFormXtype = 'dec.dcm.maintain.form';
@ -49,7 +49,19 @@ export class MaintainForm extends BI.Widget {
} }
this.store.testConnection(formValue).then(re => { this.store.testConnection(formValue).then(re => {
if (re && re.errorCode) { if (re && re.errorCode) {
this.testStatus.setFail(re.errorMsg); // 判断是否是缺少驱动,如果缺少驱动则显示下载驱动的连接
if (this.store.isDriverError(re.errorCode)) {
if (formValue.connectionType === connectionType.JDBC) {
const driver = (formValue.connectionData as ConnectionJDBC).driver;
const databaseType = (formValue.connectionData as ConnectionJDBC).database;
const databaseLink = BI.get(DATA_BASE_DRIVER_LINK.find(item => item.databaseType === databaseType), 'link');
this.testStatus.setFail(re.errorMsg, driver, BI.Services.getService('dec.service.migration').getHelpLink(databaseLink));
} else {
this.testStatus.setFail(re.errorMsg);
}
} else {
this.testStatus.setFail(re.errorMsg);
}
} else if (re.data) { } else if (re.data) {
this.testStatus.setSuccess(); this.testStatus.setSuccess();
if (re.data.length > 0) { if (re.data.length > 0) {

Loading…
Cancel
Save