mirror of
https://github.com/apache/skywalking-booster-ui.git
synced 2025-10-14 11:21:29 +00:00
types: optimize data types (#254)
This commit is contained in:
@@ -34,7 +34,7 @@ export const alarmStore = defineStore({
|
||||
total: 0,
|
||||
}),
|
||||
actions: {
|
||||
async getAlarms(params: any) {
|
||||
async getAlarms(params: Recordable) {
|
||||
const res: AxiosResponse = await graphql.query("queryAlarms").params(params);
|
||||
if (res.data.errors) {
|
||||
return res.data;
|
||||
@@ -48,6 +48,6 @@ export const alarmStore = defineStore({
|
||||
},
|
||||
});
|
||||
|
||||
export function useAlarmStore(): any {
|
||||
export function useAlarmStore(): Recordable {
|
||||
return alarmStore(store);
|
||||
}
|
||||
|
@@ -24,17 +24,17 @@ import dateFormatStep, { dateFormatTime } from "@/utils/dateFormat";
|
||||
import { TimeType } from "@/constants/data";
|
||||
/*global Nullable*/
|
||||
interface AppState {
|
||||
durationRow: any;
|
||||
durationRow: Recordable;
|
||||
utc: string;
|
||||
utcHour: number;
|
||||
utcMin: number;
|
||||
eventStack: (() => unknown)[];
|
||||
timer: Nullable<any>;
|
||||
timer: Nullable<TimeoutHandle>;
|
||||
autoRefresh: boolean;
|
||||
pageTitle: string;
|
||||
version: string;
|
||||
isMobile: boolean;
|
||||
reloadTimer: Nullable<any>;
|
||||
reloadTimer: Nullable<IntervalHandle>;
|
||||
}
|
||||
|
||||
export const appStore = defineStore({
|
||||
@@ -152,7 +152,7 @@ export const appStore = defineStore({
|
||||
}
|
||||
this.timer = setTimeout(
|
||||
() =>
|
||||
this.eventStack.forEach((event: any) => {
|
||||
this.eventStack.forEach((event: Function) => {
|
||||
setTimeout(event(), 0);
|
||||
}),
|
||||
500,
|
||||
@@ -179,11 +179,11 @@ export const appStore = defineStore({
|
||||
this.version = res.data.data.version;
|
||||
return res.data;
|
||||
},
|
||||
setReloadTimer(timer: any): void {
|
||||
setReloadTimer(timer: IntervalHandle) {
|
||||
this.reloadTimer = timer;
|
||||
},
|
||||
},
|
||||
});
|
||||
export function useAppStoreWithOut(): any {
|
||||
export function useAppStoreWithOut(): Recordable {
|
||||
return appStore(store);
|
||||
}
|
||||
|
@@ -33,7 +33,7 @@ interface DashboardState {
|
||||
entity: string;
|
||||
layerId: string;
|
||||
activedGridItem: string;
|
||||
selectorStore: any;
|
||||
selectorStore: Recordable;
|
||||
showTopology: boolean;
|
||||
currentTabItems: LayoutConfig[];
|
||||
dashboards: DashboardItem[];
|
||||
@@ -79,7 +79,7 @@ export const dashboardStore = defineStore({
|
||||
this.currentDashboard = item;
|
||||
},
|
||||
addControl(type: string) {
|
||||
const arr = this.layout.map((d: any) => Number(d.i));
|
||||
const arr = this.layout.map((d: Recordable) => Number(d.i));
|
||||
let index = String(Math.max(...arr) + 1);
|
||||
if (!this.layout.length) {
|
||||
index = "0";
|
||||
@@ -153,7 +153,7 @@ export const dashboardStore = defineStore({
|
||||
}
|
||||
const tabIndex = this.layout[idx].activedTabIndex || 0;
|
||||
const { children } = (this.layout[idx].children || [])[tabIndex];
|
||||
const arr = children.map((d: any) => Number(d.i));
|
||||
const arr = children.map((d: Recordable) => Number(d.i));
|
||||
let index = String(Math.max(...arr) + 1);
|
||||
if (!children.length) {
|
||||
index = "0";
|
||||
@@ -398,7 +398,7 @@ export const dashboardStore = defineStore({
|
||||
children: this.layout,
|
||||
...this.currentDashboard,
|
||||
};
|
||||
let res: any;
|
||||
let res: Recordable;
|
||||
let json;
|
||||
|
||||
if (this.currentDashboard.id) {
|
||||
@@ -462,13 +462,13 @@ export const dashboardStore = defineStore({
|
||||
ElMessage.error(json.message);
|
||||
return res.data;
|
||||
}
|
||||
this.dashboards = this.dashboards.filter((d: any) => d.id !== this.currentDashboard?.id);
|
||||
this.dashboards = this.dashboards.filter((d: Recordable) => d.id !== this.currentDashboard?.id);
|
||||
const key = [this.currentDashboard?.layer, this.currentDashboard?.entity, this.currentDashboard?.name].join("_");
|
||||
sessionStorage.removeItem(key);
|
||||
},
|
||||
},
|
||||
});
|
||||
|
||||
export function useDashboardStore(): any {
|
||||
export function useDashboardStore(): Recordable {
|
||||
return dashboardStore(store);
|
||||
}
|
||||
|
@@ -27,7 +27,7 @@ interface DemandLogState {
|
||||
containers: Instance[];
|
||||
instances: Instance[];
|
||||
conditions: Conditions;
|
||||
selectorStore: any;
|
||||
selectorStore: Recordable;
|
||||
logs: Log[];
|
||||
loadLogs: boolean;
|
||||
message: string;
|
||||
@@ -111,6 +111,6 @@ export const demandLogStore = defineStore({
|
||||
},
|
||||
});
|
||||
|
||||
export function useDemandLogStore(): any {
|
||||
export function useDemandLogStore(): Recordable {
|
||||
return demandLogStore(store);
|
||||
}
|
||||
|
@@ -153,6 +153,6 @@ export const ebpfStore = defineStore({
|
||||
},
|
||||
});
|
||||
|
||||
export function useEbpfStore(): any {
|
||||
export function useEbpfStore(): Recordable {
|
||||
return ebpfStore(store);
|
||||
}
|
||||
|
@@ -106,6 +106,6 @@ export const eventStore = defineStore({
|
||||
},
|
||||
});
|
||||
|
||||
export function useEventStore(): any {
|
||||
export function useEventStore(): Recordable {
|
||||
return eventStore(store);
|
||||
}
|
||||
|
@@ -27,10 +27,10 @@ interface LogState {
|
||||
services: Service[];
|
||||
instances: Instance[];
|
||||
endpoints: Endpoint[];
|
||||
conditions: any;
|
||||
selectorStore: any;
|
||||
conditions: Recordable;
|
||||
selectorStore: Recordable;
|
||||
supportQueryLogsByKeywords: boolean;
|
||||
logs: any[];
|
||||
logs: Recordable[];
|
||||
loadLogs: boolean;
|
||||
}
|
||||
|
||||
@@ -50,7 +50,7 @@ export const logStore = defineStore({
|
||||
loadLogs: false,
|
||||
}),
|
||||
actions: {
|
||||
setLogCondition(data: any) {
|
||||
setLogCondition(data: Recordable) {
|
||||
this.conditions = { ...this.conditions, ...data };
|
||||
},
|
||||
resetState() {
|
||||
@@ -152,6 +152,6 @@ export const logStore = defineStore({
|
||||
},
|
||||
});
|
||||
|
||||
export function useLogStore(): any {
|
||||
export function useLogStore(): Recordable {
|
||||
return logStore(store);
|
||||
}
|
||||
|
@@ -22,6 +22,7 @@ import type { AxiosResponse } from "axios";
|
||||
import type { Call } from "@/types/topology";
|
||||
import type { LayoutConfig } from "@/types/dashboard";
|
||||
import { ElMessage } from "element-plus";
|
||||
import type { DurationTime } from "@/types/app";
|
||||
|
||||
interface NetworkProfilingState {
|
||||
networkTasks: Array<Recordable<EBPFTaskList>>;
|
||||
@@ -74,7 +75,7 @@ export const networkProfilingStore = defineStore({
|
||||
this.activeMetricIndex = index;
|
||||
},
|
||||
setTopology(data: { nodes: ProcessNode[]; calls: Call[] }) {
|
||||
const obj = {} as any;
|
||||
const obj = {} as Recordable;
|
||||
let calls = (data.calls || []).reduce((prev: Call[], next: Call) => {
|
||||
if (!obj[next.id]) {
|
||||
obj[next.id] = true;
|
||||
@@ -92,8 +93,8 @@ export const networkProfilingStore = defineStore({
|
||||
}
|
||||
return prev;
|
||||
}, []);
|
||||
const param = {} as any;
|
||||
calls = data.calls.reduce((prev: (Call | any)[], next: Call | any) => {
|
||||
const param = {} as Recordable;
|
||||
calls = data.calls.reduce((prev: (Call & Recordable)[], next: Call & Recordable) => {
|
||||
if (param[next.targetId + next.sourceId]) {
|
||||
next.lowerArc = true;
|
||||
}
|
||||
@@ -165,7 +166,7 @@ export const networkProfilingStore = defineStore({
|
||||
}
|
||||
return res.data;
|
||||
},
|
||||
async getProcessTopology(params: { duration: any; serviceInstanceId: string }) {
|
||||
async getProcessTopology(params: { duration: DurationTime; serviceInstanceId: string }) {
|
||||
this.loadNodes = true;
|
||||
const res: AxiosResponse = await graphql.query("getProcessTopology").params(params);
|
||||
this.loadNodes = false;
|
||||
@@ -182,6 +183,6 @@ export const networkProfilingStore = defineStore({
|
||||
},
|
||||
});
|
||||
|
||||
export function useNetworkProfilingStore(): any {
|
||||
export function useNetworkProfilingStore(): Recordable {
|
||||
return networkProfilingStore(store);
|
||||
}
|
||||
|
@@ -162,10 +162,35 @@ export const profileStore = defineStore({
|
||||
}
|
||||
return res.data;
|
||||
},
|
||||
async getSegmentSpans() {
|
||||
this.analyzeTrees = [];
|
||||
this.segmentSpans = this.currentSegment.spans;
|
||||
this.currentSpan = this.currentSegment.spans[0] || {};
|
||||
async getSegmentSpans(params: { segmentId: string }) {
|
||||
if (!params.segmentId) {
|
||||
return new Promise((resolve) => resolve({}));
|
||||
}
|
||||
const res: AxiosResponse = await graphql.query("queryProfileSegment").params(params);
|
||||
if (res.data.errors) {
|
||||
this.segmentSpans = [];
|
||||
return res.data;
|
||||
}
|
||||
const { segment } = res.data.data;
|
||||
if (!segment) {
|
||||
this.segmentSpans = [];
|
||||
this.analyzeTrees = [];
|
||||
return res.data;
|
||||
}
|
||||
this.segmentSpans = segment.spans.map((d: SegmentSpan) => {
|
||||
return {
|
||||
...d,
|
||||
segmentId: this.currentSegment?.segmentId,
|
||||
traceId: (this.currentSegment.traceIds as string[])[0],
|
||||
};
|
||||
});
|
||||
if (!(segment.spans && segment.spans.length)) {
|
||||
this.analyzeTrees = [];
|
||||
return res.data;
|
||||
}
|
||||
const index = segment.spans.length - 1 || 0;
|
||||
this.currentSpan = segment.spans[index];
|
||||
return res.data;
|
||||
},
|
||||
async getProfileAnalyze(params: Array<{ segmentId: string; timeRange: { start: number; end: number } }>) {
|
||||
if (!params.length) {
|
||||
@@ -211,6 +236,6 @@ export const profileStore = defineStore({
|
||||
},
|
||||
});
|
||||
|
||||
export function useProfileStore(): any {
|
||||
export function useProfileStore(): Recordable {
|
||||
return profileStore(store);
|
||||
}
|
||||
|
@@ -233,6 +233,6 @@ export const selectorStore = defineStore({
|
||||
},
|
||||
});
|
||||
|
||||
export function useSelectorStore(): any {
|
||||
export function useSelectorStore(): Recordable {
|
||||
return selectorStore(store);
|
||||
}
|
||||
|
@@ -73,7 +73,7 @@ export const topologyStore = defineStore({
|
||||
this.nodes = data.nodes;
|
||||
},
|
||||
setTopology(data: { nodes: Node[]; calls: Call[] }) {
|
||||
const obj = {} as any;
|
||||
const obj = {} as Recordable;
|
||||
const services = useSelectorStore().services;
|
||||
const nodes = (data.nodes || []).reduce((prev: Node[], next: Node) => {
|
||||
if (!obj[next.id]) {
|
||||
@@ -302,8 +302,8 @@ export const topologyStore = defineStore({
|
||||
return res.data;
|
||||
}
|
||||
const topo = res.data.data;
|
||||
const calls = [] as any;
|
||||
const nodes = [] as any;
|
||||
const calls = [] as Call[];
|
||||
const nodes = [] as Node[];
|
||||
for (const key of Object.keys(topo)) {
|
||||
calls.push(...topo[key].calls);
|
||||
nodes.push(...topo[key].nodes);
|
||||
@@ -377,7 +377,7 @@ export const topologyStore = defineStore({
|
||||
}
|
||||
const data = res.data.data;
|
||||
const metrics = Object.keys(data);
|
||||
this.nodes = this.nodes.map((d: Node | any) => {
|
||||
this.nodes = this.nodes.map((d: Node & Recordable) => {
|
||||
for (const m of metrics) {
|
||||
for (const val of data[m].values) {
|
||||
if (d.id === val.id) {
|
||||
@@ -410,6 +410,6 @@ export const topologyStore = defineStore({
|
||||
},
|
||||
});
|
||||
|
||||
export function useTopologyStore(): any {
|
||||
export function useTopologyStore(): Recordable {
|
||||
return topologyStore(store);
|
||||
}
|
||||
|
@@ -31,9 +31,9 @@ interface TraceState {
|
||||
traceList: Trace[];
|
||||
traceSpans: Span[];
|
||||
currentTrace: Recordable<Trace>;
|
||||
conditions: any;
|
||||
traceSpanLogs: any[];
|
||||
selectorStore: any;
|
||||
conditions: Recordable;
|
||||
traceSpanLogs: Recordable[];
|
||||
selectorStore: Recordable;
|
||||
}
|
||||
|
||||
export const traceStore = defineStore({
|
||||
@@ -55,7 +55,7 @@ export const traceStore = defineStore({
|
||||
selectorStore: useSelectorStore(),
|
||||
}),
|
||||
actions: {
|
||||
setTraceCondition(data: any) {
|
||||
setTraceCondition(data: Recordable) {
|
||||
this.conditions = { ...this.conditions, ...data };
|
||||
},
|
||||
setCurrentTrace(trace: Recordable<Trace>) {
|
||||
@@ -171,7 +171,7 @@ export const traceStore = defineStore({
|
||||
this.setTraceSpans(data || []);
|
||||
return res.data;
|
||||
},
|
||||
async getSpanLogs(params: any) {
|
||||
async getSpanLogs(params: Recordable) {
|
||||
const res: AxiosResponse = await graphql.query("queryServiceLogs").params(params);
|
||||
if (res.data.errors) {
|
||||
this.traceSpanLogs = [];
|
||||
@@ -197,6 +197,6 @@ export const traceStore = defineStore({
|
||||
},
|
||||
});
|
||||
|
||||
export function useTraceStore(): any {
|
||||
export function useTraceStore(): Recordable {
|
||||
return traceStore(store);
|
||||
}
|
||||
|
Reference in New Issue
Block a user