Skip to content

Commit

Permalink
Merge pull request #17763 from jeclrsg/hpcc-30222-WU-details-calling-…
Browse files Browse the repository at this point in the history
…GetLogs

HPCC-30222 ECL Watch cut back multiple calls to WsLogaccess.GetLogs

Reviewed-by: Gordon Smith <[email protected]>
Merged-by: Gavin Halliday <[email protected]>
  • Loading branch information
ghalliday authored Sep 15, 2023
2 parents 4812518 + e4c3f62 commit 85aaa2e
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions esp/src/src-react/components/WorkunitDetails.tsx
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
import * as React from "react";
import { IPivotItemProps, Pivot, PivotItem } from "@fluentui/react";
import { scopedLogger } from "@hpcc-js/util";
import { SizeMe } from "react-sizeme";
import nlsHPCC from "src/nlsHPCC";
import { service, hasLogAccess } from "src/ESPLog";
import { useWorkunit } from "../hooks/workunit";
import { useUserTheme } from "../hooks/theme";
import { useDeepEffect } from "../hooks/deepHooks";
import { DojoAdapter } from "../layouts/DojoAdapter";
import { pivotItemStyle } from "../layouts/pivot";
import { pushUrl } from "../util/history";
Expand All @@ -22,6 +24,8 @@ import { WorkunitSummary } from "./WorkunitSummary";
import { Result } from "./Result";
import { Logs } from "./Logs";

const logger = scopedLogger("src-react/components/WorkunitDetails.tsx");

interface WorkunitDetailsProps {
wuid: string;
tab?: string;
Expand Down Expand Up @@ -54,20 +58,21 @@ export const WorkunitDetails: React.FunctionComponent<WorkunitDetailsProps> = ({

const [logCount, setLogCount] = React.useState<number | string>("*");
const [logsDisabled, setLogsDisabled] = React.useState(true);
React.useEffect(() => {

useDeepEffect(() => {
hasLogAccess().then(response => {
setLogsDisabled(!response);
return response;
}).then(hasLogAccess => {
if (hasLogAccess) {
service.GetLogsEx({ ...queryParams, jobId: wuid, LogLineStartFrom: 0, LogLineLimit: 10 }).then(response => { // HPCC-27711 - Requesting LogLineLimit=1 causes issues
setLogCount(response.total);
});
}).catch((err) => logger.error(err));
}
}).catch(() => {
setLogsDisabled(true);
});
}, [queryParams, wuid]);
}, [wuid], [queryParams]);

return <SizeMe monitorHeight>{({ size }) =>
<Pivot overflowBehavior="menu" style={{ height: "100%" }} selectedKey={tab} onLinkClick={evt => pushUrl(`/workunits/${wuid}/${evt.props.itemKey}`)}>
Expand Down

0 comments on commit 85aaa2e

Please sign in to comment.