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: Gordon Smith <[email protected]>
  • Loading branch information
GordonSmith committed Nov 16, 2023
2 parents f60821d + a12fd9b commit 893b0ca
Show file tree
Hide file tree
Showing 10 changed files with 126 additions and 81 deletions.
5 changes: 3 additions & 2 deletions esp/src/eclwatch/templates/EventScheduleWorkunitWidget.html
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,9 @@
<span data-dojo-type="dijit.ToolbarSeparator"></span>
<div id="${id}Filter" data-dojo-type="FilterDropDownWidget">
<input id="${id}EventName" title="${i18n.EventName}:" name="EventName" colspan="2" data-dojo-props="trim: true, placeHolder:'${i18n.EventNamePH}'" data-dojo-type="dijit.form.TextBox" />
<input id="${id}State" title="${i18n.State}:" name="State" colspan="2" data-dojo-props="trim: true, placeHolder:'${i18n.State}'" data-dojo-type="dijit.form.TextBox" />
<input id="${id}Owner" title="${i18n.Owner}:" name="Owner" colspan="2" data-dojo-props="trim: true, placeHolder:'${i18n.Owner}'" data-dojo-type="dijit.form.TextBox" />
<input id="${id}JobName" title="${i18n.JobName}:" name="JobName" colspan="2" data-dojo-props="trim: true, placeHolder:'${i18n.log_analysis_1}'" data-dojo-type="dijit.form.TextBox" />
<input id="${id}State" title="${i18n.State}:" name="State" colspan="2" data-dojo-props="trim: true, placeHolder:'${i18n.Compiled}'" data-dojo-type="dijit.form.TextBox" />
<input id="${id}Owner" title="${i18n.Owner}:" name="Owner" colspan="2" data-dojo-props="trim: true, placeHolder:'${i18n.jsmi}'" data-dojo-type="dijit.form.TextBox" />
<input id="${id}EventTextFilter" title="${i18n.EventText}:" name="EventText" colspan="2" data-dojo-props="trim: true, placeHolder:'${i18n.EventTextPH}'" data-dojo-type="dijit.form.TextBox" />
<input id="${id}ClusterTargetSelect" title="${i18n.Cluster}:" name="Cluster" colspan="2" data-dojo-props="trim:true, placeHolder:'${i18n.ClusterPlaceholder}'" data-dojo-type="TargetSelectWidget" />
</div>
Expand Down
93 changes: 76 additions & 17 deletions esp/src/src-react/components/DFUWorkunitDetails.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,43 @@ import { useDfuWorkunit } from "../hooks/workunit";
import { pivotItemStyle } from "../layouts/pivot";
import { pushUrl, replaceUrl } from "../util/history";
import { ShortVerticalDivider } from "./Common";
import { Field, Fields } from "./forms/Fields";
import { TableGroup } from "./forms/Groups";
import { XMLSourceEditor } from "./SourceEditor";

const logger = scopedLogger("../components/DFUWorkunitDetails.tsx");

const createField = (label: string, value: any): Field => {
return { label, type: typeof value === "number" ? "number" : "string", value, readonly: true };
};

type FieldMap = { key: string, label: string };
const sourceFieldIds: FieldMap[] = [
{ key: "SourceIP", label: nlsHPCC.IP },
{ key: "SourceDirectory", label: nlsHPCC.Directory },
{ key: "SourceFilePath", label: nlsHPCC.FilePath },
{ key: "SourceLogicalName", label: nlsHPCC.LogicalName },
{ key: "SourceNumParts", label: nlsHPCC.NumberofParts },
{ key: "SourceDali", label: nlsHPCC.Dali },
{ key: "SourceFormat", label: nlsHPCC.Format },
{ key: "SourceRecordSize", label: nlsHPCC.RecordSize },
{ key: "RowTag", label: nlsHPCC.RowTag },
{ key: "SourceCsvSeparate", label: nlsHPCC.Separators },
{ key: "SourceCsvEscape", label: nlsHPCC.Escape },
{ key: "SourceCsvTerminate", label: nlsHPCC.Terminators },
{ key: "SourceCsvQuote", label: nlsHPCC.Quote }
];
const targetFieldIds: FieldMap[] = [
{ key: "DestIP", label: nlsHPCC.IP },
{ key: "DestDirectory", label: nlsHPCC.Directory },
{ key: "DestFilePath", label: nlsHPCC.FilePath },
{ key: "DestLogicalName", label: nlsHPCC.LogicalName },
{ key: "DestGroupName", label: nlsHPCC.GroupName },
{ key: "DestNumParts", label: nlsHPCC.NumberofParts },
{ key: "DestFormat", label: nlsHPCC.Format },
{ key: "DestRecordSize", label: nlsHPCC.RecordSize }
];

