import {IControl, IDataSource, SourceCode, ITableDefinition} from '@datahu/core'
import {I18n} from '../i18n'
import getControls from './SqlServerControls'
import {ISqlServerConfig, SqlServerHelper} from './SqlServerHelper'
export class SqlServerDataSource implements IDataSource {
language: string = 'zh-cn'
helper: SqlServerHelper
constructor(language: string, config?: object) {
this.language = language
var i18n = I18n.get(this.language)
if (config) this.config = config as ISqlServerConfig
this.helper = new SqlServerHelper(this.config)
// 数据源配置界面的配置控件
this.controls = getControls(i18n)
this.title = i18n.sqlserver_title
this.description = i18n.sqlserver_description
}
getControls(): IControl[] {
return this.controls
}
controls: IControl[] = []
// 数据源默认配置值
config = {
title: '',
server: 'localhost',
port: 1433,
user: 'root',
password: '',
database: '',
options: {
encrypt: false //不设置此属性 报错
}
} as ISqlServerConfig
icon: string =
''
title: string = ''
description: string = ''
sourceCode: SourceCode = SourceCode.Javascript
getTables(): Promise> {
return this.helper.getTables()
}
getData(tables: Array): Promise> {
return this.helper.getData(tables)
}
}