Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/candidate-9.2.x' into candidate-…
Browse files Browse the repository at this point in the history
…9.4.x

Signed-off-by: Gavin Halliday <[email protected]>

# Conflicts:
#	helm/hpcc/Chart.yaml
#	helm/hpcc/templates/_helpers.tpl
#	version.cmake
  • Loading branch information
ghalliday committed Nov 1, 2024
2 parents 415de25 + 6db98c5 commit c81df7e
Show file tree
Hide file tree
Showing 3 changed files with 99 additions and 83 deletions.
3 changes: 3 additions & 0 deletions esp/src/src-react/components/Metrics.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,9 @@ export const Metrics: React.FunctionComponent<MetricsProps> = ({
selection,
fullscreen = false
}) => {
if (querySet && queryId) {
wuid = "";
}
const [_uiState, _setUIState] = React.useState({ ...defaultUIState });
const [selectedMetricsSource, setSelectedMetricsSource] = React.useState<SelectedMetricsSource>("");
const [selectedMetrics, setSelectedMetrics] = React.useState<IScope[]>([]);
Expand Down
177 changes: 95 additions & 82 deletions esp/src/src-react/hooks/metrics.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import { scopedLogger } from "@hpcc-js/util";
import { singletonHook } from "react-singleton-hook";
import { userKeyValStore } from "src/KeyValStore";
import { DockPanelLayout } from "../layouts/DockPanel";
import { singletonDebounce } from "../util/throttle";
import { useWorkunit } from "./workunit";
import { useQuery } from "./query";
import { useCounter } from "./util";
Expand Down Expand Up @@ -214,14 +215,19 @@ function useMetricsViewsImpl(): useMetricsViewsResult {

export const useMetricsViews = singletonHook(defaultState, useMetricsViewsImpl);

let wuDetailsMetaResponse: Promise<WsWorkunits.WUDetailsMetaResponse>;

export function useMetricMeta(): [string[], string[]] {

const service = useConst(() => new WorkunitsService({ baseUrl: "" }));
const [scopeTypes, setScopeTypes] = React.useState<string[]>([]);
const [properties, setProperties] = React.useState<string[]>([]);

React.useEffect(() => {
service?.WUDetailsMeta({}).then(response => {
if (!wuDetailsMetaResponse && service) {
wuDetailsMetaResponse = service.WUDetailsMeta({});
}
wuDetailsMetaResponse?.then(response => {
setScopeTypes(response?.ScopeTypes?.ScopeType || []);
setProperties((response?.Properties?.Property.map(p => p.Name) || []).sort());
});
Expand Down Expand Up @@ -274,45 +280,48 @@ export function useWorkunitMetrics(
const [count, increment] = useCounter();

React.useEffect(() => {
setStatus(FetchStatus.STARTED);
workunit?.fetchDetailsNormalized({
ScopeFilter: scopeFilter,
NestedFilter: nestedFilter,
PropertiesToReturn: {
AllScopes: true,
AllAttributes: true,
AllProperties: true,
AllNotes: true,
AllStatistics: true,
AllHints: true
},
ScopeOptions: {
IncludeId: true,
IncludeScope: true,
IncludeScopeType: true,
IncludeMatchedScopesInResults: true
},
PropertyOptions: {
IncludeName: true,
IncludeRawValue: true,
IncludeFormatted: true,
IncludeMeasure: true,
IncludeCreator: false,
IncludeCreatorType: false
}
}).then(response => {
setData(response?.data);
setColumns(response?.columns);
setActivities(response?.meta?.Activities?.Activity || []);
setProperties(response?.meta?.Properties?.Property || []);
setMeasures(response?.meta?.Measures?.Measure || []);
setScopeTypes(response?.meta?.ScopeTypes?.ScopeType || []);
}).catch(e => {
logger.error(e);
}).finally(() => {
setStatus(FetchStatus.COMPLETE);
});
}, [workunit, state, count, scopeFilter, nestedFilter]);
if (wuid && workunit) {
const fetchDetailsNormalized = singletonDebounce(workunit, "fetchDetailsNormalized");
setStatus(FetchStatus.STARTED);
fetchDetailsNormalized({
ScopeFilter: scopeFilter,
NestedFilter: nestedFilter,
PropertiesToReturn: {
AllScopes: true,
AllAttributes: true,
AllProperties: true,
AllNotes: true,
AllStatistics: true,
AllHints: true
},
ScopeOptions: {
IncludeId: true,
IncludeScope: true,
IncludeScopeType: true,
IncludeMatchedScopesInResults: true
},
PropertyOptions: {
IncludeName: true,
IncludeRawValue: true,
IncludeFormatted: true,
IncludeMeasure: true,
IncludeCreator: false,
IncludeCreatorType: false
}
}).then(response => {
setData(response?.data);
setColumns(response?.columns);
setActivities(response?.meta?.Activities?.Activity || []);
setProperties(response?.meta?.Properties?.Property || []);
setMeasures(response?.meta?.Measures?.Measure || []);
setScopeTypes(response?.meta?.ScopeTypes?.ScopeType || []);
}).catch(e => {
logger.error(e);
}).finally(() => {
setStatus(FetchStatus.COMPLETE);
});
}
}, [workunit, state, count, scopeFilter, nestedFilter, wuid]);

return { metrics: data, columns, activities, properties, measures, scopeTypes, status, refresh: increment };
}
Expand All @@ -335,45 +344,48 @@ export function useQueryMetrics(
const [count, increment] = useCounter();

React.useEffect(() => {
setStatus(FetchStatus.STARTED);
query?.fetchDetailsNormalized({
ScopeFilter: scopeFilter,
NestedFilter: nestedFilter,
PropertiesToReturn: {
AllScopes: true,
AllAttributes: true,
AllProperties: true,
AllNotes: true,
AllStatistics: true,
AllHints: true
},
ScopeOptions: {
IncludeId: true,
IncludeScope: true,
IncludeScopeType: true,
IncludeMatchedScopesInResults: true
},
PropertyOptions: {
IncludeName: true,
IncludeRawValue: true,
IncludeFormatted: true,
IncludeMeasure: true,
IncludeCreator: false,
IncludeCreatorType: false
}
}).then(response => {
setData(response?.data);
setColumns(response?.columns);
setActivities(response?.meta?.Activities?.Activity || []);
setProperties(response?.meta?.Properties?.Property || []);
setMeasures(response?.meta?.Measures?.Measure || []);
setScopeTypes(response?.meta?.ScopeTypes?.ScopeType || []);
}).catch(e => {
logger.error(e);
}).finally(() => {
setStatus(FetchStatus.COMPLETE);
});
}, [query, state, count, scopeFilter, nestedFilter]);
if (querySet && queryId && query) {
const fetchDetailsNormalized = singletonDebounce(query, "fetchDetailsNormalized");
setStatus(FetchStatus.STARTED);
fetchDetailsNormalized({
ScopeFilter: scopeFilter,
NestedFilter: nestedFilter,
PropertiesToReturn: {
AllScopes: true,
AllAttributes: true,
AllProperties: true,
AllNotes: true,
AllStatistics: true,
AllHints: true
},
ScopeOptions: {
IncludeId: true,
IncludeScope: true,
IncludeScopeType: true,
IncludeMatchedScopesInResults: true
},
PropertyOptions: {
IncludeName: true,
IncludeRawValue: true,
IncludeFormatted: true,
IncludeMeasure: true,
IncludeCreator: false,
IncludeCreatorType: false
}
}).then(response => {
setData(response?.data);
setColumns(response?.columns);
setActivities(response?.meta?.Activities?.Activity || []);
setProperties(response?.meta?.Properties?.Property || []);
setMeasures(response?.meta?.Measures?.Measure || []);
setScopeTypes(response?.meta?.ScopeTypes?.ScopeType || []);
}).catch(e => {
logger.error(e);
}).finally(() => {
setStatus(FetchStatus.COMPLETE);
});
}
}, [query, state, count, scopeFilter, nestedFilter, querySet, queryId]);

return { metrics: data, columns, activities, properties, measures, scopeTypes, status, refresh: increment };
}
Expand All @@ -385,7 +397,8 @@ export function useWUQueryMetrics(
scopeFilter: Partial<WsWorkunits.ScopeFilter> = scopeFilterDefault,
nestedFilter: WsWorkunits.NestedFilter = nestedFilterDefault
): useMetricsResult {
const wuMetrics = useWorkunitMetrics(wuid, scopeFilter, nestedFilter);
const queryMetrics = useQueryMetrics(querySet, queryId, scopeFilter, nestedFilter);
return querySet && queryId ? { ...queryMetrics } : { ...wuMetrics };
const isQuery = querySet && queryId;
const wuMetrics = useWorkunitMetrics(isQuery ? "" : wuid, scopeFilter, nestedFilter);
const queryMetrics = useQueryMetrics(isQuery ? querySet : "", isQuery ? queryId : "", scopeFilter, nestedFilter);
return isQuery ? { ...queryMetrics } : { ...wuMetrics };
}
2 changes: 1 addition & 1 deletion esp/src/src-react/hooks/workunit.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ export function useWorkunit(wuid: string, full: boolean = false): [Workunit, WUS
const [retVal, setRetVal] = React.useState<{ workunit: Workunit, state: number, lastUpdate: number, isComplete: boolean, refresh: RefreshFunc }>();

React.useEffect(() => {
if (wuid === undefined || wuid === null) {
if (!wuid) {
setRetVal({ workunit: undefined, state: WUStateID.NotFound, lastUpdate: Date.now(), isComplete: undefined, refresh: (full?: boolean) => Promise.resolve(undefined) });
return;
}
Expand Down

0 comments on commit c81df7e

Please sign in to comment.