interface DFUWorkunitDetailsProps {
wuid: string;
tab?: string;
Expand All @@ -27,6 +59,10 @@ export const DFUWorkunitDetails: React.FunctionComponent<DFUWorkunitDetailsProps
const [workunit, , , , refresh] = useDfuWorkunit(wuid, true);
const [wuXML, setWuXML] = React.useState("");
const [jobname, setJobname] = React.useState("");
const [sourceFormatMessage, setSourceFormatMessage] = React.useState("");
const [sourceFields, setSourceFields] = React.useState<Fields>();
const [targetFormatMessage, setTargetFormatMessage] = React.useState("");
const [targetFields, setTargetFields] = React.useState<Fields>();
const [_protected, setProtected] = React.useState(false);

const [showMessageBar, setShowMessageBar] = React.useState(false);
Expand All @@ -53,9 +89,44 @@ export const DFUWorkunitDetails: React.FunctionComponent<DFUWorkunitDetailsProps
}, [workunit]);

React.useEffect(() => {
if (!workunit) return;
setJobname(workunit?.JobName);
setProtected(workunit?.isProtected);
}, [workunit?.JobName, workunit?.isProtected]);

const sourceFormatMsg = FileSpray.FormatMessages[workunit?.SourceFormat];
if (sourceFormatMsg === "csv") {
setSourceFormatMessage(`(${nlsHPCC.CSV})`);
} else if (sourceFormatMsg === "fixed") {
setSourceFormatMessage(`(${nlsHPCC.Fixed})`);
} else if (!!workunit?.RowTag) {
setSourceFormatMessage(`(${nlsHPCC.XML}/${nlsHPCC.JSON})`);
}

const _sourceFields: Fields = {};
for (const fieldId of sourceFieldIds) {
if (workunit[fieldId.key] !== undefined) {
const value = fieldId.key === "SourceFormat" ? FileSpray.FormatMessages[workunit[fieldId.key]] : workunit[fieldId.key];
_sourceFields[fieldId.key] = createField(fieldId.label, value ?? null);
}
}
setSourceFields(_sourceFields);

const destFormatMsg = FileSpray.FormatMessages[workunit?.DestFormat];
if (destFormatMsg === "csv") {
setTargetFormatMessage(`(${nlsHPCC.CSV})`);
} else if (destFormatMsg === "fixed") {
setTargetFormatMessage(`(${nlsHPCC.Fixed})`);
}

const _targetFields: Fields = {};
for (const fieldId of targetFieldIds) {
if (workunit[fieldId.key] !== undefined) {
const value = fieldId.key === "DestFormat" ? FileSpray.FormatMessages[workunit[fieldId.key]] : workunit[fieldId.key];
_targetFields[fieldId.key] = createField(fieldId.label, value ?? null);
}
}
setTargetFields(_targetFields);
}, [workunit]);

