mirror of
https://github.com/apache/skywalking-booster-ui.git
synced 2025-05-01 18:23:39 +00:00
feat: set a maximum 20 entities per query in service/instance/endpoint list widgets (#406)
This commit is contained in:
parent
4e00073ec2
commit
6b2b6a5dd2
@ -14,6 +14,7 @@
|
|||||||
* See the License for the specific language governing permissions and
|
* See the License for the specific language governing permissions and
|
||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
export const MaximumEntities = 20;
|
||||||
|
|
||||||
export enum sizeEnum {
|
export enum sizeEnum {
|
||||||
XS = "XS",
|
XS = "XS",
|
||||||
|
@ -14,7 +14,7 @@
|
|||||||
* See the License for the specific language governing permissions and
|
* See the License for the specific language governing permissions and
|
||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
import { RespFields } from "./data";
|
import { RespFields, MaximumEntities } from "./data";
|
||||||
import { EntityType, ExpressionResultType } from "@/views/dashboard/data";
|
import { EntityType, ExpressionResultType } from "@/views/dashboard/data";
|
||||||
import { ElMessage } from "element-plus";
|
import { ElMessage } from "element-plus";
|
||||||
import { useDashboardStore } from "@/store/modules/dashboard";
|
import { useDashboardStore } from "@/store/modules/dashboard";
|
||||||
@ -156,7 +156,7 @@ export async function useExpressionsQueryProcessor(config: Indexable) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export async function useExpressionsQueryPodsMetrics(
|
export async function useExpressionsQueryPodsMetrics(
|
||||||
pods: Array<(Instance | Endpoint | Service) & Indexable>,
|
allPods: Array<(Instance | Endpoint | Service) & Indexable>,
|
||||||
config: {
|
config: {
|
||||||
expressions: string[];
|
expressions: string[];
|
||||||
subExpressions: string[];
|
subExpressions: string[];
|
||||||
@ -164,7 +164,7 @@ export async function useExpressionsQueryPodsMetrics(
|
|||||||
},
|
},
|
||||||
scope: string,
|
scope: string,
|
||||||
) {
|
) {
|
||||||
function expressionsGraphqlPods() {
|
function expressionsGraphqlPods(pods: Array<(Instance | Endpoint | Service) & Indexable>) {
|
||||||
const metrics: string[] = [];
|
const metrics: string[] = [];
|
||||||
const subMetrics: string[] = [];
|
const subMetrics: string[] = [];
|
||||||
config.expressions = config.expressions || [];
|
config.expressions = config.expressions || [];
|
||||||
@ -196,18 +196,22 @@ export async function useExpressionsQueryPodsMetrics(
|
|||||||
variables.push(`$entity${index}: Entity!`);
|
variables.push(`$entity${index}: Entity!`);
|
||||||
conditions[`entity${index}`] = entity;
|
conditions[`entity${index}`] = entity;
|
||||||
const f = metrics.map((name: string, idx: number) => {
|
const f = metrics.map((name: string, idx: number) => {
|
||||||
variables.push(`$expression${index}${idx}: String!`);
|
if (index === 0) {
|
||||||
conditions[`expression${index}${idx}`] = name;
|
variables.push(`$expression${idx}: String!`);
|
||||||
|
conditions[`expression${idx}`] = name;
|
||||||
|
}
|
||||||
let str = "";
|
let str = "";
|
||||||
if (config.subExpressions[idx]) {
|
if (config.subExpressions[idx]) {
|
||||||
variables.push(`$subExpression${index}${idx}: String!`);
|
if (index === 0) {
|
||||||
conditions[`subExpression${index}${idx}`] = config.subExpressions[idx];
|
variables.push(`$subExpression${idx}: String!`);
|
||||||
str = `subexpression${index}${idx}: execExpression(expression: $subExpression${index}${idx}, entity: $entity${index}, duration: $duration)${RespFields.execExpression}`;
|
conditions[`subExpression${idx}`] = config.subExpressions[idx];
|
||||||
|
}
|
||||||
|
str = `subexpression${index}${idx}: execExpression(expression: $subExpression${idx}, entity: $entity${index}, duration: $duration)${RespFields.execExpression}`;
|
||||||
}
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
str +
|
str +
|
||||||
`expression${index}${idx}: execExpression(expression: $expression${index}${idx}, entity: $entity${index}, duration: $duration)${RespFields.execExpression}`
|
`expression${index}${idx}: execExpression(expression: $expression${idx}, entity: $entity${index}, duration: $duration)${RespFields.execExpression}`
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
return f;
|
return f;
|
||||||
@ -218,7 +222,10 @@ export async function useExpressionsQueryPodsMetrics(
|
|||||||
return { queryStr, conditions };
|
return { queryStr, conditions };
|
||||||
}
|
}
|
||||||
|
|
||||||
function expressionsPodsSource(resp: { errors: string; data: Indexable }): Indexable {
|
function expressionsPodsSource(
|
||||||
|
resp: { errors: string; data: Indexable },
|
||||||
|
pods: Array<(Instance | Endpoint | Service) & Indexable>,
|
||||||
|
): Indexable {
|
||||||
if (resp.errors) {
|
if (resp.errors) {
|
||||||
ElMessage.error(resp.errors);
|
ElMessage.error(resp.errors);
|
||||||
return {};
|
return {};
|
||||||
@ -300,17 +307,39 @@ export async function useExpressionsQueryPodsMetrics(
|
|||||||
return { data, names, subNames, metricConfigArr, metricTypesArr, expressionsTips, subExpressionsTips };
|
return { data, names, subNames, metricConfigArr, metricTypesArr, expressionsTips, subExpressionsTips };
|
||||||
}
|
}
|
||||||
|
|
||||||
const dashboardStore = useDashboardStore();
|
async function fetchPodsExpressionValues(pods: Array<(Instance | Endpoint | Service) & Indexable>) {
|
||||||
const params = await expressionsGraphqlPods();
|
const dashboardStore = useDashboardStore();
|
||||||
const json = await dashboardStore.fetchMetricValue(params);
|
const params = await expressionsGraphqlPods(pods);
|
||||||
|
|
||||||
if (json.errors) {
|
const json = await dashboardStore.fetchMetricValue(params);
|
||||||
ElMessage.error(json.errors);
|
|
||||||
return {};
|
if (json.errors) {
|
||||||
|
ElMessage.error(json.errors);
|
||||||
|
return {};
|
||||||
|
}
|
||||||
|
const expressionParams = expressionsPodsSource(json, pods);
|
||||||
|
|
||||||
|
return expressionParams;
|
||||||
}
|
}
|
||||||
const expressionParams = expressionsPodsSource(json);
|
|
||||||
|
|
||||||
return expressionParams;
|
const result = [];
|
||||||
|
for (let i = 0; i < allPods.length; i += MaximumEntities) {
|
||||||
|
result.push(allPods.slice(i, i + MaximumEntities));
|
||||||
|
}
|
||||||
|
const promiseArr = result.map((d: Array<(Instance | Endpoint | Service) & Indexable>) =>
|
||||||
|
fetchPodsExpressionValues(d),
|
||||||
|
);
|
||||||
|
const responseList = await Promise.all(promiseArr);
|
||||||
|
let resp: Indexable = { data: [], expressionsTips: [], subExpressionsTips: [] };
|
||||||
|
for (const item of responseList) {
|
||||||
|
resp = {
|
||||||
|
...item,
|
||||||
|
data: [...resp.data, ...item.data],
|
||||||
|
expressionsTips: [...resp.expressionsTips, ...item.expressionsTips],
|
||||||
|
subExpressionsTips: [...resp.subExpressionsTips, ...item.subExpressionsTips],
|
||||||
|
};
|
||||||
|
}
|
||||||
|
return resp;
|
||||||
}
|
}
|
||||||
|
|
||||||
export function useQueryTopologyExpressionsProcessor(metrics: string[], instances: (Call | Node)[]) {
|
export function useQueryTopologyExpressionsProcessor(metrics: string[], instances: (Call | Node)[]) {
|
||||||
|
Loading…
Reference in New Issue
Block a user