From 7162af5fb2b4524398deb019816bc3f00a54bbd2 Mon Sep 17 00:00:00 2001 From: alan Date: Fri, 30 Aug 2019 15:19:17 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E6=97=A0jira=E4=BB=BB=E5=8A=A1=20?= =?UTF-8?q?=E9=87=8D=E5=91=BD=E5=90=8D=E7=9A=84=E6=97=B6=E5=80=99=E4=B9=9F?= =?UTF-8?q?=E5=8F=91=E9=80=81socket=EF=BC=8C=E4=BF=AE=E6=94=B9=E6=8F=92?= =?UTF-8?q?=E4=BB=B6=E5=9B=BE=E7=89=87=E5=9C=B0=E5=9D=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- redis.js | 2 +- src/modules/constants/env.ts | 1 + .../list/list_item/list_item.model.ts | 29 ++++++++++++------- .../database/database_type/database_type.ts | 12 ++++++-- 4 files changed, 31 insertions(+), 13 deletions(-) diff --git a/redis.js b/redis.js index 18c7357..f2ed7c6 100644 --- a/redis.js +++ b/redis.js @@ -6,7 +6,7 @@ BI.DOM.ready(() => { BI.config(ConstantRedisType, datas => [...datas, { text: 'Redis', databaseType: 'Redis', - iconUrl: 'http://alan-picpack.oss-cn-hangzhou.aliyuncs.com/1567134942861890', + iconUrl: 'com/fr/plugin/db/redis/images/redis.png', }]); const RedisShowName = 'dec.dcm.connection.plugin.redis.show'; diff --git a/src/modules/constants/env.ts b/src/modules/constants/env.ts index 71785e6..6045280 100644 --- a/src/modules/constants/env.ts +++ b/src/modules/constants/env.ts @@ -1,6 +1,7 @@ const fineServletURL = Dec ? Dec.fineServletURL : '/webroot/decision'; 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', 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 0058840..96b0f53 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 @@ -50,19 +50,28 @@ export class ListItemModel extends Model<{ setDatebaseTypeSelected(name: string) { this.model.datebaseTypeSelected = name; }, - setIsEdit(isEdit: boolean) { - this.model.isEdit = isEdit; + 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', + }); + } + }); + } else { + api.shutdownConnectionStatus(name); + this.model.isEdit = false; + } }, changeName(oldName: string, newName: string) { - const connections = this.model.connections.map(item => { - return { - ...item, - connectionName: item.connectionName === oldName ? newName : item.connectionName, - connectionId: oldName, - }; - }); + const connection = this.model.connections.find(item => item.connectionName === oldName); + connection.connectionId = oldName; + connection.connectionName = newName; - return api.updateConnection(connections); + return api.updateConnection(connection); }, setIsCopy(isCopy: boolean) { this.model.isCopy = isCopy; diff --git a/src/modules/pages/database/database_type/database_type.ts b/src/modules/pages/database/database_type/database_type.ts index 422334c..f573495 100644 --- a/src/modules/pages/database/database_type/database_type.ts +++ b/src/modules/pages/database/database_type/database_type.ts @@ -1,7 +1,7 @@ import { shortcut, store } from '@core/core'; import { Vtape, Label, Absolute, Img } from 'ui'; import { DatebaseTypeModel, DatebaseTypeModelXtype } from './database_type.model'; -import { ImgPrefix } from '@constants/env'; +import { ImgPrefix, PluginImgPrefix } from '@constants/env'; import './database_type.less'; export const DatebaseTypeXtype = 'dec.dcm.datebase.type'; @@ -38,7 +38,7 @@ export class DatebaseType extends BI.BasicButton { { el: { type: Img, - src: iconUrl ? iconUrl : `${ImgPrefix}${databaseType}.jpg`, + src: iconUrl ? this.getIconUrl(iconUrl) : `${ImgPrefix}${databaseType}.jpg`, ref: (_ref: any) => { this.img = _ref; }, @@ -79,4 +79,12 @@ export class DatebaseType extends BI.BasicButton { this.img.setSrc(`${ImgPrefix}default.jpg`); }; } + + private getIconUrl(url: string) { + if (url.startsWith('/')) { + return `${PluginImgPrefix}${url}`; + } + + return `${PluginImgPrefix}/${url}`; + } }