fix: params

This commit is contained in:
Fine 2024-01-08 18:12:33 +08:00
parent e0bc912e12
commit 0be1e6d26c
2 changed files with 9 additions and 25 deletions

View File

@ -544,11 +544,13 @@ export const topologyStore = defineStore({
this.setLinkClientMetrics(res.data.data); this.setLinkClientMetrics(res.data.data);
return res.data; return res.data;
}, },
async getHierarchyServiceTopology(params: { serviceId: string; layer: string }) { async getHierarchyServiceTopology() {
if (!(params.serviceId && params.layer)) { if (!(this.node.id && this.node.layer)) {
return new Promise((resolve) => resolve({})); return new Promise((resolve) => resolve({}));
} }
const res: AxiosResponse = await graphql.query("getHierarchyServiceTopology").params(params); const res: AxiosResponse = await graphql
.query("getHierarchyServiceTopology")
.params({ serviceId: this.node.id, layer: this.node.layer });
if (res.data.errors) { if (res.data.errors) {
return res.data; return res.data;
} }

View File

@ -120,7 +120,6 @@ limitations under the License. -->
const graph = ref<Nullable<any>>(null); const graph = ref<Nullable<any>>(null);
const settings = ref<any>(props.config); const settings = ref<any>(props.config);
const graphConfig = computed(() => props.config.graph || {}); const graphConfig = computed(() => props.config.graph || {});
const depth = ref<number>(graphConfig.value.depth || 2);
const topologyLayout = ref<any>({}); const topologyLayout = ref<any>({});
const popover = ref<Nullable<any>>(null); const popover = ref<Nullable<any>>(null);
const graphWidth = ref<number>(100); const graphWidth = ref<number>(100);
@ -154,7 +153,7 @@ limitations under the License. -->
} }
async function freshNodes() { async function freshNodes() {
topologyStore.setHierarchyServiceNode(null); topologyStore.setHierarchyServiceNode(null);
const resp = await getTopology(); const resp = await topologyStore.getHierarchyServiceTopology();
loading.value = false; loading.value = false;
if (resp && resp.errors) { if (resp && resp.errors) {
@ -164,7 +163,6 @@ limitations under the License. -->
} }
async function update() { async function update() {
window.addEventListener("resize", resize);
await initLegendMetrics(); await initLegendMetrics();
draw(); draw();
popover.value = d3.select("#popover"); popover.value = d3.select("#popover");
@ -287,9 +285,10 @@ limitations under the License. -->
event.stopPropagation(); event.stopPropagation();
hideTip(); hideTip();
topologyStore.setHierarchyServiceNode(d); topologyStore.setHierarchyServiceNode(d);
// handleGoDashboard(d.name); handleGoDashboard();
} }
function handleGoDashboard(name: string) { function handleGoDashboard() {
const name = ""; // todo
const path = `/dashboard/${dashboardStore.layerId}/${EntityType[0].value}/${topologyStore.node.id}/${name}`; const path = `/dashboard/${dashboardStore.layerId}/${EntityType[0].value}/${topologyStore.node.id}/${name}`;
const routeUrl = router.resolve({ path }); const routeUrl = router.resolve({ path });
@ -297,28 +296,11 @@ limitations under the License. -->
dashboardStore.setEntity(origin); dashboardStore.setEntity(origin);
} }
async function getTopology() {
const ids = selectorStore.services.map((d: Service) => d.id);
const serviceIds = dashboardStore.entity === EntityType[0].value ? [selectorStore.currentService.id] : ids;
const resp = await topologyStore.getDepthServiceTopology(serviceIds, Number(depth.value));
return resp;
}
function resize() {
const dom = document.querySelector(".hierarchy-related")?.getBoundingClientRect() || {
height: 40,
width: 0,
};
height.value = dom.height - 80;
width.value = dom.width;
}
function svgEvent() { function svgEvent() {
topologyStore.setHierarchyServiceNode(null); topologyStore.setHierarchyServiceNode(null);
dashboardStore.selectWidget(props.config); dashboardStore.selectWidget(props.config);
} }
onBeforeUnmount(() => {
window.removeEventListener("resize", resize);
});
watch( watch(
() => appStore.durationTime, () => appStore.durationTime,
() => { () => {