refactor: update codes

This commit is contained in:
Fine 2022-12-14 17:00:45 +08:00
parent 04e049c629
commit 09d0d0049b
15 changed files with 75 additions and 154 deletions

View File

@ -12,7 +12,6 @@
"build-only": "vite build", "build-only": "vite build",
"type-check": "vue-tsc --noEmit -p tsconfig.vitest.json --composite false", "type-check": "vue-tsc --noEmit -p tsconfig.vitest.json --composite false",
"lint": "eslint . --ext .vue,.js,.jsx,.cjs,.mjs,.ts,.tsx,.cts,.mts --fix --ignore-path .gitignore", "lint": "eslint . --ext .vue,.js,.jsx,.cjs,.mjs,.ts,.tsx,.cts,.mts --fix --ignore-path .gitignore",
"lint:eslint": "eslint --cache --max-warnings 0 \"{src,mock}/**/*.{vue,ts,tsx}\" --fix",
"lint:prettier": "prettier --write \"src/**/*.{js,json,tsx,css,less,scss,vue,html,md}\"", "lint:prettier": "prettier --write \"src/**/*.{js,json,tsx,css,less,scss,vue,html,md}\"",
"lint:stylelint": "stylelint --cache --fix \"**/*.{vue,less,postcss,css,scss}\" --cache --cache-location node_modules/.cache/stylelint/", "lint:stylelint": "stylelint --cache --fix \"**/*.{vue,less,postcss,css,scss}\" --cache --cache-location node_modules/.cache/stylelint/",
"lint:lint-staged": "lint-staged", "lint:lint-staged": "lint-staged",

View File

