feat: update legend expressions

This commit is contained in:
Fine 2023-08-22 16:14:21 +08:00
parent 2d5f004ca2
commit 67951a346c
3 changed files with 47 additions and 28 deletions

View File

@ -358,7 +358,7 @@ export function useQueryTopologyExpressionsProcessor(metrics: string[], instance
serviceInstanceName, serviceInstanceName,
endpointName, endpointName,
destServiceName, destServiceName,
destNormal: true, destNormal: destServiceName ? true : undefined,
destServiceInstanceName, destServiceInstanceName,
destEndpointName, destEndpointName,
}; };

View File

@ -397,6 +397,13 @@ limitations under the License. -->
if (!legend.length) { if (!legend.length) {
return icons.CUBE; return icons.CUBE;
} }
if (settings.value.metricMode === MetricModes.Expression) {
let c = true;
for (const l of legend) {
c = c && !!Number(d[l.name]);
}
return c && d.isReal ? icons.CUBEERROR : icons.CUBE;
}
let c = true; let c = true;
for (const l of legend) { for (const l of legend) {
if (l.condition === "<") { if (l.condition === "<") {

View File

@ -204,10 +204,10 @@ limitations under the License. -->
placeholder="Please input a expression" placeholder="Please input a expression"
@change="changeLegend(LegendOpt.NAME, $event, index)" @change="changeLegend(LegendOpt.NAME, $event, index)"
size="small" size="small"
class="item" class="legend-inputs"
/> />
<span v-else>
<Selector <Selector
v-else
class="item" class="item"
:value="metric.name" :value="metric.name"
:options="states.nodeMetricList" :options="states.nodeMetricList"
@ -231,6 +231,7 @@ limitations under the License. -->
size="small" size="small"
class="item" class="item"
/> />
</span>
<span> <span>
<Icon class="cp delete" iconName="remove_circle_outline" size="middle" @click="deleteMetric(index)" /> <Icon class="cp delete" iconName="remove_circle_outline" size="middle" @click="deleteMetric(index)" />
<Icon <Icon
@ -439,7 +440,13 @@ limitations under the License. -->
updateSettings(); updateSettings();
} }
function updateSettings(metricConfig?: { [key: string]: MetricConfigOpt[] }) { function updateSettings(metricConfig?: { [key: string]: MetricConfigOpt[] }) {
const metrics = legend.value.filter((d: any) => d.name && d.value && d.condition); let metrics = [];
if (isExpression.value) {
metrics = legend.value.filter((d: any) => d.name);
} else {
metrics = legend.value.filter((d: any) => d.name && d.value && d.condition);
}
const param = { const param = {
...dashboardStore.selectedGrid, ...dashboardStore.selectedGrid,
linkDashboard: states.linkDashboard, linkDashboard: states.linkDashboard,
@ -600,6 +607,11 @@ limitations under the License. -->
width: 355px; width: 355px;
} }
.legend-inputs {
margin-top: 8px;
width: 310px;
}
.item { .item {
width: 130px; width: 130px;
margin-top: 5px; margin-top: 5px;