diff --git a/sermant-backend/src/main/resources/config-ui-template/router.yml b/sermant-backend/src/main/resources/config-ui-template/router.yml index ac4b779d58..932c9ed457 100644 --- a/sermant-backend/src/main/resources/config-ui-template/router.yml +++ b/sermant-backend/src/main/resources/config-ui-template/router.yml @@ -35,4 +35,4 @@ configTemplates: - key: servicecomb.routeRule.* value: "- kind: routematcher.sermant.io/flow\n description: test\n rules:\n - precedence: 1\n match:\n attachments:\n id:\n exact: '1'\n route:\n - weight: 20\n tags:\n version: 1.0.0\n - weight: 80\n tags:\n version: 1.0.1\n- kind: routematcher.sermant.io/tag\n description: sameTag\n rules:\n - precedence: 1\n match:\n tags:\n zone:\n exact: 'hangzhou'\n policy:\n triggerThreshold: 20\n minAllInstances: 3\n- kind: route.sermant.io/lane\n description: lane\n rules:\n - precedence: 1\n match:\n method: getFoo\n path: 'io.sermant.bar'\n protocol: dubbo\n attachments:\n id:\n exact: '1'\n args:\n args0:\n type: .name\n exact: 'foo'\n route:\n - tag-inject:\n x-sermant-flag2: gray2\n weight: 100" - key: servicecomb.globalRouteRule - - value: "- kind: routematcher.sermant.io/flow\n description: test\n rules:\n - precedence: 1\n match:\n attachments:\n id:\n exact: '1'\n route:\n - weight: 20\n tags:\n version: 1.0.0\n - weight: 80\n tags:\n version: 1.0.1\n- kind: routematcher.sermant.io/tag\n description: sameTag\n rules:\n - precedence: 1\n match:\n tags:\n zone:\n exact: 'hangzhou'\n policy:\n triggerThreshold: 20\n minAllInstances: 3\n- kind: route.sermant.io/lane\n description: lane\n rules:\n - precedence: 1\n match:\n method: getFoo\n path: 'io.sermant.bar'\n protocol: dubbo\n attachments:\n id:\n exact: '1'\n args:\n args0:\n type: .name\n exact: 'foo'\n route:\n - tag-inject:\n x-sermant-flag2: gray2\n weight: 100" + value: "- kind: routematcher.sermant.io/flow\n description: test\n rules:\n - precedence: 1\n match:\n attachments:\n id:\n exact: '1'\n route:\n - weight: 20\n tags:\n version: 1.0.0\n - weight: 80\n tags:\n version: 1.0.1\n- kind: routematcher.sermant.io/tag\n description: sameTag\n rules:\n - precedence: 1\n match:\n tags:\n zone:\n exact: 'hangzhou'\n policy:\n triggerThreshold: 20\n minAllInstances: 3\n- kind: route.sermant.io/lane\n description: lane\n rules:\n - precedence: 1\n match:\n method: getFoo\n path: 'io.sermant.bar'\n protocol: dubbo\n attachments:\n id:\n exact: '1'\n args:\n args0:\n type: .name\n exact: 'foo'\n route:\n - tag-inject:\n x-sermant-flag2: gray2\n weight: 100" diff --git a/sermant-backend/src/main/webapp/frontend/package-lock.json b/sermant-backend/src/main/webapp/frontend/package-lock.json index cfd447dbc9..ff547a1952 100644 --- a/sermant-backend/src/main/webapp/frontend/package-lock.json +++ b/sermant-backend/src/main/webapp/frontend/package-lock.json @@ -10,7 +10,7 @@ "license": "MIT", "dependencies": { "@element-plus/icons-vue": "^2.1.0", - "axios": "^1.3.4", + "axios": "^1.8.2", "element-plus": "^2.2.36", "moment": "^2.29.4", "qs": "^6.11.1", @@ -1547,12 +1547,11 @@ "license": "MIT" }, "node_modules/axios": { - "version": "1.3.4", - "resolved": "https://repo.huaweicloud.com/repository/npm/axios/-/axios-1.3.4.tgz", - "integrity": "sha512-toYm+Bsyl6VC5wSkfkbbNB6ROv7KY93PEBBL6xyDczaIHasAiv4wPqQ/c4RjoQzipxRD2W5g21cOqQulZ7rHwQ==", - "license": "MIT", + "version": "1.8.4", + "resolved": "https://r.cnpmjs.org/axios/-/axios-1.8.4.tgz", + "integrity": "sha512-eBSYY4Y68NNlHbHBMdeDmKNtDgXWhQsJcGqzO3iLUM0GraQFSS9cVgPX5I9b3lbdFKyYoAEGAZF1DwhTaljNAw==", "dependencies": { - "follow-redirects": "^1.15.0", + "follow-redirects": "^1.15.6", "form-data": "^4.0.0", "proxy-from-env": "^1.1.0" } @@ -2170,16 +2169,15 @@ } }, "node_modules/follow-redirects": { - "version": "1.15.2", - "resolved": "https://repo.huaweicloud.com/repository/npm/follow-redirects/-/follow-redirects-1.15.2.tgz", - "integrity": "sha512-VQLG33o04KaQ8uYi2tVNbdrWp1QWxNNea+nmIB4EVM28v0hmP17z7aG1+wAkNzVq4KeXTq3221ye5qTJP91JwA==", + "version": "1.15.9", + "resolved": "https://r.cnpmjs.org/follow-redirects/-/follow-redirects-1.15.9.tgz", + "integrity": "sha512-gew4GsXizNgdoRyqmyfMHyAmXsZDk6mHkSxZFCzW9gwlbtOW44CDtYavM+y+72qD/Vq2l550kMF52DT8fOLJqQ==", "funding": [ { "type": "individual", "url": "https://github.com/sponsors/RubenVerborgh" } ], - "license": "MIT", "engines": { "node": ">=4.0" }, @@ -5263,11 +5261,11 @@ "integrity": "sha512-Oei9OH4tRh0YqU3GxhX79dM/mwVgvbZJaSNaRk+bshkj0S5cfHcgYakreBjrHwatXKbz+IoIdYLxrKim2MjW0Q==" }, "axios": { - "version": "1.3.4", - "resolved": "https://repo.huaweicloud.com/repository/npm/axios/-/axios-1.3.4.tgz", - "integrity": "sha512-toYm+Bsyl6VC5wSkfkbbNB6ROv7KY93PEBBL6xyDczaIHasAiv4wPqQ/c4RjoQzipxRD2W5g21cOqQulZ7rHwQ==", + "version": "1.8.4", + "resolved": "https://r.cnpmjs.org/axios/-/axios-1.8.4.tgz", + "integrity": "sha512-eBSYY4Y68NNlHbHBMdeDmKNtDgXWhQsJcGqzO3iLUM0GraQFSS9cVgPX5I9b3lbdFKyYoAEGAZF1DwhTaljNAw==", "requires": { - "follow-redirects": "^1.15.0", + "follow-redirects": "^1.15.6", "form-data": "^4.0.0", "proxy-from-env": "^1.1.0" } @@ -5710,9 +5708,9 @@ } }, "follow-redirects": { - "version": "1.15.2", - "resolved": "https://repo.huaweicloud.com/repository/npm/follow-redirects/-/follow-redirects-1.15.2.tgz", - "integrity": "sha512-VQLG33o04KaQ8uYi2tVNbdrWp1QWxNNea+nmIB4EVM28v0hmP17z7aG1+wAkNzVq4KeXTq3221ye5qTJP91JwA==" + "version": "1.15.9", + "resolved": "https://r.cnpmjs.org/follow-redirects/-/follow-redirects-1.15.9.tgz", + "integrity": "sha512-gew4GsXizNgdoRyqmyfMHyAmXsZDk6mHkSxZFCzW9gwlbtOW44CDtYavM+y+72qD/Vq2l550kMF52DT8fOLJqQ==" }, "form-data": { "version": "4.0.0", diff --git a/sermant-backend/src/main/webapp/frontend/package.json b/sermant-backend/src/main/webapp/frontend/package.json index 45971c4302..a4a045e80c 100644 --- a/sermant-backend/src/main/webapp/frontend/package.json +++ b/sermant-backend/src/main/webapp/frontend/package.json @@ -11,7 +11,7 @@ }, "dependencies": { "@element-plus/icons-vue": "^2.1.0", - "axios": "^1.3.4", + "axios": "^1.8.2", "element-plus": "^2.2.36", "moment": "^2.29.4", "qs": "^6.11.1", diff --git a/sermant-backend/src/main/webapp/frontend/src/views/ConfigInfo.vue b/sermant-backend/src/main/webapp/frontend/src/views/ConfigInfo.vue index 78cb9febe8..2d8cf67576 100644 --- a/sermant-backend/src/main/webapp/frontend/src/views/ConfigInfo.vue +++ b/sermant-backend/src/main/webapp/frontend/src/views/ConfigInfo.vue @@ -152,6 +152,8 @@ const configInfo = ref({ configType: '' }); +let currentTemplateKey=''; + const options = ref([]); interface pluginTemplate { @@ -296,6 +298,8 @@ getTemplate(); function initPageTemplate() { const param: LocationQuery = router.currentRoute.value.query; + configInfo.value.configType = param.configType; + configInfo.value.namespace = param.namespace; if (param.type != "modify") { return; } @@ -303,8 +307,6 @@ function initPageTemplate() { configInfo.value.pluginType = param.pluginType; configInfo.value.group = param.group; configInfo.value.key = param.key; - configInfo.value.namespace = param.namespace; - configInfo.value.configType = param.configType; configInfo.value.keyRule = param.keyRule; configInfo.value.groupRule = param.groupRule; console.log(param) @@ -352,9 +354,11 @@ function changeElement(template: pluginTemplate) { } configInfo.value.group = replaceTemplate(configInfo.value.groupRule, configInfo.value); configInfo.value.key = replaceTemplate(configInfo.value.keyRule, configInfo.value); + console.log(template.configTemplates) template.configTemplates.forEach(configTemplate => { const pattern = new RegExp(configTemplate.key.replace("*", ".*")); - if (pattern.test(configInfo.value.key)) { + if (pattern.test(configInfo.value.key) && currentTemplateKey != configTemplate.key) { + currentTemplateKey=configTemplate.key configInfo.value.content = configTemplate.value } }) @@ -376,7 +380,8 @@ function changePluginType() { namespace: configInfo.value.namespace, pluginType: configInfo.value.pluginType, keyRule: template.keyRule[0], - groupRule: template.groupRule[0] + groupRule: template.groupRule[0], + configType: configInfo.value.configType }; changeRule(template); changeElement(template); @@ -388,6 +393,8 @@ function initCheckRule(template: pluginTemplate) { if ((containsPlaceholder(element.name, configInfo.value.keyRule) || containsPlaceholder(element.name, configInfo.value.groupRule)) && element.required) { checkRule.value[element.name] = [{required: true, message: message, trigger: 'change'}]; + } else { + checkRule.value[element.name] = [{required: false, message: message, trigger: 'change'}]; } }) } diff --git a/sermant-backend/src/main/webapp/frontend/src/views/ConfigView.vue b/sermant-backend/src/main/webapp/frontend/src/views/ConfigView.vue index 3c4b85d6ba..1a55ce82e9 100644 --- a/sermant-backend/src/main/webapp/frontend/src/views/ConfigView.vue +++ b/sermant-backend/src/main/webapp/frontend/src/views/ConfigView.vue @@ -298,8 +298,8 @@ const configCenterInfo = reactive({ }); onBeforeMount(async () => { - await getTemplate(); - getConfigurationCenter(); + await getConfigurationCenter(); + getTemplate(); }); // 路由 const router = useRouter(); @@ -358,10 +358,10 @@ const getConfigList = () => { namespace: requestParam.value.namespace } if (params.groupRule && exactMatchFlag) { - params.group = replaceTemplate(params.groupRule, requestParam.value) + params.groupRule = replaceTemplate(params.groupRule, requestParam.value) } if (params.keyRule && exactMatchFlag) { - params.key = replaceTemplate(params.keyRule, requestParam.value) + params.keyRule = replaceTemplate(params.keyRule, requestParam.value) } if (pluginType == 'common') { params.groupRule = params.group @@ -458,8 +458,10 @@ const getConfigurationCenter = () => { }; const handlerChangePluginType = (value: string) => { + const namespace = requestParam.value.namespace; requestParam.value = {}; requestParam.value.pluginType = value + requestParam.value.namespace = namespace; currentTemplate.value = getCurrentTemplate(requestParam.value.pluginType); } @@ -512,7 +514,8 @@ const deleteConfig = (row: stringMap, index: number) => { const toAddConfig = () => { const params = { type: "add", - configType: configCenterInfo.dynamicConfigType + configType: configCenterInfo.dynamicConfigType, + namespace: configCenterInfo.namespace, }; router.push({name: "configInfo", query: params}); };