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..daa9e4d 100644 --- a/src/modules/crud/api.ts +++ b/src/modules/crud/api.ts @@ -93,4 +93,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); + } }