Skip to content

Commit

Permalink
upd: 函数管理交互更新
Browse files Browse the repository at this point in the history
  • Loading branch information
mayinrain committed Dec 31, 2024
1 parent f239a46 commit 83f64e5
Show file tree
Hide file tree
Showing 3 changed files with 63 additions and 5 deletions.
3 changes: 2 additions & 1 deletion linkis-web/src/apps/URM/i18n/common/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,8 @@
"XGHS": "Update Funtion",
"XG": "Update",
"QPZS": "View in Full Screen",
"QXQP": "Cancel Full Screen"
"QXQP": "Cancel Full Screen",
"XZHS": "Select Function"
}
}
}
Expand Down
3 changes: 2 additions & 1 deletion linkis-web/src/apps/URM/i18n/common/zh.json
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,8 @@
"XGHS": "修改函数",
"XG": "修改",
"QPZS": "全屏展示",
"QXQP": "取消全屏"
"QXQP": "取消全屏",
"XZHS": "选择函数"
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@
<FormItem
:label="$t('message.linkis.udf.functionName')"
prop="name">
<Input v-model="setting.name" :disabled="model === 1" />
<Input v-model="setting.name" :disabled="model === 1 || !registerFunctionEditable" />
</FormItem>
<FormItem
:label="$t('message.linkis.udf.functionType')"
Expand Down Expand Up @@ -95,6 +95,21 @@
fs-type="share"
@set-node="setNodePath"/>
</FormItem>
<FormItem
v-if="registerFunctions.length > 0 && model !== 1"
:label="$t('message.linkis.udf.XZHS')"
prop="name">
<Select
v-model="setting.name"
@on-change="handleFuncChange"
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 Down Expand Up @@ -268,6 +283,7 @@ export default {
isCommon: false,
isCustom: true,
},
registerFunctions: [],
TYPELIB: {
jar: 0,
Spark: {
Expand Down Expand Up @@ -308,6 +324,8 @@ export default {
directory: ''
},
isShareLoading: false,

registerFunctionEditable: true,
rules: {
name: [
{ required: true, message: this.$t('message.linkis.udf.QSRMC'), trigger: 'blur' },
Expand Down Expand Up @@ -514,6 +532,11 @@ export default {
getHeight() {
this.resize(window.innerHeight);
},
handleFuncChange(val) {
if(this.model !== 1) {
this.setting.name = val;
}
},
open(node) {
this.resetData();
const titleMap = [this.$t('message.linkis.udf.addFunction'), this.$t('message.linkis.udf.updateFunction')];
Expand All @@ -531,7 +554,10 @@ export default {
this.title = titleMap[this.model];
this.btnLabel = btnLabelMap[this.model];
},

async getRegisterFunction(path) {
const res = await api.fetch('/udf/get-register-functions', { path }, 'get');
return res.functions
},
init() {
let { name, shared, description, path, udfName, directory, udfType, registerFormat, load, useFormat } = this.node;
let fnType = 'Spark'
Expand All @@ -556,6 +582,18 @@ export default {
});
this.$nextTick(() => {
this.$set(this.setting, this.getTypes(), path);
// try {
// this.registerFunctions = await this.getRegisterFunction(path);
// if(this.registerFunctions.length !== 0) {
// this.registerFunctionEditable = false;
// } else {
// this.registerFunctionEditable = true;
// }
// } catch (err) {
// window.console.error(err);
// this.registerFunctions = [];
// this.registerFunctionEditable = true;
// }
});
},

Expand Down Expand Up @@ -659,8 +697,24 @@ export default {
this.modalHeight = h - 380 + 'px';
},

setNodePath(node) {
async setNodePath(node) {
this.$set(this.setting, this.getTypes(), node.path);
if(this.model !== 1) {
try {
this.registerFunctions = await this.getRegisterFunction(node.path);
if(this.registerFunctions.length !== 0) {
this.registerFunctionEditable = false;
this.setting.name = '';
} else {
this.registerFunctionEditable = true;
}
} catch (err) {
window.console.error(err);
this.registerFunctions = [];
this.registerFunctionEditable = true;
}
}

},

getTypes() {
Expand Down Expand Up @@ -697,6 +751,8 @@ export default {
};
this.showScalaRF = '';
this.showScalaUF = '';
this.registerFunctions = [];
this.registerFunctionEditable = true;
},

getDir() {
Expand Down

0 comments on commit 83f64e5

Please sign in to comment.