@@ -20,6 +20,9 @@ import _ from 'lodash';
2020import { stringify } from 'query-string' ;
2121import { useContext , useState } from 'react' ;
2222
23+ import { isFilterTypeExist } from '@/components/filters/utils' ;
24+ import { FILTER_TYPES } from '@/utils/filtersUtils' ;
25+
2326import { FilterTagsContext } from '../../states/filters/FiltersTagsContext' ;
2427import { SelectorsContext } from '../../states/selectors' ;
2528import { PROFILES_VIEWS } from '../../utils/consts' ;
@@ -35,6 +38,7 @@ const useGetFgMetrics = ({ customTimeSelection, customService, disableCoreNodesR
3538 const { selectedService, timeSelection, viewMode, ignoreZeros } = useContext ( SelectorsContext ) ;
3639 const { activeFilterTag } = useContext ( FilterTagsContext ) ;
3740 const [ metricsData , setMetricsData ] = useState ( undefined ) ;
41+ const [ lastHtmlData , setLastHtmlData ] = useState ( undefined ) ;
3842 const [ coresNodesCountData , setCoresNodesCountData ] = useState ( undefined ) ;
3943 const [ instanceTypeData , setInstanceTypeData ] = useState ( undefined ) ;
4044 const timeParams = getStartEndDateTimeFromSelection ( customTimeSelection || timeSelection ) ;
@@ -66,6 +70,30 @@ const useGetFgMetrics = ({ customTimeSelection, customService, disableCoreNodesR
6670 }
6771 ) ;
6872
73+ const isHostNameFilterActive = isFilterTypeExist ( FILTER_TYPES . HostName . value , activeFilterTag ) ;
74+ const { loading : lastHtmlLoading } = useFetchWithRequest (
75+ {
76+ url : DATA_URLS . GET_LAST_HTML + '?' + stringify ( metricsParams ) ,
77+ } ,
78+ {
79+ refreshDeps : [
80+ customService ,
81+ selectedService ,
82+ customTimeSelection ? customTimeSelection : timeSelection ,
83+ activeFilterTag ,
84+ ] ,
85+ ready :
86+ areParamsDefined ( customService || selectedService , customTimeSelection || timeSelection ) &&
87+ isHostNameFilterActive ,
88+ onSuccess : ( result ) => {
89+ setLastHtmlData ( result ?. content ) ;
90+ } ,
91+ onError : ( ) => {
92+ setLastHtmlData ( undefined ) ;
93+ } ,
94+ }
95+ ) ;
96+
6997 const isServiceView = viewMode === PROFILES_VIEWS . service ;
7098 const serviceAndTimeParams = {
7199 serviceName : customService || selectedService ,
@@ -117,6 +145,8 @@ const useGetFgMetrics = ({ customTimeSelection, customService, disableCoreNodesR
117145 return {
118146 metricsData,
119147 metricsLoading,
148+ lastHtmlData,
149+ lastHtmlLoading,
120150 coresNodesCountData : coresNodesCountData ,
121151 coresNodesCountLoading,
122152 instanceTypeData,
0 commit comments