Skip to content
This repository was archived by the owner on Jun 1, 2022. It is now read-only.

Commit a040016

Browse files
authored
fix: update graph parameter of query for topology metrics (#543)
* fix: query conditions of topology metrics * fix: separate alerts for states
1 parent c49ea82 commit a040016

File tree

4 files changed

+78
-23
lines changed

4 files changed

+78
-23
lines changed

src/components/rk-alert.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ limitations under the License. -->
3030
@Component
3131
export default class RkAlert extends Vue {
3232
@Prop() private message!: string;
33-
@Prop() private type!: string;
33+
@Prop({ default: 'error' }) private type!: string;
3434
@Prop() private description!: string;
3535
@Prop({ default: true }) private showIcon!: boolean;
3636
@Prop({ default: true }) private closable!: boolean;

src/graph/query/topology.ts

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,22 @@ export const queryTopoInfo = `query queryTopoInfo(
4444
${TopoServiceMetric.query},
4545
${TopoClientMetric.query}
4646
}`;
47+
export const queryTopoInfoServer = `query queryTopoInfo(
48+
${Topo.variable},
49+
${TopoMetric.variable},
50+
${TopoServiceMetric.variable})
51+
{
52+
${TopoMetric.query},
53+
${TopoServiceMetric.query}
54+
}`;
55+
export const queryTopoInfoClient = `query queryTopoInfo(
56+
${Topo.variable},
57+
${TopoMetric.variable},
58+
${TopoClientMetric.variable})
59+
{
60+
${TopoMetric.query},
61+
${TopoClientMetric.query}
62+
}`;
4763

4864
export const queryTopoInstanceDependency = `query queryTopoInstanceDependency(
4965
${TopoInstanceDependency.variable}) {${TopoInstanceDependency.query}}`;

src/store/modules/topology/index.ts

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -624,25 +624,29 @@ const actions: ActionTree<State, any> = {
624624
.params(params)
625625
.then((res: AxiosResponse) => {
626626
context.commit(types.SET_TOPO_ERRORS, { msg: query, desc: res.data.errors || '' });
627-
if (res.data.errors) {
627+
if (!res.data.data) {
628628
context.commit(types.SET_TOPO, { calls: [], nodes: [] });
629629
return;
630630
}
631631
const calls = res.data.data.topo.calls;
632632
const nodes = res.data.data.topo.nodes;
633633
const ids = nodes.map((i: any) => i.id);
634634
const idsC = calls.filter((i: any) => i.detectPoints.includes('CLIENT')).map((b: any) => b.id);
635-
const idsS = calls.filter((i: any) => i.detectPoints.includes('CLIENT')).map((b: any) => b.id);
635+
const idsS = calls.filter((i: any) => i.detectPoints.includes('SERVER')).map((b: any) => b.id);
636+
if (!ids.length) {
637+
return context.commit(types.SET_TOPO, { calls: [], nodes: [] });
638+
}
639+
const queryName = !idsC.length ? 'queryTopoInfoServer' : !idsS.length ? 'queryTopoInfoClient' : 'queryTopoInfo';
636640
return graph
637-
.query('queryTopoInfo')
641+
.query(queryName)
638642
.params({ ...params, ids, idsC, idsS })
639643
.then((info: AxiosResponse) => {
640644
context.commit(types.SET_TOPO_ERRORS, { msg: 'queryTopoInfo', desc: info.data.errors || '' });
641-
if (info.data.errors) {
645+
const resInfo = info.data.data;
646+
if (!resInfo) {
642647
context.commit(types.SET_TOPO, { calls: [], nodes: [] });
643648
return;
644649
}
645-
const resInfo = info.data.data;
646650
if (!resInfo.sla) {
647651
return context.commit(types.SET_TOPO, { calls, nodes });
648652
}

src/views/components/common/alerts-content.vue

Lines changed: 52 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -15,12 +15,60 @@ limitations under the License. -->
1515
<template>
1616
<div class="alert-content">
1717
<rk-alert
18-
v-for="(msg, index) in Object.keys(allAlerts)"
18+
v-for="(msg, index) in Object.keys(stateOption.selectorErrors)"
1919
:key="msg + index"
20-
:show.sync="allAlerts[msg]"
21-
type="error"
20+
:show.sync="stateOption.selectorErrors[msg]"
2221
:message="msg"
23-
:description="allAlerts[msg]"
22+
:description="stateOption.selectorErrors[msg]"
23+
/>
24+
<rk-alert
25+
v-for="(msg, index) in Object.keys(rocketData.dashboardErrors)"
26+
:key="msg + index"
27+
:show.sync="rocketData.dashboardErrors[msg]"
28+
:message="msg"
29+
:description="rocketData.dashboardErrors[msg]"
30+
/>
31+
<rk-alert
32+
v-for="(msg, index) in Object.keys(stateTopo.topoErrors)"
33+
:key="msg + index"
34+
:show.sync="stateTopo.topoErrors[msg]"
35+
:message="msg"
36+
:description="stateTopo.topoErrors[msg]"
37+
/>
38+
<rk-alert
39+
v-for="(msg, index) in Object.keys(rocketTrace.traceErrors)"
40+
:key="msg + index"
41+
:show.sync="rocketTrace.traceErrors[msg]"
42+
:message="msg"
43+
:description="rocketTrace.traceErrors[msg]"
44+
/>
45+
<rk-alert
46+
v-for="(msg, index) in Object.keys(rocketLog.logErrors)"
47+
:key="msg + index"
48+
:show.sync="rocketLog.logErrors[msg]"
49+
:message="msg"
50+
:description="rocketLog.logErrors[msg]"
51+
/>
52+
<rk-alert
53+
v-for="(msg, index) in Object.keys(rocketAlarm.alarmErrors)"
54+
:key="msg + index"
55+
:show.sync="rocketAlarm.alarmErrors[msg]"
56+
:message="msg"
57+
:description="rocketAlarm.alarmErrors[msg]"
58+
/>
59+
<rk-alert
60+
v-for="(msg, index) in Object.keys(stateProfile.profileErrors)"
61+
:key="msg + index"
62+
:show.sync="stateProfile.profileErrors[msg]"
63+
:message="msg"
64+
:description="stateProfile.profileErrors[msg]"
65+
/>
66+
<rk-alert
67+
v-for="(msg, index) in Object.keys(rocketEvent.eventErrors)"
68+
:key="msg + index"
69+
:show.sync="rocketEvent.eventErrors[msg]"
70+
:message="msg"
71+
:description="rocketEvent.eventErrors[msg]"
2472
/>
2573
</div>
2674
</template>
@@ -47,19 +95,6 @@ limitations under the License. -->
4795
@State('rocketAlarm') private rocketAlarm!: alarmState;
4896
@State('rocketEvent') private rocketEvent!: EventState;
4997
@State('rocketTrace') private rocketTrace!: traceState;
50-
51-
private get allAlerts() {
52-
return {
53-
...this.rocketEvent.eventErrors,
54-
...this.stateOption.selectorErrors,
55-
...this.rocketData.dashboardErrors,
56-
...this.stateTopo.topoErrors,
57-
...this.stateProfile.profileErrors,
58-
...this.rocketLog.logErrors,
59-
...this.rocketAlarm.alarmErrors,
60-
...this.rocketTrace.traceErrors,
61-
};
62-
}
6398
}
6499
</script>
65100
<style lang="scss" scoped>

0 commit comments

Comments
 (0)