build: migrate the build tool from vue-cli to vite4 (#208)

This commit is contained in:
Fine0830
2022-12-17 14:07:03 +08:00
committed by GitHub
parent 1e0c253488
commit 44dcb1e7f6
214 changed files with 27014 additions and 54234 deletions

View File

@@ -17,8 +17,8 @@
import { defineStore } from "pinia";
import { store } from "@/store";
import graphql from "@/graphql";
import { AxiosResponse } from "axios";
import { Alarm } from "@/types/alarm";
import type { AxiosResponse } from "axios";
import type { Alarm } from "@/types/alarm";
interface AlarmState {
loading: boolean;
@@ -35,9 +35,7 @@ export const alarmStore = defineStore({
}),
actions: {
async getAlarms(params: any) {
const res: AxiosResponse = await graphql
.query("queryAlarms")
.params(params);
const res: AxiosResponse = await graphql.query("queryAlarms").params(params);
if (res.data.errors) {
return res.data;
}

View File

@@ -17,9 +17,9 @@
import { defineStore } from "pinia";
import { store } from "@/store";
import graphql from "@/graphql";
import { Duration, DurationTime } from "@/types/app";
import type { Duration, DurationTime } from "@/types/app";
import getLocalTime from "@/utils/localtime";
import { AxiosResponse } from "axios";
import type { AxiosResponse } from "axios";
import dateFormatStep, { dateFormatTime } from "@/utils/dateFormat";
import { TimeType } from "@/constants/data";
/*global Nullable*/
@@ -92,9 +92,7 @@ export const appStore = defineStore({
this.duration.start.getMonth());
break;
}
const utcSpace =
(this.utcHour + new Date().getTimezoneOffset() / 60) * 3600000 +
this.utcMin * 60000;
const utcSpace = (this.utcHour + new Date().getTimezoneOffset() / 60) * 3600000 + this.utcMin * 60000;
const startUnix: number = this.duration.start.getTime();
const endUnix: number = this.duration.end.getTime();
const timeIntervals: number[] = [];
@@ -157,13 +155,11 @@ export const appStore = defineStore({
this.eventStack.forEach((event: any) => {
setTimeout(event(), 0);
}),
500
500,
);
},
async queryOAPTimeInfo() {
const res: AxiosResponse = await graphql
.query("queryOAPTimeInfo")
.params({});
const res: AxiosResponse = await graphql.query("queryOAPTimeInfo").params({});
if (res.data.errors) {
this.utc = -(new Date().getTimezoneOffset() / 60) + ":0";
} else {
@@ -176,9 +172,7 @@ export const appStore = defineStore({
return res.data;
},
async fetchVersion(): Promise<void> {
const res: AxiosResponse = await graphql
.query("queryOAPVersion")
.params({});
const res: AxiosResponse = await graphql.query("queryOAPVersion").params({});
if (res.data.errors) {
return res.data;
}

View File

@@ -16,13 +16,13 @@
*/
import { defineStore } from "pinia";
import { store } from "@/store";
import { LayoutConfig } from "@/types/dashboard";
import type { LayoutConfig } from "@/types/dashboard";
import graphql from "@/graphql";
import query from "@/graphql/fetch";
import { DashboardItem } from "@/types/dashboard";
import type { DashboardItem } from "@/types/dashboard";
import { useSelectorStore } from "@/store/modules/selectors";
import { NewControl, TextConfig, TimeRangeConfig } from "../data";
import { AxiosResponse } from "axios";
import type { AxiosResponse } from "axios";
import { ElMessage } from "element-plus";
import { useI18n } from "vue-i18n";
import { EntityType } from "@/views/dashboard/data";
@@ -105,24 +105,10 @@ export const dashboardStore = defineStore({
newItem.h = 36;
newItem.graph = {
showDepth: true,
depth:
this.entity === EntityType[1].value
? 1
: this.entity === EntityType[0].value
? 2
: 3,
depth: 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)) {
newItem.h = 36;
}
if (type === "Text") {
@@ -156,14 +142,12 @@ export const dashboardStore = defineStore({
},
addTabControls(type: string) {
const activedGridItem = this.activedGridItem.split("-")[0];
const idx = this.layout.findIndex(
(d: LayoutConfig) => d.i === activedGridItem
);
const idx = this.layout.findIndex((d: LayoutConfig) => d.i === activedGridItem);
if (idx < 0) {
return;
}
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));
let index = String(Math.max(...arr) + 1);
if (!children.length) {
@@ -184,16 +168,7 @@ export const dashboardStore = defineStore({
showDepth: true,
};
}
if (
[
"Trace",
"Profile",
"Log",
"DemandLog",
"Ebpf",
"NetworkProfiling",
].includes(type)
) {
if (["Trace", "Profile", "Log", "DemandLog", "Ebpf", "NetworkProfiling"].includes(type)) {
newItem.h = 32;
}
if (type === "Text") {
@@ -211,7 +186,7 @@ export const dashboardStore = defineStore({
return d;
});
items.push(newItem);
this.layout[idx].children[tabIndex].children = items;
(this.layout[idx].children || [])[tabIndex].children = items;
this.currentTabItems = items;
}
},
@@ -238,19 +213,15 @@ export const dashboardStore = defineStore({
},
removeControls(item: LayoutConfig) {
const actived = this.activedGridItem.split("-");
const index = this.layout.findIndex(
(d: LayoutConfig) => actived[0] === d.i
);
const index = this.layout.findIndex((d: LayoutConfig) => actived[0] === d.i);
if (this.selectedGrid && this.selectedGrid.i === item.i) {
this.selectedGrid = null;
}
if (actived.length === 3) {
const tabIndex = Number(actived[1]);
this.currentTabItems = this.currentTabItems.filter(
(d: LayoutConfig) => actived[2] !== d.i
);
this.layout[index].children[tabIndex].children = this.currentTabItems;
this.currentTabItems = this.currentTabItems.filter((d: LayoutConfig) => actived[2] !== d.i);
(this.layout[index].children || [])[tabIndex].children = this.currentTabItems;
return;
}
this.layout = this.layout.filter((d: LayoutConfig) => d.i !== item.i);
@@ -258,8 +229,8 @@ export const dashboardStore = defineStore({
removeTabItem(item: LayoutConfig, index: number) {
const idx = this.layout.findIndex((d: LayoutConfig) => d.i === item.i);
if (this.selectedGrid) {
for (const item of this.layout[idx].children[index].children) {
if (this.selectedGrid.i === item.i) {
for (const item of (this.layout[idx].children || [])[index].children) {
if (this.selectedGrid?.i === item.i) {
this.selectedGrid = null;
}
}
@@ -285,22 +256,19 @@ export const dashboardStore = defineStore({
},
setConfigs(param: { [key: string]: unknown }) {
const actived = this.activedGridItem.split("-");
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) {
const tabIndex = Number(actived[1]);
const itemIndex = this.layout[index].children[
tabIndex
].children.findIndex((d: LayoutConfig) => actived[2] === d.i);
const itemIndex = (this.layout[index].children || [])[tabIndex].children.findIndex(
(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,
};
this.selectedGrid =
this.layout[index].children[tabIndex].children[itemIndex];
this.setCurrentTabItems(this.layout[index].children[tabIndex].children);
this.selectedGrid = (this.layout[index].children || [])[tabIndex].children[itemIndex];
this.setCurrentTabItems((this.layout[index].children || [])[tabIndex].children);
return;
}
this.layout[index] = {
@@ -312,8 +280,8 @@ export const dashboardStore = defineStore({
setWidget(param: LayoutConfig) {
for (let i = 0; i < this.layout.length; i++) {
if (this.layout[i].type === "Tab") {
if (this.layout[i].children && this.layout[i].children.length) {
for (const child of this.layout[i].children) {
if ((this.layout[i].children || []).length) {
for (const child of this.layout[i].children || []) {
if (child.children && child.children.length) {
for (let c = 0; c < child.children.length; c++) {
if (child.children[c].id === param.id) {
@@ -332,23 +300,16 @@ export const dashboardStore = defineStore({
}
},
async fetchMetricType(item: string) {
const res: AxiosResponse = await graphql
.query("queryTypeOfMetrics")
.params({ name: item });
const res: AxiosResponse = await graphql.query("queryTypeOfMetrics").params({ name: item });
return res.data;
},
async fetchMetricList(regex: string) {
const res: AxiosResponse = await graphql
.query("queryMetrics")
.params({ regex });
const res: AxiosResponse = await graphql.query("queryMetrics").params({ regex });
return res.data;
},
async fetchMetricValue(param: {
queryStr: string;
conditions: { [key: string]: unknown };
}) {
async fetchMetricValue(param: { queryStr: string; conditions: { [key: string]: unknown } }) {
const res: AxiosResponse = await query(param);
return res.data;
},
@@ -371,10 +332,7 @@ export const dashboardStore = defineStore({
name: c.name,
isRoot: c.isRoot,
});
sessionStorage.setItem(
key,
JSON.stringify({ id: t.id, configuration: c })
);
sessionStorage.setItem(key, JSON.stringify({ id: t.id, configuration: c }));
}
list = list.sort((a, b) => {
const nameA = a.name.toUpperCase();
@@ -399,9 +357,7 @@ export const dashboardStore = defineStore({
return;
}
}
this.dashboards = JSON.parse(
sessionStorage.getItem("dashboards") || "[]"
);
this.dashboards = JSON.parse(sessionStorage.getItem("dashboards") || "[]");
},
async resetTemplates() {
const res = await this.fetchTemplates();
@@ -410,9 +366,7 @@ export const dashboardStore = defineStore({
ElMessage.error(res.errors);
return;
}
this.dashboards = JSON.parse(
sessionStorage.getItem("dashboards") || "[]"
);
this.dashboards = JSON.parse(sessionStorage.getItem("dashboards") || "[]");
},
async updateDashboard(setting: { id: string; configuration: string }) {
const res: AxiosResponse = await graphql.query("updateTemplate").params({
@@ -431,7 +385,7 @@ export const dashboardStore = defineStore({
return res.data;
},
async saveDashboard() {
if (!this.currentDashboard.name) {
if (!this.currentDashboard?.name) {
ElMessage.error("The dashboard name is needed.");
return;
}
@@ -452,18 +406,16 @@ export const dashboardStore = defineStore({
c.isRoot = false;
const index = this.dashboards.findIndex(
(d: DashboardItem) =>
d.name === this.currentDashboard.name &&
d.name === this.currentDashboard?.name &&
d.entity === this.currentDashboard.entity &&
d.layer === this.currentDashboard.layerId
d.layer === this.currentDashboard?.layer,
);
if (index > -1) {
const { t } = useI18n();
ElMessage.error(t("nameError"));
return;
}
res = await graphql
.query("addNewTemplate")
.params({ setting: { configuration: JSON.stringify(c) } });
res = await graphql.query("addNewTemplate").params({ setting: { configuration: JSON.stringify(c) } });
json = res.data.data.addTemplate;
}
@@ -478,17 +430,11 @@ export const dashboardStore = defineStore({
if (!this.currentDashboard.id) {
ElMessage.success("Saved successfully");
}
const key = [
this.currentDashboard.layer,
this.currentDashboard.entity,
this.currentDashboard.name,
].join("_");
const key = [this.currentDashboard.layer, this.currentDashboard.entity, this.currentDashboard.name].join("_");
this.currentDashboard.id = json.id;
if (this.currentDashboard.id) {
sessionStorage.removeItem(key);
this.dashboards = this.dashboards.filter(
(d: DashboardItem) => d.id !== this.currentDashboard.id
);
this.dashboards = this.dashboards.filter((d: DashboardItem) => d.id !== this.currentDashboard?.id);
}
this.dashboards.push(this.currentDashboard);
const l = { id: json.id, configuration: c };
@@ -498,9 +444,7 @@ export const dashboardStore = defineStore({
return json;
},
async deleteDashboard() {
const res: AxiosResponse = await graphql
.query("removeTemplate")
.params({ id: this.currentDashboard.id });
const res: AxiosResponse = await graphql.query("removeTemplate").params({ id: this.currentDashboard?.id });
if (res.data.errors) {
ElMessage.error(res.data.errors);
@@ -511,14 +455,8 @@ export const dashboardStore = defineStore({
ElMessage.error(json.message);
return res.data;
}
this.dashboards = this.dashboards.filter(
(d: any) => d.id !== this.currentDashboard.id
);
const key = [
this.currentDashboard.layer,
this.currentDashboard.entity,
this.currentDashboard.name,
].join("_");
this.dashboards = this.dashboards.filter((d: any) => d.id !== this.currentDashboard?.id);
const key = [this.currentDashboard?.layer, this.currentDashboard?.entity, this.currentDashboard?.name].join("_");
sessionStorage.removeItem(key);
},
},

View File

@@ -15,13 +15,13 @@
* limitations under the License.
*/
import { defineStore } from "pinia";
import { Instance } from "@/types/selector";
import type { Instance } from "@/types/selector";
import { store } from "@/store";
import graphql from "@/graphql";
import { AxiosResponse } from "axios";
import type { AxiosResponse } from "axios";
import { useAppStoreWithOut } from "@/store/modules/app";
import { useSelectorStore } from "@/store/modules/selectors";
import { Conditions, Log } from "@/types/demand-log";
import type { Conditions, Log } from "@/types/demand-log";
interface DemandLogState {
containers: Instance[];
@@ -59,9 +59,7 @@ export const demandLogStore = defineStore({
this.message = message || "";
},
async getInstances(id: string) {
const serviceId = this.selectorStore.currentService
? this.selectorStore.currentService.id
: id;
const serviceId = this.selectorStore.currentService ? this.selectorStore.currentService.id : id;
const res: AxiosResponse = await graphql.query("queryInstances").params({
serviceId,
duration: useAppStoreWithOut().durationTime,
@@ -75,16 +73,12 @@ export const demandLogStore = defineStore({
},
async getContainers(serviceInstanceId: string) {
if (!serviceInstanceId) {
return new Promise((resolve) =>
resolve({ errors: "No service instance" })
);
return new Promise((resolve) => resolve({ errors: "No service instance" }));
}
const condition = {
serviceInstanceId,
};
const res: AxiosResponse = await graphql
.query("fetchContainers")
.params({ condition });
const res: AxiosResponse = await graphql.query("fetchContainers").params({ condition });
if (res.data.errors) {
return res.data;
@@ -100,21 +94,17 @@ export const demandLogStore = defineStore({
},
async getDemandLogs() {
this.loadLogs = true;
const res: AxiosResponse = await graphql
.query("fetchDemandPodLogs")
.params({ condition: this.conditions });
const res: AxiosResponse = await graphql.query("fetchDemandPodLogs").params({ condition: this.conditions });
this.loadLogs = false;
if (res.data.errors) {
return res.data;
}
if (res.data.data.logs.errorReason) {
this.setLogs("", res.data.data.logs.errorReason);
this.setLogs([], res.data.data.logs.errorReason);
return res.data;
}
this.total = res.data.data.logs.logs.length;
const logs = res.data.data.logs.logs
.map((d: Log) => d.content)
.join("\n");
const logs = res.data.data.logs.logs.map((d: Log) => d.content).join("\n");
this.setLogs(logs);
return res.data;
},

View File

@@ -15,18 +15,13 @@
* limitations under the License.
*/
import { defineStore } from "pinia";
import { Option } from "@/types/app";
import {
EBPFTaskCreationRequest,
EBPFProfilingSchedule,
EBPFTaskList,
AnalyzationTrees,
} from "@/types/ebpf";
import type { Option } from "@/types/app";
import type { EBPFTaskCreationRequest, EBPFProfilingSchedule, EBPFTaskList, AnalyzationTrees } from "@/types/ebpf";
import { store } from "@/store";
import graphql from "@/graphql";
import { AxiosResponse } from "axios";
import type { AxiosResponse } from "axios";
interface EbpfState {
taskList: EBPFTaskList[];
taskList: Array<Recordable<EBPFTaskList>>;
eBPFSchedules: EBPFProfilingSchedule[];
currentSchedule: EBPFProfilingSchedule | Record<string, never>;
analyzeTrees: AnalyzationTrees[];
@@ -51,7 +46,7 @@ export const ebpfStore = defineStore({
aggregateType: "COUNT",
}),
actions: {
setSelectedTask(task: EBPFTaskList) {
setSelectedTask(task: Recordable<EBPFTaskList>) {
this.selectedTask = task || {};
},
setCurrentSchedule(s: EBPFProfilingSchedule) {
@@ -61,9 +56,7 @@ export const ebpfStore = defineStore({
this.analyzeTrees = tree;
},
async getCreateTaskData(serviceId: string) {
const res: AxiosResponse = await graphql
.query("getCreateTaskData")
.params({ serviceId });
const res: AxiosResponse = await graphql.query("getCreateTaskData").params({ serviceId });
if (res.data.errors) {
return res.data;
@@ -76,9 +69,7 @@ export const ebpfStore = defineStore({
return res.data;
},
async createTask(param: EBPFTaskCreationRequest) {
const res: AxiosResponse = await graphql
.query("saveEBPFTask")
.params({ request: param });
const res: AxiosResponse = await graphql.query("saveEBPFTask").params({ request: param });
if (res.data.errors) {
return res.data;
@@ -89,17 +80,11 @@ export const ebpfStore = defineStore({
});
return res.data;
},
async getTaskList(params: {
serviceId: string;
serviceInstanceId: string;
targets: string[];
}) {
async getTaskList(params: { serviceId: string; targets: string[] }) {
if (!params.serviceId) {
return new Promise((resolve) => resolve({}));
}
const res: AxiosResponse = await graphql
.query("getEBPFTasks")
.params(params);
const res: AxiosResponse = await graphql.query("getEBPFTasks").params(params);
this.tip = "";
if (res.data.errors) {
@@ -111,16 +96,14 @@ export const ebpfStore = defineStore({
if (!this.taskList.length) {
return res.data;
}
this.getEBPFSchedules({ taskId: this.taskList[0].taskId });
this.getEBPFSchedules({ taskId: String(this.taskList[0].taskId) });
return res.data;
},
async getEBPFSchedules(params: { taskId: string }) {
if (!params.taskId) {
return new Promise((resolve) => resolve({}));
}
const res: AxiosResponse = await graphql
.query("getEBPFSchedules")
.params({ ...params });
const res: AxiosResponse = await graphql.query("getEBPFSchedules").params({ ...params });
if (res.data.errors) {
this.eBPFSchedules = [];
@@ -148,9 +131,7 @@ export const ebpfStore = defineStore({
if (!params.timeRanges.length) {
return new Promise((resolve) => resolve({}));
}
const res: AxiosResponse = await graphql
.query("getEBPFResult")
.params(params);
const res: AxiosResponse = await graphql.query("getEBPFResult").params(params);
if (res.data.errors) {
this.analyzeTrees = [];

View File

@@ -17,9 +17,9 @@
import { defineStore } from "pinia";
import { store } from "@/store";
import graphql from "@/graphql";
import { AxiosResponse } from "axios";
import { Event, QueryEventCondition } from "@/types/events";
import { Instance, Endpoint } from "@/types/selector";
import type { AxiosResponse } from "axios";
import type { Event, QueryEventCondition } from "@/types/events";
import type { Instance, Endpoint } from "@/types/selector";
import { useAppStoreWithOut } from "@/store/modules/app";
import { useSelectorStore } from "@/store/modules/selectors";
@@ -45,9 +45,7 @@ export const eventStore = defineStore({
this.condition = data;
},
async getInstances() {
const serviceId = useSelectorStore().currentService
? useSelectorStore().currentService.id
: "";
const serviceId = useSelectorStore().currentService ? useSelectorStore().currentService.id : "";
const res: AxiosResponse = await graphql.query("queryInstances").params({
serviceId,
duration: useAppStoreWithOut().durationTime,
@@ -56,15 +54,11 @@ export const eventStore = defineStore({
if (res.data.errors) {
return res.data;
}
this.instances = [{ value: "", label: "All" }, ...res.data.data.pods] || [
{ value: "", label: "All" },
];
this.instances = [{ value: "", label: "All" }, ...res.data.data.pods] || [{ value: "", label: "All" }];
return res.data;
},
async getEndpoints() {
const serviceId = useSelectorStore().currentService
? useSelectorStore().currentService.id
: "";
const serviceId = useSelectorStore().currentService ? useSelectorStore().currentService.id : "";
if (!serviceId) {
return;
}
@@ -76,9 +70,7 @@ export const eventStore = defineStore({
if (res.data.errors) {
return res.data;
}
this.endpoints = [{ value: "", label: "All" }, ...res.data.data.pods] || [
{ value: "", label: "All" },
];
this.endpoints = [{ value: "", label: "All" }, ...res.data.data.pods] || [{ value: "", label: "All" }];
return res.data;
},
async getEvents() {
@@ -94,22 +86,20 @@ export const eventStore = defineStore({
return res.data;
}
if (res.data.data.fetchEvents) {
this.events = (res.data.data.fetchEvents.events || []).map(
(item: Event) => {
let scope = "Service";
if (item.source.serviceInstance) {
scope = "ServiceInstance";
}
if (item.source.endpoint) {
scope = "Endpoint";
}
item.scope = scope;
if (!item.endTime || item.endTime === item.startTime) {
item.endTime = Number(item.startTime) + 60000;
}
return item;
this.events = (res.data.data.fetchEvents.events || []).map((item: Event) => {
let scope = "Service";
if (item.source.serviceInstance) {
scope = "ServiceInstance";
}
);
if (item.source.endpoint) {
scope = "Endpoint";
}
item.scope = scope;
if (!item.endTime || item.endTime === item.startTime) {
item.endTime = Number(item.startTime) + 60000;
}
return item;
});
}
return res.data;
},

View File

@@ -15,10 +15,10 @@
* limitations under the License.
*/
import { defineStore } from "pinia";
import { Instance, Endpoint, Service } from "@/types/selector";
import type { Instance, Endpoint, Service } from "@/types/selector";
import { store } from "@/store";
import graphql from "@/graphql";
import { AxiosResponse } from "axios";
import type { AxiosResponse } from "axios";
import { useAppStoreWithOut } from "@/store/modules/app";
import { useSelectorStore } from "@/store/modules/selectors";
import { useDashboardStore } from "@/store/modules/dashboard";
@@ -71,9 +71,7 @@ export const logStore = defineStore({
return res.data;
},
async getInstances(id: string) {
const serviceId = this.selectorStore.currentService
? this.selectorStore.currentService.id
: id;
const serviceId = this.selectorStore.currentService ? this.selectorStore.currentService.id : id;
const res: AxiosResponse = await graphql.query("queryInstances").params({
serviceId,
duration: useAppStoreWithOut().durationTime,
@@ -82,16 +80,11 @@ export const logStore = defineStore({
if (res.data.errors) {
return res.data;
}
this.instances = [
{ value: "0", label: "All" },
...res.data.data.pods,
] || [{ value: " 0", label: "All" }];
this.instances = [{ value: "0", label: "All" }, ...res.data.data.pods] || [{ value: " 0", label: "All" }];
return res.data;
},
async getEndpoints(id: string, keyword?: string) {
const serviceId = this.selectorStore.currentService
? this.selectorStore.currentService.id
: id;
const serviceId = this.selectorStore.currentService ? this.selectorStore.currentService.id : id;
const res: AxiosResponse = await graphql.query("queryEndpoints").params({
serviceId,
duration: useAppStoreWithOut().durationTime,
@@ -100,16 +93,11 @@ export const logStore = defineStore({
if (res.data.errors) {
return res.data;
}
this.endpoints = [
{ value: "0", label: "All" },
...res.data.data.pods,
] || [{ value: "0", label: "All" }];
this.endpoints = [{ value: "0", label: "All" }, ...res.data.data.pods] || [{ value: "0", label: "All" }];
return res.data;
},
async getLogsByKeywords() {
const res: AxiosResponse = await graphql
.query("queryLogsByKeywords")
.params({});
const res: AxiosResponse = await graphql.query("queryLogsByKeywords").params({});
if (res.data.errors) {
return res.data;
@@ -127,9 +115,7 @@ export const logStore = defineStore({
},
async getServiceLogs() {
this.loadLogs = true;
const res: AxiosResponse = await graphql
.query("queryServiceLogs")
.params({ condition: this.conditions });
const res: AxiosResponse = await graphql.query("queryServiceLogs").params({ condition: this.conditions });
this.loadLogs = false;
if (res.data.errors) {
return res.data;
@@ -140,9 +126,7 @@ export const logStore = defineStore({
},
async getBrowserLogs() {
this.loadLogs = true;
const res: AxiosResponse = await graphql
.query("queryBrowserErrorLogs")
.params({ condition: this.conditions });
const res: AxiosResponse = await graphql.query("queryBrowserErrorLogs").params({ condition: this.conditions });
this.loadLogs = false;
if (res.data.errors) {

View File

@@ -15,16 +15,16 @@
* limitations under the License.
*/
import { defineStore } from "pinia";
import { EBPFTaskList, ProcessNode } from "@/types/ebpf";
import type { EBPFTaskList, ProcessNode } from "@/types/ebpf";
import { store } from "@/store";
import graphql from "@/graphql";
import { AxiosResponse } from "axios";
import { Call } from "@/types/topology";
import { LayoutConfig } from "@/types/dashboard";
import type { AxiosResponse } from "axios";
import type { Call } from "@/types/topology";
import type { LayoutConfig } from "@/types/dashboard";
import { ElMessage } from "element-plus";
interface NetworkProfilingState {
networkTasks: EBPFTaskList[];
networkTasks: Array<Recordable<EBPFTaskList>>;
networkTip: string;
selectedNetworkTask: Recordable<EBPFTaskList>;
nodes: ProcessNode[];
@@ -55,10 +55,10 @@ export const networkProfilingStore = defineStore({
loadNodes: false,
}),
actions: {
setSelectedNetworkTask(task: EBPFTaskList) {
setSelectedNetworkTask(task: Recordable<EBPFTaskList>) {
this.selectedNetworkTask = task || {};
},
setNode(node: Node) {
setNode(node: Nullable<ProcessNode>) {
this.node = node;
},
setLink(link: Call) {
@@ -117,33 +117,25 @@ export const networkProfilingStore = defineStore({
when4xx: string;
when5xx: string;
minDuration: number;
}[]
}[],
) {
const res: AxiosResponse = await graphql
.query("newNetworkProfiling")
.params({
request: {
instanceId,
samplings: params,
},
});
const res: AxiosResponse = await graphql.query("newNetworkProfiling").params({
request: {
instanceId,
samplings: params,
},
});
if (res.data.errors) {
return res.data;
}
return res.data;
},
async getTaskList(params: {
serviceId: string;
serviceInstanceId: string;
targets: string[];
}) {
async getTaskList(params: { serviceId: string; serviceInstanceId: string; targets: string[] }) {
if (!params.serviceId) {
return new Promise((resolve) => resolve({}));
}
const res: AxiosResponse = await graphql
.query("getEBPFTasks")
.params(params);
const res: AxiosResponse = await graphql.query("getEBPFTasks").params(params);
this.networkTip = "";
if (res.data.errors) {
@@ -162,11 +154,8 @@ export const networkProfilingStore = defineStore({
if (!taskId) {
return new Promise((resolve) => resolve({}));
}
const res: AxiosResponse = await graphql
.query("aliveNetworkProfiling")
.params({ taskId });
const res: AxiosResponse = await graphql.query("aliveNetworkProfiling").params({ taskId });
this.aliveMessage = "";
if (res.data.errors) {
return res.data;
}
@@ -176,14 +165,9 @@ export const networkProfilingStore = defineStore({
}
return res.data;
},
async getProcessTopology(params: {
duration: any;
serviceInstanceId: string;
}) {
async getProcessTopology(params: { duration: any; serviceInstanceId: string }) {
this.loadNodes = true;
const res: AxiosResponse = await graphql
.query("getProcessTopology")
.params(params);
const res: AxiosResponse = await graphql.query("getProcessTopology").params(params);
this.loadNodes = false;
if (res.data.errors) {
this.nodes = [];

View File

@@ -15,18 +15,18 @@
* limitations under the License.
*/
import { defineStore } from "pinia";
import { Endpoint } from "@/types/selector";
import {
import type { Endpoint } from "@/types/selector";
import type {
TaskListItem,
SegmentSpan,
ProfileAnalyzationTrees,
TaskLog,
ProfileTaskCreationRequest,
} from "@/types/profile";
import { Trace, Span } from "@/types/trace";
import type { Trace } from "@/types/trace";
import { store } from "@/store";
import graphql from "@/graphql";
import { AxiosResponse } from "axios";
import type { AxiosResponse } from "axios";
import { useAppStoreWithOut } from "@/store/modules/app";
interface ProfileState {
@@ -35,9 +35,9 @@ interface ProfileState {
condition: { serviceId: string; endpointName: string };
taskList: TaskListItem[];
segmentList: Trace[];
currentSegment: Trace | Record<string, never>;
segmentSpans: SegmentSpan[];
currentSpan: SegmentSpan | Record<string, never>;
currentSegment: Recordable<Trace>;
segmentSpans: Array<Recordable<SegmentSpan>>;
currentSpan: Recordable<SegmentSpan>;
analyzeTrees: ProfileAnalyzationTrees;
taskLogs: TaskLog[];
highlightTop: boolean;
@@ -65,10 +65,10 @@ export const profileStore = defineStore({
...data,
};
},
setCurrentSpan(span: Span) {
setCurrentSpan(span: Recordable<SegmentSpan>) {
this.currentSpan = span;
},
setCurrentSegment(s: Trace) {
setCurrentSegment(s: Recordable<Trace>) {
this.currentSegment = s;
},
setHighlightTop() {
@@ -99,9 +99,7 @@ export const profileStore = defineStore({
return res.data;
},
async getTaskList() {
const res: AxiosResponse = await graphql
.query("getProfileTaskList")
.params(this.condition);
const res: AxiosResponse = await graphql.query("getProfileTaskList").params(this.condition);
if (res.data.errors) {
return res.data;
@@ -122,9 +120,7 @@ export const profileStore = defineStore({
if (!params.taskID) {
return new Promise((resolve) => resolve({}));
}
const res: AxiosResponse = await graphql
.query("getProfileTaskSegmentList")
.params(params);
const res: AxiosResponse = await graphql.query("getProfileTaskSegmentList").params(params);
if (res.data.errors) {
this.segmentList = [];
@@ -143,7 +139,7 @@ export const profileStore = defineStore({
this.currentSegment = segmentList[0];
this.getSegmentSpans({ segmentId: segmentList[0].segmentId });
} else {
this.currentSegment = null;
this.currentSegment = {};
}
return res.data;
},
@@ -151,9 +147,7 @@ export const profileStore = defineStore({
if (!params.segmentId) {
return new Promise((resolve) => resolve({}));
}
const res: AxiosResponse = await graphql
.query("queryProfileSegment")
.params(params);
const res: AxiosResponse = await graphql.query("queryProfileSegment").params(params);
if (res.data.errors) {
this.segmentSpans = [];
return res.data;
@@ -167,8 +161,8 @@ export const profileStore = defineStore({
this.segmentSpans = segment.spans.map((d: SegmentSpan) => {
return {
...d,
segmentId: this.currentSegment.segmentId,
traceId: this.currentSegment.traceIds[0],
segmentId: this.currentSegment?.segmentId,
traceId: (this.currentSegment.traceIds as any)[0],
};
});
if (!(segment.spans && segment.spans.length)) {
@@ -179,19 +173,14 @@ export const profileStore = defineStore({
this.currentSpan = segment.spans[index];
return res.data;
},
async getProfileAnalyze(params: {
segmentId: string;
timeRanges: Array<{ start: number; end: number }>;
}) {
async getProfileAnalyze(params: { segmentId: string; timeRanges: Array<{ start: number; end: number }> }) {
if (!params.segmentId) {
return new Promise((resolve) => resolve({}));
}
if (!params.timeRanges.length) {
return new Promise((resolve) => resolve({}));
}
const res: AxiosResponse = await graphql
.query("getProfileAnalyze")
.params(params);
const res: AxiosResponse = await graphql.query("getProfileAnalyze").params(params);
if (res.data.errors) {
this.analyzeTrees = [];
@@ -211,9 +200,7 @@ export const profileStore = defineStore({
return res.data;
},
async createTask(param: ProfileTaskCreationRequest) {
const res: AxiosResponse = await graphql
.query("saveProfileTask")
.params({ creationRequest: param });
const res: AxiosResponse = await graphql.query("saveProfileTask").params({ creationRequest: param });
if (res.data.errors) {
return res.data;
@@ -222,9 +209,7 @@ export const profileStore = defineStore({
return res.data;
},
async getTaskLogs(param: { taskID: string }) {
const res: AxiosResponse = await graphql
.query("getProfileTaskLogs")
.params(param);
const res: AxiosResponse = await graphql.query("getProfileTaskLogs").params(param);
if (res.data.errors) {
return res.data;

View File

@@ -15,10 +15,10 @@
* limitations under the License.
*/
import { defineStore } from "pinia";
import { Service, Instance, Endpoint, Process } from "@/types/selector";
import type { Service, Instance, Endpoint, Process } from "@/types/selector";
import { store } from "@/store";
import graphql from "@/graphql";
import { AxiosResponse } from "axios";
import type { AxiosResponse } from "axios";
import { useAppStoreWithOut } from "@/store/modules/app";
interface SelectorState {
services: Service[];
@@ -82,9 +82,7 @@ export const selectorStore = defineStore({
return res.data || {};
},
async fetchServices(layer: string): Promise<AxiosResponse> {
const res: AxiosResponse = await graphql
.query("queryServices")
.params({ layer });
const res: AxiosResponse = await graphql.query("queryServices").params({ layer });
if (!res.data.errors) {
this.services = res.data.data.services || [];
@@ -92,10 +90,7 @@ export const selectorStore = defineStore({
}
return res.data;
},
async getServiceInstances(param?: {
serviceId: string;
isRelation: boolean;
}): Promise<Nullable<AxiosResponse>> {
async getServiceInstances(param?: { serviceId: string; isRelation: boolean }): Promise<Nullable<AxiosResponse>> {
const serviceId = param ? param.serviceId : this.currentService?.id;
if (!serviceId) {
return null;
@@ -113,10 +108,7 @@ export const selectorStore = defineStore({
}
return res.data;
},
async getProcesses(param?: {
instanceId: string;
isRelation: boolean;
}): Promise<Nullable<AxiosResponse>> {
async getProcesses(param?: { instanceId: string; isRelation: boolean }): Promise<Nullable<AxiosResponse>> {
const instanceId = param ? param.instanceId : this.currentPod?.id;
if (!instanceId) {
return null;

View File

@@ -16,12 +16,12 @@
*/
import { defineStore } from "pinia";
import { store } from "@/store";
import { Service } from "@/types/selector";
import { Node, Call } from "@/types/topology";
import type { Service } from "@/types/selector";
import type { Node, Call } from "@/types/topology";
import graphql from "@/graphql";
import { useSelectorStore } from "@/store/modules/selectors";
import { useAppStoreWithOut } from "@/store/modules/app";
import { AxiosResponse } from "axios";
import type { AxiosResponse } from "axios";
import query from "@/graphql/fetch";
import { useQueryTopologyMetrics } from "@/hooks/useMetricsProcessor";
import { ElMessage } from "element-plus";
@@ -105,21 +105,19 @@ export const topologyStore = defineStore({
this.calls = calls;
this.nodes = nodes;
},
setNodeMetricValue(m: { id: string; value: unknown }[]) {
setNodeMetricValue(m: MetricVal) {
this.nodeMetricValue = m;
},
setLinkServerMetrics(m: { id: string; value: unknown }[]) {
setLinkServerMetrics(m: MetricVal) {
this.linkServerMetrics = m;
},
setLinkClientMetrics(m: { id: string; value: unknown }[]) {
setLinkClientMetrics(m: MetricVal) {
this.linkClientMetrics = m;
},
async getDepthServiceTopology(serviceIds: string[], depth: number) {
const res = await this.getServicesTopology(serviceIds);
if (depth > 1) {
const ids = (res.nodes || [])
.map((item: Node) => item.id)
.filter((d: string) => !serviceIds.includes(d));
const ids = (res.nodes || []).map((item: Node) => item.id).filter((d: string) => !serviceIds.includes(d));
if (!ids.length) {
this.setTopology(res);
return;
@@ -139,9 +137,7 @@ export const topologyStore = defineStore({
if (depth > 3) {
const services = topo.nodes
.map((item: Node) => item.id)
.filter(
(d: string) => ![...ids, ...pods, ...serviceIds].includes(d)
);
.filter((d: string) => ![...ids, ...pods, ...serviceIds].includes(d));
if (!services.length) {
const nodes = [...res.nodes, ...json.nodes, ...topo.nodes];
const calls = [...res.calls, ...json.calls, ...topo.calls];
@@ -152,55 +148,20 @@ export const topologyStore = defineStore({
if (depth > 4) {
const nodeIds = data.nodes
.map((item: Node) => item.id)
.filter(
(d: string) =>
![...services, ...ids, ...pods, ...serviceIds].includes(d)
);
.filter((d: string) => ![...services, ...ids, ...pods, ...serviceIds].includes(d));
if (!nodeIds.length) {
const nodes = [
...res.nodes,
...json.nodes,
...topo.nodes,
...data.nodes,
];
const calls = [
...res.calls,
...json.calls,
...topo.calls,
...data.calls,
];
const nodes = [...res.nodes, ...json.nodes, ...topo.nodes, ...data.nodes];
const calls = [...res.calls, ...json.calls, ...topo.calls, ...data.calls];
this.setTopology({ nodes, calls });
return;
}
const toposObj = await this.getServicesTopology(nodeIds);
const nodes = [
...res.nodes,
...json.nodes,
...topo.nodes,
...data.nodes,
...toposObj.nodes,
];
const calls = [
...res.calls,
...json.calls,
...topo.calls,
...data.calls,
...toposObj.calls,
];
const nodes = [...res.nodes, ...json.nodes, ...topo.nodes, ...data.nodes, ...toposObj.nodes];
const calls = [...res.calls, ...json.calls, ...topo.calls, ...data.calls, ...toposObj.calls];
this.setTopology({ nodes, calls });
} else {
const nodes = [
...res.nodes,
...json.nodes,
...topo.nodes,
...data.nodes,
];
const calls = [
...res.calls,
...json.calls,
...topo.calls,
...data.calls,
];
const nodes = [...res.nodes, ...json.nodes, ...topo.nodes, ...data.nodes];
const calls = [...res.calls, ...json.calls, ...topo.calls, ...data.calls];
this.setTopology({ nodes, calls });
}
} else {
@@ -220,12 +181,10 @@ export const topologyStore = defineStore({
},
async getServicesTopology(serviceIds: string[]) {
const duration = useAppStoreWithOut().durationTime;
const res: AxiosResponse = await graphql
.query("getServicesTopology")
.params({
serviceIds,
duration,
});
const res: AxiosResponse = await graphql.query("getServicesTopology").params({
serviceIds,
duration,
});
if (res.data.errors) {
return res.data;
}
@@ -235,13 +194,11 @@ export const topologyStore = defineStore({
const serverServiceId = useSelectorStore().currentService.id;
const clientServiceId = useSelectorStore().currentDestService.id;
const duration = useAppStoreWithOut().durationTime;
const res: AxiosResponse = await graphql
.query("getInstanceTopology")
.params({
clientServiceId,
serverServiceId,
duration,
});
const res: AxiosResponse = await graphql.query("getInstanceTopology").params({
clientServiceId,
serverServiceId,
duration,
});
if (!res.data.errors) {
this.setInstanceTopology(res.data.data.topology);
}
@@ -250,9 +207,7 @@ export const topologyStore = defineStore({
async updateEndpointTopology(endpointIds: string[], depth: number) {
const res = await this.getEndpointTopology(endpointIds);
if (depth > 1) {
const ids = res.nodes
.map((item: Node) => item.id)
.filter((d: string) => !endpointIds.includes(d));
const ids = res.nodes.map((item: Node) => item.id).filter((d: string) => !endpointIds.includes(d));
if (!ids.length) {
this.setTopology(res);
return;
@@ -272,9 +227,7 @@ export const topologyStore = defineStore({
if (depth > 3) {
const endpoints = topo.nodes
.map((item: Node) => item.id)
.filter(
(d: string) => ![...ids, ...pods, ...endpointIds].includes(d)
);
.filter((d: string) => ![...ids, ...pods, ...endpointIds].includes(d));
if (!endpoints.length) {
const nodes = [...res.nodes, ...json.nodes, ...topo.nodes];
const calls = [...res.calls, ...json.calls, ...topo.calls];
@@ -285,55 +238,20 @@ export const topologyStore = defineStore({
if (depth > 4) {
const nodeIds = data.nodes
.map((item: Node) => item.id)
.filter(
(d: string) =>
![...endpoints, ...ids, ...pods, ...endpointIds].includes(d)
);
.filter((d: string) => ![...endpoints, ...ids, ...pods, ...endpointIds].includes(d));
if (!nodeIds.length) {
const nodes = [
...res.nodes,
...json.nodes,
...topo.nodes,
...data.nodes,
];
const calls = [
...res.calls,
...json.calls,
...topo.calls,
...data.calls,
];
const nodes = [...res.nodes, ...json.nodes, ...topo.nodes, ...data.nodes];
const calls = [...res.calls, ...json.calls, ...topo.calls, ...data.calls];
this.setTopology({ nodes, calls });
return;
}
const toposObj = await this.getEndpointTopology(nodeIds);
const nodes = [
...res.nodes,
...json.nodes,
...topo.nodes,
...data.nodes,
...toposObj.nodes,
];
const calls = [
...res.calls,
...json.calls,
...topo.calls,
...data.calls,
...toposObj.calls,
];
const nodes = [...res.nodes, ...json.nodes, ...topo.nodes, ...data.nodes, ...toposObj.nodes];
const calls = [...res.calls, ...json.calls, ...topo.calls, ...data.calls, ...toposObj.calls];
this.setTopology({ nodes, calls });
} else {
const nodes = [
...res.nodes,
...json.nodes,
...topo.nodes,
...data.nodes,
];
const calls = [
...res.calls,
...json.calls,
...topo.calls,
...data.calls,
];
const nodes = [...res.nodes, ...json.nodes, ...topo.nodes, ...data.nodes];
const calls = [...res.calls, ...json.calls, ...topo.calls, ...data.calls];
this.setTopology({ nodes, calls });
}
} else {
@@ -390,10 +308,7 @@ export const topologyStore = defineStore({
return { calls, nodes };
},
async getNodeMetricValue(param: {
queryStr: string;
conditions: { [key: string]: unknown };
}) {
async getNodeMetricValue(param: { queryStr: string; conditions: { [key: string]: unknown } }) {
const res: AxiosResponse = await query(param);
if (res.data.errors) {
@@ -407,9 +322,7 @@ export const topologyStore = defineStore({
this.setLinkClientMetrics({});
return;
}
const idsC = this.calls
.filter((i: Call) => i.detectPoints.includes("CLIENT"))
.map((b: Call) => b.id);
const idsC = this.calls.filter((i: Call) => i.detectPoints.includes("CLIENT")).map((b: Call) => b.id);
if (!idsC.length) {
return;
}
@@ -425,9 +338,7 @@ export const topologyStore = defineStore({
this.setLinkServerMetrics({});
return;
}
const idsS = this.calls
.filter((i: Call) => i.detectPoints.includes("SERVER"))
.map((b: Call) => b.id);
const idsS = this.calls.filter((i: Call) => i.detectPoints.includes("SERVER")).map((b: Call) => b.id);
if (!idsS.length) {
return;
}
@@ -454,10 +365,7 @@ export const topologyStore = defineStore({
ElMessage.error(res.errors);
}
},
async getLegendMetrics(param: {
queryStr: string;
conditions: { [key: string]: unknown };
}) {
async getLegendMetrics(param: { queryStr: string; conditions: { [key: string]: unknown } }) {
const res: AxiosResponse = await query(param);
if (res.data.errors) {
@@ -477,10 +385,7 @@ export const topologyStore = defineStore({
});
return res.data;
},
async getCallServerMetrics(param: {
queryStr: string;
conditions: { [key: string]: unknown };
}) {
async getCallServerMetrics(param: { queryStr: string; conditions: { [key: string]: unknown } }) {
const res: AxiosResponse = await query(param);
if (res.data.errors) {
@@ -489,10 +394,7 @@ export const topologyStore = defineStore({
this.setLinkServerMetrics(res.data.data);
return res.data;
},
async getCallClientMetrics(param: {
queryStr: string;
conditions: { [key: string]: unknown };
}) {
async getCallClientMetrics(param: { queryStr: string; conditions: { [key: string]: unknown } }) {
const res: AxiosResponse = await query(param);
if (res.data.errors) {

View File

@@ -15,11 +15,11 @@
* limitations under the License.
*/
import { defineStore } from "pinia";
import { Instance, Endpoint, Service } from "@/types/selector";
import { Trace, Span } from "@/types/trace";
import type { Instance, Endpoint, Service } from "@/types/selector";
import type { Trace, Span } from "@/types/trace";
import { store } from "@/store";
import graphql from "@/graphql";
import { AxiosResponse } from "axios";
import type { AxiosResponse } from "axios";
import { useAppStoreWithOut } from "@/store/modules/app";
import { useSelectorStore } from "@/store/modules/selectors";
import { QueryOrders } from "@/views/dashboard/data";
@@ -30,7 +30,7 @@ interface TraceState {
endpoints: Endpoint[];
traceList: Trace[];
traceSpans: Span[];
currentTrace: Trace | any;
currentTrace: Recordable<Trace>;
conditions: any;
traceSpanLogs: any[];
selectorStore: any;
@@ -58,10 +58,10 @@ export const traceStore = defineStore({
setTraceCondition(data: any) {
this.conditions = { ...this.conditions, ...data };
},
setCurrentTrace(trace: Trace) {
setCurrentTrace(trace: Recordable<Trace>) {
this.currentTrace = trace;
},
setTraceSpans(spans: Span) {
setTraceSpans(spans: Span[]) {
this.traceSpans = spans;
},
resetState() {
@@ -116,9 +116,7 @@ export const traceStore = defineStore({
return res.data;
},
async getInstances(id: string) {
const serviceId = this.selectorStore.currentService
? this.selectorStore.currentService.id
: id;
const serviceId = this.selectorStore.currentService ? this.selectorStore.currentService.id : id;
const res: AxiosResponse = await graphql.query("queryInstances").params({
serviceId: serviceId,
duration: useAppStoreWithOut().durationTime,
@@ -131,9 +129,7 @@ export const traceStore = defineStore({
return res.data;
},
async getEndpoints(id: string, keyword?: string) {
const serviceId = this.selectorStore.currentService
? this.selectorStore.currentService.id
: id;
const serviceId = this.selectorStore.currentService ? this.selectorStore.currentService.id : id;
const res: AxiosResponse = await graphql.query("queryEndpoints").params({
serviceId,
duration: useAppStoreWithOut().durationTime,
@@ -146,9 +142,7 @@ export const traceStore = defineStore({
return res.data;
},
async getTraces() {
const res: AxiosResponse = await graphql
.query("queryTraces")
.params({ condition: this.conditions });
const res: AxiosResponse = await graphql.query("queryTraces").params({ condition: this.conditions });
if (res.data.errors) {
return res.data;
}
@@ -169,9 +163,7 @@ export const traceStore = defineStore({
return res.data;
},
async getTraceSpans(params: { traceId: string }) {
const res: AxiosResponse = await graphql
.query("queryTrace")
.params(params);
const res: AxiosResponse = await graphql.query("queryTrace").params(params);
if (res.data.errors) {
return res.data;
}
@@ -180,9 +172,7 @@ export const traceStore = defineStore({
return res.data;
},
async getSpanLogs(params: any) {
const res: AxiosResponse = await graphql
.query("queryServiceLogs")
.params(params);
const res: AxiosResponse = await graphql.query("queryServiceLogs").params(params);
if (res.data.errors) {
this.traceSpanLogs = [];
return res.data;