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 { t } = useI18n();
const networkProfilingStore = useNetworkProfilingStore(); const networkProfilingStore = useNetworkProfilingStore();
const layout = ref<LayoutConfig[]>(props.widgets); const layout = ref<LayoutConfig[]>(props.widgets || []);
function clickGrid(item: LayoutConfig) { function clickGrid(item: LayoutConfig) {
networkProfilingStore.setActiveItem(item.i); networkProfilingStore.setActiveItem(item.i);

View File

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