Browse Source

Merge pull request #15 in DEC/decision-webui-dcm from ~ALAN/decision-webui-dcm:feature/10.0 to feature/10.0

* commit 'cb4e6c9ba050557758738be74354da054dd296e2':
  fix: 判断时加入other类型
  fix: 解决驱动不存在无法选择的问题
  fix: 删除无用的国际化
  fix: 无法识别的数据库类型则默认为other
  fix: 如果无法识别驱动 则提示一下
  fix: update
  fix: 兼容设计器,使用驱动来判断数据库类型
qufenxi
alan 5 years ago
parent
commit
2f8ecb5231
  1. 1
      private/i18n.ts
  2. 23
      src/modules/app.service.ts
  3. 15
      src/modules/constants/constant.ts
  4. 17
      src/modules/crud/crud.service.ts
  5. 6
      src/modules/pages/connection/connection_jdbc/connection_jdbc.ts
  6. 7
      src/modules/pages/connection/list/list.service.ts
  7. 24
      src/modules/pages/maintain/forms/components/form.jdbc.ts

1
private/i18n.ts

@ -22,7 +22,6 @@ export default {
'Dec-Dcm_Test_Connection': '测试连接',
'Dec-Dcm_Copy': '复制',
'Dec-Dcm_Edit': '编辑',
'Dec-Dcm_Save': '保存',
'Dec-Dcm_Yes': '是',
'Dec-Dcm_No': '否',
'Dec-Dcm_Search': '搜索',

23
src/modules/app.service.ts

@ -1,4 +1,4 @@
import { DATA_BASE_TYPES } from '@constants/constant';
import { DATA_BASE_TYPES, DATA_BASE_TYPES_OTHER } from '@constants/constant';
import { CONSTANT_PLUGIN_TYPES, CONSTANT_PLUGIN_SHOW, CONSTANT_PLUGIN_EDIT } from '@constants/plugin';
import { DatabaseType } from './app.typings';
export function getAllDatabaseTypes():DatabaseType[] {
@ -21,3 +21,24 @@ export function getPluginWidgetShow(plugin: string) {
export function getPluginWidgetEdit(plugin: string) {
return BI.Constants.getConstant(CONSTANT_PLUGIN_EDIT.replace('${databaseType}', plugin));
}
// 由于database可能为空,所以为了兼容平台和设计器,需要根据driver来判断数据库类型
export function getJdbcDatabaseType(database: string, driver: string): DatabaseType {
let databaseType = null;
if (database && DATA_BASE_TYPES.some(item => item.databaseType === database)) {
databaseType = DATA_BASE_TYPES.find(item => item.databaseType === database);
} else {
databaseType = (DATA_BASE_TYPES as DatabaseType[]).find(item => {
if (item.drivers) {
return item.drivers.includes(driver);
}
return item.driver === driver;
});
}
if (!databaseType) {
return DATA_BASE_TYPES_OTHER;
}
return databaseType;
}

15
src/modules/constants/constant.ts

@ -15,6 +15,19 @@ export const DATEBASE_FILTER_TYPE = {
BI.constant(CONSTANT_PLUGIN_TYPES, [
]);
export const DATA_BASE_TYPES_OTHER =
{
text: 'other',
databaseType: 'other',
driver: '',
url: '',
commonly: false,
internal: false,
type: 'jdbc',
hasSchema: false,
kerberos: false,
};
export const DATA_BASE_TYPES = [
{
text: 'ADS',
@ -383,6 +396,8 @@ export const DATA_BASE_TYPES = [
}),
];
export const CONNECT_CHARSET = [
{
text: '自动',

17
src/modules/crud/crud.service.ts

@ -2,6 +2,10 @@ import 'es6-promise/auto';
import axios, { AxiosResponse, AxiosError } from 'axios';
import { CrudReqOpts, CrudParams } from './crud.typings.d';
import { ReqPrefix } from '../constants/env';
const defaultHeaders = {
'Content-Type': 'application/json',
'X-Requested-With': 'XMLHttpRequest',
};
export function paramsSerializer(params: { [key: string]: any }) {
return Object.keys(params || {})
@ -44,6 +48,7 @@ export async function request(reqOptions: CrudReqOpts = {}) {
baseURL: ReqPrefix,
method: type,
headers: {
...defaultHeaders,
...headers,
Authorization: `Bearer ${getCookieByName('fine_auth_token')}`,
},
@ -71,9 +76,6 @@ export function requestGet(url: string, data?: any, params: CrudParams = {}) {
type: 'GET',
data,
params,
headers: {
'Content-Type': 'application/json',
},
});
}
@ -83,9 +85,6 @@ export function requestPost(url: string, data = {}, params: CrudParams = {}) {
type: 'POST',
data,
params,
headers: {
'Content-Type': 'application/json',
},
});
}
@ -94,9 +93,6 @@ export function requestDelete(url: string, data = {}) {
url,
type: 'DELETE',
data,
headers: {
'Content-Type': 'application/json',
},
});
}
@ -106,8 +102,5 @@ export function requestPut(url: string, data = {}, params: CrudParams = {}) {
type: 'PUT',
data,
params,
headers: {
'Content-Type': 'application/json',
},
});
}

6
src/modules/pages/connection/connection_jdbc/connection_jdbc.ts

