mirror of
https://github.com/apache/skywalking-booster-ui.git
synced 2025-07-03 14:04:06 +00:00
fix widgets
This commit is contained in:
parent
a96d15a5b4
commit
ed13de38be
@ -41,19 +41,22 @@ const widgetIds = ref<string[]>(
|
|||||||
associate.map((d: { widgetId: string }) => d.widgetId)
|
associate.map((d: { widgetId: string }) => d.widgetId)
|
||||||
);
|
);
|
||||||
const widgets = computed(() => {
|
const widgets = computed(() => {
|
||||||
const isLinear = ["Bar", "Line", "Area"].includes(
|
|
||||||
dashboardStore.selectedGrid.graph && dashboardStore.selectedGrid.graph.type
|
|
||||||
);
|
|
||||||
// const isRank = ["TopList"].includes(
|
// const isRank = ["TopList"].includes(
|
||||||
// dashboardStore.selectedGrid.graph && dashboardStore.selectedGrid.graph.type
|
// dashboardStore.selectedGrid.graph && dashboardStore.selectedGrid.graph.type
|
||||||
// );
|
// );
|
||||||
const { widgets } = getDashboard(dashboardStore.currentDashboard);
|
const all = getDashboard(dashboardStore.currentDashboard).widgets;
|
||||||
const items = widgets.filter(
|
const items = all.filter(
|
||||||
(d: { value: string; label: string } & LayoutConfig) => {
|
(d: { value: string; label: string } & LayoutConfig) => {
|
||||||
if (dashboardStore.selectedGrid.id !== d.id) {
|
const isLinear = ["Bar", "Line", "Area"].includes(
|
||||||
if (isLinear && d.type === "Widget" && d.widget && d.id) {
|
(d.graph && d.graph.type) || ""
|
||||||
|
);
|
||||||
|
if (
|
||||||
|
(isLinear || d.type === "Event") &&
|
||||||
|
d.id &&
|
||||||
|
dashboardStore.selectedGrid.id !== d.id
|
||||||
|
) {
|
||||||
d.value = d.id;
|
d.value = d.id;
|
||||||
d.label = d.widget.name || d.id;
|
d.label = (d.widget && d.widget.name) || d.id;
|
||||||
return d;
|
return d;
|
||||||
}
|
}
|
||||||
// if (isRank && d.type !== "Widget" && d.widget && d.id) {
|
// if (isRank && d.type !== "Widget" && d.widget && d.id) {
|
||||||
@ -62,7 +65,6 @@ const widgets = computed(() => {
|
|||||||
// return d;
|
// return d;
|
||||||
// }
|
// }
|
||||||
}
|
}
|
||||||
}
|
|
||||||
);
|
);
|
||||||
return items;
|
return items;
|
||||||
});
|
});
|
||||||
@ -78,10 +80,12 @@ function updateWidgetConfig(options: Option[]) {
|
|||||||
associate: opt,
|
associate: opt,
|
||||||
};
|
};
|
||||||
dashboardStore.selectWidget({ ...widget });
|
dashboardStore.selectWidget({ ...widget });
|
||||||
|
|
||||||
// remove unuse association widget option
|
// remove unuse association widget option
|
||||||
for (const id of widgetIds.value) {
|
for (const id of widgetIds.value) {
|
||||||
if (!newVal.includes(id)) {
|
if (!newVal.includes(id)) {
|
||||||
const w = widgets.find((d: { id: string }) => d.id === id);
|
const w = widgets.find((d: { id: string }) => d.id === id);
|
||||||
|
if (w.type !== "Event") {
|
||||||
const config = {
|
const config = {
|
||||||
...w,
|
...w,
|
||||||
associate: [],
|
associate: [],
|
||||||
@ -89,17 +93,20 @@ function updateWidgetConfig(options: Option[]) {
|
|||||||
dashboardStore.setWidget(config);
|
dashboardStore.setWidget(config);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
// add association options in target widgets
|
// add association options in target widgets
|
||||||
for (let i = 0; i < opt.length; i++) {
|
for (let i = 0; i < opt.length; i++) {
|
||||||
const item = JSON.parse(JSON.stringify(opt));
|
const item = JSON.parse(JSON.stringify(opt));
|
||||||
item[i] = { widgetId: dashboardStore.selectedGrid.id };
|
item[i] = { widgetId: dashboardStore.selectedGrid.id };
|
||||||
const w = widgets.find((d: { id: string }) => d.id === opt[i].widgetId);
|
const w = widgets.find((d: { id: string }) => d.id === opt[i].widgetId);
|
||||||
|
if (w.type !== "Event") {
|
||||||
const config = {
|
const config = {
|
||||||
...w,
|
...w,
|
||||||
associate: item,
|
associate: item,
|
||||||
};
|
};
|
||||||
dashboardStore.setWidget(config);
|
dashboardStore.setWidget(config);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
widgetIds.value = newVal;
|
widgetIds.value = newVal;
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
Loading…
Reference in New Issue
Block a user