import {IControl, IDataSource, SourceCode, ITableDefinition} from '@datahu/core'
import {I18n} from '../i18n'
import getControls from './CDataControls'
import {CDataHelper, ICDataConfig} from './CDataHelper'
export class CDataDataSource implements IDataSource {
language: string = 'zh-cn'
helper: CDataHelper
disableNew: boolean = true
constructor(language: string, config?: object) {
this.language = language
var i18n = I18n.get(this.language)
if (config) this.config = config as ICDataConfig
this.helper = new CDataHelper(this.config)
// 数据源配置界面的配置控件
this.controls = getControls(i18n)
this.title = '在线数据'
this.description = ''
}
getControls(): IControl[] {
return this.controls
}
controls: IControl[] = []
// 数据源默认配置值
config = {
user: null,
tables: []
} as ICDataConfig
icon: string = ``
title: string = ''
description: string = ''
sourceCode: SourceCode = SourceCode.SQL
getTables(): Promise> {
return this.helper.getTables()
}
getData(tables: Array): Promise> {
return this.helper.getData(tables)
}
}