Browse Source

fix: DEC-9958 在操作数据连接之前,判断数据连接是否可用。

qufenxi
alan 5 years ago
parent
commit
9f712cdcd9
  1. 23
      assets/scripts/dec.js
  2. 1
      i18n/zh_cn.properties
  3. 5
      index.html
  4. 1
      private/i18n.ts
  5. 2
      src/modules/constants/constant.ts
  6. 17
      src/modules/constants/env.ts
  7. 25
      src/modules/crud/decision.api.ts
  8. 13
      src/modules/pages/connection/connection.ts
  9. 24
      src/modules/pages/connection/list/list_item/list_item.model.ts
  10. 13
      src/modules/pages/connection/list/list_item/list_item.ts

23
assets/scripts/dec.js

@ -0,0 +1,23 @@
window.DecCst = {
ErrorCode: {
CONNECTION_DELETED: '21300035',
CONNECTION_UNDER_EDIT: '21300034',
},
Connect: {
ConnectionType: {
JDBC: 'jdbc',
JNDI: 'jndi',
},
EditStatusEvent: {
OPEN: 'getConnectionStatus',
SHUTDOWN: 'shutdownConnectionStatus',
}
}
};
window.Dec = {
fineServletURL: '/webroot/decision',
socket: {
connected: false,
},
}

1
i18n/zh_cn.properties

@ -105,6 +105,7 @@ Dec-Dcm_Socket_Unable_Connect= Socket未连接,可能存在多人同时编辑
Dec-Dcm_Connection_HW_DWS=华为云DWS Dec-Dcm_Connection_HW_DWS=华为云DWS
Dec-Dcm_Connection_Lack_Driver=未找到“{R1}”驱动。 Dec-Dcm_Connection_Lack_Driver=未找到“{R1}”驱动。
Dec-Dcm_Connection_Download_Driver=下载对应驱动 Dec-Dcm_Connection_Download_Driver=下载对应驱动
Dec-Dec_Connection_Deleted=该数据连接已被删除,无法进行操作
BI-Multi_Date_Quarter_End= 季度末 BI-Multi_Date_Quarter_End= 季度末
BI-Multi_Date_Month_Begin= 月初 BI-Multi_Date_Month_Begin= 月初

5
index.html

@ -22,16 +22,13 @@
href="./node_modules/fineui-materials/docs/materials.css" href="./node_modules/fineui-materials/docs/materials.css"
/> />
</head> </head>
<script>
var DecCst = null;
var Dec = null;
</script>
<body id="body"> <body id="body">
<div id="wrapper"></div> <div id="wrapper"></div>
<script src="./node_modules/fineui/dist/fineui.js"></script> <script src="./node_modules/fineui/dist/fineui.js"></script>
<script src="./node_modules/fineui/i18n/i18n.cn.js"></script> <script src="./node_modules/fineui/i18n/i18n.cn.js"></script>
<script src="./node_modules/fineui-materials/docs/materials.js"></script> <script src="./node_modules/fineui-materials/docs/materials.js"></script>
<script src="./assets/scripts/dec.js"></script>
<script src="./redis.js"></script> <script src="./redis.js"></script>
</body> </body>
</html> </html>

1
private/i18n.ts

