mirror of
https://github.com/apache/skywalking-booster-ui.git
synced 2025-05-14 17:05:10 +00:00
set config
This commit is contained in:
parent
6aa7c5fbae
commit
ec0758af07
@ -279,22 +279,23 @@ export const dashboardStore = defineStore({
|
||||
this.selectedGrid = this.layout[index];
|
||||
},
|
||||
setWidget(param: LayoutConfig) {
|
||||
for (let item of this.layout) {
|
||||
if (item.type === "Tab") {
|
||||
if (item.children && item.children.length) {
|
||||
for (const child of item.children) {
|
||||
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 (child.children && child.children.length) {
|
||||
for (let c of child.children) {
|
||||
if (c.id === param.id) {
|
||||
c = param;
|
||||
for (let c = 0; c < child.children.length; c++) {
|
||||
if (child.children[c].id === param.id) {
|
||||
child.children.splice(c, 1, param);
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if (item.id === param.id) {
|
||||
item = param;
|
||||
if (this.layout[i].id === param.id) {
|
||||
this.layout.splice(i, 1, param);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -51,7 +51,7 @@ const widgets = computed(() => {
|
||||
const items = widgets.filter(
|
||||
(d: { value: string; label: string } & LayoutConfig) => {
|
||||
if (dashboardStore.selectedGrid.id !== d.id) {
|
||||
if (isLinear && d.widget && d.id) {
|
||||
if (isLinear && d.type === "Widget" && d.widget && d.id) {
|
||||
d.value = d.id;
|
||||
d.label = d.widget.name || d.id;
|
||||
return d;
|
||||
@ -67,6 +67,7 @@ const widgets = computed(() => {
|
||||
return items;
|
||||
});
|
||||
function updateWidgetConfig(options: Option[]) {
|
||||
const { widgets } = getDashboard(dashboardStore.currentDashboard);
|
||||
const opt = options.map((d: Option) => {
|
||||
return { widgetId: d.value };
|
||||
});
|
||||
@ -75,6 +76,16 @@ function updateWidgetConfig(options: Option[]) {
|
||||
associate: opt,
|
||||
};
|
||||
dashboardStore.selectWidget({ ...widget });
|
||||
for (let i = 0; i < opt.length; i++) {
|
||||
const item = JSON.parse(JSON.stringify(opt));
|
||||
item[i] = { widgetId: dashboardStore.selectedGrid.id };
|
||||
const w = widgets.find((d: { id: string }) => d.id === opt[i].widgetId);
|
||||
const config = {
|
||||
...w,
|
||||
associate: item,
|
||||
};
|
||||
dashboardStore.setWidget(config);
|
||||
}
|
||||
}
|
||||
</script>
|
||||
<style lang="scss" scoped>
|
||||
|
Loading…
Reference in New Issue
Block a user