mirror of
https://github.com/apache/skywalking-booster-ui.git
synced 2025-07-18 00:05:24 +00:00
fix: remove items
This commit is contained in:
parent
6014e998d0
commit
c7c6fd18fd
@ -43,6 +43,7 @@ interface DashboardState {
|
|||||||
durationTime: Duration;
|
durationTime: Duration;
|
||||||
selectorStore: any;
|
selectorStore: any;
|
||||||
showTopology: boolean;
|
showTopology: boolean;
|
||||||
|
currentTabItems: LayoutConfig[];
|
||||||
}
|
}
|
||||||
|
|
||||||
export const dashboardStore = defineStore({
|
export const dashboardStore = defineStore({
|
||||||
@ -57,6 +58,7 @@ export const dashboardStore = defineStore({
|
|||||||
durationTime: useAppStoreWithOut().durationTime,
|
durationTime: useAppStoreWithOut().durationTime,
|
||||||
selectorStore: useSelectorStore(),
|
selectorStore: useSelectorStore(),
|
||||||
showTopology: false,
|
showTopology: false,
|
||||||
|
currentTabItems: [],
|
||||||
}),
|
}),
|
||||||
actions: {
|
actions: {
|
||||||
setLayout(data: LayoutConfig[]) {
|
setLayout(data: LayoutConfig[]) {
|
||||||
@ -158,6 +160,7 @@ export const dashboardStore = defineStore({
|
|||||||
});
|
});
|
||||||
items.push(newItem);
|
items.push(newItem);
|
||||||
this.layout[idx].children[tabIndex].children = items;
|
this.layout[idx].children[tabIndex].children = items;
|
||||||
|
this.currentTabItems = items;
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
activeGridItem(index: string) {
|
activeGridItem(index: string) {
|
||||||
@ -172,7 +175,13 @@ export const dashboardStore = defineStore({
|
|||||||
}
|
}
|
||||||
this.layout[idx].activedTabIndex = index;
|
this.layout[idx].activedTabIndex = index;
|
||||||
},
|
},
|
||||||
|
setCurrentTabItems(items: LayoutConfig[]) {
|
||||||
|
this.currentTabItems = items;
|
||||||
|
},
|
||||||
removeTab(item: LayoutConfig) {
|
removeTab(item: LayoutConfig) {
|
||||||
|
if (this.selectedGrid && this.selectedGrid.i === item.i) {
|
||||||
|
this.selectedGrid = null;
|
||||||
|
}
|
||||||
this.layout = this.layout.filter((d: LayoutConfig) => d.i !== item.i);
|
this.layout = this.layout.filter((d: LayoutConfig) => d.i !== item.i);
|
||||||
},
|
},
|
||||||
removeControls(item: LayoutConfig) {
|
removeControls(item: LayoutConfig) {
|
||||||
@ -181,6 +190,9 @@ export const dashboardStore = defineStore({
|
|||||||
(d: LayoutConfig) => actived[0] === d.i
|
(d: LayoutConfig) => actived[0] === d.i
|
||||||
);
|
);
|
||||||
|
|
||||||
|
if (this.selectedGrid.i === item.i) {
|
||||||
|
this.selectedGrid = null;
|
||||||
|
}
|
||||||
if (actived.length === 3) {
|
if (actived.length === 3) {
|
||||||
const tabIndex = Number(actived[1]);
|
const tabIndex = Number(actived[1]);
|
||||||
const itemIndex = this.layout[index].children[
|
const itemIndex = this.layout[index].children[
|
||||||
@ -188,12 +200,18 @@ export const dashboardStore = defineStore({
|
|||||||
].children.findIndex((d: LayoutConfig) => actived[2] === d.i);
|
].children.findIndex((d: LayoutConfig) => actived[2] === d.i);
|
||||||
|
|
||||||
this.layout[index].children[tabIndex].children.splice(itemIndex, 1);
|
this.layout[index].children[tabIndex].children.splice(itemIndex, 1);
|
||||||
|
this.setCurrentTabItems(this.layout[index].children[tabIndex].children);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
this.layout = this.layout.filter((d: LayoutConfig) => d.i !== item.i);
|
this.layout = this.layout.filter((d: LayoutConfig) => d.i !== item.i);
|
||||||
},
|
},
|
||||||
removeTabItem(item: LayoutConfig, index: number) {
|
removeTabItem(item: LayoutConfig, index: number) {
|
||||||
const idx = this.layout.findIndex((d: LayoutConfig) => d.i === item.i);
|
const idx = this.layout.findIndex((d: LayoutConfig) => d.i === item.i);
|
||||||
|
for (const item of this.layout[idx].children[index].children) {
|
||||||
|
if (this.selectedGrid.i === item.i) {
|
||||||
|
this.selectedGrid = null;
|
||||||
|
}
|
||||||
|
}
|
||||||
if (this.layout[idx].children) {
|
if (this.layout[idx].children) {
|
||||||
this.layout[idx].children?.splice(index, 1);
|
this.layout[idx].children?.splice(index, 1);
|
||||||
}
|
}
|
||||||
|
@ -33,7 +33,7 @@ limitations under the License. -->
|
|||||||
v-show="activeTabIndex === idx"
|
v-show="activeTabIndex === idx"
|
||||||
size="sm"
|
size="sm"
|
||||||
iconName="cancel"
|
iconName="cancel"
|
||||||
@click="deleteTabItem(idx)"
|
@click="deleteTabItem($event, idx)"
|
||||||
/>
|
/>
|
||||||
</span>
|
</span>
|
||||||
<span class="tab-icons">
|
<span class="tab-icons">
|
||||||
@ -50,8 +50,8 @@ limitations under the License. -->
|
|||||||
</div>
|
</div>
|
||||||
<div class="tab-layout">
|
<div class="tab-layout">
|
||||||
<grid-layout
|
<grid-layout
|
||||||
v-if="state.layout.length"
|
v-if="dashboardStore.currentTabItems.length"
|
||||||
v-model:layout="state.layout"
|
v-model:layout="dashboardStore.currentTabItems"
|
||||||
:col-num="24"
|
:col-num="24"
|
||||||
:row-height="10"
|
:row-height="10"
|
||||||
:is-draggable="true"
|
:is-draggable="true"
|
||||||
@ -59,7 +59,7 @@ limitations under the License. -->
|
|||||||
@layout-updated="layoutUpdatedEvent"
|
@layout-updated="layoutUpdatedEvent"
|
||||||
>
|
>
|
||||||
<grid-item
|
<grid-item
|
||||||
v-for="item in state.layout"
|
v-for="item in dashboardStore.currentTabItems"
|
||||||
:x="item.x"
|
:x="item.x"
|
||||||
:y="item.y"
|
:y="item.y"
|
||||||
:w="item.w"
|
:w="item.w"
|
||||||
@ -105,26 +105,25 @@ export default defineComponent({
|
|||||||
const activeTabIndex = ref<number>(0);
|
const activeTabIndex = ref<number>(0);
|
||||||
const activeTabWidget = ref<string>("");
|
const activeTabWidget = ref<string>("");
|
||||||
const editTabIndex = ref<number>(NaN); // edit tab item name
|
const editTabIndex = ref<number>(NaN); // edit tab item name
|
||||||
const state = reactive<{
|
dashboardStore.setCurrentTabItems(
|
||||||
layout: LayoutConfig[];
|
dashboardStore.layout[props.data.i].children[activeTabIndex.value]
|
||||||
}>({
|
.children
|
||||||
layout:
|
);
|
||||||
dashboardStore.layout[props.data.i].children[activeTabIndex.value]
|
|
||||||
.children,
|
|
||||||
});
|
|
||||||
|
|
||||||
function layoutUpdatedEvent(newLayout: LayoutConfig[]) {
|
function layoutUpdatedEvent(newLayout: LayoutConfig[]) {
|
||||||
state.layout = newLayout;
|
dashboardStore.setCurrentTabItems(newLayout);
|
||||||
}
|
}
|
||||||
function clickTabs(e: Event, idx: number) {
|
function clickTabs(e: Event, idx: number) {
|
||||||
e.stopPropagation();
|
e.stopPropagation();
|
||||||
activeTabIndex.value = idx;
|
activeTabIndex.value = idx;
|
||||||
dashboardStore.activeGridItem(idx);
|
dashboardStore.activeGridItem(idx);
|
||||||
}
|
}
|
||||||
function removeTab() {
|
function removeTab(e: Event) {
|
||||||
|
e.stopPropagation();
|
||||||
dashboardStore.removeTab(props.data);
|
dashboardStore.removeTab(props.data);
|
||||||
}
|
}
|
||||||
function deleteTabItem(idx: number) {
|
function deleteTabItem(e: Event, idx: number) {
|
||||||
|
e.stopPropagation();
|
||||||
dashboardStore.removeTabItem(props.data, idx);
|
dashboardStore.removeTabItem(props.data, idx);
|
||||||
}
|
}
|
||||||
function addTabItem() {
|
function addTabItem() {
|
||||||
@ -148,18 +147,6 @@ export default defineComponent({
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
document.body.addEventListener("click", handleClick, false);
|
document.body.addEventListener("click", handleClick, false);
|
||||||
|
|
||||||
const items =
|
|
||||||
dashboardStore.layout[props.data.i].children[activeTabIndex.value] || {};
|
|
||||||
watch(
|
|
||||||
() => items.children,
|
|
||||||
(data) => {
|
|
||||||
if (!data) {
|
|
||||||
return data;
|
|
||||||
}
|
|
||||||
state.layout = data;
|
|
||||||
}
|
|
||||||
);
|
|
||||||
watch(
|
watch(
|
||||||
() => dashboardStore.activedGridItem,
|
() => dashboardStore.activedGridItem,
|
||||||
(data) => {
|
(data) => {
|
||||||
@ -185,7 +172,7 @@ export default defineComponent({
|
|||||||
layoutUpdatedEvent,
|
layoutUpdatedEvent,
|
||||||
...toRefs(props),
|
...toRefs(props),
|
||||||
activeTabWidget,
|
activeTabWidget,
|
||||||
state,
|
dashboardStore,
|
||||||
activeTabIndex,
|
activeTabIndex,
|
||||||
editTabIndex,
|
editTabIndex,
|
||||||
};
|
};
|
||||||
|
@ -313,6 +313,7 @@ function setTabControls(id: string) {
|
|||||||
dashboardStore.addTabControls("Topology");
|
dashboardStore.addTabControls("Topology");
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
|
ElMessage.info("Don't support this control");
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user