mirror of
https://github.com/apache/skywalking-booster-ui.git
synced 2025-05-15 09:48:43 +00:00
associate widgets
This commit is contained in:
parent
dbaf6d2a43
commit
937517dc2e
@ -44,6 +44,13 @@ const props = defineProps({
|
|||||||
type: Object as PropType<{ [key: string]: any }>,
|
type: Object as PropType<{ [key: string]: any }>,
|
||||||
default: () => ({}),
|
default: () => ({}),
|
||||||
},
|
},
|
||||||
|
filters: {
|
||||||
|
type: Object as PropType<{
|
||||||
|
value: number | string;
|
||||||
|
dataIndex: number;
|
||||||
|
sourceId: string;
|
||||||
|
}>,
|
||||||
|
},
|
||||||
});
|
});
|
||||||
const available = computed(
|
const available = computed(
|
||||||
() =>
|
() =>
|
||||||
@ -55,6 +62,7 @@ const available = computed(
|
|||||||
onMounted(async () => {
|
onMounted(async () => {
|
||||||
await setOptions(props.option);
|
await setOptions(props.option);
|
||||||
chartRef.value && addResizeListener(unref(chartRef), resize);
|
chartRef.value && addResizeListener(unref(chartRef), resize);
|
||||||
|
console.log(props.filters);
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
const instance = getInstance();
|
const instance = getInstance();
|
||||||
|
|
||||||
@ -79,6 +87,27 @@ watch(
|
|||||||
setOptions(newVal);
|
setOptions(newVal);
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
watch(
|
||||||
|
() => props.filters,
|
||||||
|
() => {
|
||||||
|
console.log(props.filters);
|
||||||
|
const instance = getInstance();
|
||||||
|
if (!instance) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (props.filters) {
|
||||||
|
instance.dispatchAction({
|
||||||
|
type: "showTip",
|
||||||
|
dataIndex: props.filters.dataIndex,
|
||||||
|
seriesIndex: 0,
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
instance.dispatchAction({
|
||||||
|
type: "hideTip",
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
);
|
||||||
|
|
||||||
onBeforeUnmount(() => {
|
onBeforeUnmount(() => {
|
||||||
removeResizeListener(unref(chartRef), resize);
|
removeResizeListener(unref(chartRef), resize);
|
||||||
|
1
src/types/dashboard.d.ts
vendored
1
src/types/dashboard.d.ts
vendored
@ -38,6 +38,7 @@ export interface LayoutConfig {
|
|||||||
metricConfig?: MetricConfigOpt[];
|
metricConfig?: MetricConfigOpt[];
|
||||||
id?: string;
|
id?: string;
|
||||||
associate?: { widgetId: string }[];
|
associate?: { widgetId: string }[];
|
||||||
|
filters?: { value: number | string; dataIndex: number; sourceId: string };
|
||||||
}
|
}
|
||||||
|
|
||||||
export type MetricConfigOpt = {
|
export type MetricConfigOpt = {
|
||||||
|
@ -61,8 +61,9 @@ limitations under the License. -->
|
|||||||
metrics: data.metrics || [''],
|
metrics: data.metrics || [''],
|
||||||
metricTypes: data.metricTypes || [''],
|
metricTypes: data.metricTypes || [''],
|
||||||
i: data.i,
|
i: data.i,
|
||||||
|
id: data.id,
|
||||||
metricConfig: data.metricConfig,
|
metricConfig: data.metricConfig,
|
||||||
associate: data.associate || [],
|
filters: data.filters || {},
|
||||||
}"
|
}"
|
||||||
:needQuery="needQuery"
|
:needQuery="needQuery"
|
||||||
@click="clickHandle"
|
@click="clickHandle"
|
||||||
@ -162,6 +163,7 @@ export default defineComponent({
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
function clickHandle(params: EventParams | any) {
|
function clickHandle(params: EventParams | any) {
|
||||||
|
console.log(params);
|
||||||
const { widgets } = getDashboard(dashboardStore.currentDashboard);
|
const { widgets } = getDashboard(dashboardStore.currentDashboard);
|
||||||
const associate = (props.data.associate && props.data.associate) || [];
|
const associate = (props.data.associate && props.data.associate) || [];
|
||||||
|
|
||||||
@ -170,11 +172,12 @@ export default defineComponent({
|
|||||||
(d: { id: string }) => d.id === item.widgetId
|
(d: { id: string }) => d.id === item.widgetId
|
||||||
);
|
);
|
||||||
if (widget) {
|
if (widget) {
|
||||||
widget.filters = widget.filters || {};
|
|
||||||
widget.filters = {
|
widget.filters = {
|
||||||
...widget.filters,
|
value: params.value[0],
|
||||||
[props.data.id || ""]: { value: params.value[0] },
|
dataIndex: params.dataIndex,
|
||||||
|
sourceId: props.data.id || "",
|
||||||
};
|
};
|
||||||
|
|
||||||
dashboardStore.setWidget(widget);
|
dashboardStore.setWidget(widget);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -13,7 +13,7 @@ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|||||||
See the License for the specific language governing permissions and
|
See the License for the specific language governing permissions and
|
||||||
limitations under the License. -->
|
limitations under the License. -->
|
||||||
<template>
|
<template>
|
||||||
<Graph :option="option" @select="clickEvent" />
|
<Graph :option="option" @select="clickEvent" :filters="config.filters" />
|
||||||
</template>
|
</template>
|
||||||
<script lang="ts" setup>
|
<script lang="ts" setup>
|
||||||
import { computed } from "vue";
|
import { computed } from "vue";
|
||||||
@ -32,7 +32,15 @@ const props = defineProps({
|
|||||||
theme: { type: String, default: "light" },
|
theme: { type: String, default: "light" },
|
||||||
itemEvents: { type: Array as PropType<Event[]>, default: () => [] },
|
itemEvents: { type: Array as PropType<Event[]>, default: () => [] },
|
||||||
config: {
|
config: {
|
||||||
type: Object as PropType<LineConfig>,
|
type: Object as PropType<
|
||||||
|
LineConfig & {
|
||||||
|
filters: {
|
||||||
|
value: number | string;
|
||||||
|
dataIndex: number;
|
||||||
|
sourceId: string;
|
||||||
|
};
|
||||||
|
} & { id: string }
|
||||||
|
>,
|
||||||
default: () => ({
|
default: () => ({
|
||||||
step: false,
|
step: false,
|
||||||
smooth: false,
|
smooth: false,
|
||||||
|
Loading…
Reference in New Issue
Block a user