@ -16,7 +16,7 @@
*/ */
/* global module */ /* global module */
module.exports = { module.exports = {
printWidth: 100, printWidth: 120,
semi: true, semi: true,
vueIndentScriptAndStyle: true, vueIndentScriptAndStyle: true,
trailingComma: "all", trailingComma: "all",

View File

@ -105,8 +105,7 @@ export const dashboardStore = defineStore({
newItem.h = 36; newItem.h = 36;
newItem.graph = { newItem.graph = {
showDepth: true, showDepth: true,
depth: depth: this.entity === EntityType[1].value ? 1 : this.entity === EntityType[0].value ? 2 : 3,
this.entity === EntityType[1].value ? 1 : this.entity === EntityType[0].value ? 2 : 3,
}; };
} }
if (["Trace", "Profile", "Log", "DemandLog", "Ebpf", "NetworkProfiling"].includes(type)) { if (["Trace", "Profile", "Log", "DemandLog", "Ebpf", "NetworkProfiling"].includes(type)) {
@ -148,7 +147,7 @@ export const dashboardStore = defineStore({
return; return;
} }
const tabIndex = this.layout[idx].activedTabIndex || 0; const tabIndex = this.layout[idx].activedTabIndex || 0;
const { children } = this.layout[idx].children[tabIndex]; const { children } = (this.layout[idx].children || [])[tabIndex];
const arr = children.map((d: any) => Number(d.i)); const arr = children.map((d: any) => Number(d.i));
let index = String(Math.max(...arr) + 1); let index = String(Math.max(...arr) + 1);
if (!children.length) { if (!children.length) {
@ -187,7 +186,7 @@ export const dashboardStore = defineStore({
return d; return d;
}); });
items.push(newItem); items.push(newItem);
this.layout[idx].children[tabIndex].children = items; (this.layout[idx].children || [])[tabIndex].children = items;
this.currentTabItems = items; this.currentTabItems = items;
} }
}, },
@ -222,7 +221,7 @@ export const dashboardStore = defineStore({
if (actived.length === 3) { if (actived.length === 3) {
const tabIndex = Number(actived[1]); const tabIndex = Number(actived[1]);
this.currentTabItems = this.currentTabItems.filter((d: LayoutConfig) => actived[2] !== d.i); this.currentTabItems = this.currentTabItems.filter((d: LayoutConfig) => actived[2] !== d.i);
this.layout[index].children[tabIndex].children = this.currentTabItems; (this.layout[index].children || [])[tabIndex].children = this.currentTabItems;
return; return;
} }
this.layout = this.layout.filter((d: LayoutConfig) => d.i !== item.i); this.layout = this.layout.filter((d: LayoutConfig) => d.i !== item.i);
@ -230,8 +229,8 @@ export const dashboardStore = defineStore({
removeTabItem(item: LayoutConfig, index: number) { removeTabItem(item: LayoutConfig, index: number) {
const idx = this.layout.findIndex((d: LayoutConfig) => d.i === item.i); const idx = this.layout.findIndex((d: LayoutConfig) => d.i === item.i);
if (this.selectedGrid) { if (this.selectedGrid) {
for (const item of this.layout[idx].children[index].children) { for (const item of (this.layout[idx].children || [])[index].children) {
if (this.selectedGrid.i === item.i) { if (this.selectedGrid?.i === item.i) {
this.selectedGrid = null; this.selectedGrid = null;
} }
} }
@ -260,16 +259,16 @@ export const dashboardStore = defineStore({
const index = this.layout.findIndex((d: LayoutConfig) => actived[0] === d.i); const index = this.layout.findIndex((d: LayoutConfig) => actived[0] === d.i);
if (actived.length === 3) { if (actived.length === 3) {
const tabIndex = Number(actived[1]); const tabIndex = Number(actived[1]);
const itemIndex = this.layout[index].children[tabIndex].children.findIndex( const itemIndex = (this.layout[index].children || [])[tabIndex].children.findIndex(
(d: LayoutConfig) => actived[2] === d.i, (d: LayoutConfig) => actived[2] === d.i,
); );
this.layout[index].children[tabIndex].children[itemIndex] = { (this.layout[index].children || [])[tabIndex].children[itemIndex] = {
...this.layout[index].children[tabIndex].children[itemIndex], ...(this.layout[index].children || [])[tabIndex].children[itemIndex],
...param, ...param,
}; };
this.selectedGrid = this.layout[index].children[tabIndex].children[itemIndex]; this.selectedGrid = (this.layout[index].children || [])[tabIndex].children[itemIndex];
this.setCurrentTabItems(this.layout[index].children[tabIndex].children); this.setCurrentTabItems((this.layout[index].children || [])[tabIndex].children);
return; return;
} }
this.layout[index] = { this.layout[index] = {
@ -281,8 +280,8 @@ export const dashboardStore = defineStore({
setWidget(param: LayoutConfig) { setWidget(param: LayoutConfig) {
for (let i = 0; i < this.layout.length; i++) { for (let i = 0; i < this.layout.length; i++) {
if (this.layout[i].type === "Tab") { if (this.layout[i].type === "Tab") {
if (this.layout[i].children && this.layout[i].children.length) { if ((this.layout[i].children || []).length) {
for (const child of this.layout[i].children) { for (const child of this.layout[i].children || []) {
if (child.children && child.children.length) { if (child.children && child.children.length) {
for (let c = 0; c < child.children.length; c++) { for (let c = 0; c < child.children.length; c++) {
if (child.children[c].id === param.id) { if (child.children[c].id === param.id) {
@ -386,7 +385,7 @@ export const dashboardStore = defineStore({
return res.data; return res.data;
}, },
async saveDashboard() { async saveDashboard() {
if (!this.currentDashboard.name) { if (!this.currentDashboard?.name) {
ElMessage.error("The dashboard name is needed."); ElMessage.error("The dashboard name is needed.");
return; return;
} }
@ -407,18 +406,16 @@ export const dashboardStore = defineStore({
c.isRoot = false; c.isRoot = false;
const index = this.dashboards.findIndex( const index = this.dashboards.findIndex(
(d: DashboardItem) => (d: DashboardItem) =>
d.name === this.currentDashboard.name && d.name === this.currentDashboard?.name &&
d.entity === this.currentDashboard.entity && d.entity === this.currentDashboard.entity &&
d.layer === this.currentDashboard.layerId, d.layer === this.currentDashboard?.layer,
); );
if (index > -1) { if (index > -1) {
const { t } = useI18n(); const { t } = useI18n();
ElMessage.error(t("nameError")); ElMessage.error(t("nameError"));
return; return;
} }
res = await graphql res = await graphql.query("addNewTemplate").params({ setting: { configuration: JSON.stringify(c) } });
.query("addNewTemplate")
.params({ setting: { configuration: JSON.stringify(c) } });
json = res.data.data.addTemplate; json = res.data.data.addTemplate;
} }
@ -433,17 +430,11 @@ export const dashboardStore = defineStore({
if (!this.currentDashboard.id) { if (!this.currentDashboard.id) {
ElMessage.success("Saved successfully"); ElMessage.success("Saved successfully");
} }
const key = [ const key = [this.currentDashboard.layer, this.currentDashboard.entity, this.currentDashboard.name].join("_");
this.currentDashboard.layer,
this.currentDashboard.entity,
this.currentDashboard.name,
].join("_");
this.currentDashboard.id = json.id; this.currentDashboard.id = json.id;
if (this.currentDashboard.id) { if (this.currentDashboard.id) {
sessionStorage.removeItem(key); sessionStorage.removeItem(key);
this.dashboards = this.dashboards.filter( this.dashboards = this.dashboards.filter((d: DashboardItem) => d.id !== this.currentDashboard?.id);
(d: DashboardItem) => d.id !== this.currentDashboard.id,
);
} }
this.dashboards.push(this.currentDashboard); this.dashboards.push(this.currentDashboard);
const l = { id: json.id, configuration: c }; const l = { id: json.id, configuration: c };
@ -453,9 +444,7 @@ export const dashboardStore = defineStore({
return json; return json;
}, },
async deleteDashboard() { async deleteDashboard() {
const res: AxiosResponse = await graphql const res: AxiosResponse = await graphql.query("removeTemplate").params({ id: this.currentDashboard?.id });
.query("removeTemplate")
.params({ id: this.currentDashboard.id });
if (res.data.errors) { if (res.data.errors) {
ElMessage.error(res.data.errors); ElMessage.error(res.data.errors);
@ -466,12 +455,8 @@ export const dashboardStore = defineStore({
ElMessage.error(json.message); ElMessage.error(json.message);
return res.data; return res.data;
} }
this.dashboards = this.dashboards.filter((d: any) => d.id !== this.currentDashboard.id); this.dashboards = this.dashboards.filter((d: any) => d.id !== this.currentDashboard?.id);
const key = [ const key = [this.currentDashboard?.layer, this.currentDashboard?.entity, this.currentDashboard?.name].join("_");
this.currentDashboard.layer,
this.currentDashboard.entity,
this.currentDashboard.name,
].join("_");
sessionStorage.removeItem(key); sessionStorage.removeItem(key);
}, },
}, },

View File

@ -59,9 +59,7 @@ export const demandLogStore = defineStore({
this.message = message || ""; this.message = message || "";
}, },
async getInstances(id: string) { async getInstances(id: string) {
const serviceId = this.selectorStore.currentService const serviceId = this.selectorStore.currentService ? this.selectorStore.currentService.id : id;
? this.selectorStore.currentService.id
: id;
const res: AxiosResponse = await graphql.query("queryInstances").params({ const res: AxiosResponse = await graphql.query("queryInstances").params({
serviceId, serviceId,
duration: useAppStoreWithOut().durationTime, duration: useAppStoreWithOut().durationTime,
@ -96,15 +94,13 @@ export const demandLogStore = defineStore({
}, },
async getDemandLogs() { async getDemandLogs() {
this.loadLogs = true; this.loadLogs = true;
const res: AxiosResponse = await graphql const res: AxiosResponse = await graphql.query("fetchDemandPodLogs").params({ condition: this.conditions });
.query("fetchDemandPodLogs")
.params({ condition: this.conditions });
this.loadLogs = false; this.loadLogs = false;
if (res.data.errors) { if (res.data.errors) {
return res.data; return res.data;
} }
if (res.data.data.logs.errorReason) { if (res.data.data.logs.errorReason) {
this.setLogs("", res.data.data.logs.errorReason); this.setLogs([], res.data.data.logs.errorReason);
return res.data; return res.data;
} }
this.total = res.data.data.logs.logs.length; this.total = res.data.data.logs.logs.length;

View File

@ -16,17 +16,12 @@
*/ */
import { defineStore } from "pinia"; import { defineStore } from "pinia";
import type { Option } from "@/types/app"; import type { Option } from "@/types/app";
import type { import type { EBPFTaskCreationRequest, EBPFProfilingSchedule, EBPFTaskList, AnalyzationTrees } from "@/types/ebpf";
EBPFTaskCreationRequest,
EBPFProfilingSchedule,
EBPFTaskList,
AnalyzationTrees,
} from "@/types/ebpf";
import { store } from "@/store"; import { store } from "@/store";
import graphql from "@/graphql"; import graphql from "@/graphql";
import type { AxiosResponse } from "axios"; import type { AxiosResponse } from "axios";
interface EbpfState { interface EbpfState {
taskList: EBPFTaskList[]; taskList: Array<Recordable<EBPFTaskList>>;
eBPFSchedules: EBPFProfilingSchedule[]; eBPFSchedules: EBPFProfilingSchedule[];
currentSchedule: EBPFProfilingSchedule | Record<string, never>; currentSchedule: EBPFProfilingSchedule | Record<string, never>;
analyzeTrees: AnalyzationTrees[]; analyzeTrees: AnalyzationTrees[];
@ -51,7 +46,7 @@ export const ebpfStore = defineStore({
aggregateType: "COUNT", aggregateType: "COUNT",
}), }),
actions: { actions: {
setSelectedTask(task: EBPFTaskList) { setSelectedTask(task: Recordable<EBPFTaskList>) {
this.selectedTask = task || {}; this.selectedTask = task || {};
}, },
setCurrentSchedule(s: EBPFProfilingSchedule) { setCurrentSchedule(s: EBPFProfilingSchedule) {
@ -85,7 +80,7 @@ export const ebpfStore = defineStore({
}); });
return res.data; return res.data;
}, },
async getTaskList(params: { serviceId: string; serviceInstanceId: string; targets: string[] }) { async getTaskList(params: { serviceId: string; targets: string[] }) {
if (!params.serviceId) { if (!params.serviceId) {
return new Promise((resolve) => resolve({})); return new Promise((resolve) => resolve({}));
} }
@ -101,7 +96,7 @@ export const ebpfStore = defineStore({
if (!this.taskList.length) { if (!this.taskList.length) {
return res.data; return res.data;
} }
this.getEBPFSchedules({ taskId: this.taskList[0].taskId }); this.getEBPFSchedules({ taskId: String(this.taskList[0].taskId) });
return res.data; return res.data;
}, },
async getEBPFSchedules(params: { taskId: string }) { async getEBPFSchedules(params: { taskId: string }) {

View File

@ -24,7 +24,7 @@ import type { LayoutConfig } from "@/types/dashboard";
import { ElMessage } from "element-plus"; import { ElMessage } from "element-plus";
interface NetworkProfilingState { interface NetworkProfilingState {
networkTasks: EBPFTaskList[]; networkTasks: Array<Recordable<EBPFTaskList>>;
networkTip: string; networkTip: string;
selectedNetworkTask: Recordable<EBPFTaskList>; selectedNetworkTask: Recordable<EBPFTaskList>;
nodes: ProcessNode[]; nodes: ProcessNode[];
@ -55,10 +55,10 @@ export const networkProfilingStore = defineStore({
loadNodes: false, loadNodes: false,
}), }),
actions: { actions: {
setSelectedNetworkTask(task: EBPFTaskList) { setSelectedNetworkTask(task: Recordable<EBPFTaskList>) {
this.selectedNetworkTask = task || {}; this.selectedNetworkTask = task || {};
}, },
setNode(node: Node) { setNode(node: Nullable<ProcessNode>) {
this.node = node; this.node = node;
}, },
setLink(link: Call) { setLink(link: Call) {
@ -156,7 +156,6 @@ export const networkProfilingStore = defineStore({
} }
const res: AxiosResponse = await graphql.query("aliveNetworkProfiling").params({ taskId }); const res: AxiosResponse = await graphql.query("aliveNetworkProfiling").params({ taskId });
this.aliveMessage = "";
if (res.data.errors) { if (res.data.errors) {
return res.data; return res.data;
} }

View File

@ -23,7 +23,7 @@ import type {
TaskLog, TaskLog,
ProfileTaskCreationRequest, ProfileTaskCreationRequest,
} from "@/types/profile"; } from "@/types/profile";
import type { Trace, Span } from "@/types/trace"; import type { Trace } from "@/types/trace";
import { store } from "@/store"; import { store } from "@/store";
import graphql from "@/graphql"; import graphql from "@/graphql";
import type { AxiosResponse } from "axios"; import type { AxiosResponse } from "axios";
@ -35,9 +35,9 @@ interface ProfileState {
condition: { serviceId: string; endpointName: string }; condition: { serviceId: string; endpointName: string };
taskList: TaskListItem[]; taskList: TaskListItem[];
segmentList: Trace[]; segmentList: Trace[];
currentSegment: Trace | Record<string, never>; currentSegment: Recordable<Trace>;
segmentSpans: SegmentSpan[]; segmentSpans: Array<Recordable<SegmentSpan>>;
currentSpan: SegmentSpan | Record<string, never>; currentSpan: Recordable<SegmentSpan>;
analyzeTrees: ProfileAnalyzationTrees; analyzeTrees: ProfileAnalyzationTrees;
taskLogs: TaskLog[]; taskLogs: TaskLog[];
highlightTop: boolean; highlightTop: boolean;
@ -65,10 +65,10 @@ export const profileStore = defineStore({
...data, ...data,
}; };
}, },
setCurrentSpan(span: Span) { setCurrentSpan(span: Recordable<SegmentSpan>) {
this.currentSpan = span; this.currentSpan = span;
}, },
setCurrentSegment(s: Trace) { setCurrentSegment(s: Recordable<Trace>) {
this.currentSegment = s; this.currentSegment = s;
}, },
setHighlightTop() { setHighlightTop() {
@ -139,7 +139,7 @@ export const profileStore = defineStore({
this.currentSegment = segmentList[0]; this.currentSegment = segmentList[0];
this.getSegmentSpans({ segmentId: segmentList[0].segmentId }); this.getSegmentSpans({ segmentId: segmentList[0].segmentId });
} else { } else {
this.currentSegment = null; this.currentSegment = {};
} }
return res.data; return res.data;
}, },
@ -161,8 +161,8 @@ export const profileStore = defineStore({
this.segmentSpans = segment.spans.map((d: SegmentSpan) => { this.segmentSpans = segment.spans.map((d: SegmentSpan) => {
return { return {
...d, ...d,
segmentId: this.currentSegment.segmentId, segmentId: this.currentSegment?.segmentId,
traceId: this.currentSegment.traceIds[0], traceId: (this.currentSegment.traceIds as any)[0],
}; };
}); });
if (!(segment.spans && segment.spans.length)) { if (!(segment.spans && segment.spans.length)) {
@ -173,10 +173,7 @@ export const profileStore = defineStore({
this.currentSpan = segment.spans[index]; this.currentSpan = segment.spans[index];
return res.data; return res.data;
}, },
async getProfileAnalyze(params: { async getProfileAnalyze(params: { segmentId: string; timeRanges: Array<{ start: number; end: number }> }) {
segmentId: string;
timeRanges: Array<{ start: number; end: number }>;
}) {
if (!params.segmentId) { if (!params.segmentId) {
return new Promise((resolve) => resolve({})); return new Promise((resolve) => resolve({}));
} }
@ -203,9 +200,7 @@ export const profileStore = defineStore({
return res.data; return res.data;
}, },
async createTask(param: ProfileTaskCreationRequest) { async createTask(param: ProfileTaskCreationRequest) {
const res: AxiosResponse = await graphql const res: AxiosResponse = await graphql.query("saveProfileTask").params({ creationRequest: param });
.query("saveProfileTask")
.params({ creationRequest: param });
if (res.data.errors) { if (res.data.errors) {
return res.data; return res.data;

View File

@ -105,21 +105,19 @@ export const topologyStore = defineStore({
this.calls = calls; this.calls = calls;
this.nodes = nodes; this.nodes = nodes;
}, },
setNodeMetricValue(m: { id: string; value: unknown }[]) { setNodeMetricValue(m: MetricVal) {
this.nodeMetricValue = m; this.nodeMetricValue = m;
}, },
setLinkServerMetrics(m: { id: string; value: unknown }[]) { setLinkServerMetrics(m: MetricVal) {
this.linkServerMetrics = m; this.linkServerMetrics = m;
}, },
setLinkClientMetrics(m: { id: string; value: unknown }[]) { setLinkClientMetrics(m: MetricVal) {
this.linkClientMetrics = m; this.linkClientMetrics = m;
}, },
async getDepthServiceTopology(serviceIds: string[], depth: number) { async getDepthServiceTopology(serviceIds: string[], depth: number) {
const res = await this.getServicesTopology(serviceIds); const res = await this.getServicesTopology(serviceIds);
if (depth > 1) { if (depth > 1) {
const ids = (res.nodes || []) const ids = (res.nodes || []).map((item: Node) => item.id).filter((d: string) => !serviceIds.includes(d));
.map((item: Node) => item.id)
.filter((d: string) => !serviceIds.includes(d));
if (!ids.length) { if (!ids.length) {
this.setTopology(res); this.setTopology(res);
return; return;
@ -158,20 +156,8 @@ export const topologyStore = defineStore({
return; return;
} }
const toposObj = await this.getServicesTopology(nodeIds); const toposObj = await this.getServicesTopology(nodeIds);
const nodes = [ const nodes = [...res.nodes, ...json.nodes, ...topo.nodes, ...data.nodes, ...toposObj.nodes];
...res.nodes, const calls = [...res.calls, ...json.calls, ...topo.calls, ...data.calls, ...toposObj.calls];
...json.nodes,
...topo.nodes,
...data.nodes,
...toposObj.nodes,
];
const calls = [
...res.calls,
...json.calls,
...topo.calls,
...data.calls,
...toposObj.calls,
];
this.setTopology({ nodes, calls }); this.setTopology({ nodes, calls });
} else { } else {
const nodes = [...res.nodes, ...json.nodes, ...topo.nodes, ...data.nodes]; const nodes = [...res.nodes, ...json.nodes, ...topo.nodes, ...data.nodes];
@ -221,9 +207,7 @@ export const topologyStore = defineStore({
async updateEndpointTopology(endpointIds: string[], depth: number) { async updateEndpointTopology(endpointIds: string[], depth: number) {
const res = await this.getEndpointTopology(endpointIds); const res = await this.getEndpointTopology(endpointIds);
if (depth > 1) { if (depth > 1) {
const ids = res.nodes const ids = res.nodes.map((item: Node) => item.id).filter((d: string) => !endpointIds.includes(d));
.map((item: Node) => item.id)
.filter((d: string) => !endpointIds.includes(d));
if (!ids.length) { if (!ids.length) {
this.setTopology(res); this.setTopology(res);
return; return;
@ -254,9 +238,7 @@ export const topologyStore = defineStore({
if (depth > 4) { if (depth > 4) {
const nodeIds = data.nodes const nodeIds = data.nodes
.map((item: Node) => item.id) .map((item: Node) => item.id)
.filter( .filter((d: string) => ![...endpoints, ...ids, ...pods, ...endpointIds].includes(d));
(d: string) => ![...endpoints, ...ids, ...pods, ...endpointIds].includes(d),
);
if (!nodeIds.length) { if (!nodeIds.length) {
const nodes = [...res.nodes, ...json.nodes, ...topo.nodes, ...data.nodes]; const nodes = [...res.nodes, ...json.nodes, ...topo.nodes, ...data.nodes];
const calls = [...res.calls, ...json.calls, ...topo.calls, ...data.calls]; const calls = [...res.calls, ...json.calls, ...topo.calls, ...data.calls];
@ -264,20 +246,8 @@ export const topologyStore = defineStore({
return; return;
} }
const toposObj = await this.getEndpointTopology(nodeIds); const toposObj = await this.getEndpointTopology(nodeIds);
const nodes = [ const nodes = [...res.nodes, ...json.nodes, ...topo.nodes, ...data.nodes, ...toposObj.nodes];
...res.nodes, const calls = [...res.calls, ...json.calls, ...topo.calls, ...data.calls, ...toposObj.calls];
...json.nodes,
...topo.nodes,
...data.nodes,
...toposObj.nodes,
];
const calls = [
...res.calls,
...json.calls,
...topo.calls,
...data.calls,
...toposObj.calls,
];
this.setTopology({ nodes, calls }); this.setTopology({ nodes, calls });
} else { } else {
const nodes = [...res.nodes, ...json.nodes, ...topo.nodes, ...data.nodes]; const nodes = [...res.nodes, ...json.nodes, ...topo.nodes, ...data.nodes];
@ -352,9 +322,7 @@ export const topologyStore = defineStore({
this.setLinkClientMetrics({}); this.setLinkClientMetrics({});
return; return;
} }
const idsC = this.calls const idsC = this.calls.filter((i: Call) => i.detectPoints.includes("CLIENT")).map((b: Call) => b.id);
.filter((i: Call) => i.detectPoints.includes("CLIENT"))
.map((b: Call) => b.id);
if (!idsC.length) { if (!idsC.length) {
return; return;
} }
@ -370,9 +338,7 @@ export const topologyStore = defineStore({
this.setLinkServerMetrics({}); this.setLinkServerMetrics({});
return; return;
} }
const idsS = this.calls const idsS = this.calls.filter((i: Call) => i.detectPoints.includes("SERVER")).map((b: Call) => b.id);
.filter((i: Call) => i.detectPoints.includes("SERVER"))
.map((b: Call) => b.id);
if (!idsS.length) { if (!idsS.length) {
return; return;
} }
@ -419,10 +385,7 @@ export const topologyStore = defineStore({
}); });
return res.data; return res.data;
}, },
async getCallServerMetrics(param: { async getCallServerMetrics(param: { queryStr: string; conditions: { [key: string]: unknown } }) {
queryStr: string;
conditions: { [key: string]: unknown };
}) {
const res: AxiosResponse = await query(param); const res: AxiosResponse = await query(param);
if (res.data.errors) { if (res.data.errors) {
@ -431,10 +394,7 @@ export const topologyStore = defineStore({
this.setLinkServerMetrics(res.data.data); this.setLinkServerMetrics(res.data.data);
return res.data; return res.data;
}, },
async getCallClientMetrics(param: { async getCallClientMetrics(param: { queryStr: string; conditions: { [key: string]: unknown } }) {
queryStr: string;
conditions: { [key: string]: unknown };
}) {
const res: AxiosResponse = await query(param); const res: AxiosResponse = await query(param);
if (res.data.errors) { if (res.data.errors) {

View File

@ -30,7 +30,7 @@ interface TraceState {
endpoints: Endpoint[]; endpoints: Endpoint[];
traceList: Trace[]; traceList: Trace[];
traceSpans: Span[]; traceSpans: Span[];
currentTrace: Trace | any; currentTrace: Recordable<Trace>;
conditions: any; conditions: any;
traceSpanLogs: any[]; traceSpanLogs: any[];
selectorStore: any; selectorStore: any;
@ -58,10 +58,10 @@ export const traceStore = defineStore({
setTraceCondition(data: any) { setTraceCondition(data: any) {
this.conditions = { ...this.conditions, ...data }; this.conditions = { ...this.conditions, ...data };
}, },
setCurrentTrace(trace: Trace) { setCurrentTrace(trace: Recordable<Trace>) {
this.currentTrace = trace; this.currentTrace = trace;
}, },
setTraceSpans(spans: Span) { setTraceSpans(spans: Span[]) {
this.traceSpans = spans; this.traceSpans = spans;
}, },
resetState() { resetState() {
@ -116,9 +116,7 @@ export const traceStore = defineStore({
return res.data; return res.data;
}, },
async getInstances(id: string) { async getInstances(id: string) {
const serviceId = this.selectorStore.currentService const serviceId = this.selectorStore.currentService ? this.selectorStore.currentService.id : id;
? this.selectorStore.currentService.id
: id;
const res: AxiosResponse = await graphql.query("queryInstances").params({ const res: AxiosResponse = await graphql.query("queryInstances").params({
serviceId: serviceId, serviceId: serviceId,
duration: useAppStoreWithOut().durationTime, duration: useAppStoreWithOut().durationTime,
@ -131,9 +129,7 @@ export const traceStore = defineStore({
return res.data; return res.data;
}, },
async getEndpoints(id: string, keyword?: string) { async getEndpoints(id: string, keyword?: string) {
const serviceId = this.selectorStore.currentService const serviceId = this.selectorStore.currentService ? this.selectorStore.currentService.id : id;
? this.selectorStore.currentService.id
: id;
const res: AxiosResponse = await graphql.query("queryEndpoints").params({ const res: AxiosResponse = await graphql.query("queryEndpoints").params({
serviceId, serviceId,
duration: useAppStoreWithOut().durationTime, duration: useAppStoreWithOut().durationTime,
@ -146,9 +142,7 @@ export const traceStore = defineStore({
return res.data; return res.data;
}, },
async getTraces() { async getTraces() {
const res: AxiosResponse = await graphql const res: AxiosResponse = await graphql.query("queryTraces").params({ condition: this.conditions });
.query("queryTraces")
.params({ condition: this.conditions });
if (res.data.errors) { if (res.data.errors) {
return res.data; return res.data;
} }

View File

@ -15,3 +15,4 @@
* limitations under the License. * limitations under the License.
*/ */
declare module "monaco-editor"; declare module "monaco-editor";
export {};

View File

@ -29,6 +29,7 @@ export type Instance = {
language?: string; language?: string;
instanceUUID?: string; instanceUUID?: string;
attributes?: { name: string; value: string }[]; attributes?: { name: string; value: string }[];
id?: string;
}; };
export type Endpoint = { export type Endpoint = {

View File

@ -46,7 +46,7 @@ limitations under the License. -->
filters?: Filters; filters?: Filters;
relatedTrace?: RelatedTrace; relatedTrace?: RelatedTrace;
id?: string; id?: string;
associate: { widgetId: string }[]; associate?: { widgetId: string }[];
} }
>, >,
default: () => ({ default: () => ({
@ -66,15 +66,10 @@ limitations under the License. -->
function getOption() { function getOption() {
const { showEchartsLegend, isRight, chartColors } = useLegendProcess(props.config.legend); const { showEchartsLegend, isRight, chartColors } = useLegendProcess(props.config.legend);
setRight.value = isRight; setRight.value = isRight;
const keys = Object.keys(props.data || {}).filter( const keys = Object.keys(props.data || {}).filter((i: any) => Array.isArray(props.data[i]) && props.data[i].length);
(i: any) => Array.isArray(props.data[i]) && props.data[i].length,
);
const temp = keys.map((i: any) => { const temp = keys.map((i: any) => {
const serie: any = { const serie: any = {
data: props.data[i].map((item: any, itemIndex: number) => [ data: props.data[i].map((item: any, itemIndex: number) => [props.intervalTime[itemIndex], item]),
props.intervalTime[itemIndex],
item,
]),
name: i, name: i,
type: "line", type: "line",
symbol: "circle", symbol: "circle",

View File

@ -139,9 +139,8 @@ limitations under the License. -->
} }
} }
} }
this.tableData = element; componentKey.value += 1;
this.componentKey += 1; flag.value = !flag.value;
this.flag = !this.flag;
} }
</script> </script>
<style lang="scss" scoped> <style lang="scss" scoped>

View File

@ -23,6 +23,7 @@
"baseUrl": ".", "baseUrl": ".",
"paths": { "paths": {
"@/*": ["./src/*"] "@/*": ["./src/*"]
} },
"noImplicitThis": false
} }
} }

View File

@ -20,5 +20,6 @@
"compilerOptions": { "compilerOptions": {
"composite": true, "composite": true,
"types": ["node"], "types": ["node"],
"noImplicitThis": false
} }
} }