mirror of
https://github.com/apache/skywalking-booster-ui.git
synced 2025-05-02 17:44:46 +00:00
fix: watch layout in tab
This commit is contained in:
parent
92b03a006e
commit
3a9848a30c
@ -108,19 +108,25 @@ export const dashboardStore = defineStore({
|
|||||||
const idx = this.layout.findIndex(
|
const idx = this.layout.findIndex(
|
||||||
(d: LayoutConfig) => d.i === this.activedGridItem
|
(d: LayoutConfig) => d.i === this.activedGridItem
|
||||||
);
|
);
|
||||||
|
const { children } = this.layout[idx].children[tabIndex];
|
||||||
const newWidget = {
|
const newWidget = {
|
||||||
x: 0,
|
x: 0,
|
||||||
y: 0,
|
y: 0,
|
||||||
w: 24,
|
w: 24,
|
||||||
h: 12,
|
h: 12,
|
||||||
i: String(this.layout[idx].children[tabIndex].children.length),
|
i: String(children.length),
|
||||||
type: "Widget",
|
type: "Widget",
|
||||||
widget: {},
|
widget: {},
|
||||||
graph: {},
|
graph: {},
|
||||||
standard: {},
|
standard: {},
|
||||||
};
|
};
|
||||||
if (this.layout[idx].children) {
|
if (this.layout[idx].children) {
|
||||||
this.layout[idx].children[tabIndex].children.push(newWidget);
|
const items = children.map((d: LayoutConfig) => {
|
||||||
|
d.y = d.y + newWidget.h;
|
||||||
|
return d;
|
||||||
|
});
|
||||||
|
items.push(newWidget);
|
||||||
|
this.layout[idx].children[tabIndex].children = items;
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
activeGridItem(index: string) {
|
activeGridItem(index: string) {
|
||||||
|
@ -74,7 +74,7 @@ limitations under the License. -->
|
|||||||
</grid-layout>
|
</grid-layout>
|
||||||
</template>
|
</template>
|
||||||
<script lang="ts" setup>
|
<script lang="ts" setup>
|
||||||
import { defineProps, reactive, ref } from "vue";
|
import { defineProps, reactive, ref, watch } from "vue";
|
||||||
import type { PropType } from "vue";
|
import type { PropType } from "vue";
|
||||||
import Widget from "./Widget.vue";
|
import Widget from "./Widget.vue";
|
||||||
import { LayoutConfig } from "@/types/dashboard";
|
import { LayoutConfig } from "@/types/dashboard";
|
||||||
@ -124,6 +124,16 @@ function addTabWidget() {
|
|||||||
dashboardStore.addTabWidget(activeTabIndex.value);
|
dashboardStore.addTabWidget(activeTabIndex.value);
|
||||||
}
|
}
|
||||||
document.body.addEventListener("click", handleClick, false);
|
document.body.addEventListener("click", handleClick, false);
|
||||||
|
watch(
|
||||||
|
() =>
|
||||||
|
dashboardStore.layout[props.data.i].children[activeTabIndex.value].children,
|
||||||
|
() => {
|
||||||
|
state.layout =
|
||||||
|
dashboardStore.layout[props.data.i].children[
|
||||||
|
activeTabIndex.value
|
||||||
|
].children;
|
||||||
|
}
|
||||||
|
);
|
||||||
</script>
|
</script>
|
||||||
<style lang="scss" scoped>
|
<style lang="scss" scoped>
|
||||||
.tabs {
|
.tabs {
|
||||||
|
Loading…
Reference in New Issue
Block a user