Skip to content

Commit

Permalink
#204 support python/openmldb/kylin (#205)
Browse files Browse the repository at this point in the history
  • Loading branch information
githubnameting authored Oct 27, 2022
1 parent 005daf6 commit 6439d00
Show file tree
Hide file tree
Showing 13 changed files with 577 additions and 128 deletions.
8 changes: 4 additions & 4 deletions src/components/CodeEditor/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
<script>
import ace from 'brace'
import { mapActions } from 'vuex'
import { PythonTag, SpecialCodeSuggestKey } from '../../config'
import { LANG, PythonTag, SpecialCodeSuggestKey } from '@/config/lang'
export default {
props: {
Expand Down Expand Up @@ -63,9 +63,9 @@ export default {
},
watch: {
value (newVal, oldVal) {
if (this.readOnly) {
// if (this.readOnly) {
this.content = newVal
}
// }
this.checkLang()
;(oldVal || '').split('').forEach(i => {
Expand Down Expand Up @@ -178,7 +178,7 @@ export default {
for (let index in this.newCellList) {
index = index * 1
const { editType, content } = this.newCellList[index]
if (index < cellIndex && editType !== 'Markdown') {
if (index < cellIndex && editType !== LANG.MARKDOWN) {
const lineList = content.split('\n')
lineNum += lineList.length
beforeCellValue =
Expand Down
4 changes: 0 additions & 4 deletions src/config/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,6 @@ export const dataSourceList = [
]
export const notebookNameReg = /^[\u4e00-\u9fa9A-Za-z0-9_]+$/

export const MarkdownTag = '--%markdown'
export const PythonTag = '#%python'
export const SpecialCodeSuggestKey = ['.', '/', '`', '\'', '"']

/**
* key: file type
* value: suffix
Expand Down
45 changes: 45 additions & 0 deletions src/config/lang.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
export { default } from './lang.json'
export const SpecialCodeSuggestKey = ['.', '/', '`', '\'', '"']

export const PYTHON_PREFIX = '#%'
export const OPENMLDB_PREFIX = '--%'
export const KYLIN_PREFIX = '--%'

export const PythonTag = '#%python'
export const MarkdownTag = '--%markdown'
export const OpenMLDBTag = '--%openmldb'
export const KylinTag = '--%kylin'

export const LANG = {
BYZER: 'byzer',
PYTHON: 'python',
OPENMLDB: 'openmldb',
KYLIN: 'kylin',
MARKDOWN: 'markdown'
}

export const LANG_PREFIX = {
[LANG.PYTHON]: PYTHON_PREFIX,
[LANG.OPENMLDB]: OPENMLDB_PREFIX,
[LANG.KYLIN]: KYLIN_PREFIX,
[LANG.MARKDOWN]: null,
[LANG.BYZER]: null
}

export const LANG_TAG = {
[LANG.PYTHON]: PythonTag,
[LANG.OPENMLDB]: OpenMLDBTag,
[LANG.KYLIN]: KylinTag,
[LANG.MARKDOWN]: MarkdownTag,
[LANG.BYZER]: null
}

export const langList = [
{label: 'Byzer-lang', value: LANG.BYZER},
{label: 'Python', value: LANG.PYTHON},
{label: 'OpenMLDB', value: LANG.OPENMLDB},
{label: 'Kylin', value: LANG.KYLIN},
{label: 'Markdown', value: LANG.MARKDOWN }
]


68 changes: 68 additions & 0 deletions src/config/lang.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
{
"python": {
"input": {
"required": true,
"default": ""
},
"output": {
"required": false,
"default": ""
},
"schema": {
"required": true,
"default": ""
},
"runIn": {
"required": false,
"default": "driver",
"options": ["driver", "executor"]
},
"dataMode": {
"required": false,
"default": "data",
"options": ["data", "model"]
} ,
"cache": {
"required": false,
"default": true,
"options": [true, false]
},
"env": {
"required": true,
"default": ""
}
},
"openmldb": {
"url": {
"required": true,
"default": ""
},
"db": {
"required": true,
"default": ""
},
"execute_mode": {
"required": true,
"default": "offline",
"options": ["offline", "online"]
},
"output": {
"required": true,
"default": ""
}
},
"kylin": {
"url": {
"required": true,
"default": ""
},
"db": {
"required": true,
"default": ""
},
"output": {
"required": true,
"default": ""
}
}
}
2 changes: 2 additions & 0 deletions src/locale/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@
"close": "Close",
"submit": "Submit",
"cancel": "Cancel",
"apply": "Apply",
"applied": "Applied",
"tip": "Tip",
"pleaseInput": "Please input",
"pleaseSelect": "Please select",
Expand Down
2 changes: 2 additions & 0 deletions src/locale/zh.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@
"close": "关闭",
"submit": "提交",
"cancel": "取消",
"apply": "应用",
"applied": "已应用",
"tip": "提示",
"pleaseInput": "请输入",
"pleaseSelect": "请选择",
Expand Down
Loading

0 comments on commit 6439d00

Please sign in to comment.