From 06835d70a5d5d023cc532b4ab3dfd2150f5799da Mon Sep 17 00:00:00 2001 From: "Austin.Duan" Date: Tue, 7 Feb 2023 10:24:22 +0800 Subject: [PATCH 1/2] =?UTF-8?q?REPORT-89173=20fix:=20JNDI=E5=85=A5?= =?UTF-8?q?=E5=8F=A3=E5=B1=8F=E8=94=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/modules/app.service.ts | 18 +++++++-------- src/modules/crud/api.ts | 10 ++++----- src/modules/crud/decision.api.ts | 7 +++++- src/modules/crud/design.api.ts | 4 ++++ src/modules/pages/database/database.model.ts | 23 ++++++++++++++++---- src/modules/pages/database/database.ts | 13 ++++++++++- 6 files changed, 55 insertions(+), 20 deletions(-) diff --git a/src/modules/app.service.ts b/src/modules/app.service.ts index e35475f..7b0983f 100644 --- a/src/modules/app.service.ts +++ b/src/modules/app.service.ts @@ -1,7 +1,7 @@ import { DATA_BASE_TYPES, DATA_BASE_TYPES_OTHER, DESIGN_DRIVER_TYPE, OTHER_JDBC } from '@constants/constant'; import { DatabaseType } from './app.typings'; import { Connection } from './crud/crud.typings'; -export function getAllDatabaseTypes():DatabaseType[] { +export function getAllDatabaseTypes(): DatabaseType[] { return [ ...DATA_BASE_TYPES, ...BI.Providers.getProvider('dec.connection.provider.datebase').customDatabaseType.map(item => { @@ -45,11 +45,11 @@ export function getJdbcDatabaseType(database: string, driver: string): DatabaseT if (!databaseType) { return DATA_BASE_TYPES_OTHER; } - + return databaseType; } -export function resolveUrlInfo (url: string, database?: string) { +export function resolveUrlInfo(url: string, database?: string) { if (BI.isNull(url)) return {}; return BI.Providers.getProvider('dec.connection.provider.datebase').getJdbcResolveByType(database)(url) || { @@ -70,11 +70,11 @@ export function splitUrl(host: string, port: string, database: string, baseUrl: // https://work.fineres.com/browse/REPORT-72078 if (baseUrl.startsWith('jdbc:informix-sqli')) { return baseUrl.replace('hostname', host) - .replace(':port', port ? `:${port}` : '') - .replace('database', database) - .replace(':INFORMIXSERVER={server}',''); + .replace(':port', port ? `:${port}` : '') + .replace('database', database) + .replace(':INFORMIXSERVER={server}', ''); } - + return baseUrl.replace('hostname', host).replace(':port', port ? `:${port}` : '') .replace('database', database) .replace('dbname', database); @@ -85,13 +85,13 @@ export function connectionCanEdit(connection: Connection) { // privilegeType === 4 代表编辑权限,privilegeValue === 2 代表有权限 return connection.privilegeDetailBeanList.some(item => item.privilegeType === 4 && item.privilegeValue === 2); } - + return true; } export function getTextByDatabaseType(databaseType: string) { const database = getAllDatabaseTypes().find(item => item.databaseType === databaseType); - + return database ? database.text : ''; } diff --git a/src/modules/crud/api.ts b/src/modules/crud/api.ts index 12d4f0c..32fa735 100644 --- a/src/modules/crud/api.ts +++ b/src/modules/crud/api.ts @@ -52,11 +52,6 @@ export interface Api { */ getConnectionPool(name: string): Promise<{ data?: ConnectionPoolType }>; - /** - * 获取自定义驱动列表 - */ - getSimpleDriverList(): Promise<{ data?: any[] }>; - /** * 获取连接状态 * @param name @@ -93,4 +88,9 @@ export interface Api { * 获取外链 */ getHyperlink(name: string): string; + + /** + * 获取JNDI数据库类型可用状态 + */ + getJNDIDatabaseStatus(): Promise<{ data?: boolean }>; } diff --git a/src/modules/crud/decision.api.ts b/src/modules/crud/decision.api.ts index 5249552..782779d 100644 --- a/src/modules/crud/decision.api.ts +++ b/src/modules/crud/decision.api.ts @@ -129,11 +129,16 @@ export class DecisionApi implements Api { getTimeOut(): Promise<{ data?: any }> { return requestGet('kdc/timeout', {}); } - + putTimeOut(value: number) { return requestPut(`kdc/timeout?timeout=${value}`, {}) } + // 获取当前lic是否可以使用JNDI数据库类型 + getJNDIDatabaseStatus(): Promise<{ data?: boolean }> { + return requestGet('databasetype/limit', {}); + } + private sendEditStatusEvent(name: string, type: string): Promise { return new Promise(resolve => { if (Dec && Dec.socket.connected) { diff --git a/src/modules/crud/design.api.ts b/src/modules/crud/design.api.ts index f010918..643ad8e 100644 --- a/src/modules/crud/design.api.ts +++ b/src/modules/crud/design.api.ts @@ -88,4 +88,8 @@ export class DesignApi implements Api { // 设计器获取超链 return ''; } + + getJNDIDatabaseStatus() { + return Promise.resolve({ data: true }); + } } diff --git a/src/modules/pages/database/database.model.ts b/src/modules/pages/database/database.model.ts index 44109ea..0de45eb 100644 --- a/src/modules/pages/database/database.model.ts +++ b/src/modules/pages/database/database.model.ts @@ -2,10 +2,12 @@ import { model, Model } from '@core/core'; import { AppModel } from 'src/modules/app.model'; import { getAllDatabaseTypes } from '../../app.service'; import { DatabaseType } from '../../app.typings'; +import { connectionType } from '@constants/env'; +import { OTHER_JDBC } from '@constants/constant'; @model() export class DatebaseModel extends Model<{ - types : { + types: { filter: AppModel['TYPE']['filter']; datebaseTypeSelected: AppModel['TYPE']['datebaseTypeSelected']; }, @@ -20,20 +22,30 @@ export class DatebaseModel extends Model<{ isInternal: true, isPlugin: true, datebaseTypes: getAllDatabaseTypes().filter(item => item.commonly), + isJNDILimit: false, }; } + + computed = { + otherDatabases: () => { + return this.model.isJNDILimit + ? [OTHER_JDBC] + : [OTHER_JDBC, connectionType.JNDI]; + } + } + actions = { - setSearch:(search: string) => { + setSearch: (search: string) => { this.model.search = search; }, - setFilter:(filter: string) => { + setFilter: (filter: string) => { this.model.filter = filter; }, setDatebaseTypes: (datebaseTypes: DatabaseType[]) => { this.model.datebaseTypes = datebaseTypes; this.model.datebaseTypeSelected = ''; }, - setInternal:(isInternal: boolean) => { + setInternal: (isInternal: boolean) => { this.model.isInternal = isInternal; }, setPlugin: (isPlugin: boolean) => { @@ -42,5 +54,8 @@ export class DatebaseModel extends Model<{ setDatebaseTypeSelected(datebaseType: string) { this.model.datebaseTypeSelected = datebaseType; }, + setJNDILimit: (v: boolean) => { + this.model.isJNDILimit = v; + }, } } diff --git a/src/modules/pages/database/database.ts b/src/modules/pages/database/database.ts index 93b32ae..7779006 100644 --- a/src/modules/pages/database/database.ts +++ b/src/modules/pages/database/database.ts @@ -6,6 +6,10 @@ import { connectionType } from '@constants/env'; import { DatebaseType } from './database_type/database_type'; import { getAllDatabaseTypes } from '../../app.service'; import { ButtonGroup, MultiSelectItem, SearchEditor } from '@fui/core'; +import { ApiFactory } from 'src/modules/crud/apiFactory'; + +const api = new ApiFactory().create(); + @shortcut() @store(DatebaseModel) export class Datebase extends BI.Widget { @@ -65,6 +69,7 @@ export class Datebase extends BI.Widget { mounted() { this.store.setFilter(DATEBASE_FILTER_TYPE.COMMONLY); this.store.setDatebaseTypeSelected(''); + this.getDatabaseTypeLimit(); } render() { @@ -250,11 +255,17 @@ export class Datebase extends BI.Widget { this.store.setDatebaseTypes(this.allDatabaseTypes.filter(item => item.commonly)); break; case DATEBASE_FILTER_TYPE.OTHER: - this.store.setDatebaseTypes(this.allDatabaseTypes.filter(item => item.type === connectionType.JNDI || item.type === OTHER_JDBC)); + this.store.setDatebaseTypes(this.allDatabaseTypes.filter(item => this.model.otherDatabases.includes(item.type))); break; default: this.store.setDatebaseTypes(this.allDatabaseTypes.filter(item => item.type !== connectionType.JNDI && item.type !== OTHER_JDBC)); break; } } + + // 获取JNDI + private async getDatabaseTypeLimit() { + const result = await api.getJNDIDatabaseStatus(); + this.store.setJNDILimit(result); + } } From 49779bdcbd5e26f106848b9e968e6fb3628c8f48 Mon Sep 17 00:00:00 2001 From: "Austin.Duan" Date: Tue, 7 Feb 2023 10:31:35 +0800 Subject: [PATCH 2/2] =?UTF-8?q?=E6=97=A0JIRA=E4=BB=BB=E5=8A=A1=EF=BC=8C?= =?UTF-8?q?=E5=A4=84=E7=90=86=E4=B8=8B=E7=B1=BB=E5=9E=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/modules/crud/api.ts | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/modules/crud/api.ts b/src/modules/crud/api.ts index 32fa735..daa9e4d 100644 --- a/src/modules/crud/api.ts +++ b/src/modules/crud/api.ts @@ -52,6 +52,11 @@ export interface Api { */ getConnectionPool(name: string): Promise<{ data?: ConnectionPoolType }>; + /** + * 获取自定义驱动列表 + */ + getSimpleDriverList(): Promise<{ data?: any[] }>; + /** * 获取连接状态 * @param name