Skip to content

Commit 22fda46

Browse files
committed
Fix some bug of config manager
Signed-off-by: hanbingleixue <hanbingleixue@hotmail.com>
1 parent 58cc196 commit 22fda46

5 files changed

Lines changed: 36 additions & 28 deletions

File tree

sermant-backend/src/main/resources/config-ui-template/router.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,4 +35,4 @@ configTemplates:
3535
- key: servicecomb.routeRule.*
3636
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"
3737
- key: servicecomb.globalRouteRule
38-
- 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"
38+
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"

sermant-backend/src/main/webapp/frontend/package-lock.json

Lines changed: 15 additions & 17 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

sermant-backend/src/main/webapp/frontend/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
},
1212
"dependencies": {
1313
"@element-plus/icons-vue": "^2.1.0",
14-
"axios": "^1.3.4",
14+
"axios": "^1.8.2",
1515
"element-plus": "^2.2.36",
1616
"moment": "^2.29.4",
1717
"qs": "^6.11.1",

sermant-backend/src/main/webapp/frontend/src/views/ConfigInfo.vue

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -152,6 +152,8 @@ const configInfo = ref<stringMap>({
152152
configType: ''
153153
});
154154
155+
let currentTemplateKey='';
156+
155157
const options = ref<option[]>([]);
156158
157159
interface pluginTemplate {
@@ -296,15 +298,15 @@ getTemplate();
296298
297299
function initPageTemplate() {
298300
const param: LocationQuery = router.currentRoute.value.query;
301+
configInfo.value.configType = <string>param.configType;
302+
configInfo.value.namespace = <string>param.namespace;
299303
if (<string>param.type != "modify") {
300304
return;
301305
}
302306
modifyFlag.value = true
303307
configInfo.value.pluginType = <string>param.pluginType;
304308
configInfo.value.group = <string>param.group;
305309
configInfo.value.key = <string>param.key;
306-
configInfo.value.namespace = <string>param.namespace;
307-
configInfo.value.configType = <string>param.configType;
308310
configInfo.value.keyRule = <string>param.keyRule;
309311
configInfo.value.groupRule = <string>param.groupRule;
310312
console.log(param)
@@ -352,9 +354,11 @@ function changeElement(template: pluginTemplate) {
352354
}
353355
configInfo.value.group = replaceTemplate(configInfo.value.groupRule, configInfo.value);
354356
configInfo.value.key = replaceTemplate(configInfo.value.keyRule, configInfo.value);
357+
console.log(template.configTemplates)
355358
template.configTemplates.forEach(configTemplate => {
356359
const pattern = new RegExp(configTemplate.key.replace("*", ".*"));
357-
if (pattern.test(configInfo.value.key)) {
360+
if (pattern.test(configInfo.value.key) && currentTemplateKey != configTemplate.key) {
361+
currentTemplateKey=configTemplate.key
358362
configInfo.value.content = configTemplate.value
359363
}
360364
})
@@ -376,7 +380,8 @@ function changePluginType() {
376380
namespace: configInfo.value.namespace,
377381
pluginType: configInfo.value.pluginType,
378382
keyRule: template.keyRule[0],
379-
groupRule: template.groupRule[0]
383+
groupRule: template.groupRule[0],
384+
configType: configInfo.value.configType
380385
};
381386
changeRule(template);
382387
changeElement(template);
@@ -388,6 +393,8 @@ function initCheckRule(template: pluginTemplate) {
388393
if ((containsPlaceholder(element.name, configInfo.value.keyRule)
389394
|| containsPlaceholder(element.name, configInfo.value.groupRule)) && element.required) {
390395
checkRule.value[element.name] = [{required: true, message: message, trigger: 'change'}];
396+
} else {
397+
checkRule.value[element.name] = [{required: false, message: message, trigger: 'change'}];
391398
}
392399
})
393400
}

sermant-backend/src/main/webapp/frontend/src/views/ConfigView.vue

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -298,8 +298,8 @@ const configCenterInfo = reactive({
298298
});
299299
300300
onBeforeMount(async () => {
301-
await getTemplate();
302-
getConfigurationCenter();
301+
await getConfigurationCenter();
302+
getTemplate();
303303
});
304304
// 路由
305305
const router = useRouter();
@@ -358,10 +358,10 @@ const getConfigList = () => {
358358
namespace: requestParam.value.namespace
359359
}
360360
if (params.groupRule && exactMatchFlag) {
361-
params.group = replaceTemplate(params.groupRule, requestParam.value)
361+
params.groupRule = replaceTemplate(params.groupRule, requestParam.value)
362362
}
363363
if (params.keyRule && exactMatchFlag) {
364-
params.key = replaceTemplate(params.keyRule, requestParam.value)
364+
params.keyRule = replaceTemplate(params.keyRule, requestParam.value)
365365
}
366366
if (pluginType == 'common') {
367367
params.groupRule = params.group
@@ -458,8 +458,10 @@ const getConfigurationCenter = () => {
458458
};
459459
460460
const handlerChangePluginType = (value: string) => {
461+
const namespace = requestParam.value.namespace;
461462
requestParam.value = {};
462463
requestParam.value.pluginType = value
464+
requestParam.value.namespace = namespace;
463465
currentTemplate.value = getCurrentTemplate(requestParam.value.pluginType);
464466
}
465467
@@ -512,7 +514,8 @@ const deleteConfig = (row: stringMap, index: number) => {
512514
const toAddConfig = () => {
513515
const params = {
514516
type: "add",
515-
configType: configCenterInfo.dynamicConfigType
517+
configType: configCenterInfo.dynamicConfigType,
518+
namespace: configCenterInfo.namespace,
516519
};
517520
router.push({name: "configInfo", query: params});
518521
};

0 commit comments

Comments
 (0)