alan
6 years ago
22 changed files with 371 additions and 13 deletions
@ -0,0 +1,26 @@
|
||||
import {WidgetType, Vertical} from '@ui'; |
||||
import leftModel from './left.model'; |
||||
import {LinkType} from '@ui/type'; |
||||
import {getLinks} from './left.service'; |
||||
const className = 'fr.component.linkset.left'; |
||||
let leftContent: any = null; |
||||
const Widget: WidgetType = { |
||||
_store() { |
||||
return BI.Models.getModel(leftModel); |
||||
}, |
||||
watch:{ |
||||
linkList(linkList: LinkType[]) { |
||||
leftContent.populate(BI.createItems(getLinks(linkList))); |
||||
}, |
||||
}, |
||||
render() { |
||||
return { |
||||
type: Vertical, |
||||
ref(_ref: any) { |
||||
leftContent = _ref; |
||||
}, |
||||
}; |
||||
}, |
||||
}; |
||||
BI.shortcut(className, BI.inherit(BI.Widget, Widget)); |
||||
export default className; |
@ -0,0 +1,8 @@
|
||||
const className = 'fr.model.linkSet.left'; |
||||
const Model = BI.inherit(Fix.Model, { |
||||
context: ['linkList'], |
||||
actions: { |
||||
}, |
||||
}); |
||||
BI.model(className, Model); |
||||
export default className; |
@ -0,0 +1,17 @@
|
||||
import {LinkType} from '@ui/type'; |
||||
import LeftItem from './left_item/left.item.component'; |
||||
|
||||
export const getLinks = (linkList: LinkType[]): any => { |
||||
const links: any[] = []; |
||||
linkList.forEach((item: LinkType) => { |
||||
links.push({ |
||||
type: LeftItem, |
||||
extraCls: item.isSelected ? 'left-item-selected' : '', |
||||
title: item.connectionName, |
||||
id: item.connectionId, |
||||
creator: item.creator, |
||||
}); |
||||
}); |
||||
|
||||
return links; |
||||
}; |
@ -0,0 +1,81 @@
|
||||
import {WidgetType, Left, Label, Icon} from '@ui'; |
||||
import LeftItemModel from './left.item.model'; |
||||
const className = 'fr.component.linkSet.left.item'; |
||||
const Widget: WidgetType = { |
||||
props: { |
||||
title:'', |
||||
id:'', |
||||
creator: '', |
||||
}, |
||||
_store() { |
||||
return BI.Models.getModel(LeftItemModel); |
||||
}, |
||||
render() { |
||||
const {title, extraCls} = this.options; |
||||
|
||||
return { |
||||
type: Left, |
||||
cls: 'left-item', |
||||
extraCls, |
||||
items: [ |
||||
{ |
||||
type: Icon, |
||||
cls: 'link-font', |
||||
height: 24, |
||||
width: 26, |
||||
text: '连接', |
||||
title, |
||||
}, |
||||
{ |
||||
type: Label, |
||||
textAlign: 'left', |
||||
text: title, |
||||
title, |
||||
}, |
||||
{ |
||||
type: Left, |
||||
cls: 'icons', |
||||
items: [ |
||||
{ |
||||
type: Icon, |
||||
cls: 'link-text-font', |
||||
height: 24, |
||||
width: 26, |
||||
title: '测试连接', |
||||
}, |
||||
{ |
||||
type: Icon, |
||||
cls: 'copy-font', |
||||
height: 24, |
||||
width: 26, |
||||
title: '复制', |
||||
}, |
||||
{ |
||||
type: Icon, |
||||
cls: 'info-font', |
||||
height: 24, |
||||
width: 26, |
||||
title: '提示', |
||||
}, |
||||
{ |
||||
type: Icon, |
||||
cls: 'delete-font', |
||||
height: 24, |
||||
width: 26, |
||||
title: '删除', |
||||
}, |
||||
], |
||||
}, |
||||
|
||||
], |
||||
}; |
||||
}, |
||||
mounted() { |
||||
const {title} = this.options; |
||||
this.element.on('click', () => { |
||||
this.store.setLinkSelected(title); |
||||
}); |
||||
}, |
||||
}; |
||||
BI.shortcut(className, BI.inherit(BI.Widget, Widget)); |
||||
export default className; |
@ -0,0 +1,22 @@
|
||||
import {LinkType} from '@ui/type'; |
||||
|
||||
const className = 'fr.model.linkSet.left.item'; |
||||
const Model = BI.inherit(Fix.Model, { |
||||
context: ['linkList', 'linkSelected'], |
||||
actions: { |
||||
setLinkSelected(name: string) { |
||||
this.model.linkList.forEach((item: LinkType) => { |
||||
item.isSelected = item.connectionName === name; |
||||
if (item.connectionName === name) { |
||||
this.model.linkSelected = { |
||||
...item, |
||||
idEdit: false, |
||||
}; |
||||
} |
||||
}); |
||||
this.model.linkList = [...this.model.linkList]; |
||||
}, |
||||
}, |
||||
}); |
||||
BI.model(className, Model); |
||||
export default className; |
@ -0,0 +1,86 @@
|
||||
import {LinkType} from '@ui/type'; |
||||
|
||||
export const databaseTyle = [ |
||||
{ |
||||
text:'APACHE KYLIN', |
||||
databaseType: 'apache-kylin', |
||||
driver: 'org.apache.kylin.jdbc.Driver', |
||||
url: 'jdbc:kylin://<hostname>:<port>/<kylin_project_name>', |
||||
}, |
||||
{ |
||||
text:'DERBY', |
||||
databaseType: 'derby', |
||||
driver: 'org.apache.derby.jdbc.ClientDriver', |
||||
url: 'jdbc:derby://localhost:1527/', |
||||
}, |
||||
{ |
||||
text:'HP Vertica', |
||||
databaseType: 'hp-vertica', |
||||
driver: 'com.vertica.jdbc.Driver', |
||||
url: 'jdbc:vertica://ip:port/databaseName', |
||||
}, |
||||
{ |
||||
text:'IBM DB2', |
||||
databaseType: 'ibm-db2', |
||||
driver: 'com.ibm.db2.jcc.DB2Driver', |
||||
url: 'jdbc:db2://hostname:port/dbname', |
||||
}, |
||||
{ |
||||
text:'INFORMIX', |
||||
databaseType: 'informix', |
||||
driver: 'com.informix.jdbc.IfxDriver', |
||||
url: 'jdbc:informix-sqli://{host}:{port}/{database}:INFORMIXSERVER={server}', |
||||
}, |
||||
{ |
||||
text:'Microsoft SQL Server', |
||||
databaseType: 'sql-server', |
||||
driver: 'com.microsoft.sqlserver.jdbc.SQLServerDriver', |
||||
url: 'jdbc:sqlserver://localhost:1433;databaseName=', |
||||
}, |
||||
{ |
||||
text:'Oracle', |
||||
databaseType: 'oracle', |
||||
driver: 'oracle.jdbc.driver.OracleDriver', |
||||
url: 'jdbc:oracle:thin:@localhost:1521:databaseName', |
||||
}, |
||||
{ |
||||
text:'Privotal Greenplum Database', |
||||
databaseType: 'pivotal-greenplum-database', |
||||
driver: 'org.postgresql.Driver', |
||||
url: 'jdbc:postgresql://hostname:port/dbname', |
||||
}, |
||||
{ |
||||
text:'Postgresql', |
||||
databaseType: 'postgresql', |
||||
driver: 'org.postgresql.Driver', |
||||
url: 'jdbc:postgresql://hostname:port/dbname', |
||||
}, |
||||
{ |
||||
text:'GaussDB 200', |
||||
databaseType: 'hw-libr-a', |
||||
driver: 'org.postgresql.Driver', |
||||
url: 'jdbc:postgresql://hostname:port/dbname', |
||||
}, |
||||
{ |
||||
text:'MySQL', |
||||
databaseType: 'mysql', |
||||
driver: 'com.mysql.jdbc.Driver', |
||||
url: 'jdbc:mysql://localhost/dbname', |
||||
}, |
||||
]; |
||||
|
||||
export const getCnnectionName = (links: LinkType[]): string => { |
||||
let nameIndex = 0; |
||||
links.forEach(link => { |
||||
link.isSelected = false; |
||||
if (link.connectionName.startsWith('数据连接')) { |
||||
const name = link.connectionName.replace('数据连接', '0'); |
||||
const index = parseInt(name, 10) + 1; |
||||
if (index > nameIndex) { |
||||
nameIndex = index; |
||||
} |
||||
} |
||||
}); |
||||
|
||||
return `数据连接${nameIndex > 0 ? nameIndex : ''}`; |
||||
}; |
File diff suppressed because one or more lines are too long
@ -0,0 +1,12 @@
|
||||
import {linkList} from './curd.mock'; |
||||
const Dec: any = (window as any).parent.Dec; |
||||
|
||||
export function fetchLinkList(callback: Function): void { |
||||
if (Dec) { |
||||
Dec.reqGet('/v10/config/connection/list', 'getInstalledPlugins', (res: any) => { |
||||
callback(res.data); |
||||
}); |
||||
} else { |
||||
callback(linkList.data); |
||||
} |
||||
} |
@ -0,0 +1 @@
|
||||
export const linkList = {"data":[{"connectionId":"8c1c52f1-3d0a-429e-b35f-ee1e085a8b72","database":"","connectionName":"FRDemo","driver":"org.sqlite.JDBC","url":"jdbc:sqlite://${ENV_HOME}/../help/FRDemo.db","user":"","password":"","queryType":"","newCharsetName":'null',"originalCharsetName":'null',"validationQuery":"","schema":"","testOnBorrow":false,"maxActive":50,"options":'null',"port":0,"authType":"","creator":"designer","principal":"","keyPath":"","databaseType":"designer","privilegeDetailBeanList":'null'}]} |
@ -0,0 +1,25 @@
|
||||
export interface LinkType{ |
||||
connectionId?: string; |
||||
database?: string; |
||||
connectionName?: string; |
||||
driver?: string; |
||||
url?: string; |
||||
user?: string; |
||||
password?: string; |
||||
queryType?: string; |
||||
newCharsetName?: any; |
||||
originalCharsetName?: any; |
||||
validationQuery?: string; |
||||
schema?: string; |
||||
testOnBorrow?: boolean; |
||||
maxActive?: number; |
||||
options?: any; |
||||
port?: number; |
||||
authType?: string; |
||||
creator?: string; |
||||
principal?: string; |
||||
keyPath?: string; |
||||
databaseType?: string; |
||||
privilegeDetailBeanList?: any; |
||||
isSelected?: boolean; |
||||
} |
Loading…
Reference in new issue