diff --git a/src/store/modules/dashboard.ts b/src/store/modules/dashboard.ts
index d324b4c8..aef7aa96 100644
--- a/src/store/modules/dashboard.ts
+++ b/src/store/modules/dashboard.ts
@@ -275,6 +275,27 @@ export const dashboardStore = defineStore({
};
this.selectedGrid = this.layout[index];
},
+ setWidget(param: LayoutConfig) {
+ for (let item of this.layout) {
+ if (item.type === "Tab") {
+ if (item.children && item.children.length) {
+ for (const child of item.children) {
+ if (child.children && child.children.length) {
+ for (let c of child.children) {
+ if (c.id === param.id) {
+ c = param;
+ }
+ }
+ }
+ }
+ }
+ } else {
+ if (item.id === param.id) {
+ item = param;
+ }
+ }
+ }
+ },
async fetchMetricType(item: string) {
const res: AxiosResponse = await graphql
.query("queryTypeOfMetrics")
diff --git a/src/types/components.d.ts b/src/types/components.d.ts
index 73addae0..98d9902c 100644
--- a/src/types/components.d.ts
+++ b/src/types/components.d.ts
@@ -5,8 +5,36 @@
declare module '@vue/runtime-core' {
export interface GlobalComponents {
DateCalendar: typeof import('./../components/DateCalendar.vue')['default']
+ ElButton: typeof import('element-plus/es')['ElButton']
+ ElCollapse: typeof import('element-plus/es')['ElCollapse']
+ ElCollapseItem: typeof import('element-plus/es')['ElCollapseItem']
+ ElDialog: typeof import('element-plus/es')['ElDialog']
+ ElDropdown: typeof import('element-plus/es')['ElDropdown']
+ ElDropdownItem: typeof import('element-plus/es')['ElDropdownItem']
+ ElDropdownMenu: typeof import('element-plus/es')['ElDropdownMenu']
+ ElIcon: typeof import('element-plus/es')['ElIcon']
+ ElInput: typeof import('element-plus/es')['ElInput']
+ ElInputNumber: typeof import('element-plus/es')['ElInputNumber']
+ ElMenu: typeof import('element-plus/es')['ElMenu']
+ ElMenuItem: typeof import('element-plus/es')['ElMenuItem']
+ ElMenuItemGroup: typeof import('element-plus/es')['ElMenuItemGroup']
+ ElOption: typeof import('element-plus/es')['ElOption']
+ ElPagination: typeof import('element-plus/es')['ElPagination']
+ ElPopconfirm: typeof import('element-plus/es')['ElPopconfirm']
+ ElPopover: typeof import('element-plus/es')['ElPopover']
+ ElProgress: typeof import('element-plus/es')['ElProgress']
+ ElRadio: typeof import('element-plus/es')['ElRadio']
+ ElRadioGroup: typeof import('element-plus/es')['ElRadioGroup']
+ ElSelect: typeof import('element-plus/es')['ElSelect']
+ ElSlider: typeof import('element-plus/es')['ElSlider']
+ ElSubMenu: typeof import('element-plus/es')['ElSubMenu']
+ ElSwitch: typeof import('element-plus/es')['ElSwitch']
+ ElTable: typeof import('element-plus/es')['ElTable']
+ ElTableColumn: typeof import('element-plus/es')['ElTableColumn']
+ ElTooltip: typeof import('element-plus/es')['ElTooltip']
Graph: typeof import('./../components/Graph.vue')['default']
Icon: typeof import('./../components/Icon.vue')['default']
+ Loading: typeof import('element-plus/es')['ElLoadingDirective']
Radio: typeof import('./../components/Radio.vue')['default']
RouterLink: typeof import('vue-router')['RouterLink']
RouterView: typeof import('vue-router')['RouterView']
diff --git a/src/types/dashboard.d.ts b/src/types/dashboard.d.ts
index 3ecaf4cb..7f180afd 100644
--- a/src/types/dashboard.d.ts
+++ b/src/types/dashboard.d.ts
@@ -37,7 +37,7 @@ export interface LayoutConfig {
activedTabIndex?: number;
metricConfig?: MetricConfigOpt[];
id?: string;
- associate?: { widgetIds: string }[];
+ associate?: { widgetId: string }[];
}
export type MetricConfigOpt = {
diff --git a/src/views/dashboard/configuration/widget/AssociateOptions.vue b/src/views/dashboard/configuration/widget/AssociateOptions.vue
index b49d4967..3649f00e 100644
--- a/src/views/dashboard/configuration/widget/AssociateOptions.vue
+++ b/src/views/dashboard/configuration/widget/AssociateOptions.vue
@@ -17,7 +17,7 @@ limitations under the License. -->
{{ t("widget") }}
(associate.widgetIds || []);
+const widgetId = ref(associate.widgetId || []);
const widgets = computed(() => {
const isLinear = ["Bar", "Line", "Area"].includes(
dashboardStore.selectedGrid.graph && dashboardStore.selectedGrid.graph.type
@@ -65,10 +65,12 @@ const widgets = computed(() => {
return items;
});
function updateWidgetConfig(options: Option[]) {
- const opt = options.map((d: Option) => d.value);
+ const opt = options.map((d: Option) => {
+ return { widgetId: d.value };
+ });
const widget = {
...dashboardStore.selectedGrid,
- associate: { widgetIds: opt },
+ associate: opt,
};
dashboardStore.selectWidget({ ...widget });
}
diff --git a/src/views/dashboard/controls/Widget.vue b/src/views/dashboard/controls/Widget.vue
index 954d6525..d4b2c27e 100644
--- a/src/views/dashboard/controls/Widget.vue
+++ b/src/views/dashboard/controls/Widget.vue
@@ -87,6 +87,7 @@ import {
} from "@/hooks/useProcessor";
import { EntityType, ListChartTypes } from "../data";
import { EventParams } from "@/types/dashboard";
+import getDashboard from "@/hooks/useDashboardsSession";
const props = {
data: {
@@ -161,10 +162,22 @@ export default defineComponent({
}
}
function clickHandle(params: EventParams | any) {
- console.log(params);
- console.log(props.data.associate);
- // for (const id of props.config.associate.widgetIds) {
- // }
+ const { widgets } = getDashboard(dashboardStore.currentDashboard);
+ const associate = (props.data.associate && props.data.associate) || [];
+
+ for (const item of associate) {
+ const widget = widgets.find(
+ (d: { id: string }) => d.id === item.widgetId
+ );
+ if (widget) {
+ widget.filters = widget.filters || {};
+ widget.filters = {
+ ...widget.filters,
+ [props.data.id || ""]: { value: params.value[0] },
+ };
+ dashboardStore.setWidget(widget);
+ }
+ }
}
watch(
() => [props.data.metricTypes, props.data.metrics],
diff --git a/src/views/dashboard/graphs/Line.vue b/src/views/dashboard/graphs/Line.vue
index 6393ca4c..344fba44 100644
--- a/src/views/dashboard/graphs/Line.vue
+++ b/src/views/dashboard/graphs/Line.vue
@@ -32,9 +32,7 @@ const props = defineProps({
theme: { type: String, default: "light" },
itemEvents: { type: Array as PropType, default: () => [] },
config: {
- type: Object as PropType<
- LineConfig & { associate: { widgetIds: string[] } }
- >,
+ type: Object as PropType,
default: () => ({
step: false,
smooth: false,