diff --git a/src/components/Graph.vue b/src/components/Graph.vue index 24b76650..6b87334a 100644 --- a/src/components/Graph.vue +++ b/src/components/Graph.vue @@ -115,6 +115,12 @@ watch( } if (props.filters) { if (props.filters.isRange) { + const list = props.option.series[0].data.map( + (d: (number | string)[]) => d[0] + ); + if (!list.includes(props.filters.duration.endTime)) { + return; + } const markArea = { silent: true, itemStyle: { diff --git a/src/views/dashboard/List.vue b/src/views/dashboard/List.vue index f8cb43ef..5dbe374f 100644 --- a/src/views/dashboard/List.vue +++ b/src/views/dashboard/List.vue @@ -20,7 +20,7 @@ limitations under the License. --> placeholder="Please input name" class="input-with-search ml-10" size="small" - @change="searchDashboards" + @change="searchDashboards(1)" > diff --git a/src/views/dashboard/related/event/Content.vue b/src/views/dashboard/related/event/Content.vue index dad8e99a..5dc8c501 100644 --- a/src/views/dashboard/related/event/Content.vue +++ b/src/views/dashboard/related/event/Content.vue @@ -30,14 +30,18 @@ import { dateFormatTime } from "@/utils/dateFormat"; import { useAppStoreWithOut } from "@/store/modules/app"; const eventStore = useEventStore(); -/*global Nullable */ +/*global defineProps, Nullable */ +const props = defineProps({ + data: { + type: Object, + default: () => ({}), + }, +}); const timeline = ref>(null); const visGraph = ref>(null); const oldVal = ref<{ width: number; height: number }>({ width: 0, height: 0 }); const dashboardStore = useDashboardStore(); const appStore = useAppStoreWithOut(); -const dateFormat = (date: number, pattern = "YYYY-MM-DD HH:mm:ss") => - new Date(dayjs(date).format(pattern)); const visDate = (date: number, pattern = "YYYY-MM-DD HH:mm:ss") => dayjs(date).format(pattern); @@ -61,8 +65,8 @@ function visTimeline() { return { id: index + 1, content: d.name, - start: dateFormat(Number(d.startTime)), - end: dateFormat(Number(d.endTime)), + start: new Date(Number(d.startTime)), + end: new Date(Number(d.endTime)), data: d, className: d.type, }; @@ -97,9 +101,10 @@ function visTimeline() { }; visGraph.value = new Timeline(timeline.value, items, options); visGraph.value.on("select", (properties: { items: number[] }) => { - if (!dashboardStore.selectedGrid.eventAssociate) { + if (!props.data.eventAssociate) { return; } + dashboardStore.selectWidget(props.data); const all = getDashboard(dashboardStore.currentDashboard).widgets; const widgets = all.filter( (d: { value: string; label: string } & LayoutConfig) => { @@ -117,8 +122,20 @@ function visTimeline() { for (const widget of widgets) { let end = i.end; if (!isNaN(index)) { - if (!i.end || i.end.getTime() - i.start.getTime() < 60000) { - end = i.start.getTime() + 60000; + let diff = 60000; + switch (appStore.duration.step) { + case "MINUTE": + diff = 60000; + break; + case "HOUR": + diff = 3600000; + break; + case "DAY": + diff = 3600000 * 24; + break; + } + if (!i.end || i.end.getTime() - i.start.getTime() < diff) { + end = i.start.getTime() + diff; } } const startTime = dateFormatTime(i.start, appStore.duration.step); diff --git a/src/views/dashboard/related/event/Header.vue b/src/views/dashboard/related/event/Header.vue index 5ce838ff..81550438 100644 --- a/src/views/dashboard/related/event/Header.vue +++ b/src/views/dashboard/related/event/Header.vue @@ -125,6 +125,9 @@ function fetchSelectors() { async function getEndpoints(id?: string) { const resp = await eventStore.getEndpoints(id); + if (!resp) { + return; + } if (resp.errors) { ElMessage.error(resp.errors); return; @@ -148,6 +151,9 @@ async function queryEvents() { if (dashboardStore.entity === EntityType[3].value) { instance = selectorStore.currentPod.id; } + if (!selectorStore.currentService) { + return; + } eventStore.setEventCondition({ // layer: dashboardStore.layerId, paging: {