Fix: refresh detect point data (#282)
* fix: refresh detect point data
diff --git a/src/store/modules/topology/index.ts b/src/store/modules/topology/index.ts
index 9e9d914..3bd9969 100644
--- a/src/store/modules/topology/index.ts
+++ b/src/store/modules/topology/index.ts
@@ -56,6 +56,7 @@
detectPoints: string[];
selectedServiceCall: Call | null;
currentNode: any;
+ currentLink: any;
current: Option;
mode: boolean;
getResponseTimeTrend: number[];
@@ -83,6 +84,7 @@
_calls: [],
_nodes: [],
currentNode: {},
+ currentLink: {},
current: {
key: 'default',
label: 'default',
@@ -121,6 +123,9 @@
[types.SET_NODE](state: State, data: any) {
state.currentNode = data;
},
+ [types.SET_LINK](state: State, data: any) {
+ state.currentLink = data;
+ },
[types.SET_TOPO](state: State, data: any) {
state.calls = data.calls;
state.nodes = data.nodes;
@@ -235,6 +240,9 @@
duration: params.duration,
})
.then((res: AxiosResponse) => {
+ if (!res.data.data) {
+ return;
+ }
context.commit('SET_TOPO_RELATION', res.data.data);
context.commit(types.SET_SELECTED_CALL, params);
});
@@ -244,6 +252,9 @@
.query('queryTopoClientInfo')
.params(params)
.then((res: AxiosResponse) => {
+ if (!res.data.data) {
+ return;
+ }
context.commit('SET_TOPO_RELATION', res.data.data);
context.commit(types.SET_SELECTED_CALL, params);
});
diff --git a/src/store/mutation-types.ts b/src/store/mutation-types.ts
index 20fcbc9..1dbf989 100644
--- a/src/store/mutation-types.ts
+++ b/src/store/mutation-types.ts
@@ -82,6 +82,7 @@
export const SET_SHOW_DIALOG = 'SET_SHOW_DIALOG';
export const SET_INSTANCE_DEPENDENCY = 'SET_INSTANCE_DEPENDENCY';
export const SET_TOPO_COPY = 'SET_TOPO_COPY';
+export const SET_LINK = 'SET_LINK';
// comparison
export const SET_CHARTVAL = 'SET_CHARTVAL';
diff --git a/src/views/components/topology/chart/topo.vue b/src/views/components/topology/chart/topo.vue
index de61efa..a2a0762 100644
--- a/src/views/components/topology/chart/topo.vue
+++ b/src/views/components/topology/chart/topo.vue
@@ -76,6 +76,7 @@
event.stopPropagation();
event.preventDefault();
this.$store.commit('rocketTopo/SET_NODE', {});
+ this.$store.commit('rocketTopo/SET_LINK', {});
this.$store.dispatch('rocketTopo/CLEAR_TOPO_INFO');
this.tool.attr('style', 'display: none');
});
@@ -110,10 +111,12 @@
const {x, y, vx, vy, fx, fy, index, ...rest} = d;
this.$store.dispatch('rocketTopo/CLEAR_TOPO_INFO');
this.$store.commit('rocketTopo/SET_NODE', rest);
+ this.$store.commit('rocketTopo/SET_LINK', {});
},
handleLinkClick(d) {
event.stopPropagation();
this.$store.commit('rocketTopo/SET_NODE', {});
+ this.$store.commit('rocketTopo/SET_LINK', d);
this.$store.dispatch('rocketTopo/CLEAR_TOPO_INFO');
this.$store.commit('rocketTopo/SET_MODE', d.detectPoints);
this.$store.dispatch(this.$store.state.rocketTopo.mode ? 'rocketTopo/GET_TOPO_SERVICE_INFO' :
diff --git a/src/views/components/topology/topo-aside.vue b/src/views/components/topology/topo-aside.vue
index 7c00fd0..573ccf2 100644
--- a/src/views/components/topology/topo-aside.vue
+++ b/src/views/components/topology/topo-aside.vue
@@ -105,11 +105,21 @@
this.drawerMainBodyHeight = `${document.body.clientHeight - 50}px`;
}
+ private beforeMount() {
+ this.SET_EVENTS([this.handleRefresh]);
+ }
+
private created() {
- this.SET_EVENTS([]);
this.SET_COMPS_TREE(this.initState.tree);
}
+ private handleRefresh() {
+ this.$store.dispatch(
+ this.stateTopo.mode ? 'rocketTopo/GET_TOPO_SERVICE_INFO' : 'rocketTopo/GET_TOPO_CLIENT_INFO',
+ { ...this.stateTopo.currentLink, duration: this.durationTime },
+ );
+ }
+
private mounted() {
this.resize();
window.addEventListener('resize', this.resize);
@@ -119,6 +129,7 @@
window.removeEventListener('resize', this.resize);
this.CLEAR_TOPO_INFO();
this.CLEAR_TOPO();
+ this.SET_EVENTS([]);
}
get types() {
diff --git a/src/views/containers/topology/topology.vue b/src/views/containers/topology/topology.vue
index ebe636b..29008ea 100644
--- a/src/views/containers/topology/topology.vue
+++ b/src/views/containers/topology/topology.vue
@@ -59,7 +59,6 @@
export default class Topology extends Vue {
@State('rocketTopo') private stateTopo!: topoState;
@State('rocketOption') private stateDashboardOption!: any;
- @Mutation('SET_EVENTS') private SET_EVENTS: any;
@Action('rocketTopo/CLEAR_TOPO') private CLEAR_TOPO: any;
@Action('rocketTopo/CLEAR_TOPO_INFO') private CLEAR_TOPO_INFO: any;
@Getter('durationTime') private durationTime: any;