feat: implement Topology on the dashboard (#14)

This commit is contained in:
Fine0830
2022-02-19 23:05:57 +08:00
committed by GitHub
parent 7472d70720
commit f53b422782
81 changed files with 4886 additions and 232 deletions

View File

@@ -19,6 +19,7 @@ import {
LineSeriesOption,
HeatmapSeriesOption,
PieSeriesOption,
SankeySeriesOption,
} from "echarts/charts";
import {
TitleComponentOption,
@@ -46,6 +47,7 @@ export type ECOption = echarts.ComposeOption<
| LegendComponentOption
| HeatmapSeriesOption
| PieSeriesOption
| SankeySeriesOption
>;
export function useECharts(

View File

@@ -28,6 +28,7 @@ export function useQueryProcessor(config: any) {
const appStore = useAppStoreWithOut();
const dashboardStore = useDashboardStore();
const selectorStore = useSelectorStore();
if (!selectorStore.currentService && dashboardStore.entity !== "All") {
return;
}
@@ -40,6 +41,9 @@ export function useQueryProcessor(config: any) {
"ServiceInstanceRelation",
"EndpointRelation",
].includes(dashboardStore.entity);
if (isRelation && !selectorStore.currentDestService) {
return;
}
const fragment = config.metrics.map((name: string, index: number) => {
const metricType = config.metricTypes[index] || "";
const labels = ["0", "1", "2", "3", "4"];
@@ -257,3 +261,28 @@ export function usePodsSource(
});
return data;
}
export function useQueryTopologyMetrics(metrics: string[], ids: string[]) {
const appStore = useAppStoreWithOut();
const conditions: { [key: string]: unknown } = {
duration: appStore.durationTime,
ids,
};
const variables: string[] = [`$duration: Duration!`, `$ids: [ID!]!`];
const fragmentList = metrics.map((d: string, index: number) => {
conditions[`m${index}`] = d;
variables.push(`$m${index}: String!`);
return `${d}: getValues(metric: {
name: $m${index}
ids: $ids
}, duration: $duration) {
values {
id
value
}
}`;
});
const queryStr = `query queryData(${variables}) {${fragmentList.join(" ")}}`;
return { queryStr, conditions };
}