5
5
} from ' vue' ;
6
6
import { useRoute } from ' vue-router/composables' ;
7
7
8
- import { useQuery } from ' @tanstack/vue-query' ;
9
8
import bytes from ' bytes' ;
10
9
import { sortBy } from ' lodash' ;
11
10
@@ -22,6 +21,7 @@ import type { PrivateDataTableModel } from '@/api-clients/dashboard/private-data
22
21
import { usePublicDataTableApi } from ' @/api-clients/dashboard/public-data-table/composables/use-public-data-table-api' ;
23
22
import type { DataTableLoadParameters } from ' @/api-clients/dashboard/public-data-table/schema/api-verbs/load' ;
24
23
import type { PublicDataTableModel } from ' @/api-clients/dashboard/public-data-table/schema/model' ;
24
+ import { useScopedQuery } from ' @/query/composables/use-scoped-query' ;
25
25
import { useServiceQueryKey } from ' @/query/query-key/use-service-query-key' ;
26
26
import { i18n } from ' @/translations' ;
27
27
@@ -37,7 +37,7 @@ import type { DataInfo } from '@/common/modules/widgets/types/widget-model';
37
37
38
38
import { gray , white } from ' @/styles/colors' ;
39
39
40
- import { useDashboardGetQuery } from ' @/services/_shared/dashboard/dashboard-detail/composables/use-dashboard-get-query ' ;
40
+ import { useDashboardRefinedVars } from ' @/services/_shared/dashboard/dashboard-detail/contextual- composables/use-dashboard-refined-vars ' ;
41
41
import { SIZE_UNITS } from ' @/services/asset-inventory/constants/asset-analysis-constant' ;
42
42
import { GRANULARITY } from ' @/services/cost-explorer/constants/cost-explorer-constant' ;
43
43
import type { Granularity } from ' @/services/cost-explorer/types/cost-explorer-query-type' ;
@@ -59,6 +59,8 @@ const widgetGenerateState = widgetGenerateStore.state;
59
59
const allReferenceStore = useAllReferenceStore ();
60
60
const route = useRoute ();
61
61
const dashboardId = computed (() => route .params .dashboardId );
62
+ const { refinedVars } = useDashboardRefinedVars (dashboardId );
63
+
62
64
const {
63
65
privateDataTableAPI,
64
66
} = usePrivateDataTableApi ();
@@ -72,9 +74,6 @@ const {
72
74
} = useWidgetDataTableListQuery ({
73
75
widgetId: computed (() => widgetGenerateState .widgetId ),
74
76
});
75
- const { dashboard } = useDashboardGetQuery ({
76
- dashboardId ,
77
- });
78
77
79
78
const storeState = reactive ({
80
79
selectedDataTableId: computed <string | undefined >(() => widgetGenerateState .selectedDataTableId ),
@@ -256,22 +255,14 @@ const getSortIcon = (field: PreviewTableField) => {
256
255
// return '';
257
256
};
258
257
259
- // const getTimeDiffSubText = (field: PreviewTableField): string => {
260
- // if (!state.dataInfo?.[field.name]) return '';
261
- // const { timediff } = state.dataInfo[field.name];
262
- // if (!timediff || !Object.entries(timediff ?? {}).length) return '';
263
- // const [key, value] = Object.entries(timediff)[0];
264
- // return `( ${value} ${key} )`;
265
- // };
266
-
267
258
const { key : privateDataTableLoadQueryKey, params : privateDataTableLoadParams } = useServiceQueryKey (' dashboard' , ' private-data-table' , ' load' , {
268
259
contextKey: computed (() => storeState .selectedDataTableId ),
269
260
params: computed <DataTableLoadParameters >(() => ({
270
261
data_table_id: storeState .selectedDataTableId as string ,
271
262
granularity: state .selectedGranularity ,
272
263
sort: state .sortBy ,
273
264
page: state .page ,
274
- vars: dashboard .value ?. vars ,
265
+ vars: refinedVars .value ,
275
266
})),
276
267
});
277
268
@@ -282,11 +273,11 @@ const { key: publicDataTableLoadQueryKey, params: publicDataTableLoadParams } =
282
273
granularity: state .selectedGranularity ,
283
274
sort: state .sortBy ,
284
275
page: state .page ,
285
- vars: dashboard .value ?. vars ,
276
+ vars: refinedVars .value ,
286
277
})),
287
278
});
288
279
289
- const queryResult = useQuery ({
280
+ const queryResult = useScopedQuery ({
290
281
queryKey: state .isPrivate ? privateDataTableLoadQueryKey .value : publicDataTableLoadQueryKey .value ,
291
282
queryFn : () => {
292
283
if (! storeState .selectedDataTableId ) {
@@ -300,7 +291,7 @@ const queryResult = useQuery({
300
291
enabled: computed (() => storeState .selectedDataTableId !== undefined && state .selectedDataTable !== undefined ),
301
292
staleTime: WIDGET_LOAD_STALE_TIME ,
302
293
retry: 2 ,
303
- });
294
+ }, [ ' WORKSPACE ' , ' DOMAIN ' ] );
304
295
305
296
const dataTableLoading = computed <boolean >(() => queryResult .isLoading .value || queryResult .isFetching .value );
306
297
const isError = computed <boolean >(() => queryResult .isError .value );
0 commit comments