From 9f712cdcd96ed70174c4499dbe7c21ac30c52f8a Mon Sep 17 00:00:00 2001 From: alan Date: Tue, 24 Sep 2019 13:56:42 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20DEC-9958=20=E5=9C=A8=E6=93=8D=E4=BD=9C?= =?UTF-8?q?=E6=95=B0=E6=8D=AE=E8=BF=9E=E6=8E=A5=E4=B9=8B=E5=89=8D=EF=BC=8C?= =?UTF-8?q?=E5=88=A4=E6=96=AD=E6=95=B0=E6=8D=AE=E8=BF=9E=E6=8E=A5=E6=98=AF?= =?UTF-8?q?=E5=90=A6=E5=8F=AF=E7=94=A8=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- assets/scripts/dec.js | 23 +++++++++++++++++ i18n/zh_cn.properties | 1 + index.html | 5 +--- private/i18n.ts | 1 + src/modules/constants/constant.ts | 2 +- src/modules/constants/env.ts | 17 ++++++------- src/modules/crud/decision.api.ts | 25 +++++++++++++++++-- src/modules/pages/connection/connection.ts | 13 +++------- .../list/list_item/list_item.model.ts | 24 ++++++------------ .../connection/list/list_item/list_item.ts | 13 +++------- 10 files changed, 74 insertions(+), 50 deletions(-) create mode 100644 assets/scripts/dec.js diff --git a/assets/scripts/dec.js b/assets/scripts/dec.js new file mode 100644 index 0000000..e2d12ab --- /dev/null +++ b/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, + }, +} \ No newline at end of file diff --git a/i18n/zh_cn.properties b/i18n/zh_cn.properties index d889fad..fba0b19 100644 --- a/i18n/zh_cn.properties +++ b/i18n/zh_cn.properties @@ -105,6 +105,7 @@ Dec-Dcm_Socket_Unable_Connect= Socket未连接,可能存在多人同时编辑 Dec-Dcm_Connection_HW_DWS=华为云DWS Dec-Dcm_Connection_Lack_Driver=未找到“{R1}”驱动。 Dec-Dcm_Connection_Download_Driver=下载对应驱动 +Dec-Dec_Connection_Deleted=该数据连接已被删除,无法进行操作 BI-Multi_Date_Quarter_End= 季度末 BI-Multi_Date_Month_Begin= 月初 diff --git a/index.html b/index.html index 1bd2a5e..6bac9ec 100644 --- a/index.html +++ b/index.html @@ -22,16 +22,13 @@ href="./node_modules/fineui-materials/docs/materials.css" /> -
+ diff --git a/private/i18n.ts b/private/i18n.ts index 9813821..314ec7d 100644 --- a/private/i18n.ts +++ b/private/i18n.ts @@ -104,6 +104,7 @@ export default { 'Dec-Dcm_Connection_HW_DWS': '华为云DWS', 'Dec-Dcm_Connection_Lack_Driver': '未找到“{R1}”驱动。', 'Dec-Dcm_Connection_Download_Driver': '下载对应驱动', + 'Dec-Dec_Connection_Deleted': '该数据连接已被删除', 'BI-Multi_Date_Quarter_End': '季度末', 'BI-Multi_Date_Month_Begin': '月初', 'BI-Multi_Date_YMD': '年月日', diff --git a/src/modules/constants/constant.ts b/src/modules/constants/constant.ts index 993a0df..ee008d3 100644 --- a/src/modules/constants/constant.ts +++ b/src/modules/constants/constant.ts @@ -28,7 +28,7 @@ export const DATA_BASE_TYPES_OTHER = hasSchema: true, kerberos: false, }; -export const DATA_BASE_DRIVER_LINK = DecCst ? [ +export const DATA_BASE_DRIVER_LINK = DecCst && DecCst.Hyperlink ? [ { databaseType: 'ads', link: DecCst.Hyperlink.Database.ADS, diff --git a/src/modules/constants/env.ts b/src/modules/constants/env.ts index 6045280..dbf063b 100644 --- a/src/modules/constants/env.ts +++ b/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 ImgPrefix = `${fineServletURL}/resources?path=/com/fr/web/resources/dist/images/2x/icon/database/`; export const PluginImgPrefix = `${fineServletURL}/resources?path=`; -export const connectionType = DecCst ? DecCst.Connect.ConnectionType : { - JDBC: 'jdbc', - JNDI: 'jndi', -}; +export const connectionType = DecCst.Connect.ConnectionType; -export const editStatusEvent = DecCst ? DecCst.Connect.EditStatusEvent : { - OPEN: 'getConnectionStatus', - SHUTDOWN: 'shutdownConnectionStatus', -}; +export const editStatusEvent = DecCst.Connect.EditStatusEvent; + +export const errorCode: { + CONNECTION_DELETED: string; + CONNECTION_UNDER_EDIT: string; +} = DecCst.ErrorCode; diff --git a/src/modules/crud/decision.api.ts b/src/modules/crud/decision.api.ts index 49f0f64..be838e9 100644 --- a/src/modules/crud/decision.api.ts +++ b/src/modules/crud/decision.api.ts @@ -1,7 +1,7 @@ import { Api } from './api'; import { Connection, TestRequest, ConnectionPoolType, SocketResult } from './crud.typings'; import { requestGet, requestDelete, requestPost, requestPut } from './crud.service'; -import { editStatusEvent } from '@constants/env'; +import { editStatusEvent, errorCode } from '@constants/env'; export class DecisionApi implements Api { isDec = true; @@ -49,7 +49,28 @@ export class DecisionApi implements Api { } getConnectionStatus(name: string): Promise { - 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 { diff --git a/src/modules/pages/connection/connection.ts b/src/modules/pages/connection/connection.ts index 338126c..9ea3055 100644 --- a/src/modules/pages/connection/connection.ts +++ b/src/modules/pages/connection/connection.ts @@ -104,15 +104,10 @@ export class Connection extends BI.Widget { }, handler: () => { this.store.getConnectionStatus().then(re => { - if (re.data && re.data === 'success') { - this.store.setPageIndex(PAGE_INDEX.MAINTAIN); - this.store.setDatebaseTypeSelected(''); - } else { - BI.Msg.toast(BI.i18nText('Dec-Dcm_Connection_Is_Using', re.errorMsg), { - level: 'error', - }); - } - }); + this.store.setPageIndex(PAGE_INDEX.MAINTAIN); + this.store.setDatebaseTypeSelected(''); + }) + .catch(() => {}); }, }, ], diff --git a/src/modules/pages/connection/list/list_item/list_item.model.ts b/src/modules/pages/connection/list/list_item/list_item.model.ts index 28a5e84..bba0b94 100644 --- a/src/modules/pages/connection/list/list_item/list_item.model.ts +++ b/src/modules/pages/connection/list/list_item/list_item.model.ts @@ -31,14 +31,11 @@ export class ListItemModel extends Model<{ }, deleteConnection: (name: string) => { api.getConnectionStatus(name).then(re => { - if (re.data && re.data === 'success') { - this.removeConnection(name); - } else { - BI.Msg.toast(BI.i18nText('Dec-Dcm_Connection_Is_Using', re.errorMsg), { - level: 'error', - }); - } - }); + this.removeConnection(name); + }) + .catch(() => { + + }); }, setPageIndex: (pageIndex: string) => { this.model.pageIndex = pageIndex; @@ -52,14 +49,9 @@ export class ListItemModel extends Model<{ setIsEdit: (isEdit: boolean, name: string) => { if (isEdit) { api.getConnectionStatus(name).then(re => { - if (re.data && re.data === 'success') { - this.model.isEdit = true; - } else { - BI.Msg.toast(BI.i18nText('Dec-Dcm_Connection_Is_Using', re.errorMsg), { - level: 'error', - }); - } - }); + this.model.isEdit = true; + }) + .catch(() => {}); } else { api.shutdownConnectionStatus(name); this.model.isEdit = false; diff --git a/src/modules/pages/connection/list/list_item/list_item.ts b/src/modules/pages/connection/list/list_item/list_item.ts index b2b3378..55b1fbd 100644 --- a/src/modules/pages/connection/list/list_item/list_item.ts +++ b/src/modules/pages/connection/list/list_item/list_item.ts @@ -243,15 +243,10 @@ export class ListItem extends BI.BasicButton { edit: () => { this.store.setConnectionSelected(name); this.store.getConnectionStatus().then(re => { - if (re.data && re.data === 'success') { - this.store.setPageIndex(PAGE_INDEX.MAINTAIN); - this.store.setDatebaseTypeSelected(''); - } else { - BI.Msg.toast(BI.i18nText('Dec-Dcm_Connection_Is_Using', re.errorMsg), { - level: 'error', - }); - } - }); + this.store.setPageIndex(PAGE_INDEX.MAINTAIN); + this.store.setDatebaseTypeSelected(''); + }) + .catch(() => {}); }, changeName: () => { this.store.setIsEdit(true, name);