refactor: optimize data types for widgets and dashboards (#490)

This commit is contained in:
Fine0830
2025-08-14 18:25:40 +08:00
committed by GitHub
parent e885b61353
commit 54a700bf19
141 changed files with 972 additions and 743 deletions

View File

@@ -68,8 +68,8 @@ export async function useDashboardQueryProcessor(configList: Indexable[]) {
if (idx === 0) {
variables.push(`$entity: Entity!`);
const entity = {
serviceName: dashboardStore.entity === "All" ? undefined : selectorStore.currentService.value,
normal: dashboardStore.entity === "All" ? undefined : selectorStore.currentService.normal,
serviceName: dashboardStore.entity === "All" ? undefined : selectorStore.currentService?.value,
normal: dashboardStore.entity === "All" ? undefined : selectorStore.currentService?.normal,
serviceInstanceName: ["ServiceInstance", "ServiceInstanceRelation", "ProcessRelation", "Process"].includes(
dashboardStore.entity,
)
@@ -81,8 +81,8 @@ export async function useDashboardQueryProcessor(configList: Indexable[]) {
processName: dashboardStore.entity.includes("Process")
? selectorStore.currentProcess && selectorStore.currentProcess.value
: undefined,
destNormal: isRelation ? selectorStore.currentDestService.normal : undefined,
destServiceName: isRelation ? selectorStore.currentDestService.value : undefined,
destNormal: isRelation ? selectorStore.currentDestService?.normal : undefined,
destServiceName: isRelation ? selectorStore.currentDestService?.value : undefined,
destServiceInstanceName: ["ServiceInstanceRelation", "ProcessRelation"].includes(dashboardStore.entity)
? selectorStore.currentDestPod && selectorStore.currentDestPod.value
: undefined,
@@ -247,7 +247,7 @@ export async function useExpressionsQueryPodsMetrics(
duration: appStore.durationTime,
};
const variables: string[] = [`$duration: Duration!`];
const currentService = selectorStore.currentService || {};
const currentService = selectorStore.currentService || ({} as Service);
const fragmentList = pods.map((d: (Instance | Endpoint | Service) & Indexable, index: number) => {
const entity = {
serviceName: scope === "Service" ? d.label : currentService.label,
@@ -373,7 +373,9 @@ export async function useExpressionsQueryPodsMetrics(
const dashboardStore = useDashboardStore();
const params = await expressionsGraphqlPods(pods);
const json = await dashboardStore.fetchMetricValue(params);
const json = await dashboardStore.fetchMetricValue(
params as { queryStr: string; conditions: { [key: string]: unknown } },
);
if (json.errors) {
ElMessage.error(json.errors);