fix: update

This commit is contained in:
Fine 2023-06-03 20:32:15 +08:00
parent db7de72417
commit 2a0f6dfae2
2 changed files with 14 additions and 2 deletions

View File

@ -199,10 +199,22 @@ export async function useExpressionsQueryPodsMetrics(
const metricConfigArr: MetricConfigOpt[] = []; const metricConfigArr: MetricConfigOpt[] = [];
const metricTypesArr: string[] = []; const metricTypesArr: string[] = [];
const data = pods.map((d: any, idx: number) => { const data = pods.map((d: any, idx: number) => {
const map: any = {};
for (let index = 0; index < config.expressions.length; index++) { for (let index = 0; index < config.expressions.length; index++) {
const c: any = (config.metricConfig && config.metricConfig[index]) || {}; let c: any = (config.metricConfig && config.metricConfig[index]) || {};
const k = "expression" + idx + index; const k = "expression" + idx + index;
const results = (resp.data[k] && resp.data[k].results) || []; const results = (resp.data[k] && resp.data[k].results) || [];
const n = results[0] && results[0].metric.name;
if (map[n]) {
map[n] = {
...c,
...map[n],
};
c = map[n];
} else {
map[n] = c;
}
if (results.length > 1) { if (results.length > 1) {
const labels = (c.label || "").split(",").map((item: string) => item.replace(/^\s*|\s*$/g, "")); const labels = (c.label || "").split(",").map((item: string) => item.replace(/^\s*|\s*$/g, ""));
const labelsIdx = (c.labelsIndex || "").split(",").map((item: string) => item.replace(/^\s*|\s*$/g, "")); const labelsIdx = (c.labelsIndex || "").split(",").map((item: string) => item.replace(/^\s*|\s*$/g, ""));

View File

@ -209,7 +209,7 @@ limitations under the License. -->
.render-chart { .render-chart {
padding: 5px; padding: 5px;
height: 400px; height: 420px;
width: 100%; width: 100%;
} }