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}`; + } }