Skip to content

Commit

Permalink
Dev 1.10.0 webank (#687)
Browse files Browse the repository at this point in the history
* chore: 1.9.0

* feat: 1.10.0
  • Loading branch information
mayinrain authored Dec 19, 2024
1 parent 0d5d9f5 commit ec342a0
Show file tree
Hide file tree
Showing 11 changed files with 301 additions and 33 deletions.
8 changes: 5 additions & 3 deletions linkis-web/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "linkis",
"version": "1.4.0",
"version": "1.10.0",
"private": true,
"scripts": {
"serve": "vue-cli-service serve",
Expand All @@ -25,7 +25,7 @@
},
"dependencies": {
"@form-create/iview": "2.5.27",
"axios": "0.28.1",
"axios": "1.7.4",
"dexie": "3.2.3",
"dt-sql-parser": "3.0.5",
"highlight.js": "10.7.0",
Expand All @@ -49,7 +49,9 @@
"vue-router": "3.4.8",
"vuedraggable": "2.24.3",
"vuescroll": "4.16.1",
"worker-loader": "3.0.8"
"worker-loader": "3.0.8",
"xterm": "5.3.0",
"xterm-addon-fit": "0.8.0"
},
"devDependencies": {
"@intlify/vue-i18n-loader": "1.0.0",
Expand Down
2 changes: 0 additions & 2 deletions linkis-web/src/apps/PythonModule/.npmrc

This file was deleted.

1 change: 1 addition & 0 deletions linkis-web/src/apps/URM/i18n/common/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@
"no": "No",
"sprak": "sprak",
"jarPackage": "jar Package",
"registerFunc": "Register Function",
"scriptPath": "Script Path",
"registerFunction": "Register Function",
"registerFormat": "Register Format",
Expand Down
1 change: 1 addition & 0 deletions linkis-web/src/apps/URM/i18n/common/zh.json
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@
"no": "",
"sprak": "sprak",
"jarPackage": "jar包",
"registerFunc": "注册函数",
"scriptPath": "脚本路径",
"registerFunction": "注册的函数",
"registerFormat": "注册格式",
Expand Down
130 changes: 107 additions & 23 deletions linkis-web/src/apps/URM/module/udfManagement/addFunctionModal.vue
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,38 @@
fs-type="share"
@set-node="setNodePath"/>
</FormItem>
<FormItem
v-if="fnType === 1 && fnCategory.isSpark"
:label="$t('message.linkis.udf.registerFunc')"
prop="pyPara">
<Select
v-model="setting.pyPara"
@on-change="handleFuncChange"
:placeholder="$t('message.linkis.udf.registerFunction')"
filterable>
<Option
v-for="(item) in registerFunctions"
:label="item"
:value="item"
:key="item"/>
</Select>
</FormItem>
<FormItem
v-if="fnType === 2 && fnCategory.isSpark"
:label="$t('message.linkis.udf.registerFunc')"
prop="scalapara">
<Select
v-model="setting.scalapara"
@on-change="handleFuncChange"
:placeholder="$t('message.linkis.udf.registerFunction')"
filterable>
<Option
v-for="(item) in registerFunctions"
:label="item"
:value="item"
:key="item"/>
</Select>
</FormItem>
<FormItem
v-if="fnType === 0 && fnCategory.isCommon"
:label="$t('message.linkis.udf.registerFormat')"
Expand All @@ -110,6 +142,7 @@
prop="pyPara">
<Input
v-model="setting.pyPara"
:disabled="!registerFunctionEditable"
:placeholder="$t('message.linkis.udf.registerFunction')"/>
</FormItem>
<FormItem
Expand All @@ -134,6 +167,7 @@
<FormItem prop="scalapara">
<Input
v-model="setting.scalapara"
:disabled="!registerFunctionEditable"
:placeholder="$t('message.linkis.udf.registerFunction')"/>
</FormItem>
</div>
Expand Down Expand Up @@ -288,6 +322,8 @@ export default {
},
},
title: '',
registerFunctions: [],
registerFunctionEditable: true,
show: false,
btnLabel: this.$t('message.common.ok'),
modalHeight: '',
Expand Down Expand Up @@ -552,7 +588,11 @@ export default {
};
}
},

