feat: remove returnTypeOfMQE and add detail label (#277)

This commit is contained in:
Fine0830
2023-06-08 20:52:44 +08:00
committed by GitHub
parent 372aee2eb6
commit 54997794b4
16 changed files with 261 additions and 218 deletions

View File

@@ -96,6 +96,7 @@ limitations under the License. -->
intervalTime: { type: Array as PropType<string[]>, default: () => [] },
});
const emit = defineEmits(["expressionTips"]);
const { t } = useI18n();
const selectorStore = useSelectorStore();
const dashboardStore = useDashboardStore();
@@ -168,13 +169,12 @@ limitations under the License. -->
}
async function queryEndpointExpressions(currentPods: Endpoint[]) {
const expressions = props.config.expressions || [];
const typesOfMQE = props.config.typesOfMQE || [];
const subExpressions = props.config.subExpressions || [];
if (expressions.length && expressions[0] && typesOfMQE.length && typesOfMQE[0]) {
if (expressions.length && expressions[0]) {
const params = await useExpressionsQueryPodsMetrics(
currentPods,
{ ...props.config, metricConfig: metricConfig.value || [], typesOfMQE, expressions, subExpressions },
{ metricConfig: metricConfig.value || [], expressions, subExpressions },
EntityType[2].value,
);
endpoints.value = params.data;
@@ -182,6 +182,7 @@ limitations under the License. -->
metricTypes.value = params.metricTypesArr;
metricConfig.value = params.metricConfigArr;
colSubMetrics.value = params.colSubMetrics;
emit("expressionTips", { tips: params.expressionsTips, subTips: params.subExpressionsTips });
return;
}
@@ -190,6 +191,7 @@ limitations under the License. -->
colSubMetrics.value = [];
metricTypes.value = [];
metricConfig.value = [];
emit("expressionTips", [], []);
}
function clickEndpoint(scope: any) {
const { dashboard } = getDashboard({

View File

@@ -122,6 +122,7 @@ limitations under the License. -->
intervalTime: { type: Array as PropType<string[]>, default: () => [] },
needQuery: { type: Boolean, default: false },
});
const emit = defineEmits(["expressionTips"]);
const { t } = useI18n();
const selectorStore = useSelectorStore();
const dashboardStore = useDashboardStore();
@@ -193,6 +194,7 @@ limitations under the License. -->
colMetrics.value = names;
metricTypes.value = metricTypesArr;
metricConfig.value = metricConfigArr;
return;
}
instances.value = currentInstances;
@@ -203,13 +205,12 @@ limitations under the License. -->
async function queryInstanceExpressions(currentInstances: Instance[]) {
const expressions = props.config.expressions || [];
const typesOfMQE = props.config.typesOfMQE || [];
const subExpressions = props.config.subExpressions || [];
if (expressions.length && expressions[0] && typesOfMQE.length && typesOfMQE[0]) {
if (expressions.length && expressions[0]) {
const params = await useExpressionsQueryPodsMetrics(
currentInstances,
{ ...props.config, metricConfig: metricConfig.value || [], typesOfMQE, expressions, subExpressions },
{ metricConfig: metricConfig.value || [], expressions, subExpressions },
EntityType[3].value,
);
instances.value = params.data;
@@ -217,6 +218,7 @@ limitations under the License. -->
colSubMetrics.value = params.colSubMetrics;
metricTypes.value = params.metricTypesArr;
metricConfig.value = params.metricConfigArr;
emit("expressionTips", { tips: params.expressionsTips, subTips: params.subExpressionsTips });
return;
}
@@ -225,6 +227,7 @@ limitations under the License. -->
colMetrics.value = [];
metricTypes.value = [];
metricConfig.value = [];
emit("expressionTips", [], []);
}
function clickInstance(scope: any) {

View File

@@ -114,6 +114,7 @@ limitations under the License. -->
intervalTime: { type: Array as PropType<string[]>, default: () => [] },
isEdit: { type: Boolean, default: false },
});
const emit = defineEmits(["expressionTips"]);
const selectorStore = useSelectorStore();
const dashboardStore = useDashboardStore();
const appStore = useAppStoreWithOut();
@@ -251,13 +252,12 @@ limitations under the License. -->
}
async function queryServiceExpressions(currentServices: Service[]) {
const expressions = props.config.expressions || [];
const typesOfMQE = props.config.typesOfMQE || [];
const subExpressions = props.config.subExpressions || [];
if (expressions.length && expressions[0] && typesOfMQE.length && typesOfMQE[0]) {
if (expressions.length && expressions[0]) {
const params = await useExpressionsQueryPodsMetrics(
currentServices,
{ ...props.config, metricConfig: metricConfig.value || [], typesOfMQE, expressions, subExpressions },
{ metricConfig: metricConfig.value || [], expressions, subExpressions },
EntityType[0].value,
);
services.value = params.data;
@@ -265,6 +265,7 @@ limitations under the License. -->
colSubMetrics.value = params.subNames;
metricTypes.value = params.metricTypesArr;
metricConfig.value = params.metricConfigArr;
emit("expressionTips", { tips: params.expressionsTips, subTips: params.subExpressionsTips });
return;
}
services.value = currentServices;
@@ -272,6 +273,7 @@ limitations under the License. -->
colSubMetrics.value = [];
metricTypes.value = [];
metricConfig.value = [];
emit("expressionTips", [], []);
}
function objectSpanMethod(param: any): any {
if (!props.config.showGroup) {

View File

@@ -48,7 +48,7 @@ limitations under the License. -->
<div class="view-line">
<Line
:data="{
[colSubMetrics[index] || metric]:
[decodeURIComponent(getLabel(colSubMetrics[index], index, true)) || metric]:
scope.row[colSubMetrics[index] || metric] && scope.row[colSubMetrics[index] || metric].values,
}"
:intervalTime="intervalTime"
@@ -109,9 +109,15 @@ limitations under the License. -->
}
return encodeURIComponent("");
}
function getLabel(metric: string, index: number) {
function getLabel(metric: string, index: number, isDetail?: boolean) {
const i = Number(index);
const label = props.config.metricConfig && props.config.metricConfig[i] && props.config.metricConfig[i].label;
let label = "";
if (isDetail) {
label =
(props.config.metricConfig && props.config.metricConfig[i] && props.config.metricConfig[i].detailLabel) || "";
} else {
label = (props.config.metricConfig && props.config.metricConfig[i] && props.config.metricConfig[i].label) || "";
}
if (label) {
if (
(
@@ -129,7 +135,7 @@ limitations under the License. -->
}
return encodeURIComponent(label);
}
return encodeURIComponent(metric);
return encodeURIComponent(metric || "");
}
</script>
<style lang="scss" scoped>