This commit is contained in:
Fine 2024-10-17 22:48:21 +08:00
parent c412908c4b
commit 437081c1b6
8 changed files with 21 additions and 8 deletions

View File

@ -387,5 +387,6 @@ const msg = {
hierarchyNodeMetrics: "Metrics for Hierarchy Graph Node", hierarchyNodeMetrics: "Metrics for Hierarchy Graph Node",
hierarchyNodeDashboard: "As dashboard for Hierarchy Graph Node", hierarchyNodeDashboard: "As dashboard for Hierarchy Graph Node",
valueMappings: "Value Mappings", valueMappings: "Value Mappings",
mappingTip: "Notice: The mapping key is like (-∞, 2] or [4, 10)",
}; };
export default msg; export default msg;

View File

@ -387,5 +387,6 @@ const msg = {
hierarchyNodeMetrics: "Metrics for Hierarchy Graph Node", hierarchyNodeMetrics: "Metrics for Hierarchy Graph Node",
hierarchyNodeDashboard: "As dashboard for Hierarchy Graph Node", hierarchyNodeDashboard: "As dashboard for Hierarchy Graph Node",
valueMappings: "Value Mappings", valueMappings: "Value Mappings",
mappingTip: "Notice: The mapping key is like (-∞, 2] or [4, 10)",
}; };
export default msg; export default msg;

View File

@ -385,5 +385,6 @@ const msg = {
hierarchyNodeMetrics: "层次图节点的指标", hierarchyNodeMetrics: "层次图节点的指标",
hierarchyNodeDashboard: "作为层次图节点的dashboard", hierarchyNodeDashboard: "作为层次图节点的dashboard",
valueMappings: "值映射", valueMappings: "值映射",
mappingTip: "注意: 映射键如 (-∞, 2] 或者 [4, 10)",
}; };
export default msg; export default msg;

View File

@ -14,7 +14,6 @@ See the License for the specific language governing permissions and
limitations under the License. --> limitations under the License. -->
<template> <template>
<div> <div>
<span class="label">{{ t("valueMappings") }}</span>
<value-mappings /> <value-mappings />
</div> </div>
<div> <div>

View File

@ -14,7 +14,6 @@ See the License for the specific language governing permissions and
limitations under the License. --> limitations under the License. -->
<template> <template>
<div> <div>
<span class="label">{{ t("valueMappings") }}</span>
<value-mappings /> <value-mappings />
</div> </div>
<div class="item"> <div class="item">

View File

@ -13,6 +13,10 @@ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and See the License for the specific language governing permissions and
limitations under the License. --> limitations under the License. -->
<template> <template>
<div>
<span class="label">{{ t("valueMappings") }}</span>
<span class="label red">({{ t("mappingTip") }})</span>
</div>
<div v-for="(key, index) in keys" :key="index" class="mb-10 flex-h"> <div v-for="(key, index) in keys" :key="index" class="mb-10 flex-h">
<div class="content-decoration" contenteditable="true" @blur="changeKeys($event, index)"> <div class="content-decoration" contenteditable="true" @blur="changeKeys($event, index)">
{{ key }} {{ key }}
@ -36,7 +40,9 @@ limitations under the License. -->
<script lang="ts" setup> <script lang="ts" setup>
import { ref } from "vue"; import { ref } from "vue";
import { useDashboardStore } from "@/store/modules/dashboard"; import { useDashboardStore } from "@/store/modules/dashboard";
import { useI18n } from "vue-i18n";
const { t } = useI18n();
const dashboardStore = useDashboardStore(); const dashboardStore = useDashboardStore();
const graph = dashboardStore.selectedGrid.graph; const graph = dashboardStore.selectedGrid.graph;
const valueMappings = ref<{ [key: string]: string }>(graph?.valueMappings || {}); const valueMappings = ref<{ [key: string]: string }>(graph?.valueMappings || {});
@ -94,4 +100,10 @@ limitations under the License. -->
border-color: $active-color; border-color: $active-color;
} }
} }
.label {
font-size: 13px;
font-weight: 500;
padding-right: 10px;
}
</style> </style>

View File

@ -72,14 +72,14 @@ limitations under the License. -->
let withinRange = false; let withinRange = false;
const ranges = k.match(regex)?.map(Number) || []; const ranges = k.match(regex)?.map(Number) || [];
if (k.startsWith("[")) { if (k.startsWith("[")) {
withinRange = k.startsWith("[-∞") || Number(singleVal.value) >= ranges[0]; withinRange = Number(singleVal.value) >= ranges[0];
} else { } else {
withinRange = k.startsWith("(-∞") || Number(singleVal.value) > ranges[0]; withinRange = k.startsWith("(-∞") || Number(singleVal.value) > ranges[0];
} }
if (k.endsWith("]")) { if (k.endsWith("]")) {
withinRange = withinRange && (k.endsWith("+∞]") || Number(singleVal.value) <= (ranges[1] || ranges[0])); withinRange = withinRange && Number(singleVal.value) <= (ranges[1] || ranges[0]);
} else { } else {
withinRange = withinRange && (k.endsWith("+∞)") || Number(singleVal.value) < (ranges[1] || ranges[0])); withinRange = withinRange && (k.endsWith("∞)") || Number(singleVal.value) < (ranges[1] || ranges[0]));
} }
if (withinRange) { if (withinRange) {
return valueMappings.value[i] || singleVal.value; return valueMappings.value[i] || singleVal.value;

View File

@ -88,14 +88,14 @@ limitations under the License. -->
let withinRange = false; let withinRange = false;
const ranges = k.match(regex)?.map(Number) || []; const ranges = k.match(regex)?.map(Number) || [];
if (k.startsWith("[")) { if (k.startsWith("[")) {
withinRange = k.startsWith("[-∞") || Number(source) >= ranges[0]; withinRange = Number(source) >= ranges[0];
} else { } else {
withinRange = k.startsWith("(-∞") || Number(source) > ranges[0]; withinRange = k.startsWith("(-∞") || Number(source) > ranges[0];
} }
if (k.endsWith("]")) { if (k.endsWith("]")) {
withinRange = withinRange && (k.endsWith("+∞]") || Number(source) <= (ranges[1] || ranges[0])); withinRange = withinRange && Number(source) <= (ranges[1] || ranges[0]);
} else { } else {
withinRange = withinRange && (k.endsWith("+∞)") || Number(source) < (ranges[1] || ranges[0])); withinRange = withinRange && (k.endsWith("∞)") || Number(source) < (ranges[1] || ranges[0]));
} }
if (withinRange) { if (withinRange) {
return valueMappings.value[i]; return valueMappings.value[i];