handleFuncChange(val) {
if(this.model !== 1) {
this.setting.name = val;
}
},
init() {
let { name, shared, description, path, udfName, directory, udfType, registerFormat, load, useFormat } = this.node;
let fnType = 'Spark'
Expand All @@ -575,9 +615,26 @@ export default {
fnType,
defaultLoad: !!load
});
this.$nextTick(() => {
this.$nextTick(async () => {
this.$set(this.setting, this.getTypes(), path);
this.registerFunctionEditable = false;
if(this.getTypes() !== 'jarPath') {
if (/^[\w\u4e00-\u9fa5:.\\/]*(py|scala)$/.test(path)) {
try {
this.registerFunctions = await this.getRegisterFunction(path);
if(this.registerFunctions.length !== 0) {
this.registerFunctionEditable = false;
}
} catch (err) {
window.console.error(err);
this.registerFunctions = [];
this.registerFunctionEditable = true;
}
}

}
});

},

close() {
Expand All @@ -594,27 +651,31 @@ export default {
} else if (this.node.udfType === 1) {
this.setting.pyPara = conver(',', ')', 'indexOf', 'lastIndexOf');
} else {
const type = rf.slice(rf.indexOf('[') + 1, rf.indexOf(']'));
const typeStart = rf.indexOf('[') + 1;
const typeEnd = rf.lastIndexOf(']');
const type = rf.slice(typeStart, typeEnd);
window.console.log(type, rf, '=====');
// 如果存在多个逗号,就只用使用格式来截取,否则会出现多个类型填入input异常的问题
if (type.indexOf(',') !== type.lastIndexOf(',')) {
// there are 2 case:
// 1. tuple, return params in ();
// 2. multi params, the first params is return params
if (type.indexOf('(') !== -1) {
// tuple
this.setting.scalaTypeL = type.slice(type.indexOf('('), type.indexOf(')') + 1)
this.setting.scalaTypeR = type.slice(type.indexOf(')')+2)
} else {
// multi params
this.setting.scalaTypeL = type.split(',')[0];
this.setting.scalaTypeR = type.split(',').slice(1).toString();
const findFirstValidComma = (str) => {
let brackets = 0;
for (let i = 0; i < str.length; i++) {
const char = str[i];
// 计算所有类型的括号
if (char === '[' || char === '(') brackets++;
if (char === ']' || char === ')') brackets--;
// 只在最外层找逗号
if (char === ',' && brackets === 0) return i;
}
return -1;
};

this.showScalaRF = this.node.registerFormat;
const commaPos = findFirstValidComma(type);

if (commaPos !== -1) {
this.setting.scalaTypeL = type.slice(0, commaPos).trim();
this.setting.scalaTypeR = type.slice(commaPos + 1).trim();
} else {
this.setting.scalaTypeL = conver('[', ',', 'indexOf', 'indexOf');
this.setting.scalaTypeR = conver(',', ']', 'indexOf', 'indexOf');
this.setting.scalaTypeL = type.trim();
this.setting.scalaTypeR = '';
}
this.setting.scalapara = conver(',', ')', 'lastIndexOf', 'lastIndexOf');
}
Expand All @@ -635,7 +696,6 @@ export default {
this.$set(this.setting, `${type}R`, right);
}
},

handleShareChange() {
if (!this.isShareLoading) {
this.isShareLoading = true;
Expand All @@ -662,10 +722,10 @@ export default {
udfType: this.fnType,
isLeaf: true,
directory,
clusterName
clusterName,
};
if (this.model) {
postData = Object.assign(postData, { shared: false });
postData = Object.assign(postData, { shared: false, defaultLoad });
this.$emit('update', postData);
} else {
postData = Object.assign(postData, { defaultLoad });
Expand All @@ -692,12 +752,36 @@ export default {
resize(h) {
this.modalHeight = h - 380 + 'px';
},
// 获取注册函数
async getRegisterFunction(path) {
const res = await api.fetch('/udf/get-register-functions', { path }, 'get');
return res.functions
},

setNodePath(node) {
async setNodePath(node) {
['jarPath', 'sparkPath', 'customPath'].forEach(item => {
const temp = item === this.getTypes() ? node.path : '';
this.$set(this.setting, item, temp);
})
if(this.getTypes() !== 'jarPath') {


if (/^[\w\u4e00-\u9fa5:.\\/]*(py|scala)$/.test(node.path)) {
try {
this.registerFunctions = await this.getRegisterFunction(node.path);
if(this.registerFunctions.length !== 0) {
this.registerFunctionEditable = false;
}
} catch (err) {
window.console.error(err);
this.registerFunctions = [];
this.registerFunctionEditable = true;
}
}


}

},

getTypes() {
Expand Down
31 changes: 29 additions & 2 deletions linkis-web/src/apps/URM/module/udfManagement/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -360,7 +360,7 @@ export default {
}
},
// 新增函数
addFunction(data) {
async addFunction(data) {
if (this.loading) return
this.loading = true;
const params = {
Expand All @@ -377,19 +377,24 @@ export default {
clusterName: data.clusterName,
directory: data.directory
}
api
await api
.fetch('/udf/add', {udfAddVo: params}, 'post')
.then(() => {
this.showAddModal(false)
this.search()
this.isLoading = false
this.loading = false
if (data.defaultLoad) {
this.confirmKillIdle(data)
}
})
.catch(() => {
// this.list = [{}]
this.loading = false
this.isLoading = false

})

},
// 更新
updateFunction(data) {
Expand Down Expand Up @@ -417,12 +422,34 @@ export default {
this.loading = false
this.search()
this.$Message.success(this.$t('message.linkis.udf.success'));

console.log(data);
if (data.defaultLoad) {
this.confirmKillIdle(data)
}
})
.catch(() => {
this.isLoading = false
this.loading = false
})
},
confirmKillIdle(data) {
console.log(data);
this.$Modal.confirm({
title: this.$t('message.linkis.setting.killEngineTitle'),
content: this.$t('message.linkis.setting.killEngine'),
onOk: async () => {
try {
api.fetch("/linkisManager/rm/killEngineByCreatorEngineType", {
creator: '*',
engineType: data.udfType === 1 ? 'spark' : '*'
})
} catch (err) {
window.console.warn(err)
}
}
})
},
checkChange(v) {
this.list = this.list.map(it => {
it.checked = !it.disabled && v
Expand Down
1 change: 1 addition & 0 deletions linkis-web/src/apps/linkis/i18n/common/en.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
{
"message": {
"linkis": {
"diagnosticLog": "Diagnostic Log",
"refresh": "Refresh",
"tableSetting": "Table Setting",
"downloadLog": "Download",
Expand Down
1 change: 1 addition & 0 deletions linkis-web/src/apps/linkis/i18n/common/zh.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
{
"message": {
"linkis": {
"diagnosticLog": "诊断日志",
"refresh": "刷新",
"findNewVer": "检测到新版本",
"whetherUpdateNow": "是否立即更新?",
Expand Down
Loading

0 comments on commit ec342a0

Please sign in to comment.