@ -4,7 +4,7 @@ import { FormItemXtype } from '../components/form_item/form_item';
import { CollapseXtype, EVENT_CHANGE } from 'src/modules/components/collapse/collapse';
import { ConnectionJdbcModelXtype, ConnectionJdecModel } from './connection_jdbc.model';
import { ConnectionJDBC } from 'src/modules/crud/crud.typings';
import { getAllDatabaseTypes } from '../../../app.service';
import { getAllDatabaseTypes, getJdbcDatabaseType } from '../../../app.service';
export const ConnectionJdbcXtype = 'dec.dcm.connection_jdbc';
@shortcut(ConnectionJdbcXtype)
@store(ConnectionJdbcModelXtype)
@ -17,7 +17,7 @@ export class ConnectionJdbc extends BI.Widget {
render () {
const connectionData = this.model.connectionSelectedOne.connectionData as ConnectionJDBC;
const { driver, database, host, user, newCharsetName, schema, connectionPool, port, authType, principal, keyPath } = connectionData;
const databaseType = this.allDatabaseTypes.find(item => item.databaseType === database);
const databaseType = getJdbcDatabaseType(database, driver);
return {
type: Vertical,
@ -32,7 +32,7 @@ export class ConnectionJdbc extends BI.Widget {
{
type: FormItemXtype,
name: BI.i18nText('Dec-Dcm_Connection_Form_Database_Name'),
value: database,
value: databaseType.databaseType,
},
{
type: FormItemXtype,

7
src/modules/pages/connection/list/list.service.ts

@ -1,6 +1,7 @@
import { Connection, ConnectionJDBC, ConnectionJNDI, ConnectionPlugin } from '../../../crud/crud.typings';
import { connectionType } from '@constants/env';
import { getAllDatabaseTypes } from 'src/modules/app.service';
import { getAllDatabaseTypes, getJdbcDatabaseType } from 'src/modules/app.service';
import { DATA_BASE_TYPES_OTHER } from '@constants/constant';
export function getCreator(connection: Connection) {
switch (connection.connectionType) {
@ -16,7 +17,7 @@ export function getCreator(connection: Connection) {
export function getDatabaseType(connection: Connection) {
switch (connection.connectionType) {
case connectionType.JDBC:
return (connection.connectionData as ConnectionJDBC).database;
return getJdbcDatabaseType((connection.connectionData as ConnectionJDBC).database, (connection.connectionData as ConnectionJDBC).driver).databaseType;
case connectionType.JNDI:
return connectionType.JNDI;
default:
@ -31,6 +32,8 @@ export function hasRegistered(databaseType: string) {
return true;
case connectionType.JNDI:
return true;
case DATA_BASE_TYPES_OTHER.text:
return true;
default:
return allDatabaseTypes.some(item => item.databaseType === databaseType);
}

24
src/modules/pages/maintain/forms/components/form.jdbc.ts

@ -5,7 +5,7 @@ import { FormItemXtype } from '../../components/form_item/form_item';
import { Connection, ConnectionJDBC, ConnectionPoolJDBC } from 'src/modules/crud/crud.typings';
import { connectionType } from '@constants/env';
import { CONNECT_CHARSET } from '@constants/constant';
import { getAllDatabaseTypes } from '../../../../app.service';
import { getAllDatabaseTypes, getJdbcDatabaseType } from '../../../../app.service';
export const FormJdbcXtype = 'dec.dcm.maintain.form.jdbc';
@shortcut(FormJdbcXtype)
@ -56,7 +56,7 @@ export class FormJdbc extends BI.Widget {
const { driver, host, port, user, password, newCharsetName, schema, url, connectionPool, database, authType, principal, keyPath } = connectionData as ConnectionJDBC;
// minIdle 暂未使用
const { initialSize, maxActive, maxIdle, maxWait, validationQuery, testOnBorrow, testOnReturn, testWhileIdle, timeBetweenEvictionRunsMillis, numTestsPerEvictionRun, minEvictableIdleTimeMillis } = connectionPool as ConnectionPoolJDBC;
const databaseType = this.allDatabaseTypes.find(item => item.databaseType === database);
const databaseType = getJdbcDatabaseType(database, driver);
this.oldPassword = password;
return {
@ -100,7 +100,7 @@ export class FormJdbc extends BI.Widget {
allowBlank: true,
disabled: true,
watermark: BI.i18nText('Dec-Dcm_Connection_Form_Database_Name'),
value: database,
value: databaseType.databaseType,
ref: (_ref: any) => {
this.form.database = _ref;
},
@ -506,10 +506,9 @@ export class FormJdbc extends BI.Widget {
}
private getDrivers() {
const datebastType = (this.options.formData.connectionData as ConnectionJDBC).database;
const connectionType = this.allDatabaseTypes.find(item => item.databaseType === datebastType);
return connectionType.drivers ?
const connectionData = this.options.formData.connectionData as ConnectionJDBC;
const connectionType = getJdbcDatabaseType(connectionData.database, connectionData.driver);
const drivers = connectionType.drivers ?
connectionType.drivers.map(item => {
return {
text: item,
@ -520,6 +519,17 @@ export class FormJdbc extends BI.Widget {
text: connectionType.driver,
value: connectionType.driver,
}];
if (!drivers.some(item => item.text === connectionData.driver)) {
return [
{
text: connectionData.driver,
value: connectionData.driver,
},
];
}
return drivers;
}
private getBooleanItem() {

Loading…
Cancel
Save