mirror of
https://github.com/apache/skywalking-booster-ui.git
synced 2025-07-18 20:44:08 +00:00
feat: query topology
This commit is contained in:
parent
491bf88063
commit
c7323a7e69
@ -17,7 +17,7 @@
|
|||||||
export const ServiceTopology = {
|
export const ServiceTopology = {
|
||||||
variable: "$duration: Duration!, $serviceId: ID!",
|
variable: "$duration: Duration!, $serviceId: ID!",
|
||||||
query: `
|
query: `
|
||||||
topo: getServiceTopology(duration: $duration, serviceId: $serviceId) {
|
topology: getServiceTopology(duration: $duration, serviceId: $serviceId) {
|
||||||
nodes {
|
nodes {
|
||||||
id
|
id
|
||||||
name
|
name
|
||||||
@ -37,7 +37,7 @@ export const ServiceTopology = {
|
|||||||
export const GlobalTopology = {
|
export const GlobalTopology = {
|
||||||
variable: "$duration: Duration!",
|
variable: "$duration: Duration!",
|
||||||
query: `
|
query: `
|
||||||
topo: getGlobalTopology(duration: $duration) {
|
topology: getGlobalTopology(duration: $duration) {
|
||||||
nodes {
|
nodes {
|
||||||
id
|
id
|
||||||
name
|
name
|
||||||
@ -57,7 +57,7 @@ export const GlobalTopology = {
|
|||||||
export const ServicesTopology = {
|
export const ServicesTopology = {
|
||||||
variable: "$duration: Duration!, $serviceIds: [ID!]!",
|
variable: "$duration: Duration!, $serviceIds: [ID!]!",
|
||||||
query: `
|
query: `
|
||||||
topo: getServicesTopology(duration: $duration, serviceIds: $serviceIds) {
|
topology: getServicesTopology(duration: $duration, serviceIds: $serviceIds) {
|
||||||
nodes {
|
nodes {
|
||||||
id
|
id
|
||||||
name
|
name
|
||||||
@ -77,7 +77,7 @@ export const ServicesTopology = {
|
|||||||
export const EndpointTopology = {
|
export const EndpointTopology = {
|
||||||
variable: ["$endpointId: ID!", "$duration: Duration!"],
|
variable: ["$endpointId: ID!", "$duration: Duration!"],
|
||||||
query: `
|
query: `
|
||||||
endpointTopology: getEndpointDependencies(endpointId: $endpointId, duration: $duration) {
|
topology: getEndpointDependencies(endpointId: $endpointId, duration: $duration) {
|
||||||
nodes {
|
nodes {
|
||||||
id
|
id
|
||||||
name
|
name
|
||||||
@ -98,7 +98,7 @@ export const InstanceTopology = {
|
|||||||
variable:
|
variable:
|
||||||
"$clientServiceId: ID!, $serverServiceId: ID!, $duration: Duration!",
|
"$clientServiceId: ID!, $serverServiceId: ID!, $duration: Duration!",
|
||||||
query: `
|
query: `
|
||||||
topo: getServiceInstanceTopology(clientServiceId: $clientServiceId,
|
topology: getServiceInstanceTopology(clientServiceId: $clientServiceId,
|
||||||
serverServiceId: $serverServiceId, duration: $duration) {
|
serverServiceId: $serverServiceId, duration: $duration) {
|
||||||
nodes {
|
nodes {
|
||||||
id
|
id
|
||||||
|
@ -19,8 +19,14 @@ import { cancelToken } from "@/utils/cancelToken";
|
|||||||
import * as app from "./query/app";
|
import * as app from "./query/app";
|
||||||
import * as selector from "./query/selector";
|
import * as selector from "./query/selector";
|
||||||
import * as dashboard from "./query/dashboard";
|
import * as dashboard from "./query/dashboard";
|
||||||
|
import * as topology from "./query/topology";
|
||||||
|
|
||||||
const query: { [key: string]: string } = { ...app, ...selector, ...dashboard };
|
const query: { [key: string]: string } = {
|
||||||
|
...app,
|
||||||
|
...selector,
|
||||||
|
...dashboard,
|
||||||
|
...topology,
|
||||||
|
};
|
||||||
class Graph {
|
class Graph {
|
||||||
private queryData = "";
|
private queryData = "";
|
||||||
public query(queryData: string) {
|
public query(queryData: string) {
|
||||||
|
@ -17,6 +17,10 @@
|
|||||||
import { defineStore } from "pinia";
|
import { defineStore } from "pinia";
|
||||||
import { store } from "@/store";
|
import { store } from "@/store";
|
||||||
import { Node, Call } from "@/types/topology";
|
import { Node, Call } from "@/types/topology";
|
||||||
|
import graphql from "@/graphql";
|
||||||
|
import { AxiosResponse } from "axios";
|
||||||
|
import { useSelectorStore } from "@/store/modules/selectors";
|
||||||
|
import { useAppStoreWithOut } from "@/store/modules/app";
|
||||||
|
|
||||||
interface TopologyState {
|
interface TopologyState {
|
||||||
node: Node | null;
|
node: Node | null;
|
||||||
@ -40,9 +44,65 @@ export const topologyStore = defineStore({
|
|||||||
setLink(link: Call) {
|
setLink(link: Call) {
|
||||||
this.call = link;
|
this.call = link;
|
||||||
},
|
},
|
||||||
setTopology(nodes: Node[], links: Call[]) {
|
setTopology(data: { nodes: Node[]; links: Call[] }) {
|
||||||
this.nodes = nodes;
|
this.nodes = data.nodes;
|
||||||
this.calls = links;
|
this.calls = data.links;
|
||||||
|
},
|
||||||
|
async getServiceTopology() {
|
||||||
|
const serviceId = useSelectorStore().currentService.id;
|
||||||
|
const duration = useAppStoreWithOut().durationTime;
|
||||||
|
const res: AxiosResponse = await graphql
|
||||||
|
.query("getServiceTopology")
|
||||||
|
.params({
|
||||||
|
serviceId,
|
||||||
|
duration,
|
||||||
|
});
|
||||||
|
if (!res.data.errors) {
|
||||||
|
this.setTopology(res.data.data.topology);
|
||||||
|
}
|
||||||
|
return res.data;
|
||||||
|
},
|
||||||
|
async getGlobalTopology() {
|
||||||
|
const duration = useAppStoreWithOut().durationTime;
|
||||||
|
const res: AxiosResponse = await graphql
|
||||||
|
.query("getGlobalTopology")
|
||||||
|
.params({
|
||||||
|
duration,
|
||||||
|
});
|
||||||
|
if (!res.data.errors) {
|
||||||
|
this.setTopology(res.data.data.topology);
|
||||||
|
}
|
||||||
|
return res.data;
|
||||||
|
},
|
||||||
|
async getEndpointTopology() {
|
||||||
|
const endpointId = useSelectorStore().currentPod.id;
|
||||||
|
const duration = useAppStoreWithOut().durationTime;
|
||||||
|
const res: AxiosResponse = await graphql
|
||||||
|
.query("getEndpointTopology")
|
||||||
|
.params({
|
||||||
|
endpointId,
|
||||||
|
duration,
|
||||||
|
});
|
||||||
|
if (!res.data.errors) {
|
||||||
|
this.setTopology(res.data.data.topology);
|
||||||
|
}
|
||||||
|
return res.data;
|
||||||
|
},
|
||||||
|
async getInstanceTopology() {
|
||||||
|
const serverServiceId = useSelectorStore().currentService.id;
|
||||||
|
const clientServiceId = useSelectorStore().currentDestService.id;
|
||||||
|
const duration = useAppStoreWithOut().durationTime;
|
||||||
|
const res: AxiosResponse = await graphql
|
||||||
|
.query("getInstanceTopology")
|
||||||
|
.params({
|
||||||
|
clientServiceId,
|
||||||
|
serverServiceId,
|
||||||
|
duration,
|
||||||
|
});
|
||||||
|
if (!res.data.errors) {
|
||||||
|
this.setTopology(res.data.data.topology);
|
||||||
|
}
|
||||||
|
return res.data;
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
@ -29,6 +29,8 @@ import tool from "./utils/tool";
|
|||||||
import topoLegend from "./utils/legend";
|
import topoLegend from "./utils/legend";
|
||||||
import { Node, Call } from "@/types/topology";
|
import { Node, Call } from "@/types/topology";
|
||||||
import { useTopologyStore } from "@/store/modules/topology";
|
import { useTopologyStore } from "@/store/modules/topology";
|
||||||
|
import { useDashboardStore } from "@/store/modules/dashboard";
|
||||||
|
import { EntityType } from "../../data";
|
||||||
|
|
||||||
/*global defineProps, Nullable */
|
/*global defineProps, Nullable */
|
||||||
const props = defineProps({
|
const props = defineProps({
|
||||||
@ -41,6 +43,7 @@ const props = defineProps({
|
|||||||
});
|
});
|
||||||
const { t } = useI18n();
|
const { t } = useI18n();
|
||||||
const topologyStore = useTopologyStore();
|
const topologyStore = useTopologyStore();
|
||||||
|
const dashboardStore = useDashboardStore();
|
||||||
// const height = ref<number>(600);
|
// const height = ref<number>(600);
|
||||||
const simulation = ref<any>("");
|
const simulation = ref<any>("");
|
||||||
const svg = ref<Nullable<any>>(null);
|
const svg = ref<Nullable<any>>(null);
|
||||||
@ -53,6 +56,7 @@ const anchor = ref<any>(null);
|
|||||||
const tools = ref<any>(null);
|
const tools = ref<any>(null);
|
||||||
|
|
||||||
onMounted(() => {
|
onMounted(() => {
|
||||||
|
getTopology();
|
||||||
window.addEventListener("resize", resize);
|
window.addEventListener("resize", resize);
|
||||||
svg.value = d3
|
svg.value = d3
|
||||||
.select(chart.value)
|
.select(chart.value)
|
||||||
@ -75,6 +79,22 @@ onMounted(() => {
|
|||||||
// { icon: "" },
|
// { icon: "" },
|
||||||
// ]);
|
// ]);
|
||||||
});
|
});
|
||||||
|
async function getTopology() {
|
||||||
|
switch (dashboardStore.layer) {
|
||||||
|
case EntityType[0].value:
|
||||||
|
await topologyStore.getServiceTopology();
|
||||||
|
break;
|
||||||
|
case EntityType[1].value:
|
||||||
|
await topologyStore.getGlobalTopology();
|
||||||
|
break;
|
||||||
|
case EntityType[2].value:
|
||||||
|
await topologyStore.getEndpointTopology();
|
||||||
|
break;
|
||||||
|
case EntityType[3].value:
|
||||||
|
await topologyStore.getInstanceTopology();
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
function resize() {
|
function resize() {
|
||||||
svg.value.attr("height", chart.value.clientHeight);
|
svg.value.attr("height", chart.value.clientHeight);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user