From a8bd8d9b44dcaae79ba60481d496ed069ef5bec8 Mon Sep 17 00:00:00 2001
From: songliting <1341839053@qq.com>
Date: Thu, 27 Oct 2022 10:35:01 +0800
Subject: [PATCH] #204 support python/openmldb/kylin
---
src/components/CodeEditor/index.vue | 8 +-
src/config/index.js | 4 -
src/config/lang.js | 45 ++++
src/config/lang.json | 68 ++++++
src/locale/en.json | 2 +
src/locale/zh.json | 2 +
.../Notebook/CellBox/CellConfigForm.vue | 229 ++++++++++++++++++
src/page/Workspace/Notebook/CellBox/index.vue | 115 ++++++---
.../Workspace/Notebook/CellList/command.vue | 20 +-
.../Workspace/Notebook/CellList/index.vue | 132 +++++-----
src/page/Workspace/Notebook/CellList/util.js | 68 ++++++
.../Notebook/CollapseCode/Editor.vue | 10 +-
.../Workflow/components/CodeEditor/index.vue | 2 +-
13 files changed, 577 insertions(+), 128 deletions(-)
create mode 100644 src/config/lang.js
create mode 100644 src/config/lang.json
create mode 100644 src/page/Workspace/Notebook/CellBox/CellConfigForm.vue
create mode 100644 src/page/Workspace/Notebook/CellList/util.js
diff --git a/src/components/CodeEditor/index.vue b/src/components/CodeEditor/index.vue
index 6a6b25a..fa9149e 100644
--- a/src/components/CodeEditor/index.vue
+++ b/src/components/CodeEditor/index.vue
@@ -18,7 +18,7 @@
+
+
diff --git a/src/page/Workspace/Notebook/CellBox/index.vue b/src/page/Workspace/Notebook/CellBox/index.vue
index fbe36b4..c81e3fb 100644
--- a/src/page/Workspace/Notebook/CellBox/index.vue
+++ b/src/page/Workspace/Notebook/CellBox/index.vue
@@ -5,27 +5,48 @@
-
-
-
-
-
+
+
+
+
+
+
+
+
+
{{ getEditType() }}
+
+
+
@@ -48,18 +69,6 @@
-
-
-
-
@@ -78,8 +87,11 @@ import ExcuteResult from '../ExcuteResult'
import CollapseCode from '../CollapseCode'
import ExcuteDetail from '../ExcuteDetail'
import LogMessage from '../LogMessage'
+import CellConfigForm from './CellConfigForm'
import { mapMutations, mapActions, mapGetters, mapState } from 'vuex'
-import { JOB_STATUS, MarkdownTag } from '@/config'
+import { JOB_STATUS } from '@/config'
+import { LANG, MarkdownTag, LANG_PREFIX, langList } from '@/config/lang'
+import { getCellConfig } from '../CellList/util'
export default {
props: ['cellInfo', 'selectCell', 'disableDelete', 'isRunningAll', 'currentNotebook', 'mode', 'cellId', 'newCellList', 'showAllCell'],
@@ -97,10 +109,12 @@ export default {
showExcuteDetails: true,
startTime: 0,
showAddCode: false,
- editType: this.cellInfo.editType || 'Byzer-lang', // 编辑器类型
+ editType: this.cellInfo.editType || LANG?.BYZER, // 编辑器类型
mdMode: 'preview',
innerMaxHeight: '',
- loadingExcute: false
+ loadingExcute: false,
+ LANG: LANG,
+ showConfigForm: false
}
},
components: {
@@ -110,7 +124,8 @@ export default {
ExcuteResult,
CollapseCode,
ExcuteDetail,
- LogMessage
+ LogMessage,
+ CellConfigForm
},
created () {
this.calInnerMaxHeight()
@@ -142,7 +157,8 @@ export default {
cellInfo: {
handler (newVal) {
this.content = this.cellInfo.content
- this.editType = this.cellInfo.editType || 'Byzer-lang'
+ this.editType = this.cellInfo.editType || LANG?.BYZER
+ this.showConfigForm = Boolean(LANG_PREFIX[this.editType])
if (!newVal.job_id) {
this.excuteResult = {}
this.status = 'NEW'
@@ -179,6 +195,9 @@ export default {
...mapMutations({
addResult: 'SET_LOADED_CELL_LIST'
}),
+ getEditType () {
+ return langList.find(item => item.value === this.editType)?.label
+ },
changeMdMode (mode) {
if (this.isDemo) return
this.mdMode = mode
@@ -225,7 +244,7 @@ export default {
this.$emit('handleStopHere')
},
async handleRun () {
- if (this.editType === 'Markdown') {
+ if (this.editType === LANG.MARKDOWN) {
// markdown
this.changeStatus('1')
this.loading = false
@@ -340,13 +359,13 @@ export default {
changeContent (value) {
let newValue = value
this.content = newValue
- if (this.editType === 'Markdown') {
+ if (this.editType === LANG.MARKDOWN) {
newValue = `${MarkdownTag}${newValue}`
}
this.$emit('changeCellContent', {
value: newValue,
cellInfo: this.cellInfo,
- reserve: this.editType === 'Markdown'
+ reserve: this.editType === LANG.MARKDOWN
})
},
gotoNextCell (type) {
@@ -354,6 +373,14 @@ export default {
},
changeMode (mode) {
this.$emit('changeMode', mode)
+ },
+ handleChangeCellConfig (config) {
+ const curConfig = getCellConfig(this.selectCell)
+ const str = this.selectCell.content.replace(curConfig, config)
+ this.$emit('changeCellContent', {
+ value: str,
+ cellInfo: this.cellInfo
+ })
}
},
beforeDestory () {
@@ -362,7 +389,6 @@ export default {
}