mirror of
https://github.com/apache/skywalking-booster-ui.git
synced 2025-07-18 03:25:25 +00:00
use regex string
This commit is contained in:
parent
94eee7861a
commit
af99c7462f
@ -387,6 +387,6 @@ const msg = {
|
||||
hierarchyNodeMetrics: "Metrics for Hierarchy Graph Node",
|
||||
hierarchyNodeDashboard: "As dashboard for Hierarchy Graph Node",
|
||||
valueMappings: "Value Mappings",
|
||||
mappingTip: "Notice: The mapping key is like (-∞, 2] or [4, 10)",
|
||||
mappingTip: "Notice: The mapping key is a Regex string",
|
||||
};
|
||||
export default msg;
|
||||
|
@ -387,6 +387,6 @@ const msg = {
|
||||
hierarchyNodeMetrics: "Metrics for Hierarchy Graph Node",
|
||||
hierarchyNodeDashboard: "As dashboard for Hierarchy Graph Node",
|
||||
valueMappings: "Value Mappings",
|
||||
mappingTip: "Notice: The mapping key is like (-∞, 2] or [4, 10)",
|
||||
mappingTip: "Notice: The mapping key is a Regex string",
|
||||
};
|
||||
export default msg;
|
||||
|
@ -385,6 +385,6 @@ const msg = {
|
||||
hierarchyNodeMetrics: "层次图节点的指标",
|
||||
hierarchyNodeDashboard: "作为层次图节点的dashboard",
|
||||
valueMappings: "值映射",
|
||||
mappingTip: "注意: 映射键如 (-∞, 2] 或者 [4, 10)",
|
||||
mappingTip: "注意: 映射键是一个正则表达式字符串",
|
||||
};
|
||||
export default msg;
|
||||
|
@ -65,23 +65,9 @@ limitations under the License. -->
|
||||
if (valueMappings.value[singleVal.value]) {
|
||||
return valueMappings.value[singleVal.value];
|
||||
}
|
||||
const regex = /-?\d+(\.\d+)?/g;
|
||||
const list = Object.keys(valueMappings.value);
|
||||
for (const i of list) {
|
||||
const k = i.replace(/\s+/g, "");
|
||||
let withinRange = false;
|
||||
const ranges = k.match(regex)?.map(Number) || [];
|
||||
if (k.startsWith("[")) {
|
||||
withinRange = Number(singleVal.value) >= ranges[0];
|
||||
} else {
|
||||
withinRange = k.startsWith("(-∞") || Number(singleVal.value) > ranges[0];
|
||||
}
|
||||
if (k.endsWith("]")) {
|
||||
withinRange = withinRange && Number(singleVal.value) <= (ranges[1] || ranges[0]);
|
||||
} else {
|
||||
withinRange = withinRange && (k.endsWith("∞)") || Number(singleVal.value) < (ranges[1] || ranges[0]));
|
||||
}
|
||||
if (withinRange) {
|
||||
if (new RegExp(i).test(String(singleVal.value))) {
|
||||
return valueMappings.value[i] || singleVal.value;
|
||||
}
|
||||
}
|
||||
|
@ -81,24 +81,10 @@ limitations under the License. -->
|
||||
if (valueMappings.value[source]) {
|
||||
return valueMappings.value[source];
|
||||
}
|
||||
const regex = /-?\d+(\.\d+)?/g;
|
||||
const list = Object.keys(valueMappings.value);
|
||||
for (const i of list) {
|
||||
const k = i.replace(/\s+/g, "");
|
||||
let withinRange = false;
|
||||
const ranges = k.match(regex)?.map(Number) || [];
|
||||
if (k.startsWith("[")) {
|
||||
withinRange = Number(source) >= ranges[0];
|
||||
} else {
|
||||
withinRange = k.startsWith("(-∞") || Number(source) > ranges[0];
|
||||
}
|
||||
if (k.endsWith("]")) {
|
||||
withinRange = withinRange && Number(source) <= (ranges[1] || ranges[0]);
|
||||
} else {
|
||||
withinRange = withinRange && (k.endsWith("∞)") || Number(source) < (ranges[1] || ranges[0]));
|
||||
}
|
||||
if (withinRange) {
|
||||
return valueMappings.value[i];
|
||||
if (new RegExp(i).test(String(source))) {
|
||||
return valueMappings.value[i] || source;
|
||||
}
|
||||
}
|
||||
return source;
|
||||
|
Loading…
Reference in New Issue
Block a user