This is an automated email from the ASF dual-hosted git repository.
wusheng pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/skywalking-booster-ui.git
The following commit(s) were added to refs/heads/main by this push:
new d9064e8b fix: avoid querying data with empty parameters (#331)
d9064e8b is described below
commit d9064e8b45ae3a31b9606b63b4411d1ccdc7aa93
Author: Fine0830 <[email protected]>
AuthorDate: Mon Oct 23 10:37:43 2023 +0800
fix: avoid querying data with empty parameters (#331)
* fix: Avoid querying data with empty parameters
---
src/store/modules/topology.ts | 11 ++++++++++-
.../dashboard/related/topology/components/utils/layout.ts | 3 ++-
2 files changed, 12 insertions(+), 2 deletions(-)
diff --git a/src/store/modules/topology.ts b/src/store/modules/topology.ts
index 74bc7e15..6a12f252 100644
--- a/src/store/modules/topology.ts
+++ b/src/store/modules/topology.ts
@@ -191,6 +191,9 @@ export const topologyStore = defineStore({
}
},
async getServicesTopology(serviceIds: string[]) {
+ if (!serviceIds.length) {
+ return new Promise((resolve) => resolve({}));
+ }
const duration = useAppStoreWithOut().durationTime;
const res: AxiosResponse = await
graphql.query("getServicesTopology").params({
serviceIds,
@@ -207,7 +210,7 @@ export const topologyStore = defineStore({
const clientServiceId = (currentDestService && currentDestService.id) ||
"";
const duration = useAppStoreWithOut().durationTime;
if (!(serverServiceId && clientServiceId)) {
- return;
+ return new Promise((resolve) => resolve({}));
}
const res: AxiosResponse = await
graphql.query("getInstanceTopology").params({
clientServiceId,
@@ -220,6 +223,9 @@ export const topologyStore = defineStore({
return res.data;
},
async updateEndpointTopology(endpointIds: string[], depth: number) {
+ if (!endpointIds.length) {
+ return new Promise((resolve) => resolve({}));
+ }
const res = await this.getEndpointTopology(endpointIds);
if (depth > 1) {
const ids = res.nodes.map((item: Node) => item.id).filter((d: string)
=> !endpointIds.includes(d));
@@ -285,6 +291,9 @@ export const topologyStore = defineStore({
}
},
async getEndpointTopology(endpointIds: string[]) {
+ if (!endpointIds.length) {
+ return new Promise((resolve) => resolve({}));
+ }
const duration = useAppStoreWithOut().durationTime;
const variables = ["$duration: Duration!"];
const fragment = endpointIds.map((id: string, index: number) => {
diff --git a/src/views/dashboard/related/topology/components/utils/layout.ts
b/src/views/dashboard/related/topology/components/utils/layout.ts
index 0ac2e567..27b8073d 100644
--- a/src/views/dashboard/related/topology/components/utils/layout.ts
+++ b/src/views/dashboard/related/topology/components/utils/layout.ts
@@ -19,7 +19,8 @@ import type { Node, Call } from "@/types/topology";
export function layout(levels: Node[][], calls: Call[], radius: number) {
// precompute level depth
- levels.forEach((l: Node[], i: number) => l.forEach((n: any) => (n.level =
i)));
+ console.log(levels);
+ levels.forEach((l: Node[], i: number) => l.forEach((n: any) => n && (n.level
= i)));
const nodes: Node[] = levels.reduce((a, x) => a.concat(x), []);
// layout