Skip to content

Commit

Permalink
Fix Value Mappings (#423)
Browse files Browse the repository at this point in the history
  • Loading branch information
Fine0830 authored Oct 18, 2024
1 parent 0007e3e commit 4c60f69
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ limitations under the License. -->
<template>
<div>
<span class="label">{{ t("valueMappings") }}</span>
<span class="label red">({{ t("mappingTip") }})</span>
<span class="label red">{{ t("mappingTip") }}</span>
</div>
<div v-for="(key, index) in keys" :key="index" class="mb-10 flex-h">
<div class="content-decoration" contenteditable="true" @blur="changeKeys($event, index)">
Expand Down Expand Up @@ -56,6 +56,9 @@ limitations under the License. -->
}
delete valueMappings.value[list[index]];
keys.value = Object.keys(valueMappings.value);
if (!keys.value.length) {
keys.value = [""];
}
updateConfig();
}

Expand Down Expand Up @@ -87,7 +90,7 @@ limitations under the License. -->
</script>
<style lang="scss" scoped>
.content-decoration {
width: 200px;
width: 350px;
border: 1px solid $border-color;
cursor: text;
padding: 0 5px;
Expand Down
10 changes: 8 additions & 2 deletions src/views/dashboard/graphs/Card.vue
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ limitations under the License. -->
import type { PropType } from "vue";
import { useI18n } from "vue-i18n";
import type { CardConfig, MetricConfigOpt } from "@/types/dashboard";
import { ElMessage } from "element-plus";

/*global defineProps */
const props = defineProps({
Expand Down Expand Up @@ -67,8 +68,13 @@ limitations under the License. -->
}
const list = Object.keys(valueMappings.value);
for (const i of list) {
if (new RegExp(i).test(String(singleVal.value))) {
return valueMappings.value[i] || singleVal.value;
try {
if (new RegExp(i).test(String(singleVal.value))) {
return valueMappings.value[i] || singleVal.value;
}
} catch (e) {
ElMessage.error("invalid regex string");
return singleVal.value;
}
}
return singleVal.value;
Expand Down
11 changes: 9 additions & 2 deletions src/views/dashboard/graphs/Table.vue
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,8 @@ limitations under the License. -->
import { computed } from "vue";
import type { PropType } from "vue";
import { useI18n } from "vue-i18n";
import { ElMessage } from "element-plus";

/*global defineProps */
const props = defineProps({
data: {
Expand Down Expand Up @@ -83,8 +85,13 @@ limitations under the License. -->
}
const list = Object.keys(valueMappings.value);
for (const i of list) {
if (new RegExp(i).test(String(source))) {
return valueMappings.value[i] || source;
try {
if (new RegExp(i).test(String(source))) {
return valueMappings.value[i] || source;
}
} catch (e) {
ElMessage.error("invalid regex string");
return source;
}
}
return source;
Expand Down

0 comments on commit 4c60f69

Please sign in to comment.