mirror of
https://github.com/apache/skywalking-booster-ui.git
synced 2025-10-15 04:09:14 +00:00
feat: support ranges for Value Mappings (#421)
This commit is contained in:
@@ -22,7 +22,7 @@ limitations under the License. -->
|
||||
justifyContent: config.textAlign || 'center',
|
||||
}"
|
||||
>
|
||||
{{ decorations[singleVal] || singleVal }}
|
||||
{{ getValue() }}
|
||||
<span class="unit" v-show="config.showUnit && unit">
|
||||
{{ decodeURIComponent(unit) }}
|
||||
</span>
|
||||
@@ -48,18 +48,31 @@ limitations under the License. -->
|
||||
showUnit: true,
|
||||
textAlign: "center",
|
||||
metricConfig: [],
|
||||
decorations: {},
|
||||
valueMappings: {},
|
||||
}),
|
||||
},
|
||||
});
|
||||
const { t } = useI18n();
|
||||
const metricConfig = computed(() => props.config.metricConfig || []);
|
||||
const decorations = computed(() => props.config.decorations || {});
|
||||
const valueMappings = computed(() => props.config.valueMappings || {});
|
||||
const key = computed(() => Object.keys(props.data)[0]);
|
||||
const singleVal = computed(() =>
|
||||
Array.isArray(props.data[key.value]) ? props.data[key.value][0] : props.data[key.value],
|
||||
);
|
||||
const unit = computed(() => metricConfig.value[0] && encodeURIComponent(metricConfig.value[0].unit || ""));
|
||||
|
||||
function getValue() {
|
||||
if (valueMappings.value[singleVal.value]) {
|
||||
return valueMappings.value[singleVal.value];
|
||||
}
|
||||
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;
|
||||
}
|
||||
}
|
||||
return singleVal.value;
|
||||
}
|
||||
</script>
|
||||
<style lang="scss" scoped>
|
||||
.chart-card {
|
||||
|
@@ -58,14 +58,14 @@ limitations under the License. -->
|
||||
showTableValues: boolean;
|
||||
tableHeaderCol2: string;
|
||||
typesOfMQE: string[];
|
||||
decorations: {};
|
||||
valueMappings: {};
|
||||
}>,
|
||||
default: () => ({ showTableValues: true }),
|
||||
},
|
||||
});
|
||||
|
||||
const { t } = useI18n();
|
||||
const decorations = computed<{ [key: number]: string }>(() => props.config.decorations || {});
|
||||
const valueMappings = computed<{ [key: string]: string }>(() => props.config.valueMappings || {});
|
||||
const nameWidth = computed(() => (props.config.showTableValues ? 80 : 100));
|
||||
const dataKeys = computed(() => {
|
||||
const keys = Object.keys(props.data || {}).filter(
|
||||
@@ -75,9 +75,19 @@ limitations under the License. -->
|
||||
|
||||
return list;
|
||||
});
|
||||
|
||||
function getColValue(keys: string[]) {
|
||||
const val = props.data[(keys as string[]).join(",")][props.data[(keys as string[]).join(",")].length - 1 || 0];
|
||||
return decorations.value[val] || val;
|
||||
const source = props.data[(keys as string[]).join(",")][props.data[(keys as string[]).join(",")].length - 1 || 0];
|
||||
if (valueMappings.value[source]) {
|
||||
return valueMappings.value[source];
|
||||
}
|
||||
const list = Object.keys(valueMappings.value);
|
||||
for (const i of list) {
|
||||
if (new RegExp(i).test(String(source))) {
|
||||
return valueMappings.value[i] || source;
|
||||
}
|
||||
}
|
||||
return source;
|
||||
}
|
||||
</script>
|
||||
<style lang="scss" scoped>
|
||||
|
Reference in New Issue
Block a user