mirror of
https://github.com/apache/skywalking-booster-ui.git
synced 2025-05-02 06:34:01 +00:00
feat: switch dashboard with entity
This commit is contained in:
parent
8a2eeae315
commit
21fb053bda
@ -36,7 +36,8 @@ export const Instances = {
|
|||||||
variable: "$serviceId: ID!, $duration: Duration!",
|
variable: "$serviceId: ID!, $duration: Duration!",
|
||||||
query: `
|
query: `
|
||||||
pods: listInstances(duration: $duration, serviceId: $serviceId) {
|
pods: listInstances(duration: $duration, serviceId: $serviceId) {
|
||||||
value: id
|
id
|
||||||
|
value: name
|
||||||
label: name
|
label: name
|
||||||
language
|
language
|
||||||
instanceUUID
|
instanceUUID
|
||||||
@ -52,8 +53,9 @@ export const Endpoints = {
|
|||||||
variable: "$serviceId: ID!, $keyword: String!",
|
variable: "$serviceId: ID!, $keyword: String!",
|
||||||
query: `
|
query: `
|
||||||
pods: findEndpoint(serviceId: $serviceId, keyword: $keyword, limit: 100) {
|
pods: findEndpoint(serviceId: $serviceId, keyword: $keyword, limit: 100) {
|
||||||
value: id
|
id
|
||||||
label: name
|
value: name
|
||||||
|
label: name
|
||||||
}
|
}
|
||||||
`,
|
`,
|
||||||
};
|
};
|
||||||
|
@ -32,14 +32,11 @@ export function useQueryProcessor(config: any) {
|
|||||||
duration: appStore.durationTime,
|
duration: appStore.durationTime,
|
||||||
};
|
};
|
||||||
const variables: string[] = [`$duration: Duration!`];
|
const variables: string[] = [`$duration: Duration!`];
|
||||||
const { currentPod, currentService, currentDestPod, currentDestService } =
|
|
||||||
selectorStore;
|
|
||||||
const { entity } = dashboardStore;
|
|
||||||
const isRelation = [
|
const isRelation = [
|
||||||
"ServiceRelation",
|
"ServiceRelation",
|
||||||
"ServiceInstanceRelation",
|
"ServiceInstanceRelation",
|
||||||
"EndpointRelation",
|
"EndpointRelation",
|
||||||
].includes(entity);
|
].includes(dashboardStore.entity);
|
||||||
const fragment = config.metrics.map((name: string, index: number) => {
|
const fragment = config.metrics.map((name: string, index: number) => {
|
||||||
const metricType = config.metricTypes[index] || "";
|
const metricType = config.metricTypes[index] || "";
|
||||||
const labels = ["0", "1", "2", "3", "4"];
|
const labels = ["0", "1", "2", "3", "4"];
|
||||||
@ -52,11 +49,11 @@ export function useQueryProcessor(config: any) {
|
|||||||
variables.push(`$condition${index}: TopNCondition!`);
|
variables.push(`$condition${index}: TopNCondition!`);
|
||||||
conditions[`condition${index}`] = {
|
conditions[`condition${index}`] = {
|
||||||
name,
|
name,
|
||||||
parentService: ["Service", "All"].includes(entity)
|
parentService: ["Service", "All"].includes(dashboardStore.entity)
|
||||||
? null
|
? null
|
||||||
: currentService.value,
|
: selectorStore.currentService.value,
|
||||||
normal: currentService.normal,
|
normal: selectorStore.currentService.normal,
|
||||||
scope: entity,
|
scope: dashboardStore.entity,
|
||||||
topN: 10,
|
topN: 10,
|
||||||
order: "DES",
|
order: "DES",
|
||||||
};
|
};
|
||||||
@ -69,19 +66,35 @@ export function useQueryProcessor(config: any) {
|
|||||||
conditions[`condition${index}`] = {
|
conditions[`condition${index}`] = {
|
||||||
name,
|
name,
|
||||||
entity: {
|
entity: {
|
||||||
scope: entity,
|
scope: dashboardStore.entity,
|
||||||
serviceName: entity === "All" ? undefined : currentService.value,
|
serviceName:
|
||||||
normal: entity === "All" ? undefined : currentService.normal,
|
dashboardStore.entity === "All"
|
||||||
serviceInstanceName: entity.includes("ServiceInstance")
|
? undefined
|
||||||
? currentPod
|
: selectorStore.currentService.value,
|
||||||
|
normal:
|
||||||
|
dashboardStore.entity === "All"
|
||||||
|
? undefined
|
||||||
|
: selectorStore.currentService.normal,
|
||||||
|
serviceInstanceName: dashboardStore.entity.includes("ServiceInstance")
|
||||||
|
? selectorStore.currentPod
|
||||||
|
: undefined,
|
||||||
|
endpointName: dashboardStore.entity.includes("Endpoint")
|
||||||
|
? selectorStore.currentPod
|
||||||
|
: undefined,
|
||||||
|
destNormal: isRelation
|
||||||
|
? selectorStore.currentDestService.normal
|
||||||
|
: undefined,
|
||||||
|
destServiceName: isRelation
|
||||||
|
? selectorStore.currentDestService.value
|
||||||
: undefined,
|
: undefined,
|
||||||
endpointName: entity.includes("Endpoint") ? currentPod : undefined,
|
|
||||||
destNormal: isRelation ? currentDestService.normal : undefined,
|
|
||||||
destServiceName: isRelation ? currentDestService.value : undefined,
|
|
||||||
destServiceInstanceName:
|
destServiceInstanceName:
|
||||||
entity === "ServiceInstanceRelation" ? currentDestPod : undefined,
|
dashboardStore.entity === "ServiceInstanceRelation"
|
||||||
|
? selectorStore.currentDestPod
|
||||||
|
: undefined,
|
||||||
destEndpointName:
|
destEndpointName:
|
||||||
entity === "EndpointRelation" ? currentDestPod : undefined,
|
dashboardStore.entity === "EndpointRelation"
|
||||||
|
? selectorStore.currentDestPod
|
||||||
|
: undefined,
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
@ -35,15 +35,65 @@ export const ConfigData: any = {
|
|||||||
w: 8,
|
w: 8,
|
||||||
h: 12,
|
h: 12,
|
||||||
i: "0",
|
i: "0",
|
||||||
metrics: ["service_resp_time", "service_apdex"],
|
metrics: ["service_resp_time"],
|
||||||
metricTypes: ["readMetricsValues", "readMetricsValues"],
|
metricTypes: ["readMetricsValues"],
|
||||||
type: "Widget",
|
type: "Widget",
|
||||||
widget: {
|
widget: {
|
||||||
title: "Title",
|
title: "service_resp_time",
|
||||||
tips: "Tooltip",
|
tips: "Tooltip",
|
||||||
},
|
},
|
||||||
graph: {
|
graph: {
|
||||||
type: "Line",
|
type: "Line",
|
||||||
|
showXAxis: true,
|
||||||
|
showYAxis: true,
|
||||||
|
},
|
||||||
|
standard: {
|
||||||
|
sortOrder: "DEC",
|
||||||
|
unit: "min",
|
||||||
|
},
|
||||||
|
children: [],
|
||||||
|
};
|
||||||
|
export const ConfigData1: any = {
|
||||||
|
x: 0,
|
||||||
|
y: 0,
|
||||||
|
w: 8,
|
||||||
|
h: 12,
|
||||||
|
i: "0",
|
||||||
|
metrics: ["service_instance_resp_time"],
|
||||||
|
metricTypes: ["readMetricsValues"],
|
||||||
|
type: "Widget",
|
||||||
|
widget: {
|
||||||
|
title: "service_instance_resp_time",
|
||||||
|
tips: "Tooltip",
|
||||||
|
},
|
||||||
|
graph: {
|
||||||
|
type: "Line",
|
||||||
|
showXAxis: true,
|
||||||
|
showYAxis: true,
|
||||||
|
},
|
||||||
|
standard: {
|
||||||
|
sortOrder: "DEC",
|
||||||
|
unit: "min",
|
||||||
|
},
|
||||||
|
children: [],
|
||||||
|
};
|
||||||
|
export const ConfigData2: any = {
|
||||||
|
x: 0,
|
||||||
|
y: 0,
|
||||||
|
w: 8,
|
||||||
|
h: 12,
|
||||||
|
i: "0",
|
||||||
|
metrics: ["endpoint_avg"],
|
||||||
|
metricTypes: ["readMetricsValues"],
|
||||||
|
type: "Widget",
|
||||||
|
widget: {
|
||||||
|
title: "endpoint_avg",
|
||||||
|
tips: "Tooltip",
|
||||||
|
},
|
||||||
|
graph: {
|
||||||
|
type: "Line",
|
||||||
|
showXAxis: true,
|
||||||
|
showYAxis: true,
|
||||||
},
|
},
|
||||||
standard: {
|
standard: {
|
||||||
sortOrder: "DEC",
|
sortOrder: "DEC",
|
||||||
|
@ -18,7 +18,7 @@ import { defineStore } from "pinia";
|
|||||||
import { store } from "@/store";
|
import { store } from "@/store";
|
||||||
import { LayoutConfig } from "@/types/dashboard";
|
import { LayoutConfig } from "@/types/dashboard";
|
||||||
import graph from "@/graph";
|
import graph from "@/graph";
|
||||||
import { ConfigData } from "../data";
|
import { ConfigData, ConfigData1, ConfigData2 } from "../data";
|
||||||
import { useAppStoreWithOut } from "@/store/modules/app";
|
import { useAppStoreWithOut } from "@/store/modules/app";
|
||||||
import { useSelectorStore } from "@/store/modules/selectors";
|
import { useSelectorStore } from "@/store/modules/selectors";
|
||||||
import { NewControl } from "../data";
|
import { NewControl } from "../data";
|
||||||
@ -144,6 +144,12 @@ export const dashboardStore = defineStore({
|
|||||||
},
|
},
|
||||||
setEntity(type: string) {
|
setEntity(type: string) {
|
||||||
this.entity = type;
|
this.entity = type;
|
||||||
|
if (type === "ServiceInstance") {
|
||||||
|
this.layout = [ConfigData1];
|
||||||
|
}
|
||||||
|
if (type === "Endpoint") {
|
||||||
|
this.layout = [ConfigData2];
|
||||||
|
}
|
||||||
},
|
},
|
||||||
setConfigs(param: { [key: string]: unknown }) {
|
setConfigs(param: { [key: string]: unknown }) {
|
||||||
const actived = this.activedGridItem.split("-");
|
const actived = this.activedGridItem.split("-");
|
||||||
|
@ -35,8 +35,8 @@ import Tool from "./panel/Tool.vue";
|
|||||||
import ConfigEdit from "./configuration/ConfigEdit.vue";
|
import ConfigEdit from "./configuration/ConfigEdit.vue";
|
||||||
import { useDashboardStore } from "@/store/modules/dashboard";
|
import { useDashboardStore } from "@/store/modules/dashboard";
|
||||||
|
|
||||||
const { t } = useI18n();
|
|
||||||
const dashboardStore = useDashboardStore();
|
const dashboardStore = useDashboardStore();
|
||||||
|
const { t } = useI18n();
|
||||||
// fetch layout data from serve side
|
// fetch layout data from serve side
|
||||||
// const layout: any[] = [
|
// const layout: any[] = [
|
||||||
// { x: 0, y: 0, w: 4, h: 12, i: "0" },
|
// { x: 0, y: 0, w: 4, h: 12, i: "0" },
|
||||||
@ -56,6 +56,7 @@ const dashboardStore = useDashboardStore();
|
|||||||
// { x: 8, y: 27, w: 4, h: 15, i: "16" },
|
// { x: 8, y: 27, w: 4, h: 15, i: "16" },
|
||||||
// ];
|
// ];
|
||||||
// dashboardStore.setLayout(layout);
|
// dashboardStore.setLayout(layout);
|
||||||
|
|
||||||
function handleClick(e: any) {
|
function handleClick(e: any) {
|
||||||
e.stopPropagation();
|
e.stopPropagation();
|
||||||
if (e.target.className === "ds-main") {
|
if (e.target.className === "ds-main") {
|
||||||
|
@ -119,13 +119,27 @@ export default defineComponent({
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
watch(
|
watch(
|
||||||
() => [
|
() => [props.data.metricTypes, props.data.metrics],
|
||||||
props.data.metricTypes,
|
() => {
|
||||||
props.data.metrics,
|
queryMetrics();
|
||||||
selectorStore.currentService,
|
}
|
||||||
],
|
);
|
||||||
(data, old) => {
|
watch(
|
||||||
if (data[0] === old[0] && data[1] === old[1] && data[2] === old[2]) {
|
() => selectorStore.currentService,
|
||||||
|
() => {
|
||||||
|
if (dashboardStore.entity !== "Service") {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
queryMetrics();
|
||||||
|
}
|
||||||
|
);
|
||||||
|
watch(
|
||||||
|
() => selectorStore.currentPod,
|
||||||
|
() => {
|
||||||
|
if (
|
||||||
|
dashboardStore.entity === "All" ||
|
||||||
|
dashboardStore.entity === "Service"
|
||||||
|
) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
queryMetrics();
|
queryMetrics();
|
||||||
|
@ -42,10 +42,14 @@ export const DefaultGraphConfig: { [key: string]: any } = {
|
|||||||
step: false,
|
step: false,
|
||||||
smooth: false,
|
smooth: false,
|
||||||
showSymbol: false,
|
showSymbol: false,
|
||||||
|
showXAxis: true,
|
||||||
|
showYAxis: true,
|
||||||
},
|
},
|
||||||
Area: {
|
Area: {
|
||||||
type: "Area",
|
type: "Area",
|
||||||
opacity: 0.4,
|
opacity: 0.4,
|
||||||
|
showXAxis: true,
|
||||||
|
showYAxis: true,
|
||||||
},
|
},
|
||||||
Card: {
|
Card: {
|
||||||
type: "Card",
|
type: "Card",
|
||||||
|
@ -14,8 +14,8 @@ See the License for the specific language governing permissions and
|
|||||||
limitations under the License. -->
|
limitations under the License. -->
|
||||||
<template>
|
<template>
|
||||||
<div class="dashboard-tool flex-h">
|
<div class="dashboard-tool flex-h">
|
||||||
<div class="flex-h">
|
<div class="flex-h" v-if="!params.serviceId">
|
||||||
<div class="selectors-item">
|
<div class="selectors-item" v-if="states.key !== 10">
|
||||||
<span class="label">$Service</span>
|
<span class="label">$Service</span>
|
||||||
<Selector
|
<Selector
|
||||||
v-model="states.currentService"
|
v-model="states.currentService"
|
||||||
@ -24,12 +24,15 @@ limitations under the License. -->
|
|||||||
placeholder="Select a service"
|
placeholder="Select a service"
|
||||||
@change="changeService"
|
@change="changeService"
|
||||||
class="selectors"
|
class="selectors"
|
||||||
:borderRadius="4"
|
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
<div class="selectors-item" v-if="states.key === 3 || states.key === 4">
|
<div class="selectors-item" v-if="states.key === 3 || states.key === 4">
|
||||||
<span class="label">
|
<span class="label">
|
||||||
{{ states.entity === "endpoint" ? "$Endpoint" : "$ServiceInstance" }}
|
{{
|
||||||
|
dashboardStore.entity === "Endpoint"
|
||||||
|
? "$Endpoint"
|
||||||
|
: "$ServiceInstance"
|
||||||
|
}}
|
||||||
</span>
|
</span>
|
||||||
<Selector
|
<Selector
|
||||||
v-model="selectorStore.currentPod"
|
v-model="selectorStore.currentPod"
|
||||||
@ -38,7 +41,6 @@ limitations under the License. -->
|
|||||||
placeholder="Select a data"
|
placeholder="Select a data"
|
||||||
@change="changePods"
|
@change="changePods"
|
||||||
class="selectors"
|
class="selectors"
|
||||||
:borderRadius="4"
|
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
<div class="selectors-item" v-if="states.key === 2">
|
<div class="selectors-item" v-if="states.key === 2">
|
||||||
@ -95,8 +97,6 @@ const dashboardStore = useDashboardStore();
|
|||||||
const selectorStore = useSelectorStore();
|
const selectorStore = useSelectorStore();
|
||||||
const params = useRoute().params;
|
const params = useRoute().params;
|
||||||
const states = reactive<{
|
const states = reactive<{
|
||||||
entity: string;
|
|
||||||
layerId: string | string[];
|
|
||||||
destService: string;
|
destService: string;
|
||||||
destPod: string;
|
destPod: string;
|
||||||
key: number;
|
key: number;
|
||||||
@ -105,32 +105,31 @@ const states = reactive<{
|
|||||||
destService: "",
|
destService: "",
|
||||||
destPod: "",
|
destPod: "",
|
||||||
key: EntityType.filter((d: Option) => d.value === params.entity)[0].key || 0,
|
key: EntityType.filter((d: Option) => d.value === params.entity)[0].key || 0,
|
||||||
entity: String(params.entity),
|
currentService: "",
|
||||||
layerId: params.layerId,
|
|
||||||
currentService:
|
|
||||||
(selectorStore.currentService && selectorStore.currentService.value) || "",
|
|
||||||
});
|
});
|
||||||
dashboardStore.setLayer(states.layerId);
|
dashboardStore.setLayer(String(params.layerId));
|
||||||
dashboardStore.setEntity(states.entity);
|
dashboardStore.setEntity(String(params.entity));
|
||||||
|
|
||||||
getServices();
|
getServices();
|
||||||
|
|
||||||
async function getServices() {
|
async function getServices() {
|
||||||
if (!states.layerId) {
|
if (!dashboardStore.layerId) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
const json = await selectorStore.fetchServices(states.layerId);
|
const json = await selectorStore.fetchServices(dashboardStore.layerId);
|
||||||
if (json.errors) {
|
if (json.errors) {
|
||||||
ElMessage.error(json.errors);
|
ElMessage.error(json.errors);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
fetchPods(states.entity);
|
states.currentService = selectorStore.currentService.value;
|
||||||
|
fetchPods(dashboardStore.entity);
|
||||||
}
|
}
|
||||||
|
|
||||||
async function changeService(service: Service[]) {
|
async function changeService(service: Service[]) {
|
||||||
if (service[0]) {
|
if (service[0]) {
|
||||||
|
states.currentService = service[0].value;
|
||||||
selectorStore.setCurrentService(service[0]);
|
selectorStore.setCurrentService(service[0]);
|
||||||
fetchPods(states.entity);
|
fetchPods(dashboardStore.entity);
|
||||||
} else {
|
} else {
|
||||||
selectorStore.setCurrentService("");
|
selectorStore.setCurrentService("");
|
||||||
}
|
}
|
||||||
@ -166,10 +165,10 @@ function clickIcons(t: { id: string; content: string; name: string }) {
|
|||||||
async function fetchPods(type: string) {
|
async function fetchPods(type: string) {
|
||||||
let resp;
|
let resp;
|
||||||
switch (type) {
|
switch (type) {
|
||||||
case "endpoint":
|
case "Endpoint":
|
||||||
resp = await selectorStore.getEndpoints();
|
resp = await selectorStore.getEndpoints();
|
||||||
break;
|
break;
|
||||||
case "serviceInstance":
|
case "ServiceInstance":
|
||||||
resp = await selectorStore.getServiceInstances();
|
resp = await selectorStore.getServiceInstances();
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
|
Loading…
Reference in New Issue
Block a user