This commit is contained in:
Fine 2022-08-10 19:13:24 +08:00
parent ab1ae85694
commit e3fc5ab6c7
2 changed files with 9 additions and 7 deletions

View File

@ -56,7 +56,7 @@ const props = defineProps({
});
const { t } = useI18n();
const networkProfilingStore = useNetworkProfilingStore();
const layout = ref<LayoutConfig[]>(props.widgets);
const layout = ref<LayoutConfig[]>(props.widgets || []);
function clickGrid(item: LayoutConfig) {
networkProfilingStore.setActiveItem(item.i);

View File

@ -77,6 +77,7 @@ import type { PropType } from "vue";
import { LayoutConfig } from "@/types/dashboard";
import { useDashboardStore } from "@/store/modules/dashboard";
import { useAppStoreWithOut } from "@/store/modules/app";
import { useNetworkProfilingStore } from "@/store/modules/network-profiling";
import graphs from "../../../../graphs/topology";
import { useI18n } from "vue-i18n";
import {
@ -95,7 +96,7 @@ const props = {
};
export default defineComponent({
name: "Widget",
name: "Metric",
components: { ...graphs },
props,
setup(props) {
@ -107,6 +108,7 @@ export default defineComponent({
const { data } = toRefs(props);
const appStore = useAppStoreWithOut();
const dashboardStore = useDashboardStore();
const networkProfilingStore = useNetworkProfilingStore();
const graph = computed(() => props.data.graph || {});
const widget = computed(() => props.data.widget || {});
@ -137,15 +139,15 @@ export default defineComponent({
}
function removeWidget() {
dashboardStore.removeControls(props.data);
networkProfilingStore.removeControls(props.data);
}
function editConfig() {
dashboardStore.setConfigPanel(true);
dashboardStore.selectWidget(props.data);
networkProfilingStore.setConfigPanel(true);
networkProfilingStore.setSelectedMetric(props.data);
if (props.activeIndex) {
dashboardStore.activeGridItem(props.activeIndex);
networkProfilingStore.setActiveItem(props.activeIndex);
} else {
dashboardStore.activeGridItem(props.data.i);
networkProfilingStore.setActiveItem(props.data.i);
}
}