@ -104,6 +104,7 @@ export default {
'Dec-Dcm_Connection_HW_DWS': '华为云DWS', 'Dec-Dcm_Connection_HW_DWS': '华为云DWS',
'Dec-Dcm_Connection_Lack_Driver': '未找到“{R1}”驱动。', 'Dec-Dcm_Connection_Lack_Driver': '未找到“{R1}”驱动。',
'Dec-Dcm_Connection_Download_Driver': '下载对应驱动', 'Dec-Dcm_Connection_Download_Driver': '下载对应驱动',
'Dec-Dec_Connection_Deleted': '该数据连接已被删除',
'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': '年月日',

2
src/modules/constants/constant.ts

@ -28,7 +28,7 @@ export const DATA_BASE_TYPES_OTHER =
hasSchema: true, hasSchema: true,
kerberos: false, kerberos: false,
}; };
export const DATA_BASE_DRIVER_LINK = DecCst ? [ export const DATA_BASE_DRIVER_LINK = DecCst && DecCst.Hyperlink ? [
{ {
databaseType: 'ads', databaseType: 'ads',
link: DecCst.Hyperlink.Database.ADS, link: DecCst.Hyperlink.Database.ADS,

17
src/modules/constants/env.ts

@ -1,14 +1,13 @@
const fineServletURL = Dec ? Dec.fineServletURL : '/webroot/decision'; const fineServletURL = Dec.fineServletURL;
export const ReqPrefix = `${fineServletURL}/v10/config/connection`; export const ReqPrefix = `${fineServletURL}/v10/config/connection`;
export const ImgPrefix = `${fineServletURL}/resources?path=/com/fr/web/resources/dist/images/2x/icon/database/`; export const ImgPrefix = `${fineServletURL}/resources?path=/com/fr/web/resources/dist/images/2x/icon/database/`;
export const PluginImgPrefix = `${fineServletURL}/resources?path=`; export const PluginImgPrefix = `${fineServletURL}/resources?path=`;
export const connectionType = DecCst ? DecCst.Connect.ConnectionType : { export const connectionType = DecCst.Connect.ConnectionType;
JDBC: 'jdbc',
JNDI: 'jndi',
};
export const editStatusEvent = DecCst ? DecCst.Connect.EditStatusEvent : { export const editStatusEvent = DecCst.Connect.EditStatusEvent;
OPEN: 'getConnectionStatus',
SHUTDOWN: 'shutdownConnectionStatus', export const errorCode: {
}; CONNECTION_DELETED: string;
CONNECTION_UNDER_EDIT: string;
} = DecCst.ErrorCode;

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

@ -1,7 +1,7 @@
import { Api } from './api'; import { Api } from './api';
import { Connection, TestRequest, ConnectionPoolType, SocketResult } from './crud.typings'; import { Connection, TestRequest, ConnectionPoolType, SocketResult } from './crud.typings';
import { requestGet, requestDelete, requestPost, requestPut } from './crud.service'; import { requestGet, requestDelete, requestPost, requestPut } from './crud.service';
import { editStatusEvent } from '@constants/env'; import { editStatusEvent, errorCode } from '@constants/env';
export class DecisionApi implements Api { export class DecisionApi implements Api {
isDec = true; isDec = true;
@ -49,7 +49,28 @@ export class DecisionApi implements Api {
} }
getConnectionStatus(name: string): Promise<SocketResult> { getConnectionStatus(name: string): Promise<SocketResult> {
return this.sendEditStatusEvent(name, editStatusEvent.OPEN); return this.sendEditStatusEvent(name, editStatusEvent.OPEN).then(re => {
if (re.errorCode) {
let errorMessage = '';
switch (re.errorCode) {
case errorCode.CONNECTION_DELETED:
errorMessage = 'Dec-Dec_Connection_Deleted';
break;
case errorCode.CONNECTION_UNDER_EDIT:
errorMessage = 'Dec-Dcm_Connection_Is_Using';
break;
default:
errorMessage = re.errorMsg;
break;
}
BI.Msg.toast(BI.i18nText(errorMessage, re.errorMsg), {
level: 'error',
});
throw re;
} else {
return re;
}
});
} }
shutdownConnectionStatus(name: string): Promise<SocketResult> { shutdownConnectionStatus(name: string): Promise<SocketResult> {

13
src/modules/pages/connection/connection.ts

@ -104,15 +104,10 @@ export class Connection extends BI.Widget {
}, },
handler: () => { handler: () => {
this.store.getConnectionStatus().then(re => { this.store.getConnectionStatus().then(re => {
if (re.data && re.data === 'success') { this.store.setPageIndex(PAGE_INDEX.MAINTAIN);
this.store.setPageIndex(PAGE_INDEX.MAINTAIN); this.store.setDatebaseTypeSelected('');
this.store.setDatebaseTypeSelected(''); })
} else { .catch(() => {});
BI.Msg.toast(BI.i18nText('Dec-Dcm_Connection_Is_Using', re.errorMsg), {
level: 'error',
});
}
});
}, },
}, },
], ],

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

@ -31,14 +31,11 @@ export class ListItemModel extends Model<{
}, },
deleteConnection: (name: string) => { deleteConnection: (name: string) => {
api.getConnectionStatus(name).then(re => { api.getConnectionStatus(name).then(re => {
if (re.data && re.data === 'success') { this.removeConnection(name);
this.removeConnection(name); })
} else { .catch(() => {
BI.Msg.toast(BI.i18nText('Dec-Dcm_Connection_Is_Using', re.errorMsg), {
level: 'error', });
});
}
});
}, },
setPageIndex: (pageIndex: string) => { setPageIndex: (pageIndex: string) => {
this.model.pageIndex = pageIndex; this.model.pageIndex = pageIndex;
@ -52,14 +49,9 @@ export class ListItemModel extends Model<{
setIsEdit: (isEdit: boolean, name: string) => { setIsEdit: (isEdit: boolean, name: string) => {
if (isEdit) { if (isEdit) {
api.getConnectionStatus(name).then(re => { api.getConnectionStatus(name).then(re => {
if (re.data && re.data === 'success') { this.model.isEdit = true;
this.model.isEdit = true; })
} else { .catch(() => {});
BI.Msg.toast(BI.i18nText('Dec-Dcm_Connection_Is_Using', re.errorMsg), {
level: 'error',
});
}
});
} else { } else {
api.shutdownConnectionStatus(name); api.shutdownConnectionStatus(name);
this.model.isEdit = false; this.model.isEdit = false;

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

@ -243,15 +243,10 @@ export class ListItem extends BI.BasicButton {
edit: () => { edit: () => {
this.store.setConnectionSelected(name); this.store.setConnectionSelected(name);
this.store.getConnectionStatus().then(re => { this.store.getConnectionStatus().then(re => {
if (re.data && re.data === 'success') { this.store.setPageIndex(PAGE_INDEX.MAINTAIN);
this.store.setPageIndex(PAGE_INDEX.MAINTAIN); this.store.setDatebaseTypeSelected('');
this.store.setDatebaseTypeSelected(''); })
} else { .catch(() => {});
BI.Msg.toast(BI.i18nText('Dec-Dcm_Connection_Is_Using', re.errorMsg), {
level: 'error',
});
}
});
}, },
changeName: () => { changeName: () => {
this.store.setIsEdit(true, name); this.store.setIsEdit(true, name);

Loading…
Cancel
Save