const canSave = React.useMemo(() => {
return jobname !== workunit?.JobName || _protected !== workunit?.isProtected;
Expand Down Expand Up @@ -161,23 +232,11 @@ export const DFUWorkunitDetails: React.FunctionComponent<DFUWorkunitDetailsProps
}
}} />
<hr />
<h2>{nlsHPCC.Source} ({nlsHPCC.Fixed})</h2>
<TableGroup fields={{
"ip": { label: nlsHPCC.IP, type: "string", value: workunit?.SourceIP, readonly: true },
"directory": { label: nlsHPCC.Directory, type: "string", value: workunit?.SourceDirectory, readonly: true },
"filePath": { label: nlsHPCC.FilePath, type: "string", value: workunit?.SourceFilePath, readonly: true },
"numParts": { label: nlsHPCC.NumberofParts, type: "number", value: workunit?.SourceNumParts, readonly: true },
"format": { label: nlsHPCC.Format, type: "string", value: FileSpray.FormatMessages[workunit?.SourceFormat], readonly: true },
"recordSize": { label: nlsHPCC.RecordSize, type: "number", value: workunit?.SourceRecordSize, readonly: true },
}} />
<h2>{nlsHPCC.Source} {sourceFormatMessage}</h2>
<TableGroup fields={sourceFields} />
<hr />
<h2>{nlsHPCC.Target}</h2>
<TableGroup fields={{
"directory": { label: nlsHPCC.Directory, type: "string", value: workunit?.DestDirectory, readonly: true },
"logicalName": { label: nlsHPCC.LogicalName, type: "string", value: workunit?.DestLogicalName, readonly: true },
"groupName": { label: nlsHPCC.GroupName, type: "string", value: workunit?.DestGroupName, readonly: true },
"numParts": { label: nlsHPCC.NumberofParts, type: "number", value: workunit?.DestNumParts, readonly: true },
}} />
<h2>{nlsHPCC.Target} {targetFormatMessage}</h2>
<TableGroup fields={targetFields} />
<hr />
<h2>{nlsHPCC.Other}</h2>
<TableGroup fields={{
Expand Down
3 changes: 2 additions & 1 deletion esp/src/src-react/components/EventScheduler.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,8 @@ import { useMyAccount } from "../hooks/user";
const logger = scopedLogger("src-react/components/EventScheduler.tsx");

const FilterFields: Fields = {
"EventName": { type: "string", label: nlsHPCC.EventName },
"EventName": { type: "string", label: nlsHPCC.EventName, placeholder: nlsHPCC.EventNamePH },
"JobName": { type: "string", label: nlsHPCC.JobName, placeholder: nlsHPCC.log_analysis_1 },
"State": { type: "workunit-state", label: nlsHPCC.State, placeholder: "" },
"Owner": { type: "string", label: nlsHPCC.Owner, placeholder: nlsHPCC.jsmi },
"EventText": { type: "string", label: nlsHPCC.EventText, placeholder: nlsHPCC.EventTextPH },
Expand Down
36 changes: 0 additions & 36 deletions esp/src/src-react/components/Frame.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -90,42 +90,6 @@ export const Frame: React.FunctionComponent<FrameProps> = () => {
return () => unlisten();
}, []);

React.useEffect(() => {
initSession();

topic.subscribe("hpcc/session_management_status", function (publishedMessage) {
if (publishedMessage.status === "Unlocked") {
unlock();
} else if (publishedMessage.status === "Locked") {
lock();
} else if (publishedMessage.status === "DoIdle") {
fireIdle();
} else if (publishedMessage.status === "Idle") {
window.localStorage.setItem("pageOnLock", window.location.hash.substring(1));
setUserSession({ ...userSession, Status: "Locked" });
window.location.reload();
}
});
}, [setUserSession, userSession]);

React.useEffect(() => {
initSession();

topic.subscribe("hpcc/session_management_status", function (publishedMessage) {
if (publishedMessage.status === "Unlocked") {
unlock();
} else if (publishedMessage.status === "Locked") {
lock();
} else if (publishedMessage.status === "DoIdle") {
fireIdle();
} else if (publishedMessage.status === "Idle") {
window.localStorage.setItem("pageOnLock", window.location.hash.substring(1));
setUserSession({ ...userSession, Status: "Locked" });
window.location.reload();
}
});
}, [setUserSession, userSession]);

React.useEffect(() => {
document.title = `${showEnvironmentTitle && environmentTitle.length ? environmentTitle : "ECL Watch "}${locationPathname.split("/").join(" | ")}`;
}, [environmentTitle, locationPathname, showEnvironmentTitle]);
Expand Down
40 changes: 29 additions & 11 deletions esp/src/src-react/components/Logs.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { GetLogsExRequest, TargetAudience, LogType } from "@hpcc-js/comms";
import { Level } from "@hpcc-js/util";
import { CreateLogsQueryStore } from "src/ESPLog";
import nlsHPCC from "src/nlsHPCC";
import { logColor } from "src/Utility";
import { logColor, wuidToDate, wuidToTime } from "src/Utility";
import { HolyGrail } from "../layouts/HolyGrail";
import { pushParams } from "../util/history";
import { FluentPagedGrid, FluentPagedFooter, useCopyButtons, useFluentStoreState, FluentColumns } from "./controls/Grid";
Expand All @@ -14,7 +14,8 @@ import { Fields } from "./forms/Fields";
import { ShortVerticalDivider } from "./Common";

const maximumTimeUntilRefresh = 8 * 60 * 60 * 1000;
const startTimeOffset = 6 * 60 * 60 * 1000;
const startTimeOffset = 1 * 60 * 60 * 1000;
const endTimeOffset = 23 * 60 * 60 * 1000;
const defaultStartDate = new Date(new Date().getTime() - startTimeOffset);

const FilterFields: Fields = {
Expand Down Expand Up @@ -62,7 +63,8 @@ function formatQuery(_request: any): Partial<GetLogsExRequest> {
interface LogsProps {
wuid?: string;
filter?: Partial<GetLogsExRequest>;
page?: number
page?: number;
setLogCount?: (count: number | string) => void;
}
export const defaultFilter: Partial<GetLogsExRequest> = { StartDate: defaultStartDate };

Expand All @@ -83,7 +85,8 @@ const levelMap = (level) => {
export const Logs: React.FunctionComponent<LogsProps> = ({
wuid,
filter = defaultFilter,
page
page,
setLogCount
}) => {

const hasFilter = React.useMemo(() => Object.keys(filter).length > 0, [filter]);
Expand All @@ -103,12 +106,21 @@ export const Logs: React.FunctionComponent<LogsProps> = ({
const query = React.useMemo(() => {
if (wuid !== undefined) {
filter.workunits = wuid;
}
if (typeof filter.StartDate === "string") {
filter.StartDate = new Date(filter.StartDate);
}
if (filter.StartDate && now.getTime() - filter.StartDate.getTime() > maximumTimeUntilRefresh) {
filter.StartDate = new Date(now.getTime() - startTimeOffset);
if (typeof filter.StartDate === "string") {
filter.StartDate = new Date(filter.StartDate + ":00Z");
} else {
filter.StartDate = new Date(`${wuidToDate(wuid)}T${wuidToTime(wuid)}Z`);
}
} else {
if (typeof filter.StartDate === "string") {
filter.StartDate = new Date(filter.StartDate + ":00Z");
}
if (filter.StartDate && now.getTime() - filter.StartDate.getTime() > maximumTimeUntilRefresh) {
filter.StartDate = new Date(now.getTime() - startTimeOffset);
}
if (!filter.EndDate) {
filter.EndDate = new Date(now.getTime() + endTimeOffset);
}
}
return formatQuery(filter);
}, [filter, now, wuid]);
Expand Down Expand Up @@ -157,6 +169,7 @@ export const Logs: React.FunctionComponent<LogsProps> = ({
for (const field in FilterFields) {
retVal[field] = { ...FilterFields[field], value: filter[field] };
if (wuid !== undefined) {
delete filter.workunits;
delete retVal.jobId;
}
}
Expand All @@ -175,7 +188,12 @@ export const Logs: React.FunctionComponent<LogsProps> = ({
total={total}
columns={columns}
setSelection={setSelection}
setTotal={setTotal}
setTotal={(total) => {
setTotal(total);
if (setLogCount) {
setLogCount(total);
}
}}
refresh={refreshTable}
></FluentPagedGrid>
<Filter showFilter={showFilter} setShowFilter={setShowFilter} filterFields={filterFields} onApply={pushParams} />
Expand Down
13 changes: 4 additions & 9 deletions esp/src/src-react/components/WorkunitDetails.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ 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 { hasLogAccess } from "src/ESPLog";
import { useWorkunit } from "../hooks/workunit";
import { useUserTheme } from "../hooks/theme";
import { useDeepEffect } from "../hooks/deepHooks";
Expand Down Expand Up @@ -64,13 +64,8 @@ export const WorkunitDetails: React.FunctionComponent<WorkunitDetailsProps> = ({
hasLogAccess().then(response => {
setLogsDisabled(!response);
return response;
}).then(hasLogAccess => {
if (hasLogAccess) {
service.GetLogsEx({ ...queryParams, workunits: wuid, LogLineStartFrom: 0, LogLineLimit: 10 }).then(response => { // HPCC-27711 - Requesting LogLineLimit=1 causes issues
setLogCount(response.total);
}).catch((err) => logger.error(err));
}
}).catch(() => {
}).catch(err => {
logger.warning(err);
setLogsDisabled(true);
});
}, [wuid], [queryParams]);
Expand Down Expand Up @@ -116,7 +111,7 @@ export const WorkunitDetails: React.FunctionComponent<WorkunitDetailsProps> = ({
}
</PivotItem>
<PivotItem headerText={nlsHPCC.Logs} itemKey="logs" itemCount={logCount} headerButtonProps={logsDisabled ? { disabled: true, style: { background: themeV9.colorNeutralBackgroundDisabled, color: themeV9.colorNeutralForegroundDisabled } } : {}} style={pivotItemStyle(size, 0)}>
<Logs wuid={wuid} filter={queryParams} />
<Logs wuid={wuid} filter={queryParams} setLogCount={setLogCount} />
</PivotItem>
<PivotItem headerText={nlsHPCC.ECL} itemKey="eclsummary" style={pivotItemStyle(size, 0)}>
<DojoAdapter widgetClassID="ECLArchiveWidget" params={{ Wuid: wuid }} />
Expand Down
3 changes: 1 addition & 2 deletions esp/src/src-react/components/WorkunitsDashboard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import { chain, filter, group, map, sort } from "@hpcc-js/dataflow";
import * as Observable from "dojo/store/Observable";
import * as ESPWorkunit from "src/ESPWorkunit";
import nlsHPCC from "src/nlsHPCC";
import { wuidToDate } from "src/Utility";
import { Memory } from "src/store/Memory";
import { Chip } from "./controls/Chip";
import { pushParamExact } from "../util/history";
Expand All @@ -32,8 +33,6 @@ const innerStackTokens: IStackTokens = {

const service = new WorkunitsService({ baseUrl: "" });

const wuidToDate = (wuid: string) => `${wuid.substr(1, 4)}-${wuid.substr(5, 2)}-${wuid.substr(7, 2)}`;

interface WorkunitEx extends WUQuery.ECLWorkunit {
Day: string;
}
Expand Down
2 changes: 1 addition & 1 deletion esp/src/src-react/components/forms/Fields.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -369,7 +369,7 @@ interface CloudContainerNameField extends BaseField {
value?: string;
}

type Field = StringField | NumericField | CheckboxField | ChoiceGroupField | DateTimeField | DropdownField | DropdownMultiField |
export type Field = StringField | NumericField | CheckboxField | ChoiceGroupField | DateTimeField | DropdownField | DropdownMultiField |
LinkField | LinksField | ProgressField |
WorkunitStateField |
FileTypeField | FileSortByField |
Expand Down
4 changes: 2 additions & 2 deletions esp/src/src/ESPUtil.ts
Original file line number Diff line number Diff line change
Expand Up @@ -314,10 +314,10 @@ export function goToPageUserPreference(gridName, key) {

export const MonitorLockClick = dojo.declare([Evented], {
unlocked() {
this.emit("Unlocked", {});
this.emit("unlocked", {});
},
locked() {
this.emit("Locked", {});
this.emit("locked", {});
}
});

Expand Down
8 changes: 8 additions & 0 deletions esp/src/src/Utility.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1197,4 +1197,12 @@ export function wrapStringWithTag(string, tag = "span") {

export function isSpill(sourceKind: string, targetKind: string): boolean {
return sourceKind === "2" || targetKind === "71";
}

export function wuidToDate(wuid: string): string {
return `${wuid.substring(1, 5)}-${wuid.substring(5, 7)}-${wuid.substring(7, 9)}`;
}

export function wuidToTime(wuid: string): string {
return `${wuid.substring(10, 12)}:${wuid.substring(12, 14)}:${wuid.substring(14, 16)}`;
}

0 comments on commit 893b0ca

Please sign in to comment.