mirror of
https://github.com/apache/skywalking-booster-ui.git
synced 2025-07-12 20:05:25 +00:00
feat: Implement adding controls in Tabs (#21)
This commit is contained in:
parent
59441f7a67
commit
1377703185
@ -21,7 +21,7 @@ limitations under the License. -->
|
|||||||
lg: size === 'lg',
|
lg: size === 'lg',
|
||||||
xl: size === 'xl',
|
xl: size === 'xl',
|
||||||
logo: size === 'logo',
|
logo: size === 'logo',
|
||||||
loading: loading,
|
loading,
|
||||||
}"
|
}"
|
||||||
>
|
>
|
||||||
<use :xlink:href="`#${iconName}`"></use>
|
<use :xlink:href="`#${iconName}`"></use>
|
||||||
@ -73,4 +73,15 @@ defineProps({
|
|||||||
width: 30px;
|
width: 30px;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@keyframes loading {
|
||||||
|
0% {
|
||||||
|
-webkit-transform: rotate(0deg);
|
||||||
|
transform: rotate(0deg);
|
||||||
|
}
|
||||||
|
|
||||||
|
to {
|
||||||
|
-webkit-transform: rotate(1turn);
|
||||||
|
transform: rotate(1turn);
|
||||||
|
}
|
||||||
|
}
|
||||||
</style>
|
</style>
|
||||||
|
@ -95,6 +95,7 @@ const msg = {
|
|||||||
topChildren: "Top 5 of children",
|
topChildren: "Top 5 of children",
|
||||||
taskList: "Task List",
|
taskList: "Task List",
|
||||||
sampledTraces: "Sampled Traces",
|
sampledTraces: "Sampled Traces",
|
||||||
|
editTab: "Enable editing tab names",
|
||||||
hourTip: "Select Hour",
|
hourTip: "Select Hour",
|
||||||
minuteTip: "Select Minute",
|
minuteTip: "Select Minute",
|
||||||
secondTip: "Select Second",
|
secondTip: "Select Second",
|
||||||
|
@ -95,6 +95,7 @@ const msg = {
|
|||||||
showDepth: "展示深度选择器",
|
showDepth: "展示深度选择器",
|
||||||
taskList: "任务列表",
|
taskList: "任务列表",
|
||||||
sampledTraces: "采样的追踪",
|
sampledTraces: "采样的追踪",
|
||||||
|
editTab: "开启编辑Tab的名称",
|
||||||
hourTip: "选择小时",
|
hourTip: "选择小时",
|
||||||
minuteTip: "选择分钟",
|
minuteTip: "选择分钟",
|
||||||
secondTip: "选择秒数",
|
secondTip: "选择秒数",
|
||||||
|
@ -26,7 +26,6 @@ import { routesEvent } from "./event";
|
|||||||
import { routesAlert } from "./alert";
|
import { routesAlert } from "./alert";
|
||||||
import { routesSetting } from "./setting";
|
import { routesSetting } from "./setting";
|
||||||
import { routesAlarm } from "./alarm";
|
import { routesAlarm } from "./alarm";
|
||||||
import { useTimeoutFn } from "@/hooks/useTimeout";
|
|
||||||
|
|
||||||
const routes: Array<RouteRecordRaw> = [
|
const routes: Array<RouteRecordRaw> = [
|
||||||
...routesGen,
|
...routesGen,
|
||||||
@ -52,7 +51,7 @@ router.beforeEach((to, from, next) => {
|
|||||||
// const token = window.localStorage.getItem("skywalking-authority");
|
// const token = window.localStorage.getItem("skywalking-authority");
|
||||||
if ((window as any).axiosCancel.length !== 0) {
|
if ((window as any).axiosCancel.length !== 0) {
|
||||||
for (const func of (window as any).axiosCancel) {
|
for (const func of (window as any).axiosCancel) {
|
||||||
useTimeoutFn(func(), 0);
|
setTimeout(func(), 0);
|
||||||
}
|
}
|
||||||
(window as any).axiosCancel = [];
|
(window as any).axiosCancel = [];
|
||||||
}
|
}
|
||||||
|
@ -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[]) {
|
||||||
@ -71,7 +73,8 @@ export const dashboardStore = defineStore({
|
|||||||
metrics: [""],
|
metrics: [""],
|
||||||
};
|
};
|
||||||
if (type === "Tab") {
|
if (type === "Tab") {
|
||||||
newItem.h = 24;
|
newItem.h = 36;
|
||||||
|
newItem.activedTabIndex = 0;
|
||||||
newItem.children = [
|
newItem.children = [
|
||||||
{
|
{
|
||||||
name: "Tab1",
|
name: "Tab1",
|
||||||
@ -96,14 +99,15 @@ export const dashboardStore = defineStore({
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
if (type === "Trace" || type === "Profile") {
|
if (type === "Trace" || type === "Profile") {
|
||||||
newItem.h = 36;
|
newItem.h = 24;
|
||||||
}
|
}
|
||||||
|
this.activedGridItem = newItem.i;
|
||||||
|
this.selectedGrid = newItem;
|
||||||
this.layout = this.layout.map((d: LayoutConfig) => {
|
this.layout = this.layout.map((d: LayoutConfig) => {
|
||||||
d.y = d.y + newItem.h;
|
d.y = d.y + newItem.h;
|
||||||
return d;
|
return d;
|
||||||
});
|
});
|
||||||
this.layout.push(newItem);
|
this.layout.push(newItem);
|
||||||
this.activedGridItem = newItem.i;
|
|
||||||
},
|
},
|
||||||
addTabItem(item: LayoutConfig) {
|
addTabItem(item: LayoutConfig) {
|
||||||
const idx = this.layout.findIndex((d: LayoutConfig) => d.i === item.i);
|
const idx = this.layout.findIndex((d: LayoutConfig) => d.i === item.i);
|
||||||
@ -117,7 +121,7 @@ export const dashboardStore = defineStore({
|
|||||||
};
|
};
|
||||||
this.layout[idx].children?.push(i);
|
this.layout[idx].children?.push(i);
|
||||||
},
|
},
|
||||||
addTabWidget(tabIndex: number) {
|
addTabControls(type: string) {
|
||||||
const activedGridItem = this.activedGridItem.split("-")[0];
|
const activedGridItem = this.activedGridItem.split("-")[0];
|
||||||
const idx = this.layout.findIndex(
|
const idx = this.layout.findIndex(
|
||||||
(d: LayoutConfig) => d.i === activedGridItem
|
(d: LayoutConfig) => d.i === activedGridItem
|
||||||
@ -125,37 +129,91 @@ export const dashboardStore = defineStore({
|
|||||||
if (idx < 0) {
|
if (idx < 0) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
const tabIndex = this.layout[idx].activedTabIndex;
|
||||||
const { children } = this.layout[idx].children[tabIndex];
|
const { children } = this.layout[idx].children[tabIndex];
|
||||||
const newWidget = {
|
const newItem: LayoutConfig = {
|
||||||
x: 0,
|
...NewControl,
|
||||||
y: 0,
|
|
||||||
w: 24,
|
|
||||||
h: 12,
|
|
||||||
i: String(children.length),
|
i: String(children.length),
|
||||||
type: "Widget",
|
type,
|
||||||
widget: {
|
metricTypes: [""],
|
||||||
title: "Title",
|
metrics: [""],
|
||||||
},
|
|
||||||
graph: {},
|
|
||||||
standard: {},
|
|
||||||
};
|
};
|
||||||
|
if (type === "Topology") {
|
||||||
|
newItem.w = 4;
|
||||||
|
newItem.h = 6;
|
||||||
|
newItem.graph = {
|
||||||
|
fontColor: "white",
|
||||||
|
backgroundColor: "green",
|
||||||
|
iconTheme: true,
|
||||||
|
content: "Topology",
|
||||||
|
fontSize: 18,
|
||||||
|
showDepth: true,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
if (type === "Trace" || type === "Profile") {
|
||||||
|
newItem.h = 24;
|
||||||
|
}
|
||||||
if (this.layout[idx].children) {
|
if (this.layout[idx].children) {
|
||||||
const items = children.map((d: LayoutConfig) => {
|
const items = children.map((d: LayoutConfig) => {
|
||||||
d.y = d.y + newWidget.h;
|
d.y = d.y + newItem.h;
|
||||||
return d;
|
return d;
|
||||||
});
|
});
|
||||||
items.push(newWidget);
|
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) {
|
||||||
this.activedGridItem = index;
|
this.activedGridItem = index;
|
||||||
},
|
},
|
||||||
|
setActiveTabIndex(index: number) {
|
||||||
|
const idx = this.layout.findIndex(
|
||||||
|
(d: LayoutConfig) => d.i === this.activedGridItem
|
||||||
|
);
|
||||||
|
if (idx < 0) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
this.layout[idx].activedTabIndex = index;
|
||||||
|
},
|
||||||
|
setCurrentTabItems(items: LayoutConfig[]) {
|
||||||
|
this.currentTabItems = items;
|
||||||
|
},
|
||||||
|
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);
|
||||||
|
},
|
||||||
removeControls(item: LayoutConfig) {
|
removeControls(item: LayoutConfig) {
|
||||||
|
const actived = this.activedGridItem.split("-");
|
||||||
|
const index = this.layout.findIndex(
|
||||||
|
(d: LayoutConfig) => actived[0] === d.i
|
||||||
|
);
|
||||||
|
|
||||||
|
if (this.selectedGrid && this.selectedGrid.i === item.i) {
|
||||||
|
this.selectedGrid = null;
|
||||||
|
}
|
||||||
|
if (actived.length === 3) {
|
||||||
|
const tabIndex = Number(actived[1]);
|
||||||
|
const itemIndex = this.layout[index].children[
|
||||||
|
tabIndex
|
||||||
|
].children.findIndex((d: LayoutConfig) => actived[2] === d.i);
|
||||||
|
|
||||||
|
this.layout[index].children[tabIndex].children.splice(itemIndex, 1);
|
||||||
|
this.setCurrentTabItems(this.layout[index].children[tabIndex].children);
|
||||||
|
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);
|
||||||
|
if (this.selectedGrid) {
|
||||||
|
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);
|
||||||
}
|
}
|
||||||
@ -204,11 +262,18 @@ export const dashboardStore = defineStore({
|
|||||||
);
|
);
|
||||||
|
|
||||||
if (actived.length === 3) {
|
if (actived.length === 3) {
|
||||||
this.layout[index].children[actived[1]].children[actived[2]] = {
|
const tabIndex = Number(actived[1]);
|
||||||
...this.layout[index],
|
const itemIndex = this.layout[index].children[
|
||||||
|
tabIndex
|
||||||
|
].children.findIndex((d: LayoutConfig) => actived[2] === d.i);
|
||||||
|
|
||||||
|
this.layout[index].children[tabIndex].children[itemIndex] = {
|
||||||
|
...this.layout[index].children[tabIndex].children[itemIndex],
|
||||||
...param,
|
...param,
|
||||||
};
|
};
|
||||||
this.selectedGrid = this.layout[index];
|
this.selectedGrid =
|
||||||
|
this.layout[index].children[tabIndex].children[itemIndex];
|
||||||
|
this.setCurrentTabItems(this.layout[index].children[tabIndex].children);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
this.layout[index] = {
|
this.layout[index] = {
|
||||||
|
@ -27,6 +27,7 @@ export interface LayoutConfig {
|
|||||||
type: string;
|
type: string;
|
||||||
metricTypes: string[];
|
metricTypes: string[];
|
||||||
children?: any;
|
children?: any;
|
||||||
|
activedTabIndex?: number;
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface WidgetConfig {
|
export interface WidgetConfig {
|
||||||
|
@ -75,6 +75,7 @@ function handleClick(e: any) {
|
|||||||
e.stopPropagation();
|
e.stopPropagation();
|
||||||
if (e.target.className === "ds-main") {
|
if (e.target.className === "ds-main") {
|
||||||
dashboardStore.activeGridItem("");
|
dashboardStore.activeGridItem("");
|
||||||
|
dashboardStore.selectWidget(null);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
@ -33,38 +33,62 @@ 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">
|
||||||
<el-tooltip effect="dark" content="Add tab items" placement="bottom">
|
<el-tooltip content="Add tab items" placement="bottom">
|
||||||
<i @click="addTabItem">
|
<i @click="addTabItem">
|
||||||
<Icon size="middle" iconName="add" />
|
<Icon size="middle" iconName="add" />
|
||||||
</i>
|
</i>
|
||||||
</el-tooltip>
|
</el-tooltip>
|
||||||
<el-tooltip effect="dark" content="Add widgets" placement="bottom">
|
|
||||||
<i @click="addTabWidget">
|
|
||||||
<Icon size="middle" iconName="playlist_add" />
|
|
||||||
</i>
|
|
||||||
</el-tooltip>
|
|
||||||
</span>
|
</span>
|
||||||
</div>
|
</div>
|
||||||
<div class="operations">
|
<div class="operations">
|
||||||
<Icon size="sm" iconName="clearclose" @click="removeTab" />
|
<el-popover
|
||||||
|
placement="bottom"
|
||||||
|
trigger="click"
|
||||||
|
:width="200"
|
||||||
|
v-model:visible="showTools"
|
||||||
|
>
|
||||||
|
<template #reference>
|
||||||
|
<span>
|
||||||
|
<Icon
|
||||||
|
iconName="ellipsis_v"
|
||||||
|
size="middle"
|
||||||
|
class="operation"
|
||||||
|
@click="showTools = true"
|
||||||
|
/>
|
||||||
|
</span>
|
||||||
|
</template>
|
||||||
|
<div
|
||||||
|
class="tools"
|
||||||
|
@click="
|
||||||
|
canEditTabName = true;
|
||||||
|
showTools = false;
|
||||||
|
"
|
||||||
|
>
|
||||||
|
<span class="edit-tab">{{ t("editTab") }}</span>
|
||||||
|
</div>
|
||||||
|
<div class="tools" @click="removeTab">
|
||||||
|
<span>{{ t("delete") }}</span>
|
||||||
|
</div>
|
||||||
|
</el-popover>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="tab-layout">
|
<div class="tab-layout" @click="handleClick">
|
||||||
<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"
|
||||||
:is-resizable="true"
|
:is-resizable="true"
|
||||||
|
:responsive="true"
|
||||||
@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"
|
||||||
@ -74,103 +98,147 @@ limitations under the License. -->
|
|||||||
@click="clickTabGrid($event, item)"
|
@click="clickTabGrid($event, item)"
|
||||||
:class="{ active: activeTabWidget === item.i }"
|
:class="{ active: activeTabWidget === item.i }"
|
||||||
>
|
>
|
||||||
<Widget
|
<component
|
||||||
|
:is="item.type"
|
||||||
:data="item"
|
:data="item"
|
||||||
:activeIndex="`${data.i}-${activeTabIndex}-${item.i}`"
|
:activeIndex="`${data.i}-${activeTabIndex}-${item.i}`"
|
||||||
|
:needQuery="needQuery"
|
||||||
/>
|
/>
|
||||||
</grid-item>
|
</grid-item>
|
||||||
</grid-layout>
|
</grid-layout>
|
||||||
<div class="no-data-tips" v-else>Please add widgets.</div>
|
<div class="no-data-tips" v-else>Please add widgets.</div>
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
<script lang="ts" setup>
|
<script lang="ts">
|
||||||
import { ref, watch, reactive } from "vue";
|
import { ref, watch, defineComponent, toRefs } from "vue";
|
||||||
|
import { useI18n } from "vue-i18n";
|
||||||
import type { PropType } from "vue";
|
import type { PropType } from "vue";
|
||||||
import Widget from "./Widget.vue";
|
|
||||||
import { LayoutConfig } from "@/types/dashboard";
|
import { LayoutConfig } from "@/types/dashboard";
|
||||||
import { useDashboardStore } from "@/store/modules/dashboard";
|
import { useDashboardStore } from "@/store/modules/dashboard";
|
||||||
/*global defineProps */
|
import Topology from "./Topology.vue";
|
||||||
const props = defineProps({
|
import Widget from "./Widget.vue";
|
||||||
|
import Trace from "./Trace.vue";
|
||||||
|
import Profile from "./Profile.vue";
|
||||||
|
|
||||||
|
const props = {
|
||||||
data: {
|
data: {
|
||||||
type: Object as PropType<LayoutConfig>,
|
type: Object as PropType<LayoutConfig>,
|
||||||
default: () => ({ children: [] }),
|
default: () => ({ children: [] }),
|
||||||
},
|
},
|
||||||
active: { type: Boolean, default: false },
|
active: { type: Boolean, default: false },
|
||||||
});
|
};
|
||||||
const dashboardStore = useDashboardStore();
|
export default defineComponent({
|
||||||
const activeTabIndex = ref<number>(0);
|
name: "Tab",
|
||||||
const activeTabWidget = ref<string>("0");
|
components: { Topology, Widget, Trace, Profile },
|
||||||
const editTabIndex = ref<number>(NaN); // edit tab item name
|
props,
|
||||||
const state = reactive<{
|
setup(props) {
|
||||||
layout: LayoutConfig[];
|
const { t } = useI18n();
|
||||||
}>({
|
const dashboardStore = useDashboardStore();
|
||||||
layout:
|
const activeTabIndex = ref<number>(0);
|
||||||
dashboardStore.layout[props.data.i].children[activeTabIndex.value].children,
|
const activeTabWidget = ref<string>("");
|
||||||
});
|
const editTabIndex = ref<number>(NaN); // edit tab item name
|
||||||
|
const canEditTabName = ref<boolean>(false);
|
||||||
|
const needQuery = ref<boolean>(false);
|
||||||
|
const showTools = ref<boolean>(false);
|
||||||
|
const l = dashboardStore.layout.findIndex(
|
||||||
|
(d: LayoutConfig) => d.i === props.data.i
|
||||||
|
);
|
||||||
|
dashboardStore.setCurrentTabItems(
|
||||||
|
dashboardStore.layout[l].children[activeTabIndex.value].children
|
||||||
|
);
|
||||||
|
|
||||||
function layoutUpdatedEvent(newLayout: LayoutConfig[]) {
|
function clickTabs(e: Event, idx: number) {
|
||||||
state.layout = newLayout;
|
e.stopPropagation();
|
||||||
}
|
activeTabIndex.value = idx;
|
||||||
function clickTabs(e: Event, idx: number) {
|
dashboardStore.activeGridItem(props.data.i);
|
||||||
e.stopPropagation();
|
dashboardStore.selectWidget(props.data);
|
||||||
activeTabIndex.value = idx;
|
dashboardStore.setActiveTabIndex(idx);
|
||||||
}
|
const l = dashboardStore.layout.findIndex(
|
||||||
function removeTab() {
|
(d: LayoutConfig) => d.i === props.data.i
|
||||||
dashboardStore.removeControls(props.data);
|
);
|
||||||
}
|
dashboardStore.setCurrentTabItems(
|
||||||
function deleteTabItem(idx: number) {
|
dashboardStore.layout[l].children[activeTabIndex.value].children
|
||||||
dashboardStore.removeTabItem(props.data, idx);
|
);
|
||||||
}
|
needQuery.value = true;
|
||||||
function addTabItem() {
|
|
||||||
dashboardStore.addTabItem(props.data);
|
|
||||||
}
|
|
||||||
function editTabName(el: Event, index: number) {
|
|
||||||
el.stopPropagation();
|
|
||||||
editTabIndex.value = index;
|
|
||||||
}
|
|
||||||
function handleClick(el: any) {
|
|
||||||
if (el.target.className === "tab-name") {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
editTabIndex.value = NaN;
|
|
||||||
}
|
|
||||||
function addTabWidget(e: Event) {
|
|
||||||
e.stopPropagation();
|
|
||||||
activeTabWidget.value = String(state.layout.length);
|
|
||||||
dashboardStore.addTabWidget(activeTabIndex.value);
|
|
||||||
dashboardStore.activeGridItem(
|
|
||||||
`${props.data.i}-${activeTabIndex.value}-${activeTabWidget.value}`
|
|
||||||
);
|
|
||||||
}
|
|
||||||
function clickTabGrid(e: Event, item: LayoutConfig) {
|
|
||||||
e.stopPropagation();
|
|
||||||
activeTabWidget.value = item.i;
|
|
||||||
dashboardStore.activeGridItem(
|
|
||||||
`${props.data.i}-${activeTabIndex.value}-${item.i}`
|
|
||||||
);
|
|
||||||
}
|
|
||||||
document.body.addEventListener("click", handleClick, false);
|
|
||||||
|
|
||||||
const children = ref(
|
|
||||||
dashboardStore.layout[props.data.i].children[activeTabIndex.value].children
|
|
||||||
);
|
|
||||||
watch(
|
|
||||||
() => children.value,
|
|
||||||
(data) => {
|
|
||||||
state.layout = data;
|
|
||||||
}
|
|
||||||
);
|
|
||||||
watch(
|
|
||||||
() => dashboardStore.activedGridItem,
|
|
||||||
(data) => {
|
|
||||||
const i = data.split("-");
|
|
||||||
if (i[0] === props.data.i && activeTabIndex.value === Number(i[1])) {
|
|
||||||
activeTabWidget.value = i[2];
|
|
||||||
} else {
|
|
||||||
activeTabWidget.value = "";
|
|
||||||
}
|
}
|
||||||
}
|
function removeTab(e: Event) {
|
||||||
);
|
e.stopPropagation();
|
||||||
|
dashboardStore.removeTab(props.data);
|
||||||
|
}
|
||||||
|
function deleteTabItem(e: Event, idx: number) {
|
||||||
|
e.stopPropagation();
|
||||||
|
dashboardStore.removeTabItem(props.data, idx);
|
||||||
|
}
|
||||||
|
function addTabItem() {
|
||||||
|
dashboardStore.addTabItem(props.data);
|
||||||
|
}
|
||||||
|
function editTabName(el: Event, index: number) {
|
||||||
|
if (!canEditTabName.value) {
|
||||||
|
editTabIndex.value = NaN;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
editTabIndex.value = index;
|
||||||
|
}
|
||||||
|
function handleClick(el: any) {
|
||||||
|
if (["tab-name", "edit-tab"].includes(el.target.className)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
canEditTabName.value = false;
|
||||||
|
editTabIndex.value = NaN;
|
||||||
|
}
|
||||||
|
function clickTabGrid(e: Event, item: LayoutConfig) {
|
||||||
|
e.stopPropagation();
|
||||||
|
activeTabWidget.value = item.i;
|
||||||
|
dashboardStore.activeGridItem(
|
||||||
|
`${props.data.i}-${activeTabIndex.value}-${item.i}`
|
||||||
|
);
|
||||||
|
handleClick(e);
|
||||||
|
}
|
||||||
|
function layoutUpdatedEvent() {
|
||||||
|
const l = dashboardStore.layout.findIndex(
|
||||||
|
(d: LayoutConfig) => d.i === props.data.i
|
||||||
|
);
|
||||||
|
dashboardStore.setCurrentTabItems(
|
||||||
|
dashboardStore.layout[l].children[activeTabIndex.value].children
|
||||||
|
);
|
||||||
|
}
|
||||||
|
document.body.addEventListener("click", handleClick, false);
|
||||||
|
watch(
|
||||||
|
() => dashboardStore.activedGridItem,
|
||||||
|
(data) => {
|
||||||
|
if (!data) {
|
||||||
|
activeTabWidget.value = "";
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
const i = data.split("-");
|
||||||
|
if (i[0] === props.data.i && activeTabIndex.value === Number(i[1])) {
|
||||||
|
activeTabWidget.value = i[2];
|
||||||
|
} else {
|
||||||
|
activeTabWidget.value = "";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
);
|
||||||
|
return {
|
||||||
|
handleClick,
|
||||||
|
layoutUpdatedEvent,
|
||||||
|
clickTabGrid,
|
||||||
|
editTabName,
|
||||||
|
addTabItem,
|
||||||
|
deleteTabItem,
|
||||||
|
removeTab,
|
||||||
|
clickTabs,
|
||||||
|
...toRefs(props),
|
||||||
|
activeTabWidget,
|
||||||
|
dashboardStore,
|
||||||
|
activeTabIndex,
|
||||||
|
editTabIndex,
|
||||||
|
needQuery,
|
||||||
|
canEditTabName,
|
||||||
|
showTools,
|
||||||
|
t,
|
||||||
|
};
|
||||||
|
},
|
||||||
|
});
|
||||||
</script>
|
</script>
|
||||||
<style lang="scss" scoped>
|
<style lang="scss" scoped>
|
||||||
.tabs {
|
.tabs {
|
||||||
@ -218,10 +286,6 @@ watch(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
.el-input__inner {
|
|
||||||
border: none !important;
|
|
||||||
}
|
|
||||||
|
|
||||||
.operations {
|
.operations {
|
||||||
color: #aaa;
|
color: #aaa;
|
||||||
cursor: pointer;
|
cursor: pointer;
|
||||||
@ -263,4 +327,17 @@ watch(
|
|||||||
padding-top: 30px;
|
padding-top: 30px;
|
||||||
color: #888;
|
color: #888;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.tools {
|
||||||
|
padding: 5px 0;
|
||||||
|
color: #999;
|
||||||
|
cursor: pointer;
|
||||||
|
position: relative;
|
||||||
|
text-align: center;
|
||||||
|
|
||||||
|
&:hover {
|
||||||
|
color: #409eff;
|
||||||
|
background-color: #eee;
|
||||||
|
}
|
||||||
|
}
|
||||||
</style>
|
</style>
|
||||||
|
@ -77,6 +77,7 @@ const props = {
|
|||||||
default: () => ({ widget: {} }),
|
default: () => ({ widget: {} }),
|
||||||
},
|
},
|
||||||
activeIndex: { type: String, default: "" },
|
activeIndex: { type: String, default: "" },
|
||||||
|
needQuery: { type: Boolean, default: false },
|
||||||
};
|
};
|
||||||
export default defineComponent({
|
export default defineComponent({
|
||||||
name: "Widget",
|
name: "Widget",
|
||||||
@ -93,7 +94,7 @@ export default defineComponent({
|
|||||||
const dashboardStore = useDashboardStore();
|
const dashboardStore = useDashboardStore();
|
||||||
const selectorStore = useSelectorStore();
|
const selectorStore = useSelectorStore();
|
||||||
|
|
||||||
if (dashboardStore.entity === EntityType[1].value) {
|
if (dashboardStore.entity === EntityType[1].value || props.needQuery) {
|
||||||
queryMetrics();
|
queryMetrics();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -128,7 +129,10 @@ export default defineComponent({
|
|||||||
watch(
|
watch(
|
||||||
() => [props.data.metricTypes, props.data.metrics],
|
() => [props.data.metricTypes, props.data.metrics],
|
||||||
() => {
|
() => {
|
||||||
if (props.data.i !== dashboardStore.selectedGrid.i) {
|
if (
|
||||||
|
dashboardStore.selectedGrid &&
|
||||||
|
props.data.i !== dashboardStore.selectedGrid.i
|
||||||
|
) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (TableChartTypes.includes(dashboardStore.selectedGrid.graph.type)) {
|
if (TableChartTypes.includes(dashboardStore.selectedGrid.graph.type)) {
|
||||||
|
@ -165,9 +165,9 @@ export const SortOrder = [
|
|||||||
export const ToolIcons = [
|
export const ToolIcons = [
|
||||||
{ name: "playlist_add", content: "Add Widget", id: "addWidget" },
|
{ name: "playlist_add", content: "Add Widget", id: "addWidget" },
|
||||||
{ name: "all_inbox", content: "Add Tab", id: "addTab" },
|
{ name: "all_inbox", content: "Add Tab", id: "addTab" },
|
||||||
{ name: "device_hub", content: "Add Topology", id: "topology" },
|
{ name: "device_hub", content: "Add Topology", id: "addTopology" },
|
||||||
{ name: "merge", content: "Add Trace", id: "trace" },
|
{ name: "merge", content: "Add Trace", id: "addTrace" },
|
||||||
{ name: "timeline", content: "Add Profile", id: "profile" },
|
{ name: "timeline", content: "Add Profile", id: "addProfile" },
|
||||||
// { name: "save_alt", content: "Export", id: "export" },
|
// { name: "save_alt", content: "Export", id: "export" },
|
||||||
// { name: "folder_open", content: "Import", id: "import" },
|
// { name: "folder_open", content: "Import", id: "import" },
|
||||||
// { name: "settings", content: "Settings", id: "settings" },
|
// { name: "settings", content: "Settings", id: "settings" },
|
||||||
|
@ -53,6 +53,7 @@ export default defineComponent({
|
|||||||
}
|
}
|
||||||
function clickGrid(item: LayoutConfig) {
|
function clickGrid(item: LayoutConfig) {
|
||||||
dashboardStore.activeGridItem(item.i);
|
dashboardStore.activeGridItem(item.i);
|
||||||
|
dashboardStore.selectWidget(item);
|
||||||
}
|
}
|
||||||
return {
|
return {
|
||||||
dashboardStore,
|
dashboardStore,
|
||||||
|
@ -107,7 +107,6 @@ import { EntityType, ToolIcons, hasTopology, TraceEntitys } from "../data";
|
|||||||
import { useSelectorStore } from "@/store/modules/selectors";
|
import { useSelectorStore } from "@/store/modules/selectors";
|
||||||
import { ElMessage } from "element-plus";
|
import { ElMessage } from "element-plus";
|
||||||
import { Option } from "@/types/app";
|
import { Option } from "@/types/app";
|
||||||
import { Service } from "@/types/selector";
|
|
||||||
|
|
||||||
const dashboardStore = useDashboardStore();
|
const dashboardStore = useDashboardStore();
|
||||||
const selectorStore = useSelectorStore();
|
const selectorStore = useSelectorStore();
|
||||||
@ -260,7 +259,7 @@ async function getServices() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
async function changeService(service: Service[]) {
|
async function changeService(service: any) {
|
||||||
if (service[0]) {
|
if (service[0]) {
|
||||||
states.currentService = service[0].value;
|
states.currentService = service[0].value;
|
||||||
selectorStore.setCurrentService(service[0]);
|
selectorStore.setCurrentService(service[0]);
|
||||||
@ -270,7 +269,7 @@ async function changeService(service: Service[]) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function changeDestService(service: Service[]) {
|
function changeDestService(service: any) {
|
||||||
if (service[0]) {
|
if (service[0]) {
|
||||||
states.currentDestService = service[0].value;
|
states.currentDestService = service[0].value;
|
||||||
selectorStore.setCurrentDestService(service[0]);
|
selectorStore.setCurrentDestService(service[0]);
|
||||||
@ -279,7 +278,7 @@ function changeDestService(service: Service[]) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function changePods(pod: Option[]) {
|
function changePods(pod: any) {
|
||||||
if (pod[0]) {
|
if (pod[0]) {
|
||||||
selectorStore.setCurrentPod(pod[0]);
|
selectorStore.setCurrentPod(pod[0]);
|
||||||
} else {
|
} else {
|
||||||
@ -288,20 +287,55 @@ function changePods(pod: Option[]) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function clickIcons(t: { id: string; content: string; name: string }) {
|
function clickIcons(t: { id: string; content: string; name: string }) {
|
||||||
switch (t.id) {
|
if (
|
||||||
|
dashboardStore.selectedGrid &&
|
||||||
|
dashboardStore.selectedGrid.type === "Tab"
|
||||||
|
) {
|
||||||
|
setTabControls(t.id);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (dashboardStore.activedGridItem.split("-").length === 3) {
|
||||||
|
setTabControls(t.id);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
setControls(t.id);
|
||||||
|
}
|
||||||
|
|
||||||
|
function setTabControls(id: string) {
|
||||||
|
switch (id) {
|
||||||
|
case "addWidget":
|
||||||
|
dashboardStore.addTabControls("Widget");
|
||||||
|
break;
|
||||||
|
case "addTrace":
|
||||||
|
dashboardStore.addTabControls("Trace");
|
||||||
|
break;
|
||||||
|
case "addProfile":
|
||||||
|
dashboardStore.addTabControls("Profile");
|
||||||
|
break;
|
||||||
|
case "addTopology":
|
||||||
|
dashboardStore.addTabControls("Topology");
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
ElMessage.info("Don't support this control");
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function setControls(id: string) {
|
||||||
|
switch (id) {
|
||||||
case "addWidget":
|
case "addWidget":
|
||||||
dashboardStore.addControl("Widget");
|
dashboardStore.addControl("Widget");
|
||||||
break;
|
break;
|
||||||
case "addTab":
|
case "addTab":
|
||||||
dashboardStore.addControl("Tab");
|
dashboardStore.addControl("Tab");
|
||||||
break;
|
break;
|
||||||
case "trace":
|
case "addTrace":
|
||||||
dashboardStore.addControl("Trace");
|
dashboardStore.addControl("Trace");
|
||||||
break;
|
break;
|
||||||
case "profile":
|
case "addProfile":
|
||||||
dashboardStore.addControl("Profile");
|
dashboardStore.addControl("Profile");
|
||||||
break;
|
break;
|
||||||
case "topology":
|
case "addTopology":
|
||||||
dashboardStore.addControl("Topology");
|
dashboardStore.addControl("Topology");
|
||||||
break;
|
break;
|
||||||
case "settings":
|
case "settings":
|
||||||
|
@ -65,19 +65,16 @@ function loadTrees(l: boolean) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
.thread-stack {
|
.thread-stack {
|
||||||
padding: 5px 12px;
|
padding: 5px;
|
||||||
height: calc(50% - 50px);
|
height: calc(50% - 20px);
|
||||||
overflow: auto;
|
overflow: auto;
|
||||||
width: 100%;
|
width: 100%;
|
||||||
}
|
}
|
||||||
|
|
||||||
.t-loading {
|
.t-loading {
|
||||||
text-align: center;
|
text-align: center;
|
||||||
position: absolute;
|
|
||||||
width: 100%;
|
width: 100%;
|
||||||
height: 70px;
|
|
||||||
margin-top: 40px;
|
|
||||||
line-height: 88px;
|
|
||||||
overflow: hidden;
|
overflow: hidden;
|
||||||
|
height: calc(50% - 20px);
|
||||||
}
|
}
|
||||||
</style>
|
</style>
|
||||||
|
@ -35,16 +35,18 @@ limitations under the License. -->
|
|||||||
{{ t("analyze") }}
|
{{ t("analyze") }}
|
||||||
</el-button>
|
</el-button>
|
||||||
</div>
|
</div>
|
||||||
<Table
|
<div class="profile-table">
|
||||||
:data="profileStore.segmentSpans"
|
<Table
|
||||||
:traceId="
|
:data="profileStore.segmentSpans"
|
||||||
profileStore.currentSegment.traceIds &&
|
:traceId="
|
||||||
profileStore.currentSegment.traceIds[0]
|
profileStore.currentSegment.traceIds &&
|
||||||
"
|
profileStore.currentSegment.traceIds[0]
|
||||||
:showBtnDetail="true"
|
"
|
||||||
headerType="profile"
|
:showBtnDetail="true"
|
||||||
@select="selectSpan"
|
headerType="profile"
|
||||||
/>
|
@select="selectSpan"
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
<script lang="ts" setup>
|
<script lang="ts" setup>
|
||||||
@ -158,10 +160,14 @@ function updateTimeRange() {
|
|||||||
padding: 5px;
|
padding: 5px;
|
||||||
flex-shrink: 0;
|
flex-shrink: 0;
|
||||||
height: 50%;
|
height: 50%;
|
||||||
overflow: auto;
|
|
||||||
width: 100%;
|
width: 100%;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.profile-table {
|
||||||
|
height: calc(100% - 30px);
|
||||||
|
overflow: auto;
|
||||||
|
}
|
||||||
|
|
||||||
.profile-trace-detail-wrapper {
|
.profile-trace-detail-wrapper {
|
||||||
padding: 5px 0;
|
padding: 5px 0;
|
||||||
border-bottom: 1px solid rgba(0, 0, 0, 0.1);
|
border-bottom: 1px solid rgba(0, 0, 0, 0.1);
|
||||||
|
@ -136,7 +136,7 @@ limitations under the License. -->
|
|||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
import dayjs from "dayjs";
|
import dayjs from "dayjs";
|
||||||
import { useI18n } from "vue-i18n";
|
import { useI18n } from "vue-i18n";
|
||||||
import { ref, watch, computed, defineComponent } from "vue";
|
import { ref, computed, defineComponent } from "vue";
|
||||||
import type { PropType } from "vue";
|
import type { PropType } from "vue";
|
||||||
import SpanDetail from "../D3Graph/SpanDetail.vue";
|
import SpanDetail from "../D3Graph/SpanDetail.vue";
|
||||||
|
|
||||||
@ -152,7 +152,6 @@ export default defineComponent({
|
|||||||
emits: ["select"],
|
emits: ["select"],
|
||||||
components: { SpanDetail },
|
components: { SpanDetail },
|
||||||
setup(props, { emit }) {
|
setup(props, { emit }) {
|
||||||
/* global Nullable */
|
|
||||||
const displayChildren = ref<boolean>(true);
|
const displayChildren = ref<boolean>(true);
|
||||||
const showDetail = ref<boolean>(false);
|
const showDetail = ref<boolean>(false);
|
||||||
const { t } = useI18n();
|
const { t } = useI18n();
|
||||||
|
Loading…
Reference in New Issue
Block a user